Add extra analytics for notification performance (#6237)

* Add extra analytics for notification performance

Add technical spans to track how long a notification fetching work request takes to run, then how long it takes to actually fetch the events for the notifications

* Remove `withContext(io)` for `FetchNotificationsWorker`

The default `Dispatchers.Default` dispatcher used should be good enough and more performant

* Add network check span
This commit is contained in:
Jorge Martin Espinosa
2026-02-24 13:39:32 +01:00
committed by GitHub
parent 28c1c078a0
commit 2f80b101c5
12 changed files with 100 additions and 13 deletions

View File

@@ -28,4 +28,6 @@ sealed class AnalyticsLongRunningTransaction(
data object LoadJoinedRoomFlow : AnalyticsLongRunningTransaction("Load joined room UI", "ui.load")
data object LoadMessagesUi : AnalyticsLongRunningTransaction("Load messages UI", "ui.load")
data object DisplayFirstTimelineItems : AnalyticsLongRunningTransaction("Get and display first timeline items", null)
data class PushToNotification(val eventId: String) : AnalyticsLongRunningTransaction(AnalyticsTransactions.pushToNotification)
data class PushToWorkManager(val eventId: String) : AnalyticsLongRunningTransaction("Push to WorkManager")
}

View File

@@ -108,11 +108,12 @@ fun AnalyticsService.cancelLongRunningTransaction(
fun AnalyticsService.finishLongRunningTransaction(
longRunningTransaction: AnalyticsLongRunningTransaction,
action: (AnalyticsTransaction) -> Unit = {},
) {
removeLongRunningTransaction(longRunningTransaction)?.let {
): Boolean {
return removeLongRunningTransaction(longRunningTransaction)?.let {
action(it)
it.finish()
}
true
} ?: false
}
inline fun <T> AnalyticsService.inBridgeSdkSpan(parentTraceId: String?, block: (AnalyticsSdkSpan) -> T): T {

View File

@@ -40,5 +40,6 @@ dependencies {
testImplementation(projects.services.analytics.test)
testImplementation(projects.services.analyticsproviders.test)
testImplementation(projects.services.appnavstate.test)
testImplementation(projects.features.networkmonitor.test)
testImplementation(projects.services.toolbox.test)
}

View File

@@ -37,6 +37,12 @@ object AnalyticsTransactions {
operation = "ux",
description = "Send to sent state in timeline",
)
val pushToNotification = TransactionDefinition(
name = "Push to notification",
operation = "push_to_notification",
description = "Time from receiving a push notification until it's displayed",
)
}
data class TransactionDefinition(