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

Recent bookmark count telemetry #22293

Merged
merged 3 commits into from
Nov 4, 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 @@ -5893,6 +5893,21 @@ recent_bookmarks:
notification_emails:
- android-probes@mozilla.com
expires: "2022-02-01"
recent_bookmarks_count:
type: quantity
description: |
The number of bookmarked items appearing in the
Recently Saved section on the home page.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/22075
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/22293
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: "2022-11-01"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was just unsure what to make the expiration date now that the telemetry work for MR2 has rolled over into November.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good to me

unit: integer

recent_searches:
group_deleted:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ sealed class Event {
object BookmarkClicked : Event()
object ShowAllBookmarks : Event()
object RecentBookmarksShown : Event()
data class RecentBookmarkCount(val count: Int) : Event()

// Recently visited/Recent searches
object RecentSearchesGroupDeleted : Event()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,10 @@ private val Event.wrapper: EventWrapper<*>?
{ RecentBookmarks.shown.record(it) }
)

is Event.RecentBookmarkCount -> EventWrapper<NoExtraKeys>(
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, quantity seems to be a good fit here.

{ RecentBookmarks.recentBookmarksCount.set(this.count.toLong()) },
)

is Event.AndroidAutofillRequestWithLogins -> EventWrapper<NoExtraKeys>(
{ AndroidAutofill.requestMatchingLogins.record(it) }
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -604,9 +604,13 @@ class DefaultSessionControlController(
}

override fun handleReportSessionMetrics(state: HomeFragmentState) {
metrics.track(
if (state.recentTabs.isEmpty()) Event.RecentTabsSectionIsNotVisible
else Event.RecentTabsSectionIsVisible
)
with(metrics) {
track(
if (state.recentTabs.isEmpty()) Event.RecentTabsSectionIsNotVisible
else Event.RecentTabsSectionIsVisible
)

track(Event.RecentBookmarkCount(state.recentBookmarks.size))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import mozilla.components.browser.state.state.recover.RecoverableTab
import mozilla.components.browser.state.state.selectedOrDefaultSearchEngine
import mozilla.components.browser.state.store.BrowserStore
import mozilla.components.concept.engine.Engine
import mozilla.components.concept.storage.BookmarkNode
import mozilla.components.feature.session.SessionUseCases
import mozilla.components.feature.tab.collections.TabCollection
import mozilla.components.feature.tabs.TabsUseCases
Expand Down Expand Up @@ -843,6 +844,27 @@ class DefaultSessionControlControllerTest {
}
}

@Test
fun `WHEN handleReportSessionMetrics is called AND there are zero recent bookmarks THEN report Event#RecentBookmarkCount(0)`() {
every { homeFragmentState.recentBookmarks } returns emptyList()
every { homeFragmentState.recentTabs } returns emptyList()
createController().handleReportSessionMetrics(homeFragmentState)
verify {
metrics.track(Event.RecentBookmarkCount(0))
}
}

@Test
fun `WHEN handleReportSessionMetrics is called AND there is at least one recent bookmark THEN report Event#RecentBookmarkCount(1)`() {
val recentBookmark: BookmarkNode = mockk(relaxed = true)
every { homeFragmentState.recentBookmarks } returns listOf(recentBookmark)
every { homeFragmentState.recentTabs } returns emptyList()
createController().handleReportSessionMetrics(homeFragmentState)
verify {
metrics.track(Event.RecentBookmarkCount(1))
}
}

private fun createController(
hideOnboarding: () -> Unit = { },
registerCollectionStorageObserver: () -> Unit = { },
Expand Down