Closes #7762: Initialize Glean later in Fennec builds.
parent
40e72a7b28
commit
18244cef51
|
@ -57,6 +57,9 @@ enum class ReleaseChannel {
|
||||||
|
|
||||||
val isFennec: Boolean
|
val isFennec: Boolean
|
||||||
get() = this in fennecChannels
|
get() = this in fennecChannels
|
||||||
|
|
||||||
|
val isFenix: Boolean
|
||||||
|
get() = !isFennec
|
||||||
}
|
}
|
||||||
|
|
||||||
object Config {
|
object Config {
|
||||||
|
|
|
@ -59,21 +59,22 @@ open class FenixApplication : LocaleAwareApplication() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need to always initialize Glean and do it early here.
|
if (Config.channel.isFenix) {
|
||||||
// It is important that this initialization happens *here* before calling into
|
// We need to always initialize Glean and do it early here.
|
||||||
// setupInMainProcessOnly() which behaves differently for fenix and fennec builds.
|
// Note that we are only initializing Glean here for "fenix" builds. "fennec" builds
|
||||||
val enableGlean = if (Config.channel.isFennec) {
|
// will initialize in MigratingFenixApplication because we first need to migrate the
|
||||||
// We are disabling Glean here because for Fennec builds we may not know yet whether
|
// user's choice from Fennec.
|
||||||
// we can enable telemetry yet. We first need to migrate the setting from Fennec to
|
initializeGlean()
|
||||||
// know the user's choice. The blocking migration in `MigratingFenixApplication` will
|
|
||||||
// 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})")
|
|
||||||
|
setupInMainProcessOnly()
|
||||||
|
}
|
||||||
|
|
||||||
|
protected fun initializeGlean() {
|
||||||
|
val telemetryEnabled = settings().isTelemetryEnabled
|
||||||
|
|
||||||
|
logger.debug("Initializing Glean (uploadEnabled=$telemetryEnabled, isFennec=${Config.channel.isFennec})")
|
||||||
|
|
||||||
Glean.initialize(
|
Glean.initialize(
|
||||||
applicationContext = this,
|
applicationContext = this,
|
||||||
configuration = Configuration(
|
configuration = Configuration(
|
||||||
|
@ -81,10 +82,8 @@ open class FenixApplication : LocaleAwareApplication() {
|
||||||
httpClient = ConceptFetchHttpUploader(
|
httpClient = ConceptFetchHttpUploader(
|
||||||
lazy(LazyThreadSafetyMode.NONE) { components.core.client }
|
lazy(LazyThreadSafetyMode.NONE) { components.core.client }
|
||||||
)),
|
)),
|
||||||
uploadEnabled = enableGlean
|
uploadEnabled = telemetryEnabled
|
||||||
)
|
)
|
||||||
|
|
||||||
setupInMainProcessOnly()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@CallSuper
|
@CallSuper
|
||||||
|
|
|
@ -38,6 +38,10 @@ class MigratingFenixApplication : FenixApplication() {
|
||||||
// These migrations need to run before regular initialization happens.
|
// These migrations need to run before regular initialization happens.
|
||||||
migrateBlocking()
|
migrateBlocking()
|
||||||
|
|
||||||
|
// Now that we have migrated from Fennec whether the user wants to enable telemetry we can
|
||||||
|
// initialize Glean
|
||||||
|
initializeGlean()
|
||||||
|
|
||||||
// Fenix application initialization can happen now.
|
// Fenix application initialization can happen now.
|
||||||
super.setupInMainProcessOnly()
|
super.setupInMainProcessOnly()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue