mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-16 03:08:58 +03:00
Analytics: add screen API
This commit is contained in:
parent
5c5a547aeb
commit
995e1e3d49
2 changed files with 21 additions and 5 deletions
|
@ -63,4 +63,9 @@ interface VectorAnalytics {
|
|||
* Capture an Event
|
||||
*/
|
||||
fun capture(event: String, properties: Map<String, Any>? = null)
|
||||
|
||||
/**
|
||||
* Track a displayed screen
|
||||
*/
|
||||
fun screen(name: String, properties: Map<String, Any>? = null)
|
||||
}
|
||||
|
|
|
@ -93,11 +93,22 @@ class DefaultVectorAnalytics @Inject constructor(
|
|||
override fun capture(event: String, properties: Map<String, Any>?) {
|
||||
posthog?.capture(
|
||||
event,
|
||||
properties?.let { props ->
|
||||
Properties().apply {
|
||||
props.forEach { putValue(it.key, it.value) }
|
||||
}
|
||||
}
|
||||
properties.toPostHogProperties()
|
||||
)
|
||||
}
|
||||
|
||||
override fun screen(name: String, properties: Map<String, Any>?) {
|
||||
posthog?.screen(
|
||||
name,
|
||||
properties.toPostHogProperties()
|
||||
)
|
||||
}
|
||||
|
||||
private fun Map<String, Any>?.toPostHogProperties(): Properties? {
|
||||
if (this == null) return null
|
||||
|
||||
return Properties().apply {
|
||||
this@toPostHogProperties.forEach { putValue(it.key, it.value) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue