Skip to content

Commit

Permalink
Close mozilla-mobile#27147: Add telemetry for bookmark search
Browse files Browse the repository at this point in the history
  • Loading branch information
rocketsroger authored and mergify[bot] committed Oct 6, 2022
1 parent e81da18 commit 3f7391a
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 0 deletions.
33 changes: 33 additions & 0 deletions app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2696,6 +2696,39 @@ bookmarks_management:
metadata:
tags:
- Bookmarks
search_icon_tapped:
type: event
description: |
A user tapped on the search icon in bookmarks management.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/27147
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/27268
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: 120
metadata:
tags:
- Bookmarks
search_result_tapped:
type: event
description: |
A user tapped on the search result in bookmarks management.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/27147
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/27268
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: 120
metadata:
tags:
- Bookmarks

activation:
identifier:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class BookmarkFragmentInteractor(
}

override fun onSearch() {
BookmarksManagement.searchIconTapped.record(NoExtras())
bookmarksController.handleSearch()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
package org.mozilla.fenix.library.bookmarks

import mozilla.components.concept.engine.EngineSession.LoadUrlFlags
import mozilla.components.service.glean.private.NoExtras
import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.GleanMetrics.BookmarksManagement
import org.mozilla.fenix.HomeActivity

/**
Expand All @@ -32,6 +34,7 @@ class BookmarkSearchDialogController(
}

override fun handleUrlTapped(url: String, flags: LoadUrlFlags) {
BookmarksManagement.searchResultTapped.record(NoExtras())
clearToolbarFocus()

activity.openToBrowserAndLoad(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,12 @@ class BookmarkFragmentInteractorTest {

@Test
fun `WHEN onSearch is called THEN call controller handleSearch`() {
assertNull(BookmarksManagement.searchIconTapped.testGetValue())
interactor.onSearch()

verify {
bookmarkController.handleSearch()
}
assertNotNull(BookmarksManagement.searchIconTapped.testGetValue())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,26 @@ import io.mockk.impl.annotations.MockK
import io.mockk.verify
import kotlinx.coroutines.test.runTest
import mozilla.components.concept.engine.EngineSession
import mozilla.components.service.glean.testing.GleanTestRule
import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.GleanMetrics.BookmarksManagement
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner

@RunWith(FenixRobolectricTestRunner::class)
class BookmarkSearchControllerTest {

@get:Rule
val gleanTestRule = GleanTestRule(testContext)

@MockK(relaxed = true)
private lateinit var activity: HomeActivity

Expand Down Expand Up @@ -63,6 +75,8 @@ class BookmarkSearchControllerTest {
val url = "https://www.google.com/"
val flags = EngineSession.LoadUrlFlags.none()

assertNull(BookmarksManagement.searchResultTapped.testGetValue())

createController().handleUrlTapped(url, flags)
createController().handleUrlTapped(url)

Expand All @@ -74,6 +88,8 @@ class BookmarkSearchControllerTest {
flags = flags,
)
}

assertNotNull(BookmarksManagement.searchResultTapped.testGetValue())
}

private fun createController(
Expand Down

0 comments on commit 3f7391a

Please sign in to comment.