mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-29 13:52:10 +03:00
4f01bb34f9
no issue
33 lines
890 B
JavaScript
33 lines
890 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('./lib/ghost-version').full;
|
|
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: () => {}
|
|
};
|
|
}
|