Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions mobile/android/fenix/app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9305,6 +9305,12 @@ top_sites:
type: event
description: |
A user opened a default top site
extra_keys:
source: &top_sites_source
type: string
description: |
The surface where the top site interaction occurred.
One of "homepage" or "shortcuts_library".
bugs:
- https://github.com/mozilla-mobile/fenix/issues/8125
data_reviews:
Expand All @@ -9325,6 +9331,8 @@ top_sites:
type: event
description: |
A user opened the google top site
extra_keys:
source: *top_sites_source
bugs:
- https://github.com/mozilla-mobile/fenix/issues/17418
data_reviews:
Expand Down Expand Up @@ -9365,6 +9373,8 @@ top_sites:
type: event
description: |
A user opened a frecency top site
extra_keys:
source: *top_sites_source
bugs:
- https://github.com/mozilla-mobile/fenix/issues/14565
data_reviews:
Expand All @@ -9385,6 +9395,8 @@ top_sites:
type: event
description: |
A user opened a pinned top site
extra_keys:
source: *top_sites_source
bugs:
- https://github.com/mozilla-mobile/fenix/issues/14565
data_reviews:
Expand Down Expand Up @@ -9436,6 +9448,7 @@ top_sites:
description: |
The type of top site. Options are: "FRECENCY", "DEFAULT",
"PINNED", or "PROVIDED"
source: *top_sites_source
bugs:
- https://github.com/mozilla-mobile/fenix/issues/14565
- https://github.com/mozilla-mobile/fenix/issues/23526
Expand All @@ -9458,6 +9471,8 @@ top_sites:
type: event
description: |
A user opens a new tab based on a top site item
extra_keys:
source: *top_sites_source
bugs:
- https://github.com/mozilla-mobile/fenix/issues/6757
data_reviews:
Expand All @@ -9478,6 +9493,8 @@ top_sites:
type: event
description: |
A user opens a new private tab based on a top site item
extra_keys:
source: *top_sites_source
bugs:
- https://github.com/mozilla-mobile/fenix/issues/6757
data_reviews:
Expand All @@ -9498,6 +9515,8 @@ top_sites:
type: event
description: |
A user removes a top site item
extra_keys:
source: *top_sites_source
bugs:
- https://github.com/mozilla-mobile/fenix/issues/6757
data_reviews:
Expand All @@ -9518,6 +9537,8 @@ top_sites:
type: event
description: |
A user removed the default Google top site
extra_keys:
source: *top_sites_source
bugs:
- https://github.com/mozilla-mobile/fenix/issues/21841
data_reviews:
Expand Down Expand Up @@ -9550,6 +9571,8 @@ top_sites:
type: event
description: |
A user has opened a contile top site.
extra_keys:
source: *top_sites_source
bugs:
- https://github.com/mozilla-mobile/fenix/issues/23526
data_reviews:
Expand All @@ -9566,6 +9589,8 @@ top_sites:
description: |
A user has opened a contile top site in a private tab via the long
press context menu.
extra_keys:
source: *top_sites_source
bugs:
- https://github.com/mozilla-mobile/fenix/issues/23526
data_reviews:
Expand All @@ -9582,6 +9607,8 @@ top_sites:
description: |
A user has selected "Settings" via the contile top sites
longpress context menu.
extra_keys:
source: *top_sites_source
bugs:
- https://github.com/mozilla-mobile/fenix/issues/23526
data_reviews:
Expand All @@ -9598,6 +9625,8 @@ top_sites:
description: |
A user has selected "Our sponsors & your privacy" via the
contile top sites longpress context menu.
extra_keys:
source: *top_sites_source
bugs:
- https://github.com/mozilla-mobile/fenix/issues/23526
data_reviews:
Expand Down Expand Up @@ -9702,7 +9731,9 @@ top_sites:
A user saw a Contile top site
extra_keys:
source:
description: The source of the event, example "newtab", "urlbar"
description: |
The surface where the Contile top site was shown.
One of "homepage" or "shortcuts_library".
type: string
position:
description: The tile placement (1-based)
Expand All @@ -9729,7 +9760,9 @@ top_sites:
A user clicked a Contile top site
extra_keys:
source:
description: The source of the event, example "newtab", "urlbar"
description: |
The surface where the Contile top site was clicked.
One of "homepage" or "shortcuts_library".
Comment thread
devotaaabel marked this conversation as resolved.
type: string
position:
description: The tile placement (1-based)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ import org.mozilla.fenix.home.toolbar.HomeToolbarComposable.Companion.DirectToSe
import org.mozilla.fenix.home.topsites.DefaultTopSitesView
import org.mozilla.fenix.home.topsites.TopSitesBinding
import org.mozilla.fenix.home.topsites.controller.DefaultTopSiteController
import org.mozilla.fenix.home.topsites.controller.TopSitesSource
import org.mozilla.fenix.home.topsites.getTopSitesConfig
import org.mozilla.fenix.home.ui.Homepage
import org.mozilla.fenix.home.ui.WallpaperBackground
Expand Down Expand Up @@ -1335,6 +1336,7 @@ class HomeFragment : Fragment() {
topSitesUseCases = requireComponents.useCases.topSitesUseCase,
mozAdsUseCases = requireComponents.useCases.mozAdsUseCases,
viewLifecycleScope = viewLifecycleOwner.lifecycleScope,
source = TopSitesSource.HOMEPAGE,
)

private fun initController() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import org.mozilla.fenix.e2e.SystemInsetsPaddedFragment
import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.home.topsites.controller.DefaultTopSiteController
import org.mozilla.fenix.home.topsites.controller.TopSiteController
import org.mozilla.fenix.home.topsites.controller.TopSitesSource
import org.mozilla.fenix.home.topsites.interactor.DefaultTopSiteInteractor
import org.mozilla.fenix.home.topsites.interactor.TopSiteInteractor
import org.mozilla.fenix.home.topsites.middleware.ShortcutsMiddleware
Expand Down Expand Up @@ -69,6 +70,7 @@ class ShortcutsFragment : Fragment(), SystemInsetsPaddedFragment {
topSitesUseCases = requireComponents.useCases.topSitesUseCase,
mozAdsUseCases = requireComponents.useCases.mozAdsUseCases,
viewLifecycleScope = viewLifecycleOwner.lifecycleScope,
source = TopSitesSource.SHORTCUTS_LIBRARY,
)

interactor = DefaultTopSiteInteractor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ import java.lang.ref.WeakReference
import androidx.appcompat.R as appcompatR
import mozilla.components.ui.icons.R as iconsR

/**
* The surface where a top sites / shortcuts interaction occurred. Used as the `source` extra on
* the `top_sites` Glean events.
*/
enum class TopSitesSource(val sourceName: String) {
HOMEPAGE("homepage"),
SHORTCUTS_LIBRARY("shortcuts_library"),
}

/**
* An interface that handles the view manipulation of the top sites triggered by the Interactor.
*/
Expand Down Expand Up @@ -127,6 +136,7 @@ class DefaultTopSiteController(
private val topSitesUseCases: TopSitesUseCases,
private val mozAdsUseCases: MozAdsUseCases,
private val viewLifecycleScope: CoroutineScope,
private val source: TopSitesSource,
) : TopSiteController {

private val activity: Activity
Expand All @@ -137,9 +147,13 @@ class DefaultTopSiteController(

override fun handleOpenInPrivateTabClicked(topSite: TopSite) {
if (topSite is TopSite.Provided) {
TopSites.openContileInPrivateTab.record(NoExtras())
TopSites.openContileInPrivateTab.record(
TopSites.OpenContileInPrivateTabExtra(source = source.sourceName),
)
} else {
TopSites.openInPrivateTab.record(NoExtras())
TopSites.openInPrivateTab.record(
TopSites.OpenInPrivateTabExtra(source = source.sourceName),
)
}

activity.components.appStore.dispatch(
Expand Down Expand Up @@ -235,10 +249,12 @@ class DefaultTopSiteController(
}

override fun handleRemoveTopSiteClicked(topSite: TopSite) {
TopSites.remove.record(NoExtras())
TopSites.remove.record(TopSites.RemoveExtra(source = source.sourceName))

when (topSite.url) {
SupportUtils.GOOGLE_URL -> TopSites.googleTopSiteRemoved.record(NoExtras())
SupportUtils.GOOGLE_URL -> TopSites.googleTopSiteRemoved.record(
TopSites.GoogleTopSiteRemovedExtra(source = source.sourceName),
)
}

viewLifecycleScope.launch {
Expand All @@ -250,20 +266,30 @@ class DefaultTopSiteController(

override fun handleSelectTopSite(topSite: TopSite, position: Int) {
when (topSite) {
is TopSite.Default -> TopSites.openDefault.record(NoExtras())
is TopSite.Frecent -> TopSites.openFrecency.record(NoExtras())
is TopSite.Pinned -> TopSites.openPinned.record(NoExtras())
is TopSite.Default -> TopSites.openDefault.record(
TopSites.OpenDefaultExtra(source = source.sourceName),
)
is TopSite.Frecent -> TopSites.openFrecency.record(
TopSites.OpenFrecencyExtra(source = source.sourceName),
)
is TopSite.Pinned -> TopSites.openPinned.record(
TopSites.OpenPinnedExtra(source = source.sourceName),
)
is TopSite.Provided -> {
sendMozAdsClickInteraction(clickUrl = topSite.clickUrl)

TopSites.openContileTopSite.record(NoExtras()).also {
TopSites.openContileTopSite.record(
TopSites.OpenContileTopSiteExtra(source = source.sourceName),
).also {
recordTopSitesClickTelemetry(topSite, position)
}
}
}

when (topSite.url) {
SupportUtils.GOOGLE_URL -> TopSites.openGoogleSearchAttribution.record(NoExtras())
SupportUtils.GOOGLE_URL -> TopSites.openGoogleSearchAttribution.record(
TopSites.OpenGoogleSearchAttributionExtra(source = source.sourceName),
)
}

val availableEngines: List<SearchEngine> = getAvailableSearchEngines()
Expand Down Expand Up @@ -296,7 +322,9 @@ class DefaultTopSiteController(
}

if (existingTabForUrl == null) {
TopSites.openInNewTab.record(NoExtras())
TopSites.openInNewTab.record(
TopSites.OpenInNewTabExtra(source = source.sourceName),
)

addTabUseCase.invoke(
url = appendSearchAttributionToUrlIfNeeded(topSite.url),
Expand All @@ -320,7 +348,7 @@ class DefaultTopSiteController(
TopSites.contileClick.record(
TopSites.ContileClickExtra(
position = position + 1,
source = "newtab",
source = source.sourceName,
),
)

Expand All @@ -336,7 +364,7 @@ class DefaultTopSiteController(
TopSites.contileImpression.record(
TopSites.ContileImpressionExtra(
position = position + 1,
source = "newtab",
source = source.sourceName,
),
)

Expand All @@ -359,12 +387,16 @@ class DefaultTopSiteController(
}

override fun handleTopSiteSettingsClicked() {
TopSites.contileSettings.record(NoExtras())
TopSites.contileSettings.record(
TopSites.ContileSettingsExtra(source = source.sourceName),
)
navController.navigate(R.id.homeSettingsFragment)
}

override fun handleSponsorPrivacyClicked() {
TopSites.contileSponsorsAndPrivacy.record(NoExtras())
TopSites.contileSponsorsAndPrivacy.record(
TopSites.ContileSponsorsAndPrivacyExtra(source = source.sourceName),
)

if (navController.currentDestination?.id == R.id.shortcutsFragment) {
navController.navigate(ShortcutsFragmentDirections.actionShortcutsFragmentToBrowserFragment())
Expand All @@ -380,7 +412,9 @@ class DefaultTopSiteController(
}

override fun handleTopSiteLongClicked(topSite: TopSite) {
TopSites.longPress.record(TopSites.LongPressExtra(topSite.type))
TopSites.longPress.record(
TopSites.LongPressExtra(type = topSite.type, source = source.sourceName),
)
}

override fun handleShowAllTopSitesClicked() {
Expand Down
Loading