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

experiment overrides #1195

Merged
merged 13 commits into from
Feb 3, 2025
Merged

experiment overrides #1195

merged 13 commits into from
Feb 3, 2025

Conversation

SabrinaTardio
Copy link
Contributor

@SabrinaTardio SabrinaTardio commented Jan 27, 2025

Please review the release process for BrowserServicesKit here.

Required:

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/Minor/Patch

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

Steps to test this PR:

  1. CI is green
  2. See platforms

OS Testing:

  • iOS 14
  • iOS 15
  • iOS 16
  • macOS 10.15
  • macOS 11
  • macOS 12

Internal references:

Software Engineering Expectations
Technical Design Template

@SabrinaTardio SabrinaTardio changed the title Sabrina/experiment overrides2 experiment overrides Jan 27, 2025
@SabrinaTardio SabrinaTardio marked this pull request as ready for review January 31, 2025 08:56
@SabrinaTardio SabrinaTardio requested a review from ayoy January 31, 2025 12:06
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.

Thanks for this @SabrinaTardio! It's looking great, and I'm excited to move on to testing and reviewing platform PRs :) I'm dropping a bunch of naming comments, but feel free to push back as needed!

@@ -20,6 +20,11 @@ import Combine
import Foundation
import Persistence

/// A protocol for retrieving the current experiment cohort for feature flags if one has already been assigned.
protocol CurrentExperimentCohortProvider {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's rename it as CurrentExperimentCohortProviding, and I think it should be moved to FeatureFlagger.swift, below FlagCohort.

@@ -18,7 +18,16 @@

import Foundation

public protocol FlagCohort: RawRepresentable, CaseIterable where RawValue == CohortID {}
public protocol FlagCohort: CaseIterable, RawRepresentable where RawValue == CohortID {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's rename it as FeatureFlagCohortDescribing and ideally move it below FeatureFlagDescribing. It would also benefit from a bit of documentation.

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 think I prefer the simpler version… also this was already the result of discussion and agreements

Copy link
Contributor

Choose a reason for hiding this comment

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

Then I see two issues with it:

  • it doesn't follow protocol naming that should use a gerund.
  • for something that's dependent on FeatureFlagDescribing, it doesn't follow the naming so we should rename the latter too.

func getCohortIfEnabled<Flag: FeatureFlagExperimentDescribing>(for featureFlag: Flag) -> (any FlagCohort)?
/// > Note: Setting `allowOverride` to `false` skips checking local overrides. This can be used
/// when the non-overridden feature flag value is required.
func getCohortIfEnabled<Flag: FeatureFlagDescribing>(for featureFlag: Flag, allowOverride: Bool) -> (any FlagCohort)?
Copy link
Contributor

Choose a reason for hiding this comment

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

This function name looks too verbose, I'd say that cohort(for featureFlag:, allowOverride:) would work fine. Alternatives: activeCohort, effectiveCohort (effective because it's a combination of assigned + overridden, similar to NSAppearance.effectiveAppearance).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

also on this I am not too keen in changing it since it was the result of different discussions.
We can also revisit some naming in the future as it evolves.

@@ -304,8 +306,8 @@ public class DefaultFeatureFlagger: FeatureFlagger {
case .remoteReleasable(let featureType),
.remoteDevelopment(let featureType) where internalUserDecider.isInternalUser:
if case .subfeature(let subfeature) = featureType {
if let resolvedCohortID = getCohortIfEnabled(subfeature) {
return Flag.CohortType.allCases.first { return $0.rawValue == resolvedCohortID }
if let resolvedCohortID = getCohortIfEnabled(subfeature, allowCohortReassignment: allowCohortAssignment) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we stick to either assignment or reassignment?

@@ -20,6 +20,11 @@ import Combine
import Foundation
import Persistence

/// A protocol for retrieving the current experiment cohort for feature flags if one has already been assigned.
protocol CurrentExperimentCohortProvider {
func getCurrentCohortIfAssigned<Flag: FeatureFlagDescribing>(for featureFlag: Flag) -> (any FlagCohort)?
Copy link
Contributor

Choose a reason for hiding this comment

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

would assignedCohort(for featureFlag:) work well?

@SabrinaTardio
Copy link
Contributor Author

SabrinaTardio commented Jan 31, 2025

Thanks for this @SabrinaTardio! It's looking great, and I'm excited to move on to testing and reviewing platform PRs :) I'm dropping a bunch of naming comments, but feel free to push back as needed!

Just for transparency, I’ll address things/ask others opinion on major API changes on Monday

@SabrinaTardio SabrinaTardio requested a review from ayoy February 3, 2025 10:42
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.

Great job on this! Thanks for taking time to make the changes 🙏 💪

@SabrinaTardio SabrinaTardio merged commit 4376de0 into main Feb 3, 2025
8 checks passed
@SabrinaTardio SabrinaTardio deleted the sabrina/experiment-overrides2 branch February 3, 2025 13:54
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