diff --git a/vector/src/main/java/im/vector/app/features/analytics/impl/DefaultVectorAnalytics.kt b/vector/src/main/java/im/vector/app/features/analytics/impl/DefaultVectorAnalytics.kt index 62d360f5f7..31df1fa055 100644 --- a/vector/src/main/java/im/vector/app/features/analytics/impl/DefaultVectorAnalytics.kt +++ b/vector/src/main/java/im/vector/app/features/analytics/impl/DefaultVectorAnalytics.kt @@ -176,7 +176,7 @@ class DefaultVectorAnalytics @Inject constructor( } override fun updateUserProperties(identity: Identity) { - posthog?.identify(REUSE_EXISTING_ID, identity.getProperties().toPostHogProperties(), IGNORED_OPTIONS) + posthog?.identify(REUSE_EXISTING_ID, identity.getProperties()?.toPostHogUserProperties(), IGNORED_OPTIONS) } private fun Map?.toPostHogProperties(): Properties? { @@ -186,4 +186,14 @@ class DefaultVectorAnalytics @Inject constructor( putAll(this@toPostHogProperties) } } + + /** + * We avoid sending nulls as part of the UserProperties as this will reset the values across all devices + * The Identify event has nullable properties to allow for clients to opt in + */ + private fun Map.toPostHogUserProperties(): Properties { + return Properties().apply { + putAll(this@toPostHogUserProperties.filter { it.value != null }) + } + } }