import * as Sentry from "@sentry/core"; import { Middleware } from "inngest"; /** * Options used to configure the Sentry middleware. */ export interface SentryMiddlewareOptions { /** * If `true`, will not automatically flush events after each function run. * This can be useful if you want to control when events are sent to Sentry, * or leave it to Sentry's default behavior. * * By default, automatic flushing is enabled to ensure that events are sent in * serverless environments where the runtime may be terminated if the function * has returned a value. * * @default false */ disableAutomaticFlush?: boolean; /** * If `true`, exceptions are only captured on the final attempt of a step or * function run (when retries are exhausted or the error is non-retriable). * Intermediate retry attempts will still set span error status and add * breadcrumbs, but won't create Sentry events. * * This reduces noise for transient errors that resolve on retry. * * @default true */ onlyCaptureFinalAttempt?: boolean; /** * If `true`, step-level errors are captured as separate Sentry events in * addition to function-level errors. This gives granular visibility into * which step failed, but can produce duplicate events when a step error * propagates to the function level. * * When `false`, step errors are still recorded as error spans and breadcrumbs * (visible in traces), but only function-level errors produce Sentry events. * * @default false */ captureStepErrors?: boolean; } /** * Captures errors and performance data from Inngest functions and sends them to * Sentry. * * Can be used directly as a middleware class or configured via the * {@link sentryMiddleware} factory function. * * This imports Sentry directly and relies on it already being initialized using * `Sentry.init()`. For more information on how to configure Sentry, see the * [Sentry documentation](https://docs.sentry.io/platforms/node/). */ export declare class SentryMiddleware extends Middleware.BaseMiddleware { #private; readonly id = "inngest:sentry"; /** * See {@link SentryMiddlewareOptions} for more information. */ protected disableAutomaticFlush: boolean; /** * See {@link SentryMiddlewareOptions} for more information. */ protected onlyCaptureFinalAttempt: boolean; /** * See {@link SentryMiddlewareOptions} for more information. */ protected captureStepErrors: boolean; wrapRequest({ next, fn, runId, }: Middleware.WrapRequestArgs): Promise; wrapFunctionHandler({ next, ctx, }: Middleware.WrapFunctionHandlerArgs): Promise; transformFunctionInput(arg: Middleware.TransformFunctionInputArgs): Middleware.TransformFunctionInputArgs & { ctx: { sentry: typeof Sentry; }; }; onRunError({ error, isFinalAttempt }: Middleware.OnRunErrorArgs): void; onStepStart({ stepInfo }: Middleware.OnStepStartArgs): void; onStepComplete({ stepInfo }: Middleware.OnStepCompleteArgs): void; onStepError({ error, isFinalAttempt, stepInfo, }: Middleware.OnStepErrorArgs): void; } /** * Creates a configured Sentry middleware class. * * For default behavior, you can pass {@link SentryMiddleware} directly instead. */ export declare const sentryMiddleware: (opts?: SentryMiddlewareOptions) => typeof SentryMiddleware;