From fae8b559cfb587d2f84bc1e4de97dab22da7d66d Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Mon, 30 Aug 2021 11:44:55 -0500 Subject: [PATCH] Integrate Sentry for crash logging. --- Cargo.toml | 1 + src/error.rs | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 6f583ad..2de2b96 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,4 +33,5 @@ mapgen = "0.5" maze_generator = "1" pathfinding = "2" rand = "0.8" +sentry = "0.23" shadowcast = "0.8" diff --git a/src/error.rs b/src/error.rs index cb723f9..4d2075a 100644 --- a/src/error.rs +++ b/src/error.rs @@ -44,10 +44,21 @@ fn init_panic_handler() { })); } +#[derive(Clone, Debug, Default)] +pub struct ErrorConfig { + pub sentry_dsn: Option, +} + pub struct ErrorPlugin; impl Plugin for ErrorPlugin { - fn build(&self, _: &mut AppBuilder) { + fn build(&self, app: &mut AppBuilder) { init_panic_handler(); + if let Some(config) = app.world().get_resource::() { + if let Some(dsn) = &config.sentry_dsn { + let guard = sentry::init(dsn.clone()); + app.insert_resource(guard); + } + } } }