Make SentrySdkDsn a value class instead of a qualifier

This commit is contained in:
Jorge Martín 2025-12-04 10:22:47 +01:00 committed by Jorge Martin Espinosa
parent c7a5ce152e
commit b31267d7c7
5 changed files with 6 additions and 25 deletions

View file

@ -50,6 +50,5 @@ interface AppBindings {
fun buildMeta(): BuildMeta fun buildMeta(): BuildMeta
@SentrySdkDsn fun sentrySdkDsn(): SentrySdkDsn?
fun sentrySdkDsn(): String?
} }

View file

@ -38,7 +38,7 @@ class PlatformInitializer : Initializer<Unit> {
logLevel = logLevel, logLevel = logLevel,
extraTargets = listOf(ELEMENT_X_TARGET), extraTargets = listOf(ELEMENT_X_TARGET),
traceLogPacks = runBlocking { preferencesStore.getTracingLogPacksFlow().first() }, traceLogPacks = runBlocking { preferencesStore.getTracingLogPacksFlow().first() },
sdkSentryDsn = appBindings.sentrySdkDsn()?.takeIf { it.isNotBlank() }, sdkSentryDsn = appBindings.sentrySdkDsn()?.value?.takeIf { it.isNotBlank() },
) )
bugReporter.setCurrentTracingLogLevel(logLevel.name) bugReporter.setCurrentTracingLogLevel(logLevel.name)
platformService.init(tracingConfiguration) platformService.init(tracingConfiguration)

View file

@ -7,21 +7,5 @@
package io.element.android.libraries.di.annotations package io.element.android.libraries.di.annotations
import dev.zacsweers.metro.Qualifier @JvmInline
value class SentrySdkDsn(val value: String)
/**
* Qualifies the Sentry SDK DSN in the DI graph.
*/
@Retention(AnnotationRetention.RUNTIME)
@MustBeDocumented
@Qualifier
@Target(
AnnotationTarget.CLASS,
AnnotationTarget.FIELD,
AnnotationTarget.FUNCTION,
AnnotationTarget.PROPERTY,
AnnotationTarget.PROPERTY_GETTER,
AnnotationTarget.VALUE_PARAMETER,
AnnotationTarget.TYPE,
)
annotation class SentrySdkDsn

View file

@ -16,7 +16,6 @@ import io.element.android.libraries.di.annotations.SentrySdkDsn
@BindingContainer @BindingContainer
@ContributesTo(AppScope::class) @ContributesTo(AppScope::class)
object NoopAnalyticsModule { object NoopAnalyticsModule {
@SentrySdkDsn
@Provides @Provides
fun provideSentrySdkDsn(): String? = null fun provideSentrySdkDsn(): SentrySdkDsn? = null
} }

View file

@ -18,6 +18,5 @@ import io.element.android.services.analyticsproviders.sentry.SentryConfig
@ContributesTo(AppScope::class) @ContributesTo(AppScope::class)
object SentryModule { object SentryModule {
@Provides @Provides
@SentrySdkDsn fun provideSentrySdkDsn(): SentrySdkDsn? = SentrySdkDsn(SentryConfig.SDK_DSN)
fun provideSentrySdkDsn(): String? = SentryConfig.SDK_DSN
} }