From 9e3e95e35152d6d99eee167009db927594526567 Mon Sep 17 00:00:00 2001 From: person808 Date: Fri, 12 Jun 2020 12:28:38 -0700 Subject: [PATCH] For #11442 - Telemetry for tab counter menu. --- app/metrics.yaml | 18 ++++++++++++++++++ .../components/metrics/GleanMetricsService.kt | 4 ++++ .../fenix/components/metrics/Metrics.kt | 9 +++++++++ .../toolbar/TabCounterToolbarButton.kt | 6 ++++++ docs/metrics.md | 1 + 5 files changed, 38 insertions(+) diff --git a/app/metrics.yaml b/app/metrics.yaml index 68612c065..8d1485f44 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -186,6 +186,24 @@ events: notification_emails: - fenix-core@mozilla.com expires: "2020-09-01" + tab_counter_menu_action: + type: event + description: + A tab counter menu item was tapped + extra_keys: + item: + description: | + A string containing the name of the item the user tapped. These items + are: + + New tab, New private tab, Close tab + bugs: + - https://github.com/mozilla-mobile/fenix/issues/11442 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/11533 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-09-01" search_shortcuts: selected: 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 69384105e..1813991e2 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 @@ -548,6 +548,10 @@ private val Event.wrapper: EventWrapper<*>? is Event.SearchWidgetCFRAddWidgetPressed -> EventWrapper( { SearchWidgetCfr.addWidgetPressed.record(it) } ) + is Event.TabCounterMenuItemTapped -> EventWrapper( + { Events.tabCounterMenuAction.record(it) }, + { Events.tabCounterMenuActionKeys.valueOf(it) } + ) // Don't record other events in Glean: is Event.AddBookmark -> null 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 93f9f4ffc..744f93d99 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 @@ -431,6 +431,15 @@ sealed class Event { get() = mapOf(Events.browserMenuActionKeys.item to item.toString().toLowerCase(Locale.ROOT)) } + data class TabCounterMenuItemTapped(val item: Item) : Event() { + enum class Item { + NEW_TAB, NEW_PRIVATE_TAB, CLOSE_TAB + } + + override val extras: Map? + get() = mapOf(Events.tabCounterMenuActionKeys.item to item.toString().toLowerCase(Locale.ROOT)) + } + sealed class Search internal open val extras: Map<*, String>? diff --git a/app/src/main/java/org/mozilla/fenix/components/toolbar/TabCounterToolbarButton.kt b/app/src/main/java/org/mozilla/fenix/components/toolbar/TabCounterToolbarButton.kt index a9745894c..36baffd60 100644 --- a/app/src/main/java/org/mozilla/fenix/components/toolbar/TabCounterToolbarButton.kt +++ b/app/src/main/java/org/mozilla/fenix/components/toolbar/TabCounterToolbarButton.kt @@ -16,6 +16,8 @@ import mozilla.components.browser.session.Session import mozilla.components.browser.session.SessionManager import mozilla.components.concept.toolbar.Toolbar import org.mozilla.fenix.R +import org.mozilla.fenix.components.metrics.Event +import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.sessionsOfType import org.mozilla.fenix.theme.ThemeManager import java.lang.ref.WeakReference @@ -77,6 +79,7 @@ class TabCounterToolbarButton( private fun getTabContextMenu(context: Context): BrowserMenu { val primaryTextColor = ThemeManager.resolveAttribute(R.attr.primaryText, context) + val metrics = context.components.analytics.metrics val menuItems = listOf( BrowserMenuImageText( label = context.getString(R.string.close_tab), @@ -84,6 +87,7 @@ class TabCounterToolbarButton( iconTintColorResource = primaryTextColor, textColorResource = primaryTextColor ) { + metrics.track(Event.TabCounterMenuItemTapped(Event.TabCounterMenuItemTapped.Item.CLOSE_TAB)) onItemTapped(TabCounterMenuItem.CloseTab) }, BrowserMenuDivider(), @@ -93,6 +97,7 @@ class TabCounterToolbarButton( iconTintColorResource = primaryTextColor, textColorResource = primaryTextColor ) { + metrics.track(Event.TabCounterMenuItemTapped(Event.TabCounterMenuItemTapped.Item.NEW_TAB)) onItemTapped(TabCounterMenuItem.NewTab(false)) }, BrowserMenuImageText( @@ -101,6 +106,7 @@ class TabCounterToolbarButton( iconTintColorResource = primaryTextColor, textColorResource = primaryTextColor ) { + metrics.track(Event.TabCounterMenuItemTapped(Event.TabCounterMenuItemTapped.Item.NEW_PRIVATE_TAB)) onItemTapped(TabCounterMenuItem.NewTab(true)) } ) diff --git a/docs/metrics.md b/docs/metrics.md index aeddf0a5d..4634c84d0 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -102,6 +102,7 @@ The following metrics are added to the ping: | events.performed_search |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user performed a search |[1](https://github.com/mozilla-mobile/fenix/pull/1067#issuecomment-474598673), [2](https://github.com/mozilla-mobile/fenix/pull/1677)|
  • source: A string that tells us how the user performed the search. Possible values are: * default.action * default.suggestion * shortcut.action * shortcut.suggestion
|2020-09-01 | | events.preference_toggled |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user toggled a boolean preference in settings |[1](https://github.com/mozilla-mobile/fenix/pull/1896), [2](https://github.com/mozilla-mobile/fenix/pull/5704), [3](https://github.com/mozilla-mobile/fenix/pull/5886), [4](https://github.com/mozilla-mobile/fenix/pull/5975), [5](https://github.com/mozilla-mobile/fenix/pull/6352), [6](https://github.com/mozilla-mobile/fenix/pull/6601), [7](https://github.com/mozilla-mobile/fenix/pull/6746)|
  • enabled: Whether or not the preference is *now* enabled
  • preference_key: The preference key for the boolean (true/false) preference the user toggled. We currently track: show_search_suggestions, remote_debugging, telemetry, tracking_protection, search_bookmarks, search_browsing_history, show_clipboard_suggestions, show_search_shortcuts, open_links_in_a_private_tab (bug in implementation https://github.com/mozilla-mobile/fenix/issues/7384), pref_key_sync_logins, pref_key_sync_bookmarks, pref_key_sync_history, pref_key_show_voice_search, and pref_key_show_search_suggestions_in_private.
|2020-09-01 | | events.search_bar_tapped |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user tapped the search bar |[1](https://github.com/mozilla-mobile/fenix/pull/1067#issuecomment-474598673)|
  • source: The view the user was on when they initiated the search (For example: `Home` or `Browser`)
|2020-09-01 | +| events.tab_counter_menu_action |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A tab counter menu item was tapped |[1](https://github.com/mozilla-mobile/fenix/pull/11533)|
  • item: A string containing the name of the item the user tapped. These items are: New tab, New private tab, Close tab
|2020-09-01 | | events.whats_new_tapped |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened the "what's new" page button |[1](https://github.com/mozilla-mobile/fenix/pull/5090)||2020-09-01 | | find_in_page.closed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user closed the find in page UI |[1](https://github.com/mozilla-mobile/fenix/pull/1344#issuecomment-479285010)||2020-09-01 | | find_in_page.opened |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened the find in page UI |[1](https://github.com/mozilla-mobile/fenix/pull/1344#issuecomment-479285010)||2020-09-01 |