1.0.4 • Published 25 days ago

@benhepburn/adonis-sentry v1.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
25 days ago

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

25 days ago

1.0.3

26 days ago

1.0.1

29 days ago

1.0.0

29 days ago