Configure Sentry with more information (#1782)

* build-logic: remove error path in Sentry plugin

* gradle: fix UnstableApiUsage warning

* build-logic: configure Sentry Gradle Plugin

* app: set traces sample-rate to 1.0

* sentry-stub: init

* app: populate Sentry user field with feature flags
This commit is contained in:
Harsh Shandilya 2022-03-13 17:41:01 +05:30 committed by GitHub
parent 20725219bd
commit 861ca58a58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 76 additions and 8 deletions

View file

@ -35,4 +35,5 @@ dependencies {
implementation(libs.build.dokka)
implementation(libs.build.mavenpublish)
implementation(libs.build.semver)
implementation(libs.build.sentry)
}

View file

@ -2,11 +2,14 @@
import flavors.FlavorDimensions
import flavors.ProductFlavors
import io.sentry.android.gradle.InstrumentationFeature
plugins { id("com.android.application") }
plugins {
id("com.android.application")
id("io.sentry.android.gradle")
}
val SENTRY_DSN_PROPERTY = "SENTRY_DSN"
val INVOKED_FROM_IDE_PROPERTY = "android.injected.invoked.from.ide"
android {
androidComponents {
@ -14,12 +17,17 @@ android {
val sentryDsn = project.providers.environmentVariable(SENTRY_DSN_PROPERTY)
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"
)
}
}
}
}
sentry {
autoUploadProguardMapping.set(true)
ignoredBuildTypes.set(setOf("debug"))
ignoredFlavors.set(setOf(ProductFlavors.FREE))
tracingInstrumentation {
enabled.set(true)
features.set(setOf(InstrumentationFeature.FILE_IO))
}
}

View file

@ -16,6 +16,7 @@ apiValidation {
"format-common",
"diceware",
"random",
"sentry-stub",
"ui-compose",
)
}

View file

@ -2,6 +2,7 @@
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
*/
@file:Suppress("UnstableApiUsage")
rootProject.name = "build-logic"