Skip to content

Commit

Permalink
For mozilla-mobile#24211: Remove wrapper from context menu metrics.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcarare committed Apr 11, 2022
1 parent 525188d commit 3d9c92f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 30 deletions.
1 change: 1 addition & 0 deletions app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 0 additions & 22 deletions app/src/main/java/org/mozilla/fenix/components/metrics/Event.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -268,27 +267,6 @@ sealed class Event {
get() = keyName
}

class ContextMenuItemTapped private constructor(val item: String) : Event() {
override val extras: Map<ContextMenu.itemTappedKeys, String>?
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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<NoExtraKeys>(
{ ExperimentsDefaultBrowser.toolbarMenuClicked.record(it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
)
}
}

0 comments on commit 3d9c92f

Please sign in to comment.