wheelhouse-sentry
Version:
A small service to configure a Raven client for error logging. Meant for use with, but not limited to, Node-Wheelhouse
28 lines (23 loc) • 701 B
JavaScript
;
const Raven = require('raven');
let client = null;
module.exports = (DSN, config = {}, callback) => {
if (!client && !DSN) {
throw new Error(`
Trying to use Raven without it being initialized.
Please call the service with a Sentry DSN parameter
`);
}
if (DSN) {
if (!config.environment) {
config.environment = process.env.APP_ENV || process.env.NODE_ENV;
}
callback = callback || () => {
console.log('Exiting due to uncaught exception');
process.exit(1);
};
Raven.config(DSN, config).install(callback);
client = Raven;
}
return client;
};