Closes #18068: Use AwesomeBarFacts for AwesomeBar Telemetry (#18090)

upstream-sync
Roger Yang 3 years ago committed by GitHub
parent aada459428
commit 2322cbdd0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4553,3 +4553,83 @@ synced_tabs:
notification_emails:
- fenix-core@mozilla.com
expires: "2021-08-01"
awesomebar:
bookmark_suggestion_clicked:
type: event
description: |
The bookmark suggestion in awesomebar was clicked.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/18068
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/18090
data_sensitivity:
- interaction
notification_emails:
- fenix-core@mozilla.com
expires: "2021-08-01"
clipboard_suggestion_clicked:
type: event
description: |
The clipboard suggestion in awesomebar was clicked.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/18068
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/18090
data_sensitivity:
- interaction
notification_emails:
- fenix-core@mozilla.com
expires: "2021-08-01"
history_suggestion_clicked:
type: event
description: |
The history suggestion in awesomebar was clicked.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/18068
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/18090
data_sensitivity:
- interaction
notification_emails:
- fenix-core@mozilla.com
expires: "2021-08-01"
search_action_clicked:
type: event
description: |
The search action in awesomebar was clicked.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/18068
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/18090
data_sensitivity:
- interaction
notification_emails:
- fenix-core@mozilla.com
expires: "2021-08-01"
search_suggestion_clicked:
type: event
description: |
The search suggestion in awesomebar was clicked.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/18068
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/18090
data_sensitivity:
- interaction
notification_emails:
- fenix-core@mozilla.com
expires: "2021-08-01"
opened_tab_suggestion_clicked:
type: event
description: |
The opened tab suggestion in awesomebar was clicked.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/18068
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/18090
data_sensitivity:
- interaction
notification_emails:
- fenix-core@mozilla.com
expires: "2021-08-01"

@ -215,6 +215,12 @@ sealed class Event {
object HaveNoTopSites : Event()
object SyncedTabSuggestionClicked : Event()
object BookmarkSuggestionClicked : Event()
object ClipboardSuggestionClicked : Event()
object HistorySuggestionClicked : Event()
object SearchActionClicked : Event()
object SearchSuggestionClicked : Event()
object OpenedTabSuggestionClicked : Event()
// Interaction events with extras

@ -17,6 +17,7 @@ import org.mozilla.fenix.GleanMetrics.AboutPage
import org.mozilla.fenix.GleanMetrics.Addons
import org.mozilla.fenix.GleanMetrics.AppTheme
import org.mozilla.fenix.GleanMetrics.Autoplay
import org.mozilla.fenix.GleanMetrics.Awesomebar
import org.mozilla.fenix.GleanMetrics.BannerOpenInApp
import org.mozilla.fenix.GleanMetrics.BookmarksManagement
import org.mozilla.fenix.GleanMetrics.BrowserSearch
@ -754,6 +755,25 @@ private val Event.wrapper: EventWrapper<*>?
{ SyncedTabs.syncedTabsSuggestionClicked.record(it) }
)
is Event.BookmarkSuggestionClicked -> EventWrapper<NoExtraKeys>(
{ Awesomebar.bookmarkSuggestionClicked.record(it) }
)
is Event.ClipboardSuggestionClicked -> EventWrapper<NoExtraKeys>(
{ Awesomebar.clipboardSuggestionClicked.record(it) }
)
is Event.HistorySuggestionClicked -> EventWrapper<NoExtraKeys>(
{ Awesomebar.historySuggestionClicked.record(it) }
)
is Event.SearchActionClicked -> EventWrapper<NoExtraKeys>(
{ Awesomebar.searchActionClicked.record(it) }
)
is Event.SearchSuggestionClicked -> EventWrapper<NoExtraKeys>(
{ Awesomebar.searchSuggestionClicked.record(it) }
)
is Event.OpenedTabSuggestionClicked -> EventWrapper<NoExtraKeys>(
{ Awesomebar.openedTabSuggestionClicked.record(it) }
)
// Don't record other events in Glean:
is Event.AddBookmark -> null
is Event.OpenedBookmark -> null

@ -10,6 +10,7 @@ import mozilla.components.browser.awesomebar.facts.BrowserAwesomeBarFacts
import mozilla.components.browser.menu.facts.BrowserMenuFacts
import mozilla.components.browser.toolbar.facts.ToolbarFacts
import mozilla.components.concept.awesomebar.AwesomeBar
import mozilla.components.feature.awesomebar.facts.AwesomeBarFacts
import mozilla.components.feature.awesomebar.provider.BookmarksStorageSuggestionProvider
import mozilla.components.feature.awesomebar.provider.ClipboardSuggestionProvider
import mozilla.components.feature.awesomebar.provider.HistoryStorageSuggestionProvider
@ -271,6 +272,24 @@ internal class ReleaseMetricController(
Component.FEATURE_SYNCEDTABS to SyncedTabsFacts.Items.SYNCED_TABS_SUGGESTION_CLICKED -> {
Event.SyncedTabSuggestionClicked
}
Component.FEATURE_AWESOMEBAR to AwesomeBarFacts.Items.BOOKMARK_SUGGESTION_CLICKED -> {
Event.BookmarkSuggestionClicked
}
Component.FEATURE_AWESOMEBAR to AwesomeBarFacts.Items.CLIPBOARD_SUGGESTION_CLICKED -> {
Event.ClipboardSuggestionClicked
}
Component.FEATURE_AWESOMEBAR to AwesomeBarFacts.Items.HISTORY_SUGGESTION_CLICKED -> {
Event.HistorySuggestionClicked
}
Component.FEATURE_AWESOMEBAR to AwesomeBarFacts.Items.SEARCH_ACTION_CLICKED -> {
Event.SearchActionClicked
}
Component.FEATURE_AWESOMEBAR to AwesomeBarFacts.Items.SEARCH_SUGGESTION_CLICKED -> {
Event.SearchSuggestionClicked
}
Component.FEATURE_AWESOMEBAR to AwesomeBarFacts.Items.OPENED_TAB_SUGGESTION_CLICKED -> {
Event.OpenedTabSuggestionClicked
}
else -> null
}

@ -17,6 +17,7 @@ import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.GleanMetrics.Awesomebar
import org.mozilla.fenix.GleanMetrics.Events
import org.mozilla.fenix.GleanMetrics.Metrics
import org.mozilla.fenix.GleanMetrics.SearchDefaultEngine
@ -88,9 +89,36 @@ class GleanMetricsServiceTest {
}
@Test
fun `synced tab events is correctly recorded`() {
fun `synced tab event is correctly recorded`() {
assertFalse(SyncedTabs.syncedTabsSuggestionClicked.testHasValue())
gleanService.track(Event.SyncedTabSuggestionClicked)
assertTrue(SyncedTabs.syncedTabsSuggestionClicked.testHasValue())
}
@Test
fun `awesomebar events are correctly recorded`() {
assertFalse(Awesomebar.bookmarkSuggestionClicked.testHasValue())
gleanService.track(Event.BookmarkSuggestionClicked)
assertTrue(Awesomebar.bookmarkSuggestionClicked.testHasValue())
assertFalse(Awesomebar.clipboardSuggestionClicked.testHasValue())
gleanService.track(Event.ClipboardSuggestionClicked)
assertTrue(Awesomebar.clipboardSuggestionClicked.testHasValue())
assertFalse(Awesomebar.historySuggestionClicked.testHasValue())
gleanService.track(Event.HistorySuggestionClicked)
assertTrue(Awesomebar.historySuggestionClicked.testHasValue())
assertFalse(Awesomebar.searchActionClicked.testHasValue())
gleanService.track(Event.SearchActionClicked)
assertTrue(Awesomebar.searchActionClicked.testHasValue())
assertFalse(Awesomebar.searchSuggestionClicked.testHasValue())
gleanService.track(Event.SearchSuggestionClicked)
assertTrue(Awesomebar.searchSuggestionClicked.testHasValue())
assertFalse(Awesomebar.openedTabSuggestionClicked.testHasValue())
gleanService.track(Event.OpenedTabSuggestionClicked)
assertTrue(Awesomebar.openedTabSuggestionClicked.testHasValue())
}
}

@ -241,4 +241,38 @@ class MetricControllerTest {
controller.track(Event.SyncedTabSuggestionClicked)
verify { marketingService1.track(Event.SyncedTabSuggestionClicked) }
}
@Test
fun `tracking awesomebar events should be sent to enabled service`() {
val controller = ReleaseMetricController(
listOf(marketingService1),
isDataTelemetryEnabled = { true },
isMarketingDataTelemetryEnabled = { true }
)
every { marketingService1.shouldTrack(Event.BookmarkSuggestionClicked) } returns true
every { marketingService1.shouldTrack(Event.ClipboardSuggestionClicked) } returns true
every { marketingService1.shouldTrack(Event.HistorySuggestionClicked) } returns true
every { marketingService1.shouldTrack(Event.SearchActionClicked) } returns true
every { marketingService1.shouldTrack(Event.SearchSuggestionClicked) } returns true
every { marketingService1.shouldTrack(Event.OpenedTabSuggestionClicked) } returns true
controller.start(MetricServiceType.Marketing)
controller.track(Event.BookmarkSuggestionClicked)
verify { marketingService1.track(Event.BookmarkSuggestionClicked) }
controller.track(Event.ClipboardSuggestionClicked)
verify { marketingService1.track(Event.ClipboardSuggestionClicked) }
controller.track(Event.HistorySuggestionClicked)
verify { marketingService1.track(Event.HistorySuggestionClicked) }
controller.track(Event.SearchActionClicked)
verify { marketingService1.track(Event.SearchActionClicked) }
controller.track(Event.SearchSuggestionClicked)
verify { marketingService1.track(Event.SearchSuggestionClicked) }
controller.track(Event.OpenedTabSuggestionClicked)
verify { marketingService1.track(Event.OpenedTabSuggestionClicked) }
}
}

@ -59,6 +59,12 @@ In addition to those built-in metrics, the following metrics are added to the pi
| app_theme.dark_theme_selected |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user selected Dark Theme |[mozilla-mobile/fenix#7968](https://github.com/mozilla-mobile/fenix/pull/7968), [mozilla-mobile/fenix#13958](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877)|<ul><li>source: The source from where dark theme was selected. The source can be 'SETTINGS' or 'ONBOARDING' </li></ul>|2021-04-01 |2 |
| autoplay.setting_changed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user changed their autoplay setting to either block_cellular, block_audio, or block_all. |[mozilla-mobile/fenix#13041](https://github.com/mozilla-mobile/fenix/pull/13041#issuecomment-665777411)|<ul><li>autoplay_setting: The new setting for autoplay: block_cellular, block_audio, or block_all. </li></ul>|2021-08-01 |2 |
| autoplay.visited_setting |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user visited the autoplay settings screen |[mozilla-mobile/fenix#13041](https://github.com/mozilla-mobile/fenix/pull/13041#issuecomment-665777411)||2021-08-01 |2 |
| awesomebar.bookmark_suggestion_clicked |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The bookmark suggestion in awesomebar was clicked. |[mozilla-mobile/fenix#18090](https://github.com/mozilla-mobile/fenix/pull/18090)||2021-08-01 |2 |
| awesomebar.clipboard_suggestion_clicked |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The clipboard suggestion in awesomebar was clicked. |[mozilla-mobile/fenix#18090](https://github.com/mozilla-mobile/fenix/pull/18090)||2021-08-01 |2 |
| awesomebar.history_suggestion_clicked |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The history suggestion in awesomebar was clicked. |[mozilla-mobile/fenix#18090](https://github.com/mozilla-mobile/fenix/pull/18090)||2021-08-01 |2 |
| awesomebar.opened_tab_suggestion_clicked |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The opened tab suggestion in awesomebar was clicked. |[mozilla-mobile/fenix#18090](https://github.com/mozilla-mobile/fenix/pull/18090)||2021-08-01 |2 |
| awesomebar.search_action_clicked |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The search action in awesomebar was clicked. |[mozilla-mobile/fenix#18090](https://github.com/mozilla-mobile/fenix/pull/18090)||2021-08-01 |2 |
| awesomebar.search_suggestion_clicked |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The search suggestion in awesomebar was clicked. |[mozilla-mobile/fenix#18090](https://github.com/mozilla-mobile/fenix/pull/18090)||2021-08-01 |2 |
| banner_open_in_app.dismissed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |User tapped 'dismiss' on Open in App banner. |[mozilla-mobile/fenix#17049](https://github.com/mozilla-mobile/fenix/pull/17049)||2021-08-01 |2 |
| banner_open_in_app.displayed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |Open in App banner was shown. |[mozilla-mobile/fenix#17049](https://github.com/mozilla-mobile/fenix/pull/17049)||2021-08-01 |2 |
| banner_open_in_app.go_to_settings |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |User tapped 'go to settings' on Open in App banner. |[mozilla-mobile/fenix#17049](https://github.com/mozilla-mobile/fenix/pull/17049)||2021-08-01 |2 |

Loading…
Cancel
Save