Add Sentry to client for error handling (#43920)
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
@ -18,11 +18,11 @@ const reqLogFormat = ':date[iso] :status :method :response-time ms - :url';
|
||||
// this may be brittle
|
||||
log.enabled = true;
|
||||
|
||||
if (sentry.dns === 'dsn_from_sentry_dashboard') {
|
||||
if (sentry.dsn === 'dsn_from_sentry_dashboard') {
|
||||
log('Sentry reporting disabled unless DSN is provided.');
|
||||
} else {
|
||||
Sentry.init({
|
||||
dsn: sentry.dns
|
||||
dsn: sentry.dsn
|
||||
});
|
||||
log('Sentry initialized');
|
||||
}
|
||||
|
@ -4,14 +4,14 @@ import { isHandledError } from '../utils/create-handled-error';
|
||||
|
||||
// sends directly to Sentry
|
||||
export function reportError(err) {
|
||||
return sentry.dns === 'dsn_from_sentry_dashboard'
|
||||
return sentry.dsn === 'dsn_from_sentry_dashboard'
|
||||
? console.error(err)
|
||||
: captureException(err);
|
||||
}
|
||||
|
||||
// determines which errors should be reported
|
||||
export default function sentryErrorHandler() {
|
||||
return sentry.dns === 'dsn_from_sentry_dashboard'
|
||||
return sentry.dsn === 'dsn_from_sentry_dashboard'
|
||||
? (req, res, next) => next()
|
||||
: Handlers.errorHandler({
|
||||
shouldHandleError(err) {
|
||||
|
@ -2,7 +2,7 @@ import { Handlers } from '@sentry/node';
|
||||
import { sentry } from '../../../../config/secrets';
|
||||
|
||||
export default function sentryRequestHandler() {
|
||||
return sentry.dns === 'dsn_from_sentry_dashboard'
|
||||
return sentry.dsn === 'dsn_from_sentry_dashboard'
|
||||
? (req, res, next) => next()
|
||||
: Handlers.requestHandler();
|
||||
}
|
||||
|
Reference in New Issue
Block a user