Closes #18178: Rework History Telemetry (#18261)

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

@ -2117,15 +2117,66 @@ history:
description: |
A user opened a history item
bugs:
- https://github.com/mozilla-mobile/fenix/issues/2362
- https://github.com/mozilla-mobile/fenix/issues/18178
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/3940
- https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068
- https://github.com/mozilla-mobile/fenix/pull/18261
data_sensitivity:
- interaction
notification_emails:
- fenix-core@mozilla.com
expires: "2021-08-01"
expires: "2022-08-01"
opened_item_in_new_tab:
type: event
description: |
A user opened a history item in a new tab
bugs:
- https://github.com/mozilla-mobile/fenix/issues/18178
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/18261
data_sensitivity:
- interaction
notification_emails:
- fenix-core@mozilla.com
expires: "2022-08-01"
opened_items_in_new_tabs:
type: event
description: |
A user opened multiple history items in new tabs
bugs:
- https://github.com/mozilla-mobile/fenix/issues/18178
data_reviews:
- https://gith ub.com/mozilla-mobile/fenix/pull/18261
data_sensitivity:
- interaction
notification_emails:
- fenix-core@mozilla.com
expires: "2022-08-01"
opened_item_in_private_tab:
type: event
description: |
A user opened a history item in a private tab
bugs:
- https://github.com/mozilla-mobile/fenix/issues/18178
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/18261
data_sensitivity:
- interaction
notification_emails:
- fenix-core@mozilla.com
expires: "2022-08-01"
opened_items_in_private_tabs:
type: event
description: |
A user opened multiple history items in private tabs
bugs:
- https://github.com/mozilla-mobile/fenix/issues/18178
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/18261
data_sensitivity:
- interaction
notification_emails:
- fenix-core@mozilla.com
expires: "2022-08-01"
tip:
displayed:

@ -73,6 +73,10 @@ sealed class Event {
object HistoryOpened : Event()
object HistoryItemShared : Event()
object HistoryItemOpened : Event()
object HistoryOpenedInNewTab : Event()
object HistoryOpenedInNewTabs : Event()
object HistoryOpenedInPrivateTab : Event()
object HistoryOpenedInPrivateTabs : Event()
object HistoryItemRemoved : Event()
object HistoryAllItemsRemoved : Event()
object ReaderModeAvailable : Event()

@ -307,6 +307,18 @@ private val Event.wrapper: EventWrapper<*>?
is Event.HistoryItemOpened -> EventWrapper<NoExtraKeys>(
{ History.openedItem.record(it) }
)
is Event.HistoryOpenedInNewTab -> EventWrapper<NoExtraKeys>(
{ History.openedItemInNewTab.record(it) }
)
is Event.HistoryOpenedInNewTabs -> EventWrapper<NoExtraKeys>(
{ History.openedItemsInNewTabs.record(it) }
)
is Event.HistoryOpenedInPrivateTab -> EventWrapper<NoExtraKeys>(
{ History.openedItemInPrivateTab.record(it) }
)
is Event.HistoryOpenedInPrivateTabs -> EventWrapper<NoExtraKeys>(
{ History.openedItemsInPrivateTabs.record(it) }
)
is Event.HistoryItemRemoved -> EventWrapper<NoExtraKeys>(
{ History.removed.record(it) }
)

@ -188,7 +188,7 @@ class HistoryFragment : LibraryPageFragment<HistoryItem>(), UserInteractionHandl
}
R.id.open_history_in_new_tabs_multi_select -> {
openItemsInNewTab { selectedItem ->
requireComponents.analytics.metrics.track(Event.HistoryItemOpened)
requireComponents.analytics.metrics.track(Event.HistoryOpenedInNewTabs)
selectedItem.url
}
@ -197,7 +197,7 @@ class HistoryFragment : LibraryPageFragment<HistoryItem>(), UserInteractionHandl
}
R.id.open_history_in_private_tabs_multi_select -> {
openItemsInNewTab(private = true) { selectedItem ->
requireComponents.analytics.metrics.track(Event.HistoryItemOpened)
requireComponents.analytics.metrics.track(Event.HistoryOpenedInPrivateTabs)
selectedItem.url
}
@ -248,7 +248,11 @@ class HistoryFragment : LibraryPageFragment<HistoryItem>(), UserInteractionHandl
}
private fun openItem(item: HistoryItem, mode: BrowsingMode? = null) {
requireComponents.analytics.metrics.track(Event.HistoryItemOpened)
when (mode?.isPrivate) {
true -> requireComponents.analytics.metrics.track(Event.HistoryOpenedInPrivateTab)
false -> requireComponents.analytics.metrics.track(Event.HistoryOpenedInNewTab)
null -> requireComponents.analytics.metrics.track(Event.HistoryItemOpened)
}
mode?.let { (activity as HomeActivity).browsingModeManager.mode = it }

@ -20,6 +20,7 @@ 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.History
import org.mozilla.fenix.GleanMetrics.Metrics
import org.mozilla.fenix.GleanMetrics.SearchDefaultEngine
import org.mozilla.fenix.GleanMetrics.SyncedTabs
@ -177,4 +178,23 @@ class GleanMetricsServiceTest {
gleanService.track(Event.RemoveBookmarkFolder)
assertTrue(BookmarksManagement.folderRemove.testHasValue())
}
@Test
fun `History events is correctly recorded`() {
assertFalse(History.openedItemInNewTab.testHasValue())
gleanService.track(Event.HistoryOpenedInNewTab)
assertTrue(History.openedItemInNewTab.testHasValue())
assertFalse(History.openedItemsInNewTabs.testHasValue())
gleanService.track(Event.HistoryOpenedInNewTabs)
assertTrue(History.openedItemsInNewTabs.testHasValue())
assertFalse(History.openedItemInPrivateTab.testHasValue())
gleanService.track(Event.HistoryOpenedInPrivateTab)
assertTrue(History.openedItemInPrivateTab.testHasValue())
assertFalse(History.openedItemsInPrivateTabs.testHasValue())
gleanService.track(Event.HistoryOpenedInPrivateTabs)
assertTrue(History.openedItemsInPrivateTabs.testHasValue())
}
}

@ -330,4 +330,29 @@ class MetricControllerTest {
verify { marketingService1.track(Event.RemoveBookmarkFolder) }
verify { marketingService1.track(Event.RemoveBookmarks) }
}
@Test
fun `history events should be sent to enabled service`() {
val controller = ReleaseMetricController(
listOf(marketingService1),
isDataTelemetryEnabled = { true },
isMarketingDataTelemetryEnabled = { true }
)
every { marketingService1.shouldTrack(Event.HistoryOpenedInNewTab) } returns true
every { marketingService1.shouldTrack(Event.HistoryOpenedInNewTabs) } returns true
every { marketingService1.shouldTrack(Event.HistoryOpenedInPrivateTab) } returns true
every { marketingService1.shouldTrack(Event.HistoryOpenedInPrivateTabs) } returns true
controller.start(MetricServiceType.Marketing)
controller.track(Event.HistoryOpenedInNewTab)
controller.track(Event.HistoryOpenedInNewTabs)
controller.track(Event.HistoryOpenedInPrivateTab)
controller.track(Event.HistoryOpenedInPrivateTabs)
verify { marketingService1.track(Event.HistoryOpenedInNewTab) }
verify { marketingService1.track(Event.HistoryOpenedInNewTabs) }
verify { marketingService1.track(Event.HistoryOpenedInPrivateTab) }
verify { marketingService1.track(Event.HistoryOpenedInPrivateTabs) }
}
}

@ -138,7 +138,11 @@ In addition to those built-in metrics, the following metrics are added to the pi
| find_in_page.opened |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened the find in page UI |[mozilla-mobile/fenix#1344](https://github.com/mozilla-mobile/fenix/pull/1344#issuecomment-479285010), [mozilla-mobile/fenix#15713](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 |
| find_in_page.searched_page |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user searched the page |[mozilla-mobile/fenix#1344](https://github.com/mozilla-mobile/fenix/pull/1344#issuecomment-479285010), [mozilla-mobile/fenix#15713](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 |
| history.opened |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened the history screen |[mozilla-mobile/fenix#3940](https://github.com/mozilla-mobile/fenix/pull/3940), [mozilla-mobile/fenix#15713](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 |
| history.opened_item |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened a history item |[mozilla-mobile/fenix#3940](https://github.com/mozilla-mobile/fenix/pull/3940), [mozilla-mobile/fenix#15713](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 |
| history.opened_item |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened a history item |[mozilla-mobile/fenix#18261](https://github.com/mozilla-mobile/fenix/pull/18261)||2022-08-01 |2 |
| history.opened_item_in_new_tab |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened a history item in a new tab |[mozilla-mobile/fenix#18261](https://github.com/mozilla-mobile/fenix/pull/18261)||2022-08-01 |2 |
| history.opened_item_in_private_tab |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened a history item in a private tab |[mozilla-mobile/fenix#18261](https://github.com/mozilla-mobile/fenix/pull/18261)||2022-08-01 |2 |
| history.opened_items_in_new_tabs |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened multiple history items in new tabs |[Review 1](https://gith ub.com/mozilla-mobile/fenix/pull/18261)||2022-08-01 |2 |
| history.opened_items_in_private_tabs |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened multiple history items in private tabs |[mozilla-mobile/fenix#18261](https://github.com/mozilla-mobile/fenix/pull/18261)||2022-08-01 |2 |
| history.removed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user removed a history item |[mozilla-mobile/fenix#3940](https://github.com/mozilla-mobile/fenix/pull/3940), [mozilla-mobile/fenix#15713](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 |
| history.removed_all |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user removed all history items |[mozilla-mobile/fenix#3940](https://github.com/mozilla-mobile/fenix/pull/3940), [mozilla-mobile/fenix#15713](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 |
| history.shared |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user shared a history item |[mozilla-mobile/fenix#3940](https://github.com/mozilla-mobile/fenix/pull/3940), [mozilla-mobile/fenix#15713](https://github.com/mozilla-mobile/fenix/pull/15713#issuecomment-703972068)||2021-08-01 |2 |

Loading…
Cancel
Save