Skip to content

Commit

Permalink
Sentry Filtering (#1138)
Browse files Browse the repository at this point in the history
* Add the ability to filter sentry events.

* cleanup

* Add SSL errors to ignore list.

* Bump Sentry dependency.
  • Loading branch information
JBassett committed Nov 3, 2020
1 parent 783fb9c commit a4f8ac5
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 7 deletions.
2 changes: 0 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,12 @@ android {
buildTypes {
named("debug").configure {
applicationIdSuffix = ".debug"
manifestPlaceholders["sentryEnabled"] = "false"
}
named("release").configure {
isDebuggable = false
isJniDebuggable = false
isZipAlignEnabled = true
signingConfig = signingConfigs.getByName("release")
manifestPlaceholders["sentryEnabled"] = "true"
}
}
flavorDimensions("version")
Expand Down
5 changes: 1 addition & 4 deletions app/src/full/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@

<application
android:name=".HomeAssistantApplication" >
<meta-data android:name="io.sentry.auto-init" android:value="${sentryEnabled}" />
<meta-data android:name="io.sentry.auto-init" android:value="false" />
<meta-data android:name="io.sentry.release" android:value="${sentryRelease}" />
<meta-data android:name="io.sentry.session-tracking.enable" android:value="true" />
<meta-data android:name="io.sentry.ndk.enable" android:value="false" />
<meta-data android:name="io.sentry.dsn" android:value="https://2d646f40f9574e0b9579e301a69bb030@o427061.ingest.sentry.io/5372876" />

<receiver
android:name=".notifications.NotificationActionReceiver"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.homeassistant.companion.android

import android.content.Context
import io.sentry.android.core.SentryAndroid
import java.net.ConnectException
import java.net.SocketTimeoutException
import java.net.UnknownHostException
import javax.net.ssl.SSLException
import javax.net.ssl.SSLHandshakeException
import javax.net.ssl.SSLProtocolException

fun initCrashReporting(context: Context) {
// Don't init on debug builds
if (BuildConfig.DEBUG)
return

SentryAndroid.init(context) { options ->
options.isEnableSessionTracking = true
options.isEnableNdk = false
options.dsn = "https://2d646f40f9574e0b9579e301a69bb030@o427061.ingest.sentry.io/5372876"
options.setBeforeSend { event, hint ->
return@setBeforeSend when (hint) {
is ConnectException,
is SocketTimeoutException,
is SSLException,
is SSLHandshakeException,
is SSLProtocolException,
is UnknownHostException -> null
else -> event
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ open class HomeAssistantApplication : Application(), GraphComponentAccessor {
override fun onCreate() {
super.onCreate()

initCrashReporting(applicationContext)

graph = Graph(this, 0)

val sensorReceiver = SensorReceiver()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.homeassistant.companion.android

import android.content.Context

fun initCrashReporting(context: Context) {
// Noop
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ object Config {
}

object Misc {
const val sentry = "io.sentry:sentry-android:2.2.2"
const val sentry = "io.sentry:sentry-android:3.1.0"
const val jackson = "com.fasterxml.jackson.module:jackson-module-kotlin:2.11.3"
const val blurView = "com.eightbitlab:blurview:1.6.3"
const val iconDialog = "com.maltaisn:icondialog:3.3.0"
Expand Down

0 comments on commit a4f8ac5

Please sign in to comment.