mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
add eventtracker file
This commit is contained in:
parent
df7242e5dd
commit
a08acb18fa
1 changed files with 33 additions and 0 deletions
|
|
@ -0,0 +1,33 @@
|
|||
package app.omnivore.omnivore
|
||||
|
||||
import android.content.Context
|
||||
import com.segment.analytics.kotlin.android.Analytics
|
||||
import com.segment.analytics.kotlin.core.*
|
||||
import org.json.JSONObject
|
||||
import javax.inject.Inject
|
||||
|
||||
class EventTracker @Inject constructor(val app: Context) {
|
||||
val segmentAnalytics: Analytics
|
||||
|
||||
init {
|
||||
val writeKey = app.getString(R.string.segment_write_key)
|
||||
|
||||
segmentAnalytics = Analytics(writeKey, app.applicationContext) {
|
||||
trackApplicationLifecycleEvents = true
|
||||
application = app.applicationContext
|
||||
useLifecycleObserver = true
|
||||
}
|
||||
}
|
||||
|
||||
fun registerUser(userID: String) {
|
||||
segmentAnalytics.identify(userID)
|
||||
}
|
||||
|
||||
fun debugMessage(message: String) {
|
||||
track(message)
|
||||
}
|
||||
|
||||
fun track(eventName: String, jsonObject: JSONObject = JSONObject()) {
|
||||
segmentAnalytics.track(eventName, jsonObject)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue