Enable Sentry in the SDK: add SDK Sentry DSN value

This is provided to the SDK in `PlatformInitializer`.
This commit is contained in:
Jorge Martín
2025-11-21 10:13:47 +01:00
committed by Jorge Martin Espinosa
parent fbaedd017e
commit 53ab38d990
6 changed files with 16 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ import io.element.android.features.rageshake.api.logs.createWriteToFilesConfigur
import io.element.android.libraries.architecture.bindings
import io.element.android.libraries.featureflag.api.FeatureFlags
import io.element.android.libraries.matrix.api.tracing.TracingConfiguration
import io.element.android.services.analyticsproviders.sentry.SentryConfig
import io.element.android.x.di.AppBindings
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking
@@ -38,6 +39,7 @@ class PlatformInitializer : Initializer<Unit> {
logLevel = logLevel,
extraTargets = listOf(ELEMENT_X_TARGET),
traceLogPacks = runBlocking { preferencesStore.getTracingLogPacksFlow().first() },
sdkSentryDsn = SentryConfig.SDK_DSN.takeIf { it.isNotBlank() },
)
bugReporter.setCurrentTracingLogLevel(logLevel.name)
platformService.init(tracingConfiguration)

View File

@@ -14,4 +14,5 @@ data class TracingConfiguration(
val traceLogPacks: Set<TraceLogPack>,
val writesToLogcat: Boolean,
val writesToFilesConfiguration: WriteToFilesConfiguration,
val sdkSentryDsn: String?,
)

View File

@@ -60,5 +60,5 @@ fun TracingConfiguration.map(): org.matrix.rustcomponents.sdk.TracingConfigurati
extraTargets = extraTargets,
traceLogPacks = traceLogPacks.map(),
writeToFiles = writesToFilesConfiguration.toTracingFileConfiguration(),
sentryDsn = null,
sentryDsn = sdkSentryDsn,
)

View File

@@ -29,6 +29,7 @@ object BuildTimeConfig {
val SERVICES_POSTHOG_HOST: String? = null
val SERVICES_POSTHOG_APIKEY: String? = null
val SERVICES_SENTRY_DSN: String? = null
val SERVICES_SENTRY_SDK_DSN: String? = null
val BUG_REPORT_URL: String? = null
val BUG_REPORT_APP_NAME: String? = null

View File

@@ -32,6 +32,16 @@ android {
}
?: ""
)
buildConfigFieldStr(
name = "SDK_SENTRY_DSN",
value = if (isEnterpriseBuild) {
BuildTimeConfig.SERVICES_SENTRY_SDK_DSN
} else {
System.getenv("ELEMENT_SDK_SENTRY_DSN")
?: readLocalProperty("services.analyticsproviders.sdk.sentry.dsn")
}
?: ""
)
}
}

View File

@@ -11,6 +11,7 @@ package io.element.android.services.analyticsproviders.sentry
object SentryConfig {
const val NAME = "Sentry"
const val DSN = BuildConfig.SENTRY_DSN
const val SDK_DSN = BuildConfig.SDK_SENTRY_DSN
const val ENV_DEBUG = "DEBUG"
const val ENV_NIGHTLY = "NIGHTLY"
const val ENV_RELEASE = "RELEASE"