|
|
|
@ -10,7 +10,7 @@ import androidx.lifecycle.LifecycleOwner
|
|
|
|
|
import mozilla.components.browser.state.store.BrowserStore
|
|
|
|
|
import mozilla.components.support.base.android.Clock
|
|
|
|
|
import org.mozilla.fenix.GleanMetrics.EngineTab as EngineMetrics
|
|
|
|
|
import org.mozilla.fenix.GleanMetrics.EngineTab.foregroundMetricsKeys as MetricsKeys
|
|
|
|
|
import org.mozilla.fenix.GleanMetrics.EngineTab.ForegroundMetricsExtra as MetricsExtra
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* [LifecycleObserver] to used on the process lifecycle to measure the amount of tabs getting killed
|
|
|
|
@ -33,17 +33,15 @@ class TelemetryLifecycleObserver(
|
|
|
|
|
val lastState = pausedState ?: return
|
|
|
|
|
val currentState = createTabState()
|
|
|
|
|
|
|
|
|
|
@Suppress("DEPRECATION")
|
|
|
|
|
// FIXME(#19967): Migrate to non-deprecated API.
|
|
|
|
|
EngineMetrics.foregroundMetrics.record(
|
|
|
|
|
mapOf(
|
|
|
|
|
MetricsKeys.backgroundActiveTabs to lastState.activeEngineTabs.toString(),
|
|
|
|
|
MetricsKeys.backgroundCrashedTabs to lastState.crashedTabs.toString(),
|
|
|
|
|
MetricsKeys.backgroundTotalTabs to lastState.totalTabs.toString(),
|
|
|
|
|
MetricsKeys.foregroundActiveTabs to currentState.activeEngineTabs.toString(),
|
|
|
|
|
MetricsKeys.foregroundCrashedTabs to currentState.crashedTabs.toString(),
|
|
|
|
|
MetricsKeys.foregroundTotalTabs to currentState.totalTabs.toString(),
|
|
|
|
|
MetricsKeys.timeInBackground to (currentState.timestamp - lastState.timestamp).toString(),
|
|
|
|
|
MetricsExtra(
|
|
|
|
|
backgroundActiveTabs = lastState.activeEngineTabs.toString(),
|
|
|
|
|
backgroundCrashedTabs = lastState.crashedTabs.toString(),
|
|
|
|
|
backgroundTotalTabs = lastState.totalTabs.toString(),
|
|
|
|
|
foregroundActiveTabs = currentState.activeEngineTabs.toString(),
|
|
|
|
|
foregroundCrashedTabs = currentState.crashedTabs.toString(),
|
|
|
|
|
foregroundTotalTabs = currentState.totalTabs.toString(),
|
|
|
|
|
timeInBackground = (currentState.timestamp - lastState.timestamp).toString(),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|