allowing nullable posthog properties to be submitted

- fixes crash when attempting to identify with empty properties
- will need rebasing with https://github.com/matrix-org/matrix-analytics-events/pull/20
This commit is contained in:
Adam Brown 2022-02-01 13:33:25 +00:00
parent 741f9fabbb
commit d77e18f810
3 changed files with 5 additions and 5 deletions

View File

@ -179,7 +179,7 @@ class DefaultVectorAnalytics @Inject constructor(
posthog?.identify(REUSE_EXISTING_ID, identity.getProperties().toPostHogProperties(), IGNORED_OPTIONS)
}
private fun Map<String, Any>?.toPostHogProperties(): Properties? {
private fun Map<String, Any?>?.toPostHogProperties(): Properties? {
if (this == null) return null
return Properties().apply {

View File

@ -18,5 +18,5 @@ package im.vector.app.features.analytics.itf
interface VectorAnalyticsEvent {
fun getName(): String
fun getProperties(): Map<String, Any>?
fun getProperties(): Map<String, Any?>?
}

View File

@ -55,9 +55,9 @@ data class Identity(
override fun getName() = "Identity"
override fun getProperties(): Map<String, Any>? {
return mutableMapOf<String, Any>().apply {
ftueUseCaseSelection?.let { put("ftueUseCaseSelection", it.name) }
override fun getProperties(): Map<String, Any?>? {
return mutableMapOf<String, Any?>().apply {
put("ftueUseCaseSelection", null)
}.takeIf { it.isNotEmpty() }
}
}