From ea0f37307390c1b40e91689d1ba3ccd8fa64fdb3 Mon Sep 17 00:00:00 2001 From: mcarare Date: Wed, 25 Nov 2020 13:53:56 +0200 Subject: [PATCH 1/3] For #15366: Add documentation for recently closed tabs metrics. --- app/metrics.yaml | 15 ++++++++++++++- docs/metrics.md | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) 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/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)||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)||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)||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)||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)||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 | From cbf6b75a644a22fb9215d04a4e58c541c755aafa Mon Sep 17 00:00:00 2001 From: mcarare Date: Tue, 24 Nov 2020 18:44:56 +0200 Subject: [PATCH 2/3] For #15366: Add recently closed tabs metrics. --- .../main/java/org/mozilla/fenix/components/metrics/Event.kt | 2 ++ .../mozilla/fenix/components/metrics/GleanMetricsService.kt | 4 ++++ .../main/java/org/mozilla/fenix/tabtray/TabTrayController.kt | 1 + 3 files changed, 7 insertions(+) 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/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() { From 5fb214dc038526e68dc25381c74388a4a8318d80 Mon Sep 17 00:00:00 2001 From: mcarare Date: Wed, 25 Nov 2020 14:18:18 +0200 Subject: [PATCH 3/3] For #15366: Add recently closed tabs metrics from history fragment. --- .../org/mozilla/fenix/library/history/HistoryController.kt | 6 +++++- .../org/mozilla/fenix/library/history/HistoryFragment.kt | 5 +++-- .../mozilla/fenix/library/history/HistoryControllerTest.kt | 5 ++++- 3 files changed, 12 insertions(+), 4 deletions(-) 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/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