From 9520c9dd32d4d3befdf4d36894e136d2e408f7f1 Mon Sep 17 00:00:00 2001 From: Gabriel Luong Date: Sat, 30 May 2020 02:12:03 -0400 Subject: [PATCH] For #8920 - [Telemetry] Send add-on ids in a metrics ping --- app/metrics.yaml | 30 +++++++++++++++++++ .../components/metrics/GleanMetricsService.kt | 5 ++-- .../fenix/components/metrics/Metrics.kt | 12 ++++++-- docs/metrics.md | 4 ++- 4 files changed, 46 insertions(+), 5 deletions(-) diff --git a/app/metrics.yaml b/app/metrics.yaml index d79d4953c..2d34e1216 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -2179,6 +2179,10 @@ addons: type: event description: | A user interacted with an installed add-on in the toolbar menu + extra_keys: + addon_id: + description: | + The id of the add-on that was interacted with in the toolbar menu bugs: - https://github.com/mozilla-mobile/fenix/issues/6174 data_reviews: @@ -2212,6 +2216,32 @@ addons: notification_emails: - fenix-core@mozilla.com expires: "2020-09-01" + installed_addons: + type: string_list + description: | + A list of all installed add-ons on the device. + send_in_pings: + - metrics + bugs: + - https://github.com/mozilla-mobile/fenix/issues/8920 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/11080 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-09-01" + enabled_addons: + type: string_list + description: | + A list of all enabled add-ons on the device. + send_in_pings: + - metrics + bugs: + - https://github.com/mozilla-mobile/fenix/issues/8920 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/11080 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-09-01" startup.timeline: framework_start: 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 7989e6ce1..088a7712b 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 @@ -512,8 +512,9 @@ private val Event.wrapper: EventWrapper<*>? is Event.AddonsOpenInSettings -> EventWrapper( { Addons.openAddonsInSettings.record(it) } ) - is Event.AddonsOpenInToolbarMenu -> EventWrapper( - { Addons.openAddonInToolbarMenu.record(it) } + is Event.AddonsOpenInToolbarMenu -> EventWrapper( + { Addons.openAddonInToolbarMenu.record(it) }, + { Addons.openAddonInToolbarMenuKeys.valueOf(it) } ) is Event.TipDisplayed -> EventWrapper( { Tip.displayed.record(it) }, 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 e7aa1477b..ff880f2e2 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 @@ -166,7 +166,6 @@ sealed class Event { object PocketTopSiteRemoved : Event() object FennecToFenixMigrated : Event() object AddonsOpenInSettings : Event() - object AddonsOpenInToolbarMenu : Event() object VoiceSearchTapped : Event() object SearchWidgetCFRDisplayed : Event() object SearchWidgetCFRCanceled : Event() @@ -209,6 +208,11 @@ sealed class Event { } } + data class AddonsOpenInToolbarMenu(val addonId: String) : Event() { + override val extras: Map? + get() = hashMapOf(Addons.openAddonInToolbarMenuKeys.addonId to addonId) + } + data class TipDisplayed(val identifier: String) : Event() { override val extras: Map? get() = hashMapOf(Tip.displayedKeys.identifier to identifier) @@ -442,7 +446,9 @@ private fun Fact.toEvent(): Event? = when (Pair(component, item)) { Component.BROWSER_TOOLBAR to ToolbarFacts.Items.MENU -> { metadata?.get("customTab")?.let { Event.CustomTabsMenuOpened } } - Component.BROWSER_MENU to BrowserMenuFacts.Items.WEB_EXTENSION_MENU_ITEM -> Event.AddonsOpenInToolbarMenu + Component.BROWSER_MENU to BrowserMenuFacts.Items.WEB_EXTENSION_MENU_ITEM -> { + metadata?.get("id")?.let { Event.AddonsOpenInToolbarMenu(it.toString()) } + } Component.FEATURE_CUSTOMTABS to CustomTabsFacts.Items.CLOSE -> Event.CustomTabsClosed Component.FEATURE_CUSTOMTABS to CustomTabsFacts.Items.ACTION_BUTTON -> Event.CustomTabsActionTapped @@ -475,12 +481,14 @@ private fun Fact.toEvent(): Event? = when (Pair(component, item)) { Component.SUPPORT_WEBEXTENSIONS to WebExtensionFacts.Items.WEB_EXTENSIONS_INITIALIZED -> { metadata?.get("installed")?.let { installedAddons -> if (installedAddons is List<*>) { + Addons.installedAddons.set(installedAddons.map { it.toString() }) Addons.hasInstalledAddons.set(installedAddons.size > 0) } } metadata?.get("enabled")?.let { enabledAddons -> if (enabledAddons is List<*>) { + Addons.enabledAddons.set(enabledAddons.map { it.toString() }) Addons.hasEnabledAddons.set(enabledAddons.size > 0) } } diff --git a/docs/metrics.md b/docs/metrics.md index 2e0956633..ac9582940 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -53,7 +53,7 @@ The following metrics are added to the ping: | about_page.privacy_notice_tapped |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user tapped on "Privacy notice" item from About page |[1](https://github.com/mozilla-mobile/fenix/pull/8047)||2020-09-01 | | about_page.rights_tapped |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user tapped on "Know your rights" item from About page |[1](https://github.com/mozilla-mobile/fenix/pull/8047)||2020-09-01 | | about_page.support_tapped |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user tapped on "Support" item from About page |[1](https://github.com/mozilla-mobile/fenix/pull/8047)||2020-09-01 | -| addons.open_addon_in_toolbar_menu |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user interacted with an installed add-on in the toolbar menu |[1](https://github.com/mozilla-mobile/fenix/pull/8318)||2020-09-01 | +| addons.open_addon_in_toolbar_menu |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user interacted with an installed add-on in the toolbar menu |[1](https://github.com/mozilla-mobile/fenix/pull/8318)|
  • addon_id: The id of the add-on that was interacted with in the toolbar menu
|2020-09-01 | | addons.open_addons_in_settings |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user accessed "Add-ons" from the Settings |[1](https://github.com/mozilla-mobile/fenix/pull/8318)||2020-09-01 | | app_theme.dark_theme_selected |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user selected Dark Theme |[1](https://github.com/mozilla-mobile/fenix/pull/7968)|
  • source: The source from where dark theme was selected. The source can be 'SETTINGS' or 'ONBOARDING'
|2020-09-01 | | bookmarks_management.copied |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user copied a bookmark. |[1](https://github.com/mozilla-mobile/fenix/pull/1708)||2020-09-01 | @@ -222,8 +222,10 @@ The following metrics are added to the ping: | Name | Type | Description | Data reviews | Extras | Expiration | | --- | --- | --- | --- | --- | --- | +| addons.enabled_addons |[string_list](https://mozilla.github.io/glean/book/user/metrics/string_list.html) |A list of all enabled add-ons on the device. |[1](https://github.com/mozilla-mobile/fenix/pull/11080)||2020-09-01 | | addons.has_enabled_addons |[boolean](https://mozilla.github.io/glean/book/user/metrics/boolean.html) |Whether or not the user has enabled add-ons on the device. |[1](https://github.com/mozilla-mobile/fenix/pull/8318)||2020-09-01 | | addons.has_installed_addons |[boolean](https://mozilla.github.io/glean/book/user/metrics/boolean.html) |Whether or not the user has installed add-ons on the device. |[1](https://github.com/mozilla-mobile/fenix/pull/8318)||2020-09-01 | +| addons.installed_addons |[string_list](https://mozilla.github.io/glean/book/user/metrics/string_list.html) |A list of all installed add-ons on the device. |[1](https://github.com/mozilla-mobile/fenix/pull/11080)||2020-09-01 | | browser.search.ad_clicks |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |Records clicks of adverts on SERP pages. The key format is ‘’. |[1](https://github.com/mozilla-mobile/fenix/pull/10112)||2020-09-01 | | browser.search.in_content |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |Records the type of interaction a user has on SERP pages. |[1](https://github.com/mozilla-mobile/fenix/pull/10167)||2020-09-01 | | browser.search.with_ads |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |Records counts of SERP pages with adverts displayed. The key format is ‘’. |[1](https://github.com/mozilla-mobile/fenix/pull/10112)||2020-09-01 |