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

Commit

Permalink
For #7525 - Add telemetry for opening a top site in normal and privat…
Browse files Browse the repository at this point in the history
…e mode and removing a top site
  • Loading branch information
gabrielluong committed Jan 21, 2020
1 parent 44f3654 commit b0842c2
Show file tree
Hide file tree
Showing 5 changed files with 185 additions and 130 deletions.
35 changes: 35 additions & 0 deletions app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1653,3 +1653,38 @@ search_suggestions:
notification_emails:
- [email protected]
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:
- [email protected]
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:
- [email protected]
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:
- [email protected]
expires: "2020-09-01"
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -452,6 +453,15 @@ private val Event.wrapper: EventWrapper<*>?
is Event.CustomEngineDeleted -> EventWrapper<NoExtraKeys>(
{ UserSpecifiedSearchEngines.customEngineDeleted.record(it) }
)
is Event.TopSiteOpenInNewTab -> EventWrapper<NoExtraKeys>(
{ TopSites.openInNewTab.record(it) }
)
is Event.TopSiteOpenInPrivateTab -> EventWrapper<NoExtraKeys>(
{ TopSites.openInPrivateTab.record(it) }
)
is Event.TopSiteRemoved -> EventWrapper<NoExtraKeys>(
{ TopSites.remove.record(it) }
)
// Don't record other events in Glean:
is Event.AddBookmark -> null
is Event.OpenedBookmark -> null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ class DefaultSessionControlController(
}

override fun handleOpenInPrivateTabClicked(topSite: TopSite) {
metrics.track(Event.TopSiteOpenInPrivateTab)
with(activity) {
browsingModeManager.mode = BrowsingMode.Private
openToBrowserAndLoad(
Expand Down Expand Up @@ -288,6 +289,8 @@ class DefaultSessionControlController(
}

override fun handleRemoveTopSiteClicked(topSite: TopSite) {
metrics.track(Event.TopSiteRemoved)

lifecycleScope.launch(Dispatchers.IO) {
topSiteStorage.removeTopSite(topSite)
}
Expand Down Expand Up @@ -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,
Expand Down
Loading

0 comments on commit b0842c2

Please sign in to comment.