2.3.0 • Published 1 year ago

@zentered/fastify-sentry v2.3.0

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
1 year ago

Fastify Sentry Plugin using the Sentry SDK

Test Semantic Release Conventional Commits

Installation

npm i @zentered/fastify-sentry

or

yarn add @zentered/fastify-sentry

Usage

const fastifySentry = require('@zentered/fastify-sentry')

const errorHandler = (err, req, reply) => {
  reply.status(req.body.error).send({
    message: req.body.message,
    e: err.message
  })
}

app.register(fastifySentry, {
  dsn: process.env.SENTRY_DSN,
  environment: 'development',
  tracing: true,
  tracesSampleRate: 1.0,
  errorHandler
})

fastify.get('/', async (request, reply) => {
  // Errors in async functions are automatically caught
  throw new Error('Oops')
})

Description

This plugin adds the Sentry SDK error handler by using setErrorHandler. It also adds certain metadata, namely the path and the ip parameters of the request, to both the User context and Tag context of Sentry. If you use jwt authentication, the user id is also added to Sentry.

Options

OptionRequiredDescription
dsnrequiredThe DSN specified by Sentry.io to properly log errors to.
tracingoptionalDefault false, enable Sentry tracing.
errorHandleroptionalCustom error handler for errors.
errorFilteroptionalError filter to selectively disable Sentry reporting.

You can find further options in the Node.js Guide on Sentry.io

Author

Alex Papageorgiou

License

Licensed under GPLv3.

2.3.0

1 year ago

2.2.2

1 year ago

2.2.1

3 years ago

2.2.0

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.3

4 years ago

2.1.0

4 years ago

2.0.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago

2.0.0

4 years ago