Skip to content

Commit a512416

Browse files
committed
Bug 1996675 - Add homepage/shortcuts_library source to top sites telemetry. r=gl
1 parent e9c70d0 commit a512416

5 files changed

Lines changed: 335 additions & 64 deletions

File tree

mobile/android/fenix/app/metrics.yaml

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9241,6 +9241,12 @@ top_sites:
92419241
type: event
92429242
description: |
92439243
A user opened a default top site
9244+
extra_keys:
9245+
source: &top_sites_source
9246+
type: string
9247+
description: |
9248+
The surface where the top site interaction occurred.
9249+
One of "homepage" or "shortcuts_library".
92449250
bugs:
92459251
- https://github.com/mozilla-mobile/fenix/issues/8125
92469252
data_reviews:
@@ -9261,6 +9267,8 @@ top_sites:
92619267
type: event
92629268
description: |
92639269
A user opened the google top site
9270+
extra_keys:
9271+
source: *top_sites_source
92649272
bugs:
92659273
- https://github.com/mozilla-mobile/fenix/issues/17418
92669274
data_reviews:
@@ -9301,6 +9309,8 @@ top_sites:
93019309
type: event
93029310
description: |
93039311
A user opened a frecency top site
9312+
extra_keys:
9313+
source: *top_sites_source
93049314
bugs:
93059315
- https://github.com/mozilla-mobile/fenix/issues/14565
93069316
data_reviews:
@@ -9321,6 +9331,8 @@ top_sites:
93219331
type: event
93229332
description: |
93239333
A user opened a pinned top site
9334+
extra_keys:
9335+
source: *top_sites_source
93249336
bugs:
93259337
- https://github.com/mozilla-mobile/fenix/issues/14565
93269338
data_reviews:
@@ -9372,6 +9384,7 @@ top_sites:
93729384
description: |
93739385
The type of top site. Options are: "FRECENCY", "DEFAULT",
93749386
"PINNED", or "PROVIDED"
9387+
source: *top_sites_source
93759388
bugs:
93769389
- https://github.com/mozilla-mobile/fenix/issues/14565
93779390
- https://github.com/mozilla-mobile/fenix/issues/23526
@@ -9394,6 +9407,8 @@ top_sites:
93949407
type: event
93959408
description: |
93969409
A user opens a new tab based on a top site item
9410+
extra_keys:
9411+
source: *top_sites_source
93979412
bugs:
93989413
- https://github.com/mozilla-mobile/fenix/issues/6757
93999414
data_reviews:
@@ -9414,6 +9429,8 @@ top_sites:
94149429
type: event
94159430
description: |
94169431
A user opens a new private tab based on a top site item
9432+
extra_keys:
9433+
source: *top_sites_source
94179434
bugs:
94189435
- https://github.com/mozilla-mobile/fenix/issues/6757
94199436
data_reviews:
@@ -9434,6 +9451,8 @@ top_sites:
94349451
type: event
94359452
description: |
94369453
A user removes a top site item
9454+
extra_keys:
9455+
source: *top_sites_source
94379456
bugs:
94389457
- https://github.com/mozilla-mobile/fenix/issues/6757
94399458
data_reviews:
@@ -9454,6 +9473,8 @@ top_sites:
94549473
type: event
94559474
description: |
94569475
A user removed the default Google top site
9476+
extra_keys:
9477+
source: *top_sites_source
94579478
bugs:
94589479
- https://github.com/mozilla-mobile/fenix/issues/21841
94599480
data_reviews:
@@ -9486,6 +9507,8 @@ top_sites:
94869507
type: event
94879508
description: |
94889509
A user has opened a contile top site.
9510+
extra_keys:
9511+
source: *top_sites_source
94899512
bugs:
94909513
- https://github.com/mozilla-mobile/fenix/issues/23526
94919514
data_reviews:
@@ -9502,6 +9525,8 @@ top_sites:
95029525
description: |
95039526
A user has opened a contile top site in a private tab via the long
95049527
press context menu.
9528+
extra_keys:
9529+
source: *top_sites_source
95059530
bugs:
95069531
- https://github.com/mozilla-mobile/fenix/issues/23526
95079532
data_reviews:
@@ -9518,6 +9543,8 @@ top_sites:
95189543
description: |
95199544
A user has selected "Settings" via the contile top sites
95209545
longpress context menu.
9546+
extra_keys:
9547+
source: *top_sites_source
95219548
bugs:
95229549
- https://github.com/mozilla-mobile/fenix/issues/23526
95239550
data_reviews:
@@ -9534,6 +9561,8 @@ top_sites:
95349561
description: |
95359562
A user has selected "Our sponsors & your privacy" via the
95369563
contile top sites longpress context menu.
9564+
extra_keys:
9565+
source: *top_sites_source
95379566
bugs:
95389567
- https://github.com/mozilla-mobile/fenix/issues/23526
95399568
data_reviews:
@@ -9638,7 +9667,9 @@ top_sites:
96389667
A user saw a Contile top site
96399668
extra_keys:
96409669
source:
9641-
description: The source of the event, example "newtab", "urlbar"
9670+
description: |
9671+
The surface where the Contile top site was shown.
9672+
One of "homepage" or "shortcuts_library".
96429673
type: string
96439674
position:
96449675
description: The tile placement (1-based)
@@ -9665,7 +9696,9 @@ top_sites:
96659696
A user clicked a Contile top site
96669697
extra_keys:
96679698
source:
9668-
description: The source of the event, example "newtab", "urlbar"
9699+
description: |
9700+
The surface where the Contile top site was clicked.
9701+
One of "homepage" or "shortcuts_library".
96699702
type: string
96709703
position:
96719704
description: The tile placement (1-based)

mobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ import org.mozilla.fenix.home.toolbar.HomeToolbarComposable.Companion.DirectToSe
139139
import org.mozilla.fenix.home.topsites.DefaultTopSitesView
140140
import org.mozilla.fenix.home.topsites.TopSitesBinding
141141
import org.mozilla.fenix.home.topsites.controller.DefaultTopSiteController
142+
import org.mozilla.fenix.home.topsites.controller.TopSitesSource
142143
import org.mozilla.fenix.home.topsites.getTopSitesConfig
143144
import org.mozilla.fenix.home.ui.Homepage
144145
import org.mozilla.fenix.home.ui.WallpaperBackground
@@ -1335,6 +1336,7 @@ class HomeFragment : Fragment() {
13351336
topSitesUseCases = requireComponents.useCases.topSitesUseCase,
13361337
mozAdsUseCases = requireComponents.useCases.mozAdsUseCases,
13371338
viewLifecycleScope = viewLifecycleOwner.lifecycleScope,
1339+
source = TopSitesSource.HOMEPAGE,
13381340
)
13391341

13401342
private fun initController() {

mobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/topsites/ShortcutsFragment.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import org.mozilla.fenix.e2e.SystemInsetsPaddedFragment
1919
import org.mozilla.fenix.ext.requireComponents
2020
import org.mozilla.fenix.home.topsites.controller.DefaultTopSiteController
2121
import org.mozilla.fenix.home.topsites.controller.TopSiteController
22+
import org.mozilla.fenix.home.topsites.controller.TopSitesSource
2223
import org.mozilla.fenix.home.topsites.interactor.DefaultTopSiteInteractor
2324
import org.mozilla.fenix.home.topsites.interactor.TopSiteInteractor
2425
import org.mozilla.fenix.home.topsites.middleware.ShortcutsMiddleware
@@ -69,6 +70,7 @@ class ShortcutsFragment : Fragment(), SystemInsetsPaddedFragment {
6970
topSitesUseCases = requireComponents.useCases.topSitesUseCase,
7071
mozAdsUseCases = requireComponents.useCases.mozAdsUseCases,
7172
viewLifecycleScope = viewLifecycleOwner.lifecycleScope,
73+
source = TopSitesSource.SHORTCUTS_LIBRARY,
7274
)
7375

7476
interactor = DefaultTopSiteInteractor(

mobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/topsites/controller/TopSiteController.kt

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ import java.lang.ref.WeakReference
5252
import androidx.appcompat.R as appcompatR
5353
import mozilla.components.ui.icons.R as iconsR
5454

55+
/**
56+
* The surface where a top sites / shortcuts interaction occurred. Used as the `source` extra on
57+
* the `top_sites` Glean events.
58+
*/
59+
enum class TopSitesSource(val sourceName: String) {
60+
HOMEPAGE("homepage"),
61+
SHORTCUTS_LIBRARY("shortcuts_library"),
62+
}
63+
5564
/**
5665
* An interface that handles the view manipulation of the top sites triggered by the Interactor.
5766
*/
@@ -127,6 +136,7 @@ class DefaultTopSiteController(
127136
private val topSitesUseCases: TopSitesUseCases,
128137
private val mozAdsUseCases: MozAdsUseCases,
129138
private val viewLifecycleScope: CoroutineScope,
139+
private val source: TopSitesSource,
130140
) : TopSiteController {
131141

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

138148
override fun handleOpenInPrivateTabClicked(topSite: TopSite) {
139149
if (topSite is TopSite.Provided) {
140-
TopSites.openContileInPrivateTab.record(NoExtras())
150+
TopSites.openContileInPrivateTab.record(
151+
TopSites.OpenContileInPrivateTabExtra(source = source.sourceName),
152+
)
141153
} else {
142-
TopSites.openInPrivateTab.record(NoExtras())
154+
TopSites.openInPrivateTab.record(
155+
TopSites.OpenInPrivateTabExtra(source = source.sourceName),
156+
)
143157
}
144158

145159
activity.components.appStore.dispatch(
@@ -235,10 +249,12 @@ class DefaultTopSiteController(
235249
}
236250

237251
override fun handleRemoveTopSiteClicked(topSite: TopSite) {
238-
TopSites.remove.record(NoExtras())
252+
TopSites.remove.record(TopSites.RemoveExtra(source = source.sourceName))
239253

240254
when (topSite.url) {
241-
SupportUtils.GOOGLE_URL -> TopSites.googleTopSiteRemoved.record(NoExtras())
255+
SupportUtils.GOOGLE_URL -> TopSites.googleTopSiteRemoved.record(
256+
TopSites.GoogleTopSiteRemovedExtra(source = source.sourceName),
257+
)
242258
}
243259

244260
viewLifecycleScope.launch {
@@ -250,20 +266,30 @@ class DefaultTopSiteController(
250266

251267
override fun handleSelectTopSite(topSite: TopSite, position: Int) {
252268
when (topSite) {
253-
is TopSite.Default -> TopSites.openDefault.record(NoExtras())
254-
is TopSite.Frecent -> TopSites.openFrecency.record(NoExtras())
255-
is TopSite.Pinned -> TopSites.openPinned.record(NoExtras())
269+
is TopSite.Default -> TopSites.openDefault.record(
270+
TopSites.OpenDefaultExtra(source = source.sourceName),
271+
)
272+
is TopSite.Frecent -> TopSites.openFrecency.record(
273+
TopSites.OpenFrecencyExtra(source = source.sourceName),
274+
)
275+
is TopSite.Pinned -> TopSites.openPinned.record(
276+
TopSites.OpenPinnedExtra(source = source.sourceName),
277+
)
256278
is TopSite.Provided -> {
257279
sendMozAdsClickInteraction(clickUrl = topSite.clickUrl)
258280

259-
TopSites.openContileTopSite.record(NoExtras()).also {
281+
TopSites.openContileTopSite.record(
282+
TopSites.OpenContileTopSiteExtra(source = source.sourceName),
283+
).also {
260284
recordTopSitesClickTelemetry(topSite, position)
261285
}
262286
}
263287
}
264288

265289
when (topSite.url) {
266-
SupportUtils.GOOGLE_URL -> TopSites.openGoogleSearchAttribution.record(NoExtras())
290+
SupportUtils.GOOGLE_URL -> TopSites.openGoogleSearchAttribution.record(
291+
TopSites.OpenGoogleSearchAttributionExtra(source = source.sourceName),
292+
)
267293
}
268294

269295
val availableEngines: List<SearchEngine> = getAvailableSearchEngines()
@@ -296,7 +322,9 @@ class DefaultTopSiteController(
296322
}
297323

298324
if (existingTabForUrl == null) {
299-
TopSites.openInNewTab.record(NoExtras())
325+
TopSites.openInNewTab.record(
326+
TopSites.OpenInNewTabExtra(source = source.sourceName),
327+
)
300328

301329
addTabUseCase.invoke(
302330
url = appendSearchAttributionToUrlIfNeeded(topSite.url),
@@ -320,7 +348,7 @@ class DefaultTopSiteController(
320348
TopSites.contileClick.record(
321349
TopSites.ContileClickExtra(
322350
position = position + 1,
323-
source = "newtab",
351+
source = source.sourceName,
324352
),
325353
)
326354

@@ -336,7 +364,7 @@ class DefaultTopSiteController(
336364
TopSites.contileImpression.record(
337365
TopSites.ContileImpressionExtra(
338366
position = position + 1,
339-
source = "newtab",
367+
source = source.sourceName,
340368
),
341369
)
342370

@@ -359,12 +387,16 @@ class DefaultTopSiteController(
359387
}
360388

361389
override fun handleTopSiteSettingsClicked() {
362-
TopSites.contileSettings.record(NoExtras())
390+
TopSites.contileSettings.record(
391+
TopSites.ContileSettingsExtra(source = source.sourceName),
392+
)
363393
navController.navigate(R.id.homeSettingsFragment)
364394
}
365395

366396
override fun handleSponsorPrivacyClicked() {
367-
TopSites.contileSponsorsAndPrivacy.record(NoExtras())
397+
TopSites.contileSponsorsAndPrivacy.record(
398+
TopSites.ContileSponsorsAndPrivacyExtra(source = source.sourceName),
399+
)
368400

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

382414
override fun handleTopSiteLongClicked(topSite: TopSite) {
383-
TopSites.longPress.record(TopSites.LongPressExtra(topSite.type))
415+
TopSites.longPress.record(
416+
TopSites.LongPressExtra(type = topSite.type, source = source.sourceName),
417+
)
384418
}
385419

386420
override fun handleShowAllTopSitesClicked() {

0 commit comments

Comments
 (0)