From 79b944c725fc130196e0595fd983ccdcc66348ca Mon Sep 17 00:00:00 2001 From: Pete Date: Wed, 11 Sep 2024 11:05:56 +0100 Subject: [PATCH 1/2] Rename PIR to DBP --- DuckDuckGo.xcodeproj/project.pbxproj | 98 +++++++++---------- DuckDuckGo/Application/AppDelegate.swift | 14 +-- DuckDuckGo/Common/Localizables/UserText.swift | 58 +++++------ DuckDuckGo/DBP/DBPHomeViewController.swift | 8 +- ...ataBrokerProtectionFeatureGatekeeper.swift | 10 +- .../DBP/DataBrokerProtectionManager.swift | 4 +- .../FeatureFlagging/Model/FeatureFlag.swift | 4 +- .../FreemiumDBPFeature.swift} | 34 +++---- ...FreemiumDBPFirstProfileSavedNotifier.swift | 14 +-- .../FreemiumDBPPresenter.swift} | 26 ++--- ...FreemiumDBPPromotionViewCoordinating.swift | 40 ++++---- .../FreemiumDBPScanResultPolling.swift} | 42 ++++---- .../{PIR => DBP}/Logger+FreemiumDBP.swift | 0 .../NotificationName+Freemium.swift | 2 +- .../PromotionView+FreemiumDBP.swift} | 28 +++--- DuckDuckGo/Freemium/FreemiumDebugMenu.swift | 52 +++++----- DuckDuckGo/HomePage/View/PromotionView.swift | 2 +- .../NavigationBar/View/MoreOptionsMenu.swift | 42 ++++---- .../View/NavigationBarViewController.swift | 8 +- ...RemoteMessagingConfigMatcherProvider.swift | 6 +- .../Tab/View/BrowserTabViewController.swift | 12 +-- .../DataBrokerProtectionAgentManager.swift | 12 +-- .../DataBrokerProtectionAgentStopper.swift | 10 +- ...ataBrokerProtectionAgentManagerTests.swift | 54 +++++----- ...ataBrokerProtectionAgentStopperTests.swift | 74 +++++++------- .../DataBrokerProtectionTests/Mocks.swift | 2 +- ...wift => FreemiumDBPUserStateManager.swift} | 38 +++---- ...=> FreemiumDBPUserStateManagerTests.swift} | 44 ++++----- ...okerProtectionFeatureGatekeeperTests.swift | 28 +++--- .../FreemiumDBPFeatureTests.swift} | 78 +++++++-------- ...iumDBPFirstProfileSavedNotifierTests.swift | 30 +++--- .../FreemiumDBPPresenterTests.swift} | 14 +-- ...miumDBPPromotionViewCoordinatorTests.swift | 30 +++--- .../FreemiumDBPScanResultPollingTests.swift} | 82 ++++++++-------- UnitTests/Menus/MoreOptionsMenuTests.swift | 64 ++++++------ .../RemoteMessagingClientTests.swift | 2 +- 36 files changed, 532 insertions(+), 534 deletions(-) rename DuckDuckGo/Freemium/{PIR/FreemiumPIRFeature.swift => DBP/FreemiumDBPFeature.swift} (77%) rename DuckDuckGo/Freemium/{PIR => DBP}/FreemiumDBPFirstProfileSavedNotifier.swift (84%) rename DuckDuckGo/Freemium/{PIR/FreemiumPIRPresenter.swift => DBP/FreemiumDBPPresenter.swift} (64%) rename DuckDuckGo/Freemium/{PIR => DBP}/FreemiumDBPPromotionViewCoordinating.swift (83%) rename DuckDuckGo/Freemium/{PIR/FreemiumPIRScanResultPolling.swift => DBP/FreemiumDBPScanResultPolling.swift} (85%) rename DuckDuckGo/Freemium/{PIR => DBP}/Logger+FreemiumDBP.swift (100%) rename DuckDuckGo/Freemium/{PIR => DBP}/NotificationName+Freemium.swift (94%) rename DuckDuckGo/Freemium/{PIR/PromotionView+FreemiumPIR.swift => DBP/PromotionView+FreemiumDBP.swift} (79%) rename LocalPackages/Freemium/Sources/Freemium/{FreemiumPIRUserStateManager.swift => FreemiumDBPUserStateManager.swift} (81%) rename LocalPackages/Freemium/Tests/FreemiumTests/{FreemiumPIRUserStateManagerTests.swift => FreemiumDBPUserStateManagerTests.swift} (83%) rename UnitTests/Freemium/{PIR/FreemiumPIRFeatureTests.swift => DBP/FreemiumDBPFeatureTests.swift} (74%) rename UnitTests/Freemium/{PIR => DBP}/FreemiumDBPFirstProfileSavedNotifierTests.swift (76%) rename UnitTests/Freemium/{PIR/FreemiumPIRPresenterTests.swift => DBP/FreemiumDBPPresenterTests.swift} (83%) rename UnitTests/Freemium/{PIR => DBP}/FreemiumDBPPromotionViewCoordinatorTests.swift (84%) rename UnitTests/Freemium/{PIR/FreemiumPIRScanResultPollingTests.swift => DBP/FreemiumDBPScanResultPollingTests.swift} (80%) diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index ba04de15c2..7ac7de7756 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -2742,30 +2742,30 @@ C17CA7AE2B9B52E6008EC3C1 /* NavigationBarPopoversTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C17CA7AC2B9B52E6008EC3C1 /* NavigationBarPopoversTests.swift */; }; C17CA7B22B9B5317008EC3C1 /* MockAutofillPopoverPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C17CA7B12B9B5317008EC3C1 /* MockAutofillPopoverPresenter.swift */; }; C17CA7B32B9B5317008EC3C1 /* MockAutofillPopoverPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C17CA7B12B9B5317008EC3C1 /* MockAutofillPopoverPresenter.swift */; }; - C18194592C7CA9AB00381092 /* FreemiumPIRFeatureTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C18194582C7CA9AB00381092 /* FreemiumPIRFeatureTests.swift */; }; - C181945A2C7CA9AB00381092 /* FreemiumPIRFeatureTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C18194582C7CA9AB00381092 /* FreemiumPIRFeatureTests.swift */; }; + C18194592C7CA9AB00381092 /* FreemiumDBPFeatureTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C18194582C7CA9AB00381092 /* FreemiumDBPFeatureTests.swift */; }; + C181945A2C7CA9AB00381092 /* FreemiumDBPFeatureTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C18194582C7CA9AB00381092 /* FreemiumDBPFeatureTests.swift */; }; C181945C2C7CDCC700381092 /* PromotionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C181945B2C7CDCC700381092 /* PromotionView.swift */; }; C181945D2C7CDCC700381092 /* PromotionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C181945B2C7CDCC700381092 /* PromotionView.swift */; }; C181945F2C7CDD0E00381092 /* PromotionViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C181945E2C7CDD0E00381092 /* PromotionViewModel.swift */; }; C18194602C7CDD0E00381092 /* PromotionViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C181945E2C7CDD0E00381092 /* PromotionViewModel.swift */; }; - C18194642C7DF7D600381092 /* FreemiumPIRPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C18194632C7DF7D600381092 /* FreemiumPIRPresenter.swift */; }; - C18194652C7DF7D600381092 /* FreemiumPIRPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C18194632C7DF7D600381092 /* FreemiumPIRPresenter.swift */; }; - C18194672C7F60E500381092 /* FreemiumPIRPresenterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C18194662C7F60E500381092 /* FreemiumPIRPresenterTests.swift */; }; - C18194682C7F60E500381092 /* FreemiumPIRPresenterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C18194662C7F60E500381092 /* FreemiumPIRPresenterTests.swift */; }; - C1858CD22C7C971D00C9BEAB /* FreemiumPIRFeature.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1858CD12C7C971D00C9BEAB /* FreemiumPIRFeature.swift */; }; - C1858CD32C7C971D00C9BEAB /* FreemiumPIRFeature.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1858CD12C7C971D00C9BEAB /* FreemiumPIRFeature.swift */; }; + C18194642C7DF7D600381092 /* FreemiumDBPPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C18194632C7DF7D600381092 /* FreemiumDBPPresenter.swift */; }; + C18194652C7DF7D600381092 /* FreemiumDBPPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C18194632C7DF7D600381092 /* FreemiumDBPPresenter.swift */; }; + C18194672C7F60E500381092 /* FreemiumDBPPresenterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C18194662C7F60E500381092 /* FreemiumDBPPresenterTests.swift */; }; + C18194682C7F60E500381092 /* FreemiumDBPPresenterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C18194662C7F60E500381092 /* FreemiumDBPPresenterTests.swift */; }; + C1858CD22C7C971D00C9BEAB /* FreemiumDBPFeature.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1858CD12C7C971D00C9BEAB /* FreemiumDBPFeature.swift */; }; + C1858CD32C7C971D00C9BEAB /* FreemiumDBPFeature.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1858CD12C7C971D00C9BEAB /* FreemiumDBPFeature.swift */; }; C18BF9CC2C73678500ED6B8A /* Freemium in Frameworks */ = {isa = PBXBuildFile; productRef = C18BF9CB2C73678500ED6B8A /* Freemium */; }; C18BF9CE2C73678C00ED6B8A /* Freemium in Frameworks */ = {isa = PBXBuildFile; productRef = C18BF9CD2C73678C00ED6B8A /* Freemium */; }; C18BF9D02C736C9100ED6B8A /* Freemium in Frameworks */ = {isa = PBXBuildFile; productRef = C18BF9CF2C736C9100ED6B8A /* Freemium */; }; C18BF9D22C736C9700ED6B8A /* Freemium in Frameworks */ = {isa = PBXBuildFile; productRef = C18BF9D12C736C9700ED6B8A /* Freemium */; }; C1B1CBE12BE1915100B6049C /* DataImportShortcutsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1B1CBE02BE1915100B6049C /* DataImportShortcutsViewModel.swift */; }; C1B1CBE22BE1915100B6049C /* DataImportShortcutsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1B1CBE02BE1915100B6049C /* DataImportShortcutsViewModel.swift */; }; - C1C405872C7F80E50089DE8A /* PromotionView+FreemiumPIR.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1C405862C7F80E50089DE8A /* PromotionView+FreemiumPIR.swift */; }; - C1C405882C7F80E50089DE8A /* PromotionView+FreemiumPIR.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1C405862C7F80E50089DE8A /* PromotionView+FreemiumPIR.swift */; }; - C1CE84692C887CF60068913B /* FreemiumPIRScanResultPolling.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1CE84682C887CF60068913B /* FreemiumPIRScanResultPolling.swift */; }; - C1CE846A2C887CF60068913B /* FreemiumPIRScanResultPolling.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1CE84682C887CF60068913B /* FreemiumPIRScanResultPolling.swift */; }; - C1CE846C2C88868D0068913B /* FreemiumPIRScanResultPollingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1CE846B2C88868D0068913B /* FreemiumPIRScanResultPollingTests.swift */; }; - C1CE846D2C88868D0068913B /* FreemiumPIRScanResultPollingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1CE846B2C88868D0068913B /* FreemiumPIRScanResultPollingTests.swift */; }; + C1C405872C7F80E50089DE8A /* PromotionView+FreemiumDBP.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1C405862C7F80E50089DE8A /* PromotionView+FreemiumDBP.swift */; }; + C1C405882C7F80E50089DE8A /* PromotionView+FreemiumDBP.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1C405862C7F80E50089DE8A /* PromotionView+FreemiumDBP.swift */; }; + C1CE84692C887CF60068913B /* FreemiumDBPScanResultPolling.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1CE84682C887CF60068913B /* FreemiumDBPScanResultPolling.swift */; }; + C1CE846A2C887CF60068913B /* FreemiumDBPScanResultPolling.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1CE84682C887CF60068913B /* FreemiumDBPScanResultPolling.swift */; }; + C1CE846C2C88868D0068913B /* FreemiumDBPScanResultPollingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1CE846B2C88868D0068913B /* FreemiumDBPScanResultPollingTests.swift */; }; + C1CE846D2C88868D0068913B /* FreemiumDBPScanResultPollingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1CE846B2C88868D0068913B /* FreemiumDBPScanResultPollingTests.swift */; }; C1D8BE452C1739E70057E426 /* DataBrokerProtectionMocks.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1D8BE442C1739E70057E426 /* DataBrokerProtectionMocks.swift */; }; C1D8BE462C1739EC0057E426 /* DataBrokerProtectionMocks.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1D8BE442C1739E70057E426 /* DataBrokerProtectionMocks.swift */; }; C1DAF3B52B9A44860059244F /* AutofillPopoverPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1DAF3B42B9A44860059244F /* AutofillPopoverPresenter.swift */; }; @@ -4546,16 +4546,16 @@ C168B9AB2B31DC7E001AFAD9 /* AutofillNeverPromptWebsitesManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AutofillNeverPromptWebsitesManager.swift; sourceTree = ""; }; C17CA7AC2B9B52E6008EC3C1 /* NavigationBarPopoversTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationBarPopoversTests.swift; sourceTree = ""; }; C17CA7B12B9B5317008EC3C1 /* MockAutofillPopoverPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockAutofillPopoverPresenter.swift; sourceTree = ""; }; - C18194582C7CA9AB00381092 /* FreemiumPIRFeatureTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FreemiumPIRFeatureTests.swift; sourceTree = ""; }; + C18194582C7CA9AB00381092 /* FreemiumDBPFeatureTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FreemiumDBPFeatureTests.swift; sourceTree = ""; }; C181945B2C7CDCC700381092 /* PromotionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PromotionView.swift; sourceTree = ""; }; C181945E2C7CDD0E00381092 /* PromotionViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PromotionViewModel.swift; sourceTree = ""; }; - C18194632C7DF7D600381092 /* FreemiumPIRPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FreemiumPIRPresenter.swift; sourceTree = ""; }; - C18194662C7F60E500381092 /* FreemiumPIRPresenterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FreemiumPIRPresenterTests.swift; sourceTree = ""; }; - C1858CD12C7C971D00C9BEAB /* FreemiumPIRFeature.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FreemiumPIRFeature.swift; sourceTree = ""; }; + C18194632C7DF7D600381092 /* FreemiumDBPPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FreemiumDBPPresenter.swift; sourceTree = ""; }; + C18194662C7F60E500381092 /* FreemiumDBPPresenterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FreemiumDBPPresenterTests.swift; sourceTree = ""; }; + C1858CD12C7C971D00C9BEAB /* FreemiumDBPFeature.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FreemiumDBPFeature.swift; sourceTree = ""; }; C1B1CBE02BE1915100B6049C /* DataImportShortcutsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataImportShortcutsViewModel.swift; sourceTree = ""; }; - C1C405862C7F80E50089DE8A /* PromotionView+FreemiumPIR.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PromotionView+FreemiumPIR.swift"; sourceTree = ""; }; - C1CE84682C887CF60068913B /* FreemiumPIRScanResultPolling.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FreemiumPIRScanResultPolling.swift; sourceTree = ""; }; - C1CE846B2C88868D0068913B /* FreemiumPIRScanResultPollingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FreemiumPIRScanResultPollingTests.swift; sourceTree = ""; }; + C1C405862C7F80E50089DE8A /* PromotionView+FreemiumDBP.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PromotionView+FreemiumDBP.swift"; sourceTree = ""; }; + C1CE84682C887CF60068913B /* FreemiumDBPScanResultPolling.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FreemiumDBPScanResultPolling.swift; sourceTree = ""; }; + C1CE846B2C88868D0068913B /* FreemiumDBPScanResultPollingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FreemiumDBPScanResultPollingTests.swift; sourceTree = ""; }; C1D8BE442C1739E70057E426 /* DataBrokerProtectionMocks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataBrokerProtectionMocks.swift; sourceTree = ""; }; C1DAF3B42B9A44860059244F /* AutofillPopoverPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutofillPopoverPresenter.swift; sourceTree = ""; }; C1E961E72B879E4D001760E1 /* MockAutofillActionPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockAutofillActionPresenter.swift; sourceTree = ""; }; @@ -8976,45 +8976,45 @@ C18194562C7CA98500381092 /* Freemium */ = { isa = PBXGroup; children = ( - C18194572C7CA99400381092 /* PIR */, + C18194572C7CA99400381092 /* DBP */, ); path = Freemium; sourceTree = ""; }; - C18194572C7CA99400381092 /* PIR */ = { + C18194572C7CA99400381092 /* DBP */ = { isa = PBXGroup; children = ( - C18194582C7CA9AB00381092 /* FreemiumPIRFeatureTests.swift */, - C18194662C7F60E500381092 /* FreemiumPIRPresenterTests.swift */, - C1CE846B2C88868D0068913B /* FreemiumPIRScanResultPollingTests.swift */, + C18194582C7CA9AB00381092 /* FreemiumDBPFeatureTests.swift */, + C18194662C7F60E500381092 /* FreemiumDBPPresenterTests.swift */, + C1CE846B2C88868D0068913B /* FreemiumDBPScanResultPollingTests.swift */, C11198332C89AEFA00F0272C /* FreemiumDBPFirstProfileSavedNotifierTests.swift */, C1351DD32C8B53500086B058 /* FreemiumDBPPromotionViewCoordinatorTests.swift */, ); - path = PIR; + path = DBP; sourceTree = ""; }; C1858CCF2C7C95DB00C9BEAB /* Freemium */ = { isa = PBXGroup; children = ( - C1858CD02C7C95E500C9BEAB /* PIR */, + C1858CD02C7C95E500C9BEAB /* DBP */, C126B3592C820924005DC2A3 /* FreemiumDebugMenu.swift */, ); path = Freemium; sourceTree = ""; }; - C1858CD02C7C95E500C9BEAB /* PIR */ = { + C1858CD02C7C95E500C9BEAB /* DBP */ = { isa = PBXGroup; children = ( - C1858CD12C7C971D00C9BEAB /* FreemiumPIRFeature.swift */, - C18194632C7DF7D600381092 /* FreemiumPIRPresenter.swift */, - C1C405862C7F80E50089DE8A /* PromotionView+FreemiumPIR.swift */, - C1CE84682C887CF60068913B /* FreemiumPIRScanResultPolling.swift */, + C1858CD12C7C971D00C9BEAB /* FreemiumDBPFeature.swift */, + C18194632C7DF7D600381092 /* FreemiumDBPPresenter.swift */, + C1C405862C7F80E50089DE8A /* PromotionView+FreemiumDBP.swift */, + C1CE84682C887CF60068913B /* FreemiumDBPScanResultPolling.swift */, C11198302C898AB500F0272C /* FreemiumDBPFirstProfileSavedNotifier.swift */, C153E7C12C8AD68D00B9BAD7 /* FreemiumDBPPromotionViewCoordinating.swift */, C153E7C42C8B21B500B9BAD7 /* Logger+FreemiumDBP.swift */, C1351DD02C8B31CE0086B058 /* NotificationName+Freemium.swift */, ); - path = PIR; + path = DBP; sourceTree = ""; }; C1D8BE422C1739BA0057E426 /* Mocks */ = { @@ -10607,7 +10607,7 @@ 1DDC84FC2B8356CE00670238 /* PreferencesDefaultBrowserView.swift in Sources */, 3706FAC8293F65D500E42796 /* AppTrackerDataSetProvider.swift in Sources */, 3706FAC9293F65D500E42796 /* EncryptionKeyGeneration.swift in Sources */, - C1CE846A2C887CF60068913B /* FreemiumPIRScanResultPolling.swift in Sources */, + C1CE846A2C887CF60068913B /* FreemiumDBPScanResultPolling.swift in Sources */, 3706FACA293F65D500E42796 /* TabLazyLoader.swift in Sources */, 3706FACC293F65D500E42796 /* SaveCredentialsViewController.swift in Sources */, 3706FACD293F65D500E42796 /* PopUpButton.swift in Sources */, @@ -10707,7 +10707,7 @@ 3706FB0B293F65D500E42796 /* DefaultBrowserPromptView.swift in Sources */, 3706FB0E293F65D500E42796 /* FaviconManager.swift in Sources */, 3706FB0F293F65D500E42796 /* ChromiumFaviconsReader.swift in Sources */, - C18194652C7DF7D600381092 /* FreemiumPIRPresenter.swift in Sources */, + C18194652C7DF7D600381092 /* FreemiumDBPPresenter.swift in Sources */, 4B0BD7B82A9FE6E600EF609D /* NetworkProtectionOnboardingMenu.swift in Sources */, 3706FB10293F65D500E42796 /* SuggestionTableRowView.swift in Sources */, 3706FB11293F65D500E42796 /* DownloadsPreferences.swift in Sources */, @@ -10889,7 +10889,7 @@ B6BCC5502AFE4F7D002C5499 /* DataImportTypePicker.swift in Sources */, 7BAF9E4B2A8A3CC9002D3B6E /* UserDefaults+NetworkProtectionShared.swift in Sources */, B6685E3D29A602D90043D2EE /* ExternalAppSchemeHandler.swift in Sources */, - C1C405882C7F80E50089DE8A /* PromotionView+FreemiumPIR.swift in Sources */, + C1C405882C7F80E50089DE8A /* PromotionView+FreemiumDBP.swift in Sources */, B6E1491029A5C30500AAFBE8 /* ContentBlockingTabExtension.swift in Sources */, 3706FB82293F65D500E42796 /* PasswordManagementNoteItemView.swift in Sources */, 4BF97AD82B43C5B300EB4240 /* NetworkProtectionAppEvents.swift in Sources */, @@ -10957,7 +10957,7 @@ 3706FBA0293F65D500E42796 /* NSTextFieldExtension.swift in Sources */, 9FA173E82B7B122E00EE4E6E /* BookmarkDialogStackedContentView.swift in Sources */, 3706FBA1293F65D500E42796 /* FireproofDomainsContainer.swift in Sources */, - C1858CD32C7C971D00C9BEAB /* FreemiumPIRFeature.swift in Sources */, + C1858CD32C7C971D00C9BEAB /* FreemiumDBPFeature.swift in Sources */, 3706FBA2293F65D500E42796 /* GeolocationService.swift in Sources */, 3706FBA3293F65D500E42796 /* FireproofingURLExtensions.swift in Sources */, 3169132A2BD2C7570051B46D /* DataBrokerProtectionErrorViewController.swift in Sources */, @@ -11195,7 +11195,6 @@ 3706FC30293F65D500E42796 /* FireInfoViewController.swift in Sources */, B6F1B02F2BCE6B47005E863C /* TunnelControllerProvider.swift in Sources */, 31A83FB62BE28D7D00F74E67 /* UserText+DBP.swift in Sources */, - 56BA1E832BAC506F001CF69F /* SSLErrorPageUserScript.swift in Sources */, C18194602C7CDD0E00381092 /* PromotionViewModel.swift in Sources */, 3706FC31293F65D500E42796 /* PermissionButton.swift in Sources */, 9F6434622BEC82B700D2D8A0 /* AttributionPixelHandler.swift in Sources */, @@ -11505,7 +11504,7 @@ C13909F52B85FD79001626ED /* AutofillDeleteAllPasswordsExecutorTests.swift in Sources */, 37D046A52C7DAA8900AEAA50 /* ImageProcessorMock.swift in Sources */, 857E44642A9F70F200ED77A7 /* CampaignVariantTests.swift in Sources */, - C181945A2C7CA9AB00381092 /* FreemiumPIRFeatureTests.swift in Sources */, + C181945A2C7CA9AB00381092 /* FreemiumDBPFeatureTests.swift in Sources */, 561D29C72BDA74F4007B91D0 /* MockDDGSyncing.swift in Sources */, 3706FE1E293F661700E42796 /* GeolocationProviderTests.swift in Sources */, 567A23CE2C80CF3D0010F66C /* SpecialErrorPageUserScriptTests.swift in Sources */, @@ -11648,7 +11647,7 @@ 84DC715A2C1C1E9000033B8C /* UserDefaultsWrapperTests.swift in Sources */, B60C6F7F29B1B41D007BFAA8 /* TestRunHelperInitializer.m in Sources */, 9F0FFFBF2BCCAF1F007C87DD /* BookmarkAllTabsDialogViewModelMock.swift in Sources */, - C1CE846D2C88868D0068913B /* FreemiumPIRScanResultPollingTests.swift in Sources */, + C1CE846D2C88868D0068913B /* FreemiumDBPScanResultPollingTests.swift in Sources */, 3706FE61293F661700E42796 /* PinnedTabsViewModelTests.swift in Sources */, 3706FE62293F661700E42796 /* PasswordManagementListSectionTests.swift in Sources */, 3706FE63293F661700E42796 /* RecentlyClosedCoordinatorMock.swift in Sources */, @@ -11678,7 +11677,7 @@ 3706FE73293F661700E42796 /* PermissionManagerMock.swift in Sources */, 3706FE74293F661700E42796 /* WebsiteDataStoreMock.swift in Sources */, 3706FE75293F661700E42796 /* WebsiteBreakageReportTests.swift in Sources */, - C18194682C7F60E500381092 /* FreemiumPIRPresenterTests.swift in Sources */, + C18194682C7F60E500381092 /* FreemiumDBPPresenterTests.swift in Sources */, 56D145EF29E6DAD900E3488A /* DataImportProviderTests.swift in Sources */, 569277C529DEE09D00B633EF /* ContinueSetUpModelTests.swift in Sources */, CD89DD622C89E08D0080F9AF /* PhishingDetectionTests.swift in Sources */, @@ -12104,7 +12103,7 @@ 379E877629E98729001C8BB0 /* BookmarksCleanupErrorHandling.swift in Sources */, B6DA06E42913ECEE00225DE2 /* ContextMenuManager.swift in Sources */, B693955126F04BEB0015B914 /* GradientView.swift in Sources */, - C1858CD22C7C971D00C9BEAB /* FreemiumPIRFeature.swift in Sources */, + C1858CD22C7C971D00C9BEAB /* FreemiumDBPFeature.swift in Sources */, 37AFCE8527DA2D3900471A10 /* PreferencesSidebar.swift in Sources */, 3797C7A32C62C38800DA77FB /* HomePageSettingsModel.swift in Sources */, B6C00ED5292FB21E009C73A6 /* HoveredLinkTabExtension.swift in Sources */, @@ -12425,7 +12424,7 @@ 4B723E0D26B0006100E14D75 /* SecureVaultLoginImporter.swift in Sources */, B645D8F629FA95440024461F /* WKProcessPoolExtension.swift in Sources */, 9D9AE86B2AA76CF90026E7DC /* LoginItemsManager.swift in Sources */, - C18194642C7DF7D600381092 /* FreemiumPIRPresenter.swift in Sources */, + C18194642C7DF7D600381092 /* FreemiumDBPPresenter.swift in Sources */, 857E5AF52A79045800FC0FB4 /* PixelExperiment.swift in Sources */, B6C416A7294A4AE500C4F2E7 /* DuckPlayerTabExtension.swift in Sources */, BDBA859F2C5D25B700BC54F5 /* VPNMetadataCollector.swift in Sources */, @@ -12565,8 +12564,7 @@ F188267C2BBEB3AA00D9AC4F /* GeneralPixel.swift in Sources */, 4B723E1026B0006700E14D75 /* CSVImporter.swift in Sources */, 37A4CEBA282E992F00D75B89 /* StartupPreferences.swift in Sources */, - 4B41EDB12B168B1E001EEDF4 /* VPNFeedbackFormView.swift in Sources */, - C1CE84692C887CF60068913B /* FreemiumPIRScanResultPolling.swift in Sources */, + C1CE84692C887CF60068913B /* FreemiumDBPScanResultPolling.swift in Sources */, 1D72D59C2BFF61B200AEDE36 /* UpdateNotificationPresenter.swift in Sources */, AA4BBA3B25C58FA200C4FB0F /* MainMenu.swift in Sources */, AA585D84248FD31100E9A3E2 /* BrowserTabViewController.swift in Sources */, @@ -12751,7 +12749,7 @@ BDBA85992C5D258100BC54F5 /* VPNFeedbackFormViewController.swift in Sources */, B693955726F04BEC0015B914 /* MouseOverButton.swift in Sources */, AA61C0D02722159B00E6B681 /* FireInfoViewController.swift in Sources */, - C1C405872C7F80E50089DE8A /* PromotionView+FreemiumPIR.swift in Sources */, + C1C405872C7F80E50089DE8A /* PromotionView+FreemiumDBP.swift in Sources */, 9D9AE8692AA76CDC0026E7DC /* LoginItem+NetworkProtection.swift in Sources */, 9F9C49F92BC7BC970099738D /* BookmarkAllTabsDialogView.swift in Sources */, B64C85422694590B0048FEBE /* PermissionButton.swift in Sources */, @@ -12987,7 +12985,7 @@ 4B0219A825E0646500ED7DEA /* WebsiteDataStoreTests.swift in Sources */, AAC9C01E24CB6BEB00AD1325 /* TabCollectionViewModelTests.swift in Sources */, 56CE77612C7DFCF800AC1ED2 /* OnboardingSuggestedSearchesProviderTests.swift in Sources */, - C18194592C7CA9AB00381092 /* FreemiumPIRFeatureTests.swift in Sources */, + C18194592C7CA9AB00381092 /* FreemiumDBPFeatureTests.swift in Sources */, B662D3DE275613BB0035D4D6 /* EncryptionKeyStoreMock.swift in Sources */, 1D3B1ABF29369FC8006F4388 /* BWEncryptionTests.swift in Sources */, B6F56567299A414300A04298 /* WKWebViewMockingExtension.swift in Sources */, @@ -13130,7 +13128,7 @@ 4BF4951826C08395000547B8 /* ThirdPartyBrowserTests.swift in Sources */, 4B98D27C28D960DD003C2B6F /* FirefoxFaviconsReaderTests.swift in Sources */, 9F0FFFBE2BCCAF1F007C87DD /* BookmarkAllTabsDialogViewModelMock.swift in Sources */, - C1CE846C2C88868D0068913B /* FreemiumPIRScanResultPollingTests.swift in Sources */, + C1CE846C2C88868D0068913B /* FreemiumDBPScanResultPollingTests.swift in Sources */, B60C6F7E29B1B41D007BFAA8 /* TestRunHelperInitializer.m in Sources */, 37479F152891BC8300302FE2 /* TabCollectionViewModelTests+WithoutPinnedTabsManager.swift in Sources */, AA63745424C9BF9A00AB2AC4 /* SuggestionContainerTests.swift in Sources */, @@ -13258,7 +13256,7 @@ EEF53E182950CED5002D78F4 /* JSAlertViewModelTests.swift in Sources */, 376C4DB928A1A48A00CC0F5B /* FirePopoverViewModelTests.swift in Sources */, AAEC74B62642CC6A00C2EFBC /* HistoryStoringMock.swift in Sources */, - C18194672C7F60E500381092 /* FreemiumPIRPresenterTests.swift in Sources */, + C18194672C7F60E500381092 /* FreemiumDBPPresenterTests.swift in Sources */, AA652CB125DD825B009059CC /* LocalBookmarkStoreTests.swift in Sources */, 3199AF852C80736C003AEBDC /* DefaultDuckPlayerOnboardingDeciderTests.swift in Sources */, B630794226731F5400DCEE41 /* WKDownloadMock.swift in Sources */, diff --git a/DuckDuckGo/Application/AppDelegate.swift b/DuckDuckGo/Application/AppDelegate.swift index 7ba4d86cf0..b77c9ac052 100644 --- a/DuckDuckGo/Application/AppDelegate.swift +++ b/DuckDuckGo/Application/AppDelegate.swift @@ -98,7 +98,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { public let subscriptionUIHandler: SubscriptionUIHandling // MARK: - Freemium DBP - private var freemiumPIRScanResultPolling: FreemiumPIRScanResultPolling? + private var freemiumDBPScanResultPolling: FreemiumDBPScanResultPolling? // MARK: - VPN @@ -383,10 +383,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate { dataBrokerProtectionSubscriptionEventHandler.registerForSubscriptionAccountManagerEvents() - let freemiumPIRUserStateManager = DefaultFreemiumPIRUserStateManager(userDefaults: .dbp) + let freemiumDBPUserStateManager = DefaultFreemiumDBPUserStateManager(userDefaults: .dbp) let pirGatekeeper = DefaultDataBrokerProtectionFeatureGatekeeper(accountManager: subscriptionManager.accountManager, - freemiumPIRUserStateManager: freemiumPIRUserStateManager) + freemiumDBPUserStateManager: freemiumDBPUserStateManager) DataBrokerProtectionAppEvents(featureGatekeeper: pirGatekeeper).applicationDidFinishLaunching() @@ -411,8 +411,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate { didCrashDuringCrashHandlersSetUp = false } - freemiumPIRScanResultPolling = DefaultFreemiumPIRScanResultPolling(dataManager: DataBrokerProtectionManager.shared.dataManager, freemiumPIRUserStateManager: freemiumPIRUserStateManager) - freemiumPIRScanResultPolling?.startPollingOrObserving() + freemiumDBPScanResultPolling = DefaultFreemiumDBPScanResultPolling(dataManager: DataBrokerProtectionManager.shared.dataManager, freemiumDBPUserStateManager: freemiumDBPUserStateManager) + freemiumDBPScanResultPolling?.startPollingOrObserving() } private func fireFailedCompilationsPixelIfNeeded() { @@ -438,10 +438,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate { NetworkProtectionAppEvents(featureGatekeeper: DefaultVPNFeatureGatekeeper(subscriptionManager: subscriptionManager)).applicationDidBecomeActive() - let freemiumPIRUserStateManager = DefaultFreemiumPIRUserStateManager(userDefaults: .dbp) + let freemiumDBPUserStateManager = DefaultFreemiumDBPUserStateManager(userDefaults: .dbp) let pirGatekeeper = DefaultDataBrokerProtectionFeatureGatekeeper(accountManager: subscriptionManager.accountManager, - freemiumPIRUserStateManager: freemiumPIRUserStateManager) + freemiumDBPUserStateManager: freemiumDBPUserStateManager) DataBrokerProtectionAppEvents(featureGatekeeper: pirGatekeeper).applicationDidBecomeActive() diff --git a/DuckDuckGo/Common/Localizables/UserText.swift b/DuckDuckGo/Common/Localizables/UserText.swift index 568de61715..74710ee3cc 100644 --- a/DuckDuckGo/Common/Localizables/UserText.swift +++ b/DuckDuckGo/Common/Localizables/UserText.swift @@ -1298,55 +1298,55 @@ struct UserText { // Comment: "Progress view title when completing the purchase" static let completingPurchaseTitle = "Completing purchase..." - // Key: "freemium.pir.menu.item" + // Key: "freemium.dbp.menu.item" // Comment: "Title for Freemium Personal Information Removal (Scan-Only) item in the options menu" - static let freemiumPIROptionsMenuItem = "Personal Information Scan" + static let freemiumDBPOptionsMenuItem = "Personal Information Scan" - // Key: "home.page.promotion.freemium.pir.subtitle" - // Comment: "Subtitle for the Freemium PIR Home Page Promotion" - static let homePagePromotionFreemiumPIRSubtitle = "Find your personal info on sites that sell it." + // Key: "home.page.promotion.freemium.dbp.subtitle" + // Comment: "Subtitle for the Freemium DBP Home Page Promotion" + static let homePagePromotionFreemiumDBPSubtitle = "Find your personal info on sites that sell it." - // Key: "home.page.promotion.freemium.pir.button.title" - // Comment: "Title for the Freemium PIR Home Page Promotion Button" - static let homePagePromotionFreemiumPIRButtonTitle = "Free Scan" + // Key: "home.page.promotion.freemium.dbp.button.title" + // Comment: "Title for the Freemium DBP Home Page Promotion Button" + static let homePagePromotionFreemiumDBPButtonTitle = "Free Scan" - // Key: "home.page.promotion.freemium.pir.post.scan.engagement.results.title" - // Comment: "Title for the Freemium PIR Home Page Post Scan Engagement Promotion When There Are Results" - static let homePagePromotionFreemiumPIRPostScanEngagementResultsTitle = "We found your personal info" + // Key: "home.page.promotion.freemium.dbp.post.scan.engagement.results.title" + // Comment: "Title for the Freemium DBP Home Page Post Scan Engagement Promotion When There Are Results" + static let homePagePromotionFreemiumDBPPostScanEngagementResultsTitle = "We found your personal info" - // Key: "home.page.promotion.freemium.pir.post.scan.engagement.result.single.match.subtitle" - // Comment: "Subtitle for the Freemium PIR Home Page Post Scan Engagement Promotion When Only One Record is Found" - static let homePagePromotionFreemiumPIRPostScanEngagementResultSingleMatchSubtitle = "1 record has been found on 1 site" + // Key: "home.page.promotion.freemium.dbp.post.scan.engagement.result.single.match.subtitle" + // Comment: "Subtitle for the Freemium DBP Home Page Post Scan Engagement Promotion When Only One Record is Found" + static let homePagePromotionFreemiumDBPPostScanEngagementResultSingleMatchSubtitle = "1 record has been found on 1 site" - /// Generates a subtitle for the Freemium PIR Home Page Post Scan Engagement Promotion when records are found on a single broker site. - /// Key: "home.page.promotion.freemium.pir.post.scan.engagement.result.single.broker.subtitle" + /// Generates a subtitle for the Freemium DBP Home Page Post Scan Engagement Promotion when records are found on a single broker site. + /// Key: "home.page.promotion.freemium.dbp.post.scan.engagement.result.single.broker.subtitle" /// /// - Parameter resultCount: The number of records found. /// - Returns: A formatted string indicating the number of records found on 1 site. - static func homePagePromotionFreemiumPIRPostScanEngagementResultSingleBrokerSubtitle(resultCount: Int) -> String { + static func homePagePromotionFreemiumDBPPostScanEngagementResultSingleBrokerSubtitle(resultCount: Int) -> String { String(format: "%d records have been found on 1 site", resultCount) } - /// Generates a subtitle for the Freemium PIR Home Page Post Scan Engagement Promotion when records are found on multiple broker sites. - /// Key: "home.page.promotion.freemium.pir.post.scan.engagement.result.plural.subtitle" + /// Generates a subtitle for the Freemium DBP Home Page Post Scan Engagement Promotion when records are found on multiple broker sites. + /// Key: "home.page.promotion.freemium.dbp.post.scan.engagement.result.plural.subtitle" /// /// - Parameters: /// - resultCount: The number of records found. /// - brokerCount: The number of broker sites where records were found. /// - Returns: A formatted string indicating the number of records found on multiple sites. - static func homePagePromotionFreemiumPIRPostScanEngagementResultPluralSubtitle(resultCount: Int, brokerCount: Int) -> String { + static func homePagePromotionFreemiumDBPPostScanEngagementResultPluralSubtitle(resultCount: Int, brokerCount: Int) -> String { String(format: "%d records have been found on %d sites", resultCount, brokerCount) } - // Key: "home.page.promotion.freemium.pir.post.scan.engagement.no.results.title" - // Comment: "Title for the Freemium PIR Home Page Post Scan Engagement Promotion When There Are No Results" - static let homePagePromotionFreemiumPIRPostScanEngagementNoResultsTitle = "Good news, we didn't find your info" + // Key: "home.page.promotion.freemium.dbp.post.scan.engagement.no.results.title" + // Comment: "Title for the Freemium DBP Home Page Post Scan Engagement Promotion When There Are No Results" + static let homePagePromotionFreemiumDBPPostScanEngagementNoResultsTitle = "Good news, we didn't find your info" - // Key: "home.page.promotion.freemium.pir.post.scan.engagement.no.results.subtitle" - // Comment: "Subtitle for the Freemium PIR Home Page Post Scan Engagement Promotion When There Are No Results" - static let homePagePromotionFreemiumPIRPostScanEngagementNoResultsSubtitle = "We’ll keep checking and let you know if we find something" + // Key: "home.page.promotion.freemium.dbp.post.scan.engagement.no.results.subtitle" + // Comment: "Subtitle for the Freemium DBP Home Page Post Scan Engagement Promotion When There Are No Results" + static let homePagePromotionFreemiumDBPPostScanEngagementNoResultsSubtitle = "We’ll keep checking and let you know if we find something" - // Key: "home.page.promotion.freemium.pir.post.scan.engagement.button.title" - // Comment: "Title for the Freemium PIR Home Page Post Scan Engagement Promotion Button" - static let homePagePromotionFreemiumPIRPostScanEngagementButtonTitle = "View Details" + // Key: "home.page.promotion.freemium.dbp.post.scan.engagement.button.title" + // Comment: "Title for the Freemium DBP Home Page Post Scan Engagement Promotion Button" + static let homePagePromotionFreemiumDBPPostScanEngagementButtonTitle = "View Details" } diff --git a/DuckDuckGo/DBP/DBPHomeViewController.swift b/DuckDuckGo/DBP/DBPHomeViewController.swift index e9b37c5f63..d9d2e8e18b 100644 --- a/DuckDuckGo/DBP/DBPHomeViewController.swift +++ b/DuckDuckGo/DBP/DBPHomeViewController.swift @@ -34,7 +34,7 @@ final class DBPHomeViewController: NSViewController { private let pixelHandler: EventMapping = DataBrokerProtectionPixelsHandler() private var currentChildViewController: NSViewController? private var observer: NSObjectProtocol? - private var freemiumPIRFeature: FreemiumPIRFeature + private var freemiumDBPFeature: FreemiumDBPFeature private let prerequisiteVerifier: DataBrokerPrerequisitesStatusVerifier private lazy var errorViewController: DataBrokerProtectionErrorViewController = { @@ -73,10 +73,10 @@ final class DBPHomeViewController: NSViewController { init(dataBrokerProtectionManager: DataBrokerProtectionManager, prerequisiteVerifier: DataBrokerPrerequisitesStatusVerifier = DefaultDataBrokerPrerequisitesStatusVerifier(), - freemiumPIRFeature: FreemiumPIRFeature) { + freemiumDBPFeature: FreemiumDBPFeature) { self.dataBrokerProtectionManager = dataBrokerProtectionManager self.prerequisiteVerifier = prerequisiteVerifier - self.freemiumPIRFeature = freemiumPIRFeature + self.freemiumDBPFeature = freemiumDBPFeature super.init(nibName: nil, bundle: nil) } @@ -98,7 +98,7 @@ final class DBPHomeViewController: NSViewController { override func viewDidAppear() { super.viewDidAppear() - if !dataBrokerProtectionManager.isUserAuthenticated() && !freemiumPIRFeature.isAvailable { + if !dataBrokerProtectionManager.isUserAuthenticated() && !freemiumDBPFeature.isAvailable { assertionFailure("This UI should never be presented if the user is not authenticated") closeUI() } diff --git a/DuckDuckGo/DBP/DataBrokerProtectionFeatureGatekeeper.swift b/DuckDuckGo/DBP/DataBrokerProtectionFeatureGatekeeper.swift index 756e0b08b1..9827ad014c 100644 --- a/DuckDuckGo/DBP/DataBrokerProtectionFeatureGatekeeper.swift +++ b/DuckDuckGo/DBP/DataBrokerProtectionFeatureGatekeeper.swift @@ -36,7 +36,7 @@ struct DefaultDataBrokerProtectionFeatureGatekeeper: DataBrokerProtectionFeature private let userDefaults: UserDefaults private let subscriptionAvailability: SubscriptionFeatureAvailability private let accountManager: AccountManager - private let freemiumPIRUserStateManager: FreemiumPIRUserStateManager + private let freemiumDBPUserStateManager: FreemiumDBPUserStateManager init(privacyConfigurationManager: PrivacyConfigurationManaging = ContentBlocking.shared.privacyConfigurationManager, featureDisabler: DataBrokerProtectionFeatureDisabling = DataBrokerProtectionFeatureDisabler(), @@ -44,14 +44,14 @@ struct DefaultDataBrokerProtectionFeatureGatekeeper: DataBrokerProtectionFeature userDefaults: UserDefaults = .standard, subscriptionAvailability: SubscriptionFeatureAvailability = DefaultSubscriptionFeatureAvailability(), accountManager: AccountManager, - freemiumPIRUserStateManager: FreemiumPIRUserStateManager) { + freemiumDBPUserStateManager: FreemiumDBPUserStateManager) { self.privacyConfigurationManager = privacyConfigurationManager self.featureDisabler = featureDisabler self.pixelHandler = pixelHandler self.userDefaults = userDefaults self.subscriptionAvailability = subscriptionAvailability self.accountManager = accountManager - self.freemiumPIRUserStateManager = freemiumPIRUserStateManager + self.freemiumDBPUserStateManager = freemiumDBPUserStateManager } var isUserLocaleAllowed: Bool { @@ -78,7 +78,7 @@ struct DefaultDataBrokerProtectionFeatureGatekeeper: DataBrokerProtectionFeature Logger.dataBrokerProtection.debug("Disabling and removing DBP for all users") } - /// Checks PIR prerequisites + /// Checks DBP prerequisites /// /// Prerequisites are satisified if either: /// 1. The user is an active freemium user (e.g has onboarded to freemium and is not authenticated) @@ -88,7 +88,7 @@ struct DefaultDataBrokerProtectionFeatureGatekeeper: DataBrokerProtectionFeature func arePrerequisitesSatisfied() async -> Bool { let isAuthenticated = accountManager.isUserAuthenticated - if !isAuthenticated && freemiumPIRUserStateManager.didOnboard { return true } + if !isAuthenticated && freemiumDBPUserStateManager.didOnboard { return true } let entitlements = await accountManager.hasEntitlement(forProductName: .dataBrokerProtection, cachePolicy: .reloadIgnoringLocalCacheData) diff --git a/DuckDuckGo/DBP/DataBrokerProtectionManager.swift b/DuckDuckGo/DBP/DataBrokerProtectionManager.swift index 3e0e29e0b6..b4d8fe2302 100644 --- a/DuckDuckGo/DBP/DataBrokerProtectionManager.swift +++ b/DuckDuckGo/DBP/DataBrokerProtectionManager.swift @@ -32,9 +32,9 @@ public final class DataBrokerProtectionManager { private let fakeBrokerFlag: DataBrokerDebugFlag = DataBrokerDebugFlagFakeBroker() private lazy var freemiumDBPFirstProfileSavedNotifier: FreemiumDBPFirstProfileSavedNotifier = { - let freemiumPIRUserStateManager = DefaultFreemiumPIRUserStateManager(userDefaults: .dbp) + let freemiumDBPUserStateManager = DefaultFreemiumDBPUserStateManager(userDefaults: .dbp) let accountManager = Application.appDelegate.subscriptionManager.accountManager - let freemiumDBPFirstProfileSavedNotifier = FreemiumDBPFirstProfileSavedNotifier(freemiumPIRUserStateManager: freemiumPIRUserStateManager, + let freemiumDBPFirstProfileSavedNotifier = FreemiumDBPFirstProfileSavedNotifier(freemiumDBPUserStateManager: freemiumDBPUserStateManager, accountManager: accountManager) return freemiumDBPFirstProfileSavedNotifier }() diff --git a/DuckDuckGo/FeatureFlagging/Model/FeatureFlag.swift b/DuckDuckGo/FeatureFlagging/Model/FeatureFlag.swift index d5cacaf5af..915749a4c9 100644 --- a/DuckDuckGo/FeatureFlagging/Model/FeatureFlag.swift +++ b/DuckDuckGo/FeatureFlagging/Model/FeatureFlag.swift @@ -33,7 +33,7 @@ public enum FeatureFlag: String { case deduplicateLoginsOnImport // https://app.asana.com/0/1206488453854252/1207136666798700/f - case freemiumPIR + case freemiumDBP case highlightsOnboarding @@ -54,7 +54,7 @@ extension FeatureFlag: FeatureFlagSourceProviding { return .remoteReleasable(.subfeature(AutofillSubfeature.deduplicateLoginsOnImport)) case .unknownUsernameCategorization: return .remoteReleasable(.subfeature(AutofillSubfeature.unknownUsernameCategorization)) - case .freemiumPIR: + case .freemiumDBP: return .remoteDevelopment(.subfeature(DBPSubfeature.freemium)) case .phishingDetectionErrorPage: return .remoteReleasable(.subfeature(PhishingDetectionSubfeature.allowErrorPage)) diff --git a/DuckDuckGo/Freemium/PIR/FreemiumPIRFeature.swift b/DuckDuckGo/Freemium/DBP/FreemiumDBPFeature.swift similarity index 77% rename from DuckDuckGo/Freemium/PIR/FreemiumPIRFeature.swift rename to DuckDuckGo/Freemium/DBP/FreemiumDBPFeature.swift index 1fba4b5d14..58bad35d99 100644 --- a/DuckDuckGo/Freemium/PIR/FreemiumPIRFeature.swift +++ b/DuckDuckGo/Freemium/DBP/FreemiumDBPFeature.swift @@ -1,5 +1,5 @@ // -// FreemiumPIRFeature.swift +// FreemiumDBPFeature.swift // // Copyright © 2024 DuckDuckGo. All rights reserved. // @@ -21,28 +21,28 @@ import BrowserServicesKit import Subscription import Freemium -/// Conforming types encapsulate logic relating to the Freemium PIR Feature (e.g Feature Availability etc.) -protocol FreemiumPIRFeature { +/// Conforming types encapsulate logic relating to the Freemium DBP Feature (e.g Feature Availability etc.) +protocol FreemiumDBPFeature { var isAvailable: Bool { get } } -/// Default implementation of `FreemiumPIRFeature` -final class DefaultFreemiumPIRFeature: FreemiumPIRFeature { +/// Default implementation of `FreemiumDBPFeature` +final class DefaultFreemiumDBPFeature: FreemiumDBPFeature { private let featureFlagger: FeatureFlagger private let subscriptionManager: SubscriptionManager private let accountManager: AccountManager - private var freemiumPIRUserStateManager: FreemiumPIRUserStateManager + private var freemiumDBPUserStateManager: FreemiumDBPUserStateManager private let featureDisabler: DataBrokerProtectionFeatureDisabling var isAvailable: Bool { - /* Freemium PIR availability criteria: + /* Freemium DBP availability criteria: 1. Feature Flag enabled 2. Privacy Pro Available 3. Not a current Privacy Pro subscriber 4. (Temp) In experiment cohort */ - featureFlagger.isFeatureOn(.freemiumPIR) // #1 + featureFlagger.isFeatureOn(.freemiumDBP) // #1 && isPotentialPrivacyProSubscriber // #2 & #3 // TODO: - Also check experiment cohort here } @@ -50,20 +50,20 @@ final class DefaultFreemiumPIRFeature: FreemiumPIRFeature { init(featureFlagger: FeatureFlagger = NSApp.delegateTyped.featureFlagger, subscriptionManager: SubscriptionManager, accountManager: AccountManager, - freemiumPIRUserStateManager: FreemiumPIRUserStateManager, + freemiumDBPUserStateManager: FreemiumDBPUserStateManager, featureDisabler: DataBrokerProtectionFeatureDisabling = DataBrokerProtectionFeatureDisabler()) { self.featureFlagger = featureFlagger self.subscriptionManager = subscriptionManager self.accountManager = accountManager - self.freemiumPIRUserStateManager = freemiumPIRUserStateManager + self.freemiumDBPUserStateManager = freemiumDBPUserStateManager self.featureDisabler = featureDisabler offBoardIfNecessary() } } -private extension DefaultFreemiumPIRFeature { +private extension DefaultFreemiumDBPFeature { /// Returns true if a user is a "potential" Privacy Pro subscriber. This means: /// @@ -76,24 +76,24 @@ private extension DefaultFreemiumPIRFeature { /// Returns true IFF: /// - /// 1. The user did onboard to Freemium PIR + /// 1. The user did onboard to Freemium DBP /// 2. The feature flag is disabled /// 3. The user `isPotentialPrivacyProSubscriber` (see definition) var shouldDisableAndDelete: Bool { - guard freemiumPIRUserStateManager.didOnboard else { return false } + guard freemiumDBPUserStateManager.didOnboard else { return false } - return !featureFlagger.isFeatureOn(.freemiumPIR) + return !featureFlagger.isFeatureOn(.freemiumDBP) && isPotentialPrivacyProSubscriber } /// This method offboards a Freemium user if the feature flag was disabled /// /// Offboarding involves: - /// - Resettting `FreemiumPIRUserStateManager`state - /// - Disabling and deleting PIR data + /// - Resettting `FreemiumDBPUserStateManager`state + /// - Disabling and deleting DBP data func offBoardIfNecessary() { if shouldDisableAndDelete { - freemiumPIRUserStateManager.didOnboard = false + freemiumDBPUserStateManager.didOnboard = false featureDisabler.disableAndDelete() } } diff --git a/DuckDuckGo/Freemium/PIR/FreemiumDBPFirstProfileSavedNotifier.swift b/DuckDuckGo/Freemium/DBP/FreemiumDBPFirstProfileSavedNotifier.swift similarity index 84% rename from DuckDuckGo/Freemium/PIR/FreemiumDBPFirstProfileSavedNotifier.swift rename to DuckDuckGo/Freemium/DBP/FreemiumDBPFirstProfileSavedNotifier.swift index ece4bb6012..d5467579ab 100644 --- a/DuckDuckGo/Freemium/PIR/FreemiumDBPFirstProfileSavedNotifier.swift +++ b/DuckDuckGo/Freemium/DBP/FreemiumDBPFirstProfileSavedNotifier.swift @@ -26,18 +26,18 @@ import OSLog /// for Freemium users based on their onboarding status, authentication state, and if this is their first saved profile. This class ensures the notification is posted only once. final class FreemiumDBPFirstProfileSavedNotifier: DBPProfileSavedNotifier { - private var freemiumPIRUserStateManager: FreemiumPIRUserStateManager + private var freemiumDBPUserStateManager: FreemiumDBPUserStateManager private var accountManager: AccountManager private let notificationCenter: NotificationCenter /// Initializes the notifier with the necessary dependencies to check user state and post notifications. /// /// - Parameters: - /// - freemiumPIRUserStateManager: Manages the user state related to Freemium PIR. + /// - freemiumDBPUserStateManager: Manages the user state related to Freemium DBP. /// - accountManager: Manages account-related information, such as whether the user is authenticated. /// - notificationCenter: The notification center for posting notifications. Defaults to the system's default notification center. - init(freemiumPIRUserStateManager: FreemiumPIRUserStateManager, accountManager: AccountManager, notificationCenter: NotificationCenter = .default) { - self.freemiumPIRUserStateManager = freemiumPIRUserStateManager + init(freemiumDBPUserStateManager: FreemiumDBPUserStateManager, accountManager: AccountManager, notificationCenter: NotificationCenter = .default) { + self.freemiumDBPUserStateManager = freemiumDBPUserStateManager self.accountManager = accountManager self.notificationCenter = notificationCenter } @@ -50,12 +50,12 @@ final class FreemiumDBPFirstProfileSavedNotifier: DBPProfileSavedNotifier { /// If all conditions are met, the method posts a `pirProfileSaved` notification via the `NotificationCenter` and records that the notification has been posted. func postProfileSavedNotificationIfPermitted() { guard !accountManager.isUserAuthenticated - && freemiumPIRUserStateManager.didOnboard - && !freemiumPIRUserStateManager.didPostFirstProfileSavedNotification else { return } + && freemiumDBPUserStateManager.didOnboard + && !freemiumDBPUserStateManager.didPostFirstProfileSavedNotification else { return } Logger.freemiumDBP.debug("[Freemium DBP] Posting Profile Saved Notification") notificationCenter.post(name: .pirProfileSaved, object: nil) - freemiumPIRUserStateManager.didPostFirstProfileSavedNotification = true + freemiumDBPUserStateManager.didPostFirstProfileSavedNotification = true } } diff --git a/DuckDuckGo/Freemium/PIR/FreemiumPIRPresenter.swift b/DuckDuckGo/Freemium/DBP/FreemiumDBPPresenter.swift similarity index 64% rename from DuckDuckGo/Freemium/PIR/FreemiumPIRPresenter.swift rename to DuckDuckGo/Freemium/DBP/FreemiumDBPPresenter.swift index 946f116217..352a32f292 100644 --- a/DuckDuckGo/Freemium/PIR/FreemiumPIRPresenter.swift +++ b/DuckDuckGo/Freemium/DBP/FreemiumDBPPresenter.swift @@ -1,5 +1,5 @@ // -// FreemiumPIRPresenter.swift +// FreemiumDBPPresenter.swift // // Copyright © 2024 DuckDuckGo. All rights reserved. // @@ -18,20 +18,20 @@ import Foundation -/// Conforming types provide functionality to show Freemium PIR -protocol FreemiumPIRPresenter { - func showFreemiumPIR(didOnboard: Bool, windowControllerManager: WindowControllersManagerProtocol?) +/// Conforming types provide functionality to show Freemium DBP +protocol FreemiumDBPPresenter { + func showFreemiumDBP(didOnboard: Bool, windowControllerManager: WindowControllersManagerProtocol?) } -/// Default implementation of `FreemiumPIRPresenter` -struct DefaultFreemiumPIRPresenter: FreemiumPIRPresenter { +/// Default implementation of `FreemiumDBPPresenter` +struct DefaultFreemiumDBPPresenter: FreemiumDBPPresenter { @MainActor - /// Displays Freemium PIR - /// If the `didOnboard` parameter is true, opens PIR directly - /// If the `didOnboard` parameter is false, opens Freemium PIR onboarding + /// Displays Freemium DBP + /// If the `didOnboard` parameter is true, opens DBP directly + /// If the `didOnboard` parameter is false, opens Freemium DBP onboarding /// - Parameter didOnboard: Bool indicating if the user has onboarded already - func showFreemiumPIR(didOnboard: Bool, windowControllerManager: WindowControllersManagerProtocol? = nil) { + func showFreemiumDBP(didOnboard: Bool, windowControllerManager: WindowControllersManagerProtocol? = nil) { let windowControllerManager = windowControllerManager ?? WindowControllersManager.shared @@ -39,15 +39,15 @@ struct DefaultFreemiumPIRPresenter: FreemiumPIRPresenter { windowControllerManager.showTab(with: .dataBrokerProtection) } else { // TODO: - Onboard (i.e Ts and Cs) - showFreemiumPIROnboarding() + showFreemiumDBPOnboarding() } } } -private extension DefaultFreemiumPIRPresenter { +private extension DefaultFreemiumDBPPresenter { @MainActor - func showFreemiumPIROnboarding() { + func showFreemiumDBPOnboarding() { // TODO: - Show onboarding if we decide to do this } } diff --git a/DuckDuckGo/Freemium/PIR/FreemiumDBPPromotionViewCoordinating.swift b/DuckDuckGo/Freemium/DBP/FreemiumDBPPromotionViewCoordinating.swift similarity index 83% rename from DuckDuckGo/Freemium/PIR/FreemiumDBPPromotionViewCoordinating.swift rename to DuckDuckGo/Freemium/DBP/FreemiumDBPPromotionViewCoordinating.swift index 67439e332d..2ee1d575ba 100644 --- a/DuckDuckGo/Freemium/PIR/FreemiumDBPPromotionViewCoordinating.swift +++ b/DuckDuckGo/Freemium/DBP/FreemiumDBPPromotionViewCoordinating.swift @@ -57,13 +57,13 @@ final class FreemiumDBPPromotionViewCoordinator: FreemiumDBPPromotionViewCoordin } /// The user state manager, which tracks the user's onboarding status and scan results. - private var freemiumDBPUserStateManager: FreemiumPIRUserStateManager + private var freemiumDBPUserStateManager: FreemiumDBPUserStateManager /// Responsible for determining the availability of Freemium DBP. - private let freemiumPIRFeature: FreemiumPIRFeature + private let freemiumDBPFeature: FreemiumDBPFeature /// The presenter used to show the Freemium DBP UI. - private let freemiumPIRPresenter: FreemiumPIRPresenter + private let freemiumDBPPresenter: FreemiumDBPPresenter /// A set of cancellables for managing Combine subscriptions. private var cancellables = Set() @@ -71,16 +71,16 @@ final class FreemiumDBPPromotionViewCoordinator: FreemiumDBPPromotionViewCoordin /// Initializes the coordinator with the necessary dependencies. /// /// - Parameters: - /// - freemiumDBPUserStateManager: Manages the user's state in the Freemium PIR system. - /// - freemiumPIRFeature: The feature that determines the availability of PIR. - /// - freemiumPIRPresenter: The presenter used to show the Freemium PIR UI. Defaults to `DefaultFreemiumPIRPresenter`. - init(freemiumDBPUserStateManager: FreemiumPIRUserStateManager, - freemiumPIRFeature: FreemiumPIRFeature, - freemiumPIRPresenter: FreemiumPIRPresenter = DefaultFreemiumPIRPresenter()) { + /// - freemiumDBPUserStateManager: Manages the user's state in the Freemium DBP system. + /// - freemiumDBPFeature: The feature that determines the availability of DBP. + /// - freemiumDBPPresenter: The presenter used to show the Freemium DBP UI. Defaults to `DefaultFreemiumDBPPresenter`. + init(freemiumDBPUserStateManager: FreemiumDBPUserStateManager, + freemiumDBPFeature: FreemiumDBPFeature, + freemiumDBPPresenter: FreemiumDBPPresenter = DefaultFreemiumDBPPresenter()) { self.freemiumDBPUserStateManager = freemiumDBPUserStateManager - self.freemiumPIRFeature = freemiumPIRFeature - self.freemiumPIRPresenter = freemiumPIRPresenter + self.freemiumDBPFeature = freemiumDBPFeature + self.freemiumDBPPresenter = freemiumDBPPresenter setInitialPromotionVisibilityState() observeFreemiumDBPNotifications() @@ -93,7 +93,7 @@ private extension FreemiumDBPPromotionViewCoordinator { var proceedAction: () -> Void { { [weak self] in self?.markUserAsOnboarded() - self?.showFreemiumPIR() + self?.showFreemiumDBP() self?.dismissHomePagePromotion() } } @@ -110,9 +110,9 @@ private extension FreemiumDBPPromotionViewCoordinator { freemiumDBPUserStateManager.didOnboard = true } - /// Shows the Freemium PIR user interface via the presenter. - func showFreemiumPIR() { - freemiumPIRPresenter.showFreemiumPIR( + /// Shows the Freemium DBP user interface via the presenter. + func showFreemiumDBP() { + freemiumDBPPresenter.showFreemiumDBP( didOnboard: freemiumDBPUserStateManager.didOnboard, windowControllerManager: WindowControllersManager.shared ) @@ -124,9 +124,9 @@ private extension FreemiumDBPPromotionViewCoordinator { } /// Sets the initial visibility state of the promotion based on whether the promotion was - /// previously dismissed and whether the Freemium PIR feature is available. + /// previously dismissed and whether the Freemium DBP feature is available. func setInitialPromotionVisibilityState() { - isHomePagePromotionVisible = (!didDismissHomePagePromotion && freemiumPIRFeature.isAvailable) + isHomePagePromotionVisible = (!didDismissHomePagePromotion && freemiumDBPFeature.isAvailable) } /// Creates the view model for the promotion, updating based on the user's scan results. @@ -135,20 +135,20 @@ private extension FreemiumDBPPromotionViewCoordinator { func createViewModel() -> PromotionViewModel { if let results = freemiumDBPUserStateManager.firstScanResults { if results.matchesCount > 0 { - return .freemiumPIRPromotionScanEngagementResults( + return .freemiumDBPPromotionScanEngagementResults( resultCount: results.matchesCount, brokerCount: results.brokerCount, proceedAction: proceedAction, closeAction: closeAction ) } else { - return .freemiumPIRPromotionScanEngagementNoResults( + return .freemiumDBPPromotionScanEngagementNoResults( proceedAction: proceedAction, closeAction: closeAction ) } } else { - return .freemiumPIRPromotion(proceedAction: proceedAction, closeAction: closeAction) + return .freemiumDBPPromotion(proceedAction: proceedAction, closeAction: closeAction) } } diff --git a/DuckDuckGo/Freemium/PIR/FreemiumPIRScanResultPolling.swift b/DuckDuckGo/Freemium/DBP/FreemiumDBPScanResultPolling.swift similarity index 85% rename from DuckDuckGo/Freemium/PIR/FreemiumPIRScanResultPolling.swift rename to DuckDuckGo/Freemium/DBP/FreemiumDBPScanResultPolling.swift index 57c95be0ee..7c71da42e8 100644 --- a/DuckDuckGo/Freemium/PIR/FreemiumPIRScanResultPolling.swift +++ b/DuckDuckGo/Freemium/DBP/FreemiumDBPScanResultPolling.swift @@ -1,5 +1,5 @@ // -// FreemiumPIRScanResultPolling.swift +// FreemiumDBPScanResultPolling.swift // // Copyright © 2024 DuckDuckGo. All rights reserved. // @@ -21,16 +21,16 @@ import DataBrokerProtection import Freemium import OSLog -/// Protocol defining the interface for PIR (Profile Information Removal) scan result polling. -protocol FreemiumPIRScanResultPolling { +/// Protocol defining the interface for DBP scan result polling. +protocol FreemiumDBPScanResultPolling { /// Starts the polling process for scan results or begins observing for profile saved events. func startPollingOrObserving() } -/// A class that manages the polling for PIR (Profile Information Removal) scan results and handles posting notifications for results. +/// A class that manages the polling for DBP scan results and handles posting notifications for results. /// It either starts polling if a profile has been saved or begins observing for the event of saving a profile. /// The polling checks for results periodically and posts notifications when results are found or no results are found after a set duration. -final class DefaultFreemiumPIRScanResultPolling: FreemiumPIRScanResultPolling { +final class DefaultFreemiumDBPScanResultPolling: FreemiumDBPScanResultPolling { /// Internal for testing purposes to allow access in test cases. var timer: Timer? @@ -38,31 +38,31 @@ final class DefaultFreemiumPIRScanResultPolling: FreemiumPIRScanResultPolling { private var observer: Any? private let dataManager: DataBrokerProtectionDataManaging - private var freemiumPIRUserStateManager: FreemiumPIRUserStateManager + private var freemiumDBPUserStateManager: FreemiumDBPUserStateManager private let notificationCenter: NotificationCenter private let timerInterval: TimeInterval private let dateFormatter: DateFormatter private let maxCheckDuration: TimeInterval - /// Initializes the `DefaultFreemiumPIRScanResultPolling` instance with the necessary dependencies. + /// Initializes the `DefaultFreemiumDBPScanResultPolling` instance with the necessary dependencies. /// /// - Parameters: /// - dataManager: The data manager responsible for managing broker protection data. - /// - freemiumPIRUserStateManager: Manages the state of the user's profile in Freemium PIR. + /// - freemiumDBPUserStateManager: Manages the state of the user's profile in Freemium DBP. /// - notificationCenter: The notification center used for posting and observing notifications. Defaults to `.default`. /// - timerInterval: The interval in seconds between polling checks. Defaults to 1 hour. /// - maxCheckDuration: The maximum time allowed before stopping polling without results. Defaults to 24 hours. /// - dateFormatter: A `DateFormatter` for formatting dates. Defaults to a POSIX date-time formatter. init( dataManager: DataBrokerProtectionDataManaging, - freemiumPIRUserStateManager: FreemiumPIRUserStateManager, + freemiumDBPUserStateManager: FreemiumDBPUserStateManager, notificationCenter: NotificationCenter = .default, timerInterval: TimeInterval = 3600, // 1 hour in seconds maxCheckDuration: TimeInterval = 86400, // 24 hours in seconds - dateFormatter: DateFormatter = DefaultFreemiumPIRScanResultPolling.makePOSIXDateTimeFormatter() + dateFormatter: DateFormatter = DefaultFreemiumDBPScanResultPolling.makePOSIXDateTimeFormatter() ) { self.dataManager = dataManager - self.freemiumPIRUserStateManager = freemiumPIRUserStateManager + self.freemiumDBPUserStateManager = freemiumDBPUserStateManager self.notificationCenter = notificationCenter self.timerInterval = timerInterval self.maxCheckDuration = maxCheckDuration @@ -71,9 +71,9 @@ final class DefaultFreemiumPIRScanResultPolling: FreemiumPIRScanResultPolling { // MARK: - Public Methods - /// Starts polling for PIR scan results or observes for a profile saved notification if no profile has been saved yet. + /// Starts polling for DBP scan results or observes for a profile saved notification if no profile has been saved yet. func startPollingOrObserving() { - guard !freemiumPIRUserStateManager.didPostResultsNotification else { return } + guard !freemiumDBPUserStateManager.didPostResultsNotification else { return } if firstProfileSaved { startPolling() @@ -88,25 +88,25 @@ final class DefaultFreemiumPIRScanResultPolling: FreemiumPIRScanResultPolling { } } -private extension DefaultFreemiumPIRScanResultPolling { +private extension DefaultFreemiumDBPScanResultPolling { /// A Boolean value indicating whether the first profile has been saved. var firstProfileSaved: Bool { - freemiumPIRUserStateManager.firstProfileSavedTimestamp != nil + freemiumDBPUserStateManager.firstProfileSavedTimestamp != nil } /// The saved timestamp of the first profile as a `Date`, or `nil` if no profile has been saved yet. var firstProfileSavedTimestamp: Date? { get { - guard let timestampString = freemiumPIRUserStateManager.firstProfileSavedTimestamp else { return nil } + guard let timestampString = freemiumDBPUserStateManager.firstProfileSavedTimestamp else { return nil } return dateFormatter.date(from: timestampString) } set { if let newTimestamp = newValue { let timestampString = dateFormatter.string(from: newTimestamp) - freemiumPIRUserStateManager.firstProfileSavedTimestamp = timestampString + freemiumDBPUserStateManager.firstProfileSavedTimestamp = timestampString } else { - freemiumPIRUserStateManager.firstProfileSavedTimestamp = nil + freemiumDBPUserStateManager.firstProfileSavedTimestamp = nil } } } @@ -154,7 +154,7 @@ private extension DefaultFreemiumPIRScanResultPolling { /// Starts a timer that polls for results at regular intervals, ensuring the timer is not already running. func startPollingTimer() { - guard timer == nil, !freemiumPIRUserStateManager.didPostResultsNotification else { return } + guard timer == nil, !freemiumDBPUserStateManager.didPostResultsNotification else { return } timer = Timer.scheduledTimer(withTimeInterval: timerInterval, repeats: true) { [weak self] _ in self?.checkResultsAndNotifyIfApplicable() @@ -186,13 +186,13 @@ private extension DefaultFreemiumPIRScanResultPolling { /// - brokerCount: The number of brokers associated with the matches found. func notifyOfResultsAndStopTimer(_ matchesCount: Int, _ brokerCount: Int) { - freemiumPIRUserStateManager.firstScanResults = FreemiumDBPMatchResults(matchesCount: matchesCount, brokerCount: brokerCount) + freemiumDBPUserStateManager.firstScanResults = FreemiumDBPMatchResults(matchesCount: matchesCount, brokerCount: brokerCount) let withOrWith = matchesCount > 0 ? "WITH" : "WITHOUT" Logger.freemiumDBP.debug("[Freemium DBP] Posting Scan Results Notification \(withOrWith) matches") notificationCenter.post(name: .freemiumDBPResultPollingComplete, object: nil) - freemiumPIRUserStateManager.didPostResultsNotification = true + freemiumDBPUserStateManager.didPostResultsNotification = true stopTimer() } diff --git a/DuckDuckGo/Freemium/PIR/Logger+FreemiumDBP.swift b/DuckDuckGo/Freemium/DBP/Logger+FreemiumDBP.swift similarity index 100% rename from DuckDuckGo/Freemium/PIR/Logger+FreemiumDBP.swift rename to DuckDuckGo/Freemium/DBP/Logger+FreemiumDBP.swift diff --git a/DuckDuckGo/Freemium/PIR/NotificationName+Freemium.swift b/DuckDuckGo/Freemium/DBP/NotificationName+Freemium.swift similarity index 94% rename from DuckDuckGo/Freemium/PIR/NotificationName+Freemium.swift rename to DuckDuckGo/Freemium/DBP/NotificationName+Freemium.swift index a3e799e867..e587e1b910 100644 --- a/DuckDuckGo/Freemium/PIR/NotificationName+Freemium.swift +++ b/DuckDuckGo/Freemium/DBP/NotificationName+Freemium.swift @@ -19,7 +19,7 @@ import Foundation extension Notification.Name { - /// Notification posted when `FreemiumPIRScanResultPolling` has finished polling for scan results + /// Notification posted when `FreemiumDBPScanResultPolling` has finished polling for scan results static let freemiumDBPResultPollingComplete = Notification.Name("freemiumDBPResultPollingComplete") /// Notification posted when the user has entered Freemium DBP via a non-new tab entry point (e.g. via the meatball menu item) static let freemiumDBPEntryPointActivated = Notification.Name("freemiumDBPEntryPointActivated") diff --git a/DuckDuckGo/Freemium/PIR/PromotionView+FreemiumPIR.swift b/DuckDuckGo/Freemium/DBP/PromotionView+FreemiumDBP.swift similarity index 79% rename from DuckDuckGo/Freemium/PIR/PromotionView+FreemiumPIR.swift rename to DuckDuckGo/Freemium/DBP/PromotionView+FreemiumDBP.swift index 4bfc54d467..014c42b778 100644 --- a/DuckDuckGo/Freemium/PIR/PromotionView+FreemiumPIR.swift +++ b/DuckDuckGo/Freemium/DBP/PromotionView+FreemiumDBP.swift @@ -1,5 +1,5 @@ // -// PromotionView+FreemiumPIR.swift +// PromotionView+FreemiumDBP.swift // // Copyright © 2024 DuckDuckGo. All rights reserved. // @@ -19,11 +19,11 @@ import Foundation extension PromotionViewModel { - static func freemiumPIRPromotion(proceedAction: @escaping () -> Void, + static func freemiumDBPPromotion(proceedAction: @escaping () -> Void, closeAction: @escaping () -> Void) -> PromotionViewModel { - let subtitle = UserText.homePagePromotionFreemiumPIRSubtitle - let actionButtonText = UserText.homePagePromotionFreemiumPIRButtonTitle + let subtitle = UserText.homePagePromotionFreemiumDBPSubtitle + let actionButtonText = UserText.homePagePromotionFreemiumDBPButtonTitle return PromotionViewModel(image: .radarCheck, subtitle: subtitle, @@ -32,25 +32,25 @@ extension PromotionViewModel { closeAction: closeAction) } - static func freemiumPIRPromotionScanEngagementResults(resultCount: Int, + static func freemiumDBPPromotionScanEngagementResults(resultCount: Int, brokerCount: Int, proceedAction: @escaping () -> Void, closeAction: @escaping () -> Void) -> PromotionViewModel { - var title = UserText.homePagePromotionFreemiumPIRPostScanEngagementResultsTitle + var title = UserText.homePagePromotionFreemiumDBPPostScanEngagementResultsTitle var subtitle = "" switch (resultCount, brokerCount) { case (1, _): - subtitle = UserText.homePagePromotionFreemiumPIRPostScanEngagementResultSingleMatchSubtitle + subtitle = UserText.homePagePromotionFreemiumDBPPostScanEngagementResultSingleMatchSubtitle case (let resultCount, 1): - subtitle = UserText.homePagePromotionFreemiumPIRPostScanEngagementResultSingleBrokerSubtitle(resultCount: resultCount) + subtitle = UserText.homePagePromotionFreemiumDBPPostScanEngagementResultSingleBrokerSubtitle(resultCount: resultCount) default: - subtitle = UserText.homePagePromotionFreemiumPIRPostScanEngagementResultPluralSubtitle(resultCount: resultCount, + subtitle = UserText.homePagePromotionFreemiumDBPPostScanEngagementResultPluralSubtitle(resultCount: resultCount, brokerCount: brokerCount) } - let actionButtonText = UserText.homePagePromotionFreemiumPIRPostScanEngagementButtonTitle + let actionButtonText = UserText.homePagePromotionFreemiumDBPPostScanEngagementButtonTitle return PromotionViewModel(image: .radarCheck, title: title, @@ -60,12 +60,12 @@ extension PromotionViewModel { closeAction: closeAction) } - static func freemiumPIRPromotionScanEngagementNoResults(proceedAction: @escaping () -> Void, + static func freemiumDBPPromotionScanEngagementNoResults(proceedAction: @escaping () -> Void, closeAction: @escaping () -> Void) -> PromotionViewModel { - let title = UserText.homePagePromotionFreemiumPIRPostScanEngagementNoResultsTitle - let subtitle = UserText.homePagePromotionFreemiumPIRPostScanEngagementNoResultsSubtitle - let actionButtonText = UserText.homePagePromotionFreemiumPIRPostScanEngagementButtonTitle + let title = UserText.homePagePromotionFreemiumDBPPostScanEngagementNoResultsTitle + let subtitle = UserText.homePagePromotionFreemiumDBPPostScanEngagementNoResultsSubtitle + let actionButtonText = UserText.homePagePromotionFreemiumDBPPostScanEngagementButtonTitle return PromotionViewModel(image: .radarCheck, title: title, diff --git a/DuckDuckGo/Freemium/FreemiumDebugMenu.swift b/DuckDuckGo/Freemium/FreemiumDebugMenu.swift index 88bb00cb15..e665505012 100644 --- a/DuckDuckGo/Freemium/FreemiumDebugMenu.swift +++ b/DuckDuckGo/Freemium/FreemiumDebugMenu.swift @@ -34,9 +34,9 @@ final class FreemiumDebugMenu: NSMenuItem { private func makeSubmenu() -> NSMenu { let menu = NSMenu(title: "") - menu.addItem(NSMenuItem(title: "Set Freemium PIR Onboarded State TRUE", action: #selector(setFreemiumPIROnboardStateTrue), target: self)) - menu.addItem(NSMenuItem(title: "Set Freemium PIR Onboarded State FALSE", action: #selector(setFreemiumPIROnboardStateFalse), target: self)) - menu.addItem(NSMenuItem(title: "Set Freemium PIR First Profile Saved Timestamp NIL", action: #selector(setFirstProfileSavedTimestampNil), target: self)) + menu.addItem(NSMenuItem(title: "Set Freemium DBP Onboarded State TRUE", action: #selector(setFreemiumDBPOnboardStateTrue), target: self)) + menu.addItem(NSMenuItem(title: "Set Freemium DBP Onboarded State FALSE", action: #selector(setFreemiumDBPOnboardStateFalse), target: self)) + menu.addItem(NSMenuItem(title: "Set Freemium DBP First Profile Saved Timestamp NIL", action: #selector(setFirstProfileSavedTimestampNil), target: self)) menu.addItem(NSMenuItem(title: "Set Freemium DBP Did Post First Profile Saved FALSE", action: #selector(setDidPostFirstProfileSavedNotificationFalse), target: self)) menu.addItem(NSMenuItem(title: "Set Freemium DBP Did Post Results FALSE", action: #selector(setDidPostResultsNotificationFalse), target: self)) menu.addItem(NSMenuItem(title: "Trigger Engagement UX Results", action: #selector(triggerEngagementUXResults), target: self)) @@ -51,28 +51,28 @@ final class FreemiumDebugMenu: NSMenuItem { } @objc - func setFreemiumPIROnboardStateTrue() { - DefaultFreemiumPIRUserStateManager(userDefaults: .dbp).didOnboard = true + func setFreemiumDBPOnboardStateTrue() { + DefaultFreemiumDBPUserStateManager(userDefaults: .dbp).didOnboard = true } @objc - func setFreemiumPIROnboardStateFalse() { - DefaultFreemiumPIRUserStateManager(userDefaults: .dbp).didOnboard = false + func setFreemiumDBPOnboardStateFalse() { + DefaultFreemiumDBPUserStateManager(userDefaults: .dbp).didOnboard = false } @objc func setFirstProfileSavedTimestampNil() { - DefaultFreemiumPIRUserStateManager(userDefaults: .dbp).firstProfileSavedTimestamp = nil + DefaultFreemiumDBPUserStateManager(userDefaults: .dbp).firstProfileSavedTimestamp = nil } @objc func setDidPostFirstProfileSavedNotificationFalse() { - DefaultFreemiumPIRUserStateManager(userDefaults: .dbp).didPostFirstProfileSavedNotification = false + DefaultFreemiumDBPUserStateManager(userDefaults: .dbp).didPostFirstProfileSavedNotification = false } @objc func setDidPostResultsNotificationFalse() { - DefaultFreemiumPIRUserStateManager(userDefaults: .dbp).didPostResultsNotification = false + DefaultFreemiumDBPUserStateManager(userDefaults: .dbp).didPostResultsNotification = false } @objc @@ -82,36 +82,36 @@ final class FreemiumDebugMenu: NSMenuItem { @objc func setFirstScanResultsNil() { - DefaultFreemiumPIRUserStateManager(userDefaults: .dbp).firstScanResults = nil + DefaultFreemiumDBPUserStateManager(userDefaults: .dbp).firstScanResults = nil } @objc func setNewTabPromotionDidDismissFalse() { - DefaultFreemiumPIRUserStateManager(userDefaults: .dbp).didDismissHomePagePromotion = false + DefaultFreemiumDBPUserStateManager(userDefaults: .dbp).didDismissHomePagePromotion = false } @objc func logAllState() { - Logger.freemiumDBP.debug("FREEMIUM DBP: DefaultFreemiumPIRUserStateManager(userDefaults: .dbp).didOnboard \(DefaultFreemiumPIRUserStateManager(userDefaults: .dbp).didOnboard)") - Logger.freemiumDBP.debug("FREEMIUM DBP: DefaultFreemiumPIRUserStateManager(userDefaults: .dbp).firstProfileSavedTimestamp \(DefaultFreemiumPIRUserStateManager(userDefaults: .dbp).firstProfileSavedTimestamp ?? "Nil")") - Logger.freemiumDBP.debug("FREEMIUM DBP: DefaultFreemiumPIRUserStateManager(userDefaults: .dbp).didPostFirstProfileSavedNotification \(DefaultFreemiumPIRUserStateManager(userDefaults: .dbp).didPostFirstProfileSavedNotification)") - Logger.freemiumDBP.debug("FREEMIUM DBP: DefaultFreemiumPIRUserStateManager(userDefaults: .dbp).didPostResultsNotification \(DefaultFreemiumPIRUserStateManager(userDefaults: .dbp).didPostResultsNotification)") - if let results = DefaultFreemiumPIRUserStateManager(userDefaults: .dbp).firstScanResults { - Logger.freemiumDBP.debug("FREEMIUM DBP: DefaultFreemiumPIRUserStateManager(userDefaults: .dbp).firstScanResults \(results.matchesCount) - \(results.brokerCount)") + Logger.freemiumDBP.debug("FREEMIUM DBP: DefaultFreemiumDBPUserStateManager(userDefaults: .dbp).didOnboard \(DefaultFreemiumDBPUserStateManager(userDefaults: .dbp).didOnboard)") + Logger.freemiumDBP.debug("FREEMIUM DBP: DefaultFreemiumDBPUserStateManager(userDefaults: .dbp).firstProfileSavedTimestamp \(DefaultFreemiumDBPUserStateManager(userDefaults: .dbp).firstProfileSavedTimestamp ?? "Nil")") + Logger.freemiumDBP.debug("FREEMIUM DBP: DefaultFreemiumDBPUserStateManager(userDefaults: .dbp).didPostFirstProfileSavedNotification \(DefaultFreemiumDBPUserStateManager(userDefaults: .dbp).didPostFirstProfileSavedNotification)") + Logger.freemiumDBP.debug("FREEMIUM DBP: DefaultFreemiumDBPUserStateManager(userDefaults: .dbp).didPostResultsNotification \(DefaultFreemiumDBPUserStateManager(userDefaults: .dbp).didPostResultsNotification)") + if let results = DefaultFreemiumDBPUserStateManager(userDefaults: .dbp).firstScanResults { + Logger.freemiumDBP.debug("FREEMIUM DBP: DefaultFreemiumDBPUserStateManager(userDefaults: .dbp).firstScanResults \(results.matchesCount) - \(results.brokerCount)") } else { - Logger.freemiumDBP.debug("FREEMIUM DBP: DefaultFreemiumPIRUserStateManager(userDefaults: .dbp).firstScanResults Nil") + Logger.freemiumDBP.debug("FREEMIUM DBP: DefaultFreemiumDBPUserStateManager(userDefaults: .dbp).firstScanResults Nil") } - Logger.freemiumDBP.debug("FREEMIUM DBP: DefaultFreemiumPIRUserStateManager(userDefaults: .dbp).didDismissHomePagePromotion \(DefaultFreemiumPIRUserStateManager(userDefaults: .dbp).didDismissHomePagePromotion)") + Logger.freemiumDBP.debug("FREEMIUM DBP: DefaultFreemiumDBPUserStateManager(userDefaults: .dbp).didDismissHomePagePromotion \(DefaultFreemiumDBPUserStateManager(userDefaults: .dbp).didDismissHomePagePromotion)") } @objc func resetAllState() { - DefaultFreemiumPIRUserStateManager(userDefaults: .dbp).didOnboard = false - DefaultFreemiumPIRUserStateManager(userDefaults: .dbp).firstProfileSavedTimestamp = nil - DefaultFreemiumPIRUserStateManager(userDefaults: .dbp).didPostFirstProfileSavedNotification = false - DefaultFreemiumPIRUserStateManager(userDefaults: .dbp).didPostResultsNotification = false - DefaultFreemiumPIRUserStateManager(userDefaults: .dbp).firstScanResults = nil - DefaultFreemiumPIRUserStateManager(userDefaults: .dbp).didDismissHomePagePromotion = false + DefaultFreemiumDBPUserStateManager(userDefaults: .dbp).didOnboard = false + DefaultFreemiumDBPUserStateManager(userDefaults: .dbp).firstProfileSavedTimestamp = nil + DefaultFreemiumDBPUserStateManager(userDefaults: .dbp).didPostFirstProfileSavedNotification = false + DefaultFreemiumDBPUserStateManager(userDefaults: .dbp).didPostResultsNotification = false + DefaultFreemiumDBPUserStateManager(userDefaults: .dbp).firstScanResults = nil + DefaultFreemiumDBPUserStateManager(userDefaults: .dbp).didDismissHomePagePromotion = false } } diff --git a/DuckDuckGo/HomePage/View/PromotionView.swift b/DuckDuckGo/HomePage/View/PromotionView.swift index efb3c35dd2..93a9a62bf7 100644 --- a/DuckDuckGo/HomePage/View/PromotionView.swift +++ b/DuckDuckGo/HomePage/View/PromotionView.swift @@ -108,5 +108,5 @@ extension HomePage.Views { } #Preview { - return HomePage.Views.PromotionView(viewModel: PromotionViewModel.freemiumPIRPromotion(proceedAction: {}, closeAction: {})) + return HomePage.Views.PromotionView(viewModel: PromotionViewModel.freemiumDBPPromotion(proceedAction: {}, closeAction: {})) } diff --git a/DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift b/DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift index 70eeab0460..79669375a2 100644 --- a/DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift +++ b/DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift @@ -60,9 +60,9 @@ final class MoreOptionsMenu: NSMenu { private lazy var sharingMenu: NSMenu = SharingMenu(title: UserText.shareMenuItem) private var accountManager: AccountManager { subscriptionManager.accountManager } private let subscriptionManager: SubscriptionManager - private var freemiumPIRUserStateManager: FreemiumPIRUserStateManager - private let freemiumPIRFeature: FreemiumPIRFeature - private let freemiumPIRPresenter: FreemiumPIRPresenter + private var freemiumDBPUserStateManager: FreemiumDBPUserStateManager + private let freemiumDBPFeature: FreemiumDBPFeature + private let freemiumDBPPresenter: FreemiumDBPPresenter private let appearancePreferences: AppearancePreferences private let notificationCenter: NotificationCenter @@ -83,9 +83,9 @@ final class MoreOptionsMenu: NSMenu { sharingMenu: NSMenu? = nil, internalUserDecider: InternalUserDecider, subscriptionManager: SubscriptionManager, - freemiumPIRUserStateManager: FreemiumPIRUserStateManager, - freemiumPIRFeature: FreemiumPIRFeature, - freemiumPIRPresenter: FreemiumPIRPresenter = DefaultFreemiumPIRPresenter(), + freemiumDBPUserStateManager: FreemiumDBPUserStateManager, + freemiumDBPFeature: FreemiumDBPFeature, + freemiumDBPPresenter: FreemiumDBPPresenter = DefaultFreemiumDBPPresenter(), appearancePreferences: AppearancePreferences = .shared, notificationCenter: NotificationCenter = .default) { @@ -96,9 +96,9 @@ final class MoreOptionsMenu: NSMenu { self.subscriptionFeatureAvailability = subscriptionFeatureAvailability self.internalUserDecider = internalUserDecider self.subscriptionManager = subscriptionManager - self.freemiumPIRUserStateManager = freemiumPIRUserStateManager - self.freemiumPIRFeature = freemiumPIRFeature - self.freemiumPIRPresenter = freemiumPIRPresenter + self.freemiumDBPUserStateManager = freemiumDBPUserStateManager + self.freemiumDBPFeature = freemiumDBPFeature + self.freemiumDBPPresenter = freemiumDBPPresenter self.appearancePreferences = appearancePreferences self.notificationCenter = notificationCenter @@ -153,7 +153,7 @@ final class MoreOptionsMenu: NSMenu { addItem(NSMenuItem.separator()) - addSubscriptionAndFreemiumPIRItems() + addSubscriptionAndFreemiumDBPItems() addPageItems() @@ -273,13 +273,13 @@ final class MoreOptionsMenu: NSMenu { } @MainActor - @objc func openFreemiumPIR(_ sender: NSMenuItem) { + @objc func openFreemiumDBP(_ sender: NSMenuItem) { // TODO: Remove this - freemiumPIRUserStateManager.didOnboard = true + freemiumDBPUserStateManager.didOnboard = true // ------ - freemiumPIRPresenter.showFreemiumPIR(didOnboard: freemiumPIRUserStateManager.didOnboard, windowControllerManager: WindowControllersManager.shared) + freemiumDBPPresenter.showFreemiumDBP(didOnboard: freemiumDBPUserStateManager.didOnboard, windowControllerManager: WindowControllersManager.shared) notificationCenter.post(name: .freemiumDBPEntryPointActivated, object: nil) } @@ -355,9 +355,9 @@ final class MoreOptionsMenu: NSMenu { } @MainActor - private func addSubscriptionAndFreemiumPIRItems() { + private func addSubscriptionAndFreemiumDBPItems() { addSubscriptionItems() - addFreemiumPIRItem() + addFreemiumDBPItem() addItem(NSMenuItem.separator()) } @@ -390,15 +390,15 @@ final class MoreOptionsMenu: NSMenu { } @MainActor - private func addFreemiumPIRItem() { - guard freemiumPIRFeature.isAvailable else { return } + private func addFreemiumDBPItem() { + guard freemiumDBPFeature.isAvailable else { return } - let freemiumPIRItem = NSMenuItem(title: UserText.freemiumPIROptionsMenuItem).withImage(.dbpIcon) + let freemiumDBPItem = NSMenuItem(title: UserText.freemiumDBPOptionsMenuItem).withImage(.dbpIcon) - freemiumPIRItem.target = self - freemiumPIRItem.action = #selector(openFreemiumPIR(_:)) + freemiumDBPItem.target = self + freemiumDBPItem.action = #selector(openFreemiumDBP(_:)) - addItem(freemiumPIRItem) + addItem(freemiumDBPItem) } @MainActor diff --git a/DuckDuckGo/NavigationBar/View/NavigationBarViewController.swift b/DuckDuckGo/NavigationBar/View/NavigationBarViewController.swift index 529b304db9..99faabc934 100644 --- a/DuckDuckGo/NavigationBar/View/NavigationBarViewController.swift +++ b/DuckDuckGo/NavigationBar/View/NavigationBarViewController.swift @@ -286,15 +286,15 @@ final class NavigationBarViewController: NSViewController { @IBAction func optionsButtonAction(_ sender: NSButton) { let internalUserDecider = NSApp.delegateTyped.internalUserDecider - let freemiumPIRUserStateManager = DefaultFreemiumPIRUserStateManager(userDefaults: .dbp) - let freemiumPIRFeature = DefaultFreemiumPIRFeature(subscriptionManager: subscriptionManager, accountManager: subscriptionManager.accountManager, freemiumPIRUserStateManager: freemiumPIRUserStateManager) + let freemiumDBPUserStateManager = DefaultFreemiumDBPUserStateManager(userDefaults: .dbp) + let freemiumDBPFeature = DefaultFreemiumDBPFeature(subscriptionManager: subscriptionManager, accountManager: subscriptionManager.accountManager, freemiumDBPUserStateManager: freemiumDBPUserStateManager) let menu = MoreOptionsMenu(tabCollectionViewModel: tabCollectionViewModel, passwordManagerCoordinator: PasswordManagerCoordinator.shared, vpnFeatureGatekeeper: DefaultVPNFeatureGatekeeper(subscriptionManager: subscriptionManager), internalUserDecider: internalUserDecider, subscriptionManager: subscriptionManager, - freemiumPIRUserStateManager: freemiumPIRUserStateManager, - freemiumPIRFeature: freemiumPIRFeature) + freemiumDBPUserStateManager: freemiumDBPUserStateManager, + freemiumDBPFeature: freemiumDBPFeature) menu.actionDelegate = self let location = NSPoint(x: -menu.size.width + sender.bounds.width, y: sender.bounds.height + 4) diff --git a/DuckDuckGo/RemoteMessaging/RemoteMessagingConfigMatcherProvider.swift b/DuckDuckGo/RemoteMessaging/RemoteMessagingConfigMatcherProvider.swift index fbfbdd828f..e92fad2aca 100644 --- a/DuckDuckGo/RemoteMessaging/RemoteMessagingConfigMatcherProvider.swift +++ b/DuckDuckGo/RemoteMessaging/RemoteMessagingConfigMatcherProvider.swift @@ -137,8 +137,8 @@ final class RemoteMessagingConfigMatcherProvider: RemoteMessagingConfigMatcherPr let deprecatedRemoteMessageStorage = DefaultSurveyRemoteMessagingStorage.surveys() - let freemiumPIRUserStateManager = DefaultFreemiumPIRUserStateManager(userDefaults: .dbp) - let isCurrentFreemiumPIRUser = !subscriptionManager.accountManager.isUserAuthenticated && freemiumPIRUserStateManager.didOnboard + let freemiumDBPUserStateManager = DefaultFreemiumDBPUserStateManager(userDefaults: .dbp) + let isCurrentFreemiumDBPUser = !subscriptionManager.accountManager.isUserAuthenticated && freemiumDBPUserStateManager.didOnboard return RemoteMessagingConfigMatcher( appAttributeMatcher: AppAttributeMatcher(statisticsStore: statisticsStore, @@ -165,7 +165,7 @@ final class RemoteMessagingConfigMatcherProvider: RemoteMessagingConfigMatcherPr hasCustomHomePage: startupPreferencesPersistor().launchToCustomHomePage, isDuckPlayerOnboarded: duckPlayerPreferencesPersistor.youtubeOverlayAnyButtonPressed, isDuckPlayerEnabled: duckPlayerPreferencesPersistor.duckPlayerModeBool != false, - isCurrentFreemiumPIRUser: isCurrentFreemiumPIRUser, + isCurrentFreemiumPIRUser: isCurrentFreemiumDBPUser, dismissedDeprecatedMacRemoteMessageIds: deprecatedRemoteMessageStorage.dismissedMessageIDs() ), percentileStore: RemoteMessagingPercentileUserDefaultsStore(keyValueStore: UserDefaults.standard), diff --git a/DuckDuckGo/Tab/View/BrowserTabViewController.swift b/DuckDuckGo/Tab/View/BrowserTabViewController.swift index 4a9c8240b9..3870eab7d8 100644 --- a/DuckDuckGo/Tab/View/BrowserTabViewController.swift +++ b/DuckDuckGo/Tab/View/BrowserTabViewController.swift @@ -790,11 +790,11 @@ final class BrowserTabViewController: NSViewController { private func homePageViewControllerCreatingIfNeeded() -> HomePageViewController { return homePageViewController ?? { let subscriptionManager = Application.appDelegate.subscriptionManager - let freemiumDBPUserStateManager = DefaultFreemiumPIRUserStateManager(userDefaults: .dbp) - let freemiumPIRFeature = DefaultFreemiumPIRFeature(subscriptionManager: subscriptionManager, accountManager: subscriptionManager.accountManager, freemiumPIRUserStateManager: freemiumDBPUserStateManager) + let freemiumDBPUserStateManager = DefaultFreemiumDBPUserStateManager(userDefaults: .dbp) + let freemiumDBPFeature = DefaultFreemiumDBPFeature(subscriptionManager: subscriptionManager, accountManager: subscriptionManager.accountManager, freemiumDBPUserStateManager: freemiumDBPUserStateManager) let freemiumDBPPromotionViewCoordinator = FreemiumDBPPromotionViewCoordinator(freemiumDBPUserStateManager: freemiumDBPUserStateManager, - freemiumPIRFeature: freemiumPIRFeature) + freemiumDBPFeature: freemiumDBPFeature) let homePageViewController = HomePageViewController(tabCollectionViewModel: tabCollectionViewModel, bookmarkManager: bookmarkManager, freemiumDBPPromotionViewCoordinator: freemiumDBPPromotionViewCoordinator) self.homePageViewController = homePageViewController @@ -808,9 +808,9 @@ final class BrowserTabViewController: NSViewController { private func dataBrokerProtectionHomeViewControllerCreatingIfNeeded() -> DBPHomeViewController { return dataBrokerProtectionHomeViewController ?? { let subscriptionManager = Application.appDelegate.subscriptionManager - let freemiumPIRUserStateManager = DefaultFreemiumPIRUserStateManager(userDefaults: .dbp) - let freemiumPIRFeature = DefaultFreemiumPIRFeature(subscriptionManager: subscriptionManager, accountManager: subscriptionManager.accountManager, freemiumPIRUserStateManager: freemiumPIRUserStateManager) - let dataBrokerProtectionHomeViewController = DBPHomeViewController(dataBrokerProtectionManager: DataBrokerProtectionManager.shared, freemiumPIRFeature: freemiumPIRFeature) + let freemiumDBPUserStateManager = DefaultFreemiumDBPUserStateManager(userDefaults: .dbp) + let freemiumDBPFeature = DefaultFreemiumDBPFeature(subscriptionManager: subscriptionManager, accountManager: subscriptionManager.accountManager, freemiumDBPUserStateManager: freemiumDBPUserStateManager) + let dataBrokerProtectionHomeViewController = DBPHomeViewController(dataBrokerProtectionManager: DataBrokerProtectionManager.shared, freemiumDBPFeature: freemiumDBPFeature) self.dataBrokerProtectionHomeViewController = dataBrokerProtectionHomeViewController return dataBrokerProtectionHomeViewController }() diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Scheduler/DataBrokerProtectionAgentManager.swift b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Scheduler/DataBrokerProtectionAgentManager.swift index 884b577a0e..99233daa40 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Scheduler/DataBrokerProtectionAgentManager.swift +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Scheduler/DataBrokerProtectionAgentManager.swift @@ -77,13 +77,13 @@ public class DataBrokerProtectionAgentManagerProvider { emailService: emailService, captchaService: captchaService) - let freemiumPIRUserStateManager = DefaultFreemiumPIRUserStateManager(userDefaults: .dbp) + let freemiumDBPUserStateManager = DefaultFreemiumDBPUserStateManager(userDefaults: .dbp) let agentstopper = DefaultDataBrokerProtectionAgentStopper(dataManager: dataManager, entitlementMonitor: DataBrokerProtectionEntitlementMonitor(), authenticationManager: authenticationManager, pixelHandler: pixelHandler, - freemiumPIRUserStateManager: freemiumPIRUserStateManager) + freemiumDBPUserStateManager: freemiumDBPUserStateManager) let operationDependencies = DefaultDataBrokerOperationDependencies( database: dataManager.database, @@ -103,7 +103,7 @@ public class DataBrokerProtectionAgentManagerProvider { pixelHandler: pixelHandler, agentStopper: agentstopper, authenticationManager: authenticationManager, - freemiumPIRUserStateManager: freemiumPIRUserStateManager) + freemiumDBPUserStateManager: freemiumDBPUserStateManager) } } @@ -118,7 +118,7 @@ public final class DataBrokerProtectionAgentManager { private let pixelHandler: EventMapping private let agentStopper: DataBrokerProtectionAgentStopper private let authenticationManager: DataBrokerProtectionAuthenticationManaging - private let freemiumPIRUserStateManager: FreemiumPIRUserStateManager + private let freemiumDBPUserStateManager: FreemiumDBPUserStateManager // Used for debug functions only, so not injected private lazy var browserWindowManager = BrowserWindowManager() @@ -134,7 +134,7 @@ public final class DataBrokerProtectionAgentManager { pixelHandler: EventMapping, agentStopper: DataBrokerProtectionAgentStopper, authenticationManager: DataBrokerProtectionAuthenticationManaging, - freemiumPIRUserStateManager: FreemiumPIRUserStateManager + freemiumDBPUserStateManager: FreemiumDBPUserStateManager ) { self.userNotificationService = userNotificationService self.activityScheduler = activityScheduler @@ -145,7 +145,7 @@ public final class DataBrokerProtectionAgentManager { self.pixelHandler = pixelHandler self.agentStopper = agentStopper self.authenticationManager = authenticationManager - self.freemiumPIRUserStateManager = freemiumPIRUserStateManager + self.freemiumDBPUserStateManager = freemiumDBPUserStateManager self.activityScheduler.delegate = self self.ipcServer.serverDelegate = self diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Utils/DataBrokerProtectionAgentStopper.swift b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Utils/DataBrokerProtectionAgentStopper.swift index 42edf8f3a5..bd1f3132ee 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Utils/DataBrokerProtectionAgentStopper.swift +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Utils/DataBrokerProtectionAgentStopper.swift @@ -36,20 +36,20 @@ struct DefaultDataBrokerProtectionAgentStopper: DataBrokerProtectionAgentStopper private let authenticationManager: DataBrokerProtectionAuthenticationManaging private let pixelHandler: EventMapping private let stopAction: DataProtectionStopAction - private let freemiumPIRUserStateManager: FreemiumPIRUserStateManager + private let freemiumDBPUserStateManager: FreemiumDBPUserStateManager init(dataManager: DataBrokerProtectionDataManaging, entitlementMonitor: DataBrokerProtectionEntitlementMonitoring, authenticationManager: DataBrokerProtectionAuthenticationManaging, pixelHandler: EventMapping, stopAction: DataProtectionStopAction = DefaultDataProtectionStopAction(), - freemiumPIRUserStateManager: FreemiumPIRUserStateManager) { + freemiumDBPUserStateManager: FreemiumDBPUserStateManager) { self.dataManager = dataManager self.entitlementMonitor = entitlementMonitor self.authenticationManager = authenticationManager self.pixelHandler = pixelHandler self.stopAction = stopAction - self.freemiumPIRUserStateManager = freemiumPIRUserStateManager + self.freemiumDBPUserStateManager = freemiumDBPUserStateManager } /// Checks PIR prerequisites and stops the agent if necessary @@ -62,7 +62,7 @@ struct DefaultDataBrokerProtectionAgentStopper: DataBrokerProtectionAgentStopper do { let hasProfile = try dataManager.fetchProfile() != nil let isAuthenticated = authenticationManager.isUserAuthenticated - let didOnboardToFreemium = freemiumPIRUserStateManager.didOnboard + let didOnboardToFreemium = freemiumDBPUserStateManager.didOnboard if !hasProfile || (!isAuthenticated && !didOnboardToFreemium) { Logger.dataBrokerProtection.debug("Prerequisites are invalid") @@ -95,7 +95,7 @@ struct DefaultDataBrokerProtectionAgentStopper: DataBrokerProtectionAgentStopper private func satisfiesFreemiumPrerequisites() -> Bool { let isAuthenticated = authenticationManager.isUserAuthenticated - let didOnboardToFreemium = freemiumPIRUserStateManager.didOnboard + let didOnboardToFreemium = freemiumDBPUserStateManager.didOnboard return !isAuthenticated && didOnboardToFreemium } diff --git a/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/DataBrokerProtectionAgentManagerTests.swift b/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/DataBrokerProtectionAgentManagerTests.swift index 0b462cf8d1..1af1ff9c3d 100644 --- a/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/DataBrokerProtectionAgentManagerTests.swift +++ b/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/DataBrokerProtectionAgentManagerTests.swift @@ -33,7 +33,7 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { private var mockProfile: DataBrokerProtectionProfile! private var mockAgentStopper: MockAgentStopper! private var mockAuthenticationManager: MockAuthenticationManager! - private var mockFreemiumPIRUserStateManager: MockFreemiumPIRUserStateManager! + private var mockFreemiumDBPUserStateManager: MockFreemiumDBPUserStateManager! override func setUpWithError() throws { @@ -70,7 +70,7 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { phones: [], birthYear: 1992) - mockFreemiumPIRUserStateManager = MockFreemiumPIRUserStateManager() + mockFreemiumDBPUserStateManager = MockFreemiumDBPUserStateManager() } func testWhenAgentStart_andProfileExists_andUserIsNotFreemium_thenActivityIsScheduled_andScheduledAllOperationsRun() async throws { @@ -85,11 +85,11 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, authenticationManager: mockAuthenticationManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) mockDataManager.profileToReturn = mockProfile mockAuthenticationManager.isUserAuthenticatedValue = true - mockFreemiumPIRUserStateManager.didOnboard = false + mockFreemiumDBPUserStateManager.didOnboard = false let schedulerStartedExpectation = XCTestExpectation(description: "Scheduler started") var schedulerStarted = false @@ -126,10 +126,10 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, authenticationManager: mockAuthenticationManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) mockDataManager.profileToReturn = mockProfile - mockFreemiumPIRUserStateManager.didOnboard = true + mockFreemiumDBPUserStateManager.didOnboard = true let schedulerStartedExpectation = XCTestExpectation(description: "Scheduler started") var schedulerStarted = false @@ -161,7 +161,7 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { entitlementMonitor: DataBrokerProtectionEntitlementMonitor(), authenticationManager: MockAuthenticationManager(), pixelHandler: mockPixelHandler, - stopAction: mockStopAction, freemiumPIRUserStateManager: MockFreemiumPIRUserStateManager()) + stopAction: mockStopAction, freemiumDBPUserStateManager: MockFreemiumDBPUserStateManager()) sut = DataBrokerProtectionAgentManager( userNotificationService: mockNotificationService, activityScheduler: mockActivityScheduler, @@ -172,10 +172,10 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { pixelHandler: mockPixelHandler, agentStopper: agentStopper, authenticationManager: mockAuthenticationManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) mockDataManager.profileToReturn = nil - mockFreemiumPIRUserStateManager.didOnboard = true + mockFreemiumDBPUserStateManager.didOnboard = true let stopAgentExpectation = XCTestExpectation(description: "Stop agent expectation") @@ -207,7 +207,7 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, authenticationManager: mockAuthenticationManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) mockDataManager.profileToReturn = nil @@ -246,11 +246,11 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, authenticationManager: mockAuthenticationManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) mockDataManager.profileToReturn = mockProfile mockAuthenticationManager.isUserAuthenticatedValue = true - mockFreemiumPIRUserStateManager.didOnboard = false + mockFreemiumDBPUserStateManager.didOnboard = false var startScheduledScansCalled = false mockQueueManager.startScheduledAllOperationsIfPermittedCalledCompletion = { _ in @@ -276,10 +276,10 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, authenticationManager: mockAuthenticationManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) mockDataManager.profileToReturn = mockProfile - mockFreemiumPIRUserStateManager.didOnboard = true + mockFreemiumDBPUserStateManager.didOnboard = true var startScheduledScansCalled = false mockQueueManager.startScheduledScanOperationsIfPermittedCalledCompletion = { _ in @@ -305,10 +305,10 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, authenticationManager: mockAuthenticationManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) mockDataManager.profileToReturn = mockProfile - mockFreemiumPIRUserStateManager.didOnboard = false + mockFreemiumDBPUserStateManager.didOnboard = false var startImmediateScansCalled = false mockQueueManager.startImmediateScanOperationsIfPermittedCalledCompletion = { _ in @@ -334,10 +334,10 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, authenticationManager: mockAuthenticationManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) mockDataManager.profileToReturn = mockProfile - mockFreemiumPIRUserStateManager.didOnboard = true + mockFreemiumDBPUserStateManager.didOnboard = true var startImmediateScansCalled = false mockQueueManager.startImmediateScanOperationsIfPermittedCalledCompletion = { _ in @@ -363,7 +363,7 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, authenticationManager: mockAuthenticationManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) mockNotificationService.reset() @@ -386,7 +386,7 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, authenticationManager: mockAuthenticationManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) mockNotificationService.reset() @@ -409,7 +409,7 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, authenticationManager: mockAuthenticationManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) mockNotificationService.reset() mockQueueManager.startImmediateScanOperationsIfPermittedCompletionError = DataBrokerProtectionAgentErrorCollection(oneTimeError: NSError(domain: "test", code: 10)) @@ -433,7 +433,7 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, authenticationManager: mockAuthenticationManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) mockNotificationService.reset() mockDataManager.shouldReturnHasMatches = true @@ -457,7 +457,7 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, authenticationManager: mockAuthenticationManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) mockNotificationService.reset() mockDataManager.shouldReturnHasMatches = false @@ -481,10 +481,10 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, authenticationManager: mockAuthenticationManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) mockAuthenticationManager.isUserAuthenticatedValue = true - mockFreemiumPIRUserStateManager.didOnboard = false + mockFreemiumDBPUserStateManager.didOnboard = false var startScheduledScansCalled = false mockQueueManager.startScheduledAllOperationsIfPermittedCalledCompletion = { _ in @@ -510,9 +510,9 @@ final class DataBrokerProtectionAgentManagerTests: XCTestCase { pixelHandler: mockPixelHandler, agentStopper: mockAgentStopper, authenticationManager: mockAuthenticationManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) - mockFreemiumPIRUserStateManager.didOnboard = true + mockFreemiumDBPUserStateManager.didOnboard = true var startScheduledScansCalled = false mockQueueManager.startScheduledScanOperationsIfPermittedCalledCompletion = { _ in diff --git a/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/DataBrokerProtectionAgentStopperTests.swift b/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/DataBrokerProtectionAgentStopperTests.swift index f9f3f9b27f..97bae3c17a 100644 --- a/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/DataBrokerProtectionAgentStopperTests.swift +++ b/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/DataBrokerProtectionAgentStopperTests.swift @@ -29,7 +29,7 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { private var mockEntitlementMonitor: DataBrokerProtectionEntitlementMonitor! private var mockDataManager: MockDataBrokerProtectionDataManager! private var mockStopAction: MockDataProtectionStopAction! - private var mockFreemiumPIRUserStateManager: MockFreemiumPIRUserStateManager! + private var mockFreemiumDBPUserStateManager: MockFreemiumDBPUserStateManager! private var fakeProfile: DataBrokerProtectionProfile { let name = DataBrokerProtectionProfile.Name(firstName: "John", lastName: "Doe") @@ -46,8 +46,8 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockDataManager = MockDataBrokerProtectionDataManager(pixelHandler: mockPixelHandler, fakeBrokerFlag: DataBrokerDebugFlagFakeBroker()) mockStopAction = MockDataProtectionStopAction() - mockFreemiumPIRUserStateManager = MockFreemiumPIRUserStateManager() - mockFreemiumPIRUserStateManager.didOnboard = false + mockFreemiumDBPUserStateManager = MockFreemiumDBPUserStateManager() + mockFreemiumDBPUserStateManager.didOnboard = false } override func tearDown() { @@ -63,14 +63,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = false mockAuthenticationManager.hasValidEntitlementValue = true mockDataManager.profileToReturn = nil - mockFreemiumPIRUserStateManager.didOnboard = false + mockFreemiumDBPUserStateManager.didOnboard = false let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) await stopper.validateRunPrerequisitesAndStopAgentIfNecessary() XCTAssertTrue(mockStopAction.wasStopCalled) @@ -80,14 +80,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = false mockAuthenticationManager.hasValidEntitlementValue = true mockDataManager.profileToReturn = nil - mockFreemiumPIRUserStateManager.didOnboard = true + mockFreemiumDBPUserStateManager.didOnboard = true let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) await stopper.validateRunPrerequisitesAndStopAgentIfNecessary() XCTAssertTrue(mockStopAction.wasStopCalled) @@ -97,14 +97,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = true mockAuthenticationManager.hasValidEntitlementValue = true mockDataManager.profileToReturn = nil - mockFreemiumPIRUserStateManager.didOnboard = false + mockFreemiumDBPUserStateManager.didOnboard = false let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) await stopper.validateRunPrerequisitesAndStopAgentIfNecessary() XCTAssertTrue(mockStopAction.wasStopCalled) @@ -114,14 +114,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = true mockAuthenticationManager.hasValidEntitlementValue = true mockDataManager.profileToReturn = nil - mockFreemiumPIRUserStateManager.didOnboard = true + mockFreemiumDBPUserStateManager.didOnboard = true let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) await stopper.validateRunPrerequisitesAndStopAgentIfNecessary() XCTAssertTrue(mockStopAction.wasStopCalled) @@ -131,14 +131,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = false mockAuthenticationManager.hasValidEntitlementValue = false mockDataManager.profileToReturn = fakeProfile - mockFreemiumPIRUserStateManager.didOnboard = false + mockFreemiumDBPUserStateManager.didOnboard = false let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) await stopper.validateRunPrerequisitesAndStopAgentIfNecessary() XCTAssertTrue(mockStopAction.wasStopCalled) @@ -148,14 +148,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = false mockAuthenticationManager.hasValidEntitlementValue = false mockDataManager.profileToReturn = fakeProfile - mockFreemiumPIRUserStateManager.didOnboard = true + mockFreemiumDBPUserStateManager.didOnboard = true let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) await stopper.validateRunPrerequisitesAndStopAgentIfNecessary() XCTAssertFalse(mockStopAction.wasStopCalled) @@ -165,14 +165,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = true mockAuthenticationManager.hasValidEntitlementValue = false mockDataManager.profileToReturn = fakeProfile - mockFreemiumPIRUserStateManager.didOnboard = false + mockFreemiumDBPUserStateManager.didOnboard = false let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) await stopper.validateRunPrerequisitesAndStopAgentIfNecessary() XCTAssertTrue(mockStopAction.wasStopCalled) @@ -182,14 +182,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = true mockAuthenticationManager.hasValidEntitlementValue = false mockDataManager.profileToReturn = fakeProfile - mockFreemiumPIRUserStateManager.didOnboard = true + mockFreemiumDBPUserStateManager.didOnboard = true let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) await stopper.validateRunPrerequisitesAndStopAgentIfNecessary() XCTAssertTrue(mockStopAction.wasStopCalled) @@ -199,14 +199,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = false mockAuthenticationManager.hasValidEntitlementValue = true mockDataManager.profileToReturn = fakeProfile - mockFreemiumPIRUserStateManager.didOnboard = false + mockFreemiumDBPUserStateManager.didOnboard = false let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) await stopper.validateRunPrerequisitesAndStopAgentIfNecessary() XCTAssertTrue(mockStopAction.wasStopCalled) @@ -216,14 +216,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = false mockAuthenticationManager.hasValidEntitlementValue = true mockDataManager.profileToReturn = fakeProfile - mockFreemiumPIRUserStateManager.didOnboard = true + mockFreemiumDBPUserStateManager.didOnboard = true let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) await stopper.validateRunPrerequisitesAndStopAgentIfNecessary() XCTAssertFalse(mockStopAction.wasStopCalled) @@ -239,7 +239,7 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) await stopper.validateRunPrerequisitesAndStopAgentIfNecessary() XCTAssertFalse(mockStopAction.wasStopCalled) @@ -249,14 +249,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = true mockAuthenticationManager.hasValidEntitlementValue = true mockDataManager.profileToReturn = fakeProfile - mockFreemiumPIRUserStateManager.didOnboard = false + mockFreemiumDBPUserStateManager.didOnboard = false let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) await stopper.validateRunPrerequisitesAndStopAgentIfNecessary() XCTAssertFalse(mockStopAction.wasStopCalled) @@ -266,14 +266,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = true mockAuthenticationManager.hasValidEntitlementValue = true mockDataManager.profileToReturn = fakeProfile - mockFreemiumPIRUserStateManager.didOnboard = false + mockFreemiumDBPUserStateManager.didOnboard = false let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) await stopper.validateRunPrerequisitesAndStopAgentIfNecessary() XCTAssertFalse(mockStopAction.wasStopCalled) @@ -283,14 +283,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = true mockAuthenticationManager.hasValidEntitlementValue = true mockDataManager.profileToReturn = fakeProfile - mockFreemiumPIRUserStateManager.didOnboard = false + mockFreemiumDBPUserStateManager.didOnboard = false let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) let expectation = XCTestExpectation(description: "Wait for monitor") stopper.monitorEntitlementAndStopAgentIfEntitlementIsInvalidAndUserIsNotFreemium(interval: 0.1) @@ -307,14 +307,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = true mockAuthenticationManager.hasValidEntitlementValue = true mockDataManager.profileToReturn = fakeProfile - mockFreemiumPIRUserStateManager.didOnboard = true + mockFreemiumDBPUserStateManager.didOnboard = true let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) let expectation = XCTestExpectation(description: "Wait for monitor") stopper.monitorEntitlementAndStopAgentIfEntitlementIsInvalidAndUserIsNotFreemium(interval: 0.1) @@ -331,14 +331,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = true mockAuthenticationManager.hasValidEntitlementValue = false mockDataManager.profileToReturn = fakeProfile - mockFreemiumPIRUserStateManager.didOnboard = false + mockFreemiumDBPUserStateManager.didOnboard = false let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) let expectation = XCTestExpectation(description: "Wait for monitor") stopper.monitorEntitlementAndStopAgentIfEntitlementIsInvalidAndUserIsNotFreemium(interval: 0.1) @@ -355,14 +355,14 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { mockAuthenticationManager.isUserAuthenticatedValue = false mockAuthenticationManager.hasValidEntitlementValue = false mockDataManager.profileToReturn = fakeProfile - mockFreemiumPIRUserStateManager.didOnboard = true + mockFreemiumDBPUserStateManager.didOnboard = true let stopper = DefaultDataBrokerProtectionAgentStopper(dataManager: mockDataManager, entitlementMonitor: mockEntitlementMonitor, authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) let expectation = XCTestExpectation(description: "Wait for monitor") stopper.monitorEntitlementAndStopAgentIfEntitlementIsInvalidAndUserIsNotFreemium(interval: 0.1) @@ -385,7 +385,7 @@ final class DataBrokerProtectionAgentStopperTests: XCTestCase { authenticationManager: mockAuthenticationManager, pixelHandler: mockPixelHandler, stopAction: mockStopAction, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) let expectation = XCTestExpectation(description: "Wait for monitor") stopper.monitorEntitlementAndStopAgentIfEntitlementIsInvalidAndUserIsNotFreemium(interval: 0.1) diff --git a/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/Mocks.swift b/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/Mocks.swift index 25aa743b4f..fee4b47f02 100644 --- a/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/Mocks.swift +++ b/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/Mocks.swift @@ -1959,7 +1959,7 @@ struct MockMigrationsProvider: DataBrokerProtectionDatabaseMigrationsProvider { } } -final class MockFreemiumPIRUserStateManager: FreemiumPIRUserStateManager { +final class MockFreemiumDBPUserStateManager: FreemiumDBPUserStateManager { var didOnboard = false var didPostFirstProfileSavedNotification = false var didPostResultsNotification = false diff --git a/LocalPackages/Freemium/Sources/Freemium/FreemiumPIRUserStateManager.swift b/LocalPackages/Freemium/Sources/Freemium/FreemiumDBPUserStateManager.swift similarity index 81% rename from LocalPackages/Freemium/Sources/Freemium/FreemiumPIRUserStateManager.swift rename to LocalPackages/Freemium/Sources/Freemium/FreemiumDBPUserStateManager.swift index cf9de18af8..ce95ef89e8 100644 --- a/LocalPackages/Freemium/Sources/Freemium/FreemiumPIRUserStateManager.swift +++ b/LocalPackages/Freemium/Sources/Freemium/FreemiumDBPUserStateManager.swift @@ -1,5 +1,5 @@ // -// FreemiumPIRUserStateManager.swift +// FreemiumDBPUserStateManager.swift // // Copyright © 2024 DuckDuckGo. All rights reserved. // @@ -38,13 +38,13 @@ public struct FreemiumDBPMatchResults: Codable, Equatable { } } -/// Protocol that manages the user's state in the FreemiumPIR feature. +/// Protocol that manages the user's state in the FreemiumDBP feature. /// /// The properties in this protocol represent the various states and milestones in the user journey, /// such as whether onboarding is complete, notifications have been posted, and important timestamps or data points. /// /// Conforming types are responsible for persisting and retrieving these values. -public protocol FreemiumPIRUserStateManager { +public protocol FreemiumDBPUserStateManager { /// A boolean value indicating whether the user has completed the onboarding process. var didOnboard: Bool { get set } @@ -65,28 +65,28 @@ public protocol FreemiumPIRUserStateManager { var firstScanResults: FreemiumDBPMatchResults? { get set } } -/// Default implementation of `FreemiumPIRUserStateManager` that uses `UserDefaults` for underlying storage. +/// Default implementation of `FreemiumDBPUserStateManager` that uses `UserDefaults` for underlying storage. /// /// Each property in this class corresponds to a specific `UserDefaults` key to maintain persistence across app sessions. -public final class DefaultFreemiumPIRUserStateManager: FreemiumPIRUserStateManager { +public final class DefaultFreemiumDBPUserStateManager: FreemiumDBPUserStateManager { /// Keys for storing the values in `UserDefaults`. private enum Keys { - static let didOnboard = "macos.browser.freemium.pir.did.onboard" - static let didPostFirstProfileSavedNotification = "macos.browser.freemium.pir.did.post.first.profile.saved.notification" - static let didPostResultsNotification = "macos.browser.freemium.pir.did.post.results.notification" - static let didDismissHomePagePromotion = "macos.browser.freemium.pir.did.post.dismiss.home.page.promotion" - static let firstProfileSavedTimestamp = "macos.browser.freemium.pir.first.profile.saved.timestamp" - static let firstScanResults = "macos.browser.freemium.pir.first.scan.results" + static let didOnboard = "macos.browser.freemium.dbp.did.onboard" + static let didPostFirstProfileSavedNotification = "macos.browser.freemium.dbp.did.post.first.profile.saved.notification" + static let didPostResultsNotification = "macos.browser.freemium.dbp.did.post.results.notification" + static let didDismissHomePagePromotion = "macos.browser.freemium.dbp.did.post.dismiss.home.page.promotion" + static let firstProfileSavedTimestamp = "macos.browser.freemium.dbp.first.profile.saved.timestamp" + static let firstScanResults = "macos.browser.freemium.dbp.first.scan.results" } private let userDefaults: UserDefaults - // MARK: - FreemiumPIRUserStateManager Properties + // MARK: - FreemiumDBPUserStateManager Properties /// Tracks whether the user has completed the onboarding process. /// - /// - Uses the `UserDefaults` key: `macos.browser.freemium.pir.did.onboard`. + /// - Uses the `UserDefaults` key: `macos.browser.freemium.dbp.did.onboard`. public var didOnboard: Bool { get { userDefaults.bool(forKey: Keys.didOnboard) @@ -98,7 +98,7 @@ public final class DefaultFreemiumPIRUserStateManager: FreemiumPIRUserStateManag /// Tracks the timestamp of when the user saved their first profile. /// - /// - Uses the `UserDefaults` key: `macos.browser.freemium.pir.first.profile.saved.timestamp`. + /// - Uses the `UserDefaults` key: `macos.browser.freemium.dbp.first.profile.saved.timestamp`. public var firstProfileSavedTimestamp: String? { get { userDefaults.value(forKey: Keys.firstProfileSavedTimestamp) as? String @@ -110,7 +110,7 @@ public final class DefaultFreemiumPIRUserStateManager: FreemiumPIRUserStateManag /// Tracks whether the "First Profile Saved" notification has been posted. /// - /// - Uses the `UserDefaults` key: `macos.browser.freemium.pir.did.post.first.profile.saved.notification`. + /// - Uses the `UserDefaults` key: `macos.browser.freemium.dbp.did.post.first.profile.saved.notification`. public var didPostFirstProfileSavedNotification: Bool { get { userDefaults.bool(forKey: Keys.didPostFirstProfileSavedNotification) @@ -122,7 +122,7 @@ public final class DefaultFreemiumPIRUserStateManager: FreemiumPIRUserStateManag /// Tracks whether the results notification has been posted. /// - /// - Uses the `UserDefaults` key: `macos.browser.freemium.pir.did.post.results.notification`. + /// - Uses the `UserDefaults` key: `macos.browser.freemium.dbp.did.post.results.notification`. public var didPostResultsNotification: Bool { get { userDefaults.bool(forKey: Keys.didPostResultsNotification) @@ -135,7 +135,7 @@ public final class DefaultFreemiumPIRUserStateManager: FreemiumPIRUserStateManag /// Tracks the results of the user's first scan. /// /// This value is stored as a `FreemiumDBPMatchResults` object, encoded and decoded using `JSONEncoder` and `JSONDecoder`. - /// - Uses the `UserDefaults` key: `macos.browser.freemium.pir.first.scan.results`. + /// - Uses the `UserDefaults` key: `macos.browser.freemium.dbp.first.scan.results`. public var firstScanResults: FreemiumDBPMatchResults? { get { guard let data = userDefaults.object(forKey: Keys.firstScanResults) as? Data, @@ -151,7 +151,7 @@ public final class DefaultFreemiumPIRUserStateManager: FreemiumPIRUserStateManag /// Tracks whether the user has dismissed the homepage promotion. /// - /// - Uses the `UserDefaults` key: `macos.browser.freemium.pir.did.post.dismiss.home.page.promotion`. + /// - Uses the `UserDefaults` key: `macos.browser.freemium.dbp.did.post.dismiss.home.page.promotion`. public var didDismissHomePagePromotion: Bool { get { userDefaults.bool(forKey: Keys.didDismissHomePagePromotion) @@ -163,7 +163,7 @@ public final class DefaultFreemiumPIRUserStateManager: FreemiumPIRUserStateManag // MARK: - Initialization - /// Initializes a new instance of `DefaultFreemiumPIRUserStateManager`. + /// Initializes a new instance of `DefaultFreemiumDBPUserStateManager`. /// /// - Parameter userDefaults: The `UserDefaults` instance used to store and retrieve the user's state data. /// diff --git a/LocalPackages/Freemium/Tests/FreemiumTests/FreemiumPIRUserStateManagerTests.swift b/LocalPackages/Freemium/Tests/FreemiumTests/FreemiumDBPUserStateManagerTests.swift similarity index 83% rename from LocalPackages/Freemium/Tests/FreemiumTests/FreemiumPIRUserStateManagerTests.swift rename to LocalPackages/Freemium/Tests/FreemiumTests/FreemiumDBPUserStateManagerTests.swift index 50f68ccd37..cea25342f3 100644 --- a/LocalPackages/Freemium/Tests/FreemiumTests/FreemiumPIRUserStateManagerTests.swift +++ b/LocalPackages/Freemium/Tests/FreemiumTests/FreemiumDBPUserStateManagerTests.swift @@ -1,5 +1,5 @@ // -// FreemiumPIRUserStateManagerTests.swift +// FreemiumDBPUserStateManagerTests.swift // // Copyright © 2024 DuckDuckGo. All rights reserved. // @@ -19,27 +19,27 @@ import XCTest @testable import Freemium -final class FreemiumPIRUserStateManagerTests: XCTestCase { +final class FreemiumDBPUserStateManagerTests: XCTestCase { private enum Keys { - static let didOnboard = "macos.browser.freemium.pir.did.onboard" - static let didPostFirstProfileSavedNotification = "macos.browser.freemium.pir.did.post.first.profile.saved.notification" - static let didPostResultsNotification = "macos.browser.freemium.pir.did.post.results.notification" - static let didDismissHomePagePromotion = "macos.browser.freemium.pir.did.post.dismiss.home.page.promotion" - static let firstProfileSavedTimestamp = "macos.browser.freemium.pir.first.profile.saved.timestamp" - static let firstScanResults = "macos.browser.freemium.pir.first.scan.results" + static let didOnboard = "macos.browser.freemium.dbp.did.onboard" + static let didPostFirstProfileSavedNotification = "macos.browser.freemium.dbp.did.post.first.profile.saved.notification" + static let didPostResultsNotification = "macos.browser.freemium.dbp.did.post.results.notification" + static let didDismissHomePagePromotion = "macos.browser.freemium.dbp.did.post.dismiss.home.page.promotion" + static let firstProfileSavedTimestamp = "macos.browser.freemium.dbp.first.profile.saved.timestamp" + static let firstScanResults = "macos.browser.freemium.dbp.first.scan.results" } private static let testSuiteName = "test.defaults.freemium.user.state.tests" - private let testUserDefaults = UserDefaults(suiteName: FreemiumPIRUserStateManagerTests.testSuiteName)! + private let testUserDefaults = UserDefaults(suiteName: FreemiumDBPUserStateManagerTests.testSuiteName)! override func setUpWithError() throws { - testUserDefaults.removePersistentDomain(forName: FreemiumPIRUserStateManagerTests.testSuiteName) + testUserDefaults.removePersistentDomain(forName: FreemiumDBPUserStateManagerTests.testSuiteName) } func testSetsDidOnboard() throws { // Given - let sut = DefaultFreemiumPIRUserStateManager(userDefaults: testUserDefaults) + let sut = DefaultFreemiumDBPUserStateManager(userDefaults: testUserDefaults) XCTAssertFalse(testUserDefaults.bool(forKey: Keys.didOnboard)) // When @@ -51,7 +51,7 @@ final class FreemiumPIRUserStateManagerTests: XCTestCase { func testGetsDidOnboard() throws { // Given - let sut = DefaultFreemiumPIRUserStateManager(userDefaults: testUserDefaults) + let sut = DefaultFreemiumDBPUserStateManager(userDefaults: testUserDefaults) XCTAssertFalse(sut.didOnboard) testUserDefaults.setValue(true, forKey: Keys.didOnboard) XCTAssertTrue(testUserDefaults.bool(forKey: Keys.didOnboard)) @@ -65,7 +65,7 @@ final class FreemiumPIRUserStateManagerTests: XCTestCase { func testSetsfirstProfileSavedTimestamp() throws { // Given - let sut = DefaultFreemiumPIRUserStateManager(userDefaults: testUserDefaults) + let sut = DefaultFreemiumDBPUserStateManager(userDefaults: testUserDefaults) XCTAssertNil(testUserDefaults.value(forKey: Keys.firstProfileSavedTimestamp)) // When @@ -77,7 +77,7 @@ final class FreemiumPIRUserStateManagerTests: XCTestCase { func testGetsfirstProfileSavedTimestamp() throws { // Given - let sut = DefaultFreemiumPIRUserStateManager(userDefaults: testUserDefaults) + let sut = DefaultFreemiumDBPUserStateManager(userDefaults: testUserDefaults) XCTAssertNil(sut.firstProfileSavedTimestamp) testUserDefaults.setValue("time_stamp", forKey: Keys.firstProfileSavedTimestamp) XCTAssertNotNil(testUserDefaults.value(forKey: Keys.firstProfileSavedTimestamp)) @@ -91,7 +91,7 @@ final class FreemiumPIRUserStateManagerTests: XCTestCase { func testSetsDidPostFirstProfileSavedNotification() throws { // Given - let sut = DefaultFreemiumPIRUserStateManager(userDefaults: testUserDefaults) + let sut = DefaultFreemiumDBPUserStateManager(userDefaults: testUserDefaults) XCTAssertFalse(testUserDefaults.bool(forKey: Keys.didPostFirstProfileSavedNotification)) // When @@ -103,7 +103,7 @@ final class FreemiumPIRUserStateManagerTests: XCTestCase { func testGetsDidPostFirstProfileSavedNotification() throws { // Given - let sut = DefaultFreemiumPIRUserStateManager(userDefaults: testUserDefaults) + let sut = DefaultFreemiumDBPUserStateManager(userDefaults: testUserDefaults) XCTAssertFalse(sut.didPostFirstProfileSavedNotification) testUserDefaults.setValue(true, forKey: Keys.didPostFirstProfileSavedNotification) XCTAssertTrue(testUserDefaults.bool(forKey: Keys.didPostFirstProfileSavedNotification)) @@ -117,7 +117,7 @@ final class FreemiumPIRUserStateManagerTests: XCTestCase { func testSetsDidPostResultsNotification() throws { // Given - let sut = DefaultFreemiumPIRUserStateManager(userDefaults: testUserDefaults) + let sut = DefaultFreemiumDBPUserStateManager(userDefaults: testUserDefaults) XCTAssertFalse(testUserDefaults.bool(forKey: Keys.didPostResultsNotification)) // When @@ -129,7 +129,7 @@ final class FreemiumPIRUserStateManagerTests: XCTestCase { func testGetsDidPostResultsNotification() throws { // Given - let sut = DefaultFreemiumPIRUserStateManager(userDefaults: testUserDefaults) + let sut = DefaultFreemiumDBPUserStateManager(userDefaults: testUserDefaults) XCTAssertFalse(sut.didPostResultsNotification) testUserDefaults.setValue(true, forKey: Keys.didPostResultsNotification) XCTAssertTrue(testUserDefaults.bool(forKey: Keys.didPostResultsNotification)) @@ -143,7 +143,7 @@ final class FreemiumPIRUserStateManagerTests: XCTestCase { func testSetsDidDismissHomePagePromotion() throws { // Given - let sut = DefaultFreemiumPIRUserStateManager(userDefaults: testUserDefaults) + let sut = DefaultFreemiumDBPUserStateManager(userDefaults: testUserDefaults) XCTAssertFalse(testUserDefaults.bool(forKey: Keys.didDismissHomePagePromotion)) // When @@ -155,7 +155,7 @@ final class FreemiumPIRUserStateManagerTests: XCTestCase { func testGetsDidDismissHomePagePromotion() throws { // Given - let sut = DefaultFreemiumPIRUserStateManager(userDefaults: testUserDefaults) + let sut = DefaultFreemiumDBPUserStateManager(userDefaults: testUserDefaults) XCTAssertFalse(sut.didDismissHomePagePromotion) testUserDefaults.setValue(true, forKey: Keys.didDismissHomePagePromotion) XCTAssertTrue(testUserDefaults.bool(forKey: Keys.didDismissHomePagePromotion)) @@ -169,7 +169,7 @@ final class FreemiumPIRUserStateManagerTests: XCTestCase { func testSetsFirstScanResults() throws { // Given - let sut = DefaultFreemiumPIRUserStateManager(userDefaults: testUserDefaults) + let sut = DefaultFreemiumDBPUserStateManager(userDefaults: testUserDefaults) XCTAssertNil(testUserDefaults.data(forKey: Keys.firstScanResults)) // When @@ -188,7 +188,7 @@ final class FreemiumPIRUserStateManagerTests: XCTestCase { func testGetsFirstScanResults() throws { // Given - let sut = DefaultFreemiumPIRUserStateManager(userDefaults: testUserDefaults) + let sut = DefaultFreemiumDBPUserStateManager(userDefaults: testUserDefaults) XCTAssertNil(sut.firstScanResults) // When diff --git a/UnitTests/DBP/Tests/DataBrokerProtectionFeatureGatekeeperTests.swift b/UnitTests/DBP/Tests/DataBrokerProtectionFeatureGatekeeperTests.swift index 885816f9e5..1d19e9d428 100644 --- a/UnitTests/DBP/Tests/DataBrokerProtectionFeatureGatekeeperTests.swift +++ b/UnitTests/DBP/Tests/DataBrokerProtectionFeatureGatekeeperTests.swift @@ -28,7 +28,7 @@ final class DataBrokerProtectionFeatureGatekeeperTests: XCTestCase { private var mockFeatureDisabler: MockFeatureDisabler! private var mockFeatureAvailability: MockFeatureAvailability! private var mockAccountManager: MockAccountManager! - private var mockFreemiumPIRUserStateManager: MockFreemiumPIRUserStateManager! + private var mockFreemiumDBPUserStateManager: MockFreemiumDBPUserStateManager! private func userDefaults() -> UserDefaults { UserDefaults(suiteName: "testing_\(UUID().uuidString)")! @@ -38,8 +38,8 @@ final class DataBrokerProtectionFeatureGatekeeperTests: XCTestCase { mockFeatureDisabler = MockFeatureDisabler() mockFeatureAvailability = MockFeatureAvailability() mockAccountManager = MockAccountManager() - mockFreemiumPIRUserStateManager = MockFreemiumPIRUserStateManager() - mockFreemiumPIRUserStateManager.didOnboard = false + mockFreemiumDBPUserStateManager = MockFreemiumDBPUserStateManager() + mockFreemiumDBPUserStateManager.didOnboard = false } func testWhenNoAccessTokenIsFound_butEntitlementIs_andIsNotActiveFreemiumUser_thenFeatureIsDisabled() async { @@ -50,7 +50,7 @@ final class DataBrokerProtectionFeatureGatekeeperTests: XCTestCase { userDefaults: userDefaults(), subscriptionAvailability: mockFeatureAvailability, accountManager: mockAccountManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) // When let result = await sut.arePrerequisitesSatisfied() @@ -63,12 +63,12 @@ final class DataBrokerProtectionFeatureGatekeeperTests: XCTestCase { // Given mockAccountManager.accessToken = "token" mockAccountManager.hasEntitlementResult = .failure(MockError.someError) - mockFreemiumPIRUserStateManager.didOnboard = false + mockFreemiumDBPUserStateManager.didOnboard = false sut = DefaultDataBrokerProtectionFeatureGatekeeper(featureDisabler: mockFeatureDisabler, userDefaults: userDefaults(), subscriptionAvailability: mockFeatureAvailability, accountManager: mockAccountManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) // When let result = await sut.arePrerequisitesSatisfied() @@ -81,12 +81,12 @@ final class DataBrokerProtectionFeatureGatekeeperTests: XCTestCase { // Given mockAccountManager.accessToken = "token" mockAccountManager.hasEntitlementResult = .failure(MockError.someError) - mockFreemiumPIRUserStateManager.didOnboard = true + mockFreemiumDBPUserStateManager.didOnboard = true sut = DefaultDataBrokerProtectionFeatureGatekeeper(featureDisabler: mockFeatureDisabler, userDefaults: userDefaults(), subscriptionAvailability: mockFeatureAvailability, accountManager: mockAccountManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) // When let result = await sut.arePrerequisitesSatisfied() @@ -99,12 +99,12 @@ final class DataBrokerProtectionFeatureGatekeeperTests: XCTestCase { // Given mockAccountManager.accessToken = nil mockAccountManager.hasEntitlementResult = .failure(MockError.someError) - mockFreemiumPIRUserStateManager.didOnboard = false + mockFreemiumDBPUserStateManager.didOnboard = false sut = DefaultDataBrokerProtectionFeatureGatekeeper(featureDisabler: mockFeatureDisabler, userDefaults: userDefaults(), subscriptionAvailability: mockFeatureAvailability, accountManager: mockAccountManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) // When let result = await sut.arePrerequisitesSatisfied() @@ -117,12 +117,12 @@ final class DataBrokerProtectionFeatureGatekeeperTests: XCTestCase { // Given mockAccountManager.accessToken = "token" mockAccountManager.hasEntitlementResult = .success(true) - mockFreemiumPIRUserStateManager.didOnboard = false + mockFreemiumDBPUserStateManager.didOnboard = false sut = DefaultDataBrokerProtectionFeatureGatekeeper(featureDisabler: mockFeatureDisabler, userDefaults: userDefaults(), subscriptionAvailability: mockFeatureAvailability, accountManager: mockAccountManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) // When let result = await sut.arePrerequisitesSatisfied() @@ -135,12 +135,12 @@ final class DataBrokerProtectionFeatureGatekeeperTests: XCTestCase { // Given mockAccountManager.accessToken = nil mockAccountManager.hasEntitlementResult = .failure(MockError.someError) - mockFreemiumPIRUserStateManager.didOnboard = true + mockFreemiumDBPUserStateManager.didOnboard = true sut = DefaultDataBrokerProtectionFeatureGatekeeper(featureDisabler: mockFeatureDisabler, userDefaults: userDefaults(), subscriptionAvailability: mockFeatureAvailability, accountManager: mockAccountManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager) + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager) // When let result = await sut.arePrerequisitesSatisfied() diff --git a/UnitTests/Freemium/PIR/FreemiumPIRFeatureTests.swift b/UnitTests/Freemium/DBP/FreemiumDBPFeatureTests.swift similarity index 74% rename from UnitTests/Freemium/PIR/FreemiumPIRFeatureTests.swift rename to UnitTests/Freemium/DBP/FreemiumDBPFeatureTests.swift index edd1f80e4e..66e6e6c922 100644 --- a/UnitTests/Freemium/PIR/FreemiumPIRFeatureTests.swift +++ b/UnitTests/Freemium/DBP/FreemiumDBPFeatureTests.swift @@ -1,5 +1,5 @@ // -// FreemiumPIRFeatureTests.swift +// FreemiumDBPFeatureTests.swift // // Copyright © 2024 DuckDuckGo. All rights reserved. // @@ -23,18 +23,18 @@ import BrowserServicesKit import SubscriptionTestingUtilities import Freemium -final class FreemiumPIRFeatureTests: XCTestCase { +final class FreemiumDBPFeatureTests: XCTestCase { - private var sut: FreemiumPIRFeature! - private var mockFeatureFlagger: MockFreemiumPIRFeatureFlagger! + private var sut: FreemiumDBPFeature! + private var mockFeatureFlagger: MockFreemiumDBPFeatureFlagger! private var mockAccountManager: MockAccountManager! private var mockSubscriptionManager: SubscriptionManagerMock! - private var mockFreemiumPIRUserStateManagerManager: MockFreemiumPIRUserStateManager! + private var mockFreemiumDBPUserStateManagerManager: MockFreemiumDBPUserStateManager! private var mockFeatureDisabler: MockFeatureDisabler! override func setUpWithError() throws { - mockFeatureFlagger = MockFreemiumPIRFeatureFlagger() + mockFeatureFlagger = MockFreemiumDBPFeatureFlagger() mockAccountManager = MockAccountManager() let mockSubscriptionService = SubscriptionEndpointServiceMock() let mockAuthService = SubscriptionMockFactory.authEndpointService @@ -54,20 +54,20 @@ final class FreemiumPIRFeatureTests: XCTestCase { currentEnvironment: currentEnvironment, canPurchase: false) - mockFreemiumPIRUserStateManagerManager = MockFreemiumPIRUserStateManager() + mockFreemiumDBPUserStateManagerManager = MockFreemiumDBPUserStateManager() mockFeatureDisabler = MockFeatureDisabler() } - func testWhenFeatureFlagDisabled_thenFreemiumPIRIsNotAvailable() throws { + func testWhenFeatureFlagDisabled_thenFreemiumDBPIsNotAvailable() throws { // Given mockFeatureFlagger.isEnabled = false mockSubscriptionManager.canPurchase = true mockAccountManager.accessToken = nil - sut = DefaultFreemiumPIRFeature(featureFlagger: mockFeatureFlagger, + sut = DefaultFreemiumDBPFeature(featureFlagger: mockFeatureFlagger, subscriptionManager: mockSubscriptionManager, accountManager: mockAccountManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManagerManager, + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManagerManager, featureDisabler: mockFeatureDisabler) // When let result = sut.isAvailable @@ -76,15 +76,15 @@ final class FreemiumPIRFeatureTests: XCTestCase { XCTAssertFalse(result) } - func testWhenPrivacyProNotAvailable_thenFreemiumPIRIsNotAvailable() throws { + func testWhenPrivacyProNotAvailable_thenFreemiumDBPIsNotAvailable() throws { // Given mockFeatureFlagger.isEnabled = true mockSubscriptionManager.canPurchase = false mockAccountManager.accessToken = nil - sut = DefaultFreemiumPIRFeature(featureFlagger: mockFeatureFlagger, + sut = DefaultFreemiumDBPFeature(featureFlagger: mockFeatureFlagger, subscriptionManager: mockSubscriptionManager, accountManager: mockAccountManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManagerManager, + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManagerManager, featureDisabler: mockFeatureDisabler) // When let result = sut.isAvailable @@ -93,15 +93,15 @@ final class FreemiumPIRFeatureTests: XCTestCase { XCTAssertFalse(result) } - func testWhenAllConditionsAreNotMet_thenFreemiumPIRIsNotAvailable() throws { + func testWhenAllConditionsAreNotMet_thenFreemiumDBPIsNotAvailable() throws { // Given mockFeatureFlagger.isEnabled = false mockSubscriptionManager.canPurchase = false mockAccountManager.accessToken = "some_token" - sut = DefaultFreemiumPIRFeature(featureFlagger: mockFeatureFlagger, + sut = DefaultFreemiumDBPFeature(featureFlagger: mockFeatureFlagger, subscriptionManager: mockSubscriptionManager, accountManager: mockAccountManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManagerManager, + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManagerManager, featureDisabler: mockFeatureDisabler) // When let result = sut.isAvailable @@ -110,15 +110,15 @@ final class FreemiumPIRFeatureTests: XCTestCase { XCTAssertFalse(result) } - func testWhenUserAlreadySubscribed_thenFreemiumPIRIsNotAvailable() throws { + func testWhenUserAlreadySubscribed_thenFreemiumDBPIsNotAvailable() throws { // Given mockFeatureFlagger.isEnabled = true mockSubscriptionManager.canPurchase = true mockAccountManager.accessToken = "some_token" - sut = DefaultFreemiumPIRFeature(featureFlagger: mockFeatureFlagger, + sut = DefaultFreemiumDBPFeature(featureFlagger: mockFeatureFlagger, subscriptionManager: mockSubscriptionManager, accountManager: mockAccountManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManagerManager, + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManagerManager, featureDisabler: mockFeatureDisabler) // When let result = sut.isAvailable @@ -129,16 +129,16 @@ final class FreemiumPIRFeatureTests: XCTestCase { func testWhenUserDidNotOnboard_thenOffboardingIsNotExecuted() { // Given - mockFreemiumPIRUserStateManagerManager.didOnboard = false + mockFreemiumDBPUserStateManagerManager.didOnboard = false mockFeatureFlagger.isEnabled = false mockSubscriptionManager.canPurchase = true mockAccountManager.accessToken = nil // When - sut = DefaultFreemiumPIRFeature(featureFlagger: mockFeatureFlagger, + sut = DefaultFreemiumDBPFeature(featureFlagger: mockFeatureFlagger, subscriptionManager: mockSubscriptionManager, accountManager: mockAccountManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManagerManager, + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManagerManager, featureDisabler: mockFeatureDisabler) // Then @@ -147,82 +147,82 @@ final class FreemiumPIRFeatureTests: XCTestCase { func testWhenUserDidOnboard_andFeatureIsDisabled_andUserCanPurchase_andUserIsNotSubscribed_thenOffboardingIsExecuted() { // Given - mockFreemiumPIRUserStateManagerManager.didOnboard = true + mockFreemiumDBPUserStateManagerManager.didOnboard = true mockFeatureFlagger.isEnabled = false mockSubscriptionManager.canPurchase = true mockAccountManager.accessToken = nil // When - sut = DefaultFreemiumPIRFeature(featureFlagger: mockFeatureFlagger, + sut = DefaultFreemiumDBPFeature(featureFlagger: mockFeatureFlagger, subscriptionManager: mockSubscriptionManager, accountManager: mockAccountManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManagerManager, + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManagerManager, featureDisabler: mockFeatureDisabler) // Then - XCTAssertFalse(mockFreemiumPIRUserStateManagerManager.didOnboard) + XCTAssertFalse(mockFreemiumDBPUserStateManagerManager.didOnboard) XCTAssertTrue(mockFeatureDisabler.disableAndDeleteWasCalled) } func testWhenUserDidOnboard_andFeatureIsDisabled_andUserCanPurchase_andUserIsSubscribed_thenOffboardingIsNotExecuted() { // Given - mockFreemiumPIRUserStateManagerManager.didOnboard = true + mockFreemiumDBPUserStateManagerManager.didOnboard = true mockFeatureFlagger.isEnabled = false mockSubscriptionManager.canPurchase = true mockAccountManager.accessToken = "some_token" // When - sut = DefaultFreemiumPIRFeature(featureFlagger: mockFeatureFlagger, + sut = DefaultFreemiumDBPFeature(featureFlagger: mockFeatureFlagger, subscriptionManager: mockSubscriptionManager, accountManager: mockAccountManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManagerManager, + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManagerManager, featureDisabler: mockFeatureDisabler) // Then - XCTAssertTrue(mockFreemiumPIRUserStateManagerManager.didOnboard) + XCTAssertTrue(mockFreemiumDBPUserStateManagerManager.didOnboard) XCTAssertFalse(mockFeatureDisabler.disableAndDeleteWasCalled) } func testWhenUserDidOnboard_andFeatureIsEnabled_andUserCanPurchase_andUserIsNotSubscribed_thenOffboardingIsNotExecuted() { // Given - mockFreemiumPIRUserStateManagerManager.didOnboard = true + mockFreemiumDBPUserStateManagerManager.didOnboard = true mockFeatureFlagger.isEnabled = true mockSubscriptionManager.canPurchase = true mockAccountManager.accessToken = nil // When - sut = DefaultFreemiumPIRFeature(featureFlagger: mockFeatureFlagger, + sut = DefaultFreemiumDBPFeature(featureFlagger: mockFeatureFlagger, subscriptionManager: mockSubscriptionManager, accountManager: mockAccountManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManagerManager, + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManagerManager, featureDisabler: mockFeatureDisabler) // Then - XCTAssertTrue(mockFreemiumPIRUserStateManagerManager.didOnboard) + XCTAssertTrue(mockFreemiumDBPUserStateManagerManager.didOnboard) XCTAssertFalse(mockFeatureDisabler.disableAndDeleteWasCalled) } func testWhenUserDidOnboard_andFeatureIsDisabled_andUserCannotPurchase_thenOffboardingIsNotExecuted() { // Given - mockFreemiumPIRUserStateManagerManager.didOnboard = true + mockFreemiumDBPUserStateManagerManager.didOnboard = true mockFeatureFlagger.isEnabled = false mockSubscriptionManager.canPurchase = false mockAccountManager.accessToken = nil // When - sut = DefaultFreemiumPIRFeature(featureFlagger: mockFeatureFlagger, + sut = DefaultFreemiumDBPFeature(featureFlagger: mockFeatureFlagger, subscriptionManager: mockSubscriptionManager, accountManager: mockAccountManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManagerManager, + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManagerManager, featureDisabler: mockFeatureDisabler) // Then - XCTAssertTrue(mockFreemiumPIRUserStateManagerManager.didOnboard) + XCTAssertTrue(mockFreemiumDBPUserStateManagerManager.didOnboard) XCTAssertFalse(mockFeatureDisabler.disableAndDeleteWasCalled) } } -final class MockFreemiumPIRFeatureFlagger: FeatureFlagger { +final class MockFreemiumDBPFeatureFlagger: FeatureFlagger { var isEnabled = false func isFeatureOn(forProvider: F) -> Bool where F: BrowserServicesKit.FeatureFlagSourceProviding { diff --git a/UnitTests/Freemium/PIR/FreemiumDBPFirstProfileSavedNotifierTests.swift b/UnitTests/Freemium/DBP/FreemiumDBPFirstProfileSavedNotifierTests.swift similarity index 76% rename from UnitTests/Freemium/PIR/FreemiumDBPFirstProfileSavedNotifierTests.swift rename to UnitTests/Freemium/DBP/FreemiumDBPFirstProfileSavedNotifierTests.swift index a1fbd2fc1d..ef77f124d7 100644 --- a/UnitTests/Freemium/PIR/FreemiumDBPFirstProfileSavedNotifierTests.swift +++ b/UnitTests/Freemium/DBP/FreemiumDBPFirstProfileSavedNotifierTests.swift @@ -21,16 +21,16 @@ import XCTest final class FreemiumDBPFirstProfileSavedNotifierTests: XCTestCase { - private var mockFreemiumPIRUserStateManager: MockFreemiumPIRUserStateManager! + private var mockFreemiumDBPUserStateManager: MockFreemiumDBPUserStateManager! private var mockAccountManager: MockAccountManager! private var mockNotificationCenter: MockNotificationCenter! private var sut: FreemiumDBPFirstProfileSavedNotifier! override func setUpWithError() throws { - mockFreemiumPIRUserStateManager = MockFreemiumPIRUserStateManager() + mockFreemiumDBPUserStateManager = MockFreemiumDBPUserStateManager() mockAccountManager = MockAccountManager() mockNotificationCenter = MockNotificationCenter() - sut = FreemiumDBPFirstProfileSavedNotifier(freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager, + sut = FreemiumDBPFirstProfileSavedNotifier(freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager, accountManager: mockAccountManager, notificationCenter: mockNotificationCenter) } @@ -38,8 +38,8 @@ final class FreemiumDBPFirstProfileSavedNotifierTests: XCTestCase { func testWhenAllCriteriaSatisfied_thenNotificationShouldBePosted() { // Given mockAccountManager.accessToken = nil - mockFreemiumPIRUserStateManager.didOnboard = true - mockFreemiumPIRUserStateManager.didPostFirstProfileSavedNotification = false + mockFreemiumDBPUserStateManager.didOnboard = true + mockFreemiumDBPUserStateManager.didPostFirstProfileSavedNotification = false // When sut.postProfileSavedNotificationIfPermitted() @@ -47,14 +47,14 @@ final class FreemiumDBPFirstProfileSavedNotifierTests: XCTestCase { // Then XCTAssertTrue(mockNotificationCenter.didCallPostNotification) XCTAssertEqual(mockNotificationCenter.lastPostedNotification, .pirProfileSaved) - XCTAssertTrue(mockFreemiumPIRUserStateManager.didPostFirstProfileSavedNotification) + XCTAssertTrue(mockFreemiumDBPUserStateManager.didPostFirstProfileSavedNotification) } func testWhenUserIsAuthenticated_thenNotificationShouldNotBePosted() { // Given mockAccountManager.accessToken = "some_token" - mockFreemiumPIRUserStateManager.didOnboard = true - mockFreemiumPIRUserStateManager.didPostFirstProfileSavedNotification = false + mockFreemiumDBPUserStateManager.didOnboard = true + mockFreemiumDBPUserStateManager.didPostFirstProfileSavedNotification = false // When sut.postProfileSavedNotificationIfPermitted() @@ -66,8 +66,8 @@ final class FreemiumDBPFirstProfileSavedNotifierTests: XCTestCase { func testWhenUserHasNotCompletedOnboarding_thenNotificationShouldNotBePosted() { // Given mockAccountManager.accessToken = nil - mockFreemiumPIRUserStateManager.didOnboard = false - mockFreemiumPIRUserStateManager.didPostFirstProfileSavedNotification = false + mockFreemiumDBPUserStateManager.didOnboard = false + mockFreemiumDBPUserStateManager.didPostFirstProfileSavedNotification = false // When sut.postProfileSavedNotificationIfPermitted() @@ -79,8 +79,8 @@ final class FreemiumDBPFirstProfileSavedNotifierTests: XCTestCase { func testWhenNotificationAlreadyPosted_thenShouldNotPostAgain() { // Given mockAccountManager.accessToken = nil - mockFreemiumPIRUserStateManager.didOnboard = true - mockFreemiumPIRUserStateManager.didPostFirstProfileSavedNotification = true + mockFreemiumDBPUserStateManager.didOnboard = true + mockFreemiumDBPUserStateManager.didPostFirstProfileSavedNotification = true // When sut.postProfileSavedNotificationIfPermitted() @@ -92,8 +92,8 @@ final class FreemiumDBPFirstProfileSavedNotifierTests: XCTestCase { func testWhenNotificationIsPosted_thenStateShouldBeUpdated() { // Given mockAccountManager.accessToken = nil - mockFreemiumPIRUserStateManager.didOnboard = true - mockFreemiumPIRUserStateManager.didPostFirstProfileSavedNotification = false + mockFreemiumDBPUserStateManager.didOnboard = true + mockFreemiumDBPUserStateManager.didPostFirstProfileSavedNotification = false // When sut.postProfileSavedNotificationIfPermitted() @@ -101,6 +101,6 @@ final class FreemiumDBPFirstProfileSavedNotifierTests: XCTestCase { // Then XCTAssertTrue(mockNotificationCenter.didCallPostNotification) XCTAssertEqual(mockNotificationCenter.lastPostedNotification, .pirProfileSaved) - XCTAssertTrue(mockFreemiumPIRUserStateManager.didPostFirstProfileSavedNotification) + XCTAssertTrue(mockFreemiumDBPUserStateManager.didPostFirstProfileSavedNotification) } } diff --git a/UnitTests/Freemium/PIR/FreemiumPIRPresenterTests.swift b/UnitTests/Freemium/DBP/FreemiumDBPPresenterTests.swift similarity index 83% rename from UnitTests/Freemium/PIR/FreemiumPIRPresenterTests.swift rename to UnitTests/Freemium/DBP/FreemiumDBPPresenterTests.swift index 40cb985c37..fa7825bf57 100644 --- a/UnitTests/Freemium/PIR/FreemiumPIRPresenterTests.swift +++ b/UnitTests/Freemium/DBP/FreemiumDBPPresenterTests.swift @@ -1,5 +1,5 @@ // -// FreemiumPIRPresenterTests.swift +// FreemiumDBPPresenterTests.swift // // Copyright © 2024 DuckDuckGo. All rights reserved. // @@ -20,27 +20,27 @@ import XCTest @testable import DuckDuckGo_Privacy_Browser import Combine -final class FreemiumPIRPresenterTests: XCTestCase { +final class FreemiumDBPPresenterTests: XCTestCase { private var mockWindowControllerManager: MockWindowControllerManager! - private var sut = DefaultFreemiumPIRPresenter() + private var sut = DefaultFreemiumDBPPresenter() @MainActor - func testWhenCallShowFreemiumPIRAndDidOnboardThenShowPIRTabIsCalled() async throws { + func testWhenCallShowFreemiumDBPAndDidOnboardThenShowPIRTabIsCalled() async throws { // Given mockWindowControllerManager = MockWindowControllerManager() // When - sut.showFreemiumPIR(didOnboard: true, windowControllerManager: mockWindowControllerManager) + sut.showFreemiumDBP(didOnboard: true, windowControllerManager: mockWindowControllerManager) // Then XCTAssertEqual(mockWindowControllerManager.showTabContent, Tab.Content.dataBrokerProtection) } @MainActor - func testWhenCallShowFreemiumPIRAndDidNotOnboardThenShowPIRTabIsNotCalled() async throws { + func testWhenCallShowFreemiumDBPAndDidNotOnboardThenShowPIRTabIsNotCalled() async throws { // Given mockWindowControllerManager = MockWindowControllerManager() // When - sut.showFreemiumPIR(didOnboard: false, windowControllerManager: mockWindowControllerManager) + sut.showFreemiumDBP(didOnboard: false, windowControllerManager: mockWindowControllerManager) // Then XCTAssertEqual(mockWindowControllerManager.showTabContent, Tab.Content.none) } diff --git a/UnitTests/Freemium/PIR/FreemiumDBPPromotionViewCoordinatorTests.swift b/UnitTests/Freemium/DBP/FreemiumDBPPromotionViewCoordinatorTests.swift similarity index 84% rename from UnitTests/Freemium/PIR/FreemiumDBPPromotionViewCoordinatorTests.swift rename to UnitTests/Freemium/DBP/FreemiumDBPPromotionViewCoordinatorTests.swift index 6f2bf549ff..baf7832c90 100644 --- a/UnitTests/Freemium/PIR/FreemiumDBPPromotionViewCoordinatorTests.swift +++ b/UnitTests/Freemium/DBP/FreemiumDBPPromotionViewCoordinatorTests.swift @@ -23,20 +23,20 @@ import Freemium final class FreemiumDBPPromotionViewCoordinatorTests: XCTestCase { private var sut: FreemiumDBPPromotionViewCoordinator! - private var mockUserStateManager: MockFreemiumPIRUserStateManager! - private var mockFeature: MockFreemiumPIRFeature! - private var mockPresenter: MockFreemiumPIRPresenter! + private var mockUserStateManager: MockFreemiumDBPUserStateManager! + private var mockFeature: MockFreemiumDBPFeature! + private var mockPresenter: MockFreemiumDBPPresenter! @MainActor override func setUpWithError() throws { - mockUserStateManager = MockFreemiumPIRUserStateManager() - mockFeature = MockFreemiumPIRFeature() - mockPresenter = MockFreemiumPIRPresenter() + mockUserStateManager = MockFreemiumDBPUserStateManager() + mockFeature = MockFreemiumDBPFeature() + mockPresenter = MockFreemiumDBPPresenter() sut = FreemiumDBPPromotionViewCoordinator( freemiumDBPUserStateManager: mockUserStateManager, - freemiumPIRFeature: mockFeature, - freemiumPIRPresenter: mockPresenter + freemiumDBPFeature: mockFeature, + freemiumDBPPresenter: mockPresenter ) } @@ -56,8 +56,8 @@ final class FreemiumDBPPromotionViewCoordinatorTests: XCTestCase { // When sut = FreemiumDBPPromotionViewCoordinator( freemiumDBPUserStateManager: mockUserStateManager, - freemiumPIRFeature: mockFeature, - freemiumPIRPresenter: mockPresenter + freemiumDBPFeature: mockFeature, + freemiumDBPPresenter: mockPresenter ) // Then @@ -73,8 +73,8 @@ final class FreemiumDBPPromotionViewCoordinatorTests: XCTestCase { // When sut = FreemiumDBPPromotionViewCoordinator( freemiumDBPUserStateManager: mockUserStateManager, - freemiumPIRFeature: mockFeature, - freemiumPIRPresenter: mockPresenter + freemiumDBPFeature: mockFeature, + freemiumDBPPresenter: mockPresenter ) // Then @@ -115,8 +115,8 @@ final class FreemiumDBPPromotionViewCoordinatorTests: XCTestCase { let viewModel = sut.viewModel // Then - XCTAssertEqual(viewModel.title, UserText.homePagePromotionFreemiumPIRPostScanEngagementResultsTitle) - XCTAssertEqual(viewModel.subtitle, UserText.homePagePromotionFreemiumPIRPostScanEngagementResultPluralSubtitle(resultCount: 5, brokerCount: 2)) + XCTAssertEqual(viewModel.title, UserText.homePagePromotionFreemiumDBPPostScanEngagementResultsTitle) + XCTAssertEqual(viewModel.subtitle, UserText.homePagePromotionFreemiumDBPPostScanEngagementResultPluralSubtitle(resultCount: 5, brokerCount: 2)) } @MainActor @@ -128,7 +128,7 @@ final class FreemiumDBPPromotionViewCoordinatorTests: XCTestCase { let viewModel = sut.viewModel // Then - XCTAssertEqual(viewModel.subtitle, UserText.homePagePromotionFreemiumPIRSubtitle) + XCTAssertEqual(viewModel.subtitle, UserText.homePagePromotionFreemiumDBPSubtitle) } func testNotificationObservation_updatesPromotionVisibility() { diff --git a/UnitTests/Freemium/PIR/FreemiumPIRScanResultPollingTests.swift b/UnitTests/Freemium/DBP/FreemiumDBPScanResultPollingTests.swift similarity index 80% rename from UnitTests/Freemium/PIR/FreemiumPIRScanResultPollingTests.swift rename to UnitTests/Freemium/DBP/FreemiumDBPScanResultPollingTests.swift index 79189b26d9..f142a5a7f5 100644 --- a/UnitTests/Freemium/PIR/FreemiumPIRScanResultPollingTests.swift +++ b/UnitTests/Freemium/DBP/FreemiumDBPScanResultPollingTests.swift @@ -1,5 +1,5 @@ // -// FreemiumPIRScanResultPollingTests.swift +// FreemiumDBPScanResultPollingTests.swift // // Copyright © 2024 DuckDuckGo. All rights reserved. // @@ -22,27 +22,27 @@ import XCTest import Common import Freemium -final class FreemiumPIRScanResultPollingTests: XCTestCase { +final class FreemiumDBPScanResultPollingTests: XCTestCase { - private var sut: FreemiumPIRScanResultPolling! - private var mockFreemiumPIRUserStateManager: MockFreemiumPIRUserStateManager! + private var sut: FreemiumDBPScanResultPolling! + private var mockFreemiumDBPUserStateManager: MockFreemiumDBPUserStateManager! private var mockNotificationCenter: MockNotificationCenter! private var mockDataManager: MockDataBrokerProtectionDataManager! - private let dateFormatter = FreemiumPIRScanResultPollingTests.makePOSIXDateTimeFormatter() - private let key = "macos.browser.freemium.pir.first.profile.saved.timestamp" + private let dateFormatter = FreemiumDBPScanResultPollingTests.makePOSIXDateTimeFormatter() + private let key = "macos.browser.freemium.dbp.first.profile.saved.timestamp" override func setUpWithError() throws { - mockFreemiumPIRUserStateManager = MockFreemiumPIRUserStateManager() + mockFreemiumDBPUserStateManager = MockFreemiumDBPUserStateManager() mockNotificationCenter = MockNotificationCenter() mockDataManager = MockDataBrokerProtectionDataManager() } func testWhenResultsAlreadyPosted_thenNoPollingOrObserving() { // Given - mockFreemiumPIRUserStateManager.didPostResultsNotification = true - let sut = DefaultFreemiumPIRScanResultPolling( + mockFreemiumDBPUserStateManager.didPostResultsNotification = true + let sut = DefaultFreemiumDBPScanResultPolling( dataManager: mockDataManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager, + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager, notificationCenter: mockNotificationCenter ) @@ -58,10 +58,10 @@ final class FreemiumPIRScanResultPollingTests: XCTestCase { func testWhenFirstProfileIsAlreadySaved_thenPollingStartsImmediately() { // Given let timestampString = dateFormatter.string(from: Date()) - mockFreemiumPIRUserStateManager.firstProfileSavedTimestamp = timestampString - let sut = DefaultFreemiumPIRScanResultPolling( + mockFreemiumDBPUserStateManager.firstProfileSavedTimestamp = timestampString + let sut = DefaultFreemiumDBPScanResultPolling( dataManager: mockDataManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager, + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager, notificationCenter: mockNotificationCenter ) @@ -76,9 +76,9 @@ final class FreemiumPIRScanResultPollingTests: XCTestCase { func testWhenNoProfileIsSaved_thenObserveForNotification_andDontStartTimer() { // Given - let sut = DefaultFreemiumPIRScanResultPolling( + let sut = DefaultFreemiumDBPScanResultPolling( dataManager: mockDataManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager, + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager, notificationCenter: mockNotificationCenter ) @@ -93,9 +93,9 @@ final class FreemiumPIRScanResultPollingTests: XCTestCase { func testWhenIsNotifiedOfFirstProfileSaved_thenPollingStarts() { // Given - let sut = DefaultFreemiumPIRScanResultPolling( + let sut = DefaultFreemiumDBPScanResultPolling( dataManager: mockDataManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager, + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager, notificationCenter: mockNotificationCenter ) @@ -104,7 +104,7 @@ final class FreemiumPIRScanResultPollingTests: XCTestCase { mockNotificationCenter.post(name: .pirProfileSaved, object: nil) // Then - XCTAssertNotNil(mockFreemiumPIRUserStateManager.firstProfileSavedTimestamp) + XCTAssertNotNil(mockFreemiumDBPUserStateManager.firstProfileSavedTimestamp) XCTAssertTrue(mockNotificationCenter.didCallAddObserver) XCTAssertFalse(mockDataManager.didCallMatchesFoundCount) XCTAssertNotNil(sut.timer) @@ -114,10 +114,10 @@ final class FreemiumPIRScanResultPollingTests: XCTestCase { // Given mockDataManager.matchesFoundCountValue = (3, 2) let timestampString = dateFormatter.string(from: Date.nowMinus(hours: 12)) - mockFreemiumPIRUserStateManager.firstProfileSavedTimestamp = timestampString - let sut = DefaultFreemiumPIRScanResultPolling( + mockFreemiumDBPUserStateManager.firstProfileSavedTimestamp = timestampString + let sut = DefaultFreemiumDBPScanResultPolling( dataManager: mockDataManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager, + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager, notificationCenter: mockNotificationCenter ) @@ -128,7 +128,7 @@ final class FreemiumPIRScanResultPollingTests: XCTestCase { XCTAssertFalse(mockNotificationCenter.didCallAddObserver) XCTAssertTrue(mockDataManager.didCallMatchesFoundCount) XCTAssertEqual(mockNotificationCenter.lastPostedNotification, .freemiumDBPResultPollingComplete) - XCTAssertEqual(mockFreemiumPIRUserStateManager.firstScanResults, FreemiumDBPMatchResults(matchesCount: 3, brokerCount: 2)) + XCTAssertEqual(mockFreemiumDBPUserStateManager.firstScanResults, FreemiumDBPMatchResults(matchesCount: 3, brokerCount: 2)) XCTAssertNil(sut.timer) } @@ -136,10 +136,10 @@ final class FreemiumPIRScanResultPollingTests: XCTestCase { // Given mockDataManager.matchesFoundCountValue = (4, 2) let timestampString = dateFormatter.string(from: Date.nowMinus(hours: 36)) - mockFreemiumPIRUserStateManager.firstProfileSavedTimestamp = timestampString - let sut = DefaultFreemiumPIRScanResultPolling( + mockFreemiumDBPUserStateManager.firstProfileSavedTimestamp = timestampString + let sut = DefaultFreemiumDBPScanResultPolling( dataManager: mockDataManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager, + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager, notificationCenter: mockNotificationCenter ) @@ -148,7 +148,7 @@ final class FreemiumPIRScanResultPollingTests: XCTestCase { // Then XCTAssertEqual(mockNotificationCenter.lastPostedNotification, .freemiumDBPResultPollingComplete) - XCTAssertEqual(mockFreemiumPIRUserStateManager.firstScanResults, FreemiumDBPMatchResults(matchesCount: 4, brokerCount: 2)) + XCTAssertEqual(mockFreemiumDBPUserStateManager.firstScanResults, FreemiumDBPMatchResults(matchesCount: 4, brokerCount: 2)) XCTAssertFalse(mockNotificationCenter.didCallAddObserver) XCTAssertTrue(mockDataManager.didCallMatchesFoundCount) XCTAssertNil(sut.timer) @@ -158,10 +158,10 @@ final class FreemiumPIRScanResultPollingTests: XCTestCase { // Given mockDataManager.matchesFoundCountValue = (0, 0) let timestampString = dateFormatter.string(from: Date.nowMinus(hours: 36)) - mockFreemiumPIRUserStateManager.firstProfileSavedTimestamp = timestampString - let sut = DefaultFreemiumPIRScanResultPolling( + mockFreemiumDBPUserStateManager.firstProfileSavedTimestamp = timestampString + let sut = DefaultFreemiumDBPScanResultPolling( dataManager: mockDataManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager, + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager, notificationCenter: mockNotificationCenter ) @@ -170,7 +170,7 @@ final class FreemiumPIRScanResultPollingTests: XCTestCase { // Then XCTAssertEqual(mockNotificationCenter.lastPostedNotification, .freemiumDBPResultPollingComplete) - XCTAssertEqual(mockFreemiumPIRUserStateManager.firstScanResults, FreemiumDBPMatchResults(matchesCount: 0, brokerCount: 0)) + XCTAssertEqual(mockFreemiumDBPUserStateManager.firstScanResults, FreemiumDBPMatchResults(matchesCount: 0, brokerCount: 0)) XCTAssertFalse(mockNotificationCenter.didCallAddObserver) XCTAssertTrue(mockDataManager.didCallMatchesFoundCount) XCTAssertNil(sut.timer) @@ -178,9 +178,9 @@ final class FreemiumPIRScanResultPollingTests: XCTestCase { func testWhenPollingIsDeinitialized_thenTimerIsInvalidated() { // Given - var sut: DefaultFreemiumPIRScanResultPolling? = DefaultFreemiumPIRScanResultPolling( + var sut: DefaultFreemiumDBPScanResultPolling? = DefaultFreemiumDBPScanResultPolling( dataManager: mockDataManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager, + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager, notificationCenter: mockNotificationCenter ) sut?.startPollingOrObserving() @@ -194,9 +194,9 @@ final class FreemiumPIRScanResultPollingTests: XCTestCase { func testWhenTimerAlreadyExists_thenSecondTimerIsNotCreated() { // Given - let sut = DefaultFreemiumPIRScanResultPolling( + let sut = DefaultFreemiumDBPScanResultPolling( dataManager: mockDataManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager, + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager, notificationCenter: mockNotificationCenter ) sut.startPollingOrObserving() @@ -214,11 +214,11 @@ final class FreemiumPIRScanResultPollingTests: XCTestCase { mockDataManager.matchesFoundCountValue = (0, 0) mockDataManager.didCallMatchesFoundCount = false // Simulate an error let timestampString = dateFormatter.string(from: Date.nowMinus(hours: 1)) - mockFreemiumPIRUserStateManager.firstProfileSavedTimestamp = timestampString + mockFreemiumDBPUserStateManager.firstProfileSavedTimestamp = timestampString - let sut = DefaultFreemiumPIRScanResultPolling( + let sut = DefaultFreemiumDBPScanResultPolling( dataManager: mockDataManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager, + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager, notificationCenter: mockNotificationCenter ) @@ -236,11 +236,11 @@ final class FreemiumPIRScanResultPollingTests: XCTestCase { // Given mockDataManager.matchesFoundCountValue = (0, 0) let timestampString = dateFormatter.string(from: Date.nowMinus(hours: 12)) - mockFreemiumPIRUserStateManager.firstProfileSavedTimestamp = timestampString + mockFreemiumDBPUserStateManager.firstProfileSavedTimestamp = timestampString - let sut = DefaultFreemiumPIRScanResultPolling( + let sut = DefaultFreemiumDBPScanResultPolling( dataManager: mockDataManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager, + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager, notificationCenter: mockNotificationCenter ) @@ -254,7 +254,7 @@ final class FreemiumPIRScanResultPollingTests: XCTestCase { } } -private extension FreemiumPIRScanResultPollingTests { +private extension FreemiumDBPScanResultPollingTests { static func makePOSIXDateTimeFormatter() -> DateFormatter { let dateFormatter = DateFormatter() diff --git a/UnitTests/Menus/MoreOptionsMenuTests.swift b/UnitTests/Menus/MoreOptionsMenuTests.swift index 8cd867c15f..a3e2d1bbb9 100644 --- a/UnitTests/Menus/MoreOptionsMenuTests.swift +++ b/UnitTests/Menus/MoreOptionsMenuTests.swift @@ -38,10 +38,10 @@ final class MoreOptionsMenuTests: XCTestCase { var subscriptionManager: SubscriptionManagerMock! - private var mockFreemiumPIRFeatureFlagger = MockFreemiumPIRFeatureFlagger() - private var mockFreemiumPIRPresenter = MockFreemiumPIRPresenter() - private var freemiumPIRFeature: DefaultFreemiumPIRFeature! - private var mockFreemiumPIRUserStateManager = MockFreemiumPIRUserStateManager() + private var mockFreemiumDBPFeatureFlagger = MockFreemiumDBPFeatureFlagger() + private var mockFreemiumDBPPresenter = MockFreemiumDBPPresenter() + private var freemiumDBPFeature: DefaultFreemiumDBPFeature! + private var mockFreemiumDBPUserStateManager = MockFreemiumDBPUserStateManager() private var mockNotificationCenter: MockNotificationCenter! var moreOptionsMenu: MoreOptionsMenu! @@ -69,7 +69,7 @@ final class MoreOptionsMenuTests: XCTestCase { purchasePlatform: .appStore), canPurchase: false) - freemiumPIRFeature = DefaultFreemiumPIRFeature(featureFlagger: mockFreemiumPIRFeatureFlagger, subscriptionManager: subscriptionManager, accountManager: subscriptionManager.accountManager, freemiumPIRUserStateManager: MockFreemiumPIRUserStateManager(), featureDisabler: MockFeatureDisabler()) + freemiumDBPFeature = DefaultFreemiumDBPFeature(featureFlagger: mockFreemiumDBPFeatureFlagger, subscriptionManager: subscriptionManager, accountManager: subscriptionManager.accountManager, freemiumDBPUserStateManager: MockFreemiumDBPUserStateManager(), featureDisabler: MockFeatureDisabler()) mockNotificationCenter = MockNotificationCenter() @@ -96,9 +96,9 @@ final class MoreOptionsMenuTests: XCTestCase { sharingMenu: NSMenu(), internalUserDecider: internalUserDecider, subscriptionManager: subscriptionManager, - freemiumPIRUserStateManager: mockFreemiumPIRUserStateManager, - freemiumPIRFeature: freemiumPIRFeature, - freemiumPIRPresenter: mockFreemiumPIRPresenter, + freemiumDBPUserStateManager: mockFreemiumDBPUserStateManager, + freemiumDBPFeature: freemiumDBPFeature, + freemiumDBPPresenter: mockFreemiumDBPPresenter, notificationCenter: mockNotificationCenter) moreOptionsMenu.actionDelegate = capturingActionDelegate @@ -145,10 +145,10 @@ final class MoreOptionsMenuTests: XCTestCase { } @MainActor - func testThatMoreOptionMenuHasTheExpectedItemsWhenUnauthenticatedAndCanPurchaseSubscriptionAndFreemiumPIRFeatureFlagDisabled() { + func testThatMoreOptionMenuHasTheExpectedItemsWhenUnauthenticatedAndCanPurchaseSubscriptionAndFreemiumDBPFeatureFlagDisabled() { subscriptionManager.canPurchase = true subscriptionManager.currentEnvironment = SubscriptionEnvironment(serviceEnvironment: .production, purchasePlatform: .stripe) - mockFreemiumPIRFeatureFlagger.isEnabled = false + mockFreemiumDBPFeatureFlagger.isEnabled = false setupMoreOptionsMenu() @@ -177,10 +177,10 @@ final class MoreOptionsMenuTests: XCTestCase { } @MainActor - func testThatMoreOptionMenuHasTheExpectedItemsWhenUnauthenticatedAndFreemiumPIRFeatureFlagEnabled() { + func testThatMoreOptionMenuHasTheExpectedItemsWhenUnauthenticatedAndFreemiumDBPFeatureFlagEnabled() { subscriptionManager.canPurchase = true subscriptionManager.currentEnvironment = SubscriptionEnvironment(serviceEnvironment: .production, purchasePlatform: .stripe) - mockFreemiumPIRFeatureFlagger.isEnabled = true + mockFreemiumDBPFeatureFlagger.isEnabled = true setupMoreOptionsMenu() @@ -203,16 +203,16 @@ final class MoreOptionsMenuTests: XCTestCase { XCTAssertTrue(moreOptionsMenu.items[13].isSeparatorItem) XCTAssertEqual(moreOptionsMenu.items[14].title, UserText.subscriptionOptionsMenuItem) XCTAssertFalse(moreOptionsMenu.items[14].hasSubmenu) - XCTAssertEqual(moreOptionsMenu.items[15].title, UserText.freemiumPIROptionsMenuItem) + XCTAssertEqual(moreOptionsMenu.items[15].title, UserText.freemiumDBPOptionsMenuItem) XCTAssertTrue(moreOptionsMenu.items[16].isSeparatorItem) XCTAssertEqual(moreOptionsMenu.items[17].title, UserText.mainMenuHelp) XCTAssertEqual(moreOptionsMenu.items[18].title, UserText.settings) } @MainActor - func testThatMoreOptionMenuHasTheExpectedItemsWhenSubscriptionIsActiveAndFreemiumPIRFeatureFlagDisabled() { + func testThatMoreOptionMenuHasTheExpectedItemsWhenSubscriptionIsActiveAndFreemiumDBPFeatureFlagDisabled() { mockAuthentication() - mockFreemiumPIRFeatureFlagger.isEnabled = false + mockFreemiumDBPFeatureFlagger.isEnabled = false setupMoreOptionsMenu() @@ -247,9 +247,9 @@ final class MoreOptionsMenuTests: XCTestCase { } @MainActor - func testThatMoreOptionMenuHasTheExpectedItemsWhenSubscriptionIsActiveAndFreemiumPIRFeatureFlagEnabled() { + func testThatMoreOptionMenuHasTheExpectedItemsWhenSubscriptionIsActiveAndFreemiumDBPFeatureFlagEnabled() { mockAuthentication() - mockFreemiumPIRFeatureFlagger.isEnabled = true + mockFreemiumDBPFeatureFlagger.isEnabled = true setupMoreOptionsMenu() @@ -284,43 +284,43 @@ final class MoreOptionsMenuTests: XCTestCase { } @MainActor - func testWhenClickingFreemiumPIROptionAndDidNotOnboardThenFreemiumPresenterIsCalledWithDidNotOnboardStateAndNotificationIsPosted() throws { + func testWhenClickingFreemiumDBPOptionAndDidNotOnboardThenFreemiumPresenterIsCalledWithDidNotOnboardStateAndNotificationIsPosted() throws { // Given subscriptionManager.canPurchase = true subscriptionManager.currentEnvironment = SubscriptionEnvironment(serviceEnvironment: .production, purchasePlatform: .stripe) - mockFreemiumPIRFeatureFlagger.isEnabled = true - mockFreemiumPIRUserStateManager.didOnboard = false + mockFreemiumDBPFeatureFlagger.isEnabled = true + mockFreemiumDBPUserStateManager.didOnboard = false setupMoreOptionsMenu() - let freemiumItemIndex = try XCTUnwrap(moreOptionsMenu.indexOfItem(withTitle: UserText.freemiumPIROptionsMenuItem)) + let freemiumItemIndex = try XCTUnwrap(moreOptionsMenu.indexOfItem(withTitle: UserText.freemiumDBPOptionsMenuItem)) // When moreOptionsMenu.performActionForItem(at: freemiumItemIndex) // Then - XCTAssertTrue(mockFreemiumPIRPresenter.didCallShowFreemium) - XCTAssertTrue(mockFreemiumPIRPresenter.didOnboardState) + XCTAssertTrue(mockFreemiumDBPPresenter.didCallShowFreemium) + XCTAssertTrue(mockFreemiumDBPPresenter.didOnboardState) XCTAssertTrue(mockNotificationCenter.didCallPostNotification) XCTAssertEqual(mockNotificationCenter.lastPostedNotification, .freemiumDBPEntryPointActivated) } @MainActor - func testWhenClickingFreemiumPIROptionAndDidOnboardThenFreemiumPresenterIsCalledWithDidOnboardStateAndNotificationIsPosted() throws { + func testWhenClickingFreemiumDBPOptionAndDidOnboardThenFreemiumPresenterIsCalledWithDidOnboardStateAndNotificationIsPosted() throws { // Given subscriptionManager.canPurchase = true subscriptionManager.currentEnvironment = SubscriptionEnvironment(serviceEnvironment: .production, purchasePlatform: .stripe) - mockFreemiumPIRFeatureFlagger.isEnabled = true - mockFreemiumPIRUserStateManager.didOnboard = true + mockFreemiumDBPFeatureFlagger.isEnabled = true + mockFreemiumDBPUserStateManager.didOnboard = true setupMoreOptionsMenu() - let freemiumItemIndex = try XCTUnwrap(moreOptionsMenu.indexOfItem(withTitle: UserText.freemiumPIROptionsMenuItem)) + let freemiumItemIndex = try XCTUnwrap(moreOptionsMenu.indexOfItem(withTitle: UserText.freemiumDBPOptionsMenuItem)) // When moreOptionsMenu.performActionForItem(at: freemiumItemIndex) // Then - XCTAssertTrue(mockFreemiumPIRPresenter.didCallShowFreemium) - XCTAssertTrue(mockFreemiumPIRPresenter.didOnboardState) + XCTAssertTrue(mockFreemiumDBPPresenter.didCallShowFreemium) + XCTAssertTrue(mockFreemiumDBPPresenter.didOnboardState) XCTAssertTrue(mockNotificationCenter.didCallPostNotification) XCTAssertEqual(mockNotificationCenter.lastPostedNotification, .freemiumDBPEntryPointActivated) } @@ -407,7 +407,7 @@ final class NetworkProtectionVisibilityMock: VPNFeatureGatekeeper { } } -final class MockFreemiumPIRFeature: FreemiumPIRFeature { +final class MockFreemiumDBPFeature: FreemiumDBPFeature { var featureAvailable = false var isAvailable: Bool { @@ -415,11 +415,11 @@ final class MockFreemiumPIRFeature: FreemiumPIRFeature { } } -final class MockFreemiumPIRPresenter: FreemiumPIRPresenter { +final class MockFreemiumDBPPresenter: FreemiumDBPPresenter { var didCallShowFreemium = false var didOnboardState = false - func showFreemiumPIR(didOnboard: Bool, windowControllerManager: WindowControllersManagerProtocol? = nil) { + func showFreemiumDBP(didOnboard: Bool, windowControllerManager: WindowControllersManagerProtocol? = nil) { didCallShowFreemium = true didOnboardState = didOnboard } diff --git a/UnitTests/RemoteMessaging/RemoteMessagingClientTests.swift b/UnitTests/RemoteMessaging/RemoteMessagingClientTests.swift index 72f1a3ad9e..47538f80d7 100644 --- a/UnitTests/RemoteMessaging/RemoteMessagingClientTests.swift +++ b/UnitTests/RemoteMessaging/RemoteMessagingClientTests.swift @@ -30,7 +30,7 @@ struct MockRemoteMessagingStoreProvider: RemoteMessagingStoreProviding { } } -final class MockFreemiumPIRUserStateManager: FreemiumPIRUserStateManager { +final class MockFreemiumDBPUserStateManager: FreemiumDBPUserStateManager { var didOnboard = false var didPostFirstProfileSavedNotification = false var didPostResultsNotification = false From 2de7679fa10810ad4936efffe82f5af7ed7634d1 Mon Sep 17 00:00:00 2001 From: Pete Date: Wed, 11 Sep 2024 12:10:08 +0100 Subject: [PATCH 2/2] Fix minor post-rebase issue --- .../Freemium/DBP/FreemiumDBPPresenterTests.swift | 11 +++++++++++ .../RecentlyClosedCoordinatorTests.swift | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/UnitTests/Freemium/DBP/FreemiumDBPPresenterTests.swift b/UnitTests/Freemium/DBP/FreemiumDBPPresenterTests.swift index fa7825bf57..2f3f67cc71 100644 --- a/UnitTests/Freemium/DBP/FreemiumDBPPresenterTests.swift +++ b/UnitTests/Freemium/DBP/FreemiumDBPPresenterTests.swift @@ -48,6 +48,9 @@ final class FreemiumDBPPresenterTests: XCTestCase { private final class MockWindowControllerManager: WindowControllersManagerProtocol { + + var lastKeyMainWindowController: DuckDuckGo_Privacy_Browser.MainWindowController? + var showTabContent: Tab.Content = .none var pinnedTabsManager: PinnedTabsManager = PinnedTabsManager() @@ -63,4 +66,12 @@ private final class MockWindowControllerManager: WindowControllersManagerProtoco func showTab(with content: Tab.TabContent) { showTabContent = content } + + func show(url: URL?, source: Tab.TabContent.URLSource, newTab: Bool) {} + + func showBookmarksTab() {} + + func openNewWindow(with tabCollectionViewModel: TabCollectionViewModel?, burnerMode: BurnerMode, droppingPoint: NSPoint?, contentSize: NSSize?, showWindow: Bool, popUp: Bool, lazyLoadTabs: Bool, isMiniaturized: Bool) -> MainWindow? { + nil + } } diff --git a/UnitTests/RecentlyClosed/RecentlyClosedCoordinatorTests.swift b/UnitTests/RecentlyClosed/RecentlyClosedCoordinatorTests.swift index d71077de1c..9ff00af06c 100644 --- a/UnitTests/RecentlyClosed/RecentlyClosedCoordinatorTests.swift +++ b/UnitTests/RecentlyClosed/RecentlyClosedCoordinatorTests.swift @@ -87,7 +87,7 @@ private extension RecentlyClosedWindow { } } -private final class WindowControllersManagerMock: WindowControllersManagerProtocol { +final class WindowControllersManagerMock: WindowControllersManagerProtocol { var pinnedTabsManager = PinnedTabsManager(tabCollection: .init()) var didRegisterWindowController = PassthroughSubject<(MainWindowController), Never>()