@kaname-png/plugin-sentry
TypeScript icon, indicating that this package has built-in type declarations

1.4.0 • Public • Published

Neko Plugins Logo

@kaname-png/plugin-sentry

Plugin for @sapphire/framework to publish errors to sentry.

GitHub codecov npm (scoped) npm

Description

This plugin allows you to integrate Sentry with Bot. Sentry is a developer-focused error tracking and performance monitoring platform that helps developers see what really matters, solve faster, and learn more about their applications.

More information about Sentry can be found on its website.

Features

  • Fully ready for TypeScript!
  • Includes ESM ready entrypoint
  • Easy to use

Installation

@kaname-png/plugin-sentry depends on the following packages. Be sure to install these along with this package!

You can use the following command to install this package, or replace npm install with your package manager of choice.

npm install @kaname-png/plugin-sentry @sentry/node @sentry/integrations @sapphire/framework discord.js

PS: You can view events by default here.


Usage

JavaScript

In your main or setup file, register the plugin:

require('@kaname-png/plugin-sentry/register');

const client = new SapphireClient({
	/* your bot options */
	sentry: {
		loadSentryErrorListeners: true, // (Optional) Load the default events .
		options: {
			// The options to pass to the sentry client.
		}
	}
});

async function main() {
	await client.login();
}

void main();

TypeScript

In your main or setup file, register the plugin:

import '@kaname-png/plugin-sentry/register';

const client = new SapphireClient({
	/* your bot options */
	sentry: {
		options: {
			// The options to pass to the sentry client.
		}
	}
});

async function main() {
	await client.login();
}

void main();

Then, you can create new listener by extending the SentryListener class.

With TypeScript

import { SentryListener } from '@kaname-png/plugin-sentry';
import { ApplyOptions } from '@sapphire/decorators';

// Using ApplyOptions decorator makes it easy to configure
@ApplyOptions<SentryListener.Options>({
  event: 'error'
})
// Extend `SentryListener` instead of `Listener`
export class ErrorListener extends SentryListener {
  public async run(error: unknown) {
    return this.captureException(error, {
      // your context options
    })
  }
}

With Javascript

import { SentryListener } from '@kaname-png/plugin-sentry';

module.exports = class ErrorListener extends SentryListener {
  constructor(context, options) {
    super(context, {
      ...options,
      event: 'error'
    })
  }

  async run(error) {
    return this.captureException(error, {
      // your context options
    })
  }
}

**The default listeners:

  • plugin-api: "error"
  • plugin-subcommands: "MessageSubcommandError", "chatInputSubcommandError"
  • plugin-scheduled-tasks: "scheduledTaskError"
  • framework: "messageCommandError", "chatInputCommandError", "contextMenuCommandError", "commandAutocompleteInteractionError", "error", "listenerError" and "interactionHandlerError"

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Kaname

💻 🐛 📖 🚇 🚧 👀

This project follows the all-contributors specification. Contributions of any kind welcome!

Package Sidebar

Install

npm i @kaname-png/plugin-sentry

Weekly Downloads

5

Version

1.4.0

License

MIT

Unpacked Size

121 kB

Total Files

100

Last publish

Collaborators

  • kaname-png