Commit c6a643bf by Demid Merzlyakov

IOS-74: implement AppsFlyer analytics events.

parent 7d64491a
......@@ -7,6 +7,10 @@
import Foundation
/// See
/// https://inmobi.sharepoint.com/:x:/r/sites/blend-all/_layouts/15/guestaccess.aspx?e=KujQS1&share=EROF-1U3ZkVCstR4vAIN8kgB2emhefIzh5yZnZ4v02oIyQ
/// for reference
public enum AnalyticsEvent: String {
//TODO: rename to Swifty names. This is a legacy from the old app.
case ANALYTICS_LAUNCH_FROM_WIDGET = "LAUNCH FROM WIDGET" // params: type
......@@ -85,4 +89,11 @@ public enum AnalyticsEvent: String {
case ANALYTICS_A9_BID_RECEIVED = "A9_BID_RECEIVED"
case ANALYTICS_AD_CLICKED = "AD_CLICKED"
case ANALYTICS_APP_OPEN = "APP_OPEN"
/// FTUE Funnel: User has saved his first city after installing the app.
case ANALYTICS_USER_QUALIFIED = "USER_QUALIFIED"
/// FTUE Funnel: User comes back to the app between the 3rd day after being qualified and 6th day.
case ANALYTICS_D3_RETAINED = "D3_RETAINED"
/// FTUE Funnel: When the user opens the app for the first time
case ANALYTICS_FIRST_OPEN = "FIRST_OPEN"
}
......@@ -47,6 +47,19 @@ 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 {
analytics(log: .ANALYTICS_FIRST_OPEN)
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.
......
......@@ -466,6 +466,10 @@ public class LocationManager {
}
}
else {
if locations.count == 0 && Settings.shared.userQualifiedDate == nil {
analytics(log: .ANALYTICS_USER_QUALIFIED)
Settings.shared.userQualifiedDate = Date()
}
locations = [location] + locations
analytics(log: .ANALYTICS_ADD_LOCATION)
}
......@@ -479,6 +483,10 @@ public class LocationManager {
}
}
else {
if locations.count == 0 && Settings.shared.userQualifiedDate == nil {
analytics(log: .ANALYTICS_USER_QUALIFIED)
Settings.shared.userQualifiedDate = Date()
}
locations.append(location)
analytics(log: .ANALYTICS_ADD_LOCATION)
if selectLocation {
......
......@@ -66,6 +66,12 @@ class Settings {
@UserDefaultsBasicValue(key: "selectedLayer")
public var selectedLayerId:String = DefaultSettingsFactory().getSettings().selectedLayerId
@UserDefaultsOptionalValue("userQualifiedDate")
public var userQualifiedDate: Date?
@UserDefaultsOptionalValue("firstOpenDate")
public var firstOpenDate: Date?
#warning("Not implemented!")
//TODO: implement store in UserDefaults and configure via UI in debug builds.
public var adLogging: Bool = true
......
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