view room excessive tracks fixed, added active space property to space switch event

This commit is contained in:
NIkita Fedrunov 2022-05-24 17:01:55 +02:00
parent d70d110454
commit 484afac10b
3 changed files with 18 additions and 7 deletions

View File

@ -31,6 +31,7 @@ data class ExperimentInteraction(
SpaceSwitchHeader, SpaceSwitchHeader,
SpaceSwitchHeaderAdd, SpaceSwitchHeaderAdd,
SpaceSwitchHeaderCreate, SpaceSwitchHeaderCreate,
SpacePanelSwitchSpace
} }
override fun getName() = "Interaction" override fun getName() = "Interaction"

View File

@ -228,8 +228,22 @@ class HomeDetailViewModel @AssistedInject constructor(
appStateHandler.setCurrentSpace(space?.roomId) 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() { private fun observeRoomSummaries() {
appStateHandler.selectedRoomGroupingFlow.distinctUntilChanged().flatMapLatest { appStateHandler.selectedRoomGroupingFlow.distinctUntilChanged().flatMapLatest {
trackSpaceSwitch()
// we use it as a trigger to all changes in room, but do not really load // we use it as a trigger to all changes in room, but do not really load
// the actual models // the actual models
session.roomService().getPagedRoomSummariesLive( session.roomService().getPagedRoomSummariesLive(
@ -294,9 +308,6 @@ class HomeDetailViewModel @AssistedInject constructor(
hasUnreadMessages = dmRooms.totalCount + otherRooms.totalCount > 0 hasUnreadMessages = dmRooms.totalCount + otherRooms.totalCount > 0
) )
} }
groupingMethod.spaceSummary?.toAnalyticsViewRoom(null, groupingMethod)?.let {
analyticsTracker.capture(it)
}
} }
null -> Unit null -> Unit
} }

View File

@ -30,7 +30,7 @@ import im.vector.app.core.di.MavericksAssistedViewModelFactory
import im.vector.app.core.di.hiltMavericksViewModelFactory import im.vector.app.core.di.hiltMavericksViewModelFactory
import im.vector.app.core.platform.VectorViewModel import im.vector.app.core.platform.VectorViewModel
import im.vector.app.features.analytics.AnalyticsTracker 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.invite.AutoAcceptInvites
import im.vector.app.features.session.coroutineScope import im.vector.app.features.session.coroutineScope
import im.vector.app.features.settings.VectorPreferences 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 -> private fun handleSelectSpace(action: SpaceListAction.SelectSpace) = withState { state ->
val groupingMethod = state.selectedGroupingMethod val groupingMethod = state.selectedGroupingMethod
val isAtSpace = groupingMethod.space() != null
if (groupingMethod is RoomGroupingMethod.ByLegacyGroup || groupingMethod.space()?.roomId != action.spaceSummary?.roomId) { 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)) } setState { copy(selectedGroupingMethod = RoomGroupingMethod.BySpace(action.spaceSummary)) }
appStateHandler.setCurrentSpace(action.spaceSummary?.roomId) appStateHandler.setCurrentSpace(action.spaceSummary?.roomId)
_viewEvents.post(SpaceListViewEvents.OpenSpace(groupingMethod is RoomGroupingMethod.ByLegacyGroup)) _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 -> private fun handleSelectGroup(action: SpaceListAction.SelectLegacyGroup) = withState { state ->