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

Check subfeature state before reading rollout data #649

Merged
merged 3 commits into from
Feb 7, 2024

Conversation

dus7
Copy link
Contributor

@dus7 dus7 commented Feb 1, 2024

Asana task(s): https://app.asana.com/0/414235014887631/1206494747562366/f

iOS PR: duckduckgo/iOS#2426
macOS PR: duckduckgo/macos-browser#2152
What kind of version bump will this require?: Patch

Description:
This fix comprises of two parts:

Fix subfeature state resolution logic

Rollout state is checked before the global subfeature state, resulting in reporting invalid reason for it being disabled. This rearranges the rollout check so it’s performed as the last one.

Fix (flaky) test

Because the test subject was given a real randomizer, it produced mixed results - in 85% of chances leaning towards an invalid value. Passing mocked randomizer makes it stable.

Steps to test this PR:

  1. Ensure CI is green

@dus7 dus7 marked this pull request as ready for review February 2, 2024 16:05
let satisfiesMinVersion = satisfiesMinVersion(subfeatureData?.minSupportedVersion, versionProvider: versionProvider)

switch subfeatureData?.state {
case PrivacyConfigurationData.State.enabled:
guard satisfiesMinVersion else { return .disabled(.appVersionNotSupported) }

return .enabled
case PrivacyConfigurationData.State.internal:
guard internalUserDecider.isInternalUser else { return .disabled(.limitedToInternalUsers) }
guard satisfiesMinVersion else { return .disabled(.appVersionNotSupported) }
Copy link
Collaborator

Choose a reason for hiding this comment

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

We probably could extract this from 202 and 205 lines to 208 to simplify logic flow

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was considering this, but it means for internal user we would enable subfeature regardless of supported version and moving these two checks before state verification would result in reporting not supported version before disabled (not sure if this is a concern). I’d prefer to keep it as it is TBH.

Copy link
Collaborator

@bwaresiak bwaresiak left a comment

Choose a reason for hiding this comment

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

LGTM! Good job!

@dus7 dus7 merged commit 2555be7 into main Feb 7, 2024
10 of 11 checks passed
@dus7 dus7 deleted the mariusz/fix-rollout-check branch February 7, 2024 08:20
samsymons added a commit that referenced this pull request Feb 8, 2024
* main:
  add alternateHtmlLoad navigation type (HTML Error Page) (#644)
  Check subfeature state before reading rollout data (#649)
  Add NavigationPreferences CustomHeaderFields (#651)
  Update autofill to 10.1.0 (#643)
  Add Autoconsent onByDefault subfeature (#647)
  Add error codes to site breakage reports (#642)
  Run unit tests also on iOS Simulator (#641)
  Improve VPN auth token storage (#639)
  Bump content-scope-scripts to 4.59.2 (#638)
  Fix `site:` queries escaping with iOS 17 SDK (#640)
  Breakage improvement (#621)
  Don't report CancellationError from BookmarksFaviconsFetcher (#634)
  Add explicit mapping of SyncError to error code (#637)
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.

2 participants