Skip to content

Commit 7b0947f

Browse files
committed
Update crash reporter
1 parent 2d46721 commit 7b0947f

File tree

6 files changed

+73
-219
lines changed

6 files changed

+73
-219
lines changed

app/build.gradle

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,6 @@ dependencies {
292292
implementation 'com.squareup.okhttp:okhttp:2.7.5'
293293
implementation 'com.squareup.okhttp3:okhttp:3.12.13'
294294
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.13'
295-
implementation "com.newrelic.agent.android:android-agent:5.27.1"
296295
//implementation 'com.jakewharton.retrofit:retrofit1-okhttp3-client:1.1.0'
297296
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
298297
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
@@ -342,9 +341,7 @@ dependencies {
342341
implementation 'net.danlew:android.joda:2.10.6.1'
343342
implementation 'org.bouncycastle:bcpkix-jdk15to18:1.68'
344343

345-
def appCenterSdkVersion = '4.4.5'
346-
implementation "com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}"
347-
implementation "com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}"
344+
implementation 'io.sentry:sentry-android:4.2.0'
348345

349346
testImplementation 'joda-time:joda-time:2.10.7'
350347

app/src/main/AndroidManifest.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,19 @@
137137
android:name="AA_MODELS"
138138
android:value="com.eveningoutpost.dexdrip.models.ActiveBgAlert,com.eveningoutpost.dexdrip.models.ActiveBluetoothDevice,com.eveningoutpost.dexdrip.models.AlertType,com.eveningoutpost.dexdrip.models.BgReading,com.eveningoutpost.dexdrip.models.BgReadingArchive,com.eveningoutpost.dexdrip.models.BgReading,com.eveningoutpost.dexdrip.models.Calibration,com.eveningoutpost.dexdrip.models.Calibration,com.eveningoutpost.dexdrip.models.CalibrationRequest,com.eveningoutpost.dexdrip.models.Sensor,com.eveningoutpost.dexdrip.models.TransmitterData,com.eveningoutpost.dexdrip.models.Treatments,com.eveningoutpost.dexdrip.models.UserError,com.eveningoutpost.dexdrip.models.UserNotification,com.eveningoutpost.dexdrip.sharemodels.models,com.eveningoutpost.dexdrip.utilitymodels.BgSendQueue,com.eveningoutpost.dexdrip.utilitymodels.CalibrationSendQueue,com.eveningoutpost.dexdrip.utilitymodels.SensorSendQueue,com.eveningoutpost.dexdrip.models.HeartRate,com.eveningoutpost.dexdrip.models.StepCounter,com.eveningoutpost.dexdrip.utilitymodels.UploaderQueue,com.eveningoutpost.dexdrip.models.BloodTest,com.eveningoutpost.dexdrip.models.Accuracy,com.eveningoutpost.dexdrip.models.Reminder,com.eveningoutpost.dexdrip.models.LibreData,com.eveningoutpost.dexdrip.models.LibreBlock,com.eveningoutpost.dexdrip.models.APStatus,com.eveningoutpost.dexdrip.models.Prediction,com.eveningoutpost.dexdrip.models.DesertSync,com.eveningoutpost.dexdrip.models.PenData,com.eveningoutpost.dexdrip.models.Libre2RawValue,com.eveningoutpost.dexdrip.models.Libre2Sensor" />
139139

140+
<meta-data
141+
android:name="io.sentry.auto-init"
142+
android:value="false" />
143+
144+
<provider
145+
android:name="io.sentry.android.core.SentryInitProvider"
146+
android:authorities="${applicationId}.SentryInitProvider"
147+
tools:node="remove" />
148+
<provider
149+
android:name="io.sentry.android.core.SentryPerformanceProvider"
150+
android:authorities="${applicationId}.SentryPerformanceProvider"
151+
tools:node="remove" />
152+
140153
<provider
141154
android:name="com.activeandroid.content.ContentProvider"
142155
android:authorities="${applicationId}"

app/src/main/java/com/eveningoutpost/dexdrip/utils/AppCenterCrashReporting.java

Lines changed: 0 additions & 52 deletions
This file was deleted.

app/src/main/java/com/eveningoutpost/dexdrip/utils/NewRelicCrashReporting.java

Lines changed: 0 additions & 159 deletions
This file was deleted.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
2+
package com.eveningoutpost.dexdrip.utils;
3+
4+
import android.app.Application;
5+
6+
import com.eveningoutpost.dexdrip.models.JoH;
7+
import com.eveningoutpost.dexdrip.models.UserError;
8+
9+
import io.sentry.Sentry;
10+
import io.sentry.android.core.SentryAndroid;
11+
import io.sentry.android.core.SentryAndroidOptions;
12+
13+
// jamorham
14+
public class SentryCrashReporting {
15+
private static final String TAG = "Sentry";
16+
private static final String serverDomain = "bluejay.website";
17+
private static final String segment1 = "643697dfe5994e1b8d2788ede119cd5e";
18+
private static final String segment2 = "27340ce23ddd103028eaa178a466d768";
19+
private static final String scheme = "https://";
20+
private static final String DSN = getDsn();
21+
private static volatile boolean started = false;
22+
public synchronized static void start(Application app) {
23+
try {
24+
if (started) {
25+
UserError.Log.e(TAG, "Already started!");
26+
return;
27+
}
28+
started = true;
29+
if (JoH.pratelimit("crash-reporting-start", 240) ||
30+
JoH.pratelimit("crash-reporting-start2", 240)) {
31+
SentryAndroid.init(app, options -> {
32+
options.setDsn(DSN);
33+
options.enableAllAutoBreadcrumbs(false);
34+
options.setEnableActivityLifecycleBreadcrumbs(false);
35+
options.setEnableSystemEventBreadcrumbs(false);
36+
// options.setEnableAutoSessionTracking(true);
37+
// options.setEnableRootCheck(false);
38+
// TODO
39+
});
40+
Sentry.addBreadcrumb(DexCollectionType.getBestCollectorHardwareName(),"BootCollector");
41+
// Sentry.captureMessage("Hello world");
42+
} else {
43+
if (JoH.pratelimit("crash-reporting-start-failure", 3600)) {
44+
UserError.Log.wtf(TAG, "Unable to start crash reporter as app is restarting too frequently - if you are a developer then you can ignore this message");
45+
}
46+
}
47+
} catch (Throwable e) {
48+
if (JoH.pratelimit("crash-reporting-start-exception", 3600)) {
49+
UserError.Log.wtf(TAG, "Unable to start crash reporter: " + e);
50+
}
51+
}
52+
}
53+
54+
static String getDsn() {
55+
return String.format("%s%s@%s.%s/1", scheme, segment1, segment2, serverDomain);
56+
}
57+
}

app/src/main/java/com/eveningoutpost/dexdrip/xdrip.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
import com.eveningoutpost.dexdrip.utilitymodels.Pref;
2626
import com.eveningoutpost.dexdrip.utilitymodels.VersionTracker;
2727
import com.eveningoutpost.dexdrip.calibrations.PluggableCalibration;
28-
import com.eveningoutpost.dexdrip.utils.AppCenterCrashReporting;
29-
import com.eveningoutpost.dexdrip.utils.NewRelicCrashReporting;
28+
import com.eveningoutpost.dexdrip.utils.SentryCrashReporting;
3029
import com.eveningoutpost.dexdrip.utils.jobs.DailyJob;
3130
import com.eveningoutpost.dexdrip.utils.jobs.XDripJobCreator;
3231
import com.eveningoutpost.dexdrip.watch.lefun.LeFunEntry;
@@ -80,8 +79,7 @@ public void onCreate() {
8079
JodaTimeAndroid.init(this);
8180
try {
8281
if (PreferenceManager.getDefaultSharedPreferences(xdrip.context).getBoolean("enable_crashlytics", true)) {
83-
//NewRelicCrashReporting.start();
84-
AppCenterCrashReporting.start(this);
82+
SentryCrashReporting.start(this);
8583
}
8684
} catch (Exception e) {
8785
Log.e(TAG, e.toString());

0 commit comments

Comments
 (0)