Skip to content

Commit

Permalink
feat: Setup Sentry (#147)
Browse files Browse the repository at this point in the history
* deps: Add `sentry`

* chore: Initilize sentry client
  • Loading branch information
m1sk9 authored Dec 14, 2024
1 parent 319a682 commit 9a5557d
Show file tree
Hide file tree
Showing 4 changed files with 244 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ENV_NAME=development
DISCORD_API_TOKEN=
REDMINE_URL=http://localhost:8080
REDMINE_API_KEY=
Expand Down
225 changes: 225 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ tracing = { version = "0.1.40" }
envy = { version = "0.4.2" }
typed-builder = { version = "0.20.0" }
regex = { version = "1.10.6" }
sentry = { version = "0.35.0" }

[dependencies.serenity]
version = "0.12.1"
Expand Down
17 changes: 17 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ mod redmine;

#[derive(serde::Serialize, serde::Deserialize, Debug)]
pub struct IdeaReactionEnv {
pub env_name: String,
pub discord_api_token: String,
pub redmine_api_key: String,
pub redmine_url: String,
Expand Down Expand Up @@ -38,6 +39,22 @@ async fn main() -> anyhow::Result<()> {
}

let envs = envs();

let _guard = if &envs.env_name == "production" {
let client = sentry::init((
"https://[email protected]//5",
sentry::ClientOptions {
release: sentry::release_name!(),
traces_sample_rate: 1.0,
..Default::default()
},
));
sentry::configure_scope(|s| s.set_level(Some(sentry::Level::Warning)));
Some(client)
} else {
None
};

let intents =
GatewayIntents::GUILD_MESSAGES | GatewayIntents::GUILDS | GatewayIntents::MESSAGE_CONTENT;
let mut client = Client::builder(&envs.discord_api_token, intents)
Expand Down

0 comments on commit 9a5557d

Please sign in to comment.