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

Closes #18163: Use SyncedTabsFacts for Synced Tab Telemetry #18172

Merged
merged 1 commit into from
Mar 8, 2021
Merged
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
15 changes: 15 additions & 0 deletions app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4538,3 +4538,18 @@ engine_tab:
- [email protected]
- [email protected]
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:
- [email protected]
expires: "2021-08-01"
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -749,6 +750,9 @@ private val Event.wrapper: EventWrapper<*>?
is Event.BannerOpenInAppGoToSettings -> EventWrapper<NoExtraKeys>(
{ BannerOpenInApp.goToSettings.record(it) }
)
is Event.SyncedTabSuggestionClicked -> EventWrapper<NoExtraKeys>(
{ SyncedTabs.syncedTabsSuggestionClicked.record(it) }
)

// Don't record other events in Glean:
is Event.AddBookmark -> null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -267,6 +268,9 @@ internal class ReleaseMetricController(
}
null
}
Component.FEATURE_SYNCEDTABS to SyncedTabsFacts.Items.SYNCED_TABS_SUGGESTION_CLICKED -> {
Event.SyncedTabSuggestionClicked
}
else -> null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -85,4 +86,11 @@ class GleanMetricsServiceTest {
assertEquals(1, events[0].extra!!.size)
assertEquals("APP_ICON", events[0].extra!!["source"])
}

@Test

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍 yay tests!

fun `synced tab events is correctly recorded`() {
assertFalse(SyncedTabs.syncedTabsSuggestionClicked.testHasValue())
gleanService.track(Event.SyncedTabSuggestionClicked)
assertTrue(SyncedTabs.syncedTabsSuggestionClicked.testHasValue())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,18 @@ class MetricControllerTest {

assertEquals(controller.factToEvent(fact), Event.HaveNoTopSites)
}

@Test
fun `tracking synced tab event should be sent to enabled service`() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍

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) }
}
}
1 change: 1 addition & 0 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down