Skip to content

Commit

Permalink
Remove VPN upgrade card (#1983)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
samsymons authored Dec 19, 2023
1 parent 0583409 commit e64ddb6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 35 deletions.
2 changes: 1 addition & 1 deletion DuckDuckGo/Common/Utilities/UserDefaultsWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ public struct UserDefaultsWrapper<T> {

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
Expand Down Expand Up @@ -190,6 +189,7 @@ public struct UserDefaultsWrapper<T> {
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
Expand Down
34 changes: 3 additions & 31 deletions DuckDuckGo/HomePage/Model/HomePageContinueSetUpModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -182,7 +179,6 @@ extension HomePage.Models {
}
#endif

// swiftlint:disable cyclomatic_complexity
@MainActor func performAction(for featureType: FeatureType) {
switch featureType {
case .defaultBrowser:
Expand All @@ -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 {
Expand All @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -301,15 +281,14 @@ 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
}
}
featuresMatrix = features.chunked(into: itemsPerRow)
}
// swiftlint:enable cyclomatic_complexity function_body_length

// Helper Functions
@objc private func newTabOpenNotification(_ notification: Notification) {
Expand Down Expand Up @@ -477,7 +456,6 @@ extension HomePage.Models {
case surveyDay0
case surveyDay7
case networkProtectionRemoteMessage(NetworkProtectionRemoteMessage)
case networkProtectionSystemExtensionUpgrade
case dataBrokerProtectionWaitlistInvited

var title: String {
Expand All @@ -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"
}
Expand All @@ -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!"
}
Expand All @@ -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"
}
Expand All @@ -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)!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`")
}
Expand All @@ -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`")
}
Expand Down
1 change: 0 additions & 1 deletion UnitTests/HomePage/ContinueSetUpModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ final class ContinueSetUpModelTests: XCTestCase {
UserDefaultsWrapper<Any>.clearAll()
userDefaults.set(Date(), forKey: UserDefaultsWrapper<Date>.Key.firstLaunchDate.rawValue)
userDefaults.set(false, forKey: UserDefaultsWrapper<Date>.Key.homePageUserInteractedWithSurveyDay0.rawValue)
userDefaults.set(false, forKey: UserDefaultsWrapper<Date>.Key.shouldShowNetworkProtectionSystemExtensionUpgradePrompt.rawValue)
capturingDefaultBrowserProvider = CapturingDefaultBrowserProvider()
capturingDataImportProvider = CapturingDataImportProvider()
tabCollectionVM = TabCollectionViewModel()
Expand Down

0 comments on commit e64ddb6

Please sign in to comment.