Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sentry Filtering #1138

Merged
merged 4 commits into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see now, disregard my deleted comment lol

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we include HTTPException?

Because of how the dependencies are setup we can't right now, but we can explore in the future.

Sentry also has their ANR issues that I am not sure if we need them?

ANR (App not responding) are events we should investigate further. Most likely means we are doing something on the main thread we shouldn't be.

}
}
}
}
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