Skip to content

Commit 25f35ad

Browse files
committed
ADFA-4397: Consolidate to a single GLITCHTIP_DSN and guard reporting init
- Read one glitchtipDsn / GLITCHTIP_DSN for both debug and release builds and drop the unused SENTRY_ORG, SENTRY_PROJECT, and SENTRY_AUTH_TOKEN. - Wrap SentryAndroid.init, the logback appender setup, and Sentry.setUser in runCatching so a failure is logged and direct-boot startup still runs ShizukuSettings and the EventBus.
1 parent 6637313 commit 25f35ad

5 files changed

Lines changed: 32 additions & 31 deletions

File tree

‎.github/workflows/analyze.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
# Firebase config). Scoped to this step so SonarCloud and other
8080
# third-party actions never see them.
8181
FIREBASE_CONSOLE_URL: ${{ secrets.FIREBASE_CONSOLE_URL }}
82-
SENTRY_DSN_DEBUG: ${{ secrets.SENTRY_DSN_DEBUG }}
82+
GLITCHTIP_DSN: ${{ secrets.GLITCHTIP_DSN }}
8383
run: |
8484
echo "gradle_time_start=$(date +%s)" >> $GITHUB_ENV
8585
flox activate -d flox/base -- ./gradlew :app:assembleV8Debug --no-daemon
@@ -104,7 +104,7 @@ jobs:
104104
# The Gradle build also drives Sentry/Firebase configuration during
105105
# the unit-test compile path.
106106
FIREBASE_CONSOLE_URL: ${{ secrets.FIREBASE_CONSOLE_URL }}
107-
SENTRY_DSN_DEBUG: ${{ secrets.SENTRY_DSN_DEBUG }}
107+
GLITCHTIP_DSN: ${{ secrets.GLITCHTIP_DSN }}
108108
run: flox activate -d flox/base -- ./gradlew :testing:tooling:assemble :testing:common:assemble sonarqube --info --no-build-cache -x lint --continue
109109

110110
- name: Upload JaCoCo report

‎.github/workflows/debug.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ env:
2727
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.MVN_SIGNING_KEY_ID }}
2828
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.MVN_SIGNING_KEY_PASSWORD }}
2929
FIREBASE_CONSOLE_URL: ${{ secrets.FIREBASE_CONSOLE_URL }}
30-
SENTRY_DSN_DEBUG: ${{ secrets.SENTRY_DSN_DEBUG }}
30+
GLITCHTIP_DSN: ${{ secrets.GLITCHTIP_DSN }}
3131

3232
jobs:
3333
check_changes:

‎.github/workflows/release.yml‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ env:
2525
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.MVN_SIGNING_KEY_ID }}
2626
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.MVN_SIGNING_KEY_PASSWORD }}
2727
FIREBASE_CONSOLE_URL: ${{ secrets.FIREBASE_CONSOLE_URL }}
28-
SENTRY_DSN_RELEASE: ${{ secrets.SENTRY_DSN_RELEASE }}
29-
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
30-
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
31-
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
28+
GLITCHTIP_DSN: ${{ secrets.GLITCHTIP_DSN }}
3229

3330
jobs:
3431
merge_stage_to_main:

‎app/build.gradle.kts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ val props =
8383
if (file.exists()) load(file.inputStream())
8484
}
8585

86+
val glitchtipDsn = props.getProperty("glitchtipDsn") ?: propOrEnv("GLITCHTIP_DSN")
87+
8688
apply {
8789
plugin(AndroidIDEAssetsPlugin::class.java)
8890
}
@@ -114,12 +116,10 @@ android {
114116
buildTypes {
115117
debug {
116118
signingConfig = signingConfigs.getByName("debug")
117-
manifestPlaceholders["sentryDsn"] =
118-
props.getProperty("sentryDsnDebug") ?: propOrEnv("SENTRY_DSN_DEBUG")
119+
manifestPlaceholders["sentryDsn"] = glitchtipDsn
119120
}
120121
release {
121-
manifestPlaceholders["sentryDsn"] =
122-
props.getProperty("sentryDsnRelease") ?: propOrEnv("SENTRY_DSN_RELEASE")
122+
manifestPlaceholders["sentryDsn"] = glitchtipDsn
123123
}
124124
}
125125

‎app/src/main/java/com/itsaky/androidide/app/DeviceProtectedApplicationLoader.kt‎

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -72,28 +72,32 @@ internal object DeviceProtectedApplicationLoader :
7272
),
7373
)
7474

75-
SentryAndroid.init(app) { options ->
76-
options.environment =
77-
if (BuildConfig.DEBUG) IDEApplication.SENTRY_ENV_DEV else IDEApplication.SENTRY_ENV_PROD
78-
}
79-
80-
val loggerContext = LoggerFactory.getILoggerFactory() as LoggerContext
81-
val sentryLogAppender =
82-
SentryAppender().apply {
83-
context = loggerContext
84-
setMinimumEventLevel(Level.OFF)
85-
setMinimumBreadcrumbLevel(Level.INFO)
86-
setMinimumLevel(Level.WARN)
87-
start()
75+
runCatching {
76+
SentryAndroid.init(app) { options ->
77+
options.environment =
78+
if (BuildConfig.DEBUG) IDEApplication.SENTRY_ENV_DEV else IDEApplication.SENTRY_ENV_PROD
8879
}
89-
loggerContext.getLogger(Logger.ROOT_LOGGER_NAME).addAppender(sentryLogAppender)
9080

91-
Sentry.setUser(
92-
User().apply {
93-
id = Settings.Secure.getString(app.contentResolver, Settings.Secure.ANDROID_ID)
94-
username = "${Build.MANUFACTURER} ${Build.MODEL}"
95-
},
96-
)
81+
val loggerContext = LoggerFactory.getILoggerFactory() as LoggerContext
82+
val sentryLogAppender =
83+
SentryAppender().apply {
84+
context = loggerContext
85+
setMinimumEventLevel(Level.OFF)
86+
setMinimumBreadcrumbLevel(Level.INFO)
87+
setMinimumLevel(Level.WARN)
88+
start()
89+
}
90+
loggerContext.getLogger(Logger.ROOT_LOGGER_NAME).addAppender(sentryLogAppender)
91+
92+
Sentry.setUser(
93+
User().apply {
94+
id = Settings.Secure.getString(app.contentResolver, Settings.Secure.ANDROID_ID)
95+
username = "${Build.MANUFACTURER} ${Build.MODEL}"
96+
},
97+
)
98+
}.onFailure {
99+
logger.error("Failed to initialize crash and log reporting", it)
100+
}
97101

98102
ShizukuSettings.initialize()
99103

0 commit comments

Comments
 (0)