mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-28 05:07:58 +03:00
Analytics: add capture API
This commit is contained in:
parent
b33cddf0e3
commit
5c5a547aeb
2 changed files with 19 additions and 0 deletions
|
@ -58,4 +58,9 @@ interface VectorAnalytics {
|
|||
* To be called when application is started
|
||||
*/
|
||||
fun init()
|
||||
|
||||
/**
|
||||
* Capture an Event
|
||||
*/
|
||||
fun capture(event: String, properties: Map<String, Any>? = null)
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ package im.vector.app.features.analytics.impl
|
|||
|
||||
import android.content.Context
|
||||
import com.posthog.android.PostHog
|
||||
import com.posthog.android.Properties
|
||||
import im.vector.app.features.analytics.AnalyticsConfig
|
||||
import im.vector.app.features.analytics.VectorAnalytics
|
||||
import im.vector.app.features.analytics.store.AnalyticsStore
|
||||
|
@ -60,6 +61,8 @@ class DefaultVectorAnalytics @Inject constructor(
|
|||
override suspend fun onSignOut() {
|
||||
// reset the analyticsId
|
||||
setAnalyticsId("")
|
||||
// reset the library
|
||||
posthog?.reset()
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
|
@ -86,4 +89,15 @@ class DefaultVectorAnalytics @Inject constructor(
|
|||
.collectDeviceId(false)
|
||||
.build()
|
||||
}
|
||||
|
||||
override fun capture(event: String, properties: Map<String, Any>?) {
|
||||
posthog?.capture(
|
||||
event,
|
||||
properties?.let { props ->
|
||||
Properties().apply {
|
||||
props.forEach { putValue(it.key, it.value) }
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue