Bug 1836167 - New telemetry in bookmarks

fenix/116.0
Harrison Oglesby 11 months ago committed by mergify[bot]
parent 63773d9614
commit 144abb235c

@ -1652,6 +1652,103 @@ metrics:
metadata:
tags:
- China
bookmarks_add:
type: labeled_counter
lifetime: application
description: |
A counter that indicates how many bookmarks a user has added.
The label for this counter is `<source>`.
`source` will be: `page_action_menu` as that is the only
entry point right now to add bookmarks.
send_in_pings:
- metrics
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1836167
data_reviews:
- https://github.com/mozilla-mobile/firefox-android/pull/2375
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
- cgordon@mozilla.com
expires: never
metadata:
tags:
- Bookmarks
bookmarks_edit:
type: labeled_counter
lifetime: application
description: |
A counter that indicates how many bookmarks a user has edited.
The label for this counter is `<source>`.
`source` will be: `bookmark_edit_page` or `bookmark_panel`.
send_in_pings:
- metrics
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1836167
data_reviews:
- https://github.com/mozilla-mobile/firefox-android/pull/2375
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
- cgordon@mozilla.com
expires: never
metadata:
tags:
- Bookmarks
bookmarks_delete:
type: labeled_counter
lifetime: application
description: |
A counter that indicates how many bookmarks a user has deleted.
The label for this counter is `<source>`.
`source` will be: `add_bookmark_toast` or `bookmark_panel`.
send_in_pings:
- metrics
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1836167
data_reviews:
- https://github.com/mozilla-mobile/firefox-android/pull/2375
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
- cgordon@mozilla.com
expires: never
metadata:
tags:
- Bookmarks
bookmarks_open:
type: labeled_counter
lifetime: application
description: |
A counter that indicates how many bookmarks a user has opened.
The label for this counter is `<source>`.
`source` will be: `top_sites`, `awesomebar_results`, `bookmark_panel`.
send_in_pings:
- metrics
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1836167
data_reviews:
- https://github.com/mozilla-mobile/firefox-android/pull/2375
data_sensitivity:
- interaction
notification_emails:
- android-probes@mozilla.com
- cgordon@mozilla.com
expires: never
metadata:
tags:
- Bookmarks
mobile_bookmarks_count:
type: counter
lifetime: application
@ -1670,7 +1767,7 @@ metrics:
- https://github.com/mozilla-mobile/fenix/pull/16942#issuecomment-742794701
- https://github.com/mozilla-mobile/fenix/pull/19924#issuecomment-861423789
- https://github.com/mozilla-mobile/fenix/pull/20517#pullrequestreview-718069041
- https://github.com/mozilla-mobile/fenix/pull/21038#issuecomment-906757301
- https://github.com/mozilla-mobile/fenix/pull/21038#issuecomment-9067573./01
data_sensitivity:
- interaction
notification_emails:

@ -118,6 +118,7 @@ import org.mozilla.fenix.browser.readermode.DefaultReaderModeController
import org.mozilla.fenix.components.FenixSnackbar
import org.mozilla.fenix.components.FindInPageIntegration
import org.mozilla.fenix.components.StoreProvider
import org.mozilla.fenix.components.metrics.MetricsUtils
import org.mozilla.fenix.components.toolbar.BrowserFragmentState
import org.mozilla.fenix.components.toolbar.BrowserFragmentStore
import org.mozilla.fenix.components.toolbar.BrowserToolbarView
@ -1403,6 +1404,7 @@ abstract class BaseBrowserFragment :
position = null,
)
MetricsUtils.recordBookmarkMetrics(MetricsUtils.BookmarkAction.ADD, METRIC_SOURCE)
withContext(Main) {
view?.let {
FenixSnackbar.make(
@ -1412,6 +1414,10 @@ abstract class BaseBrowserFragment :
)
.setText(getString(R.string.bookmark_saved_snackbar))
.setAction(getString(R.string.edit_bookmark_snackbar_action)) {
MetricsUtils.recordBookmarkMetrics(
MetricsUtils.BookmarkAction.EDIT,
TOAST_METRIC_SOURCE,
)
nav(
R.id.browserFragment,
BrowserFragmentDirections.actionGlobalBookmarkEditFragment(
@ -1566,6 +1572,8 @@ abstract class BaseBrowserFragment :
private const val REQUEST_CODE_DOWNLOAD_PERMISSIONS = 1
private const val REQUEST_CODE_PROMPT_PERMISSIONS = 2
private const val REQUEST_CODE_APP_PERMISSIONS = 3
private const val METRIC_SOURCE = "page_action_menu"
private const val TOAST_METRIC_SOURCE = "add_bookmark_toast"
val onboardingLinksList: List<String> = listOf(
SupportUtils.getMozillaPageUrl(SupportUtils.MozillaPage.PRIVATE_NOTICE),

@ -60,6 +60,30 @@ object MetricsUtils {
Events.performedSearch.record(Events.PerformedSearchExtra(performedSearchExtra))
}
/**
* Records the appropriate metric for performed Bookmark action.
* @param action The [BookmarkAction] being counted.
* @param source Describes where the action was called from.
*/
fun recordBookmarkMetrics(
action: BookmarkAction,
source: String,
) {
when (action) {
BookmarkAction.ADD -> Metrics.bookmarksAdd[source].add()
BookmarkAction.EDIT -> Metrics.bookmarksEdit[source].add()
BookmarkAction.DELETE -> Metrics.bookmarksDelete[source].add()
BookmarkAction.OPEN -> Metrics.bookmarksOpen[source].add()
}
}
/**
* Describes which bookmark action is being recorded.
*/
enum class BookmarkAction {
ADD, EDIT, DELETE, OPEN
}
/**
* Get the default salt to use for hashing. This is a convenience
* function to help with unit tests.

@ -9,6 +9,7 @@ import mozilla.components.concept.storage.BookmarkNodeType
import mozilla.telemetry.glean.private.NoExtras
import org.mozilla.fenix.GleanMetrics.BookmarksManagement
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
import org.mozilla.fenix.components.metrics.MetricsUtils
/**
* Interactor for the Bookmarks screen.
@ -33,6 +34,10 @@ class BookmarkFragmentInteractor(
override fun onEditPressed(node: BookmarkNode) {
bookmarksController.handleBookmarkEdit(node)
MetricsUtils.recordBookmarkMetrics(
MetricsUtils.BookmarkAction.EDIT,
METRIC_SOURCE,
)
}
override fun onAllBookmarksDeselected() {
@ -69,6 +74,10 @@ class BookmarkFragmentInteractor(
bookmarksController.handleOpeningBookmark(item, BrowsingMode.Normal)
BookmarksManagement.openInNewTab.record(NoExtras())
}
MetricsUtils.recordBookmarkMetrics(
MetricsUtils.BookmarkAction.OPEN,
METRIC_SOURCE,
)
}
override fun onOpenInPrivateTab(item: BookmarkNode) {
@ -77,16 +86,28 @@ class BookmarkFragmentInteractor(
bookmarksController.handleOpeningBookmark(item, BrowsingMode.Private)
BookmarksManagement.openInPrivateTab.record(NoExtras())
}
MetricsUtils.recordBookmarkMetrics(
MetricsUtils.BookmarkAction.OPEN,
METRIC_SOURCE,
)
}
override fun onOpenAllInNewTabs(folder: BookmarkNode) {
require(folder.type == BookmarkNodeType.FOLDER)
bookmarksController.handleOpeningFolderBookmarks(folder, BrowsingMode.Normal)
MetricsUtils.recordBookmarkMetrics(
MetricsUtils.BookmarkAction.OPEN,
METRIC_SOURCE,
)
}
override fun onOpenAllInPrivateTabs(folder: BookmarkNode) {
require(folder.type == BookmarkNodeType.FOLDER)
bookmarksController.handleOpeningFolderBookmarks(folder, BrowsingMode.Private)
MetricsUtils.recordBookmarkMetrics(
MetricsUtils.BookmarkAction.OPEN,
METRIC_SOURCE,
)
}
override fun onDelete(nodes: Set<BookmarkNode>) {
@ -100,6 +121,10 @@ class BookmarkFragmentInteractor(
BookmarkNodeType.FOLDER -> BookmarkRemoveType.FOLDER
null -> BookmarkRemoveType.MULTIPLE
}
MetricsUtils.recordBookmarkMetrics(
MetricsUtils.BookmarkAction.DELETE,
METRIC_SOURCE,
)
if (eventType == BookmarkRemoveType.FOLDER) {
bookmarksController.handleBookmarkFolderDeletion(nodes)
} else {
@ -133,4 +158,8 @@ class BookmarkFragmentInteractor(
override fun onRequestSync() {
bookmarksController.handleRequestSync()
}
companion object {
const val METRIC_SOURCE = "bookmark_panel"
}
}

@ -43,6 +43,7 @@ import org.mozilla.fenix.GleanMetrics.BookmarksManagement
import org.mozilla.fenix.NavHostActivity
import org.mozilla.fenix.R
import org.mozilla.fenix.components.FenixSnackbar
import org.mozilla.fenix.components.metrics.MetricsUtils
import org.mozilla.fenix.databinding.FragmentEditBookmarkBinding
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.getRootView
@ -222,6 +223,7 @@ class EditBookmarkFragment : Fragment(R.layout.fragment_edit_bookmark), MenuProv
lifecycleScope.launch(IO) {
requireComponents.core.bookmarksStorage.deleteNode(args.guidToEdit)
BookmarksManagement.removed.record(NoExtras())
MetricsUtils.recordBookmarkMetrics(MetricsUtils.BookmarkAction.DELETE, METRIC_SOURCE)
launch(Main) {
Navigation.findNavController(requireActivity(), R.id.container)
@ -312,4 +314,8 @@ class EditBookmarkFragment : Fragment(R.layout.fragment_edit_bookmark), MenuProv
_binding = null
}
companion object {
private const val METRIC_SOURCE = "bookmark_edit_page"
}
}

Loading…
Cancel
Save