Skip to content

Commit

Permalink
Remove VPN feature flag checks (#3334)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/414235014887631/1208254974939835/f
Tech Design URL:
CC:

Description:

This PR cleans up VPN feature flag checks after the subscription launch.
  • Loading branch information
samsymons authored Sep 13, 2024
1 parent 2834118 commit 98d546f
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 77 deletions.
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10885,7 +10885,7 @@
repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 194.1.0;
version = 195.0.0;
};
};
9F8FE9472BAE50E50071E372 /* XCRemoteSwiftPackageReference "lottie-spm" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/DuckDuckGo/BrowserServicesKit",
"state" : {
"revision" : "09b4901eeab71625c4796c0819d0066278b7b6d6",
"version" : "194.1.0"
"revision" : "f9134f887b1215779a1050134d09d7e824a8abc0",
"version" : "195.0.0"
}
},
{
Expand Down
15 changes: 1 addition & 14 deletions DuckDuckGo/AppDependencyProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,25 +125,12 @@ class AppDependencyProvider: DependencyProvider {
privacyConfigurationManager: ContentBlocking.shared.privacyConfigurationManager,
purchasePlatform: .appStore)
let accessTokenProvider: () -> String? = {
func isSubscriptionEnabled() -> Bool {
#if ALPHA || DEBUG
if let subscriptionOverrideEnabled = UserDefaults.networkProtectionGroupDefaults.subscriptionOverrideEnabled {
return subscriptionOverrideEnabled
}
#endif
return subscriptionFeatureAvailability.isFeatureAvailable
}

if isSubscriptionEnabled() {
return { accountManager.accessToken }
}
return { nil }
return { accountManager.accessToken }
}()
#if os(macOS)
networkProtectionKeychainTokenStore = NetworkProtectionKeychainTokenStore(keychainType: .dataProtection(.unspecified),
serviceName: "\(Bundle.main.bundleIdentifier!).authToken",
errorEvents: .networkProtectionAppDebugEvents,
isSubscriptionEnabled: true,
accessTokenProvider: accessTokenProvider)
#else
networkProtectionKeychainTokenStore = NetworkProtectionKeychainTokenStore(accessTokenProvider: accessTokenProvider)
Expand Down
27 changes: 2 additions & 25 deletions DuckDuckGo/DefaultNetworkProtectionVisibility.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,33 +34,10 @@ struct DefaultNetworkProtectionVisibility: NetworkProtectionFeatureVisibility {
}

var token: String? {
if shouldMonitorEntitlement() {
return accountManager.accessToken
}
return nil
}

func isPrivacyProLaunched() -> Bool {
if let subscriptionOverrideEnabled = userDefaults.subscriptionOverrideEnabled {
#if ALPHA || DEBUG
return subscriptionOverrideEnabled
#else
return false
#endif
}

return AppDependencyProvider.shared.subscriptionFeatureAvailability.isFeatureAvailable
}

func shouldMonitorEntitlement() -> Bool {
isPrivacyProLaunched()
return accountManager.accessToken
}

func shouldShowVPNShortcut() -> Bool {
if isPrivacyProLaunched() {
return accountManager.isUserAuthenticated
} else {
return false
}
return accountManager.isUserAuthenticated
}
}
18 changes: 1 addition & 17 deletions DuckDuckGo/NetworkProtectionConvenienceInitialisers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,6 @@ extension ConnectionServerInfoObserverThroughSession {
}
}

extension NetworkProtectionCodeRedemptionCoordinator {

convenience init(isManualCodeRedemptionFlow: Bool = false, accountManager: AccountManager) {
let settings = AppDependencyProvider.shared.vpnSettings
let networkProtectionVisibility = AppDependencyProvider.shared.vpnFeatureVisibility
self.init(
environment: settings.selectedEnvironment,
tokenStore: AppDependencyProvider.shared.networkProtectionKeychainTokenStore,
isManualCodeRedemptionFlow: isManualCodeRedemptionFlow,
errorEvents: .networkProtectionAppDebugEvents,
isSubscriptionEnabled: networkProtectionVisibility.isPrivacyProLaunched()
)
}
}

extension NetworkProtectionVPNSettingsViewModel {
convenience init() {
self.init(
Expand All @@ -86,8 +71,7 @@ extension NetworkProtectionLocationListCompositeRepository {
self.init(
environment: settings.selectedEnvironment,
tokenStore: AppDependencyProvider.shared.networkProtectionKeychainTokenStore,
errorEvents: .networkProtectionAppDebugEvents,
isSubscriptionEnabled: AppDependencyProvider.shared.vpnFeatureVisibility.isPrivacyProLaunched()
errorEvents: .networkProtectionAppDebugEvents
)
}
}
Expand Down
3 changes: 0 additions & 3 deletions DuckDuckGo/NetworkProtectionDebugViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -634,9 +634,6 @@ final class NetworkProtectionDebugViewController: UITableViewController {
cell.textLabel?.text = """
Endpoint: \(AppDependencyProvider.shared.vpnSettings.selectedEnvironment.endpointURL.absoluteString)
isPrivacyProLaunched: \(vpnVisibility.isPrivacyProLaunched() ? "YES" : "NO")
shouldMonitorEntitlement: \(vpnVisibility.shouldMonitorEntitlement() ? "YES" : "NO")
shouldShowVPNShortcut: \(vpnVisibility.shouldShowVPNShortcut() ? "YES" : "NO")
"""
case .none:
Expand Down
7 changes: 1 addition & 6 deletions DuckDuckGo/NetworkProtectionFeatureVisibility.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@ import Foundation
import Subscription

public protocol NetworkProtectionFeatureVisibility {
func isPrivacyProLaunched() -> Bool

/// Whether to enforce entitlement check and show entitlement-related messaging
/// This should always happen after 100% roll out
/// N.B. Backend will independently check for valid entitlement regardless of this value
func shouldMonitorEntitlement() -> Bool

/// Whether to show VPN shortcut on the home screen
func shouldShowVPNShortcut() -> Bool

}
12 changes: 4 additions & 8 deletions DuckDuckGo/SettingsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -464,14 +464,10 @@ extension SettingsViewModel {
}

private func updateNetPStatus(connectionStatus: ConnectionStatus) {
if AppDependencyProvider.shared.vpnFeatureVisibility.isPrivacyProLaunched() {
switch connectionStatus {
case .connected:
self.state.networkProtectionConnected = true
default:
self.state.networkProtectionConnected = false
}
} else {
switch connectionStatus {
case .connected:
self.state.networkProtectionConnected = true
default:
self.state.networkProtectionConnected = false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ final class NetworkProtectionPacketTunnelProvider: PacketTunnelProvider {
providerEvents: Self.packetTunnelProviderEvents,
settings: settings,
defaults: .networkProtectionGroupDefaults,
isSubscriptionEnabled: true,
entitlementCheck: { return await Self.entitlementCheck(accountManager: accountManager) })

accountManager.delegate = self
Expand Down

0 comments on commit 98d546f

Please sign in to comment.