From e2481fa8e6416c30c55258ad4139cb843e7a3f2b Mon Sep 17 00:00:00 2001 From: fedrunov <66663241+fedrunov@users.noreply.github.com> Date: Tue, 5 Apr 2022 09:28:31 +0200 Subject: [PATCH] metrics for IA project (#5399) --- .../features/createdirect/CreateDirectRoomViewModel.kt | 7 ++++++- .../app/features/createdirect/DirectRoomHelper.kt | 7 ++++++- .../roompreview/RoomPreviewNoPreviewFragment.kt | 6 ++++++ .../roomdirectory/roompreview/RoomPreviewViewModel.kt | 2 +- .../app/features/roomprofile/RoomProfileFragment.kt | 8 +++++++- .../app/features/roomprofile/RoomProfileViewModel.kt | 10 +++++++++- .../features/roomprofile/alias/RoomAliasFragment.kt | 6 ++++++ .../roomprofile/members/RoomMemberListFragment.kt | 6 ++++++ .../notifications/RoomNotificationSettingsFragment.kt | 6 ++++++ .../roomprofile/permissions/RoomPermissionsFragment.kt | 6 ++++++ .../roomprofile/settings/RoomSettingsFragment.kt | 6 ++++++ .../settings/VectorSettingsAdvancedSettingsFragment.kt | 7 +++++++ .../features/settings/VectorSettingsGeneralFragment.kt | 6 ++++++ .../settings/VectorSettingsHelpAboutFragment.kt | 7 +++++++ .../features/settings/VectorSettingsLabsFragment.kt | 7 +++++++ .../settings/VectorSettingsPreferencesFragment.kt | 7 +++++++ .../settings/VectorSettingsVoiceVideoFragment.kt | 7 +++++++ .../ignored/VectorSettingsIgnoredUsersFragment.kt | 6 ++++++ .../app/features/settings/legals/LegalsFragment.kt | 6 ++++++ .../VectorSettingsNotificationPreferenceFragment.kt | 7 +++++++ .../vector/app/features/spaces/SpaceListViewModel.kt | 8 +++++++- .../features/spaces/SpaceSettingsMenuBottomSheet.kt | 6 ++++++ .../features/spaces/explore/SpaceDirectoryFragment.kt | 2 ++ .../app/features/spaces/people/SpacePeopleViewModel.kt | 7 ++++++- 24 files changed, 146 insertions(+), 7 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomViewModel.kt b/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomViewModel.kt index 9ce8e68dab..0d67390654 100644 --- a/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomViewModel.kt @@ -26,11 +26,14 @@ import im.vector.app.core.di.MavericksAssistedViewModelFactory import im.vector.app.core.di.hiltMavericksViewModelFactory import im.vector.app.core.mvrx.runCatchingToAsync import im.vector.app.core.platform.VectorViewModel +import im.vector.app.features.analytics.AnalyticsTracker +import im.vector.app.features.analytics.plan.CreatedRoom import im.vector.app.features.raw.wellknown.getElementWellknown import im.vector.app.features.raw.wellknown.isE2EByDefault import im.vector.app.features.userdirectory.PendingSelection import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +import org.matrix.android.sdk.api.extensions.orFalse import org.matrix.android.sdk.api.raw.RawService import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.permalinks.PermalinkData @@ -41,7 +44,8 @@ import org.matrix.android.sdk.api.session.user.model.User class CreateDirectRoomViewModel @AssistedInject constructor( @Assisted initialState: CreateDirectRoomViewState, private val rawService: RawService, - val session: Session + val session: Session, + val analyticsTracker: AnalyticsTracker ) : VectorViewModel(initialState) { @@ -117,6 +121,7 @@ class CreateDirectRoomViewModel @AssistedInject constructor( val result = runCatchingToAsync { session.createRoom(roomParams) } + analyticsTracker.capture(CreatedRoom(isDM = roomParams.isDirect.orFalse())) setState { copy( diff --git a/vector/src/main/java/im/vector/app/features/createdirect/DirectRoomHelper.kt b/vector/src/main/java/im/vector/app/features/createdirect/DirectRoomHelper.kt index cf75bdf1b6..e9f0cbfea4 100644 --- a/vector/src/main/java/im/vector/app/features/createdirect/DirectRoomHelper.kt +++ b/vector/src/main/java/im/vector/app/features/createdirect/DirectRoomHelper.kt @@ -16,8 +16,11 @@ package im.vector.app.features.createdirect +import im.vector.app.features.analytics.AnalyticsTracker +import im.vector.app.features.analytics.plan.CreatedRoom import im.vector.app.features.raw.wellknown.getElementWellknown import im.vector.app.features.raw.wellknown.isE2EByDefault +import org.matrix.android.sdk.api.extensions.orFalse import org.matrix.android.sdk.api.extensions.tryOrNull import org.matrix.android.sdk.api.raw.RawService import org.matrix.android.sdk.api.session.Session @@ -26,7 +29,8 @@ import javax.inject.Inject class DirectRoomHelper @Inject constructor( private val rawService: RawService, - private val session: Session + private val session: Session, + private val analyticsTracker: AnalyticsTracker ) { suspend fun ensureDMExists(userId: String): String { @@ -45,6 +49,7 @@ class DirectRoomHelper @Inject constructor( enableEncryptionIfInvitedUsersSupportIt = adminE2EByDefault } roomId = session.createRoom(roomParams) + analyticsTracker.capture(CreatedRoom(isDM = roomParams.isDirect.orFalse())) } return roomId } diff --git a/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewNoPreviewFragment.kt b/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewNoPreviewFragment.kt index 90f1a4785d..baa6d0add1 100644 --- a/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewNoPreviewFragment.kt +++ b/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewNoPreviewFragment.kt @@ -37,6 +37,7 @@ import im.vector.app.core.platform.VectorBaseFragment import im.vector.app.core.utils.styleMatchingText import im.vector.app.core.utils.tappableMatchingText import im.vector.app.databinding.FragmentRoomPreviewNoPreviewBinding +import im.vector.app.features.analytics.plan.MobileScreen import im.vector.app.features.home.AvatarRenderer import im.vector.app.features.navigation.Navigator import im.vector.app.features.roomdirectory.JoinState @@ -69,6 +70,11 @@ class RoomPreviewNoPreviewFragment @Inject constructor( views.roomPreviewNoPreviewJoin.commonClicked = { roomPreviewViewModel.handle(RoomPreviewAction.Join) } } + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + analyticsScreenName = MobileScreen.ScreenName.RoomPreview + } + override fun invalidate() = withState(roomPreviewViewModel) { state -> views.roomPreviewNoPreviewJoin.render( diff --git a/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewViewModel.kt b/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewViewModel.kt index a22dc7ed95..8eefd7659d 100644 --- a/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/roomdirectory/roompreview/RoomPreviewViewModel.kt @@ -251,7 +251,7 @@ class RoomPreviewViewModel @AssistedInject constructor( // Always false in this case (?) isDM = false, isSpace = false, - roomSize = state.numJoinMembers.toAnalyticsRoomSize() + roomSize = state.numJoinMembers.toAnalyticsRoomSize(), )) // We do not update the joiningRoomsIds here, because, the room is not joined yet regarding the sync data. // Instead, we wait for the room to be joined diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileFragment.kt b/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileFragment.kt index ba9280dc59..9177f843a0 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileFragment.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileFragment.kt @@ -43,6 +43,7 @@ import im.vector.app.core.utils.copyToClipboard import im.vector.app.core.utils.startSharePlainTextIntent import im.vector.app.databinding.FragmentMatrixProfileBinding import im.vector.app.databinding.ViewStubRoomProfileHeaderBinding +import im.vector.app.features.analytics.plan.Interaction import im.vector.app.features.analytics.plan.MobileScreen import im.vector.app.features.home.AvatarRenderer import im.vector.app.features.home.room.detail.RoomDetailPendingAction @@ -90,7 +91,7 @@ class RoomProfileFragment @Inject constructor( override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - analyticsScreenName = MobileScreen.ScreenName.RoomSettings + analyticsScreenName = MobileScreen.ScreenName.RoomDetails setFragmentResultListener(MigrateRoomBottomSheet.REQUEST_KEY) { _, bundle -> bundle.getString(MigrateRoomBottomSheet.BUNDLE_KEY_REPLACEMENT_ROOM)?.let { replacementRoomId -> roomDetailPendingActionStore.data = RoomDetailPendingAction.OpenRoom(replacementRoomId, closeCurrentRoom = true) @@ -270,6 +271,11 @@ class RoomProfileFragment @Inject constructor( override fun createShortcut() { // Ask the view model to prepare it... roomProfileViewModel.handle(RoomProfileAction.CreateShortcut) + analyticsTracker.capture(Interaction( + index = null, + interactionType = null, + name = Interaction.Name.MobileRoomAddHome + )) } private fun addShortcut(onShortcutReady: RoomProfileViewEvents.OnShortcutReady) { diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileViewModel.kt b/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileViewModel.kt index 61013c8eb6..7c6623b087 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/RoomProfileViewModel.kt @@ -26,6 +26,8 @@ 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.core.resources.StringProvider +import im.vector.app.features.analytics.AnalyticsTracker +import im.vector.app.features.analytics.plan.Interaction import im.vector.app.features.home.ShortcutCreator import im.vector.app.features.powerlevel.PowerLevelsFlowFactory import im.vector.app.features.session.coroutineScope @@ -52,7 +54,8 @@ class RoomProfileViewModel @AssistedInject constructor( @Assisted private val initialState: RoomProfileViewState, private val stringProvider: StringProvider, private val shortcutCreator: ShortcutCreator, - private val session: Session + private val session: Session, + private val analyticsTracker: AnalyticsTracker ) : VectorViewModel(initialState) { @AssistedFactory @@ -186,6 +189,11 @@ class RoomProfileViewModel @AssistedInject constructor( viewModelScope.launch { try { session.leaveRoom(room.roomId) + analyticsTracker.capture(Interaction( + index = null, + interactionType = null, + name = Interaction.Name.MobileRoomLeave + )) // Do nothing, we will be closing the room automatically when it will get back from sync } catch (failure: Throwable) { _viewEvents.post(RoomProfileViewEvents.Failure(failure)) diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/alias/RoomAliasFragment.kt b/vector/src/main/java/im/vector/app/features/roomprofile/alias/RoomAliasFragment.kt index 2a738fd07c..d5eeedee74 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/alias/RoomAliasFragment.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/alias/RoomAliasFragment.kt @@ -33,6 +33,7 @@ import im.vector.app.core.platform.VectorBaseFragment import im.vector.app.core.utils.shareText import im.vector.app.core.utils.toast import im.vector.app.databinding.FragmentRoomSettingGenericBinding +import im.vector.app.features.analytics.plan.MobileScreen import im.vector.app.features.home.AvatarRenderer import im.vector.app.features.roomprofile.RoomProfileArgs import im.vector.app.features.roomprofile.alias.detail.RoomAliasBottomSheet @@ -61,6 +62,11 @@ class RoomAliasFragment @Inject constructor( return FragmentRoomSettingGenericBinding.inflate(inflater, container, false) } + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + analyticsScreenName = MobileScreen.ScreenName.RoomAddresses + } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) sharedActionViewModel = activityViewModelProvider.get(RoomAliasBottomSheetSharedActionViewModel::class.java) diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/members/RoomMemberListFragment.kt b/vector/src/main/java/im/vector/app/features/roomprofile/members/RoomMemberListFragment.kt index d7a9ecf39b..c1e97f0416 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/members/RoomMemberListFragment.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/members/RoomMemberListFragment.kt @@ -32,6 +32,7 @@ import im.vector.app.core.extensions.cleanup import im.vector.app.core.extensions.configureWith import im.vector.app.core.platform.VectorBaseFragment import im.vector.app.databinding.FragmentRoomMemberListBinding +import im.vector.app.features.analytics.plan.MobileScreen import im.vector.app.features.home.AvatarRenderer import im.vector.app.features.roomprofile.RoomProfileArgs import org.matrix.android.sdk.api.session.events.model.Event @@ -54,6 +55,11 @@ class RoomMemberListFragment @Inject constructor( return FragmentRoomMemberListBinding.inflate(inflater, container, false) } + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + analyticsScreenName = MobileScreen.ScreenName.RoomMembers + } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) roomMemberListController.callback = this diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/notifications/RoomNotificationSettingsFragment.kt b/vector/src/main/java/im/vector/app/features/roomprofile/notifications/RoomNotificationSettingsFragment.kt index 320fdfd833..1bf392d9f8 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/notifications/RoomNotificationSettingsFragment.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/notifications/RoomNotificationSettingsFragment.kt @@ -28,6 +28,7 @@ import im.vector.app.core.extensions.cleanup import im.vector.app.core.extensions.configureWith import im.vector.app.core.platform.VectorBaseFragment import im.vector.app.databinding.FragmentRoomSettingGenericBinding +import im.vector.app.features.analytics.plan.MobileScreen import im.vector.app.features.home.AvatarRenderer import im.vector.app.features.settings.VectorSettingsActivity import org.matrix.android.sdk.api.session.room.notification.RoomNotificationState @@ -47,6 +48,11 @@ class RoomNotificationSettingsFragment @Inject constructor( return FragmentRoomSettingGenericBinding.inflate(inflater, container, false) } + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + analyticsScreenName = MobileScreen.ScreenName.RoomNotifications + } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) setupToolbar(views.roomSettingsToolbar) diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/permissions/RoomPermissionsFragment.kt b/vector/src/main/java/im/vector/app/features/roomprofile/permissions/RoomPermissionsFragment.kt index c1175796fb..49efc416ea 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/permissions/RoomPermissionsFragment.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/permissions/RoomPermissionsFragment.kt @@ -30,6 +30,7 @@ import im.vector.app.core.extensions.configureWith import im.vector.app.core.platform.VectorBaseFragment import im.vector.app.core.utils.toast import im.vector.app.databinding.FragmentRoomSettingGenericBinding +import im.vector.app.features.analytics.plan.MobileScreen import im.vector.app.features.home.AvatarRenderer import im.vector.app.features.roommemberprofile.powerlevel.EditPowerLevelDialogs import im.vector.app.features.roomprofile.RoomProfileArgs @@ -52,6 +53,11 @@ class RoomPermissionsFragment @Inject constructor( return FragmentRoomSettingGenericBinding.inflate(inflater, container, false) } + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + analyticsScreenName = MobileScreen.ScreenName.RoomPermissions + } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/settings/RoomSettingsFragment.kt b/vector/src/main/java/im/vector/app/features/roomprofile/settings/RoomSettingsFragment.kt index 0bde35f41e..eb69e36ba0 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/settings/RoomSettingsFragment.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/settings/RoomSettingsFragment.kt @@ -39,6 +39,7 @@ import im.vector.app.core.platform.VectorBaseFragment import im.vector.app.core.resources.ColorProvider import im.vector.app.core.utils.toast import im.vector.app.databinding.FragmentRoomSettingGenericBinding +import im.vector.app.features.analytics.plan.MobileScreen import im.vector.app.features.home.AvatarRenderer import im.vector.app.features.roomprofile.RoomProfileArgs import im.vector.app.features.roomprofile.RoomProfileSharedActionViewModel @@ -77,6 +78,11 @@ class RoomSettingsFragment @Inject constructor( override fun getMenuRes() = R.menu.vector_room_settings + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + analyticsScreenName = MobileScreen.ScreenName.RoomSettings + } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) roomProfileSharedActionViewModel = activityViewModelProvider.get(RoomProfileSharedActionViewModel::class.java) diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsAdvancedSettingsFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsAdvancedSettingsFragment.kt index 68ce4e691c..b616ce1e1f 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsAdvancedSettingsFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsAdvancedSettingsFragment.kt @@ -16,12 +16,14 @@ package im.vector.app.features.settings +import android.os.Bundle import androidx.preference.Preference import androidx.preference.SeekBarPreference import im.vector.app.R import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.core.preference.VectorPreferenceCategory import im.vector.app.core.preference.VectorSwitchPreference +import im.vector.app.features.analytics.plan.MobileScreen import im.vector.app.features.rageshake.RageShake class VectorSettingsAdvancedSettingsFragment : VectorSettingsBaseFragment() { @@ -31,6 +33,11 @@ class VectorSettingsAdvancedSettingsFragment : VectorSettingsBaseFragment() { private var rageshake: RageShake? = null + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + analyticsScreenName = MobileScreen.ScreenName.SettingsAdvanced + } + override fun onResume() { super.onResume() diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsGeneralFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsGeneralFragment.kt index db6b4002a0..7060bd67fd 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsGeneralFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsGeneralFragment.kt @@ -51,6 +51,7 @@ import im.vector.app.core.utils.toast import im.vector.app.databinding.DialogChangePasswordBinding import im.vector.app.features.MainActivity import im.vector.app.features.MainActivityArgs +import im.vector.app.features.analytics.plan.MobileScreen import im.vector.app.features.discovery.DiscoverySettingsFragment import im.vector.app.features.navigation.SettingsActivityPayload import im.vector.app.features.workers.signout.SignOutUiWorker @@ -117,6 +118,11 @@ class VectorSettingsGeneralFragment @Inject constructor( } } + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + analyticsScreenName = MobileScreen.ScreenName.SettingsGeneral + } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsHelpAboutFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsHelpAboutFragment.kt index 31d9cf0426..3a999f299f 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsHelpAboutFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsHelpAboutFragment.kt @@ -16,6 +16,7 @@ package im.vector.app.features.settings +import android.os.Bundle import androidx.preference.Preference import im.vector.app.BuildConfig import im.vector.app.R @@ -24,6 +25,7 @@ import im.vector.app.core.utils.FirstThrottler import im.vector.app.core.utils.copyToClipboard import im.vector.app.core.utils.openAppSettingsPage import im.vector.app.core.utils.openUrlInChromeCustomTab +import im.vector.app.features.analytics.plan.MobileScreen import im.vector.app.features.version.VersionProvider import org.matrix.android.sdk.api.Matrix import javax.inject.Inject @@ -37,6 +39,11 @@ class VectorSettingsHelpAboutFragment @Inject constructor( private val firstThrottler = FirstThrottler(1000) + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + analyticsScreenName = MobileScreen.ScreenName.SettingsHelp + } + override fun bindPref() { // Help findPreference(VectorPreferences.SETTINGS_HELP_PREFERENCE_KEY)!! diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt index 003832fb97..fb2fb2b490 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt @@ -16,11 +16,13 @@ package im.vector.app.features.settings +import android.os.Bundle import androidx.preference.Preference import im.vector.app.R import im.vector.app.core.preference.VectorSwitchPreference import im.vector.app.features.MainActivity import im.vector.app.features.MainActivityArgs +import im.vector.app.features.analytics.plan.MobileScreen import org.matrix.android.sdk.internal.database.lightweight.LightweightSettingsStorage import javax.inject.Inject @@ -33,6 +35,11 @@ class VectorSettingsLabsFragment @Inject constructor( override var titleRes = R.string.room_settings_labs_pref_title override val preferenceXmlRes = R.xml.vector_settings_labs + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + analyticsScreenName = MobileScreen.ScreenName.SettingsLabs + } + override fun bindPref() { findPreference(VectorPreferences.SETTINGS_LABS_AUTO_REPORT_UISI)?.let { pref -> // ensure correct default diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt index fa020c8d26..0c7b1bd7d9 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt @@ -18,6 +18,7 @@ package im.vector.app.features.settings import android.app.Activity import android.content.Context +import android.os.Bundle import android.widget.CheckedTextView import androidx.core.view.children import androidx.preference.Preference @@ -32,6 +33,7 @@ import im.vector.app.core.preference.VectorSwitchPreference import im.vector.app.databinding.DialogSelectTextSizeBinding import im.vector.app.features.MainActivity import im.vector.app.features.MainActivityArgs +import im.vector.app.features.analytics.plan.MobileScreen import im.vector.app.features.configuration.VectorConfiguration import im.vector.app.features.themes.ThemeUtils import javax.inject.Inject @@ -54,6 +56,11 @@ class VectorSettingsPreferencesFragment @Inject constructor( findPreference("SETTINGS_INTERFACE_TAKE_PHOTO_VIDEO")!! } + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + analyticsScreenName = MobileScreen.ScreenName.SettingsPreferences + } + override fun bindPref() { // user interface preferences setUserInterfacePreferences() diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsVoiceVideoFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsVoiceVideoFragment.kt index 05d1a1f60f..fbf54479fc 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsVoiceVideoFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsVoiceVideoFragment.kt @@ -20,6 +20,7 @@ import android.app.Activity import android.content.Intent import android.media.RingtoneManager import android.net.Uri +import android.os.Bundle import androidx.preference.Preference import androidx.preference.SwitchPreference import im.vector.app.R @@ -29,6 +30,7 @@ import im.vector.app.core.utils.getCallRingtoneName import im.vector.app.core.utils.getCallRingtoneUri import im.vector.app.core.utils.setCallRingtoneUri import im.vector.app.core.utils.setUseRiotDefaultRingtone +import im.vector.app.features.analytics.plan.MobileScreen class VectorSettingsVoiceVideoFragment : VectorSettingsBaseFragment() { @@ -42,6 +44,11 @@ class VectorSettingsVoiceVideoFragment : VectorSettingsBaseFragment() { findPreference(VectorPreferences.SETTINGS_CALL_RINGTONE_URI_PREFERENCE_KEY)!! } + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + analyticsScreenName = MobileScreen.ScreenName.SettingsVoiceVideo + } + override fun bindPref() { // Incoming call sounds mUseRiotCallRingtonePreference.onPreferenceClickListener = Preference.OnPreferenceClickListener { diff --git a/vector/src/main/java/im/vector/app/features/settings/ignored/VectorSettingsIgnoredUsersFragment.kt b/vector/src/main/java/im/vector/app/features/settings/ignored/VectorSettingsIgnoredUsersFragment.kt index 5c188fe933..7128639c81 100644 --- a/vector/src/main/java/im/vector/app/features/settings/ignored/VectorSettingsIgnoredUsersFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/ignored/VectorSettingsIgnoredUsersFragment.kt @@ -32,6 +32,7 @@ import im.vector.app.core.extensions.cleanup import im.vector.app.core.extensions.configureWith import im.vector.app.core.platform.VectorBaseFragment import im.vector.app.databinding.FragmentGenericRecyclerBinding +import im.vector.app.features.analytics.plan.MobileScreen import javax.inject.Inject class VectorSettingsIgnoredUsersFragment @Inject constructor( @@ -45,6 +46,11 @@ class VectorSettingsIgnoredUsersFragment @Inject constructor( private val viewModel: IgnoredUsersViewModel by fragmentViewModel() + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + analyticsScreenName = MobileScreen.ScreenName.SettingsIgnoredUsers + } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) diff --git a/vector/src/main/java/im/vector/app/features/settings/legals/LegalsFragment.kt b/vector/src/main/java/im/vector/app/features/settings/legals/LegalsFragment.kt index f9b50bdead..9a4090ad1b 100644 --- a/vector/src/main/java/im/vector/app/features/settings/legals/LegalsFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/legals/LegalsFragment.kt @@ -30,6 +30,7 @@ import im.vector.app.core.utils.FirstThrottler import im.vector.app.core.utils.displayInWebView import im.vector.app.core.utils.openUrlInChromeCustomTab import im.vector.app.databinding.FragmentGenericRecyclerBinding +import im.vector.app.features.analytics.plan.MobileScreen import im.vector.app.features.discovery.ServerPolicy import im.vector.app.features.settings.VectorSettingsUrls import im.vector.app.openOssLicensesMenuActivity @@ -47,6 +48,11 @@ class LegalsFragment @Inject constructor( private val viewModel by fragmentViewModel(LegalsViewModel::class) private val firstThrottler = FirstThrottler(1000) + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + analyticsScreenName = MobileScreen.ScreenName.SettingsLegals + } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) diff --git a/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationPreferenceFragment.kt b/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationPreferenceFragment.kt index 4199bd1753..d363d5d2f3 100644 --- a/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationPreferenceFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationPreferenceFragment.kt @@ -21,6 +21,7 @@ import android.content.Context import android.content.Intent import android.media.RingtoneManager import android.net.Uri +import android.os.Bundle import android.os.Parcelable import android.widget.Toast import androidx.lifecycle.LiveData @@ -40,6 +41,7 @@ import im.vector.app.core.pushers.PushersManager import im.vector.app.core.services.GuardServiceStarter import im.vector.app.core.utils.isIgnoringBatteryOptimizations import im.vector.app.core.utils.requestDisablingBatteryOptimization +import im.vector.app.features.analytics.plan.MobileScreen import im.vector.app.features.notifications.NotificationUtils import im.vector.app.features.settings.BackgroundSyncMode import im.vector.app.features.settings.BackgroundSyncModeChooserDialog @@ -72,6 +74,11 @@ class VectorSettingsNotificationPreferenceFragment @Inject constructor( private var interactionListener: VectorSettingsFragmentInteractionListener? = null + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + analyticsScreenName = MobileScreen.ScreenName.SettingsNotifications + } + override fun bindPref() { findPreference(VectorPreferences.SETTINGS_ENABLE_ALL_NOTIF_PREFERENCE_KEY)!!.let { pref -> val pushRuleService = session 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 20af5b5827..fff8475d2a 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 @@ -28,6 +28,8 @@ import im.vector.app.RoomGroupingMethod 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.invite.AutoAcceptInvites import im.vector.app.features.session.coroutineScope import im.vector.app.features.settings.VectorPreferences @@ -64,7 +66,8 @@ class SpaceListViewModel @AssistedInject constructor(@Assisted initialState: Spa private val appStateHandler: AppStateHandler, private val session: Session, private val vectorPreferences: VectorPreferences, - private val autoAcceptInvites: AutoAcceptInvites + private val autoAcceptInvites: AutoAcceptInvites, + private val analyticsTracker: AnalyticsTracker ) : VectorViewModel(initialState) { @AssistedFactory @@ -225,9 +228,12 @@ class SpaceListViewModel @AssistedInject constructor(@Assisted initialState: Spa private fun handleSelectSpace(action: SpaceListAction.SelectSpace) = withState { state -> val groupingMethod = state.selectedGroupingMethod 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)) } } diff --git a/vector/src/main/java/im/vector/app/features/spaces/SpaceSettingsMenuBottomSheet.kt b/vector/src/main/java/im/vector/app/features/spaces/SpaceSettingsMenuBottomSheet.kt index 7449868292..78eab5b97f 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/SpaceSettingsMenuBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/SpaceSettingsMenuBottomSheet.kt @@ -30,6 +30,7 @@ import dagger.hilt.android.AndroidEntryPoint import im.vector.app.core.extensions.setTextOrHide import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment import im.vector.app.databinding.BottomSheetSpaceSettingsBinding +import im.vector.app.features.analytics.plan.MobileScreen import im.vector.app.features.home.AvatarRenderer import im.vector.app.features.navigation.Navigator import im.vector.app.features.rageshake.BugReporter @@ -71,6 +72,11 @@ class SpaceSettingsMenuBottomSheet : VectorBaseBottomSheetDialogFragment bundle.getString(SpaceAddRoomSpaceChooserBottomSheet.BUNDLE_KEY_ACTION)?.let { action -> diff --git a/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleViewModel.kt b/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleViewModel.kt index 2e386697d4..4fee675351 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/people/SpacePeopleViewModel.kt @@ -26,10 +26,13 @@ import dagger.assisted.AssistedInject 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.CreatedRoom import im.vector.app.features.raw.wellknown.getElementWellknown import im.vector.app.features.raw.wellknown.isE2EByDefault import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +import org.matrix.android.sdk.api.extensions.orFalse import org.matrix.android.sdk.api.raw.RawService import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.room.model.create.CreateRoomParams @@ -37,7 +40,8 @@ import org.matrix.android.sdk.api.session.room.model.create.CreateRoomParams class SpacePeopleViewModel @AssistedInject constructor( @Assisted val initialState: SpacePeopleViewState, private val rawService: RawService, - private val session: Session + private val session: Session, + private val analyticsTracker: AnalyticsTracker ) : VectorViewModel(initialState) { @AssistedFactory @@ -83,6 +87,7 @@ class SpacePeopleViewModel @AssistedInject constructor( try { val roomId = session.createRoom(roomParams) + analyticsTracker.capture(CreatedRoom(isDM = roomParams.isDirect.orFalse())) _viewEvents.post(SpacePeopleViewEvents.OpenRoom(roomId)) setState { copy(createAndInviteState = Success(roomId)) } } catch (failure: Throwable) {