Skip to content

Commit d57fabc

Browse files
Merge pull request #165 from appdevforall/feat/ADFA-4533-glitchtip-crash-reporting
ADFA-4533: wire GlitchTip (Sentry SDK) crash reporting (DSN-only, con…
2 parents 1a5db6b + 570cb77 commit d57fabc

7 files changed

Lines changed: 57 additions & 0 deletions

File tree

‎.github/workflows/android-release-build.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ jobs:
6565
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
6666
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
6767
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
68+
# ADFA-4533: GlitchTip DSN for release builds
69+
SENTRY_DSN_RELEASE: ${{ secrets.SENTRY_DSN_RELEASE }}
6870
run: |
6971
./gradlew assembleRelease \
7072
-Pandroid.injected.signing.store.file=$(pwd)/keystore.jks \

‎.github/workflows/firebase-distribution.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ jobs:
8989
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
9090
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
9191
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
92+
# ADFA-4533: GlitchTip DSN for release builds distributed to testers
93+
SENTRY_DSN_RELEASE: ${{ secrets.SENTRY_DSN_RELEASE }}
9294
run: |
9395
# TODO: Add gradle start/end timers here for the CI performance script
9496
# echo "gradle_time_start=$(date +%s)" >> $GITHUB_ENV

‎controller/app/build.gradle‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,14 @@ android {
6868
release {
6969
minifyEnabled false
7070
signingConfig signingConfigs.release
71+
// ADFA-4533: GlitchTip (Sentry) DSN from -PsentryDsnRelease or $SENTRY_DSN_RELEASE (empty -> SDK inert)
72+
manifestPlaceholders = [sentryDsn: (project.findProperty('sentryDsnRelease') ?: System.getenv('SENTRY_DSN_RELEASE') ?: '')]
7173
}
7274
debug {
7375
minifyEnabled false
7476
//signingConfig signingConfigs.release
77+
// ADFA-4533: GlitchTip (Sentry) DSN from -PsentryDsnDebug or $SENTRY_DSN_DEBUG (empty -> SDK inert)
78+
manifestPlaceholders = [sentryDsn: (project.findProperty('sentryDsnDebug') ?: System.getenv('SENTRY_DSN_DEBUG') ?: '')]
7579
}
7680
}
7781

@@ -157,6 +161,9 @@ android {
157161
}
158162

159163
dependencies {
164+
// ADFA-4533: GlitchTip (Sentry-compatible) crash reporting SDK.
165+
implementation 'io.sentry:sentry-android-core:8.29.0'
166+
160167
// 10. Core dependencies
161168
implementation 'androidx.appcompat:appcompat:1.7.1'
162169
implementation 'com.google.android.material:material:1.13.0'

‎controller/app/src/main/AndroidManifest.xml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
3636
android:roundIcon="@mipmap/ic_launcher_round"
3737
android:theme="@style/Theme.IIABController">
3838

39+
<!-- ADFA-4533: GlitchTip (Sentry) crash reporting. DSN injected per build type via the
40+
${sentryDsn} placeholder; auto-init disabled so init is consent-gated in code. -->
41+
<meta-data android:name="io.sentry.dsn" android:value="${sentryDsn}" />
42+
<meta-data android:name="io.sentry.auto-init" android:value="false" />
43+
3944
<provider
4045
android:name="androidx.core.content.FileProvider"
4146
android:authorities="${applicationId}.provider"

‎controller/app/src/main/java/org/iiab/controller/IIABApplication.java‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ public void onCreate() {
3535
Log.e("IIABApplication", "Error initializing Conscrypt", e);
3636
}
3737

38+
// ADFA-4533: crash reporting to GlitchTip (Sentry SDK), gated by its OWN opt-in
39+
// (CrashReportConsent, default ON) -- independent of usage-analytics consent, since error
40+
// reports are operational, not behavioural telemetry, and carry no PII
41+
// (io.sentry.send-default-pii=false). No-op unless a DSN was built in (empty DSN -> SDK
42+
// stays inert); manifest sets io.sentry.auto-init=false, so this is the only init path.
43+
// Init here (before our handler) so K2GoUncaughtExceptionHandler wraps Sentry: save -> report.
44+
try {
45+
if (org.iiab.controller.delivery.data.CrashReportConsent.isEnabled(this)) {
46+
io.sentry.android.core.SentryAndroid.init(this);
47+
}
48+
} catch (Throwable t) {
49+
Log.e("IIABApplication", "Sentry init skipped", t);
50+
}
51+
3852
// Capture uncaught exceptions into a crash report, offered on next launch.
3953
Thread.UncaughtExceptionHandler previous = Thread.getDefaultUncaughtExceptionHandler();
4054
Thread.setDefaultUncaughtExceptionHandler(
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package org.iiab.controller.delivery.data;
2+
3+
import android.content.Context;
4+
5+
/**
6+
* Opt-in flag for crash / error reporting (GlitchTip via the Sentry SDK). Separate from
7+
* {@link AnalyticsConsent} on purpose: error reports are operational (not behavioural
8+
* telemetry) and carry no PII, so they can follow a different policy. Default ON; flip the
9+
* default here if administration decides error reports must also be opt-in.
10+
*/
11+
public final class CrashReportConsent {
12+
13+
private static final String PREFS = "iiab_delivery";
14+
private static final String KEY = "crash_reports_opt_in";
15+
16+
private CrashReportConsent() {
17+
}
18+
19+
public static boolean isEnabled(Context ctx) {
20+
return ctx.getSharedPreferences(PREFS, Context.MODE_PRIVATE).getBoolean(KEY, true);
21+
}
22+
23+
public static void setEnabled(Context ctx, boolean enabled) {
24+
ctx.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit().putBoolean(KEY, enabled).apply();
25+
}
26+
}

‎controller/build.gradle‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ allprojects {
4747
repositories {
4848
google()
4949
jcenter()
50+
mavenCentral()
5051
maven { url 'https://jitpack.io' }
5152
}
5253
}

0 commit comments

Comments
 (0)