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

Feature #6434 - AB Test New Onboarding #6601

Merged
merged 6 commits into from
May 14, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions Client.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@
435D660323D793DF0046EFA2 /* UpdateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 435D660223D793DF0046EFA2 /* UpdateModel.swift */; };
435D660523D794B90046EFA2 /* UpdateViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 435D660423D794B90046EFA2 /* UpdateViewModel.swift */; };
435D660723D7962C0046EFA2 /* UpdateCoverSheetTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 435D660623D7962C0046EFA2 /* UpdateCoverSheetTableViewCell.swift */; };
435D7CC02461EFCB0043ACB9 /* IntroScreenWelcomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 435D7CBF2461EFCB0043ACB9 /* IntroScreenWelcomeView.swift */; };
435D7CC32461EFDD0043ACB9 /* IntroScreenSyncView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 435D7CC22461EFDD0043ACB9 /* IntroScreenSyncView.swift */; };
435D7CC5246209AA0043ACB9 /* IntroViewControllerV2.swift in Sources */ = {isa = PBXBuildFile; fileRef = 435D7CC4246209AA0043ACB9 /* IntroViewControllerV2.swift */; };
43A5643823CD1E1C00B6857D /* UpdateViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43A5643523CD1E1B00B6857D /* UpdateViewController.swift */; };
43A5643923CD1E1C00B6857D /* Update.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 43A5643623CD1E1B00B6857D /* Update.xcassets */; };
43B137F223A181A200CB7FA0 /* NSUserDefaultsPrefs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43B137F123A181A200CB7FA0 /* NSUserDefaultsPrefs.swift */; };
Expand Down Expand Up @@ -1387,6 +1390,9 @@
435D660223D793DF0046EFA2 /* UpdateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateModel.swift; sourceTree = "<group>"; };
435D660423D794B90046EFA2 /* UpdateViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateViewModel.swift; sourceTree = "<group>"; };
435D660623D7962C0046EFA2 /* UpdateCoverSheetTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateCoverSheetTableViewCell.swift; sourceTree = "<group>"; };
435D7CBF2461EFCB0043ACB9 /* IntroScreenWelcomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntroScreenWelcomeView.swift; sourceTree = "<group>"; };
435D7CC22461EFDD0043ACB9 /* IntroScreenSyncView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntroScreenSyncView.swift; sourceTree = "<group>"; };
435D7CC4246209AA0043ACB9 /* IntroViewControllerV2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntroViewControllerV2.swift; sourceTree = "<group>"; };
435FAB17242404B400AE9310 /* FullscreenHelper.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; name = FullscreenHelper.js; path = Client/Frontend/UserContent/UserScripts/AllFrames/AtDocumentStart/FullscreenHelper.js; sourceTree = SOURCE_ROOT; };
43A5643523CD1E1B00B6857D /* UpdateViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UpdateViewController.swift; sourceTree = "<group>"; };
43A5643623CD1E1B00B6857D /* Update.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Update.xcassets; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3033,6 +3039,9 @@
children = (
E49943F41AE6879C00BF9DE4 /* IntroViewController.swift */,
E49943F61AE69EDD00BF9DE4 /* Intro.xcassets */,
435D7CC4246209AA0043ACB9 /* IntroViewControllerV2.swift */,
435D7CBF2461EFCB0043ACB9 /* IntroScreenWelcomeView.swift */,
435D7CC22461EFDD0043ACB9 /* IntroScreenSyncView.swift */,
);
path = Intro;
sourceTree = "<group>";
Expand Down Expand Up @@ -5117,6 +5126,7 @@
EB9854FF2422686F0040F24B /* AppDelegate+PushNotifications.swift in Sources */,
E64ED8FA1BC55AE300DAF864 /* UIAlertControllerExtensions.swift in Sources */,
39CE74F821A83105007AE4F2 /* TranslationSettingsController.swift in Sources */,
435D7CC02461EFCB0043ACB9 /* IntroScreenWelcomeView.swift in Sources */,
282DA4731A68C1E700A406E2 /* OpenSearch.swift in Sources */,
39CE74F421A72309007AE4F2 /* TranslationToastHandler.swift in Sources */,
D04CD74B216CF86B004FF5B0 /* DevicePickerViewController.swift in Sources */,
Expand All @@ -5141,6 +5151,7 @@
C4F3B29A1CFCF93A00966259 /* ButtonToast.swift in Sources */,
EBA3B2D02268F40C00728BDB /* SyncMenuButton.swift in Sources */,
D31A0FC71A65D6D000DC8C7E /* SearchSuggestClient.swift in Sources */,
435D7CC5246209AA0043ACB9 /* IntroViewControllerV2.swift in Sources */,
A83E5AB71C1D993D0026D912 /* UIPasteboardExtensions.swift in Sources */,
D8EFFA0C1FF5B1FA001D3A09 /* NavigationRouter.swift in Sources */,
D0E55C4F1FB4FD23006DC274 /* FormPostHelper.swift in Sources */,
Expand Down Expand Up @@ -5191,6 +5202,7 @@
EBB89504219398E500EB91A0 /* TrackingProtectionPageStats.swift in Sources */,
D31F95E91AC226CB005C9F3B /* ScreenshotHelper.swift in Sources */,
28EADE5D1AFC3A78007FB2FB /* UIImageViewExtensions.swift in Sources */,
435D7CC32461EFDD0043ACB9 /* IntroScreenSyncView.swift in Sources */,
39CE74F021A6D2B8007AE4F2 /* DocumentServicesHelper.swift in Sources */,
D3968F251A38FE8500CEFD3B /* TabManager.swift in Sources */,
C4E398601D22C409004E89BA /* TopTabsLayout.swift in Sources */,
Expand Down
3 changes: 3 additions & 0 deletions Client/Application/LeanplumIntegration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ struct LPAttributeKey {
static let telemetryOptIn = "Telemetry Opt In"
static let fxaAccountVerified = "FxA account is verified"
static let fxaDeviceCount = "Number of devices in FxA account"
static let experimentName = "Experiment name"
static let experimentId = "Experiment id"
static let experimentVariant = "Experiment variant"
}

struct MozillaAppSchemes {
Expand Down
101 changes: 75 additions & 26 deletions Client/Frontend/Browser/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1914,34 +1914,14 @@ extension BrowserViewController: UIAdaptivePresentationControllerDelegate {
}

extension BrowserViewController: IntroViewControllerDelegate {
@discardableResult func presentIntroViewController(_ force: Bool = false, animated: Bool = true) -> Bool {
onboardingUserResearchHelper()
func presentIntroViewController(_ forcedType: OnboardingScreenType? = nil) {
if let deeplink = self.profile.prefs.stringForKey("AdjustDeeplinkKey"), let url = URL(string: deeplink) {
self.launchFxAFromDeeplinkURL(url)
return true
return
}

if force || profile.prefs.intForKey(PrefsKeys.IntroSeen) == nil {
let introViewController = IntroViewController()
introViewController.delegate = self
// On iPad we present it modally in a controller
if topTabsVisible {
introViewController.preferredContentSize = CGSize(width: ViewControllerConsts.PreferredSize.IntroViewController.width, height: ViewControllerConsts.PreferredSize.IntroViewController.height)
introViewController.modalPresentationStyle = .formSheet
} else {
introViewController.modalPresentationStyle = .fullScreen
}
present(introViewController, animated: animated) {
// On first run (and forced) open up the homepage in the background.
if let homePageURL = NewTabHomePageAccessors.getHomePage(self.profile.prefs), let tab = self.tabManager.selectedTab, DeviceInfo.hasConnectivity() {
tab.loadRequest(URLRequest(url: homePageURL))
}
}

return true
if forcedType != nil || profile.prefs.intForKey(PrefsKeys.IntroSeen) == nil {
onboardingUserResearchHelper(forcedType)
}

return false
}

func presentETPCoverSheetViewController(_ force: Bool = false) {
Expand Down Expand Up @@ -2015,10 +1995,79 @@ extension BrowserViewController: IntroViewControllerDelegate {
return false
}

func onboardingUserResearchHelper() {
private func onboardingUserResearchHelper(_ forcedType: OnboardingScreenType? = nil) {
print("lp initial value \(String(describing: onboardingUserResearch?.lpVariable?.boolValue()))")
if forcedType != nil {
showProperIntroVC(forcedType)
return
}
let screenType = onboardingUserResearch?.onboardingScreenType
if screenType == nil && !DeviceInfo.hasConnectivity() {
self.onboardingUserResearch?.updateValue(value: true)
showProperIntroVC()
return
}
onboardingUserResearch?.updatedLPVariables = {(lpVariable) -> () in
print("lpVariable \(String(describing: lpVariable?.boolValue()))")
if screenType == nil {
print("lp Variable from server \(String(describing: lpVariable?.boolValue()))")
self.onboardingUserResearch?.updateTelemetry()
self.onboardingUserResearch?.updateValue(value: lpVariable?.boolValue() ?? true)
self.showProperIntroVC()
}
}
}

private func showProperIntroVC(_ forcedType: OnboardingScreenType? = nil) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactoring Note: Will likely be moved to a new ViewModel for when we combine introViewController + introViewControllerV2

var onboardingType = self.onboardingUserResearch?.onboardingScreenType
if forcedType != nil {
onboardingType = forcedType
}
switch onboardingType {
case .versionV1:
self.introVCHelper()
case .versionV2:
self.introVC2Helper()
case .none:
print("Onboarding screen un-avaialble")
}
}

private func introVCHelper() {
let introViewController = IntroViewController()
introViewController.delegate = self
nbhasin2 marked this conversation as resolved.
Show resolved Hide resolved
self.introVCPresentHelper(introViewController: introViewController)
}

private func introVC2Helper() {
let introViewController = IntroViewControllerV2()
introViewController.didFinishClosure = { controller, fxaLoginFlow in
self.profile.prefs.setInt(1, forKey: PrefsKeys.IntroSeen)
controller.dismiss(animated: true) {
if self.navigationController?.viewControllers.count ?? 0 > 1 {
_ = self.navigationController?.popToRootViewController(animated: true)
}
if let flow = fxaLoginFlow {
let fxaParams = FxALaunchParams(query: ["entrypoint": "firstrun"])
self.presentSignInViewController(fxaParams, flowType: flow)
}
}
}
self.introVCPresentHelper(introViewController: introViewController)
}

private func introVCPresentHelper(introViewController: UIViewController) {
// On iPad we present it modally in a controller
if topTabsVisible {
introViewController.preferredContentSize = CGSize(width: ViewControllerConsts.PreferredSize.IntroViewController.width, height: ViewControllerConsts.PreferredSize.IntroViewController.height)
introViewController.modalPresentationStyle = .formSheet
} else {
introViewController.modalPresentationStyle = .fullScreen
}
present(introViewController, animated: true) {
// On first run (and forced) open up the homepage in the background.
if let homePageURL = NewTabHomePageAccessors.getHomePage(self.profile.prefs), let tab = self.tabManager.selectedTab, DeviceInfo.hasConnectivity() {
tab.loadRequest(URLRequest(url: homePageURL))
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "illustration-syncing-devices.pdf",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.