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
bc62d4c8ba
commit
71031008dd
33 changed files with 443 additions and 48 deletions
|
|
@ -26,6 +26,7 @@ import kotlinx.coroutines.flow.asStateFlow
|
|||
class FakeAnalyticsService(
|
||||
isEnabled: Boolean = false,
|
||||
didAskUserConsent: Boolean = false,
|
||||
private val startTransactionLambda: (String, String?, String?) -> AnalyticsTransaction = { _, _, _ -> NoopAnalyticsTransaction },
|
||||
) : AnalyticsService {
|
||||
private val isEnabledFlow = MutableStateFlow(isEnabled)
|
||||
override val didAskUserConsentFlow = MutableStateFlow(didAskUserConsent)
|
||||
|
|
@ -72,7 +73,11 @@ class FakeAnalyticsService(
|
|||
// No op
|
||||
}
|
||||
|
||||
override fun startTransaction(name: String, operation: String?): AnalyticsTransaction = NoopAnalyticsTransaction
|
||||
override fun startTransaction(name: String, operation: String?, description: String?): AnalyticsTransaction = startTransactionLambda(
|
||||
name,
|
||||
operation,
|
||||
description
|
||||
)
|
||||
override fun startLongRunningTransaction(
|
||||
longRunningTransaction: AnalyticsLongRunningTransaction,
|
||||
parentTransaction: AnalyticsTransaction?
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* 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.test.watchers
|
||||
|
||||
import io.element.android.services.analytics.api.watchers.AnalyticsSendMessageWatcher
|
||||
|
||||
class FakeAnalyticsSendMessageWatcher(
|
||||
private val startLambda: () -> Unit = {},
|
||||
private val stopLambda: () -> Unit = {},
|
||||
) : AnalyticsSendMessageWatcher {
|
||||
override fun start() = startLambda()
|
||||
override fun stop() = stopLambda()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue