Ghost/core/server/sentry.js
Daniel Lockyer 4fda464103 Added captureException helper to Sentry integration
no issue

- this allows us to custom capture exceptions
2020-03-04 13:42:30 +00:00

33 lines
892 B
JavaScript

const config = require('./config');
const sentryConfig = config.get('sentry');
const expressNoop = function (req, res, next) {
next();
};
if (sentryConfig && !sentryConfig.disabled) {
const Sentry = require('@sentry/node');
const version = require('../../package.json').version;
Sentry.init({
dsn: sentryConfig.dsn,
release: 'ghost@' + version
});
module.exports = {
requestHandler: Sentry.Handlers.requestHandler(),
errorHandler: Sentry.Handlers.errorHandler({
shouldHandleError(error) {
// Only handle 500 errors for now
return (error.statusCode === 500);
}
}),
captureException: Sentry.captureException
};
} else {
module.exports = {
requestHandler: expressNoop,
errorHandler: expressNoop,
captureException: () => {}
};
}