Skip to content

Commit

Permalink
load Sentry DSN from sentry.properties
Browse files Browse the repository at this point in the history
  • Loading branch information
johan12345 committed Jul 7, 2020
1 parent f786ab2 commit 7f6a297
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
11 changes: 11 additions & 0 deletions opacclient/opacapp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,27 @@ android {
}
}

// load Sentry configuration from sentry.properties file, if it exists
def sentryProps = new Properties()
def sentryPropsFile = project.rootProject.file("sentry.properties")
String dsn = null;
if (sentryPropsFile.exists()) {
sentryProps.load(sentryPropsFile.newDataInputStream())
dsn = sentryProps.getProperty("dsn")
}

buildTypes {
release {
minifyEnabled true
signingConfig signingConfigs.release
proguardFiles 'proguard-rules.txt'
buildConfigField("String", "SENTRY_DSN", dsn != null ? "\"$dsn\"" : "null")
}
debug {
debuggable true
applicationIdSuffix ".debug"
versionNameSuffix "-debug"
buildConfigField("String", "SENTRY_DSN", "null")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Bundle;
import androidx.preference.PreferenceManager;
import android.util.Log;

import org.joda.time.DateTime;
Expand All @@ -53,6 +52,7 @@
import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
import androidx.multidex.MultiDex;
import androidx.preference.PreferenceManager;
import de.geeksfactory.opacclient.apis.OpacApi;
import de.geeksfactory.opacclient.frontend.AccountListActivity;
import de.geeksfactory.opacclient.frontend.LibraryListActivity;
Expand Down Expand Up @@ -373,8 +373,10 @@ public void onCreate() {

sp = PreferenceManager.getDefaultSharedPreferences(this);

if (!BuildConfig.DEBUG) {
SentryAndroid.init(this);
if (BuildConfig.SENTRY_DSN != null) {
SentryAndroid.init(this, options -> {
options.setDsn(BuildConfig.SENTRY_DSN);
});
if (getLibrary() != null) {
Sentry.setTag(SENTRY_LIBRARY, getLibrary().getIdent());
}
Expand Down

0 comments on commit 7f6a297

Please sign in to comment.