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

Old to new onboarding migration fix #3934

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions DuckDuckGo-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,9 @@
9F4CC51F2C48D758006A96EB /* ContextualDaxDialogsFactoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F4CC51E2C48D758006A96EB /* ContextualDaxDialogsFactoryTests.swift */; };
9F4CC5242C4A4F0D006A96EB /* SwiftUITestUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F4CC5232C4A4F0D006A96EB /* SwiftUITestUtilities.swift */; };
9F4CC5272C4E230C006A96EB /* PrivacyIconContextualOnboardingAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F4CC5262C4E230C006A96EB /* PrivacyIconContextualOnboardingAnimator.swift */; };
9F5179D82D54598800E40B40 /* DaxDialogsOnboardingMigrator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F5179D72D54598800E40B40 /* DaxDialogsOnboardingMigrator.swift */; };
9F5179DA2D545D4300E40B40 /* DaxDialogsOnboardingMigratorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F5179D92D545D4300E40B40 /* DaxDialogsOnboardingMigratorTests.swift */; };
9F5179DB2D545D4300E40B40 /* DaxDialogsOnboardingMigratorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F5179D92D545D4300E40B40 /* DaxDialogsOnboardingMigratorTests.swift */; };
9F5E5AAC2C3D0FCD00165F54 /* ContextualDaxDialogsFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F5E5AAB2C3D0FCD00165F54 /* ContextualDaxDialogsFactory.swift */; };
9F5E5AB02C3E4C6000165F54 /* ContextualOnboardingPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F5E5AAF2C3E4C6000165F54 /* ContextualOnboardingPresenter.swift */; };
9F5E5AB22C3E606D00165F54 /* ContextualOnboardingPresenterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F5E5AB12C3E606D00165F54 /* ContextualOnboardingPresenterTests.swift */; };
Expand Down Expand Up @@ -2701,6 +2704,8 @@
9F4CC51E2C48D758006A96EB /* ContextualDaxDialogsFactoryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContextualDaxDialogsFactoryTests.swift; sourceTree = "<group>"; };
9F4CC5232C4A4F0D006A96EB /* SwiftUITestUtilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUITestUtilities.swift; sourceTree = "<group>"; };
9F4CC5262C4E230C006A96EB /* PrivacyIconContextualOnboardingAnimator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivacyIconContextualOnboardingAnimator.swift; sourceTree = "<group>"; };
9F5179D72D54598800E40B40 /* DaxDialogsOnboardingMigrator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DaxDialogsOnboardingMigrator.swift; sourceTree = "<group>"; };
9F5179D92D545D4300E40B40 /* DaxDialogsOnboardingMigratorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DaxDialogsOnboardingMigratorTests.swift; sourceTree = "<group>"; };
9F5E5AAB2C3D0FCD00165F54 /* ContextualDaxDialogsFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContextualDaxDialogsFactory.swift; sourceTree = "<group>"; };
9F5E5AAF2C3E4C6000165F54 /* ContextualOnboardingPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContextualOnboardingPresenter.swift; sourceTree = "<group>"; };
9F5E5AB12C3E606D00165F54 /* ContextualOnboardingPresenterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContextualOnboardingPresenterTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -5212,6 +5217,7 @@
9FDEC7B92C9006E000C7A692 /* BrowserComparisonModelTests.swift */,
9F8E0F322CCA642D001EA7C5 /* VideoPlayerViewModelTests.swift */,
9F1798562CD2443F0073018B /* AddToDockPromoViewModelTests.swift */,
9F5179D92D545D4300E40B40 /* DaxDialogsOnboardingMigratorTests.swift */,
);
name = Onboarding;
sourceTree = "<group>";
Expand Down Expand Up @@ -6696,6 +6702,7 @@
851B128B2220483A004781BC /* OnboardingViewController.swift */,
F47E53DA250A9A1C0037C686 /* Onboarding.xcassets */,
6F8496402BC3D8EE00ADA54E /* OnboardingButtonsView.swift */,
9F5179D72D54598800E40B40 /* DaxDialogsOnboardingMigrator.swift */,
);
name = Onboarding;
sourceTree = "<group>";
Expand Down Expand Up @@ -8299,6 +8306,7 @@
98F0FC2021FF18E700CE77AB /* AutoClearSettingsViewController.swift in Sources */,
D67969112BC84CE700BA8B34 /* SubscriptionContainerViewModel.swift in Sources */,
85DB12ED2A1FED0C000A4A72 /* AppDelegate+AppDeepLinks.swift in Sources */,
9F5179D82D54598800E40B40 /* DaxDialogsOnboardingMigrator.swift in Sources */,
98DA6ECA2181E41F00E65433 /* ThemeManager.swift in Sources */,
F1D43AFC2B99C56000BAB743 /* RootDebugViewController+VanillaBrowser.swift in Sources */,
C159DF072A430B60007834BB /* EmailSignupViewController.swift in Sources */,
Expand Down Expand Up @@ -8727,6 +8735,7 @@
CBC88EE12C7F834300F0F8C5 /* SpecialErrorPageUserScriptTests.swift in Sources */,
56D0602D2C383FD2003BAEB5 /* OnboardingSuggestedSearchesProviderTests.swift in Sources */,
31E77B272D038BBC006F1C9F /* OmnibarAccessoryHandlerTests.swift in Sources */,
9F5179DA2D545D4300E40B40 /* DaxDialogsOnboardingMigratorTests.swift in Sources */,
569437242BDD405400C0881B /* SyncBookmarksAdapterTests.swift in Sources */,
858479CD2B87964500D156C1 /* HistoryManagerTests.swift in Sources */,
CBCCF96828885DEE006F4A71 /* AppPrivacyConfigurationTests.swift in Sources */,
Expand Down Expand Up @@ -8832,6 +8841,7 @@
files = (
85F21DB0210F5E32002631A6 /* AtbIntegrationTests.swift in Sources */,
8551912724746EDC0010FDD0 /* SnapshotHelper.swift in Sources */,
9F5179DB2D545D4300E40B40 /* DaxDialogsOnboardingMigratorTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
3 changes: 3 additions & 0 deletions DuckDuckGo/AppLifecycle/AppStates/Launching.swift
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ struct Launching: AppState {
}
}

// Hide Dax Dialogs if users already completed old onboarding.
DaxDialogsOnboardingMigrator().migrateFromOldToNewOboarding()

// MARK: Sync initialisation
#if DEBUG
let defaultEnvironment = ServerEnvironment.development
Expand Down
38 changes: 38 additions & 0 deletions DuckDuckGo/DaxDialogsOnboardingMigrator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// DaxDialogsOnboardingMigrator.swift
// DuckDuckGo
//
// Copyright © 2025 DuckDuckGo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation

// This class is used to avoid showing in-context Dax Dialogs to users who already completed the old onboarding flow.
// https://app.asana.com/0/414709148257752/1209317131414536
final class DaxDialogsOnboardingMigrator {
private let daxDialogsSettings: DaxDialogsSettings

init(daxDialogsSettings: DaxDialogsSettings = DefaultDaxDialogsSettings()) {
self.daxDialogsSettings = daxDialogsSettings
}

func migrateFromOldToNewOboarding() {
// Check if `homeScreenMessagesSeen` is not 0.
// In that case we consider the old onboarding flow completed and hide the dax dialogs.
if daxDialogsSettings.homeScreenMessagesSeen > 0 {
daxDialogsSettings.isDismissed = true
}
}
}
37 changes: 6 additions & 31 deletions DuckDuckGo/DaxDialogsSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@

import Core

protocol DaxDialogsSettings {
protocol DaxDialogsSettings: AnyObject {

var isDismissed: Bool { get set }


// Used to understand if users completed the old onboarding flow and should not be prompted in-context dax dialogs.
var homeScreenMessagesSeen: Int { get }

var browsingAfterSearchShown: Bool { get set }

var browsingWithTrackersShown: Bool { get set }
Expand Down Expand Up @@ -89,31 +92,3 @@ class DefaultDaxDialogsSettings: DaxDialogsSettings {
var lastShownContextualOnboardingDialogType: String?

}

class InMemoryDaxDialogsSettings: DaxDialogsSettings {

var isDismissed: Bool = false

var browsingAfterSearchShown: Bool = false

var browsingWithTrackersShown: Bool = false

var browsingWithoutTrackersShown: Bool = false

var browsingMajorTrackingSiteShown: Bool = false

var fireButtonEducationShownOrExpired: Bool = false

var fireMessageExperimentShown: Bool = false

var fireButtonPulseDateShown: Date?

var privacyButtonPulseShown: Bool = false

var browsingFinalDialogShown = false

var lastVisitedOnboardingWebsiteURLPath: String?

var lastShownContextualOnboardingDialogType: String?

}
Loading
Loading