[fenix] For mozilla-mobilehttps://github.com/mozilla-mobile/fenix/issues/8172: Add a new 'E_Fennec_To_Fenix_Migrated' Leanplum event
This new event will be sent when the user has successfully migrated from Fennec to Fenix. This event will only be sent to Leanplum and not to the other telemetry services like Glean or Adjust. Co-authored-by: ValentinTimisica <valentin.timisica@softvision.ro>pull/600/head
parent
7d0ec138cd
commit
673fca0d49
@ -0,0 +1,32 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix
|
||||
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import mozilla.components.lib.state.ext.flowScoped
|
||||
import mozilla.components.support.base.log.logger.Logger
|
||||
import mozilla.components.support.migration.state.MigrationProgress
|
||||
import mozilla.components.support.migration.state.MigrationStore
|
||||
import org.mozilla.fenix.components.metrics.Event
|
||||
import org.mozilla.fenix.components.metrics.MetricController
|
||||
|
||||
class MigrationTelemetryListener(
|
||||
private val metrics: MetricController,
|
||||
private val store: MigrationStore
|
||||
) {
|
||||
@UseExperimental(ExperimentalCoroutinesApi::class)
|
||||
fun start() {
|
||||
// Observe for migration completed.
|
||||
store.flowScoped { flow ->
|
||||
flow.collect { state ->
|
||||
Logger("MigrationTelemetryListener").debug("Migration state: ${state.progress}")
|
||||
if (state.progress == MigrationProgress.COMPLETED) {
|
||||
metrics.track(Event.FennecToFenixMigrated)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue