Commit 3125a002 authored by Matthew Finkel's avatar Matthew Finkel
Browse files

Merge branch 'bug_40212_2' into 'tor-browser-99.0.0b3-11.5-1'

Bug 40212: Disable more telemetry (especially, since it caused crashes)

See merge request !148
parents 14c96c7e 7bdfdab5
Pipeline #39108 failed with stages
......@@ -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})")
......
......@@ -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
......@@ -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())
......@@ -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)
......@@ -1029,10 +1039,12 @@ class GleanMetricsService(
}
override fun track(event: Event) {
event.wrapper?.track(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
}
}
......@@ -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 {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment