Commit 27dff7ac authored by MozLando's avatar MozLando
Browse files

Merge #5581



5581: FennecMigrator: Notify Glean about whether telemetry should be collected after migrating Fennec setting. r=grigoryk a=pocmo



Co-authored-by: default avatarSebastian Kaspari <s.kaspari@gmail.com>
parents b0a21ff0 8c4a25b7
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import mozilla.components.browser.storage.sync.PlacesHistoryStorage
import mozilla.components.concept.engine.Engine
import mozilla.components.lib.crash.CrashReporter
import mozilla.components.service.fxa.manager.FxaAccountManager
import mozilla.components.service.glean.Glean
import mozilla.components.service.sync.logins.AsyncLoginsStorage
import mozilla.components.support.base.log.logger.Logger
import mozilla.components.support.migration.FennecMigrator.Builder
@@ -835,6 +836,19 @@ class FennecMigrator private constructor(
            return Result.Failure(e)
        }

        if (
            result is Result.Success<SettingsMigrationResult> &&
            result.value is SettingsMigrationResult.Success.SettingsMigrated
        ) {
            logger.info("Preferences migrated, telemetry should be: " + result.value.telemetry)

            // We let Glean immediately know about the updated telemetry value. We expect it to
            // have been initialized with telemetry OFF earlier and so we may enable it here
            // because further migration code will try to send telemetry pings too - and this
            // will happen before we hand off to the app again to continue and enable telemetry.
            Glean.setUploadEnabled(result.value.telemetry)
        }

        if (result is Result.Failure<SettingsMigrationResult>) {
            val migrationFailureWrapper = result.throwables.first() as SettingsMigrationException
            return when (val failure = migrationFailureWrapper.failure) {