Skip to content

Commit 791f4bc

Browse files
committed
feat(sentry): add final app version and platform configuration options next to the sentry dsn
1 parent f812afc commit 791f4bc

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

  • bindings/matrix-sdk-ffi/src/platform

bindings/matrix-sdk-ffi/src/platform/mod.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -492,9 +492,17 @@ pub struct TracingConfiguration {
492492
/// If set, configures rotated log files where to write additional logs.
493493
write_to_files: Option<TracingFileConfiguration>,
494494

495-
/// If set, the Sentry DSN to use for error reporting.
495+
/// If set, the Sentry configuration to use for error reporting.
496496
#[cfg(feature = "sentry")]
497-
sentry_dsn: Option<String>,
497+
sentry_config: Option<SentryConfig>,
498+
}
499+
500+
#[cfg(feature = "sentry")]
501+
#[derive(uniffi::Record)]
502+
pub struct SentryConfig {
503+
dsn: String,
504+
app_version: String,
505+
app_platform: String,
498506
}
499507

500508
impl TracingConfiguration {
@@ -515,10 +523,10 @@ impl TracingConfiguration {
515523
{
516524
// Prepare the Sentry layer, if a DSN is provided.
517525
let (sentry_layer, sentry_logging_ctx) =
518-
if let Some(sentry_dsn) = self.sentry_dsn.take() {
526+
if let Some(sentry_config) = self.sentry_config.take() {
519527
// Initialize the Sentry client with the given options.
520528
let sentry_guard = sentry::init((
521-
sentry_dsn,
529+
sentry_config.dsn,
522530
sentry::ClientOptions {
523531
traces_sampler: Some(Arc::new(|ctx| {
524532
// Make sure bridge spans are always uploaded
@@ -534,6 +542,11 @@ impl TracingConfiguration {
534542
},
535543
));
536544

545+
sentry::configure_scope(|scope| {
546+
scope.set_tag("app_version", sentry_config.app_version);
547+
scope.set_tag("app_platform", sentry_config.app_platform);
548+
});
549+
537550
let sentry_enabled = Arc::new(AtomicBool::new(true));
538551

539552
// Add a Sentry layer to the tracing subscriber.
@@ -776,7 +789,7 @@ mod tests {
776789
write_to_stdout_or_system: true,
777790
write_to_files: None,
778791
#[cfg(feature = "sentry")]
779-
sentry_dsn: None,
792+
sentry_config: None,
780793
};
781794

782795
let filter = build_tracing_filter(&config);
@@ -822,7 +835,7 @@ mod tests {
822835
write_to_stdout_or_system: true,
823836
write_to_files: None,
824837
#[cfg(feature = "sentry")]
825-
sentry_dsn: None,
838+
sentry_config: None,
826839
};
827840

828841
let filter = build_tracing_filter(&config);
@@ -869,7 +882,7 @@ mod tests {
869882
write_to_stdout_or_system: true,
870883
write_to_files: None,
871884
#[cfg(feature = "sentry")]
872-
sentry_dsn: None,
885+
sentry_config: None,
873886
};
874887

875888
let filter = build_tracing_filter(&config);

0 commit comments

Comments
 (0)