From 7220b32e91d7f0e3033e7f3f11cdb3e9a7198409 Mon Sep 17 00:00:00 2001 From: Sawyer Blatz Date: Mon, 18 May 2020 12:41:25 -0700 Subject: [PATCH] For #8125: Add default top site telemetry --- app/metrics.yaml | 17 ++++++++++++++++- .../components/metrics/GleanMetricsService.kt | 3 +++ .../mozilla/fenix/components/metrics/Metrics.kt | 1 + .../sessioncontrol/SessionControlController.kt | 7 ++++--- .../sessioncontrol/SessionControlInteractor.kt | 7 ++++--- .../topsites/TopSiteItemViewHolder.kt | 2 +- docs/metrics.md | 3 ++- 7 files changed, 31 insertions(+), 9 deletions(-) diff --git a/app/metrics.yaml b/app/metrics.yaml index 74f13b88d026..aba8a80e6642 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -325,7 +325,11 @@ metrics: type: counter lifetime: application description: | - A counter that indicates how many top sites a user has + A counter that indicates how many top sites a user has. This value will + only be set if the user has at least *one* top site. If they have 0, + this ping will not get sent, resulting in a null value. To disambiguate + between a failed `top_sites_count` ping and 0 top sites, please see + `has_top_sites`. send_in_pings: - metrics bugs: @@ -1841,6 +1845,17 @@ voice_search: expires: "2020-09-01" top_sites: + open_default: + type: event + description: | + A user opened a default top site + bugs: + - https://github.com/mozilla-mobile/fenix/issues/8125 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/10752 + notification_emails: + - fenix-core@mozilla.com + expires: "2020-09-01" open_in_new_tab: type: event description: | 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 8fd647de474f..bb3e09f11716 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 @@ -471,6 +471,9 @@ private val Event.wrapper: EventWrapper<*>? { Logins.saveLoginsSettingChanged.record(it) }, { Logins.saveLoginsSettingChangedKeys.valueOf(it) } ) + is Event.TopSiteOpenDefault -> EventWrapper( + { TopSites.openDefault.record(it) } + ) is Event.TopSiteOpenInNewTab -> EventWrapper( { TopSites.openInNewTab.record(it) } ) 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 7afc84be0e28..4b7d49839f2c 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 @@ -140,6 +140,7 @@ sealed class Event { object NotificationDownloadTryAgain : Event() object NotificationMediaPlay : Event() object NotificationMediaPause : Event() + object TopSiteOpenDefault : Event() object TopSiteOpenInNewTab : Event() object TopSiteOpenInPrivateTab : Event() object TopSiteRemoved : 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 0511f54e2b55..07cc39eaf28e 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 @@ -27,6 +27,7 @@ import org.mozilla.fenix.components.TabCollectionStorage import org.mozilla.fenix.components.TopSiteStorage import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.components.metrics.MetricController +import org.mozilla.fenix.components.tips.Tip import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.nav import org.mozilla.fenix.ext.sessionsOfType @@ -35,7 +36,6 @@ import org.mozilla.fenix.home.HomeFragmentAction import org.mozilla.fenix.home.HomeFragmentDirections import org.mozilla.fenix.home.HomeFragmentStore import org.mozilla.fenix.home.Tab -import org.mozilla.fenix.components.tips.Tip import org.mozilla.fenix.settings.SupportUtils import mozilla.components.feature.tab.collections.Tab as ComponentTab @@ -128,7 +128,7 @@ interface SessionControlController { /** * @see [TopSiteInteractor.onSelectTopSite] */ - fun handleSelectTopSite(url: String) + fun handleSelectTopSite(url: String, isDefault: Boolean) /** * @see [TabSessionInteractor.onShareTabs] @@ -344,9 +344,10 @@ class DefaultSessionControlController( activity.openToBrowser(BrowserDirection.FromHome) } - override fun handleSelectTopSite(url: String) { + override fun handleSelectTopSite(url: String, isDefault: Boolean) { invokePendingDeleteJobs() metrics.track(Event.TopSiteOpenInNewTab) + if (isDefault) { metrics.track(Event.TopSiteOpenDefault) } if (url == SupportUtils.POCKET_TRENDING_URL) { metrics.track(Event.PocketTopSiteClicked) } activity.components.useCases.tabsUseCases.addTab.invoke( url = url, diff --git a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlInteractor.kt b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlInteractor.kt index 1b52a3b378fb..83d051a554fb 100644 --- a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlInteractor.kt +++ b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlInteractor.kt @@ -201,8 +201,9 @@ interface TopSiteInteractor { * Selects the given top site. Called when a user clicks on a top site. * * @param url The URL of the top site. + * @param isDefault Whether or not the top site is a default one. */ - fun onSelectTopSite(url: String) + fun onSelectTopSite(url: String, isDefault: Boolean) } /** @@ -278,8 +279,8 @@ class SessionControlInteractor( controller.handleSelectTab(tabView, sessionId) } - override fun onSelectTopSite(url: String) { - controller.handleSelectTopSite(url) + override fun onSelectTopSite(url: String, isDefault: Boolean) { + controller.handleSelectTopSite(url, isDefault) } override fun onShareTabs() { diff --git a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/topsites/TopSiteItemViewHolder.kt b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/topsites/TopSiteItemViewHolder.kt index d765344518c8..d20dfcabf288 100644 --- a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/topsites/TopSiteItemViewHolder.kt +++ b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/topsites/TopSiteItemViewHolder.kt @@ -36,7 +36,7 @@ class TopSiteItemViewHolder( } top_site_item.setOnClickListener { - interactor.onSelectTopSite(topSite.url) + interactor.onSelectTopSite(topSite.url, topSite.isDefault) } top_site_item.setOnLongClickListener() { diff --git a/docs/metrics.md b/docs/metrics.md index 33d81d8321a7..ceeadf9fa3c8 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -169,6 +169,7 @@ The following metrics are added to the ping: | tip.displayed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The tip was displayed |[1](https://github.com/mozilla-mobile/fenix/pull/9836)|
  • identifier: The identifier of the tip displayed
|2020-09-01 | | tip.pressed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The tip's button was pressed |[1](https://github.com/mozilla-mobile/fenix/pull/9836)|
  • identifier: The identifier of the tip the action was taken on
|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_default |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened a default top site |[1](https://github.com/mozilla-mobile/fenix/pull/10752)||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 | @@ -233,7 +234,7 @@ The following metrics are added to the ping: | metrics.mozilla_products |[string_list](https://mozilla.github.io/glean/book/user/metrics/string_list.html) |A list of all the Mozilla products installed on device. We currently scan for: Firefox, Firefox Beta, Firefox Aurora, Firefox Nightly, Firefox Fdroid, Firefox Lite, Reference Browser, Reference Browser Debug, Fenix, Focus, and Lockwise. |[1](https://github.com/mozilla-mobile/fenix/pull/1953/), [2](https://github.com/mozilla-mobile/fenix/pull/5216)||2020-09-01 | | metrics.search_count |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |The labels for this counter are `.`. If the search engine is bundled with Fenix `search-engine-name` will be the name of the search engine. If it's a custom search engine (defined: https://github.com/mozilla-mobile/fenix/issues/1607) the value will be `custom`. `source` will be: `action`, `suggestion`, `widget` or `shortcut` (depending on the source from which the search started). Also added the `other` option for the source but it should never enter on this case. |[1](https://github.com/mozilla-mobile/fenix/pull/1677), [2](https://github.com/mozilla-mobile/fenix/pull/5216), [3](https://github.com/mozilla-mobile/fenix/pull/7310)||2020-09-01 | | metrics.toolbar_position |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |A string that indicates the new position of the toolbar TOP or BOTTOM |[1](https://github.com/mozilla-mobile/fenix/pull/6608)||2020-09-01 | -| metrics.top_sites_count |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |A counter that indicates how many top sites a user has |[1](https://github.com/mozilla-mobile/fenix/pull/9556)||2020-09-01 | +| metrics.top_sites_count |[counter](https://mozilla.github.io/glean/book/user/metrics/counter.html) |A counter that indicates how many top sites a user has. This value will only be set if the user has at least *one* top site. If they have 0, this ping will not get sent, resulting in a null value. To disambiguate between a failed `top_sites_count` ping and 0 top sites, please see `has_top_sites`. |[1](https://github.com/mozilla-mobile/fenix/pull/9556)||2020-09-01 | | perf.awesomebar.bookmark_suggestions |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |Duration of a bookmarks awesomebar suggestion query. |[1](https://github.com/mozilla-mobile/fenix/pull/10276#pullrequestreview-411101979)||2020-09-15 | | perf.awesomebar.clipboard_suggestions |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |Duration of a clipboard awesomebar suggestion query. |[1](https://github.com/mozilla-mobile/fenix/pull/10276#pullrequestreview-411101979)||2020-09-15 | | perf.awesomebar.history_suggestions |[timing_distribution](https://mozilla.github.io/glean/book/user/metrics/timing_distribution.html) |Duration of a history awesomebar suggestion query. |[1](https://github.com/mozilla-mobile/fenix/pull/10276#pullrequestreview-411101979)||2020-09-15 |