2020-01-29 15:09:21 +03:00
|
|
|
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');
|
2020-03-26 18:35:46 +03:00
|
|
|
const version = require('./lib/ghost-version').full;
|
2020-01-29 15:09:21 +03:00
|
|
|
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);
|
|
|
|
}
|
2020-02-19 01:01:49 +03:00
|
|
|
}),
|
|
|
|
captureException: Sentry.captureException
|
2020-01-29 15:09:21 +03:00
|
|
|
};
|
|
|
|
} else {
|
|
|
|
module.exports = {
|
|
|
|
requestHandler: expressNoop,
|
2020-02-19 01:01:49 +03:00
|
|
|
errorHandler: expressNoop,
|
|
|
|
captureException: () => {}
|
2020-01-29 15:09:21 +03:00
|
|
|
};
|
|
|
|
}
|