[fenix] For https://github.com/mozilla-mobile/fenix/issues/24715: Remove wrapper from addons metrics.

pull/600/head
mcarare 2 years ago committed by mergify[bot]
parent 52df5cd2f4
commit ebb6647c37

@ -5679,6 +5679,7 @@ addons:
addon_id: addon_id:
description: | description: |
The id of the add-on that was interacted with in the toolbar menu The id of the add-on that was interacted with in the toolbar menu
type: string
bugs: bugs:
- https://github.com/mozilla-mobile/fenix/issues/6174 - https://github.com/mozilla-mobile/fenix/issues/6174
- https://github.com/mozilla-mobile/fenix/issues/19923 - https://github.com/mozilla-mobile/fenix/issues/19923
@ -5704,6 +5705,7 @@ addons:
addon_id: addon_id:
description: | description: |
The id of the add-on that was interacted with The id of the add-on that was interacted with
type: string
bugs: bugs:
- https://github.com/mozilla-mobile/fenix/issues/17644 - https://github.com/mozilla-mobile/fenix/issues/17644
data_reviews: data_reviews:

@ -20,9 +20,9 @@ import kotlinx.coroutines.launch
import mozilla.components.feature.addons.Addon import mozilla.components.feature.addons.Addon
import mozilla.components.feature.addons.AddonManagerException import mozilla.components.feature.addons.AddonManagerException
import mozilla.components.feature.addons.ui.translateName import mozilla.components.feature.addons.ui.translateName
import org.mozilla.fenix.GleanMetrics.Addons
import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.databinding.FragmentInstalledAddOnDetailsBinding import org.mozilla.fenix.databinding.FragmentInstalledAddOnDetailsBinding
import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.runIfFragmentIsAttached import org.mozilla.fenix.ext.runIfFragmentIsAttached
@ -212,9 +212,8 @@ class InstalledAddonDetailsFragment : Fragment() {
binding.settings.apply { binding.settings.apply {
isVisible = shouldSettingsBeVisible() isVisible = shouldSettingsBeVisible()
setOnClickListener { setOnClickListener {
requireContext().components.analytics.metrics.track( Addons.openAddonSetting.record(Addons.OpenAddonSettingExtra(addon.id))
Event.AddonOpenSetting(addon.id)
)
val settingUrl = addon.installedState?.optionsPageUrl ?: return@setOnClickListener val settingUrl = addon.installedState?.optionsPageUrl ?: return@setOnClickListener
val directions = if (addon.installedState?.openOptionsPageInTab == true) { val directions = if (addon.installedState?.openOptionsPageInTab == true) {
val components = it.context.components val components = it.context.components

@ -5,7 +5,6 @@
package org.mozilla.fenix.components.metrics package org.mozilla.fenix.components.metrics
import mozilla.components.browser.state.search.SearchEngine import mozilla.components.browser.state.search.SearchEngine
import org.mozilla.fenix.GleanMetrics.Addons
import org.mozilla.fenix.GleanMetrics.Autoplay import org.mozilla.fenix.GleanMetrics.Autoplay
import org.mozilla.fenix.GleanMetrics.ContextMenu import org.mozilla.fenix.GleanMetrics.ContextMenu
import org.mozilla.fenix.GleanMetrics.Events import org.mozilla.fenix.GleanMetrics.Events
@ -54,7 +53,6 @@ sealed class Event {
} }
) )
} }
object AddonsOpenInSettings : Event()
object SearchWidgetInstalled : Event() object SearchWidgetInstalled : Event()
object ProgressiveWebAppOpenFromHomescreenTap : Event() object ProgressiveWebAppOpenFromHomescreenTap : Event()
@ -131,16 +129,6 @@ sealed class Event {
// Interaction events with extras // Interaction events with extras
data class AddonsOpenInToolbarMenu(val addonId: String) : Event() {
override val extras: Map<Addons.openAddonInToolbarMenuKeys, String>?
get() = hashMapOf(Addons.openAddonInToolbarMenuKeys.addonId to addonId)
}
data class AddonOpenSetting(val addonId: String) : Event() {
override val extras: Map<Addons.openAddonSettingKeys, String>?
get() = hashMapOf(Addons.openAddonSettingKeys.addonId to addonId)
}
data class PerformedSearch(val eventSource: EventSource) : Event() { data class PerformedSearch(val eventSource: EventSource) : Event() {
sealed class EngineSource { sealed class EngineSource {
abstract val engine: SearchEngine abstract val engine: SearchEngine

@ -8,7 +8,6 @@ import android.content.Context
import mozilla.components.service.glean.Glean import mozilla.components.service.glean.Glean
import mozilla.components.service.glean.private.NoExtraKeys import mozilla.components.service.glean.private.NoExtraKeys
import mozilla.components.support.base.log.logger.Logger import mozilla.components.support.base.log.logger.Logger
import org.mozilla.fenix.GleanMetrics.Addons
import org.mozilla.fenix.GleanMetrics.AndroidAutofill import org.mozilla.fenix.GleanMetrics.AndroidAutofill
import org.mozilla.fenix.GleanMetrics.Autoplay import org.mozilla.fenix.GleanMetrics.Autoplay
import org.mozilla.fenix.GleanMetrics.Awesomebar import org.mozilla.fenix.GleanMetrics.Awesomebar
@ -132,17 +131,6 @@ private val Event.wrapper: EventWrapper<*>?
{ Pocket.homeRecsCategoryClicked.record(it) }, { Pocket.homeRecsCategoryClicked.record(it) },
{ Pocket.homeRecsCategoryClickedKeys.valueOf(it) } { Pocket.homeRecsCategoryClickedKeys.valueOf(it) }
) )
is Event.AddonsOpenInSettings -> EventWrapper<NoExtraKeys>(
{ Addons.openAddonsInSettings.record(it) }
)
is Event.AddonsOpenInToolbarMenu -> EventWrapper(
{ Addons.openAddonInToolbarMenu.record(it) },
{ Addons.openAddonInToolbarMenuKeys.valueOf(it) }
)
is Event.AddonOpenSetting -> EventWrapper(
{ Addons.openAddonSetting.record(it) },
{ Addons.openAddonSettingKeys.valueOf(it) }
)
is Event.AutoPlaySettingVisited -> EventWrapper<NoExtraKeys>( is Event.AutoPlaySettingVisited -> EventWrapper<NoExtraKeys>(
{ Autoplay.visitedSetting.record(it) } { Autoplay.visitedSetting.record(it) }
) )

@ -35,6 +35,7 @@ import mozilla.components.support.base.log.logger.Logger
import mozilla.components.support.webextensions.facts.WebExtensionFacts import mozilla.components.support.webextensions.facts.WebExtensionFacts
import mozilla.telemetry.glean.private.NoExtras import mozilla.telemetry.glean.private.NoExtras
import org.mozilla.fenix.BuildConfig import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.GleanMetrics.Addons
import org.mozilla.fenix.GleanMetrics.CustomTab import org.mozilla.fenix.GleanMetrics.CustomTab
import org.mozilla.fenix.GleanMetrics.Events import org.mozilla.fenix.GleanMetrics.Events
import org.mozilla.fenix.GleanMetrics.LoginDialog import org.mozilla.fenix.GleanMetrics.LoginDialog
@ -143,6 +144,14 @@ internal class ReleaseMetricController(
Component.FEATURE_CUSTOMTABS to CustomTabsFacts.Items.CLOSE -> { Component.FEATURE_CUSTOMTABS to CustomTabsFacts.Items.CLOSE -> {
CustomTab.closed.record(NoExtras()) CustomTab.closed.record(NoExtras())
} }
Component.BROWSER_MENU to BrowserMenuFacts.Items.WEB_EXTENSION_MENU_ITEM -> {
metadata?.get("id")?.let {
Addons.openAddonInToolbarMenu.record(Addons.OpenAddonInToolbarMenuExtra(it.toString()))
}
Unit
}
else -> { else -> {
this.toEvent()?.also { this.toEvent()?.also {
track(it) track(it)
@ -233,10 +242,6 @@ internal class ReleaseMetricController(
} }
} }
Component.BROWSER_MENU == component && BrowserMenuFacts.Items.WEB_EXTENSION_MENU_ITEM == item -> {
metadata?.get("id")?.let { Event.AddonsOpenInToolbarMenu(it.toString()) }
}
Component.SUPPORT_WEBEXTENSIONS == component && WebExtensionFacts.Items.WEB_EXTENSIONS_INITIALIZED == item -> { Component.SUPPORT_WEBEXTENSIONS == component && WebExtensionFacts.Items.WEB_EXTENSIONS_INITIALIZED == item -> {
metadata?.get("installed")?.let { installedAddons -> metadata?.get("installed")?.let { installedAddons ->
if (installedAddons is List<*>) { if (installedAddons is List<*>) {

@ -33,20 +33,19 @@ import mozilla.components.concept.sync.AccountObserver
import mozilla.components.concept.sync.AuthType import mozilla.components.concept.sync.AuthType
import mozilla.components.concept.sync.OAuthAccount import mozilla.components.concept.sync.OAuthAccount
import mozilla.components.concept.sync.Profile import mozilla.components.concept.sync.Profile
import mozilla.components.service.glean.private.NoExtras
import mozilla.components.support.ktx.android.view.showKeyboard import mozilla.components.support.ktx.android.view.showKeyboard
import mozilla.telemetry.glean.private.NoExtras
import org.mozilla.fenix.BrowserDirection import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.Config import org.mozilla.fenix.Config
import org.mozilla.fenix.GleanMetrics.Addons
import org.mozilla.fenix.GleanMetrics.Events import org.mozilla.fenix.GleanMetrics.Events
import org.mozilla.fenix.GleanMetrics.TrackingProtection import org.mozilla.fenix.GleanMetrics.TrackingProtection
import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.databinding.AmoCollectionOverrideDialogBinding import org.mozilla.fenix.databinding.AmoCollectionOverrideDialogBinding
import org.mozilla.fenix.ext.application import org.mozilla.fenix.ext.application
import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.getPreferenceKey import org.mozilla.fenix.ext.getPreferenceKey
import org.mozilla.fenix.ext.metrics
import org.mozilla.fenix.ext.navigateToNotificationsSettings import org.mozilla.fenix.ext.navigateToNotificationsSettings
import org.mozilla.fenix.ext.requireComponents import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.settings
@ -280,7 +279,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
SettingsFragmentDirections.actionSettingsFragmentToLocaleSettingsFragment() SettingsFragmentDirections.actionSettingsFragmentToLocaleSettingsFragment()
} }
resources.getString(R.string.pref_key_addons) -> { resources.getString(R.string.pref_key_addons) -> {
requireContext().metrics.track(Event.AddonsOpenInSettings) Addons.openAddonsInSettings.record(mozilla.components.service.glean.private.NoExtras())
SettingsFragmentDirections.actionSettingsFragmentToAddonsFragment() SettingsFragmentDirections.actionSettingsFragmentToAddonsFragment()
} }
resources.getString(R.string.pref_key_data_choices) -> { resources.getString(R.string.pref_key_data_choices) -> {

@ -6,14 +6,12 @@ package org.mozilla.fenix.components.metrics
import mozilla.components.service.glean.testing.GleanTestRule import mozilla.components.service.glean.testing.GleanTestRule
import mozilla.components.support.test.robolectric.testContext import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue import org.junit.Assert.assertTrue
import org.junit.Before import org.junit.Before
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.mozilla.fenix.GleanMetrics.Addons
import org.mozilla.fenix.GleanMetrics.Awesomebar import org.mozilla.fenix.GleanMetrics.Awesomebar
import org.mozilla.fenix.GleanMetrics.CreditCards import org.mozilla.fenix.GleanMetrics.CreditCards
import org.mozilla.fenix.GleanMetrics.RecentBookmarks import org.mozilla.fenix.GleanMetrics.RecentBookmarks
@ -67,33 +65,6 @@ class GleanMetricsServiceTest {
assertTrue(Awesomebar.openedTabSuggestionClicked.testHasValue()) assertTrue(Awesomebar.openedTabSuggestionClicked.testHasValue())
} }
@Test
fun `Addon events are correctly recorded`() {
assertFalse(Addons.openAddonsInSettings.testHasValue())
gleanService.track(Event.AddonsOpenInSettings)
assertTrue(Addons.openAddonsInSettings.testHasValue())
assertFalse(Addons.openAddonInToolbarMenu.testHasValue())
gleanService.track(Event.AddonsOpenInToolbarMenu("123"))
assertTrue(Addons.openAddonInToolbarMenu.testHasValue())
var events = Addons.openAddonInToolbarMenu.testGetValue()
assertEquals(1, events.size)
assertEquals("addons", events[0].category)
assertEquals("open_addon_in_toolbar_menu", events[0].name)
assertEquals(1, events[0].extra!!.size)
assertEquals("123", events[0].extra!!["addon_id"])
assertFalse(Addons.openAddonSetting.testHasValue())
gleanService.track(Event.AddonOpenSetting("123"))
assertTrue(Addons.openAddonSetting.testHasValue())
events = Addons.openAddonSetting.testGetValue()
assertEquals(1, events.size)
assertEquals("addons", events[0].category)
assertEquals("open_addon_setting", events[0].name)
assertEquals(1, events[0].extra!!.size)
assertEquals("123", events[0].extra!!["addon_id"])
}
@Test @Test
fun `Home screen recent bookmarks events are correctly recorded`() { fun `Home screen recent bookmarks events are correctly recorded`() {
assertFalse(RecentBookmarks.shown.testHasValue()) assertFalse(RecentBookmarks.shown.testHasValue())

Loading…
Cancel
Save