Skip to content

Commit

Permalink
updating the identity with the use case selection as part of the onbo…
Browse files Browse the repository at this point in the history
…arding flow
  • Loading branch information
ouchadam committed Jan 20, 2022
1 parent 9754afe commit 0222a33
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<OnboardingViewState, OnboardingAction, OnboardingViewEvents>(initialState) {

@AssistedFactory
Expand Down Expand Up @@ -463,13 +466,19 @@ 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)
}

private fun resetUseCase() {
viewModelScope.launch {
onboardingStore.resetUseCase()
vectorAnalytics.updateUserProperties(
Identity(ftueUseCaseSelection = null)
)
}
}

Expand Down

0 comments on commit 0222a33

Please sign in to comment.