1
0
Fork 0

Issue #7762: Enable glean based on setting for non-fennec builds.

master
Sebastian Kaspari 2020-01-22 13:37:52 +01:00
parent 44e4d8e12c
commit 9a15103a20
1 changed files with 14 additions and 10 deletions

View File

@ -59,17 +59,21 @@ open class FenixApplication : LocaleAwareApplication() {
return return
} }
// We need to always initialize Glean and do it early here. Note that we are disabling it // We need to always initialize Glean and do it early here.
// here too (uploadEnabled = false). If needed Glean will be enabled later by the migration
// code (if this user used to be a fennec user with the right flags enabled) or by
// GleanMetricsService if telemetry is enabled for this user.
// It is important that this initialization happens *here* before calling into // It is important that this initialization happens *here* before calling into
// setupInMainProcessOnly() which behaves differently for fenix and fennec builds. // setupInMainProcessOnly() which behaves differently for fenix and fennec builds.
// Glean needs to be disabled initially because otherwise we may already collect telemetry val enableGlean = if (Config.channel.isFennec) {
// before we know whether we want that (which is *after* the migration). // We are disabling Glean here because for Fennec builds we may not know yet whether
// As a side effect this means pings submitted between the initialization here and until we // we can enable telemetry yet. We first need to migrate the setting from Fennec to
// potentially enable Glean would be lost. However such pings do not exist at this moment. // know the user's choice. The blocking migration in `MigratingFenixApplication` will
logger.debug("Initializing Glean (uploadEnabled=false)") // notify glean once the value has been migrated.
false
} else {
// We initialize Glean with telemetry enabled (or disabled) early here so that we do not
// end up loosing data for components that collect telemetry very early.
settings().isTelemetryEnabled
}
logger.debug("Initializing Glean (uploadEnabled=$enableGlean, isFennec=${Config.channel.isFennec})")
Glean.initialize( Glean.initialize(
applicationContext = this, applicationContext = this,
configuration = Configuration( configuration = Configuration(
@ -77,7 +81,7 @@ open class FenixApplication : LocaleAwareApplication() {
httpClient = ConceptFetchHttpUploader( httpClient = ConceptFetchHttpUploader(
lazy(LazyThreadSafetyMode.NONE) { components.core.client } lazy(LazyThreadSafetyMode.NONE) { components.core.client }
)), )),
uploadEnabled = false uploadEnabled = enableGlean
) )
setupInMainProcessOnly() setupInMainProcessOnly()