lit-fastify-bugsnag
TypeScript icon, indicating that this package has built-in type declarations

0.3.1 • Public • Published

Fastify Bugsnag Plugin

Easily send your application errors to Bugsnag from your Fastify server.

Installation

npm install fastify-bugsnag --save

# OR

yarn add fastify-bugsnag

Usage

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.

Dependents (0)

Package Sidebar

Install

npm i lit-fastify-bugsnag

Weekly Downloads

0

Version

0.3.1

License

MIT

Unpacked Size

461 kB

Total Files

12

Last publish

Collaborators

  • glitch003