Send version to Sentry.

This commit is contained in:
Nolan Darilek 2022-02-01 10:22:38 -06:00
parent 3cfb638b48
commit 184cfac47e

View File

@ -47,6 +47,7 @@ fn init_panic_handler() {
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug, Default)]
pub struct ErrorConfig { pub struct ErrorConfig {
pub sentry_dsn: Option<String>, pub sentry_dsn: Option<String>,
pub version: Option<String>,
} }
pub struct ErrorPlugin; pub struct ErrorPlugin;
@ -58,7 +59,14 @@ impl Plugin for ErrorPlugin {
} }
if let Some(config) = app.world.get_resource::<ErrorConfig>() { if let Some(config) = app.world.get_resource::<ErrorConfig>() {
if let Some(dsn) = &config.sentry_dsn { if let Some(dsn) = &config.sentry_dsn {
let guard = sentry::init(dsn.clone()); let release = config.version.clone().unwrap_or_else(|| "".to_string());
let guard = sentry::init((
dsn.as_str(),
sentry::ClientOptions {
release: Some(release.into()),
..Default::default()
},
));
app.insert_resource(guard); app.insert_resource(guard);
} }
} }