chore(sentry_webhook): add basic logs to the webhook so we can debug the pipeline based on event ID (#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.
This commit is contained in:
Sander Bruens 2023-11-20 12:18:36 -05:00 committed by GitHub
parent 41d498f228
commit 094eeb3570
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View file

@ -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) => {

View file

@ -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}`));