Functions and Classes
This page provides the API reference for functions, classes, and exported services in @eienjs/adonisjs-sentry.
Functions
defineConfig(config)
Validates and returns the Sentry configuration object for AdonisJS.
import { defineConfig } from '@eienjs/adonisjs-sentry';
export default defineConfig({
enabled: true,
environment: 'production',
dsn: 'https://...',
});
- Parameters:
config(SentryConfig): Sentry configuration options.
- Returns:
SentryConfig - Throws:
RuntimeException: Whenenvironmentis missing or empty.RuntimeException: Whenenabledistruebutdsnis missing or undefined.
reportException(error, ctx?)
Captures an exception in Sentry with contextual metadata and tags.
import { reportException } from '@eienjs/adonisjs-sentry';
// Inside HttpExceptionHandler
const eventId = reportException(error, ctx);
// Standalone in background job or service
const eventId = reportException(error);
- Parameters:
error(unknown): The exception or error to capture.ctx(HttpContext, optional): The AdonisJS HTTP context for the current request.
- Returns:
string | undefined— The generated Sentry event ID, orundefinedif Sentry is disabled, uninitialized, or the exception matches an ignore list.
configure(command)
Invoked internally by AdonisJS during node ace configure @eienjs/adonisjs-sentry.
- Parameters:
command(ConfigureCommand): The Ace configure command instance.
Exports
Sentry
A direct re-export of the entire @sentry/node SDK namespace.
import { Sentry } from '@eienjs/adonisjs-sentry';
Sentry.captureMessage('Order placed', 'info');
Sentry.addBreadcrumb({ category: 'cart', message: 'Item added' });
stubsRoot
Absolute filesystem path pointing to the package's stubs/ directory.
import { stubsRoot } from '@eienjs/adonisjs-sentry';
Classes
SentryMiddleware
Import path: @eienjs/adonisjs-sentry/middleware/sentry_middleware
AdonisJS router middleware that isolates the Sentry scope for each HTTP request and instruments root spans.
Methods
handle(ctx: HttpContext, next: NextFn): Promise<unknown>- Evaluates whether Sentry is initialized.
- Wraps execution in
Sentry.withIsolationScope(...). - Sets transaction name
${method} ${pattern}and updates the active root span. - Attaches
route,http.method, andrequest_idtags.
SentryProvider
Import path: @eienjs/adonisjs-sentry/providers/sentry_provider
The service provider registered in adonisrc.ts.
Methods
register(): Promise<void>- Reads
config/sentry.ts. - Configures global reporting options via
configureReporting(report). - Initializes
Sentry.init(options)if enabled and not already initialized.
- Reads
shutdown(): Promise<void>- Flushes queued events and closes the Sentry client with a 2-second timeout (
Sentry.close(2000)).
- Flushes queued events and closes the Sentry client with a 2-second timeout (
VerifySentryIntegration
Import path: @eienjs/adonisjs-sentry/commands/verify_sentry_integration
Ace command class representing node ace sentry:verify.
Properties
static commandName:'sentry:verify'static description:'Generate a test event and send it to Sentry'
