Introduce Sentry for error reporting (#1737)

This commit is contained in:
Harsh Shandilya 2022-02-20 18:58:35 +05:30
parent f6dd7e338f
commit 3d0006d610
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80
7 changed files with 47 additions and 0 deletions

View file

@ -31,6 +31,8 @@ jobs:
uses: gradle/gradle-build-action@v2.1.3
with:
arguments: --no-configuration-cache :app:assembleFreeRelease :app:assembleNonFreeRelease :app:bundleNonFreeRelease
env:
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
- name: Upload non-free release APK
uses: actions/upload-artifact@v2.3.1

View file

@ -31,6 +31,7 @@ jobs:
uses: gradle/gradle-build-action@v2.1.3
env:
SNAPSHOT: "true"
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
with:
arguments: --no-configuration-cache :app:assembleFreeRelease :app:assembleNonFreeRelease

View file

@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file.
- Allow importing QR code from images
- Introduce a new opt-in PGP backend powered by [PGPainless](https://github.com/pgpainless/pgpainless) that does not require OpenKeychain
- Add the ability to run garbage collection on the internal Git repository
- Introduce crash reporting backed by Sentry
### Fixed

View file

@ -10,6 +10,7 @@ plugins {
id("com.github.android-password-store.kotlin-android")
id("com.github.android-password-store.kotlin-kapt")
id("com.github.android-password-store.versioning-plugin")
id("com.github.android-password-store.sentry")
id("dagger.hilt.android.plugin")
}
@ -106,6 +107,7 @@ dependencies {
debugImplementation(libs.thirdparty.leakcanary)
add("nonFreeImplementation", libs.thirdparty.nonfree.googlePlayAuthApiPhone)
add("nonFreeImplementation", libs.thirdparty.nonfree.sentry)
androidTestImplementation(libs.bundles.testDependencies)
androidTestImplementation(libs.bundles.androidTestDependencies)

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
~ SPDX-License-Identifier: GPL-3.0-only
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<meta-data android:name="io.sentry.dsn" android:value="${sentryDsn}" />
<meta-data android:name="io.sentry.traces.sample-rate" android:value="0.0" />
</application>
</manifest>

View file

@ -0,0 +1,29 @@
@file:Suppress("PropertyName")
import flavors.FlavorDimensions
import flavors.ProductFlavors
plugins { id("com.android.application") }
val SENTRY_DSN_PROPERTY = "SENTRY_DSN"
val INVOKED_FROM_IDE_PROPERTY = "android.injected.invoked.from.ide"
android {
androidComponents {
onVariants(selector().withFlavor(FlavorDimensions.FREE to ProductFlavors.NON_FREE)) { variant ->
val sentryDsn =
project
.providers
.environmentVariable(SENTRY_DSN_PROPERTY)
.orElse("https://public_key@example.com/project_id")
if (sentryDsn.isPresent) {
variant.manifestPlaceholders.put("sentryDsn", sentryDsn.get())
} else if (project.providers.gradleProperty(INVOKED_FROM_IDE_PROPERTY).orNull != "true") {
// Checking for 'INVOKED_FROM_IDE_PROPERTY' prevents failures during Gradle sync by the IDE
throw GradleException(
"The '${SENTRY_DSN_PROPERTY}' environment variable must be set when building the ${ProductFlavors.NON_FREE} flavor"
)
}
}
}
}

View file

@ -83,6 +83,7 @@ thirdparty-plumber = { module = "com.squareup.leakcanary:plumber-android", versi
thirdparty-logcat = "com.squareup.logcat:logcat:0.1"
thirdparty-modernAndroidPrefs = "de.maxr1998:modernandroidpreferences:2.3.0"
thirdparty-nonfree-googlePlayAuthApiPhone = "com.google.android.gms:play-services-auth-api-phone:18.0.1"
thirdparty-nonfree-sentry = "io.sentry:sentry-android:5.6.1"
thirdparty-pgpainless = "org.pgpainless:pgpainless-core:1.1.0"
thirdparty-sshauth = "com.github.open-keychain.open-keychain:sshauthentication-api:5.7.5"
thirdparty-sshj = "com.hierynomus:sshj:0.32.0"