@@ -21,7 +21,6 @@ import com.itsaky.androidide.utils.FeatureFlags
2121import com.termux.shared.reflection.ReflectionUtils
2222import io.github.rosemoe.sora.widget.schemes.EditorColorScheme
2323import io.sentry.Sentry
24- import io.sentry.SentryReplayOptions.SentryReplayQuality
2524import io.sentry.android.core.SentryAndroid
2625import kotlinx.coroutines.Dispatchers
2726import kotlinx.coroutines.launch
@@ -32,6 +31,13 @@ import org.koin.core.component.KoinComponent
3231import org.koin.core.component.inject
3332import org.slf4j.LoggerFactory
3433import kotlin.system.exitProcess
34+ import ch.qos.logback.classic.Level
35+ import ch.qos.logback.classic.Logger
36+ import ch.qos.logback.classic.LoggerContext
37+ import io.sentry.logback.SentryAppender
38+ import io.sentry.protocol.User
39+ import android.os.Build
40+ import android.provider.Settings
3541
3642/* *
3743 * @author Akash Yadav
@@ -67,16 +73,34 @@ internal object DeviceProtectedApplicationLoader :
6773 ),
6874 )
6975
70- SentryAndroid .init (app) { options ->
71- // Reduce replay quality to LOW to prevent OOM
72- // This reduces screenshot compression to 10 and bitrate to 50kbps
73- // (defaults to MEDIUM quality)
74- options.sessionReplay.quality = SentryReplayQuality .LOW
75- options.environment =
76- if (BuildConfig .DEBUG ) IDEApplication .SENTRY_ENV_DEV else IDEApplication .SENTRY_ENV_PROD
77-
78- // Enrich every Sentry event with app-specific diagnostic context.
79- SentryDiagnosticsContext .install(options)
76+ runCatching {
77+ SentryAndroid .init (app) { options ->
78+ options.environment =
79+ if (BuildConfig .DEBUG ) IDEApplication .SENTRY_ENV_DEV else IDEApplication .SENTRY_ENV_PROD
80+
81+ // Enrich every Sentry event with app-specific diagnostic context.
82+ SentryDiagnosticsContext .install(options)
83+ }
84+
85+ val loggerContext = LoggerFactory .getILoggerFactory() as LoggerContext
86+ val sentryLogAppender =
87+ SentryAppender ().apply {
88+ context = loggerContext
89+ setMinimumEventLevel(Level .OFF )
90+ setMinimumBreadcrumbLevel(Level .INFO )
91+ setMinimumLevel(Level .WARN )
92+ start()
93+ }
94+ loggerContext.getLogger(Logger .ROOT_LOGGER_NAME ).addAppender(sentryLogAppender)
95+
96+ Sentry .setUser(
97+ User ().apply {
98+ id = Settings .Secure .getString(app.contentResolver, Settings .Secure .ANDROID_ID )
99+ username = " ${Build .MANUFACTURER } ${Build .MODEL } "
100+ },
101+ )
102+ }.onFailure {
103+ logger.error(" Failed to initialize crash and log reporting" , it)
80104 }
81105
82106 ShizukuSettings .initialize()
0 commit comments