Merge pull request #5142 from vector-im/feature/adm/set-usecase-on-account-creation
Aligning use case tracking with iOS
This commit is contained in:
commit
b75fd18959
|
@ -0,0 +1 @@
|
||||||
|
Analytics: aligns use case identifying with iOS implementation
|
|
@ -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 })
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -465,13 +465,11 @@ class OnboardingViewModel @AssistedInject constructor(
|
||||||
|
|
||||||
private fun handleUpdateUseCase(action: OnboardingAction.UpdateUseCase) {
|
private fun handleUpdateUseCase(action: OnboardingAction.UpdateUseCase) {
|
||||||
setState { copy(useCase = action.useCase) }
|
setState { copy(useCase = action.useCase) }
|
||||||
analyticsTracker.updateUserProperties(Identity(ftueUseCaseSelection = action.useCase.toTrackingValue()))
|
|
||||||
_viewEvents.post(OnboardingViewEvents.OpenServerSelection)
|
_viewEvents.post(OnboardingViewEvents.OpenServerSelection)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun resetUseCase() {
|
private fun resetUseCase() {
|
||||||
setState { copy(useCase = null) }
|
setState { copy(useCase = null) }
|
||||||
analyticsTracker.updateUserProperties(Identity(ftueUseCaseSelection = null))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleUpdateServerType(action: OnboardingAction.UpdateServerType) {
|
private fun handleUpdateServerType(action: OnboardingAction.UpdateServerType) {
|
||||||
|
@ -754,6 +752,7 @@ class OnboardingViewModel @AssistedInject constructor(
|
||||||
private suspend fun onSessionCreated(session: Session) {
|
private suspend fun onSessionCreated(session: Session) {
|
||||||
awaitState().useCase?.let { useCase ->
|
awaitState().useCase?.let { useCase ->
|
||||||
session.vectorStore(applicationContext).setUseCase(useCase)
|
session.vectorStore(applicationContext).setUseCase(useCase)
|
||||||
|
analyticsTracker.updateUserProperties(Identity(ftueUseCaseSelection = useCase.toTrackingValue()))
|
||||||
}
|
}
|
||||||
activeSessionHolder.setActiveSession(session)
|
activeSessionHolder.setActiveSession(session)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue