🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

fastify-sentry

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-sentry

A plugin for attaching the Sentry SDK error handling to Fastify

1.1.0
Source
npm
Version published
Weekly downloads
221
27.01%
Maintainers
1
Weekly downloads
 
Created
Source

Fastify Sentry Plugin using the Sentry SDK

NPM

CircleCI

Installation

npm i fastify-sentry -s

Usage

const fastify = require("fastify")();
// Should be first declaration
fastify.register(
  require("fastify-sentry"),
  {
    dsn: "https://00000000000000000000000000000000@sentry.io/0000000"
  },
  err => {
    if (err) throw err;
  }
);

fastify.get("/", async (request, reply) => {
  throw new Error("Oops");
  reply.send({ hello: "world" });
});

Description

This plugin adds the Sentry SDK error handler by using fastify.setErrorHandler. This means that the Sentry SDK will only catch any errors thrown in routes with async functions. In order to properly log errors thrown within synchronous functions, you need to pass the error object within reply.send. It also adds certain metadata, namely the path and the ip parameters of req.raw, to both the User context and Tag context of Sentry.

Options

OptionDescription
dsnRequired, the DSN specified by Sentry.io to properly log errors to.

Author

Alex Papageorgiou

License

Licensed under GPLv3.

Keywords

fastify

FAQs

Package last updated on 03 Dec 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts