Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
For #8172: Add a new 'E_Fennec_To_Fenix_Migrated' Leanplum event
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
boek and ValentinTimisica committed Feb 13, 2020
1 parent abd56c5 commit 127169f
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ private val Event.wrapper: EventWrapper<*>?
is Event.InteractWithSearchURLArea -> null
is Event.ClearedPrivateData -> null
is Event.DismissedOnboarding -> null
is Event.FennecToFenixMigrated -> null
}

class GleanMetricsService(private val context: Context) : MetricsService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ private val Event.name: String?
is Event.SyncAuthSignOut -> "E_Sign_Out_FxA"
is Event.ClearedPrivateData -> "E_Cleared_Private_Data"
is Event.DismissedOnboarding -> "E_Dismissed_Onboarding"
is Event.FennecToFenixMigrated -> "E_Fennec_To_Fenix_Migrated"

// Do not track other events in Leanplum
else -> ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ sealed class Event {
object RightsTapped : Event()
object LicensingTapped : Event()
object LibrariesThatWeUseTapped : Event()
object FennecToFenixMigrated : Event()

// Interaction events with extras

Expand Down
Original file line number Diff line number Diff line change
@@ -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)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ class MigratingFenixApplication : FenixApplication() {
)
}

val migrationTelemetryListener by lazy {
MigrationTelemetryListener(
components.analytics.metrics,
components.migrationStore
)
}

override fun setupInMainProcessOnly() {
// These migrations need to run before regular initialization happens.
migrateBlocking()
Expand All @@ -55,6 +62,7 @@ class MigratingFenixApplication : FenixApplication() {

// The rest of the migrations can happen now.
migrationPushSubscriber.start()
migrationTelemetryListener.start()
migrator.startMigrationIfNeeded(components.migrationStore, MigrationService::class.java)
}

Expand Down
5 changes: 5 additions & 0 deletions docs/mma.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@ Here is the list of current Events sent, which can be found here in the code bas
<td>The user finished onboarding. Could be triggered by pressing "start browsing," opening settings, or invoking a search.</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/3459#issuecomment-502191109">#3459</a></td>
</tr>
<tr>
<td>`E_Fennec_To_Fenix_Migrated`</td>
<td>The user has just migrated from Fennec to Fenix.</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/8208#issuecomment-584040440">#8208</a></td>
</tr>
</table>

Deep links
Expand Down

0 comments on commit 127169f

Please sign in to comment.