mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-27 12:00:03 +03:00
filtering null values from the identify properties
- resetting values to null may cause inconsistent cross device tracking
This commit is contained in:
parent
63a937c096
commit
48b339075b
1 changed files with 11 additions and 1 deletions
|
@ -176,7 +176,7 @@ class DefaultVectorAnalytics @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateUserProperties(identity: Identity) {
|
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<String, Any?>?.toPostHogProperties(): Properties? {
|
private fun Map<String, Any?>?.toPostHogProperties(): Properties? {
|
||||||
|
@ -186,4 +186,14 @@ class DefaultVectorAnalytics @Inject constructor(
|
||||||
putAll(this@toPostHogProperties)
|
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<String, Any?>.toPostHogUserProperties(): Properties {
|
||||||
|
return Properties().apply {
|
||||||
|
putAll(this@toPostHogUserProperties.filter { it.value != null })
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue