From 9d659af75db75ed5e4f36957fd2da43af2160203 Mon Sep 17 00:00:00 2001 From: mike a Date: Wed, 3 Jan 2024 21:00:40 -0800 Subject: [PATCH] Bug 1869664 - Add more toolbar telemetry --- app/metrics.yaml | 57 +++++++++++++++++-- .../fenix/browser/BaseBrowserFragment.kt | 2 + .../toolbar/BrowserToolbarMenuController.kt | 17 ++++-- .../fenix/search/SearchDialogFragment.kt | 1 + .../fenix/search/toolbar/ToolbarView.kt | 5 ++ ...DefaultBrowserToolbarMenuControllerTest.kt | 4 +- 6 files changed, 76 insertions(+), 10 deletions(-) diff --git a/app/metrics.yaml b/app/metrics.yaml index 4edb0eb1a..92a892dc6 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -135,10 +135,10 @@ events: description: | A string containing the name of the item the user tapped. These items include: - add_to_homescreen, add_to_top_sites, addons_manager, back, bookmark, - bookmarks, desktop_view_off, desktop_view_on, downloads, - find_in_page, forward, history, new_tab, open_in_app, open_in_fenix, - quit, reader_mode_appearance, reload, remove_from_top_sites, + add_to_homescreen, add_to_top_sites, addons_manager, back, back_long_press, + bookmark, bookmarks, desktop_view_off, desktop_view_on, downloads, + find_in_page, forward, forward_long_press, history, new_tab, open_in_app, + open_in_fenix, quit, reader_mode_appearance, reload, remove_from_top_sites, save_to_collection, set_default_browser, settings, share, stop, sync_account, translate and print_content. type: string @@ -475,6 +475,23 @@ events: notification_emails: - android-probes@mozilla.com expires: never + browser_toolbar_security_indicator_tapped: + type: event + description: | + An event that indicates that a user has tapped + the security indicator icon (at the start of the domain name). + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1869664 + data_reviews: + - https://github.com/mozilla-mobile/firefox-android/pull/5019#issuecomment-1876329933 + data_sensitivity: + - interaction + notification_emails: + - android-probes@mozilla.com + expires: never + metadata: + tags: + - Toolbar browser_toolbar_erase_tapped: type: event description: | @@ -489,6 +506,22 @@ events: notification_emails: - android-probes@mozilla.com expires: never + browser_toolbar_input_cleared: + type: event + description: | + A user pressed the circle cross icon, clearing the input in the toolbar. + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1869664 + data_reviews: + - https://github.com/mozilla-mobile/firefox-android/pull/5019#issuecomment-1876329933 + data_sensitivity: + - interaction + notification_emails: + - android-probes@mozilla.com + expires: never + metadata: + tags: + - Toolbar browser_toolbar_qr_scan_tapped: type: event description: | @@ -506,6 +539,22 @@ events: metadata: tags: - Toolbar + browser_toolbar_qr_scan_completed: + type: event + description: | + An event that indicates that a QR code has been scanned successfully. + bugs: + - https://bugzilla.mozilla.org/show_bug.cgi?id=1869664 + data_reviews: + - https://github.com/mozilla-mobile/firefox-android/pull/5019#issuecomment-1876329933 + data_sensitivity: + - interaction + notification_emails: + - android-probes@mozilla.com + expires: never + metadata: + tags: + - Toolbar toolbar_tab_swipe: type: event description: | diff --git a/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt b/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt index 63c8c44ec..7c667782a 100644 --- a/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt @@ -115,6 +115,7 @@ import mozilla.components.support.locale.ActivityContextWrapper import mozilla.components.ui.widgets.withCenterAlignedButtons import org.mozilla.fenix.BuildConfig import org.mozilla.fenix.FeatureFlags +import org.mozilla.fenix.GleanMetrics.Events import org.mozilla.fenix.GleanMetrics.MediaState import org.mozilla.fenix.GleanMetrics.PullToRefreshInBrowser import org.mozilla.fenix.HomeActivity @@ -468,6 +469,7 @@ abstract class BaseBrowserFragment : browserToolbarView.view.display.setOnSiteSecurityClickedListener { showQuickSettingsDialog() + Events.browserToolbarSecurityIndicatorTapped.record() } contextMenuFeature.set( diff --git a/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarMenuController.kt b/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarMenuController.kt index f7cb9576f..259abd6df 100644 --- a/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarMenuController.kt +++ b/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarMenuController.kt @@ -426,7 +426,7 @@ class DefaultBrowserToolbarMenuController( } } - @Suppress("ComplexMethod") + @Suppress("ComplexMethod", "LongMethod") private fun trackToolbarItemInteraction(item: ToolbarMenu.Item) { when (item) { is ToolbarMenu.Item.OpenInFenix -> @@ -439,10 +439,19 @@ class DefaultBrowserToolbarMenuController( Events.browserMenuAction.record(Events.BrowserMenuActionExtra("open_in_app")) is ToolbarMenu.Item.CustomizeReaderView -> Events.browserMenuAction.record(Events.BrowserMenuActionExtra("reader_mode_appearance")) - is ToolbarMenu.Item.Back -> - Events.browserMenuAction.record(Events.BrowserMenuActionExtra("back")) + is ToolbarMenu.Item.Back -> { + if (item.viewHistory) { + Events.browserMenuAction.record(Events.BrowserMenuActionExtra("back_long_press")) + } else { + Events.browserMenuAction.record(Events.BrowserMenuActionExtra("back")) + } + } is ToolbarMenu.Item.Forward -> - Events.browserMenuAction.record(Events.BrowserMenuActionExtra("forward")) + if (item.viewHistory) { + Events.browserMenuAction.record(Events.BrowserMenuActionExtra("forward_long_press")) + } else { + Events.browserMenuAction.record(Events.BrowserMenuActionExtra("forward")) + } is ToolbarMenu.Item.Reload -> Events.browserMenuAction.record(Events.BrowserMenuActionExtra("reload")) is ToolbarMenu.Item.Stop -> diff --git a/app/src/main/java/org/mozilla/fenix/search/SearchDialogFragment.kt b/app/src/main/java/org/mozilla/fenix/search/SearchDialogFragment.kt index 84d527b1b..f6fd7de78 100644 --- a/app/src/main/java/org/mozilla/fenix/search/SearchDialogFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/search/SearchDialogFragment.kt @@ -672,6 +672,7 @@ class SearchDialogFragment : AppCompatDialogFragment(), UserInteractionHandler { }.show() } } + Events.browserToolbarQrScanCompleted.record() }, ) } diff --git a/app/src/main/java/org/mozilla/fenix/search/toolbar/ToolbarView.kt b/app/src/main/java/org/mozilla/fenix/search/toolbar/ToolbarView.kt index 7fbb4cf13..fc186e8da 100644 --- a/app/src/main/java/org/mozilla/fenix/search/toolbar/ToolbarView.kt +++ b/app/src/main/java/org/mozilla/fenix/search/toolbar/ToolbarView.kt @@ -13,6 +13,7 @@ import mozilla.components.feature.toolbar.ToolbarAutocompleteFeature import mozilla.components.support.ktx.android.content.getColorFromAttr import mozilla.components.support.ktx.android.content.res.resolveAttribute import mozilla.components.support.ktx.android.view.hideKeyboard +import org.mozilla.fenix.GleanMetrics.Events import org.mozilla.fenix.R import org.mozilla.fenix.components.Components import org.mozilla.fenix.search.SearchEngineSource @@ -116,6 +117,10 @@ class ToolbarView( url = text interactor.onTextChanged(text) } + + override fun onInputCleared() { + Events.browserToolbarInputCleared.record() + } }, ) } diff --git a/app/src/test/java/org/mozilla/fenix/components/toolbar/DefaultBrowserToolbarMenuControllerTest.kt b/app/src/test/java/org/mozilla/fenix/components/toolbar/DefaultBrowserToolbarMenuControllerTest.kt index 12fcb7278..b1bf97dc8 100644 --- a/app/src/test/java/org/mozilla/fenix/components/toolbar/DefaultBrowserToolbarMenuControllerTest.kt +++ b/app/src/test/java/org/mozilla/fenix/components/toolbar/DefaultBrowserToolbarMenuControllerTest.kt @@ -312,7 +312,7 @@ class DefaultBrowserToolbarMenuControllerTest { assertNotNull(Events.browserMenuAction.testGetValue()) val snapshot = Events.browserMenuAction.testGetValue()!! assertEquals(1, snapshot.size) - assertEquals("back", snapshot.single().extra?.getValue("item")) + assertEquals("back_long_press", snapshot.single().extra?.getValue("item")) val directions = BrowserFragmentDirections.actionGlobalTabHistoryDialogFragment(null) verify { navController.navigate(directions) } @@ -347,7 +347,7 @@ class DefaultBrowserToolbarMenuControllerTest { assertNotNull(Events.browserMenuAction.testGetValue()) val snapshot = Events.browserMenuAction.testGetValue()!! assertEquals(1, snapshot.size) - assertEquals("forward", snapshot.single().extra?.getValue("item")) + assertEquals("forward_long_press", snapshot.single().extra?.getValue("item")) val directions = BrowserFragmentDirections.actionGlobalTabHistoryDialogFragment(null)