From 68358b43505347f987e2c690595810b806a66c2e Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 20 Jun 2017 22:51:30 -0700 Subject: Add random user identifier --- app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt | 13 ++++++++++--- app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt | 6 +++++- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'app/src/main/kotlin') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt index dc9f0c11..d21915e7 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt @@ -20,6 +20,7 @@ import com.raizlabs.android.dbflow.config.FlowManager import io.fabric.sdk.android.Fabric import timber.log.Timber import timber.log.Timber.DebugTree +import java.util.* /** @@ -34,18 +35,24 @@ class FrostApp : Application() { // lateinit var refWatcher: RefWatcher override fun onCreate() { + FlowManager.init(FlowConfig.Builder(this).build()) + Prefs.initialize(this, "${BuildConfig.APPLICATION_ID}.prefs") + FbCookie() + if (Prefs.installDate == -1L) { + Prefs.installDate = System.currentTimeMillis() + Prefs.identifier = Random().nextInt(Int.MAX_VALUE) + } // if (LeakCanary.isInAnalyzerProcess(this)) return // refWatcher = LeakCanary.install(this) if (BuildConfig.DEBUG) { Timber.plant(DebugTree()) // LeakCanary.enableDisplayLeakActivity(this) } else { + Crashlytics.setUserIdentifier("${Prefs.installDate}-${Prefs.identifier}") Fabric.with(this, Crashlytics(), Answers()) Timber.plant(CrashReportingTree()) } - FlowManager.init(FlowConfig.Builder(this).build()) - Prefs.initialize(this, "${BuildConfig.APPLICATION_ID}.prefs") - FbCookie() + super.onCreate() //Drawer profile loading logic DrawerImageLoader.init(object : AbstractDrawerImageLoader() { diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt index cda259b2..9f37ff2e 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt @@ -33,7 +33,11 @@ object Prefs : KPref() { var notificationFreq: Long by kpref("notification_freq", -1L) - var versionCode:Int by kpref("version_code", -1) + var versionCode: Int by kpref("version_code", -1) + + var installDate: Long by kpref("install_date", -1L) + + var identifier: Int by kpref("indentifier", -1) private val loader = lazyResettable { Theme.values[Prefs.theme] } -- cgit v1.2.3