Skip to content

Commit

Permalink
chore(sentry_webhook): add basic logs to the webhook so we can debug …
Browse files Browse the repository at this point in the history
…the pipeline based on event ID (Jigsaw-Code#1454)

* Add some basic logs so we can cross-reference events.

* Add `is-processed` response header.

* Prevent log injection.

* Log response header at DEBUG level.
  • Loading branch information
sbruens authored Nov 20, 2023
1 parent 41d498f commit 094eeb3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/sentry_webhook/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@ exports.postSentryEventToSalesforce = (req: express.Request, res: express.Respon
if (!sentryEvent) {
return res.status(400).send('Missing Sentry event');
}
const eventId = sentryEvent.event_id?.replace(/\n|\r/g, '');
if (!shouldPostEventToSalesforce(sentryEvent)) {
console.log('Not posting event:', eventId);
return res.status(200).send();
}
// Use the request message if SentryEvent.message is unpopulated.
sentryEvent.message = sentryEvent.message || req.body.message;
postSentryEventToSalesforce(sentryEvent, req.body.project)
.then(() => {
console.log('Successfully posted event:', eventId);
res.status(200).send();
})
.catch((e) => {
Expand Down
1 change: 1 addition & 0 deletions src/sentry_webhook/post_sentry_event_to_salesforce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export function postSentryEventToSalesforce(event: SentryEvent, project: string)
},
(res) => {
if (res.statusCode === 200) {
console.debug('Salesforce `is-processed`:', res.headers['is-processed']);
resolve();
} else {
reject(new Error(`Failed to post form data, response status: ${res.statusCode}`));
Expand Down

0 comments on commit 094eeb3

Please sign in to comment.