Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
For #8125: Add default top site telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
sblatz committed May 22, 2020
1 parent b2673bc commit 7220b32
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 9 deletions.
17 changes: 16 additions & 1 deletion app/metrics.yaml
Expand Up @@ -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:
Expand Down Expand Up @@ -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: |
Expand Down
Expand Up @@ -471,6 +471,9 @@ private val Event.wrapper: EventWrapper<*>?
{ Logins.saveLoginsSettingChanged.record(it) },
{ Logins.saveLoginsSettingChangedKeys.valueOf(it) }
)
is Event.TopSiteOpenDefault -> EventWrapper<NoExtraKeys>(
{ TopSites.openDefault.record(it) }
)
is Event.TopSiteOpenInNewTab -> EventWrapper<NoExtraKeys>(
{ TopSites.openInNewTab.record(it) }
)
Expand Down
Expand Up @@ -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()
Expand Down
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -128,7 +128,7 @@ interface SessionControlController {
/**
* @see [TopSiteInteractor.onSelectTopSite]
*/
fun handleSelectTopSite(url: String)
fun handleSelectTopSite(url: String, isDefault: Boolean)

/**
* @see [TabSessionInteractor.onShareTabs]
Expand Down Expand Up @@ -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,
Expand Down
Expand Up @@ -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)
}

/**
Expand Down Expand Up @@ -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() {
Expand Down
Expand Up @@ -36,7 +36,7 @@ class TopSiteItemViewHolder(
}

top_site_item.setOnClickListener {
interactor.onSelectTopSite(topSite.url)
interactor.onSelectTopSite(topSite.url, topSite.isDefault)
}

top_site_item.setOnLongClickListener() {
Expand Down
3 changes: 2 additions & 1 deletion docs/metrics.md
Expand Up @@ -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)|<ul><li>identifier: The identifier of the tip displayed</li></ul>|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)|<ul><li>identifier: The identifier of the tip the action was taken on</li></ul>|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)|<ul><li>position: A string that indicates the new position of the toolbar TOP or BOTTOM </li></ul>|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 |
Expand Down Expand Up @@ -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 `<search-engine-name>.<source>`. 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 |
Expand Down

0 comments on commit 7220b32

Please sign in to comment.