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 18, 2020
1 parent ee62297 commit 3cff1ae
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 7 deletions.
11 changes: 11 additions & 0 deletions app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1827,6 +1827,17 @@ search_suggestions:
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/TODO
notification_emails:
- fenix-core@mozilla.com
expires: "2020-09-01"
open_in_new_tab:
type: event
description: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
1 change: 1 addition & 0 deletions docs/metrics.md
Original file line number Diff line number Diff line change
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/TODO)||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

0 comments on commit 3cff1ae

Please sign in to comment.