diff --git a/app/metrics.yaml b/app/metrics.yaml index 4670b97b3..362102e3a 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -4538,3 +4538,18 @@ engine_tab: - fenix-core@mozilla.com - skaspari@mozilla.com expires: "2021-12-31" + +synced_tabs: + synced_tabs_suggestion_clicked: + type: event + description: | + The synced tab suggestion in awesomebar was clicked. + bugs: + - https://github.com/mozilla-mobile/fenix/issues/18163 + data_reviews: + - https://github.com/mozilla-mobile/fenix/pull/18172 + data_sensitivity: + - interaction + notification_emails: + - fenix-core@mozilla.com + expires: "2021-08-01" diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt index c7e2431ea..bdbdfd819 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt @@ -214,6 +214,8 @@ sealed class Event { object HaveTopSites : Event() object HaveNoTopSites : Event() + object SyncedTabSuggestionClicked : Event() + // Interaction events with extras data class TopSiteSwipeCarousel(val page: Int) : Event() { 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 d122d34a7..3e3304b09 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 @@ -53,6 +53,7 @@ import org.mozilla.fenix.GleanMetrics.SearchSuggestions import org.mozilla.fenix.GleanMetrics.SearchWidget import org.mozilla.fenix.GleanMetrics.SyncAccount import org.mozilla.fenix.GleanMetrics.SyncAuth +import org.mozilla.fenix.GleanMetrics.SyncedTabs import org.mozilla.fenix.GleanMetrics.Tab import org.mozilla.fenix.GleanMetrics.Tabs import org.mozilla.fenix.GleanMetrics.TabsTray @@ -749,6 +750,9 @@ private val Event.wrapper: EventWrapper<*>? is Event.BannerOpenInAppGoToSettings -> EventWrapper( { BannerOpenInApp.goToSettings.record(it) } ) + is Event.SyncedTabSuggestionClicked -> EventWrapper( + { SyncedTabs.syncedTabsSuggestionClicked.record(it) } + ) // Don't record other events in Glean: is Event.AddBookmark -> null diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/MetricController.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/MetricController.kt index 013fd2422..19e220447 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/MetricController.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/MetricController.kt @@ -22,6 +22,7 @@ import mozilla.components.feature.findinpage.facts.FindInPageFacts import mozilla.components.feature.media.facts.MediaFacts import mozilla.components.feature.prompts.dialog.LoginDialogFacts import mozilla.components.feature.pwa.ProgressiveWebAppFacts +import mozilla.components.feature.syncedtabs.facts.SyncedTabsFacts import mozilla.components.feature.top.sites.facts.TopSitesFacts import mozilla.components.support.base.Component import mozilla.components.support.base.facts.Action @@ -267,6 +268,9 @@ internal class ReleaseMetricController( } null } + Component.FEATURE_SYNCEDTABS to SyncedTabsFacts.Items.SYNCED_TABS_SUGGESTION_CLICKED -> { + Event.SyncedTabSuggestionClicked + } else -> null } diff --git a/app/src/test/java/org/mozilla/fenix/components/metrics/GleanMetricsServiceTest.kt b/app/src/test/java/org/mozilla/fenix/components/metrics/GleanMetricsServiceTest.kt index 16e932db2..3317d9fcc 100644 --- a/app/src/test/java/org/mozilla/fenix/components/metrics/GleanMetricsServiceTest.kt +++ b/app/src/test/java/org/mozilla/fenix/components/metrics/GleanMetricsServiceTest.kt @@ -20,6 +20,7 @@ import org.junit.runner.RunWith import org.mozilla.fenix.GleanMetrics.Events import org.mozilla.fenix.GleanMetrics.Metrics import org.mozilla.fenix.GleanMetrics.SearchDefaultEngine +import org.mozilla.fenix.GleanMetrics.SyncedTabs import org.mozilla.fenix.helpers.FenixRobolectricTestRunner import org.mozilla.fenix.utils.BrowsersCache @@ -85,4 +86,11 @@ class GleanMetricsServiceTest { assertEquals(1, events[0].extra!!.size) assertEquals("APP_ICON", events[0].extra!!["source"]) } + + @Test + fun `synced tab events is correctly recorded`() { + assertFalse(SyncedTabs.syncedTabsSuggestionClicked.testHasValue()) + gleanService.track(Event.SyncedTabSuggestionClicked) + assertTrue(SyncedTabs.syncedTabsSuggestionClicked.testHasValue()) + } } diff --git a/app/src/test/java/org/mozilla/fenix/components/metrics/MetricControllerTest.kt b/app/src/test/java/org/mozilla/fenix/components/metrics/MetricControllerTest.kt index be97fd8a3..c4630c852 100644 --- a/app/src/test/java/org/mozilla/fenix/components/metrics/MetricControllerTest.kt +++ b/app/src/test/java/org/mozilla/fenix/components/metrics/MetricControllerTest.kt @@ -227,4 +227,18 @@ class MetricControllerTest { assertEquals(controller.factToEvent(fact), Event.HaveNoTopSites) } + + @Test + fun `tracking synced tab event should be sent to enabled service`() { + val controller = ReleaseMetricController( + listOf(marketingService1), + isDataTelemetryEnabled = { true }, + isMarketingDataTelemetryEnabled = { true } + ) + every { marketingService1.shouldTrack(Event.SyncedTabSuggestionClicked) } returns true + controller.start(MetricServiceType.Marketing) + + controller.track(Event.SyncedTabSuggestionClicked) + verify { marketingService1.track(Event.SyncedTabSuggestionClicked) } + } } diff --git a/docs/metrics.md b/docs/metrics.md index 0ecbf2827..9fa8c0844 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -201,6 +201,7 @@ In addition to those built-in metrics, the following metrics are added to the pi | sync_auth.sign_up |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |User registered a new Firefox Account, and was signed into it |[mozilla-mobile/fenix#4931](https://github.com/mozilla-mobile/fenix/pull/4931#issuecomment-529740300), [mozilla-mobile/fenix#15713](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |1, 2 | | sync_auth.use_email |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user chose to use their email to sign in instead of scanning a QR code, counterpart to "scan_pairing" |[mozilla-mobile/fenix#9835](https://github.com/mozilla-mobile/fenix/pull/9835#pullrequestreview-398641844), [mozilla-mobile/fenix#15713](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 | | sync_auth.use_email_problem |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user chose to use their email to sign in after an account problem |[mozilla-mobile/fenix#9835](https://github.com/mozilla-mobile/fenix/pull/9835#pullrequestreview-398641844), [mozilla-mobile/fenix#15713](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 | +| synced_tabs.synced_tabs_suggestion_clicked |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The synced tab suggestion in awesomebar was clicked. |[mozilla-mobile/fenix#18172](https://github.com/mozilla-mobile/fenix/pull/18172)||2021-08-01 |2 | | tab.media_pause |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the pause icon on a tab from the home screen |[mozilla-mobile/fenix#5266](https://github.com/mozilla-mobile/fenix/pull/5266), [mozilla-mobile/fenix#15713](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 | | tab.media_play |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the play icon on a tab from the home screen |[mozilla-mobile/fenix#5266](https://github.com/mozilla-mobile/fenix/pull/5266), [mozilla-mobile/fenix#15713](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 | | tabs.setting_opened |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The tab settings were opened. |[mozilla-mobile/fenix#15811](https://github.com/mozilla-mobile/fenix/pull/15811#issuecomment-706402952)||2021-08-01 |2 |