Bug 1841262 — Add coenrolling features to NimbusBuilder

This commit refactors the android-components implementations of `NimbusBuilder`
and `Nimbus` to accommodate the new `getCoenrollingFeatureIds()` API.

This API is internal to Application Services, but needs to be passed in
via the constructor of the Nimbus object.
fenix/117.0
James Hugman 11 months ago committed by mergify[bot]
parent 158029070d
commit 0c4947c08b

@ -8,7 +8,6 @@ import android.content.Context
import mozilla.components.service.nimbus.NimbusApi
import mozilla.components.service.nimbus.NimbusAppInfo
import mozilla.components.service.nimbus.NimbusBuilder
import mozilla.components.service.nimbus.loggingErrorReporter
import mozilla.components.service.nimbus.messaging.FxNimbusMessaging
import mozilla.components.service.nimbus.messaging.NimbusSystem
import mozilla.components.support.base.log.logger.Logger
@ -30,6 +29,8 @@ import org.mozilla.fenix.utils.Settings
*/
private const val TIME_OUT_LOADING_EXPERIMENT_FROM_DISK_MS = 200L
private val logger = Logger("service/Nimbus")
/**
* Create the Nimbus singleton object for the Fenix app.
*/
@ -59,35 +60,32 @@ fun createNimbus(context: Context, urlString: String?): NimbusApi {
return NimbusBuilder(context).apply {
url = urlString
errorReporter = { message, e ->
if (BuildConfig.BUILD_TYPE == "debug") {
Logger.error("Nimbus error: $message", e)
}
if (e !is NimbusException || e.isReportableError()) {
@Suppress("TooGenericExceptionCaught")
try {
context.components.analytics.crashReporter.submitCaughtException(e)
} catch (e: Throwable) {
loggingErrorReporter(message, e)
}
}
}
errorReporter = context::reportError
initialExperiments = R.raw.initial_experiments
timeoutLoadingExperiment = TIME_OUT_LOADING_EXPERIMENT_FROM_DISK_MS
usePreviewCollection = context.settings().nimbusUsePreview
isFirstRun = isAppFirstRun
onCreateCallback = { nimbus ->
FxNimbus.initialize { nimbus }
}
onApplyCallback = {
FxNimbus.invalidateCachedValues()
}
onFetchedCallback = {
featureManifest = FxNimbus
onFetchCallback = {
context.settings().nimbusExperimentsFetched = true
}
}.build(appInfo)
}
private fun Context.reportError(message: String, e: Throwable) {
if (BuildConfig.BUILD_TYPE == "debug") {
logger.error("Nimbus error: $message", e)
}
if (e !is NimbusException || e.isReportableError()) {
@Suppress("TooGenericExceptionCaught")
try {
this.components.analytics.crashReporter.submitCaughtException(e)
} catch (e: Throwable) {
logger.error(message, e)
}
}
}
/**
* Classifies which errors we should forward to our crash reporter or not. We want to filter out the
* non-reportable ones if we know there is no reasonable action that we can perform.

Loading…
Cancel
Save