-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use secret Sentry DSN value #4210
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
import io.element.android.services.analyticsproviders.api.AnalyticsProvider | ||
import io.element.android.services.analyticsproviders.sentry.log.analyticsTag | ||
import io.sentry.Sentry | ||
import io.sentry.SentryLevel | ||
import io.sentry.SentryOptions | ||
import io.sentry.android.core.SentryAndroid | ||
import timber.log.Timber | ||
|
@@ -35,13 +36,20 @@ | |
override fun init() { | ||
Timber.tag(analyticsTag.value).d("Initializing Sentry") | ||
if (Sentry.isEnabled()) return | ||
|
||
val dsn = if (SentryConfig.DSN.isNotBlank()) { | ||
SentryConfig.DSN | ||
Check warning on line 41 in services/analyticsproviders/sentry/src/main/kotlin/io/element/android/services/analyticsproviders/sentry/SentryAnalyticsProvider.kt
|
||
} else { | ||
Timber.w("No Sentry DSN provided, Sentry will not be initialized") | ||
Check warning on line 43 in services/analyticsproviders/sentry/src/main/kotlin/io/element/android/services/analyticsproviders/sentry/SentryAnalyticsProvider.kt
|
||
return | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking of something like val dsn = SentryConfig.DSN.takeIf { it.isNotBlank() }
if (dsn == null)
Timber.w("No Sentry DSN provided, Sentry will not report anything")
} but this is probably equivalent. |
||
|
||
SentryAndroid.init(context) { options -> | ||
options.dsn = SentryConfig.DNS | ||
options.dsn = dsn | ||
Check warning on line 48 in services/analyticsproviders/sentry/src/main/kotlin/io/element/android/services/analyticsproviders/sentry/SentryAnalyticsProvider.kt
|
||
options.beforeSend = SentryOptions.BeforeSendCallback { event, _ -> event } | ||
options.tracesSampleRate = 1.0 | ||
options.isEnableUserInteractionTracing = true | ||
options.environment = buildMeta.buildType.toSentryEnv() | ||
options.diagnosticLevel | ||
} | ||
} | ||
|
||
|
@@ -51,9 +59,11 @@ | |
} | ||
|
||
override fun capture(event: VectorAnalyticsEvent) { | ||
Sentry.captureMessage("Event: ${event.getName()}", SentryLevel.INFO) | ||
Check warning on line 62 in services/analyticsproviders/sentry/src/main/kotlin/io/element/android/services/analyticsproviders/sentry/SentryAnalyticsProvider.kt
|
||
} | ||
|
||
override fun screen(screen: VectorAnalyticsScreen) { | ||
Sentry.captureMessage("Screen: ${screen.getName()}", SentryLevel.INFO) | ||
Check warning on line 66 in services/analyticsproviders/sentry/src/main/kotlin/io/element/android/services/analyticsproviders/sentry/SentryAnalyticsProvider.kt
|
||
} | ||
|
||
override fun updateUserProperties(userProperties: UserProperties) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ package io.element.android.services.analyticsproviders.sentry | |
|
||
object SentryConfig { | ||
const val NAME = "Sentry" | ||
const val DNS = "https://[email protected]/59" | ||
const val DSN = BuildConfig.SENTRY_DSN | ||
const val ENV_DEBUG = "DEBUG" | ||
const val ENV_RELEASE = "RELEASE" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the doc:
So it's maybe safer to set default value to
null
, or do not calloptions.dsn = SentryConfig.DNS
ifSentryConfig.DNS
is empty (maybe the latter is simpler, and we may Timber a warning in this case).