Commit 15ad20ca by Demid Merzlyakov

IOS-74: AppsFlyer event bugfix: log d3 retention event once.

parent 74580a8d
......@@ -33,7 +33,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
ThemeManager.refreshAppearance()
if let launchOptions = launchOptions {
log.debug("Launch options: \(launchOptions)")
}
......@@ -52,26 +51,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// Note that the Amazon SDK will get assigned a proper value for consent status inside CCPAHelper.onAppLaunch
// So, make sure this call happens after the
CCPAHelper.shared.onAppLaunch()
if CCPAHelper.shared.isNewUser && Settings.shared.firstOpenDate == nil {
var firstOpenSource = FirstOpenSource.icon
if launchOptions?[.remoteNotification] != nil {
firstOpenSource = .pushNotification
}
else if launchOptions?[.url] != nil {
firstOpenSource = .url
}
analytics(log: .ANALYTICS_FIRST_OPEN, params: [.ANALYTICS_KEY_FIST_OPEN_SOURCE: firstOpenSource.rawValue])
Settings.shared.firstOpenDate = Date()
}
if let userQualifiedDate = Settings.shared.userQualifiedDate {
let timeSinceQualified = Date().timeIntervalSince(userQualifiedDate)
let day = TimeInterval(3600 * 24)
if timeSinceQualified >= 3 * day && timeSinceQualified < 6 * day {
analytics(log: .ANALYTICS_D3_RETAINED)
}
}
// As of DTB 3.4.6 the Amazon SDK freezes the main thread on startup for a couple of seconds, which got us rejected during an AppStore Review. We're going to move this initialization to the AppDelegate for now. The consent status is going to be set earlier within CCPAHelper.shared.onAppLaunch(), so make sure CCPAHelper's onAppLaunch is called before Amazon's setAppKey
// TODO: remove setAppKey from here, if Amazon has fixed the freeze on startup.
......@@ -112,7 +91,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
MoEngage.sharedInstance().initializeLive(with: moEngageConfig, andLaunchOptions: launchOptions)
#endif
analytics(log: .ANALYTICS_APP_OPEN)
logAppLaunchEvents(launchOptions: launchOptions)
return true
}
......@@ -138,6 +117,36 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
PushNotificationsManager.shared.set(pushToken: deviceToken)
}
private func logAppLaunchEvents(launchOptions: [UIApplication.LaunchOptionsKey: Any]?) {
let settings = Settings.shared
if settings.firstOpenDate == nil && CCPAHelper.shared.isNewUser {
var firstOpenSource = FirstOpenSource.icon
if launchOptions?[.remoteNotification] != nil {
firstOpenSource = .pushNotification
}
else if launchOptions?[.url] != nil {
firstOpenSource = .url
}
analytics(log: .ANALYTICS_FIRST_OPEN, params: [.ANALYTICS_KEY_FIST_OPEN_SOURCE: firstOpenSource.rawValue])
settings.firstOpenDate = Date()
}
if settings.d3RetentionDate == nil {
if let userQualifiedDate = Settings.shared.userQualifiedDate {
let timeSinceQualified = Date().timeIntervalSince(userQualifiedDate)
let day = TimeInterval(3600 * 24)
if timeSinceQualified >= 3 * day && timeSinceQualified < 6 * day {
analytics(log: .ANALYTICS_D3_RETAINED)
settings.d3RetentionDate = Date()
}
}
}
analytics(log: .ANALYTICS_APP_OPEN)
}
func initializeAppsFlyer() {
appsFlyerLog.info("AppsFlyer initialize with AppsFlyerId: \(kAppsFlyerId), Apple App ID: \(kAppsFlyerAppId)")
appsFlyer.appsFlyerDevKey = kAppsFlyerId
......
......@@ -89,6 +89,9 @@ public class Settings {
@UserDefaultsOptionalValue("firstOpenDate")
public var firstOpenDate: Date?
@UserDefaultsOptionalValue("d3RetentionDate")
public var d3RetentionDate: Date?
@UserDefaultsBasicValue(key: "locationDidAdded")
public var locationDidAdded:Bool = false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment