Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable analytics on debug #1101

Merged
merged 3 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/1101.bugfix
yostyle marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Correction de la durée de l'appel dans les données d'usages.
8 changes: 7 additions & 1 deletion vector-config/src/main/java/im/vector/app/config/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions vector/src/main/java/im/vector/app/features/home/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ class WebRtcCall(
}
}
}
var durationMillis = 0
private set

private var inviteTimeout: Deferred<Unit>? = null

Expand Down Expand Up @@ -274,10 +276,6 @@ class WebRtcCall(
}
}

fun durationMillis(): Int {
return timer.elapsedTime().toInt()
}

fun formattedDuration(): String {
return formatDuration(
Duration.ofMillis(timer.elapsedTime())
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading