From f93e141d52b40ebc8f823d3de7aa2ee666247b55 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 | 35 +++++++++++++++++++ .../components/metrics/GleanMetricsService.kt | 10 ++++++ .../fenix/components/metrics/Metrics.kt | 3 ++ .../SessionControlController.kt | 4 +++ docs/metrics.md | 5 ++- 5 files changed, 56 insertions(+), 1 deletion(-) diff --git a/app/metrics.yaml b/app/metrics.yaml index ceacceaec..b025233e5 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -1667,3 +1667,38 @@ search_suggestions: notification_emails: - fenix-core@mozilla.com expires: "2020-09-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-09-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-09-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-09-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 5e94fd3f9..7183394db 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 @@ -39,6 +39,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.GleanMetrics.UserSpecifiedSearchEngines import org.mozilla.fenix.ext.components @@ -456,6 +457,15 @@ private val Event.wrapper: EventWrapper<*>? { Logins.saveLoginsSettingChanged.record(it) }, { Logins.saveLoginsSettingChangedKeys.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 1c0cfe002..28800a588 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 @@ -127,6 +127,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 497a187d7..d706bace1 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 87bf72cc7..b07b21ff0 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -80,7 +80,7 @@ The following metrics are added to the ping: | download_notification.try_again |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user tapped on try again when a download fails in the download notification |[1](https://github.com/mozilla-mobile/fenix/pull/6554)||2020-09-01 | | error_page.visited_error |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user encountered an error page |[1](https://github.com/mozilla-mobile/fenix/pull/2491#issuecomment-492414486)|
  • error_type: The error type of the error page encountered
|2020-09-01 | | events.app_opened |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened the app |[1](https://github.com/mozilla-mobile/fenix/pull/1067#issuecomment-474598673)|
  • source: The method used to open Fenix. Possible values are: `app_icon`, `custom_tab` or `link`
|2020-09-01 | -| events.browser_menu_action |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A browser menu item was tapped |[1](https://github.com/mozilla-mobile/fenix/pull/1214#issue-264756708), [2](https://github.com/mozilla-mobile/fenix/pull/5098#issuecomment-529658996), [3](https://github.com/mozilla-mobile/fenix/pull/6310)|
  • item: A string containing the name of the item the user tapped. These items include: Settings, Library, Help, Desktop Site toggle on/off, Find in Page, New Tab, Private Tab, Share, Report Site Issue, Back/Forward button, Reload Button, Quit, Reader Mode On, Reader Mode Off, Open In App
|2020-09-01 | +| events.browser_menu_action |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A browser menu item was tapped |[1](https://github.com/mozilla-mobile/fenix/pull/1214#issue-264756708), [2](https://github.com/mozilla-mobile/fenix/pull/5098#issuecomment-529658996), [3](https://github.com/mozilla-mobile/fenix/pull/6310)|
  • item: A string containing the name of the item the user tapped. These items include: Settings, Library, Help, Desktop Site toggle on/off, Find in Page, New Tab, Private Tab, Share, Report Site Issue, Back/Forward button, Reload Button, Quit, Reader Mode On, Reader Mode Off, Open In App, Add to Firefox Home
|2020-09-01 | | events.entered_url |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user entered a url |[1](https://github.com/mozilla-mobile/fenix/pull/1067#issuecomment-474598673)|
  • autocomplete: A boolean that tells us whether the URL was autofilled by an Autocomplete suggestion
|2020-09-01 | | 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)|
  • mode: The mode the link was opened in. Either 'PRIVATE' or 'NORMAL'
|2020-09-01 | | 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 | @@ -149,6 +149,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-09-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-09-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-09-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-09-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-09-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-09-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-09-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-09-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-09-01 |