From 7595f28368b8eec6003f9b24d4be1ebc017a9db7 Mon Sep 17 00:00:00 2001 From: Gabriel Luong Date: Tue, 7 Jan 2020 15:06:27 -0500 Subject: [PATCH] For #7525 - Add telemetry for opening a top site in normal and private mode and removing a top site --- app/metrics.yaml | 37 ++++++++++++++++++- .../components/metrics/GleanMetricsService.kt | 10 +++++ .../fenix/components/metrics/Metrics.kt | 3 ++ .../SessionControlController.kt | 4 ++ docs/metrics.md | 3 ++ 5 files changed, 56 insertions(+), 1 deletion(-) diff --git a/app/metrics.yaml b/app/metrics.yaml index 5d1bef72f156..b13e3c6c6445 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -1669,4 +1669,39 @@ search_suggestions: - https://github.com/mozilla-mobile/fenix/pull/6746 notification_emails: - fenix-core@mozilla.com - expires: "2020-03-01" \ No newline at end of file + expires: "2020-03-01" + +top_sites: + open_in_new_tab: + type: event + description: > + A user opens a new tab based on a top site item + bugs: + - https://github.com/mozilla-mobile/fenix/issues/6757 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/7523 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + open_in_private_tab: + type: event + description: > + A user opens a new private tab based on a top site item + bugs: + - https://github.com/mozilla-mobile/fenix/issues/6757 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/7523 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" + remove: + type: event + description: > + A user removes a top site item + bugs: + - https://github.com/mozilla-mobile/fenix/issues/6757 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/7523 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-03-01" 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 3e330ad32535..40b3740997ec 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 @@ -42,6 +42,7 @@ import org.mozilla.fenix.GleanMetrics.SyncAccount import org.mozilla.fenix.GleanMetrics.SyncAuth import org.mozilla.fenix.GleanMetrics.Tab import org.mozilla.fenix.GleanMetrics.ToolbarSettings +import org.mozilla.fenix.GleanMetrics.TopSites import org.mozilla.fenix.GleanMetrics.TrackingProtection import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.settings @@ -454,6 +455,15 @@ private val Event.wrapper: EventWrapper<*>? { ToolbarSettings.changedPosition.record(it) }, { ToolbarSettings.changedPositionKeys.valueOf(it) } ) + is Event.TopSiteOpenInNewTab -> EventWrapper( + { TopSites.openInNewTab.record(it) } + ) + is Event.TopSiteOpenInPrivateTab -> EventWrapper( + { TopSites.openInPrivateTab.record(it) } + ) + is Event.TopSiteRemoved -> EventWrapper( + { TopSites.remove.record(it) } + ) // Don't record other events in Glean: is Event.AddBookmark -> null is Event.OpenedBookmark -> 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 4d209e016ae3..535c2608bc48 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 @@ -128,6 +128,9 @@ sealed class Event { object NotificationDownloadTryAgain : Event() object NotificationMediaPlay : Event() object NotificationMediaPause : Event() + object TopSiteOpenInNewTab : Event() + object TopSiteOpenInPrivateTab : Event() + object TopSiteRemoved : Event() object TrackingProtectionTrackerList : Event() object TrackingProtectionIconPressed : Event() object TrackingProtectionSettingsPanel : Event() diff --git a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlController.kt b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlController.kt index 497a187d76c4..d706bace11b7 100644 --- a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlController.kt +++ b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlController.kt @@ -260,6 +260,7 @@ class DefaultSessionControlController( } override fun handleOpenInPrivateTabClicked(topSite: TopSite) { + metrics.track(Event.TopSiteOpenInPrivateTab) with(activity) { browsingModeManager.mode = BrowsingMode.Private openToBrowserAndLoad( @@ -288,6 +289,8 @@ class DefaultSessionControlController( } override fun handleRemoveTopSiteClicked(topSite: TopSite) { + metrics.track(Event.TopSiteRemoved) + lifecycleScope.launch(Dispatchers.IO) { topSiteStorage.removeTopSite(topSite) } @@ -336,6 +339,7 @@ class DefaultSessionControlController( } override fun handleSelectTopSite(url: String) { + metrics.track(Event.TopSiteOpenInNewTab) activity.components.useCases.tabsUseCases.addTab.invoke(url, true, true) navController.nav( R.id.homeFragment, diff --git a/docs/metrics.md b/docs/metrics.md index 6038ed88d8e1..f257be46278c 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -150,6 +150,9 @@ The following metrics are added to the ping: | tab.media_pause |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the pause icon on a tab from the home screen |[1](https://github.com/mozilla-mobile/fenix/pull/5266)||2020-03-01 | | tab.media_play |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the play icon on a tab from the home screen |[1](https://github.com/mozilla-mobile/fenix/pull/5266)||2020-03-01 | | toolbar_settings.changed_position |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The user selected a new position for the toolbar |[1](https://github.com/mozilla-mobile/fenix/pull/6608)|
  • position: A string that indicates the new position of the toolbar TOP or BOTTOM
|2020-03-01 | +| top_sites.open_in_new_tab |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opens a new tab based on a top site item |[1](https://github.com/mozilla-mobile/fenix/pull/7523)||2020-03-01 | +| top_sites.open_in_private_tab |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opens a new private tab based on a top site item |[1](https://github.com/mozilla-mobile/fenix/pull/7523)||2020-03-01 | +| top_sites.remove |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user removes a top site item |[1](https://github.com/mozilla-mobile/fenix/pull/7523)||2020-03-01 | | tracking_protection.etp_setting_changed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user changed their tracking protection level setting to either strict or standard. |[1](https://github.com/mozilla-mobile/fenix/pull/5414#issuecomment-532847188)|
  • etp_setting: The new setting for ETP: strict, standard
|2020-03-01 | | tracking_protection.etp_settings |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened tracking protection settings through settings. |[1](https://github.com/mozilla-mobile/fenix/pull/5414#issuecomment-532847188)||2020-03-01 | | tracking_protection.etp_shield |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the tracking protection shield icon in toolbar. |[1](https://github.com/mozilla-mobile/fenix/pull/5414#issuecomment-532847188)||2020-03-01 |