Skip to content

Commit

Permalink
Adding Sentry for crash report (#413)
Browse files Browse the repository at this point in the history
* Adding Sentry gradle

* Update AndroidManifest.xml

* Implement and init sentry

* Update build.gradle

* Update ExceptionManager

* Update AndroidManifest.xml
  • Loading branch information
lorenzoPrimi authored Feb 5, 2021
1 parent 3591be7 commit 7d179a6
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ dependencies {
implementation 'ru.noties:markwon:2.0.1'
implementation 'commons-io:commons-io:2.6'
implementation 'ly.count.android:sdk:20.11.1'
implementation 'io.sentry:sentry-android:4.0.0'
//arcview to fragment_dashboard
implementation 'com.github.florent37:shapeofview:1.3.2'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

import ly.count.android.sdk.Countly;

import io.sentry.Sentry;

public class ExceptionManager {
public static void logException(Exception e){
Countly.sharedInstance().crashes().recordHandledException(e);
Sentry.captureException(e);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@

import com.google.firebase.crashlytics.FirebaseCrashlytics;

import io.sentry.Sentry;

public class ExceptionManager {
public static void logException(Exception e){
FirebaseCrashlytics.getInstance().recordException(e);
Sentry.captureException(e);
}
}
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,10 @@
android:icon="@drawable/notification_icon"
android:label="@string/Dashboard_Card_Run">
</service>

<meta-data
android:name="io.sentry.dsn"
android:value="https://9dcd83d9519844188803aa817cdcd416@o155150.ingest.sentry.io/5619989" />

</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Date;
import java.util.concurrent.TimeUnit;

import io.sentry.android.core.SentryAndroid;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
Expand Down Expand Up @@ -50,6 +51,20 @@ public class Application extends android.app.Application {
FlavorApplication.onCreate(this);
if (BuildConfig.DEBUG)
FlowLog.setMinimumLoggingLevel(FlowLog.Level.V);
else {
SentryAndroid.init(this,
options -> {
options.setDsn("https://9dcd83d9519844188803aa817cdcd416@o155150.ingest.sentry.io/5619989");
options.setBeforeSend(
(event, hint) -> {
// Drop an event altogether:
if (!preferenceManager.isSendCrash()) {
return null;
}
return event;
});
});
}
if (preferenceManager.canCallDeleteJson())
Measurement.deleteUploadedJsons(this);
Measurement.deleteOldLogs(this);
Expand Down

0 comments on commit 7d179a6

Please sign in to comment.