Closes #18173: Add Telemetry When User Opens a Bookmark (#18174)

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

@ -1545,6 +1545,19 @@ search.default_engine:
expires: "2021-08-01"
bookmarks_management:
open:
type: event
description: |
A user opened a bookmark.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/18173
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/18174
data_sensitivity:
- interaction
notification_emails:
- fenix-core@mozilla.com
expires: "2022-08-01"
open_in_new_tab:
type: event
description: |

@ -191,6 +191,9 @@ private val Event.wrapper: EventWrapper<*>?
{ Events.browserMenuAction.record(it) },
{ Events.browserMenuActionKeys.valueOf(it) }
)
is Event.OpenedBookmark -> EventWrapper<NoExtraKeys>(
{ BookmarksManagement.open.record(it) }
)
is Event.OpenedBookmarkInNewTab -> EventWrapper<NoExtraKeys>(
{ BookmarksManagement.openInNewTab.record(it) }
)
@ -776,7 +779,6 @@ private val Event.wrapper: EventWrapper<*>?
// Don't record other events in Glean:
is Event.AddBookmark -> null
is Event.OpenedBookmark -> null
is Event.OpenedAppFirstRun -> null
is Event.InteractWithSearchURLArea -> null
is Event.ClearedPrivateData -> null

@ -18,6 +18,7 @@ import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.GleanMetrics.Awesomebar
import org.mozilla.fenix.GleanMetrics.BookmarksManagement
import org.mozilla.fenix.GleanMetrics.Events
import org.mozilla.fenix.GleanMetrics.Metrics
import org.mozilla.fenix.GleanMetrics.SearchDefaultEngine
@ -121,4 +122,59 @@ class GleanMetricsServiceTest {
gleanService.track(Event.OpenedTabSuggestionClicked)
assertTrue(Awesomebar.openedTabSuggestionClicked.testHasValue())
}
@Test
fun `bookmark events is correctly recorded`() {
assertFalse(BookmarksManagement.open.testHasValue())
gleanService.track(Event.OpenedBookmark)
assertTrue(BookmarksManagement.open.testHasValue())
assertFalse(BookmarksManagement.openInNewTab.testHasValue())
gleanService.track(Event.OpenedBookmarkInNewTab)
assertTrue(BookmarksManagement.openInNewTab.testHasValue())
assertFalse(BookmarksManagement.openInNewTabs.testHasValue())
gleanService.track(Event.OpenedBookmarksInNewTabs)
assertTrue(BookmarksManagement.openInNewTabs.testHasValue())
assertFalse(BookmarksManagement.openInPrivateTab.testHasValue())
gleanService.track(Event.OpenedBookmarkInPrivateTab)
assertTrue(BookmarksManagement.openInPrivateTab.testHasValue())
assertFalse(BookmarksManagement.openInPrivateTabs.testHasValue())
gleanService.track(Event.OpenedBookmarksInPrivateTabs)
assertTrue(BookmarksManagement.openInPrivateTabs.testHasValue())
assertFalse(BookmarksManagement.edited.testHasValue())
gleanService.track(Event.EditedBookmark)
assertTrue(BookmarksManagement.edited.testHasValue())
assertFalse(BookmarksManagement.moved.testHasValue())
gleanService.track(Event.MovedBookmark)
assertTrue(BookmarksManagement.moved.testHasValue())
assertFalse(BookmarksManagement.removed.testHasValue())
gleanService.track(Event.RemoveBookmark)
assertTrue(BookmarksManagement.removed.testHasValue())
assertFalse(BookmarksManagement.multiRemoved.testHasValue())
gleanService.track(Event.RemoveBookmarks)
assertTrue(BookmarksManagement.multiRemoved.testHasValue())
assertFalse(BookmarksManagement.shared.testHasValue())
gleanService.track(Event.ShareBookmark)
assertTrue(BookmarksManagement.shared.testHasValue())
assertFalse(BookmarksManagement.copied.testHasValue())
gleanService.track(Event.CopyBookmark)
assertTrue(BookmarksManagement.copied.testHasValue())
assertFalse(BookmarksManagement.folderAdd.testHasValue())
gleanService.track(Event.AddBookmarkFolder)
assertTrue(BookmarksManagement.folderAdd.testHasValue())
assertFalse(BookmarksManagement.folderRemove.testHasValue())
gleanService.track(Event.RemoveBookmarkFolder)
assertTrue(BookmarksManagement.folderRemove.testHasValue())
}
}

@ -275,4 +275,59 @@ class MetricControllerTest {
controller.track(Event.OpenedTabSuggestionClicked)
verify { marketingService1.track(Event.OpenedTabSuggestionClicked) }
}
@Test
fun `tracking bookmark events should be sent to enabled service`() {
val controller = ReleaseMetricController(
listOf(marketingService1),
isDataTelemetryEnabled = { true },
isMarketingDataTelemetryEnabled = { true }
)
every { marketingService1.shouldTrack(Event.AddBookmark) } returns true
every { marketingService1.shouldTrack(Event.RemoveBookmark) } returns true
every { marketingService1.shouldTrack(Event.OpenedBookmark) } returns true
every { marketingService1.shouldTrack(Event.OpenedBookmarkInNewTab) } returns true
every { marketingService1.shouldTrack(Event.OpenedBookmarksInNewTabs) } returns true
every { marketingService1.shouldTrack(Event.OpenedBookmarkInPrivateTab) } returns true
every { marketingService1.shouldTrack(Event.OpenedBookmarksInPrivateTabs) } returns true
every { marketingService1.shouldTrack(Event.EditedBookmark) } returns true
every { marketingService1.shouldTrack(Event.MovedBookmark) } returns true
every { marketingService1.shouldTrack(Event.ShareBookmark) } returns true
every { marketingService1.shouldTrack(Event.CopyBookmark) } returns true
every { marketingService1.shouldTrack(Event.AddBookmarkFolder) } returns true
every { marketingService1.shouldTrack(Event.RemoveBookmarkFolder) } returns true
every { marketingService1.shouldTrack(Event.RemoveBookmarks) } returns true
controller.start(MetricServiceType.Marketing)
controller.track(Event.AddBookmark)
controller.track(Event.RemoveBookmark)
controller.track(Event.OpenedBookmark)
controller.track(Event.OpenedBookmarkInNewTab)
controller.track(Event.OpenedBookmarksInNewTabs)
controller.track(Event.OpenedBookmarkInPrivateTab)
controller.track(Event.OpenedBookmarksInPrivateTabs)
controller.track(Event.EditedBookmark)
controller.track(Event.MovedBookmark)
controller.track(Event.ShareBookmark)
controller.track(Event.CopyBookmark)
controller.track(Event.AddBookmarkFolder)
controller.track(Event.RemoveBookmarkFolder)
controller.track(Event.RemoveBookmarks)
verify { marketingService1.track(Event.AddBookmark) }
verify { marketingService1.track(Event.RemoveBookmark) }
verify { marketingService1.track(Event.OpenedBookmark) }
verify { marketingService1.track(Event.OpenedBookmarkInNewTab) }
verify { marketingService1.track(Event.OpenedBookmarksInNewTabs) }
verify { marketingService1.track(Event.OpenedBookmarkInPrivateTab) }
verify { marketingService1.track(Event.OpenedBookmarksInPrivateTabs) }
verify { marketingService1.track(Event.EditedBookmark) }
verify { marketingService1.track(Event.MovedBookmark) }
verify { marketingService1.track(Event.ShareBookmark) }
verify { marketingService1.track(Event.CopyBookmark) }
verify { marketingService1.track(Event.AddBookmarkFolder) }
verify { marketingService1.track(Event.RemoveBookmarkFolder) }
verify { marketingService1.track(Event.RemoveBookmarks) }
}
}

@ -74,6 +74,7 @@ In addition to those built-in metrics, the following metrics are added to the pi
| bookmarks_management.folder_remove |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user removed a bookmark folder. |[mozilla-mobile/fenix#3724](https://github.com/mozilla-mobile/fenix/pull/3724), [mozilla-mobile/fenix#13958](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877)||2021-04-01 |2 |
| bookmarks_management.moved |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user moved an existing bookmark or folder to another folder. |[mozilla-mobile/fenix#1708](https://github.com/mozilla-mobile/fenix/pull/1708), [mozilla-mobile/fenix#13958](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877)||2021-04-01 |2 |
| bookmarks_management.multi_removed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user removed multiple bookmarks at once. |[mozilla-mobile/fenix#1708](https://github.com/mozilla-mobile/fenix/pull/1708), [mozilla-mobile/fenix#13958](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877)||2021-04-01 |2 |
| bookmarks_management.open |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened a bookmark. |[mozilla-mobile/fenix#18174](https://github.com/mozilla-mobile/fenix/pull/18174)||2022-08-01 |2 |
| bookmarks_management.open_in_new_tab |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened a bookmark in a new tab. |[mozilla-mobile/fenix#1708](https://github.com/mozilla-mobile/fenix/pull/1708), [mozilla-mobile/fenix#13958](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877)||2021-04-01 |2 |
| bookmarks_management.open_in_new_tabs |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened multiple bookmarks at once in new tabs. |[mozilla-mobile/fenix#1708](https://github.com/mozilla-mobile/fenix/pull/1708), [mozilla-mobile/fenix#13958](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877)||2021-04-01 |2 |
| bookmarks_management.open_in_private_tab |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened a bookmark in a new private tab. |[mozilla-mobile/fenix#1708](https://github.com/mozilla-mobile/fenix/pull/1708), [mozilla-mobile/fenix#13958](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877)||2021-04-01 |2 |

Loading…
Cancel
Save