diff --git a/app/src/main/java/org/mozilla/fenix/FenixApplication.kt b/app/src/main/java/org/mozilla/fenix/FenixApplication.kt index e0e3e883d..afc5fe689 100644 --- a/app/src/main/java/org/mozilla/fenix/FenixApplication.kt +++ b/app/src/main/java/org/mozilla/fenix/FenixApplication.kt @@ -91,13 +91,6 @@ open class FenixApplication : Application() { } private fun setupCrashReporting() { - @Suppress("ConstantConditionIf") - if (!BuildConfig.CRASH_REPORTING || BuildConfig.BUILD_TYPE != "release") { - // Only enable crash reporting if this is a release build and if crash reporting was explicitly enabled - // via a Gradle command line flag. - return - } - components .analytics .crashReporter diff --git a/app/src/main/java/org/mozilla/fenix/components/Analytics.kt b/app/src/main/java/org/mozilla/fenix/components/Analytics.kt index 4588ad6f8..561f7856b 100644 --- a/app/src/main/java/org/mozilla/fenix/components/Analytics.kt +++ b/app/src/main/java/org/mozilla/fenix/components/Analytics.kt @@ -9,6 +9,7 @@ import android.app.PendingIntent import android.content.Context import android.content.Intent import mozilla.components.lib.crash.CrashReporter +import mozilla.components.lib.crash.service.CrashReporterService import mozilla.components.lib.crash.service.MozillaSocorroService import mozilla.components.lib.crash.service.SentryService import org.mozilla.fenix.BuildConfig @@ -28,14 +29,21 @@ class Analytics( private val context: Context ) { val crashReporter: CrashReporter by lazy { - val sentryService = SentryService( - context, - BuildConfig.SENTRY_TOKEN, - tags = mapOf("geckoview" to "$MOZ_APP_VERSION-$MOZ_APP_BUILDID"), - sendEventForNativeCrashes = true - ) + var services = listOf() - val socorroService = MozillaSocorroService(context, "Fenix") + if (!BuildConfig.SENTRY_TOKEN.isNullOrEmpty()) { + val sentryService = SentryService( + context, + BuildConfig.SENTRY_TOKEN, + tags = mapOf("geckoview" to "$MOZ_APP_VERSION-$MOZ_APP_BUILDID"), + sendEventForNativeCrashes = true + ) + + services += sentryService + } + + val socorroService = MozillaSocorroService(context, context.getString(R.string.app_name)) + services += socorroService val intent = Intent(context, HomeActivity::class.java).apply { flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP @@ -49,7 +57,7 @@ class Analytics( ) CrashReporter( - services = listOf(sentryService, socorroService), + services = services, shouldPrompt = CrashReporter.Prompt.ALWAYS, promptConfiguration = CrashReporter.PromptConfiguration( appName = context.getString(R.string.app_name), diff --git a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt index b09845c82..2041f8eca 100644 --- a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt +++ b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt @@ -8,6 +8,7 @@ import android.content.Context import android.content.SharedPreferences import android.preference.PreferenceManager import mozilla.components.feature.sitepermissions.SitePermissionsRules +import org.mozilla.fenix.BuildConfig import org.mozilla.fenix.R import org.mozilla.fenix.ext.getPreferenceKey import java.security.InvalidParameterException @@ -42,7 +43,8 @@ class Settings private constructor(context: Context) { get() = preferences.getString(appContext.getPreferenceKey(R.string.pref_key_search_engine), "") ?: "" val isCrashReportingEnabled: Boolean - get() = preferences.getBoolean(appContext.getPreferenceKey(R.string.pref_key_crash_reporter), true) + get() = preferences.getBoolean(appContext.getPreferenceKey(R.string.pref_key_crash_reporter), true) && + BuildConfig.CRASH_REPORTING && BuildConfig.BUILD_TYPE == "release" val isRemoteDebuggingEnabled: Boolean get() = preferences.getBoolean(appContext.getPreferenceKey(R.string.pref_key_remote_debugging), false)