Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for feature flags overrides #3892

Merged
merged 13 commits into from
Feb 3, 2025

Conversation

SabrinaTardio
Copy link
Contributor

@SabrinaTardio SabrinaTardio commented Jan 29, 2025

Task/Issue URL: https://app.asana.com/0/1204186595873227/1209266907041599/f
Tech Design URL: https://app.asana.com/0/1204186595873227/1209266907041602/f
CC:

Description: Moves experiment flag to be part of FeatureFlag (conforming to FeatureFlagDescribing). This allows to extend macOS local overrides to experiment (that will be also added to iOS in a follow up PR)

Steps to test this PR:
Non Internal user

  1. Run the app
  2. Go to settings all debug options toggle Internal User State off
  3. Go to settings all debug options-> Feature Flags -> You should be invited to set internal user state

Feature Flag Override

  1. Run the app
  2. Go to settings all debug options toggle Internal User State on
  3. Go to settings all debug options-> Feature Flags, There are two sections: feature flags and experiments
  4. Test testExperiment- Default state should be true.
  5. Toggle it off and check that the default value is still indicated as true, go back to the main settings menu and check that zoom setting is not available
  6. Toggle it on again and check that the zoom setting is again visible
  7. Toggle the feature off and then press on reset and check that the zoom setting is again visible

Experiment Override

  1. Run the app
  2. Go to settings all debug options toggle Internal User State on
  3. Go to settings all debug options-> Feature Flags, There are two sections: feature flags and experiments
  4. Test testExperiment- Default state should be one between treatment and control, (according to what you see printed in the debuggerCOHORT A or COHORT B)
  5. Click on it and you should see a new page: It should have the right cohort checked and the reset menu item disabled
  6. Click on the other cohort and check you get the expected COHORT printed on the debugger, check that the default value stays the same and that the reset is now enabled.
  7. Navigate back and check that the current state of the cohort matches.
  8. Navigate in the experiment menu again and test reset works as expected (COHORT print and state of the menus)

Reset All Overrides

  1. Run the app
  2. Go to settings all debug options toggle Internal User State on
  3. Go to settings all debug options-> Feature Flags, There are two sections: feature flags and experiments
  4. Turn zoom flag off and override the experiment cohort
  5. press “Reset All Overrides and check that the values go back to their default

Test text Zoom -? Default state should be true, Try to toggle it off and check that when visiting a site there is no option to zoom in the settings, use reset and/or toggle to turn it on again and check the Zoom option reappears
and check it behaves as expected and the menu item reports the expected state
You should see one experiment with a default value that can be either control or treatment: (you’ll see COHORT A or COHORT B printed accordingly)
Try and select a cohort to override and check the print is changed accordingly
Test that “Remove override” comes back to the default state
Test that switch to [cohort] behaves as expected (print and menu item state]
Check that "Remove all overrides” works for both feature flags and experiments.

<!—
Before submitting a PR, please ensure you have tested the combinations you expect the reviewer to test, then delete configurations you know do not need explicit testing.

Using a simulator where a physical device is unavailable is acceptable.
—>

Definition of Done (Internal Only):

Copy Testing:

  • Use of correct apostrophes in new copy, ie rather than

Orientation Testing:

  • Portrait
  • Landscape

Device Testing:

  • iPhone SE (1st Gen)
  • iPhone 8
  • iPhone X
  • iPhone 14 Pro
  • iPad

OS Testing:

  • iOS 15
  • iOS 16
  • iOS 17

Theme Testing:

  • Light theme
  • Dark theme

Internal references:

Software Engineering Expectations
Technical Design Template

@SabrinaTardio SabrinaTardio marked this pull request as ready for review January 31, 2025 11:06
@SabrinaTardio SabrinaTardio changed the title adjust for changes made for supporting experiment override in macOS make experiment flags conform to FeatureFlagDescribing Jan 31, 2025
@SabrinaTardio SabrinaTardio changed the title make experiment flags conform to FeatureFlagDescribing add support for feature flags overrides Jan 31, 2025
Copy link
Contributor

@aataraxiaa aataraxiaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manual testing was failing and I realized that in places where I was casting the cohort it was failing (e.g guard let cohort = freeTrialsExperiment.getCohortIfEnabled() as? FreeTrialsFeatureFlagExperiment.Cohort). So, we need to remove the FreeTrialsFeatureFlagExperiment.Cohort type and in places where it was being used update it to the new cohort you defined in BSK. Then also need to update unit tests where the original cohort was used.

I actually made the changes and tried to push, but there had been more changes and also a rebase, so probs just easier if you make them.

@SabrinaTardio
Copy link
Contributor Author

freeTrialsExperiment.getCohortIfEnabled

Manual testing was failing and I realized that in places where I was casting the cohort it was failing (e.g guard let cohort = freeTrialsExperiment.getCohortIfEnabled() as? FreeTrialsFeatureFlagExperiment.Cohort). So, we need to remove the FreeTrialsFeatureFlagExperiment.Cohort type and in places where it was being used update it to the new cohort you defined in BSK. Then also need to update unit tests where the original cohort was used.

I actually made the changes and tried to push, but there had been more changes and also a rebase, so probs just easier if you make them.

Thanks for baring with me… sorry I completely missed it cause the tests were passing… I just pushed the changes. Hopefully all is ok now

Copy link
Contributor

@aataraxiaa aataraxiaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SabrinaTardio I tested the Free Trial related changes and I was able to retrieve both control and treatment cohorts using a custom JSONBlob config. So, changes look good to me. As discussed on MM, I leave the main review, testing and approval to @ayoy .

@SabrinaTardio
Copy link
Contributor Author

@SabrinaTardio I tested the Free Trial related changes and I was able to retrieve both control and treatment cohorts using a custom JSONBlob config. So, changes look good to me. As discussed on MM, I leave the main review, testing and approval to @ayoy .

Thank you so much for taking the time to test it!

Copy link

github-actions bot commented Feb 3, 2025

Warnings
⚠️ PR has more than 500 lines of code changing. Consider splitting into smaller PRs if possible.

Generated by 🚫 dangerJS against b55d920

Copy link
Contributor

@ayoy ayoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Works as expected 💪 I've fixed protocol compliance in unit tests and am leaving a comment about Localizable.xcstrings file. Thanks @SabrinaTardio!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably aren't interested in checking this file in.

SabrinaTardio added a commit to duckduckgo/BrowserServicesKit that referenced this pull request Feb 3, 2025
Task/Issue URL:
https://app.asana.com/0/1204186595873227/1209266907041599/f
iOS PR: duckduckgo/iOS#3892
macOS PR: duckduckgo/macos-browser#3798
What kind of version bump will this require?: Major

**Optional**:

Tech Design URL:
https://app.asana.com/0/1204186595873227/1209266907041602/f

**Description**:
- Experiment types will be defined as FeatureFlag enum values, with
their cohort types defined as per FeatureFlagDescribing protocol.
- Add support for overrides of experiment cohorts, Cohort type can be
used to populate local overrides menu
@SabrinaTardio SabrinaTardio merged commit 86cb666 into main Feb 3, 2025
13 checks passed
@SabrinaTardio SabrinaTardio deleted the sabrina/experiment-override-macOS branch February 3, 2025 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants