0.4.0 • Published 5 years ago
node-good-sentry v0.4.0
node-good-sentry
node-good-sentry is a module for streaming hapi server events to a Sentry Sentry server via good.
Example Usage of GoodSentry and StreamCleaner
import * as Hapi from "hapi";
import * as good from "good";
const server = new Hapi.Server({host: "0.0.0.0",port: 3000});
const StreamCleanerArgs = {
'password': 'redact',
'responsePayload.manager': 'remove'
};
const GoodSentryConfig = {
sentryDsn: process.env.SENTRY_DSN,
configOptions: {
environment: process.env.NODE_ENV,
release: process.env.HEROKU_RELEASE_VERSION,
autoBreadcrumbs: true
}
};
const LoggingConfiguration = {
reporters: {
sentry: [
{
module: 'good-squeeze',
name: 'Squeeze',
args: [{ log: '*' }],
},
{
module: 'node-good-sentry',
name: 'StreamCleaner',
args: [StreamCleanerArgs]
},
{
module: 'node-good-sentry',
name: 'GoodSentry',
args: [GoodSentryConfig]
}
]
}
};
const start = async () => {
try {
await server.register([
{
plugin: good,
options: LoggingConfiguration
}
]);
await server.start();
return `Application started at: ${server.info.uri}`;
} catch (error) {
console.log(error);
throw Error(error.message);
}
};
start()
.then(resp => console.log(resp))
.catch(error => {
process.exit(1);
});
This above example sets up the reporter named sentry to listen for server events and send them to a Sentry project with additional settings.
License
MIT License. See the LICENSE file.