diff --git a/DuckDuckGo/AppDelegate/AppDelegate.swift b/DuckDuckGo/AppDelegate/AppDelegate.swift index 7b8432e427..6ae7e3f113 100644 --- a/DuckDuckGo/AppDelegate/AppDelegate.swift +++ b/DuckDuckGo/AppDelegate/AppDelegate.swift @@ -215,17 +215,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate, FileDownloadManagerDel #endif } - // Temporary feature flag tester, to validate that phased rollouts are working as intended. - // This is to be removed before the end of August 2023. - lazy var featureFlagTester: PhasedRolloutFeatureFlagTester = { - return PhasedRolloutFeatureFlagTester() - }() - func applicationDidBecomeActive(_ notification: Notification) { syncService?.initializeIfNeeded(isInternalUser: internalUserDecider?.isInternalUser ?? false) syncService?.scheduler.notifyAppLifecycleEvent() - - featureFlagTester.sendFeatureFlagEnabledPixelIfNecessary() } func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply { diff --git a/DuckDuckGo/Main/View/MainViewController.swift b/DuckDuckGo/Main/View/MainViewController.swift index d13b2fbed0..00520a118a 100644 --- a/DuckDuckGo/Main/View/MainViewController.swift +++ b/DuckDuckGo/Main/View/MainViewController.swift @@ -85,6 +85,7 @@ final class MainViewController: NSViewController { view.registerForDraggedTypes([.URL, .fileURL]) registerForBookmarkBarPromptNotifications() + registerForDidBecomeActiveNotifications() } var bookmarkBarPromptObserver: Any? @@ -124,6 +125,19 @@ final class MainViewController: NSViewController { updateDividerColor() } + func registerForDidBecomeActiveNotifications() { + NotificationCenter.default.addObserver(self, + selector: #selector(applicationDidBecomeActive), + name: NSApplication.didBecomeActiveNotification, + object: nil) + } + + @objc func applicationDidBecomeActive() { + // Temporary feature flag tester, to validate that phased rollouts are working as intended. + // This is to be removed before the end of August 2023. + PhasedRolloutFeatureFlagTester.shared.sendFeatureFlagEnabledPixelIfNecessary() + } + override func viewDidLayout() { findInPageContainerView.applyDropShadow() } diff --git a/DuckDuckGo/NetworkProtection/PhasedRolloutFeatureFlagTester.swift b/DuckDuckGo/NetworkProtection/PhasedRolloutFeatureFlagTester.swift index 5129aec131..c4ddb5edc0 100644 --- a/DuckDuckGo/NetworkProtection/PhasedRolloutFeatureFlagTester.swift +++ b/DuckDuckGo/NetworkProtection/PhasedRolloutFeatureFlagTester.swift @@ -37,6 +37,8 @@ final class PhasedRolloutFeatureFlagTester { static let hasSentPixelKey = "network-protection.incremental-feature-flag-test.has-sent-pixel" } + static let shared = PhasedRolloutFeatureFlagTester() + private let privacyConfigurationManager: PrivacyConfigurationManaging private let pixelSender: PhasedRolloutPixelSender private let userDefaults: UserDefaults @@ -56,6 +58,7 @@ final class PhasedRolloutFeatureFlagTester { } markPixelAsSent() + pixelSender.sendPixel { [weak self] error in if error != nil { self?.markPixelAsUnsent()