Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit 8b121e9

Browse files
committed
Fix sentry implementation.
1 parent 5f44892 commit 8b121e9

File tree

6 files changed

+23
-9
lines changed

6 files changed

+23
-9
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
*.iml
22
.gradle
3-
/sentry.properties
43
/local.properties
54
/.idea/
65
.DS_Store
@@ -9,3 +8,4 @@
98
.externalNativeBuild
109
.cxx
1110
local.properties
11+
sentry.properties

app/build.gradle

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ sentry {
9393
// If disabled the plugin will run a dry-run and just generate a UUID.
9494
// The mapping file has to be uploaded manually via sentry-cli in this case.
9595
// Default is enabled.
96-
autoUploadProguardMapping = true
96+
autoUploadProguardMapping = hasSentryConfig
9797

9898
// Experimental flag to turn on support for GuardSquare's tools integration (Dexguard and External Proguard).
9999
// If enabled, the plugin will try to consume and upload the mapping file produced by Dexguard and External Proguard.
@@ -104,7 +104,7 @@ sentry {
104104
// for Sentry. This executes sentry-cli automatically so
105105
// you don't need to do it manually.
106106
// Default is disabled.
107-
uploadNativeSymbols = true
107+
uploadNativeSymbols = hasSentryConfig
108108

109109
// Does or doesn't include the source code of native code for Sentry.
110110
// This executes sentry-cli with the --include-sources param. automatically so
@@ -116,7 +116,7 @@ sentry {
116116
// Does auto instrumentation for specified features through bytecode manipulation.
117117
// Default is enabled.
118118
tracingInstrumentation {
119-
enabled = true
119+
enabled = false
120120
}
121121

122122
// Enable auto-installation of Sentry components (sentry-android SDK and okhttp, timber and fragment integrations).
@@ -188,3 +188,16 @@ dependencies {
188188
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
189189
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
190190
}
191+
192+
if (hasSentryConfig) {
193+
Properties properties = new Properties();
194+
try (FileInputStream fis = new FileInputStream(sentryConfigFile)) {
195+
properties.load(fis)
196+
}
197+
tasks.withType(Exec) {
198+
environment "SENTRY_PROJECT", properties.getProperty("defaults.project")
199+
environment "SENTRY_ORG", properties.getProperty("defaults.org")
200+
environment "SENTRY_URL", properties.getProperty("defaults.url")
201+
environment "SENTRY_AUTH_TOKEN", properties.getProperty("auth.token")
202+
}
203+
}

app/src/default/java/com/fox2code/mmm/sentry/SentryBreadcrumb.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ public void setType(@Nullable String type) {
2020
breadcrumb.setType(type);
2121
}
2222

23-
public void setData(@NotNull String key, @NotNull Object value) {
23+
public void setData(@NotNull String key, @Nullable Object value) {
24+
if (value == null) value = "null";
2425
Objects.requireNonNull(key);
25-
Objects.requireNonNull(value);
2626
breadcrumb.setData(key, value);
2727
}
2828

app/src/fdroid/java/com/fox2code/mmm/sentry/SentryBreadcrumb.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ public SentryBreadcrumb() {}
1010

1111
public void setType(@Nullable String type) {}
1212

13-
public void setData(@NotNull String key, @NotNull Object value) {
13+
public void setData(@NotNull String key, @Nullable Object value) {
1414
Objects.requireNonNull(key);
15-
Objects.requireNonNull(value);
1615
}
1716

1817
public void setCategory(@Nullable String category) {}

app/src/main/java/com/fox2code/mmm/utils/Http.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import java.util.Objects;
3737
import java.util.concurrent.TimeUnit;
3838

39+
import io.sentry.android.okhttp.SentryOkHttpInterceptor;
3940
import okhttp3.Cache;
4041
import okhttp3.Cookie;
4142
import okhttp3.CookieJar;

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ buildscript {
66
gradlePluginPortal()
77
}
88
project.ext.latestAboutLibsRelease = "10.5.0"
9-
project.ext.hasSentryConfig = false
9+
project.ext.sentryConfigFile = new File(rootDir, "sentry.properties").getAbsoluteFile()
10+
project.ext.hasSentryConfig = sentryConfigFile.exists()
1011
dependencies {
1112
classpath 'com.android.tools.build:gradle:7.3.0'
1213
classpath "com.mikepenz.aboutlibraries.plugin:aboutlibraries-plugin:${latestAboutLibsRelease}"

0 commit comments

Comments
 (0)