Analytics tracker, support report custom properties not yet in schame

This commit is contained in:
Valere 2024-03-14 11:25:44 +01:00
parent 72d2199f1a
commit 1f430a4015
2 changed files with 9 additions and 3 deletions

View file

@ -23,8 +23,10 @@ import im.vector.app.features.analytics.plan.UserProperties
interface AnalyticsTracker {
/**
* Capture an Event.
*
* @param customProperties Some custom properties to attach to the event.
*/
fun capture(event: VectorAnalyticsEvent)
fun capture(event: VectorAnalyticsEvent, customProperties: Map<String, Any>? = null)
/**
* Track a displayed screen.

View file

@ -171,11 +171,15 @@ class DefaultVectorAnalytics @Inject constructor(
}
}
override fun capture(event: VectorAnalyticsEvent) {
override fun capture(event: VectorAnalyticsEvent, customProperties: Map<String, Any>?) {
Timber.tag(analyticsTag.value).d("capture($event)")
posthog
?.takeIf { userConsent == true }
?.capture(event.getName(), event.getProperties()?.toPostHogProperties())
?.capture(
event.getName(),
(customProperties.orEmpty() +
event.getProperties().orEmpty()).toPostHogProperties()
)
}
override fun screen(screen: VectorAnalyticsScreen) {