Skip to content

Commit

Permalink
Bug 1395124 - Fix issue with first run and second run events in LP. (#…
Browse files Browse the repository at this point in the history
…3116) r=justindarc
  • Loading branch information
farhanpatel committed Aug 31, 2017
1 parent b2dd97a commit 631c293
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
4 changes: 1 addition & 3 deletions Client/Application/LeanplumIntegration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ class LeanplumIntegration {
userAttributesDict[UserAttributeKeyName.pocketInstalled.rawValue] = !canInstallPocket()
userAttributesDict[UserAttributeKeyName.signedInSync.rawValue] = profile?.hasAccount()

Leanplum.start(userAttributes: userAttributesDict)

Leanplum.onStartResponse({ _ in
Leanplum.start(withUserId: nil, userAttributes: userAttributesDict, responseHandler: { _ in
self.track(eventName: LeanplumEventName.openedApp)

// We need to check if the app is a clean install to use for
Expand Down
20 changes: 7 additions & 13 deletions Client/Frontend/Browser/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2690,7 +2690,6 @@ extension BrowserViewController: IntroViewControllerDelegate {
introViewController.modalPresentationStyle = UIModalPresentationStyle.formSheet
}
present(introViewController, animated: true) {
self.profile.prefs.setInt(1, forKey: IntroViewControllerSeenProfileKey)
// On first run (and forced) open up the homepage in the background.
let state = self.getCurrentAppState()
if let homePageURL = HomePageAccessors.getHomePage(state), let tab = self.tabManager.selectedTab, DeviceInfo.hasConnectivity() {
Expand All @@ -2712,16 +2711,20 @@ extension BrowserViewController: IntroViewControllerDelegate {
self.presentSignInViewController(fxaParams)
}

func introViewControllerDidFinish(_ introViewController: IntroViewController) {
func introViewControllerDidFinish(_ introViewController: IntroViewController, requestToLogin: Bool) {
self.profile.prefs.setInt(1, forKey: IntroViewControllerSeenProfileKey)
introViewController.dismiss(animated: true) { finished in
if self.navigationController?.viewControllers.count ?? 0 > 1 {
_ = self.navigationController?.popToRootViewController(animated: true)
}

guard let deeplink = self.profile.prefs.stringForKey("AdjustDeeplinkKey"), let url = URL(string: deeplink) else {
if let deeplink = self.profile.prefs.stringForKey("AdjustDeeplinkKey"), let url = URL(string: deeplink) {
self.launchFxAFromDeeplinkURL(url)
return
}
self.launchFxAFromDeeplinkURL(url)
if requestToLogin {
self.presentSignInViewController()
}
}
}

Expand Down Expand Up @@ -2749,15 +2752,6 @@ extension BrowserViewController: IntroViewControllerDelegate {
self.dismiss(animated: true, completion: nil)
}

func introViewControllerDidRequestToLogin(_ introViewController: IntroViewController) {
introViewController.dismiss(animated: true, completion: { () -> Void in
guard let deeplink = self.profile.prefs.stringForKey("AdjustDeeplinkKey"), let url = URL(string: deeplink) else {
self.presentSignInViewController()
return
}
self.launchFxAFromDeeplinkURL(url)
})
}
}

extension BrowserViewController: FxAContentViewControllerDelegate {
Expand Down
7 changes: 3 additions & 4 deletions Client/Frontend/Intro/IntroViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ struct IntroViewControllerUX {
let IntroViewControllerSeenProfileKey = "IntroViewControllerSeen"

protocol IntroViewControllerDelegate: class {
func introViewControllerDidFinish(_ introViewController: IntroViewController)
func introViewControllerDidRequestToLogin(_ introViewController: IntroViewController)
func introViewControllerDidFinish(_ introViewController: IntroViewController, requestToLogin: Bool)
}

class IntroViewController: UIViewController, UIScrollViewDelegate {
Expand Down Expand Up @@ -271,7 +270,7 @@ class IntroViewController: UIViewController, UIScrollViewDelegate {

func SELstartBrowsing() {
LeanplumIntegration.sharedInstance.track(eventName: .dismissedOnboarding)
delegate?.introViewControllerDidFinish(self)
delegate?.introViewControllerDidFinish(self, requestToLogin: false)
}

func SELback() {
Expand Down Expand Up @@ -299,7 +298,7 @@ class IntroViewController: UIViewController, UIScrollViewDelegate {
}

func SELlogin() {
delegate?.introViewControllerDidRequestToLogin(self)
delegate?.introViewControllerDidFinish(self, requestToLogin: true)
}

fileprivate var accessibilityScrollStatus: String {
Expand Down

0 comments on commit 631c293

Please sign in to comment.