From 9df13ae121fe803da31ae5c62741f62fa3776701 Mon Sep 17 00:00:00 2001 From: jhugman Date: Sun, 12 Jul 2020 22:47:34 +0000 Subject: [PATCH] For #11655: add leanplum event for installing an addon (#12136) r=elise * For #11655: add leanplum event for installing an addon * Add link to data-review request in PR * Addressed CI comments --- .../org/mozilla/fenix/addons/AddonsManagementFragment.kt | 4 ++++ .../mozilla/fenix/components/metrics/GleanMetricsService.kt | 1 + .../fenix/components/metrics/LeanplumMetricsService.kt | 3 ++- .../java/org/mozilla/fenix/components/metrics/Metrics.kt | 2 ++ docs/mma.md | 5 +++++ 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/mozilla/fenix/addons/AddonsManagementFragment.kt b/app/src/main/java/org/mozilla/fenix/addons/AddonsManagementFragment.kt index 9afcb871f..166ec2a39 100644 --- a/app/src/main/java/org/mozilla/fenix/addons/AddonsManagementFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/addons/AddonsManagementFragment.kt @@ -29,8 +29,10 @@ import mozilla.components.feature.addons.ui.AddonsManagerAdapterDelegate import mozilla.components.feature.addons.ui.PermissionsDialogFragment import mozilla.components.feature.addons.ui.translatedName import org.mozilla.fenix.R +import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.getRootView +import org.mozilla.fenix.ext.requireComponents import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.showToolbar import org.mozilla.fenix.theme.ThemeManager @@ -192,11 +194,13 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management), onPositiveButtonClicked = onPositiveButtonClicked ) dialog.show(parentFragmentManager, PERMISSIONS_DIALOG_FRAGMENT_TAG) + requireContext().components.analytics.metrics.track(Event.AddonInstalled(addon.id)) } } private fun showInstallationDialog(addon: Addon) { if (!isInstallationInProgress && !hasExistingAddonInstallationDialogFragment()) { + requireComponents.analytics.metrics.track(Event.AddonInstalled(addon.id)) val addonCollectionProvider = requireContext().components.addonCollectionProvider val dialog = AddonInstallationDialogFragment.newInstance( diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt index 043cfed25..bd1c43e7c 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt @@ -650,6 +650,7 @@ private val Event.wrapper: EventWrapper<*>? is Event.ClearedPrivateData -> null is Event.DismissedOnboarding -> null is Event.FennecToFenixMigrated -> null + is Event.AddonInstalled -> null } class GleanMetricsService(private val context: Context) : MetricsService { diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt index 957d5617e..d3aa0c8c3 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/LeanplumMetricsService.kt @@ -38,9 +38,10 @@ private val Event.name: String? is Event.ClearedPrivateData -> "E_Cleared_Private_Data" is Event.DismissedOnboarding -> "E_Dismissed_Onboarding" is Event.FennecToFenixMigrated -> "E_Fennec_To_Fenix_Migrated" + is Event.AddonInstalled -> "E_Addon_Installed" // Do not track other events in Leanplum - else -> "" + else -> null } class LeanplumMetricsService(private val application: Application) : MetricsService { diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt index 007dd1536..9e8fe2d88 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/Metrics.kt @@ -465,6 +465,8 @@ sealed class Event { } object CrashReporterOpened : Event() + data class AddonInstalled(val addonId: String) : Event() + data class CrashReporterClosed(val crashSubmitted: Boolean) : Event() { override val extras: Map? get() = mapOf(CrashReporter.closedKeys.crashSubmitted to crashSubmitted.toString()) diff --git a/docs/mma.md b/docs/mma.md index 26f33e1c6..90f3d7a5c 100644 --- a/docs/mma.md +++ b/docs/mma.md @@ -231,6 +231,11 @@ Here is the list of current Events sent, which can be found here in the code bas The user has just migrated from Fennec to Fenix. #8208 + + `E_Addon_Installed` + The user has installed an addon from the addon management page. + #12136 + Deep links