1.3.1 • Published 14 days ago

@kaname-png/plugin-sentry v1.3.1

Weekly downloads
-
License
MIT
Repository
github
Last release
14 days ago

Neko Plugins Logo

@kaname-png/plugin-sentry

Plugin for @sapphire/framework to post error on 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

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
    })
  }
}

Contributors ✨

Thanks goes to these wonderful people (emoji key):

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