diff --git a/changelog.d/1101.bugfix b/changelog.d/1101.bugfix new file mode 100644 index 0000000000..1f21c936b1 --- /dev/null +++ b/changelog.d/1101.bugfix @@ -0,0 +1 @@ +Activation du module analytics sur l'instance de dev. diff --git a/vector-config/src/main/java/im/vector/app/config/Config.kt b/vector-config/src/main/java/im/vector/app/config/Config.kt index b4a746f749..417de805a9 100644 --- a/vector-config/src/main/java/im/vector/app/config/Config.kt +++ b/vector-config/src/main/java/im/vector/app/config/Config.kt @@ -83,7 +83,13 @@ object Config { * The analytics configuration to use for the Debug build type. * Can be disabled by providing Analytics.Disabled */ - val DEBUG_ANALYTICS_CONFIG = Analytics.Disabled // TCHAP No analytics + val DEBUG_ANALYTICS_CONFIG = Analytics.Enabled( + postHogHost = "https://us.i.posthog.com", // TCHAP dev posthog + postHogApiKey = "phc_eQOeaQiaIxdX9kaQmqYTD7RJLyFubYmGYKUI9czqqQD", // TCHAP dev posthog + policyLink = "https://tchap.beta.gouv.fr/politique-de-confidentialite", // TCHAP dev posthog + sentryDSN = "", + sentryEnvironment = "DEBUG" + ) /** * The analytics configuration to use for the Release build type. diff --git a/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt b/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt index e3f4de20e0..180e7ebae0 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt @@ -56,6 +56,8 @@ import im.vector.app.features.MainActivityArgs import im.vector.app.features.analytics.accountdata.AnalyticsAccountDataViewModel import im.vector.app.features.analytics.plan.MobileScreen import im.vector.app.features.analytics.plan.ViewRoom +import im.vector.app.features.analytics.ui.consent.AnalyticsConsentViewActions +import im.vector.app.features.analytics.ui.consent.AnalyticsConsentViewModel import im.vector.app.features.crypto.recover.SetupMode import im.vector.app.features.home.room.list.actions.RoomListSharedAction import im.vector.app.features.home.room.list.actions.RoomListSharedActionViewModel @@ -134,6 +136,8 @@ class HomeActivity : private val serverBackupStatusViewModel: ServerBackupStatusViewModel by viewModel() + private val analyticsConsentViewModel: AnalyticsConsentViewModel by viewModel() + @Inject lateinit var vectorUncaughtExceptionHandler: VectorUncaughtExceptionHandler @Inject lateinit var notificationDrawerManager: NotificationDrawerManager @Inject lateinit var popupAlertManager: PopupAlertManager @@ -280,6 +284,7 @@ class HomeActivity : } is HomeActivityViewEvents.OnCrossSignedInvalidated -> handleCrossSigningInvalidated(it) HomeActivityViewEvents.ShowAnalyticsOptIn -> handleShowAnalyticsOptIn() + HomeActivityViewEvents.SetAnalyticsOptIn -> handleSetAnalyticsOptIn() HomeActivityViewEvents.ShowNotificationDialog -> handleShowNotificationDialog() HomeActivityViewEvents.ShowReleaseNotes -> handleShowReleaseNotes() HomeActivityViewEvents.NotifyUserForThreadsMigration -> handleNotifyUserForThreadsMigration() @@ -340,6 +345,11 @@ class HomeActivity : navigator.openAnalyticsOptIn(this) } + // TCHAP user already consented about analytics in the private policy + private fun handleSetAnalyticsOptIn() { + analyticsConsentViewModel.handle(AnalyticsConsentViewActions.SetUserConsent(true)) + } + /** * Migrating from old threads io.element.thread to new m.thread needs an initial sync to * sync and display existing messages appropriately. diff --git a/vector/src/main/java/im/vector/app/features/home/HomeActivityViewEvents.kt b/vector/src/main/java/im/vector/app/features/home/HomeActivityViewEvents.kt index c57f32694b..332cc9dc2d 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeActivityViewEvents.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeActivityViewEvents.kt @@ -33,6 +33,7 @@ sealed interface HomeActivityViewEvents : VectorViewEvents { data class OnCrossSignedInvalidated(val userItem: MatrixItem.UserItem) : HomeActivityViewEvents object PromptToEnableSessionPush : HomeActivityViewEvents object ShowAnalyticsOptIn : HomeActivityViewEvents + object SetAnalyticsOptIn : HomeActivityViewEvents object ShowNotificationDialog : HomeActivityViewEvents object ShowReleaseNotes : HomeActivityViewEvents object NotifyUserForThreadsMigration : HomeActivityViewEvents diff --git a/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt b/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt index dc88747c25..b5e6528274 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt @@ -203,7 +203,9 @@ class HomeActivityViewModel @AssistedInject constructor( .onEach { didAskUser -> Timber.v("DidAskUserConsent: $didAskUser") if (!didAskUser) { - _viewEvents.post(HomeActivityViewEvents.ShowAnalyticsOptIn) + // TCHAP user already consented about analytics in the private policy + //_viewEvents.post(HomeActivityViewEvents.ShowAnalyticsOptIn) + _viewEvents.post(HomeActivityViewEvents.SetAnalyticsOptIn) } else { _viewEvents.post(HomeActivityViewEvents.ShowNotificationDialog) } diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsSecurityPrivacyFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsSecurityPrivacyFragment.kt index c28f67f7ec..09cbc9e175 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsSecurityPrivacyFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsSecurityPrivacyFragment.kt @@ -354,13 +354,15 @@ class VectorSettingsSecurityPrivacyFragment : analyticsConsent.setOnPreferenceChangeListener { _, newValue -> val newValueBool = newValue as? Boolean ?: false - if (newValueBool) { - // User wants to enable analytics, display the opt in screen - navigator.openAnalyticsOptIn(requireContext()) - } else { - // Just disable analytics - analyticsConsentViewModel.handle(AnalyticsConsentViewActions.SetUserConsent(false)) - } + // TCHAP user already consented about analytics in the private policy + analyticsConsentViewModel.handle(AnalyticsConsentViewActions.SetUserConsent(newValueBool)) +// if (newValueBool) { +// // User wants to enable analytics, display the opt in screen +// navigator.openAnalyticsOptIn(requireContext()) +// } else { +// // Just disable analytics +// analyticsConsentViewModel.handle(AnalyticsConsentViewActions.SetUserConsent(false)) +// } true } } diff --git a/vector/src/withdmvoip/java/im/vector/app/features/call/webrtc/WebRtcCall.kt b/vector/src/withdmvoip/java/im/vector/app/features/call/webrtc/WebRtcCall.kt index 9c65d94a94..e56ed1af1e 100644 --- a/vector/src/withdmvoip/java/im/vector/app/features/call/webrtc/WebRtcCall.kt +++ b/vector/src/withdmvoip/java/im/vector/app/features/call/webrtc/WebRtcCall.kt @@ -174,6 +174,8 @@ class WebRtcCall( } } } + var durationMillis = 0 + private set private var inviteTimeout: Deferred? = null @@ -274,10 +276,6 @@ class WebRtcCall( } } - fun durationMillis(): Int { - return timer.elapsedTime().toInt() - } - fun formattedDuration(): String { return formatDuration( Duration.ofMillis(timer.elapsedTime()) @@ -914,6 +912,7 @@ class WebRtcCall( inviteTimeout?.cancel() inviteTimeout = null mxCall.state = CallState.Ended(reason ?: EndCallReason.USER_HANGUP) + durationMillis = timer.elapsedTime().toInt() release() onCallEnded(callId, reason ?: EndCallReason.USER_HANGUP, rejected) } diff --git a/vector/src/withdmvoip/java/im/vector/app/features/call/webrtc/WebRtcCallManager.kt b/vector/src/withdmvoip/java/im/vector/app/features/call/webrtc/WebRtcCallManager.kt index 6213ce2aee..2f01a43128 100644 --- a/vector/src/withdmvoip/java/im/vector/app/features/call/webrtc/WebRtcCallManager.kt +++ b/vector/src/withdmvoip/java/im/vector/app/features/call/webrtc/WebRtcCallManager.kt @@ -477,7 +477,7 @@ class WebRtcCallManager @Inject constructor( private fun WebRtcCall.trackCallEnded() { analyticsTracker.capture( CallEnded( - durationMs = durationMillis(), + durationMs = durationMillis, isVideo = mxCall.isVideoCall, numParticipants = 2, placed = mxCall.isOutgoing