Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscription State improvements + Remove SUBSCRIPTION Flag #2726

Merged
merged 12 commits into from
Apr 15, 2024
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// AccountManagerExtension.swift
// AccountManager+AppGroup.swift
// DuckDuckGo
//
// Copyright © 2024 DuckDuckGo. All rights reserved.
Expand All @@ -17,8 +17,6 @@
// limitations under the License.
//

#if SUBSCRIPTION

import Foundation
import Subscription

Expand All @@ -27,5 +25,3 @@ public extension AccountManager {
self.init(subscriptionAppGroup: Bundle.main.appGroup(bundle: .subs))
}
}

#endif
39 changes: 19 additions & 20 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -729,9 +729,6 @@
BD862E072B30F5E30073E2EE /* VPNFeedbackSender.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD862E062B30F5E30073E2EE /* VPNFeedbackSender.swift */; };
BD862E092B30F63E0073E2EE /* VPNMetadataCollector.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD862E082B30F63E0073E2EE /* VPNMetadataCollector.swift */; };
BD862E0B2B30F9300073E2EE /* VPNFeedbackFormView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD862E0A2B30F9300073E2EE /* VPNFeedbackFormView.swift */; };
BDA583872B98B6C700732FDC /* AccountManagerExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDA583862B98B6C700732FDC /* AccountManagerExtension.swift */; };
BDA583882B98B92F00732FDC /* AccountManagerExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDA583862B98B6C700732FDC /* AccountManagerExtension.swift */; };
BDA583892B98BA7600732FDC /* AccountManagerExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDA583862B98B6C700732FDC /* AccountManagerExtension.swift */; };
BDC234F72B27F51100D3C798 /* UniquePixel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDC234F62B27F51100D3C798 /* UniquePixel.swift */; };
BDD3B3552B8EF8DB005857A8 /* NetworkProtectionUNNotificationPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE3766DD2AC5945500AAB575 /* NetworkProtectionUNNotificationPresenter.swift */; };
BDFF031D2BA3D2BD00F324C9 /* DefaultNetworkProtectionVisibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDFF031C2BA3D2BD00F324C9 /* DefaultNetworkProtectionVisibility.swift */; };
Expand Down Expand Up @@ -880,6 +877,7 @@
D6FEB8B12B7498A300C3615F /* HeadlessWebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6FEB8B02B7498A300C3615F /* HeadlessWebView.swift */; };
D6FEB8B32B74990D00C3615F /* HeadlessWebViewNavCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6FEB8B22B74990D00C3615F /* HeadlessWebViewNavCoordinator.swift */; };
D6FEB8B52B74994000C3615F /* HeadlessWebViewCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6FEB8B42B74994000C3615F /* HeadlessWebViewCoordinator.swift */; };
D6FF22482BC95F0B008E7BCC /* AccountManager+AppGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6FF22472BC95F0B008E7BCC /* AccountManager+AppGroup.swift */; };
EA39B7E2268A1A35000C62CD /* privacy-reference-tests in Resources */ = {isa = PBXBuildFile; fileRef = EA39B7E1268A1A35000C62CD /* privacy-reference-tests */; };
EAB19EDA268963510015D3EA /* DomainMatchingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB19ED9268963510015D3EA /* DomainMatchingTests.swift */; };
EE0153E12A6EABE0002A8B26 /* NetworkProtectionConvenienceInitialisers.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE0153E02A6EABE0002A8B26 /* NetworkProtectionConvenienceInitialisers.swift */; };
Expand Down Expand Up @@ -2418,7 +2416,6 @@
BD862E062B30F5E30073E2EE /* VPNFeedbackSender.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPNFeedbackSender.swift; sourceTree = "<group>"; };
BD862E082B30F63E0073E2EE /* VPNMetadataCollector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPNMetadataCollector.swift; sourceTree = "<group>"; };
BD862E0A2B30F9300073E2EE /* VPNFeedbackFormView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPNFeedbackFormView.swift; sourceTree = "<group>"; };
BDA583862B98B6C700732FDC /* AccountManagerExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountManagerExtension.swift; sourceTree = "<group>"; };
BDC234F62B27F51100D3C798 /* UniquePixel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UniquePixel.swift; sourceTree = "<group>"; };
BDFF03192BA39C5A00F324C9 /* NetworkProtectionFeatureVisibility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkProtectionFeatureVisibility.swift; sourceTree = "<group>"; };
BDFF031C2BA3D2BD00F324C9 /* DefaultNetworkProtectionVisibility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultNetworkProtectionVisibility.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2579,6 +2576,7 @@
D6FEB8B02B7498A300C3615F /* HeadlessWebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlessWebView.swift; sourceTree = "<group>"; };
D6FEB8B22B74990D00C3615F /* HeadlessWebViewNavCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlessWebViewNavCoordinator.swift; sourceTree = "<group>"; };
D6FEB8B42B74994000C3615F /* HeadlessWebViewCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlessWebViewCoordinator.swift; sourceTree = "<group>"; };
D6FF22472BC95F0B008E7BCC /* AccountManager+AppGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AccountManager+AppGroup.swift"; sourceTree = "<group>"; };
EA39B7E1268A1A35000C62CD /* privacy-reference-tests */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "privacy-reference-tests"; path = "submodules/privacy-reference-tests"; sourceTree = SOURCE_ROOT; };
EAB19ED9268963510015D3EA /* DomainMatchingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DomainMatchingTests.swift; sourceTree = "<group>"; };
EE0153E02A6EABE0002A8B26 /* NetworkProtectionConvenienceInitialisers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkProtectionConvenienceInitialisers.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -4564,14 +4562,6 @@
path = Feedback;
sourceTree = "<group>";
};
BDA583852B98B69C00732FDC /* Subscription */ = {
isa = PBXGroup;
children = (
BDA583862B98B6C700732FDC /* AccountManagerExtension.swift */,
);
name = Subscription;
sourceTree = "<group>";
};
BDFF031F2BA3D3AD00F324C9 /* Feature Visibility */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -4871,6 +4861,14 @@
name = Model;
sourceTree = "<group>";
};
D6FF22462BC95EF9008E7BCC /* Subscription */ = {
isa = PBXGroup;
children = (
D6FF22472BC95F0B008E7BCC /* AccountManager+AppGroup.swift */,
);
name = Subscription;
sourceTree = "<group>";
};
EA7EFE662677F5BD0075464E /* PrivacyReferenceTests */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -5260,7 +5258,7 @@
F143C2E51E4A4CD400CFDE3A /* Core */ = {
isa = PBXGroup;
children = (
BDA583852B98B69C00732FDC /* Subscription */,
D6FF22462BC95EF9008E7BCC /* Subscription */,
4B470ED4299C484B0086EBDC /* AppTrackingProtection */,
F1CE42A71ECA0A520074A8DF /* Bookmarks */,
837774491F8E1ECE00E17A29 /* ContentBlocker */,
Expand Down Expand Up @@ -6624,7 +6622,6 @@
02025AD42988229800E694E7 /* ProxySocket.swift in Sources */,
02025AD62988229800E694E7 /* SocketProtocol.swift in Sources */,
02025AD82988229800E694E7 /* Tunnel.swift in Sources */,
BDA583892B98BA7600732FDC /* AccountManagerExtension.swift in Sources */,
02025ADA2988229800E694E7 /* Port.swift in Sources */,
02025ADB2988229800E694E7 /* HTTPStreamScanner.swift in Sources */,
02025ADC2988229800E694E7 /* UInt128.swift in Sources */,
Expand Down Expand Up @@ -7078,7 +7075,6 @@
85F98F92296F32BD00742F4A /* SyncSettingsViewController.swift in Sources */,
84E341961E2F7EFB00BDBA6F /* AppDelegate.swift in Sources */,
310D091D2799F57200DC0060 /* Download.swift in Sources */,
BDA583882B98B92F00732FDC /* AccountManagerExtension.swift in Sources */,
C13F3F6C2B7F88470083BE40 /* AuthConfirmationPromptViewModel.swift in Sources */,
1EEF124E2850EADE003DDE57 /* PrivacyIconView.swift in Sources */,
37FCAAAB29911BF1000E420A /* WaitlistExtensions.swift in Sources */,
Expand Down Expand Up @@ -7435,6 +7431,7 @@
854858E32937BC550063610B /* CollectionExtension.swift in Sources */,
1E6A4D692984208800A371D3 /* LocaleExtension.swift in Sources */,
98F6EA472863124100720957 /* ContentBlockerRulesLists.swift in Sources */,
D6FF22482BC95F0B008E7BCC /* AccountManager+AppGroup.swift in Sources */,
F1134EB01F40AC6300B73467 /* AtbParser.swift in Sources */,
EE50052E29C369D300AE0773 /* FeatureFlag.swift in Sources */,
BD15DB852B959CFD00821457 /* BundleExtension.swift in Sources */,
Expand Down Expand Up @@ -7479,7 +7476,6 @@
B652DF0D287C2A6300C12A9C /* PrivacyFeatures.swift in Sources */,
F10E522D1E946F8800CE1253 /* NSAttributedStringExtension.swift in Sources */,
9887DC252354D2AA005C85F5 /* Database.swift in Sources */,
BDA583872B98B6C700732FDC /* AccountManagerExtension.swift in Sources */,
F143C3171E4A99D200CFDE3A /* AppURLs.swift in Sources */,
C1963863283794A000298D4D /* BookmarksCachingSearch.swift in Sources */,
);
Expand Down Expand Up @@ -8705,7 +8701,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_LDFLAGS = "-ld_classic";
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "NETWORK_PROTECTION SUBSCRIPTION";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = NETWORK_PROTECTION;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -8735,7 +8731,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "$(APP_ID)";
PRODUCT_NAME = "$(TARGET_NAME)";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "Development - App";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG APP_TRACKING_PROTECTION NETWORK_PROTECTION SUBSCRIPTION";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG APP_TRACKING_PROTECTION NETWORK_PROTECTION";
SWIFT_VERSION = 5.0;
};
name = Debug;
Expand All @@ -8759,6 +8755,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "$(APP_ID)";
PRODUCT_NAME = "$(TARGET_NAME)";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "match AppStore com.duckduckgo.mobile.ios";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = NETWORK_PROTECTION;
SWIFT_VERSION = 5.0;
};
name = Release;
Expand Down Expand Up @@ -9185,7 +9182,7 @@
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG APP_TRACKING_PROTECTION NETWORK_PROTECTION SUBSCRIPTION ALPHA";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG APP_TRACKING_PROTECTION NETWORK_PROTECTION ALPHA";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2";
VALID_ARCHS = "$(ARCHS_STANDARD_64_BIT)";
Expand Down Expand Up @@ -9217,6 +9214,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "$(APP_ID)";
PRODUCT_NAME = "$(TARGET_NAME)";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "Development App - Alpha";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG APP_TRACKING_PROTECTION NETWORK_PROTECTION ALPHA";
SWIFT_VERSION = 5.0;
};
name = "Alpha Debug";
Expand Down Expand Up @@ -9581,7 +9579,7 @@
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "-ld_classic";
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "NETWORK_PROTECTION ALPHA SUBSCRIPTION";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "NETWORK_PROTECTION ALPHA";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2";
VALID_ARCHS = "$(ARCHS_STANDARD_64_BIT)";
Expand Down Expand Up @@ -9609,6 +9607,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.duckduckgo.mobile.ios.alpha;
PRODUCT_NAME = "$(TARGET_NAME)-Alpha";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "match AppStore com.duckduckgo.mobile.ios.alpha";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "NETWORK_PROTECTION ALPHA";
SWIFT_VERSION = 5.0;
};
name = Alpha;
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" : "b0749d25996c0fa18be07b7851f02ebb3b9fab50",
"version" : "134.0.1"
"revision" : "bc70d1a27263cc97a4060ac9e73ec10929c28a29",
"version" : "134.0.0"
}
},
{
Expand All @@ -50,8 +50,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/content-scope-scripts",
"state" : {
"revision" : "1bb3bc5eb565735051f342a87b5405d4374876c7",
"version" : "5.12.0"
"revision" : "62d5dc3d02f6a8347dc5f0b52162a0107d38b74c",
"version" : "5.8.0"
}
},
{
Expand Down Expand Up @@ -104,8 +104,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/airbnb/lottie-spm.git",
"state" : {
"revision" : "4d0c11c85f5a9ec3d1b0daf2dc6daebc0e2df897",
"version" : "4.4.2"
"revision" : "3bd43e12d6fb54654366a61f7cfaca787318b8ce",
"version" : "4.4.1"
}
},
{
Expand All @@ -122,8 +122,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/privacy-dashboard",
"state" : {
"revision" : "14b13d0c3db38f471ce4ba1ecb502ee1986c84d7",
"version" : "3.5.0"
"revision" : "620921fea14569eb00745cb5a44890d5890d99ec",
"version" : "3.4.0"
}
},
{
Expand Down Expand Up @@ -167,8 +167,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/scinfu/SwiftSoup",
"state" : {
"revision" : "028487d4a8a291b2fe1b4392b5425b6172056148",
"version" : "2.7.2"
"revision" : "1d39e56d364cba79ce43b341f9661b534cccb18d",
"version" : "2.7.1"
}
},
{
Expand Down Expand Up @@ -203,8 +203,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/weichsel/ZIPFoundation.git",
"state" : {
"revision" : "02b6abe5f6eef7e3cbd5f247c5cc24e246efcfe0",
"version" : "0.9.19"
"revision" : "b979e8b52c7ae7f3f39fa0182e738e9e7257eb78",
"version" : "0.9.18"
}
}
],
Expand Down
13 changes: 0 additions & 13 deletions DuckDuckGo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ import Configuration
import Networking
import DDGSync
import SyncDataProviders

#if SUBSCRIPTION
import Subscription
#endif

#if NETWORK_PROTECTION
import NetworkProtection
Expand Down Expand Up @@ -335,9 +332,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
NetworkProtectionAccessController().refreshNetworkProtectionAccess()
#endif

#if SUBSCRIPTION
setupSubscriptionsEnvironment()
#endif

if vpnFeatureVisibility.shouldKeepVPNAccessViaWaitlist() {
clearDebugWaitlistState()
Expand Down Expand Up @@ -406,9 +401,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
#if NETWORK_PROTECTION
private func presentExpiredEntitlementAlert() {
let alertController = CriticalAlerts.makeExpiredEntitlementAlert { [weak self] in
#if SUBSCRIPTION
self?.mainViewController?.segueToPrivacyPro()
#endif
}
window?.rootViewController?.present(alertController, animated: true) { [weak self] in
DailyPixel.fireDailyAndCount(pixel: .privacyProVPNAccessRevokedDialogShown)
Expand Down Expand Up @@ -452,7 +445,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}


#if SUBSCRIPTION
private func setupSubscriptionsEnvironment() {
Task {
#if DEBUG || ALPHA
Expand All @@ -470,7 +462,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
SubscriptionPurchaseEnvironment.current = .appStore
}
}
#endif

func applicationDidBecomeActive(_ application: UIApplication) {
guard !testing else { return }
Expand Down Expand Up @@ -573,7 +564,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

func updateSubscriptionStatus() {
#if SUBSCRIPTION
Task {
let accountManager = AccountManager()

Expand All @@ -588,7 +578,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

_ = await accountManager.fetchEntitlements(cachePolicy: .reloadIgnoringLocalCacheData)
}
#endif
}

func applicationWillResignActive(_ application: UIApplication) {
Expand Down Expand Up @@ -627,15 +616,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

private func firePrivacyProFeatureEnabledPixel() {
#if SUBSCRIPTION
let subscriptionFeatureAvailability = AppDependencyProvider.shared.subscriptionFeatureAvailability
guard subscriptionFeatureAvailability.isFeatureAvailable,
subscriptionFeatureAvailability.isSubscriptionPurchaseAllowed else {
return
}

DailyPixel.fire(pixel: .privacyProFeatureEnabled)
#endif
}

private func fireAppTPActiveUserPixel() {
Expand Down
10 changes: 1 addition & 9 deletions DuckDuckGo/MainViewController+Segues.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ import Bookmarks
import BrowserServicesKit
import SwiftUI
import PrivacyDashboard

#if SUBSCRIPTION
import Subscription
#endif

extension MainViewController {

Expand Down Expand Up @@ -204,15 +201,13 @@ extension MainViewController {
launchSettings()
}

#if SUBSCRIPTION
func segueToPrivacyPro() {
os_log(#function, log: .generalLog, type: .debug)
hideAllHighlightsIfNeeded()
launchSettings {
$0.triggerDeepLinkNavigation(to: .subscriptionFlow)
}
}
#endif

func segueToDebugSettings() {
os_log(#function, log: .generalLog, type: .debug)
Expand Down Expand Up @@ -251,13 +246,10 @@ extension MainViewController {
appSettings: appSettings,
bookmarksDatabase: bookmarksDatabase,
tabManager: tabManager)
#if SUBSCRIPTION

let settingsViewModel = SettingsViewModel(legacyViewProvider: legacyViewProvider,
accountManager: AccountManager(),
deepLink: deepLinkTarget)
#else
let settingsViewModel = SettingsViewModel(legacyViewProvider: legacyViewProvider)
#endif

Pixel.fire(pixel: .settingsPresented,
withAdditionalParameters: PixelExperiment.parameters)
Expand Down
Loading
Loading