For #24761: Remove wrapper from autoplay settings metrics.

pull/543/head
mcarare 2 years ago committed by mergify[bot]
parent 44fa899154
commit 68f71c6f1d

@ -6185,7 +6185,8 @@ autoplay:
autoplay_setting: autoplay_setting:
description: | description: |
The new setting for autoplay: block_cellular, The new setting for autoplay: block_cellular,
block_audio, or block_all. block_audio, allow_all or block_all.
type: string
bugs: bugs:
- https://github.com/mozilla-mobile/fenix/issues/11579 - https://github.com/mozilla-mobile/fenix/issues/11579
data_reviews: data_reviews:

@ -4,9 +4,7 @@
package org.mozilla.fenix.components.metrics package org.mozilla.fenix.components.metrics
import org.mozilla.fenix.GleanMetrics.Autoplay
import org.mozilla.fenix.GleanMetrics.SearchTerms import org.mozilla.fenix.GleanMetrics.SearchTerms
import java.util.Locale
sealed class Event { sealed class Event {
@ -63,17 +61,6 @@ sealed class Event {
get() = keyName get() = keyName
} }
object AutoPlaySettingVisited : Event()
data class AutoPlaySettingChanged(val setting: AutoplaySetting) : Event() {
enum class AutoplaySetting {
BLOCK_CELLULAR, BLOCK_AUDIO, BLOCK_ALL, ALLOW_ALL
}
override val extras: Map<Autoplay.settingChangedKeys, String>?
get() = mapOf(Autoplay.settingChangedKeys.autoplaySetting to setting.toString().lowercase(Locale.ROOT))
}
data class SearchTermGroupCount(val count: Int) : Event() { data class SearchTermGroupCount(val count: Int) : Event() {
override val extras: Map<SearchTerms.numberOfSearchTermGroupKeys, String> override val extras: Map<SearchTerms.numberOfSearchTermGroupKeys, String>
get() = hashMapOf(SearchTerms.numberOfSearchTermGroupKeys.count to count.toString()) get() = hashMapOf(SearchTerms.numberOfSearchTermGroupKeys.count to count.toString())

@ -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.Autoplay
import org.mozilla.fenix.GleanMetrics.Awesomebar import org.mozilla.fenix.GleanMetrics.Awesomebar
import org.mozilla.fenix.GleanMetrics.BrowserSearch import org.mozilla.fenix.GleanMetrics.BrowserSearch
import org.mozilla.fenix.GleanMetrics.HomeMenu import org.mozilla.fenix.GleanMetrics.HomeMenu
@ -83,13 +82,6 @@ private val Event.wrapper: EventWrapper<*>?
} }
) )
is Event.AutoPlaySettingVisited -> EventWrapper<NoExtraKeys>(
{ Autoplay.visitedSetting.record(it) }
)
is Event.AutoPlaySettingChanged -> EventWrapper(
{ Autoplay.settingChanged.record(it) },
{ Autoplay.settingChangedKeys.valueOf(it) }
)
is Event.ProgressiveWebAppOpenFromHomescreenTap -> EventWrapper<NoExtraKeys>( is Event.ProgressiveWebAppOpenFromHomescreenTap -> EventWrapper<NoExtraKeys>(
{ ProgressiveWebApp.homescreenTap.record(it) } { ProgressiveWebApp.homescreenTap.record(it) }
) )

@ -9,10 +9,10 @@ import androidx.navigation.Navigation
import androidx.preference.Preference import androidx.preference.Preference
import androidx.preference.Preference.OnPreferenceClickListener import androidx.preference.Preference.OnPreferenceClickListener
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import mozilla.components.service.glean.private.NoExtras
import org.mozilla.fenix.GleanMetrics.Autoplay
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.getPreferenceKey import org.mozilla.fenix.ext.getPreferenceKey
import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.ext.showToolbar import org.mozilla.fenix.ext.showToolbar
import org.mozilla.fenix.settings.PhoneFeature import org.mozilla.fenix.settings.PhoneFeature
@ -73,7 +73,7 @@ class SitePermissionsFragment : PreferenceFragmentCompat() {
.actionSitePermissionsToManagePhoneFeatures(phoneFeature) .actionSitePermissionsToManagePhoneFeatures(phoneFeature)
if (phoneFeature == PhoneFeature.AUTOPLAY_AUDIBLE) { if (phoneFeature == PhoneFeature.AUTOPLAY_AUDIBLE) {
requireComponents.analytics.metrics.track(Event.AutoPlaySettingVisited) Autoplay.visitedSetting.record(NoExtras())
} }
Navigation.findNavController(requireView()).navigate(directions) Navigation.findNavController(requireView()).navigate(directions)

@ -24,11 +24,10 @@ import androidx.navigation.fragment.navArgs
import mozilla.components.feature.sitepermissions.SitePermissionsRules import mozilla.components.feature.sitepermissions.SitePermissionsRules
import mozilla.components.feature.sitepermissions.SitePermissionsRules.Action.ALLOWED import mozilla.components.feature.sitepermissions.SitePermissionsRules.Action.ALLOWED
import mozilla.components.feature.sitepermissions.SitePermissionsRules.Action.BLOCKED import mozilla.components.feature.sitepermissions.SitePermissionsRules.Action.BLOCKED
import org.mozilla.fenix.GleanMetrics.Autoplay
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.databinding.FragmentManageSitePermissionsFeaturePhoneBinding import org.mozilla.fenix.databinding.FragmentManageSitePermissionsFeaturePhoneBinding
import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.ext.showToolbar import org.mozilla.fenix.ext.showToolbar
import org.mozilla.fenix.settings.PhoneFeature import org.mozilla.fenix.settings.PhoneFeature
@ -43,6 +42,13 @@ const val AUTOPLAY_BLOCK_AUDIBLE = 1
const val AUTOPLAY_ALLOW_ON_WIFI = 2 const val AUTOPLAY_ALLOW_ON_WIFI = 2
const val AUTOPLAY_ALLOW_ALL = 3 const val AUTOPLAY_ALLOW_ALL = 3
/**
* Possible values for autoplay setting changed extra key.
*/
enum class AutoplaySettingMetricsExtraKey {
BLOCK_CELLULAR, BLOCK_AUDIO, BLOCK_ALL, ALLOW_ALL
}
@SuppressWarnings("TooManyFunctions") @SuppressWarnings("TooManyFunctions")
class SitePermissionsManagePhoneFeatureFragment : Fragment() { class SitePermissionsManagePhoneFeatureFragment : Fragment() {
@ -190,29 +196,27 @@ class SitePermissionsManagePhoneFeatureFragment : Fragment() {
*/ */
private fun saveActionInSettings(autoplaySetting: Int) { private fun saveActionInSettings(autoplaySetting: Int) {
settings.setAutoplayUserSetting(autoplaySetting) settings.setAutoplayUserSetting(autoplaySetting)
val setting: Event.AutoPlaySettingChanged.AutoplaySetting
val (audible, inaudible) = when (autoplaySetting) { val (audible, inaudible) = when (autoplaySetting) {
AUTOPLAY_ALLOW_ALL -> { AUTOPLAY_ALLOW_ALL -> {
setting = Event.AutoPlaySettingChanged.AutoplaySetting.ALLOW_ALL
ALLOWED to ALLOWED ALLOWED to ALLOWED
} }
AUTOPLAY_ALLOW_ON_WIFI -> { AUTOPLAY_ALLOW_ON_WIFI -> {
setting = Event.AutoPlaySettingChanged.AutoplaySetting.BLOCK_CELLULAR
BLOCKED to BLOCKED BLOCKED to BLOCKED
} }
AUTOPLAY_BLOCK_AUDIBLE -> { AUTOPLAY_BLOCK_AUDIBLE -> {
setting = Event.AutoPlaySettingChanged.AutoplaySetting.BLOCK_AUDIO
BLOCKED to ALLOWED BLOCKED to ALLOWED
} }
AUTOPLAY_BLOCK_ALL -> { AUTOPLAY_BLOCK_ALL -> {
setting = Event.AutoPlaySettingChanged.AutoplaySetting.BLOCK_ALL
BLOCKED to BLOCKED BLOCKED to BLOCKED
} }
else -> return else -> return
} }
requireComponents.analytics.metrics.track(Event.AutoPlaySettingChanged(setting)) autoplaySetting.toAutoplayMetricsExtraKey()?.let { extraKey ->
Autoplay.settingChanged.record(Autoplay.SettingChangedExtra(extraKey))
}
settings.setSitePermissionsPhoneFeatureAction(AUTOPLAY_AUDIBLE, audible) settings.setSitePermissionsPhoneFeatureAction(AUTOPLAY_AUDIBLE, audible)
settings.setSitePermissionsPhoneFeatureAction(AUTOPLAY_INAUDIBLE, inaudible) settings.setSitePermissionsPhoneFeatureAction(AUTOPLAY_INAUDIBLE, inaudible)
context?.components?.useCases?.sessionUseCases?.reload?.invoke() context?.components?.useCases?.sessionUseCases?.reload?.invoke()
@ -269,4 +273,17 @@ class SitePermissionsManagePhoneFeatureFragment : Fragment() {
this this
} }
} }
/**
* Returns a [AutoplaySettingMetricsExtraKey] from an AUTOPLAY setting value.
*/
private fun Int.toAutoplayMetricsExtraKey(): String? {
return when (this) {
AUTOPLAY_BLOCK_ALL -> AutoplaySettingMetricsExtraKey.BLOCK_ALL.name.lowercase()
AUTOPLAY_BLOCK_AUDIBLE -> AutoplaySettingMetricsExtraKey.BLOCK_AUDIO.name.lowercase()
AUTOPLAY_ALLOW_ON_WIFI -> AutoplaySettingMetricsExtraKey.BLOCK_CELLULAR.name.lowercase()
AUTOPLAY_ALLOW_ALL -> AutoplaySettingMetricsExtraKey.ALLOW_ALL.name.lowercase()
else -> null
}
}
} }

@ -199,8 +199,6 @@
<ID>UndocumentedPublicClass:Event.kt$Event$AndroidAutofillSearchItemSelected : Event</ID> <ID>UndocumentedPublicClass:Event.kt$Event$AndroidAutofillSearchItemSelected : Event</ID>
<ID>UndocumentedPublicClass:Event.kt$Event$AndroidAutofillUnlockCanceled : Event</ID> <ID>UndocumentedPublicClass:Event.kt$Event$AndroidAutofillUnlockCanceled : Event</ID>
<ID>UndocumentedPublicClass:Event.kt$Event$AndroidAutofillUnlockSuccessful : Event</ID> <ID>UndocumentedPublicClass:Event.kt$Event$AndroidAutofillUnlockSuccessful : Event</ID>
<ID>UndocumentedPublicClass:Event.kt$Event$AutoPlaySettingChanged : Event</ID>
<ID>UndocumentedPublicClass:Event.kt$Event$AutoPlaySettingVisited : Event</ID>
<ID>UndocumentedPublicClass:Event.kt$Event$AverageTabsPerSearchTermGroup : Event</ID> <ID>UndocumentedPublicClass:Event.kt$Event$AverageTabsPerSearchTermGroup : Event</ID>
<ID>UndocumentedPublicClass:Event.kt$Event$BaiduTopSiteRemoved : Event</ID> <ID>UndocumentedPublicClass:Event.kt$Event$BaiduTopSiteRemoved : Event</ID>
<ID>UndocumentedPublicClass:Event.kt$Event$BookmarkClicked : Event</ID> <ID>UndocumentedPublicClass:Event.kt$Event$BookmarkClicked : Event</ID>
@ -420,7 +418,6 @@
<ID>UndocumentedPublicClass:Event.kt$Event$WallpaperSettingsOpened : Event</ID> <ID>UndocumentedPublicClass:Event.kt$Event$WallpaperSettingsOpened : Event</ID>
<ID>UndocumentedPublicClass:Event.kt$Event$WallpaperSwitched : Event</ID> <ID>UndocumentedPublicClass:Event.kt$Event$WallpaperSwitched : Event</ID>
<ID>UndocumentedPublicClass:Event.kt$Event$WhatsNewTapped : Event</ID> <ID>UndocumentedPublicClass:Event.kt$Event$WhatsNewTapped : Event</ID>
<ID>UndocumentedPublicClass:Event.kt$Event.AutoPlaySettingChanged$AutoplaySetting</ID>
<ID>UndocumentedPublicClass:Event.kt$Event.BrowserMenuItemTapped$Item</ID> <ID>UndocumentedPublicClass:Event.kt$Event.BrowserMenuItemTapped$Item</ID>
<ID>UndocumentedPublicClass:Event.kt$Event.DarkThemeSelected$Source</ID> <ID>UndocumentedPublicClass:Event.kt$Event.DarkThemeSelected$Source</ID>
<ID>UndocumentedPublicClass:Event.kt$Event.Messaging$MessageClicked : Messaging</ID> <ID>UndocumentedPublicClass:Event.kt$Event.Messaging$MessageClicked : Messaging</ID>

Loading…
Cancel
Save