diff --git a/app/metrics.yaml b/app/metrics.yaml index bad326aba5ea..a5c93c1ae535 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -331,7 +331,20 @@ events: notification_emails: - fenix-core@mozilla.com expires: "2021-04-01" - + recently_closed_tabs_opened: + type: event + description: | + An event that indicates that the user + has accessed recently closed tabs list. + bugs: + - https://github.com/mozilla-mobile/fenix/issues/15366 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/16739 + data_sensitivity: + - interaction + notification_emails: + - fenix-core@mozilla.com + expires: "2021-05-10" onboarding: fxa_auto_signin: type: event diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt index 87d10a519ac6..8c68ff9324c4 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt @@ -183,6 +183,8 @@ sealed class Event { object TabSettingsOpened : Event() + object RecentlyClosedTabsOpened : Event() + // Interaction events with extras data class TopSiteSwipeCarousel(val page: Int) : Event() { 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 82e462d7bb57..63af84e9d6f3 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 @@ -659,6 +659,10 @@ private val Event.wrapper: EventWrapper<*>? { ProgressiveWebApp.backgroundKeys.valueOf(it) } ) + is Event.RecentlyClosedTabsOpened -> EventWrapper( + { Events.recentlyClosedTabsOpened.record(it) } + ) + Event.MasterPasswordMigrationDisplayed -> EventWrapper( { MasterPassword.displayed.record(it) } ) diff --git a/app/src/main/java/org/mozilla/fenix/library/history/HistoryController.kt b/app/src/main/java/org/mozilla/fenix/library/history/HistoryController.kt index 069afb1df86e..96ef57698c82 100644 --- a/app/src/main/java/org/mozilla/fenix/library/history/HistoryController.kt +++ b/app/src/main/java/org/mozilla/fenix/library/history/HistoryController.kt @@ -15,6 +15,8 @@ import mozilla.components.concept.engine.prompt.ShareData import org.mozilla.fenix.R import org.mozilla.fenix.browser.browsingmode.BrowsingMode import org.mozilla.fenix.components.FenixSnackbar +import org.mozilla.fenix.components.metrics.Event +import org.mozilla.fenix.components.metrics.MetricController @Suppress("TooManyFunctions") interface HistoryController { @@ -43,7 +45,8 @@ class DefaultHistoryController( private val displayDeleteAll: () -> Unit, private val invalidateOptionsMenu: () -> Unit, private val deleteHistoryItems: (Set) -> Unit, - private val syncHistory: suspend () -> Unit + private val syncHistory: suspend () -> Unit, + private val metrics: MetricController ) : HistoryController { override fun handleOpen(item: HistoryItem, mode: BrowsingMode?) { openToBrowser(item, mode) @@ -111,5 +114,6 @@ class DefaultHistoryController( HistoryFragmentDirections.actionGlobalRecentlyClosed(), NavOptions.Builder().setPopUpTo(R.id.recentlyClosedFragment, true).build() ) + metrics.track(Event.RecentlyClosedTabsOpened) } } diff --git a/app/src/main/java/org/mozilla/fenix/library/history/HistoryFragment.kt b/app/src/main/java/org/mozilla/fenix/library/history/HistoryFragment.kt index 7f2d49db6ec7..26ebe09eb3ab 100644 --- a/app/src/main/java/org/mozilla/fenix/library/history/HistoryFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/library/history/HistoryFragment.kt @@ -92,8 +92,9 @@ class HistoryFragment : LibraryPageFragment(), UserInteractionHandl ::displayDeleteAllDialog, ::invalidateOptionsMenu, ::deleteHistoryItems, - ::syncHistory - ) + ::syncHistory, + requireComponents.analytics.metrics + ) historyInteractor = HistoryInteractor( historyController ) diff --git a/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayController.kt b/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayController.kt index bb3a4f56b464..f6e4ce768410 100644 --- a/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayController.kt +++ b/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayController.kt @@ -250,6 +250,7 @@ class DefaultTabTrayController( override fun handleRecentlyClosedClicked() { val directions = TabTrayDialogFragmentDirections.actionGlobalRecentlyClosed() navController.navigate(directions) + metrics.track(Event.RecentlyClosedTabsOpened) } override fun handleGoToTabsSettingClicked() { diff --git a/app/src/test/java/org/mozilla/fenix/library/history/HistoryControllerTest.kt b/app/src/test/java/org/mozilla/fenix/library/history/HistoryControllerTest.kt index ea6f427cf87f..601c8cc41f76 100644 --- a/app/src/test/java/org/mozilla/fenix/library/history/HistoryControllerTest.kt +++ b/app/src/test/java/org/mozilla/fenix/library/history/HistoryControllerTest.kt @@ -25,6 +25,7 @@ import org.junit.Test import org.junit.runner.RunWith import org.mozilla.fenix.browser.browsingmode.BrowsingMode import org.mozilla.fenix.components.FenixSnackbar +import org.mozilla.fenix.components.metrics.MetricController import org.mozilla.fenix.ext.directionsEq import org.mozilla.fenix.helpers.FenixRobolectricTestRunner @@ -45,6 +46,7 @@ class HistoryControllerTest { private val invalidateOptionsMenu: () -> Unit = mockk(relaxed = true) private val deleteHistoryItems: (Set) -> Unit = mockk(relaxed = true) private val syncHistory: suspend () -> Unit = mockk(relaxed = true) + private val metrics: MetricController = mockk(relaxed = true) private val controller = DefaultHistoryController( store, navController, @@ -56,7 +58,8 @@ class HistoryControllerTest { displayDeleteAll, invalidateOptionsMenu, deleteHistoryItems, - syncHistory + syncHistory, + metrics ) @Before diff --git a/docs/metrics.md b/docs/metrics.md index 2efab09a079c..41e1194c5870 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -106,6 +106,7 @@ The following metrics are added to the ping: | events.opened_link |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened a link with Fenix |[1](https://github.com/mozilla-mobile/fenix/pull/5975), [2](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877)|
  • mode: The mode the link was opened in. Either 'PRIVATE' or 'NORMAL'. N.B.: this probe may be incorrectly implemented: see https://github.com/mozilla-mobile/fenix/issues/14133
|2021-04-01 |2 | | 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), [3](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877)|
  • source: A string that tells us how the user performed the search. Possible values are: * default.action * default.suggestion * shortcut.action * shortcut.suggestion
|2021-04-01 |2 | | 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), [8](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877)|
  • 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.
|2021-06-01 |1, 2 | +| events.recently_closed_tabs_opened |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |An event that indicates that the user has accessed recently closed tabs list. |[1](https://github.com/mozilla-mobile/fenix/pull/16739)||2021-05-10 |2 | | 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), [2](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877)|
  • source: The view the user was on when they initiated the search (For example: `Home` or `Browser`)
|2021-04-01 |2 | | 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), [2](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877)|
  • item: A string containing the name of the item the user tapped. These items are: New tab, New private tab, Close tab
|2021-04-01 |2 | | 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), [2](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877)||2021-04-01 |2 |