add with_scope instead since sometimes it was getting messed up
@@ -319,11 +319,12 @@ async fn listen_github_webhooks(
let event_type = EventType::from_str(&event_type_string).unwrap();
// Add context to sentry.
- sentry::configure_scope(|scope| {
+ sentry::with_scope(
+ |scope| {
scope.set_context("github.webhook", sentry::protocol::Context::Other(event.clone().into()));
scope.set_tag("github.event.type", &event_type_string);
- });
-
+ },
+ || async {
let mut ok_to_continue = true;
// Filter by event type any actions we can rule out for all repos.
@@ -384,8 +385,7 @@ async fn listen_github_webhooks(
match repo_name {
Repo::RFD => match event_type {
- EventType::Push => {
- match handle_rfd_push(&github, api_context, event.clone(), &company).await {
+ EventType::Push => match handle_rfd_push(&github, api_context, event.clone(), &company).await {
Ok(message) => {
event.create_comment(&github, &message).await.unwrap();
}
@@ -401,10 +401,7 @@ async fn listen_github_webhooks(
.await
.unwrap();
}
- }
- sentry::end_session();
- return Ok(HttpResponseAccepted("ok".to_string()));
- }
+ },
EventType::PullRequest => {
// Let's create the check run.
let check_run_id = event.create_check_run(&github).await.unwrap();
@@ -429,8 +426,6 @@ async fn listen_github_webhooks(
.unwrap();
}
}
- sentry::end_session();
- return Ok(HttpResponseAccepted("ok".to_string()));
}
EventType::CheckRun => {
sentry::capture_message(&format!("CheckRun event:\n{:#?}", event), sentry::Level::Info);
@@ -459,8 +454,6 @@ async fn listen_github_webhooks(
.unwrap();
}
}
- sentry::end_session();
- return Ok(HttpResponseAccepted("ok".to_string()));
}
}
_ => {
@@ -472,6 +465,8 @@ async fn listen_github_webhooks(
}
}
}
+ },
+ ).await;
sentry::end_session();
Ok(HttpResponseAccepted("ok".to_string()))
