mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-02 03:40:16 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/19931: Add telemetry probes for recent bookmarks on home screen (https://github.com/mozilla-mobile/fenix/pull/20316)
* Add telemetry probes for recent bookmarks on home screen. Tests for controller. * Make the events into counters in the metrics ping Update tests to reflect new metrics Add data review link for new metrics Mock new settings for startup metrics tests Update metrics Add test for recent bookmark glean events * Recent bookmarks controller tests
This commit is contained in:
parent
7b7a252ecf
commit
d105e8bc19
@ -5750,3 +5750,41 @@ recent_tabs:
|
||||
notification_emails:
|
||||
- android-probes@mozilla.com
|
||||
expires: "2022-06-23"
|
||||
|
||||
recent_bookmarks:
|
||||
bookmark_clicked:
|
||||
type: counter
|
||||
lifetime: application
|
||||
description: |
|
||||
A counter that indicates the number of times that a user
|
||||
has clicked on a recently saved bookmark from the home
|
||||
screen.
|
||||
send_in_pings:
|
||||
- metrics
|
||||
bugs:
|
||||
- https://github.com/mozilla-mobile/fenix/issues/19931
|
||||
data_reviews:
|
||||
- https://github.com/mozilla-mobile/fenix/pull/20316#issuecomment-888291843
|
||||
data_sensitivity:
|
||||
- interaction
|
||||
notification_emails:
|
||||
- android-probes@mozilla.com
|
||||
expires: "2022-02-01"
|
||||
show_all_bookmarks:
|
||||
type: counter
|
||||
lifetime: application
|
||||
description: |
|
||||
A counter that indicates the number of times that a user
|
||||
has clicked the show all button for recently saved bookmarks
|
||||
on the home screen.
|
||||
send_in_pings:
|
||||
- metrics
|
||||
bugs:
|
||||
- https://github.com/mozilla-mobile/fenix/issues/19931
|
||||
data_reviews:
|
||||
- https://github.com/mozilla-mobile/fenix/pull/20316#issuecomment-888291843
|
||||
data_sensitivity:
|
||||
- interaction
|
||||
notification_emails:
|
||||
- android-probes@mozilla.com
|
||||
expires: "2022-02-01"
|
||||
|
@ -251,6 +251,10 @@ sealed class Event {
|
||||
object OpenRecentTab : Event()
|
||||
object OpenInProgressMediaTab : Event()
|
||||
|
||||
// Recent bookmarks
|
||||
object BookmarkClicked : Event()
|
||||
object ShowAllBookmarks : Event()
|
||||
|
||||
// Android Autofill
|
||||
object AndroidAutofillUnlockSuccessful : Event()
|
||||
object AndroidAutofillUnlockCanceled : Event()
|
||||
|
@ -46,6 +46,7 @@ import org.mozilla.fenix.GleanMetrics.PrivateBrowsingMode
|
||||
import org.mozilla.fenix.GleanMetrics.PrivateBrowsingShortcut
|
||||
import org.mozilla.fenix.GleanMetrics.ProgressiveWebApp
|
||||
import org.mozilla.fenix.GleanMetrics.ReaderMode
|
||||
import org.mozilla.fenix.GleanMetrics.RecentBookmarks
|
||||
import org.mozilla.fenix.GleanMetrics.RecentTabs
|
||||
import org.mozilla.fenix.GleanMetrics.SearchShortcuts
|
||||
import org.mozilla.fenix.GleanMetrics.SearchSuggestions
|
||||
@ -853,6 +854,14 @@ private val Event.wrapper: EventWrapper<*>?
|
||||
{ RecentTabs.showAllClicked.record(it) }
|
||||
)
|
||||
|
||||
is Event.BookmarkClicked -> EventWrapper<NoExtraKeys>(
|
||||
{ RecentBookmarks.bookmarkClicked.add() }
|
||||
)
|
||||
|
||||
is Event.ShowAllBookmarks -> EventWrapper<NoExtraKeys>(
|
||||
{ RecentBookmarks.showAllBookmarks.add() }
|
||||
)
|
||||
|
||||
is Event.AndroidAutofillRequestWithLogins -> EventWrapper<NoExtraKeys>(
|
||||
{ AndroidAutofill.requestMatchingLogins.record(it) }
|
||||
)
|
||||
|
@ -12,6 +12,8 @@ import mozilla.components.concept.storage.BookmarkNode
|
||||
import org.mozilla.fenix.BrowserDirection
|
||||
import org.mozilla.fenix.HomeActivity
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.components.metrics.Event
|
||||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.home.HomeFragmentDirections
|
||||
import org.mozilla.fenix.home.recentbookmarks.interactor.RecentBookmarksInteractor
|
||||
|
||||
@ -47,9 +49,11 @@ class DefaultRecentBookmarksController(
|
||||
newTab = true,
|
||||
from = BrowserDirection.FromHome
|
||||
)
|
||||
activity.components.core.metrics.track(Event.BookmarkClicked)
|
||||
}
|
||||
|
||||
override fun handleShowAllBookmarksClicked() {
|
||||
activity.components.core.metrics.track(Event.ShowAllBookmarks)
|
||||
dismissSearchDialogIfDisplayed()
|
||||
navController.navigate(
|
||||
HomeFragmentDirections.actionGlobalBookmarkFragment(BookmarkRoot.Mobile.id)
|
||||
|
@ -19,6 +19,7 @@ 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.RecentBookmarks
|
||||
import org.mozilla.fenix.GleanMetrics.SyncedTabs
|
||||
import org.mozilla.fenix.GleanMetrics.TabsTray
|
||||
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
||||
@ -277,4 +278,15 @@ class GleanMetricsServiceTest {
|
||||
gleanService.track(Event.DefaultBrowserNotifTapped)
|
||||
assertTrue(Events.defaultBrowserNotifTapped.testHasValue())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Home screen recent bookmarks events are correctly recorded`() {
|
||||
assertFalse(RecentBookmarks.bookmarkClicked.testHasValue())
|
||||
gleanService.track(Event.BookmarkClicked)
|
||||
assertTrue(RecentBookmarks.bookmarkClicked.testHasValue())
|
||||
|
||||
assertFalse(RecentBookmarks.showAllBookmarks.testHasValue())
|
||||
gleanService.track(Event.ShowAllBookmarks)
|
||||
assertTrue(RecentBookmarks.showAllBookmarks.testHasValue())
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import io.mockk.spyk
|
||||
import io.mockk.verify
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.TestCoroutineDispatcher
|
||||
import kotlinx.coroutines.test.runBlockingTest
|
||||
import mozilla.appservices.places.BookmarkRoot
|
||||
import mozilla.components.concept.storage.BookmarkNode
|
||||
import mozilla.components.concept.storage.BookmarkNodeType
|
||||
@ -24,6 +25,9 @@ import org.junit.Test
|
||||
import org.mozilla.fenix.BrowserDirection
|
||||
import org.mozilla.fenix.HomeActivity
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.components.metrics.Event
|
||||
import org.mozilla.fenix.components.metrics.MetricController
|
||||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.home.HomeFragmentDirections
|
||||
import org.mozilla.fenix.home.recentbookmarks.controller.DefaultRecentBookmarksController
|
||||
|
||||
@ -37,12 +41,18 @@ class DefaultRecentBookmarksControllerTest {
|
||||
|
||||
private val activity: HomeActivity = mockk(relaxed = true)
|
||||
private val navController: NavController = mockk(relaxUnitFun = true)
|
||||
private val metrics: MetricController = mockk(relaxed = true)
|
||||
|
||||
private lateinit var controller: DefaultRecentBookmarksController
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
every { activity.openToBrowserAndLoad(any(), any(), any()) } just Runs
|
||||
every { activity.components.core.metrics } returns metrics
|
||||
|
||||
every { navController.currentDestination } returns mockk {
|
||||
every { id } returns R.id.homeFragment
|
||||
}
|
||||
every { navController.navigateUp() } returns true
|
||||
|
||||
controller = spyk(
|
||||
@ -85,13 +95,14 @@ class DefaultRecentBookmarksControllerTest {
|
||||
from = BrowserDirection.FromHome
|
||||
)
|
||||
}
|
||||
verify { metrics.track(Event.BookmarkClicked) }
|
||||
verify(exactly = 0) {
|
||||
navController.navigateUp()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `WHEN show all recently saved bookmark is clicked THEN the bookmarks root is opened`() {
|
||||
fun `WHEN show all recently saved bookmark is clicked THEN the bookmarks root is opened`() = runBlockingTest {
|
||||
every { navController.currentDestination } returns mockk {
|
||||
every { id } returns R.id.homeFragment
|
||||
}
|
||||
@ -100,8 +111,8 @@ class DefaultRecentBookmarksControllerTest {
|
||||
|
||||
val directions = HomeFragmentDirections.actionGlobalBookmarkFragment(BookmarkRoot.Mobile.id)
|
||||
verify {
|
||||
controller.dismissSearchDialogIfDisplayed()
|
||||
navController.navigate(directions)
|
||||
metrics.track(Event.ShowAllBookmarks)
|
||||
}
|
||||
verify(exactly = 0) {
|
||||
navController.navigateUp()
|
||||
@ -117,10 +128,12 @@ class DefaultRecentBookmarksControllerTest {
|
||||
controller.handleShowAllBookmarksClicked()
|
||||
|
||||
val directions = HomeFragmentDirections.actionGlobalBookmarkFragment(BookmarkRoot.Mobile.id)
|
||||
|
||||
verify {
|
||||
controller.dismissSearchDialogIfDisplayed()
|
||||
navController.navigateUp()
|
||||
navController.navigate(directions)
|
||||
metrics.track(Event.ShowAllBookmarks)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user