Commit 1c41c300 authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Don't enable sentry for mars-sandbox

There were a lot of events (1k+) from this host, looks like it might be some sort of automated environment
parent 8b9217ec
...@@ -22,6 +22,7 @@ import kotlinx.coroutines.Dispatchers ...@@ -22,6 +22,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import leakcanary.LeakSentry import leakcanary.LeakSentry
import java.net.InetAddress
import java.util.* import java.util.*
import kotlin.system.exitProcess import kotlin.system.exitProcess
...@@ -97,58 +98,61 @@ class SmokeScreen : Application() { ...@@ -97,58 +98,61 @@ class SmokeScreen : Application() {
fun initSentry(forceStatus: Status = Status.NONE) { fun initSentry(forceStatus: Status = Status.NONE) {
if (!BuildConfig.DEBUG && BuildConfig.SENTRY_DSN != "dummy") { if (!BuildConfig.DEBUG && BuildConfig.SENTRY_DSN != "dummy") {
GlobalScope.launch(Dispatchers.IO) { GlobalScope.launch(Dispatchers.IO) {
val enabledType = getPreferences().crashreportingType val hostName = InetAddress.getLocalHost().hostName
if (forceStatus != Status.DATASAVING && (enabledType == Crashreporting.FULL || forceStatus == Status.ENABLED)) { if(!hostName.startsWith("mars-sandbox", true)) {
// Enable Sentry in full mode val enabledType = getPreferences().crashreportingType
// This passes some device-related data, but nothing which allows user actions to be tracked across the app if (forceStatus != Status.DATASAVING && (enabledType == Crashreporting.FULL || forceStatus == Status.ENABLED)) {
// Info: Some data is attached by the AndroidEventBuilderHelper class, which is present by default // Enable Sentry in full mode
// This passes some device-related data, but nothing which allows user actions to be tracked across the app
Sentry.init( // Info: Some data is attached by the AndroidEventBuilderHelper class, which is present by default
BuildConfig.SENTRY_DSN,
AndroidSentryClientFactory(this@SmokeScreen) Sentry.init(
) BuildConfig.SENTRY_DSN,
Sentry.getContext().user = AndroidSentryClientFactory(this@SmokeScreen)
User(getPreferences().crashReportingUUID, null, null, null)
Sentry.getStoredClient().apply {
addTag("user.language", Locale.getDefault().displayLanguage)
addTag("app.database_version", AppDatabase.currentVersion.toString())
addTag("app.dns_server_name", getPreferences().dnsServerConfig.name)
addTag(
"app.dns_server_primary",
getPreferences().dnsServerConfig.servers[0].address.formatToString()
)
addTag(
"app.dns_server_secondary",
getPreferences().dnsServerConfig.servers.getOrNull(1)?.address?.formatToString()
) )
addTag( Sentry.getContext().user =
"app.installer_package", User(getPreferences().crashReportingUUID, null, null, null)
packageManager.getInstallerPackageName(packageName) Sentry.getStoredClient().apply {
addTag("user.language", Locale.getDefault().displayLanguage)
addTag("app.database_version", AppDatabase.currentVersion.toString())
addTag("app.dns_server_name", getPreferences().dnsServerConfig.name)
addTag(
"app.dns_server_primary",
getPreferences().dnsServerConfig.servers[0].address.formatToString()
)
addTag(
"app.dns_server_secondary",
getPreferences().dnsServerConfig.servers.getOrNull(1)?.address?.formatToString()
)
addTag(
"app.installer_package",
packageManager.getInstallerPackageName(packageName)
)
addTag("richdata", "true")
addTag("app.fromCi", BuildConfig.FROM_CI.toString())
addTag("app.commit", BuildConfig.COMMIT_HASH)
}
} else if (enabledType == Crashreporting.MINIMAL || forceStatus == Status.DATASAVING) {
// Inits Sentry in datasaving mode
// Only data absolutely necessary is transmitted (Android version, app version).
// Only crashes will be reported, no regular events.
Sentry.init(
BuildConfig.SENTRY_DSN,
AndroidSentryClientFactory(this@SmokeScreen)
) )
addTag("richdata", "true") Sentry.getContext().user =
addTag("app.fromCi", BuildConfig.FROM_CI.toString()) User("anon-" + BuildConfig.VERSION_CODE, null, null, null)
addTag("app.commit", BuildConfig.COMMIT_HASH) Sentry.getStoredClient().apply {
} addTag("richdata", "false")
} else if (enabledType == Crashreporting.MINIMAL || forceStatus == Status.DATASAVING) { addTag("dist", BuildConfig.VERSION_CODE.toString())
// Inits Sentry in datasaving mode addTag("app.commit", BuildConfig.COMMIT_HASH)
// Only data absolutely necessary is transmitted (Android version, app version). addTag("app.fromCi", BuildConfig.FROM_CI.toString())
// Only crashes will be reported, no regular events. addExtra("dist", BuildConfig.VERSION_CODE)
Sentry.init( this.builderHelpers.forEach {
BuildConfig.SENTRY_DSN, this.removeBuilderHelper(it)
AndroidSentryClientFactory(this@SmokeScreen) }
) this.addBuilderHelper(DatasavingSentryEventHelper())
Sentry.getContext().user =
User("anon-" + BuildConfig.VERSION_CODE, null, null, null)
Sentry.getStoredClient().apply {
addTag("richdata", "false")
addTag("dist", BuildConfig.VERSION_CODE.toString())
addTag("app.commit", BuildConfig.COMMIT_HASH)
addTag("app.fromCi", BuildConfig.FROM_CI.toString())
addExtra("dist", BuildConfig.VERSION_CODE)
this.builderHelpers.forEach {
this.removeBuilderHelper(it)
} }
this.addBuilderHelper(DatasavingSentryEventHelper())
} }
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment