Add extra properties "cryptoSDK" to Error.CryptoSDK.Rust to all events and screen sent to PostHog.
This commit is contained in:
parent
cf36ce3cec
commit
b8e8578fad
1 changed files with 20 additions and 2 deletions
|
|
@ -20,6 +20,7 @@ import com.posthog.PostHogInterface
|
||||||
import com.squareup.anvil.annotations.ContributesMultibinding
|
import com.squareup.anvil.annotations.ContributesMultibinding
|
||||||
import im.vector.app.features.analytics.itf.VectorAnalyticsEvent
|
import im.vector.app.features.analytics.itf.VectorAnalyticsEvent
|
||||||
import im.vector.app.features.analytics.itf.VectorAnalyticsScreen
|
import im.vector.app.features.analytics.itf.VectorAnalyticsScreen
|
||||||
|
import im.vector.app.features.analytics.plan.Error
|
||||||
import im.vector.app.features.analytics.plan.UserProperties
|
import im.vector.app.features.analytics.plan.UserProperties
|
||||||
import io.element.android.libraries.di.AppScope
|
import io.element.android.libraries.di.AppScope
|
||||||
import io.element.android.services.analyticsproviders.api.AnalyticsProvider
|
import io.element.android.services.analyticsproviders.api.AnalyticsProvider
|
||||||
|
|
@ -56,11 +57,17 @@ class PosthogAnalyticsProvider @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun capture(event: VectorAnalyticsEvent) {
|
override fun capture(event: VectorAnalyticsEvent) {
|
||||||
posthog?.capture(event.getName(), properties = event.getProperties()?.keepOnlyNonNullValues())
|
posthog?.capture(
|
||||||
|
event = event.getName(),
|
||||||
|
properties = event.getProperties()?.keepOnlyNonNullValues().withExtraProperties(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun screen(screen: VectorAnalyticsScreen) {
|
override fun screen(screen: VectorAnalyticsScreen) {
|
||||||
posthog?.screen(screen.getName(), properties = screen.getProperties())
|
posthog?.screen(
|
||||||
|
screenTitle = screen.getName(),
|
||||||
|
properties = screen.getProperties().withExtraProperties(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateUserProperties(userProperties: UserProperties) {
|
override fun updateUserProperties(userProperties: UserProperties) {
|
||||||
|
|
@ -98,3 +105,14 @@ private fun Map<String, Any?>.keepOnlyNonNullValues(): Map<String, Any> {
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Properties which will be added to all Events and Screens.
|
||||||
|
*/
|
||||||
|
private val extraProperties: Map<String, Any> = mapOf(
|
||||||
|
"cryptoSDK" to Error.CryptoSDK.Rust
|
||||||
|
)
|
||||||
|
|
||||||
|
private fun Map<String, Any>?.withExtraProperties(): Map<String, Any> {
|
||||||
|
return orEmpty() + extraProperties
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue