From eb615fa48e2815a8cbb00cc2eb0c47b9838c46c9 Mon Sep 17 00:00:00 2001 From: lmarceau Date: Thu, 28 Nov 2024 16:30:17 -0500 Subject: [PATCH] Add FXIOS-10717 [sponsored tiles] Add feature flag for unified ads API (#23441) * Add feature flag for unified ads * Forgot to add debugKey --- .../FeatureFlags/NimbusFlaggableFeature.swift | 3 +++ .../FeatureFlagsDebugViewController.swift | 7 +++++++ .../Client/Nimbus/NimbusFeatureFlagLayer.swift | 8 ++++++++ firefox-ios/nimbus-features/unifiedAds.yaml | 18 ++++++++++++++++++ firefox-ios/nimbus.fml.yaml | 1 + 5 files changed, 37 insertions(+) create mode 100644 firefox-ios/nimbus-features/unifiedAds.yaml diff --git a/firefox-ios/Client/FeatureFlags/NimbusFlaggableFeature.swift b/firefox-ios/Client/FeatureFlags/NimbusFlaggableFeature.swift index 0e67825834e0..e1a29e8acffb 100644 --- a/firefox-ios/Client/FeatureFlags/NimbusFlaggableFeature.swift +++ b/firefox-ios/Client/FeatureFlags/NimbusFlaggableFeature.swift @@ -42,6 +42,7 @@ enum NimbusFeatureFlagID: String, CaseIterable { case searchHighlights case sentFromFirefox case splashScreen + case unifiedAds case unifiedSearch case toolbarRefactor case toolbarOneTapNewTab @@ -64,6 +65,7 @@ enum NimbusFeatureFlagID: String, CaseIterable { .toolbarRefactor, .trackingProtectionRefactor, .passwordGenerator, + .unifiedAds, .unifiedSearch: return rawValue + PrefsKeys.FeatureFlags.DebugSuffixKey default: @@ -127,6 +129,7 @@ struct NimbusFlaggableFeature: HasNimbusSearchBar { .feltPrivacyFeltDeletion, .searchHighlights, .splashScreen, + .unifiedAds, .unifiedSearch, .toolbarRefactor, .toolbarOneTapNewTab, diff --git a/firefox-ios/Client/Frontend/Settings/Main/Debug/FeatureFlags/FeatureFlagsDebugViewController.swift b/firefox-ios/Client/Frontend/Settings/Main/Debug/FeatureFlags/FeatureFlagsDebugViewController.swift index f2437e23630d..0043f024c9e5 100644 --- a/firefox-ios/Client/Frontend/Settings/Main/Debug/FeatureFlags/FeatureFlagsDebugViewController.swift +++ b/firefox-ios/Client/Frontend/Settings/Main/Debug/FeatureFlags/FeatureFlagsDebugViewController.swift @@ -88,6 +88,13 @@ final class FeatureFlagsDebugViewController: SettingsTableViewController, Featur ) { [weak self] _ in self?.reloadView() }, + FeatureFlagsBoolSetting( + with: .unifiedAds, + titleText: format(string: "Enable Unified Ads"), + statusText: format(string: "Toggle to use unified ads API") + ) { [weak self] _ in + self?.reloadView() + }, FeatureFlagsBoolSetting( with: .unifiedSearch, titleText: format(string: "Enable Unified Search"), diff --git a/firefox-ios/Client/Nimbus/NimbusFeatureFlagLayer.swift b/firefox-ios/Client/Nimbus/NimbusFeatureFlagLayer.swift index a6fe7c497156..6b9a3400cec2 100644 --- a/firefox-ios/Client/Nimbus/NimbusFeatureFlagLayer.swift +++ b/firefox-ios/Client/Nimbus/NimbusFeatureFlagLayer.swift @@ -103,6 +103,9 @@ final class NimbusFeatureFlagLayer { case .toolbarRefactor: return checkToolbarRefactorFeature(from: nimbus) + case .unifiedAds: + return checkUnifiedAdsFeature(from: nimbus) + case .unifiedSearch: return checkUnifiedSearchFeature(from: nimbus) @@ -204,6 +207,11 @@ final class NimbusFeatureFlagLayer { return config.enabled } + private func checkUnifiedAdsFeature(from nimbus: FxNimbus) -> Bool { + let config = nimbus.features.unifiedAds.value() + return config.enabled + } + private func checkUnifiedSearchFeature(from nimbus: FxNimbus) -> Bool { let config = nimbus.features.toolbarRefactorFeature.value() return config.unifiedSearch diff --git a/firefox-ios/nimbus-features/unifiedAds.yaml b/firefox-ios/nimbus-features/unifiedAds.yaml new file mode 100644 index 000000000000..553c89bfe409 --- /dev/null +++ b/firefox-ios/nimbus-features/unifiedAds.yaml @@ -0,0 +1,18 @@ +# The configuration for the unifiedAds feature +features: + unified-ads: + description: > + This property is for managing the roll out of the unified ads API + variables: + enabled: + description: > + If true, we will enable user to use the unified ads API + type: Boolean + default: false + defaults: + - channel: beta + value: + enabled: false + - channel: developer + value: + enabled: false diff --git a/firefox-ios/nimbus.fml.yaml b/firefox-ios/nimbus.fml.yaml index bc98c00ade8f..6158b4259ddd 100644 --- a/firefox-ios/nimbus.fml.yaml +++ b/firefox-ios/nimbus.fml.yaml @@ -43,4 +43,5 @@ include: - nimbus-features/toolbarRefactorFeature.yaml - nimbus-features/tosFeature.yaml - nimbus-features/trackingProtectionRefactor.yaml + - nimbus-features/unifiedAds.yaml - nimbus-features/zoomFeature.yaml