MR2 Telemetry: Recent tabs section probe (#22166)
* For #22107 - Added probe to track if the Recent tabs / jump back in section is visible * For #22107 - Fixed lint errors * For #22107 - added data review number to metric * For #22166 - fixed expiration date Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
9a53a12c57
commit
a06b04ec6d
|
@ -5828,6 +5828,20 @@ recent_tabs:
|
|||
notification_emails:
|
||||
- android-probes@mozilla.com
|
||||
expires: "2022-06-23"
|
||||
section_visible:
|
||||
type: boolean
|
||||
description: |
|
||||
An indication of whether the recent tabs /
|
||||
Jump Back In section is visible on the homepage.
|
||||
bugs:
|
||||
- https://github.com/mozilla-mobile/fenix/issues/22107
|
||||
data_reviews:
|
||||
- https://github.com/mozilla-mobile/fenix/pull/22166
|
||||
data_sensitivity:
|
||||
- interaction
|
||||
notification_emails:
|
||||
- android-probes@mozilla.com
|
||||
expires: "2022-11-01"
|
||||
|
||||
recent_bookmarks:
|
||||
shown:
|
||||
|
|
|
@ -268,6 +268,8 @@ sealed class Event {
|
|||
object ShowAllRecentTabs : Event()
|
||||
object OpenRecentTab : Event()
|
||||
object OpenInProgressMediaTab : Event()
|
||||
object RecentTabsSectionIsVisible : Event()
|
||||
object RecentTabsSectionIsNotVisible : Event()
|
||||
|
||||
// Recent bookmarks
|
||||
object BookmarkClicked : Event()
|
||||
|
|
|
@ -799,6 +799,14 @@ private val Event.wrapper: EventWrapper<*>?
|
|||
{ RecentTabs.showAllClicked.record(it) }
|
||||
)
|
||||
|
||||
is Event.RecentTabsSectionIsVisible -> EventWrapper<NoExtraKeys>(
|
||||
{ RecentTabs.sectionVisible.set(true) }
|
||||
)
|
||||
|
||||
is Event.RecentTabsSectionIsNotVisible -> EventWrapper<NoExtraKeys>(
|
||||
{ RecentTabs.sectionVisible.set(false) }
|
||||
)
|
||||
|
||||
is Event.BookmarkClicked -> EventWrapper<NoExtraKeys>(
|
||||
{ RecentBookmarks.bookmarkClicked.add() }
|
||||
)
|
||||
|
|
|
@ -434,7 +434,7 @@ class HomeFragment : Fragment() {
|
|||
sessionControlView?.update(homeFragmentStore.state)
|
||||
|
||||
binding.root.consumeFrom(homeFragmentStore, viewLifecycleOwner) {
|
||||
sessionControlView?.update(it)
|
||||
sessionControlView?.update(it, shouldReportMetrics = true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ import org.mozilla.fenix.ext.settings
|
|||
import org.mozilla.fenix.home.HomeFragment
|
||||
import org.mozilla.fenix.home.HomeFragmentAction
|
||||
import org.mozilla.fenix.home.HomeFragmentDirections
|
||||
import org.mozilla.fenix.home.HomeFragmentState
|
||||
import org.mozilla.fenix.home.HomeFragmentStore
|
||||
import org.mozilla.fenix.home.Mode
|
||||
import org.mozilla.fenix.settings.SupportUtils
|
||||
|
@ -188,6 +189,11 @@ interface SessionControlController {
|
|||
* @see [OnboardingInteractor.showOnboardingDialog]
|
||||
*/
|
||||
fun handleShowOnboardingDialog()
|
||||
|
||||
/**
|
||||
* @see [SessionControlInteractor.reportSessionMetrics]
|
||||
*/
|
||||
fun handleReportSessionMetrics(state: HomeFragmentState)
|
||||
}
|
||||
|
||||
@Suppress("TooManyFunctions", "LargeClass")
|
||||
|
@ -596,4 +602,11 @@ class DefaultSessionControlController(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun handleReportSessionMetrics(state: HomeFragmentState) {
|
||||
metrics.track(
|
||||
if (state.recentTabs.isEmpty()) Event.RecentTabsSectionIsNotVisible
|
||||
else Event.RecentTabsSectionIsVisible
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.mozilla.fenix.components.tips.Tip
|
|||
import org.mozilla.fenix.historymetadata.HistoryMetadataGroup
|
||||
import org.mozilla.fenix.historymetadata.controller.HistoryMetadataController
|
||||
import org.mozilla.fenix.historymetadata.interactor.HistoryMetadataInteractor
|
||||
import org.mozilla.fenix.home.HomeFragmentState
|
||||
import org.mozilla.fenix.home.recentbookmarks.controller.RecentBookmarksController
|
||||
import org.mozilla.fenix.home.recentbookmarks.interactor.RecentBookmarksInteractor
|
||||
import org.mozilla.fenix.home.recenttabs.controller.RecentTabController
|
||||
|
@ -36,6 +37,13 @@ interface TabSessionInteractor {
|
|||
* Called when a user clicks on the Private Mode button on the homescreen.
|
||||
*/
|
||||
fun onPrivateModeButtonClicked(newMode: BrowsingMode, userHasBeenOnboarded: Boolean)
|
||||
|
||||
/**
|
||||
* Called when there is an update to the session state and updated metrics need to be reported
|
||||
*
|
||||
* * @param state The state the homepage from which to report desired metrics.
|
||||
*/
|
||||
fun reportSessionMetrics(state: HomeFragmentState)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -410,4 +418,8 @@ class SessionControlInteractor(
|
|||
override fun onDiscoverMoreClicked(link: String) {
|
||||
pocketStoriesController.handleDiscoverMoreClicked(link)
|
||||
}
|
||||
|
||||
override fun reportSessionMetrics(state: HomeFragmentState) {
|
||||
controller.handleReportSessionMetrics(state)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -215,11 +215,13 @@ class SessionControlView(
|
|||
}
|
||||
}
|
||||
|
||||
fun update(state: HomeFragmentState) {
|
||||
fun update(state: HomeFragmentState, shouldReportMetrics: Boolean = false) {
|
||||
if (state.shouldShowHomeOnboardingDialog(view.context.settings())) {
|
||||
interactor.showOnboardingDialog()
|
||||
}
|
||||
|
||||
if (shouldReportMetrics) interactor.reportSessionMetrics(state)
|
||||
|
||||
val stateAdapterList = state.toAdapterList()
|
||||
if (homeScreenViewModel.shouldScrollToTopSites) {
|
||||
sessionControlAdapter.submitList(stateAdapterList) {
|
||||
|
|
|
@ -55,6 +55,7 @@ import org.mozilla.fenix.components.metrics.MetricController
|
|||
import org.mozilla.fenix.components.tips.Tip
|
||||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.home.recenttabs.RecentTab
|
||||
import org.mozilla.fenix.home.sessioncontrol.DefaultSessionControlController
|
||||
import org.mozilla.fenix.settings.SupportUtils
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
|
@ -107,6 +108,7 @@ class DefaultSessionControlControllerTest {
|
|||
)
|
||||
|
||||
private lateinit var store: BrowserStore
|
||||
private val homeFragmentState: HomeFragmentState = mockk(relaxed = true)
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
|
@ -816,6 +818,31 @@ class DefaultSessionControlControllerTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `WHEN handleReportSessionMetrics is called AND there are zero recent tabs THEN report Event#RecentTabsSectionIsNotVisible`() {
|
||||
every { homeFragmentState.recentTabs } returns emptyList()
|
||||
createController().handleReportSessionMetrics(homeFragmentState)
|
||||
verify(exactly = 0) {
|
||||
metrics.track(Event.RecentTabsSectionIsVisible)
|
||||
}
|
||||
verify {
|
||||
metrics.track(Event.RecentTabsSectionIsNotVisible)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `WHEN handleReportSessionMetrics is called AND there is at least one recent tab THEN report Event#RecentTabsSectionIsVisible`() {
|
||||
val recentTab: RecentTab = mockk(relaxed = true)
|
||||
every { homeFragmentState.recentTabs } returns listOf(recentTab)
|
||||
createController().handleReportSessionMetrics(homeFragmentState)
|
||||
verify(exactly = 0) {
|
||||
metrics.track(Event.RecentTabsSectionIsNotVisible)
|
||||
}
|
||||
verify {
|
||||
metrics.track(Event.RecentTabsSectionIsVisible)
|
||||
}
|
||||
}
|
||||
|
||||
private fun createController(
|
||||
hideOnboarding: () -> Unit = { },
|
||||
registerCollectionStorageObserver: () -> Unit = { },
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
package org.mozilla.fenix.home
|
||||
|
||||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import mozilla.components.concept.storage.BookmarkNode
|
||||
|
@ -259,4 +260,12 @@ class SessionControlInteractorTest {
|
|||
|
||||
verify { pocketStoriesController.handleLearnMoreClicked(link) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun reportSessionMetrics() {
|
||||
val homeFragmentState: HomeFragmentState = mockk(relaxed = true)
|
||||
every { homeFragmentState.recentBookmarks } returns emptyList()
|
||||
interactor.reportSessionMetrics(homeFragmentState)
|
||||
verify { controller.handleReportSessionMetrics(homeFragmentState) }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user