import * as sentry from '@sentry/types' ; import * as express from 'express' ; import { postSentryEventToSalesforce , shouldPostEventToSalesforce } from './post_sentry_event_to_salesforce' ; exports . postSentryEventToSalesforce = ( req , res ) => { if ( req . method !== 'POST' ) { return res . status ( 405 ) . send ( 'Method not allowed' ) ; } if ( ! req . body ) { return res . status ( 400 ) . send ( 'Missing request body' ) ; } const sentryEvent = req . body . event ; if ( ! sentryEvent ) { return res . status ( 400 ) . send ( 'Missing Sentry event' ) ; } if ( ! shouldPostEventToSalesforce ( sentryEvent ) ) { return res . status ( 200 ) . send ( ) ; } sentryEvent . message = sentryEvent . message || req . body . message ; postSentryEventToSalesforce ( sentryEvent , req . body . project ) . then ( ( ) => { res . status ( 200 ) . send ( ) ; } ) . catch ( ( e ) => { console . error ( e ) ; res . status ( 200 ) . send ( ) ; } ) ; } ;