diff --git a/app/metrics.yaml b/app/metrics.yaml index e09866fe338c..a0542e00eb00 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -702,6 +702,7 @@ context_menu: open_in_new_tab, open_in_private_tab, open_image_in_new_tab, save_image, share_link, copy_link, copy_image_location, share_image ``` + type: string bugs: - https://github.com/mozilla-mobile/fenix/issues/957 - https://github.com/mozilla-mobile/fenix/issues/16076 diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt index c2e7f3e01443..1d6c26930e7a 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt @@ -9,7 +9,6 @@ import mozilla.components.feature.top.sites.TopSite import org.mozilla.fenix.GleanMetrics.Addons import org.mozilla.fenix.GleanMetrics.AppTheme import org.mozilla.fenix.GleanMetrics.Autoplay -import org.mozilla.fenix.GleanMetrics.ContextMenu import org.mozilla.fenix.GleanMetrics.Events import org.mozilla.fenix.GleanMetrics.Pocket import org.mozilla.fenix.GleanMetrics.SearchTerms @@ -268,27 +267,6 @@ sealed class Event { get() = keyName } - class ContextMenuItemTapped private constructor(val item: String) : Event() { - override val extras: Map? - get() = mapOf(ContextMenu.itemTappedKeys.named to item) - - companion object { - fun create(context_item: String) = - allowList[context_item]?.let { ContextMenuItemTapped(it) } - - private val allowList = mapOf( - "mozac.feature.contextmenu.open_in_new_tab" to "open_in_new_tab", - "mozac.feature.contextmenu.open_in_private_tab" to "open_in_private_tab", - "mozac.feature.contextmenu.open_image_in_new_tab" to "open_image_in_new_tab", - "mozac.feature.contextmenu.save_image" to "save_image", - "mozac.feature.contextmenu.share_link" to "share_link", - "mozac.feature.contextmenu.copy_link" to "copy_link", - "mozac.feature.contextmenu.copy_image_location" to "copy_image_location", - "mozac.feature.contextmenu.share_image" to "share_image" - ) - } - } - data class AddonInstalled(val addonId: String) : Event() object AutoPlaySettingVisited : Event() diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt index dfefe82034b5..89c76976bf34 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt @@ -14,7 +14,6 @@ import org.mozilla.fenix.GleanMetrics.AppTheme import org.mozilla.fenix.GleanMetrics.Autoplay import org.mozilla.fenix.GleanMetrics.Awesomebar import org.mozilla.fenix.GleanMetrics.BrowserSearch -import org.mozilla.fenix.GleanMetrics.ContextMenu import org.mozilla.fenix.GleanMetrics.ContextualMenu import org.mozilla.fenix.GleanMetrics.CreditCards import org.mozilla.fenix.GleanMetrics.Events @@ -104,10 +103,6 @@ private val Event.wrapper: EventWrapper<*>? BrowserSearch.inContent[label].add(1) } ) - is Event.ContextMenuItemTapped -> EventWrapper( - { ContextMenu.itemTapped.record(it) }, - { ContextMenu.itemTappedKeys.valueOf(it) } - ) is Event.SetDefaultBrowserToolbarMenuClicked -> EventWrapper( { ExperimentsDefaultBrowser.toolbarMenuClicked.record(it) } diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/MetricController.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/MetricController.kt index 55dc16fe8d38..8c135b4fcef5 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/MetricController.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/MetricController.kt @@ -35,6 +35,7 @@ import mozilla.components.support.base.log.logger.Logger import mozilla.components.support.webextensions.facts.WebExtensionFacts import mozilla.telemetry.glean.private.NoExtras import org.mozilla.fenix.BuildConfig +import org.mozilla.fenix.GleanMetrics.ContextMenu import org.mozilla.fenix.GleanMetrics.Events import org.mozilla.fenix.GleanMetrics.LoginDialog import org.mozilla.fenix.GleanMetrics.MediaNotification @@ -134,6 +135,16 @@ internal class ReleaseMetricController( Component.FEATURE_CUSTOMTABS to CustomTabsFacts.Items.CLOSE -> { CustomTab.closed.record(NoExtras()) } + + Component.FEATURE_CONTEXTMENU to ContextMenuFacts.Items.ITEM -> { + metadata?.get("item")?.let { + contextMenuAllowList[item]?.let { + ContextMenu.itemTapped.record(ContextMenu.ItemTappedExtra(it)) + } + } + Unit + } + else -> { this.toEvent()?.also { track(it) @@ -211,9 +222,6 @@ internal class ReleaseMetricController( Component.FEATURE_PROMPTS == component && CreditCardAutofillDialogFacts.Items.AUTOFILL_CREDIT_CARD_PROMPT_DISMISSED == item -> Event.CreditCardAutofillPromptDismissed - Component.FEATURE_CONTEXTMENU == component && ContextMenuFacts.Items.ITEM == item -> { - metadata?.get("item")?.let { Event.ContextMenuItemTapped.create(it.toString()) } - } Component.FEATURE_CONTEXTMENU == component && ContextMenuFacts.Items.TEXT_SELECTION_OPTION == item -> { when (metadata?.get("textSelectionOption")?.toString()) { CONTEXT_MENU_COPY -> Event.ContextMenuCopyTapped @@ -362,5 +370,19 @@ internal class ReleaseMetricController( const val CONTEXT_MENU_SEARCH_PRIVATELY = "CUSTOM_CONTEXT_MENU_SEARCH_PRIVATELY" const val CONTEXT_MENU_SELECT_ALL = "org.mozilla.geckoview.SELECT_ALL" const val CONTEXT_MENU_SHARE = "CUSTOM_CONTEXT_MENU_SHARE" + + /** + * Non - Text selection long press context menu items to be tracked. + */ + private val contextMenuAllowList = mapOf( + "mozac.feature.contextmenu.open_in_new_tab" to "open_in_new_tab", + "mozac.feature.contextmenu.open_in_private_tab" to "open_in_private_tab", + "mozac.feature.contextmenu.open_image_in_new_tab" to "open_image_in_new_tab", + "mozac.feature.contextmenu.save_image" to "save_image", + "mozac.feature.contextmenu.share_link" to "share_link", + "mozac.feature.contextmenu.copy_link" to "copy_link", + "mozac.feature.contextmenu.copy_image_location" to "copy_image_location", + "mozac.feature.contextmenu.share_image" to "share_image" + ) } }