@benhepburn/adonis-sentry
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

AdonisJS Sentry

Install

Install from npm:

npm install @benhepburn/adonis-sentry

or

pnpm install @benhepburn/adonis-sentry

or

yarn add @benhepburn/adonis-sentry

Then, configure the package for Adonis:

node ace configure @benhepburn/adonis-sentry

Configuration

Enter the Sentry DSN and Traces sample rate in your .env file:

SENTRY_DSN=https://<...>.sentry.io/<...>
SENTRY_TRACES_SAMPLE_RATE=1.0 # Set this to a lower value in production

To enable enhanced event data, you must enable useAsyncLocalStorage in config/app.ts so the current request can be fetched (see caveats here):

useAsyncLocalStorage: true,

Usage

Import the service to use it:

import sentry from "@benhepburn/adonis-sentry/service"

To capture all exceptions, add the capture line to app/exceptions/handler.ts inside the report function:

async report(error: unknown, ctx: HttpContext) {
  sentry.captureException(error); // Add this line
  ...
  return super.report(error, ctx);
}

Exceptions can be captured manually as well:

try {
  ...
} catch (error: unknown) {
  sentry.captureException(error);
}

Package Sidebar

Install

npm i @benhepburn/adonis-sentry

Weekly Downloads

36

Version

1.0.4

License

MIT

Unpacked Size

10.6 kB

Total Files

18

Last publish

Collaborators

  • benhepburn