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

treturner-plugin-sentry

v0.0.5

Published

Sentry plugin for Payload

Downloads

27

Readme

Sentry Plugin for Payload

This plugin seamlessly integrates Sentry with Payload for performance monitoring and error tracking.

Installation

  yarn add @payloadcms/plugin-sentry
  # OR
  npm i @payloadcms/plugin-sentry

Basic Usage

  1. Import sentry from '@payloadcms/plugin-sentry'
  2. Add it to the plugins array of your Payload config
  3. Pass in your Data Source Name (DSN)
  4. Pass additional options - not required
import { buildConfig } from 'payload/config';
import { sentry } from '@payloadcms/plugin-sentry';
import { Pages, Media } from './collections';

const config = buildConfig({
  collections: [Pages, Media],
  plugins: [
    sentry({
      dsn: 'https://[email protected]/4505357433352176',
    }),
  ]
});

export default config;

Options

Data Source Name (DSN) and where to find it

  • dsn : string | required

    Sentry automatically assigns a DSN when you create a project, the unique DSN informs Sentry where to send events so they are associated with the correct project.

    :rotating_light: You can find the DSN in your project settings by navigating to [Project] > Settings > Client Keys (DSN) in sentry.io.

Additional Options

  • enabled: boolean | optional

    Set to false to disable the plugin. Defaults to true.

  • init : ClientOptions | optional

    Sentry allows a variety of options to be passed into the Sentry.init() function, see the full list of options here.

  • requestHandler : RequestHandlerOptions | optional

    Accepts options that let you decide what data should be included in the event sent to Sentry, checkout the options here.

  • captureErrors: number[] | optional

    By default, Sentry.errorHandler will capture only errors with a status code of 500 or higher. To capture additional error codes, pass the values as numbers in an array.

You can configure any of these options by passing them to the plugin under options:

import { buildConfig } from 'payload/config';
import { sentry } from '@payloadcms/plugin-sentry';
import { Pages, Media } from './collections';

const config = buildConfig({
  collections: [Pages, Media],
  plugins: [
    sentry({
      dsn: 'https://[email protected]/4505357433352176',
      options: {
        init: {
          debug: true,
          environment: 'development',
          tracesSampleRate: 1.0,
        },
        requestHandler: {
          serverName: false,
          user: ["email"],
        },
        captureErrors: [400, 403, 404],
      }
    }),
  ]
});

export default config;

To learn more about these options and when to use them, visit the Sentry Docs.

TypeScript

All types can be directly imported:

import { PluginOptions } from '@payloadcms/plugin-sentry/types';

Development

To actively develop or debug this plugin you can either work directly within the demo directory of this repo, or link your own project.

Internal Demo

This repo includes a demo of Payload that installs the plugin directly from the source code. This is the easiest way to get started. To spin up this demo, follow these steps:

  1. First clone the repo
  2. Then, cd plugin-sentry && yarn && cd dev && yarn && yarn dev
  3. Now open http://localhost:3000/admin in your browser
  4. Create a new user and sign in
  5. Use the buttons to throw test errors

That's it! Changes made in ./src will be reflected in the demo.