0.3.1 • Published 4 years ago
lit-fastify-bugsnag v0.3.1
Fastify Bugsnag Plugin
Easily send your application errors to Bugsnag from your Fastify server.
Installation
npm install fastify-bugsnag --save
# OR
yarn add fastify-bugsnagUsage
const fastify = require('fastify')();
fastify.register(require('fastify-bugsnag'), {
key: 'Your-Bugsnag-API-Key', // Defaults to process.env.BUGSNAG_API_KEY
enableReporting: process.env.NODE_ENV === 'production', // OR similar
bugsnagOptions: {
appType: 'web',
}
});
fastify.get('/', async (request, reply) => {
fastify.bugsnag.leaveBreadcrumb('Visited homepage'); // OR request.bugsnag.leaveBreadcrumb();
});
fastify.get('/error', async (request, reply) => {
request.bugsnag.notify(new Error('This is a generic error'));
});Description
The plugin will decorate fastify instance with bugsnag property and request as well. The value behind bugsnag, is
a full BugsnagClient. Bugsnag documentation
Be aware that the plugin mimics the behaviour of
official Bugsnag Express plugin with appending
the request data to the error. That includes body, query and params which may include user data!
Options
| Parameter | Default Value | Description |
|---|---|---|
key | process.env.BUGSNAG_API_KEY | API Key obtained from Bugsnag dashboard project. REQUIRED |
enableReporting | undefined | Set to true on environments or under conditions you want to report the errors to Bugsnag. |
bugsnagOptions | {} | Additional configuration options for Bugsnag Client. |
License
Licensed under MIT.
0.3.1
4 years ago