Loading app/src/main/java/org/mozilla/fenix/FenixApplication.kt +4 −0 Original line number Diff line number Diff line Loading @@ -157,6 +157,10 @@ open class FenixApplication : LocaleAwareApplication(), Provider { @OptIn(DelicateCoroutinesApi::class) // GlobalScope usage protected open fun initializeGlean() { val telemetryEnabled = settings().isTelemetryEnabled if (!telemetryEnabled) { logger.debug("Preventing Glean from initializing, since telemetry is disabled") return } logger.debug("Initializing Glean (uploadEnabled=$telemetryEnabled, isFennec=${Config.channel.isFennec})") Loading app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt +14 −2 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ import android.content.Context import mozilla.components.service.glean.Glean import mozilla.components.service.glean.private.NoExtraKeys import mozilla.components.support.base.log.logger.Logger import org.mozilla.fenix.BuildConfig import org.mozilla.fenix.GleanMetrics.Addons import org.mozilla.fenix.GleanMetrics.AndroidAutofill import org.mozilla.fenix.GleanMetrics.AppTheme Loading Loading @@ -85,6 +86,9 @@ private class EventWrapper<T : Enum<T>>( } fun track(event: Event) { if (BuildConfig.DATA_COLLECTION_DISABLED) { return } val extras = if (keyMapper != null) { event.extras?.mapKeys { (key) -> keyMapper.invoke(key.toString().asCamelCase()) Loading Loading @@ -1002,6 +1006,12 @@ class GleanMetricsService( private val installationPing = FirstSessionPing(context) override fun start() { if (BuildConfig.DATA_COLLECTION_DISABLED) { Logger.debug("Data collection is disabled, not initializing Glean.") initialized = true return } logger.debug("Enabling Glean.") // Initialization of Glean already happened in FenixApplication. Glean.setUploadEnabled(true) Loading Loading @@ -1029,10 +1039,12 @@ class GleanMetricsService( } override fun track(event: Event) { if (!BuildConfig.DATA_COLLECTION_DISABLED) { event.wrapper?.track(event) } } override fun shouldTrack(event: Event): Boolean { return event.wrapper != null return !BuildConfig.DATA_COLLECTION_DISABLED && event.wrapper != null } } app/src/main/java/org/mozilla/fenix/components/metrics/MetricController.kt +5 −1 Original line number Diff line number Diff line Loading @@ -151,7 +151,11 @@ internal class ReleaseMetricController( private fun isInitialized(type: MetricServiceType): Boolean = initialized.contains(type) private fun isTelemetryEnabled(@Suppress("UNUSED_PARAMETER") type: MetricServiceType): Boolean = false private fun isTelemetryEnabled(type: MetricServiceType): Boolean = !BuildConfig.DATA_COLLECTION_DISABLED && when (type) { MetricServiceType.Data -> isDataTelemetryEnabled() MetricServiceType.Marketing -> isMarketingDataTelemetryEnabled() } @Suppress("LongMethod", "MaxLineLength") private fun Fact.toEvent(): Event? = when { Loading Loading
app/src/main/java/org/mozilla/fenix/FenixApplication.kt +4 −0 Original line number Diff line number Diff line Loading @@ -157,6 +157,10 @@ open class FenixApplication : LocaleAwareApplication(), Provider { @OptIn(DelicateCoroutinesApi::class) // GlobalScope usage protected open fun initializeGlean() { val telemetryEnabled = settings().isTelemetryEnabled if (!telemetryEnabled) { logger.debug("Preventing Glean from initializing, since telemetry is disabled") return } logger.debug("Initializing Glean (uploadEnabled=$telemetryEnabled, isFennec=${Config.channel.isFennec})") Loading
app/src/main/java/org/mozilla/fenix/components/metrics/GleanMetricsService.kt +14 −2 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ import android.content.Context import mozilla.components.service.glean.Glean import mozilla.components.service.glean.private.NoExtraKeys import mozilla.components.support.base.log.logger.Logger import org.mozilla.fenix.BuildConfig import org.mozilla.fenix.GleanMetrics.Addons import org.mozilla.fenix.GleanMetrics.AndroidAutofill import org.mozilla.fenix.GleanMetrics.AppTheme Loading Loading @@ -85,6 +86,9 @@ private class EventWrapper<T : Enum<T>>( } fun track(event: Event) { if (BuildConfig.DATA_COLLECTION_DISABLED) { return } val extras = if (keyMapper != null) { event.extras?.mapKeys { (key) -> keyMapper.invoke(key.toString().asCamelCase()) Loading Loading @@ -1002,6 +1006,12 @@ class GleanMetricsService( private val installationPing = FirstSessionPing(context) override fun start() { if (BuildConfig.DATA_COLLECTION_DISABLED) { Logger.debug("Data collection is disabled, not initializing Glean.") initialized = true return } logger.debug("Enabling Glean.") // Initialization of Glean already happened in FenixApplication. Glean.setUploadEnabled(true) Loading Loading @@ -1029,10 +1039,12 @@ class GleanMetricsService( } override fun track(event: Event) { if (!BuildConfig.DATA_COLLECTION_DISABLED) { event.wrapper?.track(event) } } override fun shouldTrack(event: Event): Boolean { return event.wrapper != null return !BuildConfig.DATA_COLLECTION_DISABLED && event.wrapper != null } }
app/src/main/java/org/mozilla/fenix/components/metrics/MetricController.kt +5 −1 Original line number Diff line number Diff line Loading @@ -151,7 +151,11 @@ internal class ReleaseMetricController( private fun isInitialized(type: MetricServiceType): Boolean = initialized.contains(type) private fun isTelemetryEnabled(@Suppress("UNUSED_PARAMETER") type: MetricServiceType): Boolean = false private fun isTelemetryEnabled(type: MetricServiceType): Boolean = !BuildConfig.DATA_COLLECTION_DISABLED && when (type) { MetricServiceType.Data -> isDataTelemetryEnabled() MetricServiceType.Marketing -> isMarketingDataTelemetryEnabled() } @Suppress("LongMethod", "MaxLineLength") private fun Fact.toEvent(): Event? = when { Loading