diff --git a/app/metrics.yaml b/app/metrics.yaml index 23e9bbe18f8e..824039daacf5 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -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: | 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 485f4cc0b79a..2d69a43c4eb8 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 @@ -470,6 +470,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 875a9e736fe4..de60ede6635e 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 e008d2b34523..b3767897003d 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)||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)||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)||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 |