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

For #8172: Add a new "Fenix" Leanplum attribute #8208

Merged
merged 3 commits into from
Feb 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 Expand Up @@ -94,7 +95,8 @@ class LeanplumMetricsService(private val application: Application) : MetricsServ
"klar_installed" to installedApps.contains(MozillaProductDetector.MozillaProducts.KLAR.productName),
"fxa_signed_in" to application.settings().fxaSignedIn,
"fxa_has_synced_items" to application.settings().fxaHasSyncedItems,
"search_widget_installed" to application.settings().searchWidgetInstalled
"search_widget_installed" to application.settings().searchWidgetInstalled,
"fenix" to true
))
}

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
10 changes: 10 additions & 0 deletions docs/mma.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ User Attributes
<td>A boolean indicating that the user has at least one search widget placed on the home screen</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/4694#issuecomment-520591275">#4694</a></td>
</tr>
<tr>
<td>`fenix`</td>
<td>A boolean indicating that this is a Fenix installation</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/8208">#8208</a></td>
</tr>
</table>

Events
Expand Down Expand Up @@ -221,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