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

Commit

Permalink
For #22175: Telemetry event for deleting a search term group from the…
Browse files Browse the repository at this point in the history
… recent searches section on home
  • Loading branch information
eliserichards committed Oct 26, 2021
1 parent d943be0 commit a7f2a2f
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 5 deletions.
19 changes: 19 additions & 0 deletions app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5730,6 +5730,25 @@ recent_bookmarks:
- android-probes@mozilla.com
expires: "2022-02-01"

recent_searches:
group_deleted:
type: event
description: |
A user has deleted a search term group from the
"Recent searches" section on the homescreen using
the long-press menu "Remove" option. This removes
the item from the homescreen, but does not delete
the item from history.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/22175
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/TBD
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
expires: "2022-04-01"

credit_cards:
saved:
type: counter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ sealed class Event {
object BookmarkClicked : Event()
object ShowAllBookmarks : Event()

// Recently visited/Recent searches
object RecentSearchesGroupDeleted : Event()

// Android Autofill
object AndroidAutofillUnlockSuccessful : Event()
object AndroidAutofillUnlockCanceled : Event()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import org.mozilla.fenix.GleanMetrics.Preferences
import org.mozilla.fenix.GleanMetrics.ProgressiveWebApp
import org.mozilla.fenix.GleanMetrics.ReaderMode
import org.mozilla.fenix.GleanMetrics.RecentBookmarks
import org.mozilla.fenix.GleanMetrics.RecentSearches
import org.mozilla.fenix.GleanMetrics.RecentTabs
import org.mozilla.fenix.GleanMetrics.SearchShortcuts
import org.mozilla.fenix.GleanMetrics.SearchWidget
Expand Down Expand Up @@ -789,6 +790,10 @@ private val Event.wrapper: EventWrapper<*>?
{ RecentBookmarks.showAllBookmarks.add() }
)

is Event.RecentSearchesGroupDeleted -> EventWrapper<NoExtraKeys>(
{ RecentSearches.groupDeleted.record(it) }
)

is Event.AndroidAutofillRequestWithLogins -> EventWrapper<NoExtraKeys>(
{ AndroidAutofill.requestMatchingLogins.record(it) }
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import mozilla.components.browser.state.action.HistoryMetadataAction
import mozilla.components.browser.state.store.BrowserStore
import mozilla.components.concept.storage.HistoryMetadataStorage
import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.components.metrics.MetricController
import org.mozilla.fenix.historymetadata.HistoryMetadataGroup
import org.mozilla.fenix.historymetadata.interactor.HistoryMetadataInteractor
import org.mozilla.fenix.home.HomeFragmentAction
Expand Down Expand Up @@ -49,7 +51,8 @@ class DefaultHistoryMetadataController(
private val homeStore: HomeFragmentStore,
private val navController: NavController,
private val storage: HistoryMetadataStorage,
private val scope: CoroutineScope
private val scope: CoroutineScope,
private val metrics: MetricController
) : HistoryMetadataController {

override fun handleHistoryShowAllClicked() {
Expand Down Expand Up @@ -79,6 +82,7 @@ class DefaultHistoryMetadataController(
scope.launch {
storage.deleteHistoryMetadata(searchTerm)
}
metrics.track(Event.RecentSearchesGroupDeleted)
}

@VisibleForTesting(otherwise = PRIVATE)
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,8 @@ class HomeFragment : Fragment() {
homeStore = homeFragmentStore,
storage = components.core.historyStorage,
scope = viewLifecycleOwner.lifecycleScope,
store = components.core.store
store = components.core.store,
metrics = requireComponents.analytics.metrics
),
pocketStoriesController = DefaultPocketStoriesController(
homeActivity = activity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.components.metrics.MetricController
import org.mozilla.fenix.historymetadata.HistoryMetadataGroup
import org.mozilla.fenix.home.HomeFragmentAction
import org.mozilla.fenix.home.HomeFragmentDirections
Expand All @@ -40,6 +42,8 @@ class HistoryMetadataControllerTest {
val coroutinesTestRule = MainCoroutineRule(testDispatcher)

private val navController = mockk<NavController>(relaxed = true)
private val metrics: MetricController = mockk(relaxed = true)

private lateinit var storage: HistoryMetadataStorage
private lateinit var homeFragmentStore: HomeFragmentStore
private lateinit var store: BrowserStore
Expand All @@ -62,7 +66,8 @@ class HistoryMetadataControllerTest {
store = store,
navController = navController,
scope = scope,
storage = storage
storage = storage,
metrics = metrics
)
)
}
Expand Down Expand Up @@ -137,9 +142,8 @@ class HistoryMetadataControllerTest {
testDispatcher.advanceUntilIdle()
verify {
store.dispatch(HistoryMetadataAction.DisbandSearchGroupAction(searchTerm = historyGroup.title))
}
verify {
homeFragmentStore.dispatch(HomeFragmentAction.DisbandSearchGroupAction(searchTerm = historyGroup.title))
metrics.track(Event.RecentSearchesGroupDeleted)
}

coVerify {
Expand Down

0 comments on commit a7f2a2f

Please sign in to comment.