Adjust metrics to the new specifications (#5937)
* Add `AnalyticsTransactions` with a set of `TransactionDefinition` items matching those in the user story * Use that for `AnalyticsLongRunningTransactions`, make sure we send the right fields (name, operation, description) * Add `AnalyticsSendMessageWatcher` to track how long it takes for an event to be sent and for us to get a call back for that from sync * Add `Noop` implementation for enterprise
This commit is contained in:
parent
a9e095ddf9
commit
06c4b9488b
33 changed files with 443 additions and 48 deletions
|
|
@ -7,15 +7,24 @@
|
|||
|
||||
package io.element.android.services.analytics.api
|
||||
|
||||
import io.element.android.services.analyticsproviders.api.AnalyticsTransactions
|
||||
import io.element.android.services.analyticsproviders.api.TransactionDefinition
|
||||
|
||||
sealed class AnalyticsLongRunningTransaction(
|
||||
val name: String,
|
||||
val operation: String?,
|
||||
val operation: String? = null,
|
||||
val description: String? = null,
|
||||
) {
|
||||
data object ColdStartUntilCachedRoomList : AnalyticsLongRunningTransaction("Cold start until cached room list is displayed", null)
|
||||
data object FirstRoomsDisplayed : AnalyticsLongRunningTransaction("First rooms displayed after login or restoration", null)
|
||||
data object ResumeAppUntilNewRoomsReceived : AnalyticsLongRunningTransaction("App was resumed and new room list items arrived", null)
|
||||
data object NotificationTapOpensTimeline : AnalyticsLongRunningTransaction("A notification was tapped and it opened a timeline", null)
|
||||
data object OpenRoom : AnalyticsLongRunningTransaction("Open a room and see loaded items in the timeline", null)
|
||||
constructor(definition: TransactionDefinition) : this(definition.name, definition.operation, definition.description)
|
||||
|
||||
// UX flows
|
||||
data object ColdStart : AnalyticsLongRunningTransaction(AnalyticsTransactions.coldStart)
|
||||
data object CatchUp : AnalyticsLongRunningTransaction(AnalyticsTransactions.catchUp)
|
||||
data object NotificationToMessage : AnalyticsLongRunningTransaction(AnalyticsTransactions.notificationToMessage)
|
||||
data object OpenRoom : AnalyticsLongRunningTransaction(AnalyticsTransactions.openRoom)
|
||||
|
||||
// Technical flows
|
||||
data object FirstRoomsDisplayed : AnalyticsLongRunningTransaction("First rooms displayed after login or restoration", null, null)
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ interface AnalyticsService : AnalyticsTracker, ErrorTracker {
|
|||
/**
|
||||
* Starts a transaction to measure the performance of an operation.
|
||||
*/
|
||||
fun startTransaction(name: String, operation: String? = null): AnalyticsTransaction
|
||||
fun startTransaction(name: String, operation: String? = null, description: String? = null): AnalyticsTransaction
|
||||
|
||||
/**
|
||||
* Starts an [AnalyticsLongRunningTransaction], that can be shared with other components.
|
||||
|
|
@ -80,11 +80,12 @@ interface AnalyticsService : AnalyticsTracker, ErrorTracker {
|
|||
inline fun <T> AnalyticsService.recordTransaction(
|
||||
name: String,
|
||||
operation: String,
|
||||
description: String? = null,
|
||||
parentTransaction: AnalyticsTransaction? = null,
|
||||
block: (AnalyticsTransaction) -> T
|
||||
): T {
|
||||
val transaction = parentTransaction?.startChild(name, operation)
|
||||
?: startTransaction(name, operation)
|
||||
val transaction = parentTransaction?.startChild(operation, description)
|
||||
?: startTransaction(name, operation, description)
|
||||
try {
|
||||
val result = block(transaction)
|
||||
return result
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2025 Element Creations Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.services.analytics.api.watchers
|
||||
|
||||
/**
|
||||
* An analytics watcher tracking the time it took the client to send a message.
|
||||
*/
|
||||
interface AnalyticsSendMessageWatcher {
|
||||
/**
|
||||
* Start listening to send queue updates and tracking the sending states of the events.
|
||||
*/
|
||||
fun start()
|
||||
|
||||
/**
|
||||
* Stop observing the sending states of the events.
|
||||
*/
|
||||
fun stop()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue