aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-06-20 23:04:57 -0700
committerAllan Wang <me@allanwang.ca>2017-06-20 23:04:57 -0700
commit1b74d78f836ca30ef78a779da75f6acb592277a4 (patch)
tree5a35dea3f6ba78bbc2fe0fa16f670ea49aeeb1e5
parent68358b43505347f987e2c690595810b806a66c2e (diff)
downloadfrost-1b74d78f836ca30ef78a779da75f6acb592277a4.tar.gz
frost-1b74d78f836ca30ef78a779da75f6acb592277a4.tar.bz2
frost-1b74d78f836ca30ef78a779da75f6acb592277a4.zip
Add anonymous event logging
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt17
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt6
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt7
3 files changed, 22 insertions, 8 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt
index 3cee4852..85112fdc 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt
@@ -1,6 +1,5 @@
package com.pitchedapps.frost
-import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
import android.os.Bundle
import android.os.Handler
@@ -8,21 +7,22 @@ import android.support.v4.widget.SwipeRefreshLayout
import android.support.v7.widget.AppCompatTextView
import android.support.v7.widget.Toolbar
import android.widget.ImageView
-import ca.allanwang.kau.utils.*
+import ca.allanwang.kau.utils.bindView
+import ca.allanwang.kau.utils.fadeIn
+import ca.allanwang.kau.utils.fadeOut
+import ca.allanwang.kau.utils.setTextWithFade
import com.bumptech.glide.Glide
import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.engine.GlideException
import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.target.Target
+import com.crashlytics.android.answers.LoginEvent
import com.pitchedapps.frost.dbflow.CookieModel
import com.pitchedapps.frost.dbflow.fetchUsername
import com.pitchedapps.frost.dbflow.loadFbCookiesAsync
-import com.pitchedapps.frost.dbflow.saveFbCookie
-import com.pitchedapps.frost.facebook.FACEBOOK_COM
-import com.pitchedapps.frost.facebook.FbTab
import com.pitchedapps.frost.facebook.PROFILE_PICTURE_URL
import com.pitchedapps.frost.utils.L
-import com.pitchedapps.frost.utils.Prefs
+import com.pitchedapps.frost.utils.frostAnswers
import com.pitchedapps.frost.utils.launchNewTask
import com.pitchedapps.frost.utils.setFrostColors
import com.pitchedapps.frost.web.LoginWebView
@@ -32,8 +32,6 @@ import io.reactivex.functions.BiFunction
import io.reactivex.internal.operators.single.SingleToObservable
import io.reactivex.subjects.BehaviorSubject
import io.reactivex.subjects.SingleSubject
-import org.jsoup.Jsoup
-import kotlin.concurrent.thread
/**
@@ -90,6 +88,9 @@ class LoginActivity : BaseActivity() {
refresh = false
if (!foundImage) L.e("Could not get profile photo; Invalid userId?\n\t$cookie")
textview.setTextWithFade(String.format(getString(R.string.welcome), name), duration = 500)
+ frostAnswers {
+ logLogin(LoginEvent().putMethod("frost_browser").putSuccess(true))
+ }
/*
* The user may have logged into an account that is already in the database
* We will let the db handle duplicates and load it now after the new account has been saved
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt
index 9014b50d..2e87d141 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt
@@ -21,6 +21,7 @@ import co.zsmb.materialdrawerkt.draweritems.badgeable.primaryItem
import co.zsmb.materialdrawerkt.draweritems.divider
import co.zsmb.materialdrawerkt.draweritems.profile.profile
import co.zsmb.materialdrawerkt.draweritems.profile.profileSetting
+import com.crashlytics.android.answers.ContentViewEvent
import com.mikepenz.google_material_typeface_library.GoogleMaterial
import com.mikepenz.iconics.IconicsDrawable
import com.mikepenz.materialdrawer.AccountHeader
@@ -250,6 +251,11 @@ class MainActivity : BaseActivity() {
selectedColor = 0x00000001.toLong()
identifier = item.titleId.toLong()
onClick { _ ->
+ frostAnswers {
+ logContentView(ContentViewEvent()
+ .putContentName(item.name)
+ .putContentType("drawer_item"))
+ }
launchWebOverlay(item.url)
false
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
index 954a340f..3e0e6924 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
@@ -15,6 +15,7 @@ import android.view.View
import android.widget.TextView
import ca.allanwang.kau.utils.*
import com.afollestad.materialdialogs.MaterialDialog
+import com.crashlytics.android.answers.Answers
import com.pitchedapps.frost.*
import com.pitchedapps.frost.dbflow.CookieModel
import com.pitchedapps.frost.facebook.FB_URL_BASE
@@ -134,4 +135,10 @@ fun Context.scheduleNotifications(minutes: Long): Boolean {
return false
}
return true
+}
+
+fun frostAnswers(action: Answers.() -> Unit) {
+ if (BuildConfig.DEBUG) return
+ //TODO add opt out toggle
+ Answers.getInstance().action()
} \ No newline at end of file