1
0
Fork 0

Fixes #1219: Display crash reporter (without reporting) on all builds

master
Sawyer Blatz 2019-03-27 11:04:00 -07:00 committed by Colin Lee
parent 15888eb106
commit edc9d31729
3 changed files with 19 additions and 16 deletions

View File

@ -91,13 +91,6 @@ open class FenixApplication : Application() {
} }
private fun setupCrashReporting() { 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 components
.analytics .analytics
.crashReporter .crashReporter

View File

@ -9,6 +9,7 @@ import android.app.PendingIntent
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import mozilla.components.lib.crash.CrashReporter 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.MozillaSocorroService
import mozilla.components.lib.crash.service.SentryService import mozilla.components.lib.crash.service.SentryService
import org.mozilla.fenix.BuildConfig import org.mozilla.fenix.BuildConfig
@ -28,14 +29,21 @@ class Analytics(
private val context: Context private val context: Context
) { ) {
val crashReporter: CrashReporter by lazy { val crashReporter: CrashReporter by lazy {
val sentryService = SentryService( var services = listOf<CrashReporterService>()
context,
BuildConfig.SENTRY_TOKEN,
tags = mapOf("geckoview" to "$MOZ_APP_VERSION-$MOZ_APP_BUILDID"),
sendEventForNativeCrashes = true
)
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 { val intent = Intent(context, HomeActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
@ -49,7 +57,7 @@ class Analytics(
) )
CrashReporter( CrashReporter(
services = listOf(sentryService, socorroService), services = services,
shouldPrompt = CrashReporter.Prompt.ALWAYS, shouldPrompt = CrashReporter.Prompt.ALWAYS,
promptConfiguration = CrashReporter.PromptConfiguration( promptConfiguration = CrashReporter.PromptConfiguration(
appName = context.getString(R.string.app_name), appName = context.getString(R.string.app_name),

View File

@ -8,6 +8,7 @@ import android.content.Context
import android.content.SharedPreferences import android.content.SharedPreferences
import android.preference.PreferenceManager import android.preference.PreferenceManager
import mozilla.components.feature.sitepermissions.SitePermissionsRules import mozilla.components.feature.sitepermissions.SitePermissionsRules
import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.ext.getPreferenceKey import org.mozilla.fenix.ext.getPreferenceKey
import java.security.InvalidParameterException 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), "") ?: "" get() = preferences.getString(appContext.getPreferenceKey(R.string.pref_key_search_engine), "") ?: ""
val isCrashReportingEnabled: Boolean 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 val isRemoteDebuggingEnabled: Boolean
get() = preferences.getBoolean(appContext.getPreferenceKey(R.string.pref_key_remote_debugging), false) get() = preferences.getBoolean(appContext.getPreferenceKey(R.string.pref_key_remote_debugging), false)