diff --git a/vector/src/main/java/im/vector/app/features/analytics/experiment/ExperimentInteraction.kt b/vector/src/main/java/im/vector/app/features/analytics/experiment/ExperimentInteraction.kt index a6ef02b30b..dae61ddf44 100644 --- a/vector/src/main/java/im/vector/app/features/analytics/experiment/ExperimentInteraction.kt +++ b/vector/src/main/java/im/vector/app/features/analytics/experiment/ExperimentInteraction.kt @@ -31,6 +31,7 @@ data class ExperimentInteraction( SpaceSwitchHeader, SpaceSwitchHeaderAdd, SpaceSwitchHeaderCreate, + SpacePanelSwitchSpace } override fun getName() = "Interaction" diff --git a/vector/src/main/java/im/vector/app/features/home/HomeDetailViewModel.kt b/vector/src/main/java/im/vector/app/features/home/HomeDetailViewModel.kt index 0db12adc9f..4a579b6346 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeDetailViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeDetailViewModel.kt @@ -228,8 +228,22 @@ class HomeDetailViewModel @AssistedInject constructor( appStateHandler.setCurrentSpace(space?.roomId) } + private fun trackSpaceSwitch(){ + when (val groupingMethod = appStateHandler.getCurrentRoomGroupingMethod()) { + is RoomGroupingMethod.ByLegacyGroup -> { + // TODO!! + } + is RoomGroupingMethod.BySpace -> { + groupingMethod.spaceSummary?.toAnalyticsViewRoom(null, groupingMethod)?.let { + analyticsTracker.capture(it) + } + } + } + } + private fun observeRoomSummaries() { appStateHandler.selectedRoomGroupingFlow.distinctUntilChanged().flatMapLatest { + trackSpaceSwitch() // we use it as a trigger to all changes in room, but do not really load // the actual models session.roomService().getPagedRoomSummariesLive( @@ -294,9 +308,6 @@ class HomeDetailViewModel @AssistedInject constructor( hasUnreadMessages = dmRooms.totalCount + otherRooms.totalCount > 0 ) } - groupingMethod.spaceSummary?.toAnalyticsViewRoom(null, groupingMethod)?.let { - analyticsTracker.capture(it) - } } null -> Unit } diff --git a/vector/src/main/java/im/vector/app/features/spaces/SpaceListViewModel.kt b/vector/src/main/java/im/vector/app/features/spaces/SpaceListViewModel.kt index 57068743e8..2089c8b0b3 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/SpaceListViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/SpaceListViewModel.kt @@ -30,7 +30,7 @@ import im.vector.app.core.di.MavericksAssistedViewModelFactory import im.vector.app.core.di.hiltMavericksViewModelFactory import im.vector.app.core.platform.VectorViewModel import im.vector.app.features.analytics.AnalyticsTracker -import im.vector.app.features.analytics.plan.Interaction +import im.vector.app.features.analytics.experiment.ExperimentInteraction import im.vector.app.features.invite.AutoAcceptInvites import im.vector.app.features.session.coroutineScope import im.vector.app.features.settings.VectorPreferences @@ -234,14 +234,13 @@ class SpaceListViewModel @AssistedInject constructor(@Assisted initialState: Spa private fun handleSelectSpace(action: SpaceListAction.SelectSpace) = withState { state -> val groupingMethod = state.selectedGroupingMethod + val isAtSpace = groupingMethod.space() != null if (groupingMethod is RoomGroupingMethod.ByLegacyGroup || groupingMethod.space()?.roomId != action.spaceSummary?.roomId) { - analyticsTracker.capture(Interaction(null, null, Interaction.Name.SpacePanelSwitchSpace)) setState { copy(selectedGroupingMethod = RoomGroupingMethod.BySpace(action.spaceSummary)) } appStateHandler.setCurrentSpace(action.spaceSummary?.roomId) _viewEvents.post(SpaceListViewEvents.OpenSpace(groupingMethod is RoomGroupingMethod.ByLegacyGroup)) - } else { - analyticsTracker.capture(Interaction(null, null, Interaction.Name.SpacePanelSelectedSpace)) } + analyticsTracker.capture(ExperimentInteraction(ExperimentInteraction.Name.SpacePanelSwitchSpace, mapOf("isSubspace" to isAtSpace))) } private fun handleSelectGroup(action: SpaceListAction.SelectLegacyGroup) = withState { state ->