4.0.0 • Published 4 months ago

fastify-bugsnag v4.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Fastify Bugsnag Plugin

NPM version CI workflow Known Vulnerabilities js-standard-style Test Coverage

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

Description

The plugin will decorate FastifyInstance and FastifyRequest with bugsnag property. The value behind bugsnag, is a full BugsnagClient. Bugsnag documentation.

To the FastifyInstance is attached also an onError handler, which will send all the errors directly to your Bugsnag dashboard. In the similar fashion as it's done by the official @bugsnag/plugin-express.

⚠️ Plugin Behaviour ⚠️

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!

Compatibility

Version
Fastify^4.x
Bugsnag^7.17.0
Node^18.12.1 || ^20.10.0 || >= 21.0.0

Installation

npm install fastify-bugsnag --save

# OR

yarn add fastify-bugsnag

Usage

// Javascript
// index.js
const fastify = require('fastify')();

fastify.register(require('fastify-bugsnag'), {
  apiKey: 'Your-Bugsnag-API-Key', // Defaults to process.env.BUGSNAG_API_KEY
  // Rest of Bugsnag Configuration Options
});

// Typescript/ESM
// index.ts
import fastify from 'fastify';
import fastifyBugsnag from 'fastify-bugsnag';

fastify.register(fastifyBugsnag, {
  apiKey: 'Your-Bugsnag-API-Key', // Defaults to process.env.BUGSNAG_API_KEY
  // Rest of Bugsnag Configuration Options
});
// routes.ts
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'));
});

Options

ParameterDefault ValueDescription
apiKeyprocess.env.BUGSNAG_API_KEYAPI Key obtained from Bugsnag dashboard project. REQUIRED

For additional options check the official documentation of Bugsnag here.

License

Licensed under MIT.

4.0.0

4 months ago

3.1.1

9 months ago

3.1.0

10 months ago

3.0.0

12 months ago

2.0.0

1 year ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.5.0

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.4.2

2 years ago

0.3.1

2 years ago

0.3.0

3 years ago

0.1.2

3 years ago

0.2.0

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago