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

Commit

Permalink
Recent bookmark count telemetry (#22293)
Browse files Browse the repository at this point in the history
* For #22075 - Added event to track the count of recent bookmarks

* For #22075 - Added data review issue number

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
MozillaNoah and mergify[bot] authored Nov 4, 2021
1 parent cff78af commit 8caefbe
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 4 deletions.
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"
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>(
{ 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

0 comments on commit 8caefbe

Please sign in to comment.