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

Commit

Permalink
Make the events into counters in the metrics ping
Browse files Browse the repository at this point in the history
  • Loading branch information
Elise Richards committed Jul 29, 2021
1 parent 867c473 commit f117ff7
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 43 deletions.
64 changes: 36 additions & 28 deletions app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,42 @@ metrics:
- [email protected]
- [email protected]
expires: "2021-08-11"
recent_bookmark_click_count:
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/TBD...
data_sensitivity:
- interaction
notification_emails:
- [email protected]
expires: "2022-02-01"
recent_bookmark_showall_count:
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/TBD...
data_sensitivity:
- interaction
notification_emails:
- [email protected]
expires: "2022-02-01"

preferences:
search_suggestions_enabled:
Expand Down Expand Up @@ -5961,31 +5997,3 @@ recent_tabs:
notification_emails:
- [email protected]
expires: "2022-06-23"
recent_bookmarks:
bookmark_clicked:
type: event
description: |
A recently saved bookmark was clicked on the home screen.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/19931
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/TBD...
data_sensitivity:
- interaction
notification_emails:
- [email protected]
expires: "2022-01-31"
show_all_clicked:
type: event
description: |
The show all button was clicked on the recently saved
bookmarks section of the home screen.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/19931
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/TBD...
data_sensitivity:
- interaction
notification_emails:
- [email protected]
expires: "2022-01-31"
8 changes: 8 additions & 0 deletions app/src/main/java/org/mozilla/fenix/FenixApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,14 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
creditCardsAutofillCount.add(settings.creditCardsAutofilledCount)
}

if (settings.recentBookmarkClickedCount > 0) {
recentBookmarkClickCount.add(settings.recentBookmarkClickedCount)
}

if (settings.recentBookmarkShowAllCount > 0) {
recentBookmarkShowallCount.add(settings.recentBookmarkShowAllCount)
}

val installedAddonSize = settings.installedAddonsCount
Addons.hasInstalledAddons.set(installedAddonSize > 0)
if (installedAddonSize > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,6 @@ sealed class Event {
object OpenRecentTab : Event()
object OpenInProgressMediaTab : Event()

// Recent bookmarks on Home
object RecentBookmarkClicked : Event()
object RecentBookmarkShowAll : Event()

// Interaction events with extras

data class TopSiteSwipeCarousel(val page: Int) : Event() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ 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
Expand Down Expand Up @@ -863,14 +862,6 @@ private val Event.wrapper: EventWrapper<*>?
{ RecentTabs.showAllClicked.record(it) }
)

is Event.RecentBookmarkClicked -> EventWrapper<NoExtraKeys>(
{ RecentBookmarks.bookmarkClicked.record(it) }
)

is Event.RecentBookmarkShowAll -> EventWrapper<NoExtraKeys>(
{ RecentBookmarks.showAllClicked.record(it) }
)

// Don't record other events in Glean:
is Event.AddBookmark -> null
is Event.OpenedAppFirstRun -> null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.home.HomeFragmentDirections
import org.mozilla.fenix.home.recentbookmarks.interactor.RecentBookmarksInteractor

Expand Down Expand Up @@ -47,11 +48,11 @@ class DefaultRecentBookmarksController(
newTab = true,
from = BrowserDirection.FromHome
)
activity.components.core.metrics.track(Event.RecentBookmarkClicked)
activity.settings().recentBookmarkClickedCount += 1
}

override fun handleShowAllBookmarksClicked() {
activity.components.core.metrics.track(Event.RecentBookmarkShowAll)
activity.settings().recentBookmarkShowAllCount += 1
val directions = HomeFragmentDirections.actionGlobalBookmarkFragment(BookmarkRoot.Mobile.id)
navController.nav(R.id.homeFragment, directions)
}
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/java/org/mozilla/fenix/utils/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,24 @@ class Settings(private val appContext: Context) : PreferencesHolder {
0
)

/**
* Stores the number of times that recently saved bookmarks on the home screen
* have been clicked by the user.
*/
var recentBookmarkClickedCount by intPreference(
appContext.getPreferenceKey(R.string.pref_key_home_bookmark_click_count),
0
)

/**
* Stores the number of times that the Show All button for recently saved bookmarks
* on the home screen has been clicked by the user.
*/
var recentBookmarkShowAllCount by intPreference(
appContext.getPreferenceKey(R.string.pref_key_home_bookmark_show_all_click_count),
0
)

private var savedLoginsSortingStrategyString by stringPreference(
appContext.getPreferenceKey(R.string.pref_key_saved_logins_sorting_strategy),
default = SavedLoginsSortingStrategyMenu.Item.AlphabeticallySort.strategyString
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/values/preference_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@
<!-- Set default browser experiment card-->
<string name="pref_key_experiment_card_home" translatable="false">pref_key_experiment_card_home</string>

<!-- Home -->
<!-- Metric value key for the number of times that recently saved bookmarks on the home screen has been clicked by the user. -->
<string name="pref_key_home_bookmark_click_count" translatable="false">pref_key_home_bookmark_click_count</string>
<!-- Metric value key for the number of times that recently saved bookmarks Show All button on the home screen has been clicked by the user. -->
<string name="pref_key_home_bookmark_show_all_click_count" translatable="false">pref_key_home_bookmark_show_all_click_count</string>

<!-- Secret Info Setting Keys -->
<string name="pref_key_secret_debug_info" translatable="false">pref_key_secret_debug_info</string>

Expand Down

0 comments on commit f117ff7

Please sign in to comment.