For #17644: Record when user taps on a add-on's setting (#18504)

upstream-sync
Roger Yang 3 years ago committed by GitHub
parent fc220da336
commit 34a7bc0baa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -3938,6 +3938,23 @@ addons:
notification_emails:
- fenix-core@mozilla.com
expires: "2021-07-01"
open_addon_setting:
type: event
description: |
A user opened an add-on's setting
extra_keys:
addon_id:
description: |
The id of the add-on that was interacted with
bugs:
- https://github.com/mozilla-mobile/fenix/issues/17644
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/18504
data_sensitivity:
- interaction
notification_emails:
- fenix-core@mozilla.com
expires: "2022-08-01"
has_installed_addons:
type: boolean
description: |

@ -24,6 +24,7 @@ import mozilla.components.feature.addons.ui.translateName
import org.mozilla.fenix.GleanMetrics.Addons
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.showToolbar
import org.mozilla.fenix.ext.runIfFragmentIsAttached
@ -196,6 +197,9 @@ class InstalledAddonDetailsFragment : Fragment() {
view.settings.apply {
isVisible = shouldSettingsBeVisible()
setOnClickListener {
requireContext().components.analytics.metrics.track(
Event.AddonOpenSetting(addon.id)
)
val settingUrl = addon.installedState?.optionsPageUrl ?: return@setOnClickListener
val directions = if (addon.installedState?.openOptionsPageInTab == true) {
val components = it.context.components

@ -325,6 +325,11 @@ sealed class Event {
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 TipDisplayed(val identifier: String) : Event() {
override val extras: Map<Tip.displayedKeys, String>?
get() = hashMapOf(Tip.displayedKeys.identifier to identifier)

@ -586,6 +586,10 @@ private val Event.wrapper: EventWrapper<*>?
{ Addons.openAddonInToolbarMenu.record(it) },
{ Addons.openAddonInToolbarMenuKeys.valueOf(it) }
)
is Event.AddonOpenSetting -> EventWrapper(
{ Addons.openAddonSetting.record(it) },
{ Addons.openAddonSettingKeys.valueOf(it) }
)
is Event.TipDisplayed -> EventWrapper(
{ Tip.displayed.record(it) },
{ Tip.displayedKeys.valueOf(it) }

@ -159,7 +159,7 @@ class GleanMetricsServiceTest {
}
@Test
fun `bookmark events is correctly recorded`() {
fun `bookmark events are correctly recorded`() {
assertFalse(BookmarksManagement.open.testHasValue())
gleanService.track(Event.OpenedBookmark)
assertTrue(BookmarksManagement.open.testHasValue())
@ -214,7 +214,7 @@ class GleanMetricsServiceTest {
}
@Test
fun `History events is correctly recorded`() {
fun `History events are correctly recorded`() {
assertFalse(History.openedItemInNewTab.testHasValue())
gleanService.track(Event.HistoryOpenedInNewTab)
assertTrue(History.openedItemInNewTab.testHasValue())
@ -231,4 +231,31 @@ class GleanMetricsServiceTest {
gleanService.track(Event.HistoryOpenedInPrivateTabs)
assertTrue(History.openedItemsInPrivateTabs.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"])
}
}

@ -55,6 +55,7 @@ In addition to those built-in metrics, the following metrics are added to the pi
| about_page.privacy_notice_tapped |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user tapped on "Privacy notice" item from About page |[mozilla-mobile/fenix#8047](https://github.com/mozilla-mobile/fenix/pull/8047), [mozilla-mobile/fenix#13958](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877), [mozilla-mobile/fenix#18143](https://github.com/mozilla-mobile/fenix/pull/18143)||2021-07-01 |2 |
| about_page.support_tapped |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user tapped on "Support" item from About page |[mozilla-mobile/fenix#8047](https://github.com/mozilla-mobile/fenix/pull/8047), [mozilla-mobile/fenix#13958](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877), [mozilla-mobile/fenix#18143](https://github.com/mozilla-mobile/fenix/pull/18143)||2021-07-01 |2 |
| addons.open_addon_in_toolbar_menu |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user interacted with an installed add-on in the toolbar menu |[mozilla-mobile/fenix#8318](https://github.com/mozilla-mobile/fenix/pull/8318), [mozilla-mobile/fenix#13958](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877), [mozilla-mobile/fenix#18143](https://github.com/mozilla-mobile/fenix/pull/18143)|<ul><li>addon_id: The id of the add-on that was interacted with in the toolbar menu </li></ul>|2021-07-01 |2 |
| addons.open_addon_setting |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened an add-on's setting |[mozilla-mobile/fenix#18504](https://github.com/mozilla-mobile/fenix/pull/18504)|<ul><li>addon_id: The id of the add-on that was interacted with </li></ul>|2022-08-01 |2 |
| addons.open_addons_in_settings |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user accessed "Add-ons" from the Settings |[mozilla-mobile/fenix#8318](https://github.com/mozilla-mobile/fenix/pull/8318), [mozilla-mobile/fenix#13958](https://github.com/mozilla-mobile/fenix/pull/13958#issuecomment-676857877), [mozilla-mobile/fenix#18143](https://github.com/mozilla-mobile/fenix/pull/18143)||2021-07-01 |2 |
| android_keystore_experiment.experiment_failure |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |Records an instance of an unexpected failure during the experiment |[mozilla-mobile/fenix#18333](https://github.com/mozilla-mobile/fenix/pull/18333#pullrequestreview-612447395)|<ul><li>failure_exception: Exception class associated with an unexpected failure of this experiment, not caught by the other failure handlers. </li></ul>|2021-09-01 |1 |
| android_keystore_experiment.get_failure |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |Unexpected failure when trying to read from secure prefs. |[mozilla-mobile/fenix#18333](https://github.com/mozilla-mobile/fenix/pull/18333#pullrequestreview-612447395)|<ul><li>failure_exception: Exception class associated with an unexpected failure of this experiment. </li></ul>|2021-09-01 |1 |

Loading…
Cancel
Save