diff --git a/Cargo.toml b/Cargo.toml index ac205cf..ceab8ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "songlify" -version = "0.3.1" +version = "0.3.2" edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -11,3 +11,4 @@ log = "0.4.17" pretty_env_logger = "0.4.0" tokio = { version = "1.18.2", features = ["rt-multi-thread", "macros"] } rspotify = { version = "0.11.5", features = ["default"]} +sentry = "0.26.0" diff --git a/src/main.rs b/src/main.rs index 00e4fc9..e0ee163 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +use sentry::ClientInitGuard; +use std::env; use teloxide::prelude::*; use crate::spotify::{PlayableKind, TrackInfo}; @@ -16,6 +18,23 @@ async fn main() { teloxide::enable_logging!(); log::info!("Starting Songlify..."); + let mut _guard: ClientInitGuard; + match env::var("SENTRY_DSN") { + Ok(sentry_dsn) => { + log::debug!("Sentry DSN found, enabling error reporting"); + _guard = sentry::init(( + sentry_dsn, + sentry::ClientOptions { + release: sentry::release_name!(), + ..Default::default() + }, + )); + } + Err(_) => { + log::warn!("No sentry DSN set, errors will not be reported. Use SENTRY_DSN env variable if you want to set error reporting") + } + } + let bot = Bot::from_env().auto_send(); teloxide::repl(bot, |message: Message, bot: AutoSend| async move { let text = message.text().and_then(spotify::get_entry_kind);