From 0222a33d040ba94b4cf94c35026ad203793edb66 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 20 Jan 2022 10:43:24 +0000 Subject: [PATCH] updating the identity with the use case selection as part of the onboarding flow --- .../im/vector/app/features/onboarding/FtueUseCase.kt | 11 +++++++++++ .../app/features/onboarding/OnboardingViewModel.kt | 11 ++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/onboarding/FtueUseCase.kt b/vector/src/main/java/im/vector/app/features/onboarding/FtueUseCase.kt index 952612b43f8..23bea3eb99b 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/FtueUseCase.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/FtueUseCase.kt @@ -16,6 +16,8 @@ package im.vector.app.features.onboarding +import im.vector.app.features.analytics.plan.Identity + enum class FtueUseCase(val persistableValue: String) { FRIENDS_FAMILY("friends_family"), TEAMS("teams"), @@ -26,3 +28,12 @@ enum class FtueUseCase(val persistableValue: String) { fun from(persistedValue: String) = values().first { it.persistableValue == persistedValue } } } + +fun FtueUseCase.toTrackingValue(): Identity.FtueUseCaseSelection { + return when (this) { + FtueUseCase.FRIENDS_FAMILY -> Identity.FtueUseCaseSelection.PersonalMessaging + FtueUseCase.TEAMS -> Identity.FtueUseCaseSelection.WorkMessaging + FtueUseCase.COMMUNITIES -> Identity.FtueUseCaseSelection.CommunityMessaging + FtueUseCase.SKIP -> Identity.FtueUseCaseSelection.Skip + } +} diff --git a/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewModel.kt b/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewModel.kt index 2a068fab9e1..95928eba683 100644 --- a/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/onboarding/OnboardingViewModel.kt @@ -36,6 +36,8 @@ import im.vector.app.core.platform.VectorViewModel import im.vector.app.core.resources.StringProvider import im.vector.app.core.utils.ensureTrailingSlash import im.vector.app.features.VectorFeatures +import im.vector.app.features.analytics.VectorAnalytics +import im.vector.app.features.analytics.plan.Identity import im.vector.app.features.login.HomeServerConnectionConfigFactory import im.vector.app.features.login.LoginConfig import im.vector.app.features.login.LoginMode @@ -75,7 +77,8 @@ class OnboardingViewModel @AssistedInject constructor( private val stringProvider: StringProvider, private val homeServerHistoryService: HomeServerHistoryService, private val vectorFeatures: VectorFeatures, - private val onboardingStore: OnboardingStore + private val onboardingStore: OnboardingStore, + private val vectorAnalytics: VectorAnalytics ) : VectorViewModel(initialState) { @AssistedFactory @@ -463,6 +466,9 @@ class OnboardingViewModel @AssistedInject constructor( private fun handleUpdateUseCase(action: OnboardingAction.UpdateUseCase) { viewModelScope.launch { onboardingStore.setUseCase(action.useCase) + vectorAnalytics.updateUserProperties( + Identity(ftueUseCaseSelection = action.useCase.toTrackingValue()) + ) } _viewEvents.post(OnboardingViewEvents.OpenServerSelection) } @@ -470,6 +476,9 @@ class OnboardingViewModel @AssistedInject constructor( private fun resetUseCase() { viewModelScope.launch { onboardingStore.resetUseCase() + vectorAnalytics.updateUserProperties( + Identity(ftueUseCaseSelection = null) + ) } }