Skip to content

Commit

Permalink
NetP App Store waitlist tweaks (#2197) (#2204)
Browse files Browse the repository at this point in the history
Task/Issue URL:
https://app.asana.com/0/1199230911884351/1206604571588642/f
Tech Design URL:
CC: @Bunn

**Description**:

This PR cherry picks a recent NetP changes and turns NetP on in release
builds.
  • Loading branch information
samsymons authored Feb 15, 2024
1 parent 9c7f9bb commit 4209093
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Configuration/AppStore.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ GCC_PREPROCESSOR_DEFINITIONS[config=Review][arch=*][sdk=*] = APPSTORE=1 REVIEW=1
MACOSX_DEPLOYMENT_TARGET = 12.3

SWIFT_ACTIVE_COMPILATION_CONDITIONS[arch=*][sdk=*] = APPSTORE $(FEATURE_FLAGS)
SWIFT_ACTIVE_COMPILATION_CONDITIONS[config=CI][arch=*][sdk=*] = APPSTORE DEBUG NETWORK_PROTECTION DBP CI $(FEATURE_FLAGS)
SWIFT_ACTIVE_COMPILATION_CONDITIONS[config=Debug][arch=*][sdk=*] = APPSTORE DEBUG NETWORK_PROTECTION DBP $(FEATURE_FLAGS)
SWIFT_ACTIVE_COMPILATION_CONDITIONS[config=Review][arch=*][sdk=*] = APPSTORE REVIEW NETWORK_PROTECTION DBP $(FEATURE_FLAGS)
SWIFT_ACTIVE_COMPILATION_CONDITIONS[config=CI][arch=*][sdk=*] = APPSTORE DEBUG CI $(FEATURE_FLAGS)
SWIFT_ACTIVE_COMPILATION_CONDITIONS[config=Debug][arch=*][sdk=*] = APPSTORE DEBUG $(FEATURE_FLAGS)
SWIFT_ACTIVE_COMPILATION_CONDITIONS[config=Review][arch=*][sdk=*] = APPSTORE REVIEW $(FEATURE_FLAGS)

NETP_BASE_APP_GROUP = $(DEVELOPMENT_TEAM).com.duckduckgo.macos.browser.network-protection
NETP_APP_GROUP[config=CI][sdk=macos*] = $(NETP_BASE_APP_GROUP).debug
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Common.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ COMBINE_HIDPI_IMAGES = YES
DEVELOPMENT_TEAM = HKE973VLUW
DEVELOPMENT_TEAM[config=CI][sdk=*] =

FEATURE_FLAGS = FEEDBACK DBP
FEATURE_FLAGS = FEEDBACK DBP NETWORK_PROTECTION

GCC_PREPROCESSOR_DEFINITIONS[config=CI][arch=*][sdk=*] = DEBUG=1 CI=1 $(inherited)
GCC_PREPROCESSOR_DEFINITIONS[config=Debug][arch=*][sdk=*] = DEBUG=1 $(inherited)
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Tests/UnitTestsAppStore.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "UnitTests.xcconfig"
#include "../AppStore.xcconfig"

FEATURE_FLAGS = FEEDBACK
FEATURE_FLAGS = FEEDBACK NETWORK_PROTECTION DBP

PRODUCT_BUNDLE_IDENTIFIER = com.duckduckgo.mobile.ios.DuckDuckGoTests

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ final class NetworkProtectionAppEvents {
func applicationDidFinishLaunching() {
let loginItemsManager = LoginItemsManager()

Task {
Task { @MainActor in
await removeLegacyLoginItemAndVPNConfiguration()
migrateNetworkProtectionAuthTokenToSharedKeychainIfNecessary()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,15 @@ final class NetworkProtectionNavBarButtonModel: NSObject, ObservableObject {
let isWaitlistUser = waitlist.waitlistStorage.isWaitlistUser
let hasAuthToken = NetworkProtectionKeychainTokenStore().isFeatureActivated

#if !APPSTORE
// If the user hasn't signed up to the waitlist or doesn't have an auth token through some other method, then show them the badged icon
// to get their attention and encourage them to sign up. Also avoid showing the button is the user has opened the waitlist UI but
// dismissed it.
if !isWaitlistUser && !hasAuthToken && !waitlist.waitlistSignUpPromptDismissed {
showButton = true
return
}
#endif
}

guard !isPinned,
Expand Down
29 changes: 28 additions & 1 deletion DuckDuckGo/Waitlist/NetworkProtectionFeatureVisibility.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,30 @@ struct DefaultNetworkProtectionVisibility: NetworkProtectionFeatureVisibility {
///
/// Once the waitlist beta has ended, we can trigger a remote change that removes the user's auth token and turn off the waitlist flag, hiding Network Protection from the user.
func isNetworkProtectionVisible() -> Bool {
isEasterEggUser || waitlistIsOngoing
#if APPSTORE
return isEasterEggUser || (isUserLocaleAllowed && waitlistIsOngoing)
#else
return isEasterEggUser || waitlistIsOngoing
#endif
}

var isUserLocaleAllowed: Bool {
var regionCode: String?
if #available(macOS 13, *) {
regionCode = Locale.current.region?.identifier
} else {
regionCode = Locale.current.regionCode
}

if isInternalUser {
regionCode = "US"
}

#if DEBUG // Always assume US for debug builds
regionCode = "US"
#endif

return (regionCode ?? "US") == "US"
}

/// Whether the user is fully onboarded
Expand Down Expand Up @@ -129,6 +152,10 @@ struct DefaultNetworkProtectionVisibility: NetworkProtectionFeatureVisibility {
}
}

private var isInternalUser: Bool {
NSApp.delegateTyped.internalUserDecider.isInternalUser
}

func disableForAllUsers() {
Task {
await featureDisabler.disable(keepAuthToken: false, uninstallSystemExtension: false)
Expand Down
6 changes: 6 additions & 0 deletions UnitTests/HomePage/ContinueSetUpModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ final class ContinueSetUpModelTests: XCTestCase {
dataBrokerProtectionRemoteMessaging: MockDataBrokerProtectionRemoteMessaging(),
dataBrokerProtectionUserDefaults: userDefaults
)
#else
let messaging = HomePageRemoteMessaging.defaultMessaging()
#endif

vm = HomePage.Models.ContinueSetUpModel(
Expand Down Expand Up @@ -543,6 +545,8 @@ final class ContinueSetUpModelTests: XCTestCase {
dataBrokerProtectionRemoteMessaging: MockDataBrokerProtectionRemoteMessaging(),
dataBrokerProtectionUserDefaults: userDefaults
)
#else
return HomePageRemoteMessaging.defaultMessaging()
#endif
}

Expand Down Expand Up @@ -587,6 +591,8 @@ extension HomePage.Models.ContinueSetUpModel {
dataBrokerProtectionRemoteMessaging: MockDataBrokerProtectionRemoteMessaging(),
dataBrokerProtectionUserDefaults: appGroupUserDefaults
)
#else
let messaging = HomePageRemoteMessaging.defaultMessaging()
#endif

return HomePage.Models.ContinueSetUpModel(
Expand Down

0 comments on commit 4209093

Please sign in to comment.