Skip to content
This repository has been archived by the owner on Feb 24, 2025. It is now read-only.

Commit

Permalink
Add .enable option for feature flag (#1223)
Browse files Browse the repository at this point in the history
**Required**:

Task/Issue URL:  https://app.asana.com/0/0/1209364252386095/f

iOS PR:  duckduckgo/iOS#3952
macOS PR: duckduckgo/macos-browser#3854
What kind of version bump will this require?: Minor

**Optional**:

Tech Design URL:
CC:

**Description**:
Adds a new .enable option for Feature Flags which doesn’t require
privacy config checks.
Counterpart of “.disable"
  • Loading branch information
Bunn authored Feb 10, 2025
1 parent f0db997 commit 7356a39
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ public enum FeatureFlagSource {
/// Completely disabled in all configurations
case disabled

/// Completely enabled in all configurations
case enabled

/// Enabled for internal users only. Cannot be toggled remotely
case internalOnly((any FeatureFlagCohortDescribing)? = nil)

Expand Down Expand Up @@ -333,6 +336,8 @@ public class DefaultFeatureFlagger: FeatureFlagger {
switch featureFlag.source {
case .disabled:
return false
case .enabled:
return true
case .internalOnly:
return internalUserDecider.isInternalUser
case .remoteDevelopment(let featureType):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ final class DefaultFeatureFlaggerTests: XCTestCase {
XCTAssertFalse(featureFlagger.isFeatureOn(for: FeatureFlagSource.disabled))
}

func testWhenEnabled_sourceEnabled_returnsTrue() {
let featureFlagger = createFeatureFlagger()
XCTAssertTrue(featureFlagger.isFeatureOn(for: FeatureFlagSource.enabled))
}

func testWhenInternalOnly_returnsIsInternalUserValue() {
let featureFlagger = createFeatureFlagger()
internalUserDeciderStore.isInternalUser = false
Expand Down

0 comments on commit 7356a39

Please sign in to comment.