diff --git a/.gitignore b/.gitignore index 21e8403..71f7189 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ *.iml .gradle -/sentry.properties /local.properties /.idea/ .DS_Store @@ -9,3 +8,4 @@ .externalNativeBuild .cxx local.properties +sentry.properties diff --git a/app/build.gradle b/app/build.gradle index 47938af..d1ea446 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -93,7 +93,7 @@ sentry { // If disabled the plugin will run a dry-run and just generate a UUID. // The mapping file has to be uploaded manually via sentry-cli in this case. // Default is enabled. - autoUploadProguardMapping = true + autoUploadProguardMapping = hasSentryConfig // Experimental flag to turn on support for GuardSquare's tools integration (Dexguard and External Proguard). // If enabled, the plugin will try to consume and upload the mapping file produced by Dexguard and External Proguard. @@ -104,7 +104,7 @@ sentry { // for Sentry. This executes sentry-cli automatically so // you don't need to do it manually. // Default is disabled. - uploadNativeSymbols = true + uploadNativeSymbols = hasSentryConfig // Does or doesn't include the source code of native code for Sentry. // This executes sentry-cli with the --include-sources param. automatically so @@ -116,7 +116,7 @@ sentry { // Does auto instrumentation for specified features through bytecode manipulation. // Default is enabled. tracingInstrumentation { - enabled = true + enabled = false } // Enable auto-installation of Sentry components (sentry-android SDK and okhttp, timber and fragment integrations). @@ -188,3 +188,16 @@ dependencies { androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' } + +if (hasSentryConfig) { + Properties properties = new Properties(); + try (FileInputStream fis = new FileInputStream(sentryConfigFile)) { + properties.load(fis) + } + tasks.withType(Exec) { + environment "SENTRY_PROJECT", properties.getProperty("defaults.project") + environment "SENTRY_ORG", properties.getProperty("defaults.org") + environment "SENTRY_URL", properties.getProperty("defaults.url") + environment "SENTRY_AUTH_TOKEN", properties.getProperty("auth.token") + } +} \ No newline at end of file diff --git a/app/src/default/java/com/fox2code/mmm/sentry/SentryBreadcrumb.java b/app/src/default/java/com/fox2code/mmm/sentry/SentryBreadcrumb.java index 5684172..623aaa2 100644 --- a/app/src/default/java/com/fox2code/mmm/sentry/SentryBreadcrumb.java +++ b/app/src/default/java/com/fox2code/mmm/sentry/SentryBreadcrumb.java @@ -20,9 +20,9 @@ public class SentryBreadcrumb { breadcrumb.setType(type); } - public void setData(@NotNull String key, @NotNull Object value) { + public void setData(@NotNull String key, @Nullable Object value) { + if (value == null) value = "null"; Objects.requireNonNull(key); - Objects.requireNonNull(value); breadcrumb.setData(key, value); } diff --git a/app/src/fdroid/java/com/fox2code/mmm/sentry/SentryBreadcrumb.java b/app/src/fdroid/java/com/fox2code/mmm/sentry/SentryBreadcrumb.java index a1cb9f4..1ab6d69 100644 --- a/app/src/fdroid/java/com/fox2code/mmm/sentry/SentryBreadcrumb.java +++ b/app/src/fdroid/java/com/fox2code/mmm/sentry/SentryBreadcrumb.java @@ -10,9 +10,8 @@ public class SentryBreadcrumb { public void setType(@Nullable String type) {} - public void setData(@NotNull String key, @NotNull Object value) { + public void setData(@NotNull String key, @Nullable Object value) { Objects.requireNonNull(key); - Objects.requireNonNull(value); } public void setCategory(@Nullable String category) {} diff --git a/app/src/main/java/com/fox2code/mmm/utils/Http.java b/app/src/main/java/com/fox2code/mmm/utils/Http.java index fa8f40b..5af6ddd 100644 --- a/app/src/main/java/com/fox2code/mmm/utils/Http.java +++ b/app/src/main/java/com/fox2code/mmm/utils/Http.java @@ -36,6 +36,7 @@ import java.util.List; import java.util.Objects; import java.util.concurrent.TimeUnit; +import io.sentry.android.okhttp.SentryOkHttpInterceptor; import okhttp3.Cache; import okhttp3.Cookie; import okhttp3.CookieJar; diff --git a/build.gradle b/build.gradle index e38dbc8..be694be 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,8 @@ buildscript { gradlePluginPortal() } project.ext.latestAboutLibsRelease = "10.5.0" - project.ext.hasSentryConfig = false + project.ext.sentryConfigFile = new File(rootDir, "sentry.properties").getAbsoluteFile() + project.ext.hasSentryConfig = sentryConfigFile.exists() dependencies { classpath 'com.android.tools.build:gradle:7.3.0' classpath "com.mikepenz.aboutlibraries.plugin:aboutlibraries-plugin:${latestAboutLibsRelease}"