npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

kuzzle-plugin-sentry

v0.2.1

Published

Kuzzle plugin boilerplate template

Downloads

4

Readme

Kuzzle Plugin Sentry

This plugin allows to send the errors encountered by Kuzzle to Sentry for further detailed analysis.

Installation

First, you have to get the Sentry DSN URL associated with the project you want to monitor.
Please refer to Sentry documentation to create a new Node.js project and get your DSN.

One you have it, you have to provide the DSN to the plugin using one of the following method.

  • SENTRY_DSN environment variable
  • plugins.sentry.dsn key in Kuzzle configuration file

Usage

This plugin adds a hook on the request:onError event triggered by Kuzzle each time a request fail.

Each error will be enriched with the authenticated user to allow Sentry to compute the number of user affected by an issue. (See Sentry documentation)

It will send the error to Sentry alongside with other useful informations like:

  • input payload
  • request context

Finally, is adds a Sentry tag containing the controller and action name to quickly identify related events.

Configuration

You can configure the plugin by using Kuzzle configuration file.

Sentry environment

It's possible to define the Sentry environment to bring even more context to catched errors.

You can either provide the KUZZLE_ENV environment variable or add the following key to the configuration:


{
  // kuzzle configuration file
  "plugins": {
    "sentry": {
      "environment": "staging"
    }
  }
}

Ignore errors

You can define errors that will be ignored and thus not send to Sentry.

By default the plugin will only send the PluginImplementationError.

If you add filters manually, then it will send every errors except those matching the filters.

You can filter errors either by status or by id.

Theses filters can be defined in the configuration file:

{
  // kuzzle configuration file
  "plugins": {
    "sentry": {
      "ignore": {
        "ids": [
          "security.token.verification_error",
          "security.token.expired"
        ],
        "statuses": [ 401, 403 ]
      } 
    }
  }
}

Filter sensitive values

Any sensitive information will be filtered in the Sentry report. This include password and authentication tokens.

By default, those values are:

  • context.token._id: contain the authentication token
  • context.token.jwt: authentication token
  • input.jwt: authentication token
  • input.body.password: password of the local strategy

You can add other value to be filtered automatically in the sensitiveValues array:

{
  // kuzzle configuration file
  "plugins": {
    "sentry": {
      "sensitiveValues": [
        "input.body.fbkeyid"
      ]
    }
  }
}

Exclude Sentry integrations

You can exclude default Sentry integration by providing their name in the configuration.

{
  // kuzzle configuration file
  "plugins": {
    "sentry": {
      "excludeIntegrations": [
        "Http",
        "Console"
      ]
    }
  }
}

Configuration example

{
  // kuzzle configuration file
  "plugins": {
    "sentry": {
      // DSN
      "dsn": "https://[email protected]/214284..."

      // Sentry environment
      "environment": "staging",

      // ignore specific errors
      "ignore": {
        "ids": [
          "security.token.verification_error",
          "security.token.expired"
        ],
        "statuses": [ 401, 403 ]
      },

      // Exclude Sentry default integrations
      "excludeIntegrations": [
        "Http",
        "Console"
      ],

      // Additional sensitives values to filter before sending the error
      "sensitiveValues": [
        "input.body.fbkeyid"
      ]
    }    
  }
}

Extended API

admin:switch

This plugin also expose an API method in order to enable or disable sending events to Sentry.

JSON payload:

{
  "controller": "sentry/admin",
  "action": "switch",
  "state": "on"
}

HTTP route:

# enable plugin
curl localhost:7512/_plugin/sentry/switch/on

# disable plugin
curl localhost:7512/_plugin/sentry/switch/off

send:generic

Sends an error to sentry.

// Example usage in another plugin

this.context.accessors.sdk.query({
  controller: 'sentry/send',
  action: 'request',
  body: {
    error: new Error('failure'),
    tags: {
      tag1: 'gordon',
      tag2: 'alyx'
    },
    extras: {
      some: 'extra data',
      whatever: 'you want'
    },
    request: // Optional errored request
  }
})

Example of Sentry report

sentry kuzzle