From e64ddb631241abf3885fc5d67a059f79f1f07140 Mon Sep 17 00:00:00 2001 From: Sam Symons Date: Tue, 19 Dec 2023 01:02:01 -0800 Subject: [PATCH] Remove VPN upgrade card (#1983) Task/Issue URL: https://app.asana.com/0/1199230911884351/1206201126808135/f Tech Design URL: CC: Description: This PR removes the VPN upgrade card that was implemented earlier this year ahead of the VPN menu agent ownership change. --- .../Utilities/UserDefaultsWrapper.swift | 2 +- .../Model/HomePageContinueSetUpModel.swift | 34 ++----------------- ...taBrokerProtectionInMemoryCacheTests.swift | 4 +-- .../HomePage/ContinueSetUpModelTests.swift | 1 - 4 files changed, 6 insertions(+), 35 deletions(-) diff --git a/DuckDuckGo/Common/Utilities/UserDefaultsWrapper.swift b/DuckDuckGo/Common/Utilities/UserDefaultsWrapper.swift index 0382b5de65..7bcf40d4b8 100644 --- a/DuckDuckGo/Common/Utilities/UserDefaultsWrapper.swift +++ b/DuckDuckGo/Common/Utilities/UserDefaultsWrapper.swift @@ -146,7 +146,6 @@ public struct UserDefaultsWrapper { case networkProtectionExcludedRoutes = "netp.excluded-routes" case networkProtectionTermsAndConditionsAccepted = "network-protection.waitlist-terms-and-conditions.accepted" - case shouldShowNetworkProtectionSystemExtensionUpgradePrompt = "network-protection.show-system-extension-upgrade-prompt" case networkProtectionWaitlistSignUpPromptDismissed = "network-protection.waitlist.sign-up-prompt-dismissed" // Network Protection: Shared Defaults @@ -190,6 +189,7 @@ public struct UserDefaultsWrapper { case networkProtectionConnectionTesterEnabled = "netp.connection-tester-enabled" case networkProtectionShouldExcludeLocalNetworks = "netp.exclude-local-routes" case networkProtectionRegistrationKeyValidity = "com.duckduckgo.network-protection.NetworkProtectionTunnelController.registrationKeyValidityKey" + case shouldShowNetworkProtectionSystemExtensionUpgradePrompt = "network-protection.show-system-extension-upgrade-prompt" } private let key: Key diff --git a/DuckDuckGo/HomePage/Model/HomePageContinueSetUpModel.swift b/DuckDuckGo/HomePage/Model/HomePageContinueSetUpModel.swift index 6fa5b846ff..23ea546ce8 100644 --- a/DuckDuckGo/HomePage/Model/HomePageContinueSetUpModel.swift +++ b/DuckDuckGo/HomePage/Model/HomePageContinueSetUpModel.swift @@ -115,9 +115,6 @@ extension HomePage.Models { @UserDefaultsWrapper(key: .firstLaunchDate, defaultValue: Calendar.current.date(byAdding: .month, value: -1, to: Date())!) private var firstLaunchDate: Date - @UserDefaultsWrapper(key: .shouldShowNetworkProtectionSystemExtensionUpgradePrompt, defaultValue: true) - private var shouldShowNetworkProtectionSystemExtensionUpgradePrompt: Bool - var isMoreOrLessButtonNeeded: Bool { return featuresMatrix.count > itemsRowCountWhenCollapsed } @@ -182,7 +179,6 @@ extension HomePage.Models { } #endif - // swiftlint:disable cyclomatic_complexity @MainActor func performAction(for featureType: FeatureType) { switch featureType { case .defaultBrowser: @@ -207,17 +203,12 @@ extension HomePage.Models { visitSurvey(day: .day7) case .networkProtectionRemoteMessage(let message): handle(remoteMessage: message) - case .networkProtectionSystemExtensionUpgrade: -#if NETWORK_PROTECTION - NotificationCenter.default.post(name: .ToggleNetworkProtectionInMainWindow, object: nil) -#endif case .dataBrokerProtectionWaitlistInvited: #if DBP DataBrokerProtectionAppEvents().handleWaitlistInvitedNotification(source: .cardUI) #endif } } - // swiftlint:enable cyclomatic_complexity func removeItem(for featureType: FeatureType) { switch featureType { @@ -238,15 +229,13 @@ extension HomePage.Models { networkProtectionRemoteMessaging.dismiss(message: message) Pixel.fire(.networkProtectionRemoteMessageDismissed(messageID: message.id)) #endif - case .networkProtectionSystemExtensionUpgrade: - shouldShowNetworkProtectionSystemExtensionUpgradePrompt = false case .dataBrokerProtectionWaitlistInvited: shouldShowDBPWaitlistInvitedCardUI = false } refreshFeaturesMatrix() } - // swiftlint:disable cyclomatic_complexity function_body_length + // swiftlint:disable:next cyclomatic_complexity func refreshFeaturesMatrix() { var features: [FeatureType] = [] #if DBP @@ -256,15 +245,6 @@ extension HomePage.Models { #endif #if NETWORK_PROTECTION - - // Only show the upgrade card to users who have used the VPN before: - let activationStore = DefaultWaitlistActivationDateStore() - if shouldShowNetworkProtectionSystemExtensionUpgradePrompt, - appGroupUserDefaults.networkProtectionOnboardingStatusRawValue != OnboardingStatus.completed.rawValue, - activationStore.daysSinceActivation() != nil { - features.append(.networkProtectionSystemExtensionUpgrade) - } - for message in networkProtectionRemoteMessaging.presentableRemoteMessages() { features.append(.networkProtectionRemoteMessage(message)) DailyPixel.fire( @@ -301,7 +281,7 @@ extension HomePage.Models { if shouldSurveyDay7BeVisible { features.append(feature) } - case .networkProtectionRemoteMessage, .networkProtectionSystemExtensionUpgrade: + case .networkProtectionRemoteMessage: break // Do nothing, NetP remote messages get appended first case .dataBrokerProtectionWaitlistInvited: break // Do nothing. The feature is being set for everyone invited in the waitlist @@ -309,7 +289,6 @@ extension HomePage.Models { } featuresMatrix = features.chunked(into: itemsPerRow) } - // swiftlint:enable cyclomatic_complexity function_body_length // Helper Functions @objc private func newTabOpenNotification(_ notification: Notification) { @@ -477,7 +456,6 @@ extension HomePage.Models { case surveyDay0 case surveyDay7 case networkProtectionRemoteMessage(NetworkProtectionRemoteMessage) - case networkProtectionSystemExtensionUpgrade case dataBrokerProtectionWaitlistInvited var title: String { @@ -496,8 +474,6 @@ extension HomePage.Models { return UserText.newTabSetUpSurveyDay7CardTitle case .networkProtectionRemoteMessage(let message): return message.cardTitle - case .networkProtectionSystemExtensionUpgrade: - return "VPN Update Available" case .dataBrokerProtectionWaitlistInvited: return "Personal Information Removal" } @@ -519,8 +495,6 @@ extension HomePage.Models { return UserText.newTabSetUpSurveyDay7Summary case .networkProtectionRemoteMessage(let message): return message.cardDescription - case .networkProtectionSystemExtensionUpgrade: - return "Allow VPN system software again to continue testing Network Protection." case .dataBrokerProtectionWaitlistInvited: return "You're invited to try Personal Information Removal beta!" } @@ -542,8 +516,6 @@ extension HomePage.Models { return UserText.newTabSetUpSurveyDay7Action case .networkProtectionRemoteMessage(let message): return message.action.actionTitle - case .networkProtectionSystemExtensionUpgrade: - return "Update VPN" case .dataBrokerProtectionWaitlistInvited: return "Get Started" } @@ -565,7 +537,7 @@ extension HomePage.Models { return NSImage(named: "Survey-128")!.resized(to: iconSize)! case .surveyDay7: return NSImage(named: "Survey-128")!.resized(to: iconSize)! - case .networkProtectionRemoteMessage, .networkProtectionSystemExtensionUpgrade: + case .networkProtectionRemoteMessage: return NSImage(named: "VPN-Ended")!.resized(to: iconSize)! case .dataBrokerProtectionWaitlistInvited: return NSImage(named: "DBP-Information-Remover")!.resized(to: iconSize)! diff --git a/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/DataBrokerProtectionInMemoryCacheTests.swift b/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/DataBrokerProtectionInMemoryCacheTests.swift index 30bd4fb47a..9b2ad00a3a 100644 --- a/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/DataBrokerProtectionInMemoryCacheTests.swift +++ b/LocalPackages/DataBrokerProtection/Tests/DataBrokerProtectionTests/DataBrokerProtectionInMemoryCacheTests.swift @@ -42,7 +42,7 @@ final class DataBrokerProtectionInMemoryCacheTests: XCTestCase { func testCacheDoesNotStoreEmptyNames() throws { let cache = InMemoryDataCache() - var result = cache.addNameToCurrentUserProfile(DBPUIUserProfileName(first: "", middle: "Jacob", last: "JingleHeimerSchmidt", suffix: nil)) + let result = cache.addNameToCurrentUserProfile(DBPUIUserProfileName(first: "", middle: "Jacob", last: "JingleHeimerSchmidt", suffix: nil)) XCTAssertFalse(result, "Result of adding empty name should be `false`") } @@ -68,7 +68,7 @@ final class DataBrokerProtectionInMemoryCacheTests: XCTestCase { func testCacheDoesNotStoreEmptyAddresses() throws { let cache = InMemoryDataCache() - var result = cache.addAddressToCurrentUserProfile(DBPUIUserProfileAddress(street: "123 any street", city: "", state: "TX", zipCode: "12345")) + let result = cache.addAddressToCurrentUserProfile(DBPUIUserProfileAddress(street: "123 any street", city: "", state: "TX", zipCode: "12345")) XCTAssertFalse(result, "Result of adding empty address should be `false`") } diff --git a/UnitTests/HomePage/ContinueSetUpModelTests.swift b/UnitTests/HomePage/ContinueSetUpModelTests.swift index 5284c9d322..a94068872a 100644 --- a/UnitTests/HomePage/ContinueSetUpModelTests.swift +++ b/UnitTests/HomePage/ContinueSetUpModelTests.swift @@ -57,7 +57,6 @@ final class ContinueSetUpModelTests: XCTestCase { UserDefaultsWrapper.clearAll() userDefaults.set(Date(), forKey: UserDefaultsWrapper.Key.firstLaunchDate.rawValue) userDefaults.set(false, forKey: UserDefaultsWrapper.Key.homePageUserInteractedWithSurveyDay0.rawValue) - userDefaults.set(false, forKey: UserDefaultsWrapper.Key.shouldShowNetworkProtectionSystemExtensionUpgradePrompt.rawValue) capturingDefaultBrowserProvider = CapturingDefaultBrowserProvider() capturingDataImportProvider = CapturingDataImportProvider() tabCollectionVM = TabCollectionViewModel()