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

[MBL-975] Report This Project Feature Flag #1851

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ final class RemoteConfigFeatureFlagToolsViewControllerTests: TestCase {
RemoteConfigFeature.consentManagementDialogEnabled.rawValue: false,
RemoteConfigFeature.facebookLoginInterstitialEnabled
.rawValue: false,
RemoteConfigFeature.reportThisProjectEnabled.rawValue: false,
RemoteConfigFeature.creatorDashboardEnabled
.rawValue: false
]
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions Library/RemoteConfig/RemoteConfigFeature+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ public func featureFacebookLoginInterstitialEnabled() -> Bool {
.isFeatureEnabled(featureKey: RemoteConfigFeature.facebookLoginInterstitialEnabled) ?? false)
}

public func featureReportThisProjectEnabled() -> Bool {
return AppEnvironment.current.userDefaults
.remoteConfigFeatureFlags[RemoteConfigFeature.reportThisProjectEnabled.rawValue] ??
(AppEnvironment.current.remoteConfigClient?
.isFeatureEnabled(featureKey: RemoteConfigFeature.reportThisProjectEnabled) ?? false)
}

public func featureUseOfAIProjectTabEnabled() -> Bool {
return AppEnvironment.current.userDefaults
.remoteConfigFeatureFlags[RemoteConfigFeature.useOfAIProjectTab.rawValue] ??
Expand Down
18 changes: 18 additions & 0 deletions Library/RemoteConfig/RemoteConfigFeature+HelpersTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,24 @@ final class RemoteConfigFeatureHelpersTests: TestCase {
}
}

func testReportThisProject_RemoteConfig_FeatureFlag_True() {
let mockRemoteConfigClient = MockRemoteConfigClient()
|> \.features .~ [RemoteConfigFeature.reportThisProjectEnabled.rawValue: true]

withEnvironment(remoteConfigClient: mockRemoteConfigClient) {
XCTAssertTrue(featureReportThisProjectEnabled())
}
}

func testReportThisProject_RemoteConfig_FeatureFlag_False() {
let mockRemoteConfigClient = MockRemoteConfigClient()
|> \.features .~ [RemoteConfigFeature.reportThisProjectEnabled.rawValue: false]

withEnvironment(remoteConfigClient: mockRemoteConfigClient) {
XCTAssertFalse(featureReportThisProjectEnabled())
}
}

func testUseOfAIProjectTab_RemoteConfig_FeatureFlag_False() {
let mockRemoteConfigClient = MockRemoteConfigClient()
|> \.features .~ [RemoteConfigFeature.useOfAIProjectTab.rawValue: false]
Expand Down
2 changes: 2 additions & 0 deletions Library/RemoteConfig/RemoteConfigFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public enum RemoteConfigFeature: String, CaseIterable {
case consentManagementDialogEnabled = "consent_management_dialog"
case creatorDashboardEnabled = "creator_dashboard"
case facebookLoginInterstitialEnabled = "facebook_interstitial"
case reportThisProjectEnabled = "report_this_project"
case useOfAIProjectTab = "use_of_ai_project_tab"
}

Expand All @@ -13,6 +14,7 @@ extension RemoteConfigFeature: CustomStringConvertible {
case .consentManagementDialogEnabled: return "Consent Management Dialog"
case .creatorDashboardEnabled: return "Creator Dashboard"
case .facebookLoginInterstitialEnabled: return "Facebook Login Interstitial"
case .reportThisProjectEnabled: return "Report This Project"
case .useOfAIProjectTab: return "Use of AI Project Tab"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ private func isFeatureEnabled(_ feature: RemoteConfigFeature) -> Bool {
return featureFacebookLoginInterstitialEnabled()
case .creatorDashboardEnabled:
return featureCreatorDashboardEnabled()
case .reportThisProjectEnabled:
return featureReportThisProjectEnabled()
case .useOfAIProjectTab:
return featureUseOfAIProjectTabEnabled()
}
Expand All @@ -109,6 +111,9 @@ private func getValueFromUserDefaults(for feature: RemoteConfigFeature) -> Bool?
case .creatorDashboardEnabled:
return AppEnvironment.current.userDefaults
.remoteConfigFeatureFlags[RemoteConfigFeature.creatorDashboardEnabled.rawValue]
case .reportThisProjectEnabled:
return AppEnvironment.current.userDefaults
.remoteConfigFeatureFlags[RemoteConfigFeature.reportThisProjectEnabled.rawValue]
case .useOfAIProjectTab:
return AppEnvironment.current.userDefaults
.remoteConfigFeatureFlags[RemoteConfigFeature.useOfAIProjectTab.rawValue]
Expand All @@ -128,6 +133,9 @@ private func setValueInUserDefaults(for feature: RemoteConfigFeature, and value:
case .creatorDashboardEnabled:
return AppEnvironment.current.userDefaults
.remoteConfigFeatureFlags[RemoteConfigFeature.creatorDashboardEnabled.rawValue] = value
case .reportThisProjectEnabled:
return AppEnvironment.current.userDefaults
.remoteConfigFeatureFlags[RemoteConfigFeature.reportThisProjectEnabled.rawValue] = value
case .useOfAIProjectTab:
return AppEnvironment.current.userDefaults
.remoteConfigFeatureFlags[RemoteConfigFeature.useOfAIProjectTab.rawValue] = value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ final class RemoteConfigFlagToolsViewModelTests: TestCase {
RemoteConfigFeature.consentManagementDialogEnabled.rawValue: true,
RemoteConfigFeature.facebookLoginInterstitialEnabled.rawValue: true,
RemoteConfigFeature.creatorDashboardEnabled.rawValue: true,
RemoteConfigFeature.reportThisProjectEnabled.rawValue: true,
RemoteConfigFeature.useOfAIProjectTab.rawValue: true
]

Expand All @@ -47,6 +48,7 @@ final class RemoteConfigFlagToolsViewModelTests: TestCase {
RemoteConfigFeature.consentManagementDialogEnabled.rawValue: true,
RemoteConfigFeature.facebookLoginInterstitialEnabled.rawValue: true,
RemoteConfigFeature.creatorDashboardEnabled.rawValue: false,
RemoteConfigFeature.reportThisProjectEnabled.rawValue: false,
RemoteConfigFeature.useOfAIProjectTab.rawValue: false
]

Expand Down