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

Commit

Permalink
Closes #18068: Use AwesomeBarFacts for AwesomeBar Telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
rocketsroger committed Feb 19, 2021
1 parent 6e0a648 commit cc129c9
Show file tree
Hide file tree
Showing 7 changed files with 194 additions and 0 deletions.
80 changes: 80 additions & 0 deletions app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4473,3 +4473,83 @@ engine:
- fenix-core@mozilla.com
- skaspari@mozilla.com
expires: "2021-12-31"

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/issues/18068
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/issues/18068
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/issues/18068
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/issues/18068
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/issues/18068
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/issues/18068
data_sensitivity:
- interaction
notification_emails:
- fenix-core@mozilla.com
expires: "2021-08-01"
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,13 @@ sealed class Event {
object HaveTopSites : Event()
object HaveNoTopSites : Event()

object BookmarkSuggestionClicked : Event()
object ClipboardSuggestionClicked : Event()
object HistorySuggestionClicked : Event()
object SearchActionClicked : Event()
object SearchSuggestionClicked : Event()
object OpenedTabSuggestionClicked : 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 @@ -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
Expand Down Expand Up @@ -750,6 +751,25 @@ private val Event.wrapper: EventWrapper<*>?
{ BannerOpenInApp.goToSettings.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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -267,6 +268,24 @@ internal class ReleaseMetricController(
}
null
}
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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -85,4 +86,31 @@ class GleanMetricsServiceTest {
assertEquals(1, events[0].extra!!.size)
assertEquals("APP_ICON", events[0].extra!!["source"])
}

@Test
fun `awesomebar events is 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())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,38 @@ class MetricControllerTest {

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

@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) }
}
}
6 changes: 6 additions & 0 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ The following metrics are added to the ping:
| app_theme.dark_theme_selected |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user selected Dark Theme |[1](https://github.com/mozilla-mobile/fenix/pull/7968), [2](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. |[1](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 |[1](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. |[1](https://github.com/mozilla-mobile/fenix/issues/18068)||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. |[1](https://github.com/mozilla-mobile/fenix/issues/18068)||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. |[1](https://github.com/mozilla-mobile/fenix/issues/18068)||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. |[1](https://github.com/mozilla-mobile/fenix/issues/18068)||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. |[1](https://github.com/mozilla-mobile/fenix/issues/18068)||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. |[1](https://github.com/mozilla-mobile/fenix/issues/18068)||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. |[1](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. |[1](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. |[1](https://github.com/mozilla-mobile/fenix/pull/17049)||2021-08-01 |2 |
Expand Down

0 comments on commit cc129c9

Please sign in to comment.