Pluggable integrations that enhance Sentry JavaScript SDKs with additional error tracking, monitoring, and debugging capabilities.
npx @tessl/cli install tessl/npm-sentry--integrations@7.120.0The @sentry/integrations package provides a collection of pluggable integrations that enhance the functionality of Sentry JavaScript SDKs. These integrations add capabilities for error tracking, monitoring, debugging, and data collection across different environments.
Note: This package was discontinued with version 8.0.0 of the Sentry JavaScript SDKs. All integrations from this package are now directly exported from the SDK packages like @sentry/react and @sentry/node for better maintenance and reduced bundle size.
For migration guidance, see:
npm install @sentry/integrationsAll integrations are available as both modern function-based integrations (recommended) and legacy class-based integrations (deprecated):
// Modern function-based integrations (recommended)
import { captureConsoleIntegration, debugIntegration, dedupeIntegration } from '@sentry/integrations';
// Legacy class-based integrations (deprecated)
import { CaptureConsole, Debug, Dedupe } from '@sentry/integrations';CommonJS:
const { captureConsoleIntegration, debugIntegration } = require('@sentry/integrations');import * as Sentry from '@sentry/browser';
import { captureConsoleIntegration, dedupeIntegration } from '@sentry/integrations';
Sentry.init({
dsn: 'YOUR_DSN',
integrations: [
captureConsoleIntegration({
levels: ['error', 'warn']
}),
dedupeIntegration()
]
});The integrations package follows a dual-pattern architecture:
defineIntegration() for consistent behavior.convertIntegrationFnToClass().setup(), setupOnce(), and processEvent().Captures Console API calls (console.log, console.error, etc.) as Sentry events. Useful for debugging and monitoring console output in production.
function captureConsoleIntegration(options?: CaptureConsoleOptions): Integration;
interface CaptureConsoleOptions {
levels?: string[];
}Removes duplicate error events based on message, exception, stacktrace, and fingerprint comparison. Prevents spam from repeated errors.
function dedupeIntegration(): Integration;Development-only integration that logs events to console and optionally triggers debugger breakpoints before events are sent.
function debugIntegration(options?: DebugOptions): Integration;
interface DebugOptions {
stringify?: boolean;
debugger?: boolean;
}Extracts additional custom properties from Error objects and attaches them as event context. Captures error causes and custom error properties.
function extraErrorDataIntegration(options?: Partial<ExtraErrorDataOptions>): Integration;
interface ExtraErrorDataOptions {
/** The object depth up to which to capture data on error objects. Default: 3 */
depth: number;
/** Whether to capture error causes (Error.cause property). Default: false */
captureErrorCause: boolean;
}Monitors HTTP requests (fetch and XMLHttpRequest) and creates events for failed requests based on status codes and URL patterns.
function httpClientIntegration(options?: Partial<HttpClientOptions>): Integration;
interface HttpClientOptions {
/** HTTP status codes that should be considered failed. Default: [[500, 599]] */
failedRequestStatusCodes: HttpStatusCodeRange[];
/** Targets to track for failed requests. Default: [/.*/] */
failedRequestTargets: HttpRequestTarget[];
}
type HttpStatusCodeRange = [number, number] | number;
type HttpRequestTarget = string | RegExp;Transforms stack frame filenames using configurable rules. Useful for normalizing paths in different deployment environments.
function rewriteFramesIntegration(options?: RewriteFramesOptions): Integration;
interface RewriteFramesOptions {
/** Root path to strip from filenames */
root?: string;
/** Prefix to add to rewritten filenames. Default: 'app:///' */
prefix?: string;
/** Custom frame processing function */
iteratee?: StackFrameIteratee;
}
type StackFrameIteratee = (frame: StackFrame) => StackFrame;Browser-only integration that captures Reporting API events (crash reports, deprecation warnings, intervention reports).
function reportingObserverIntegration(options?: ReportingObserverOptions): Integration;
interface ReportingObserverOptions {
types?: ReportTypes[];
}
type ReportTypes = 'crash' | 'deprecation' | 'intervention';Browser-only integration that adds source context lines to stack frames for inline JavaScript in HTML pages.
function contextLinesIntegration(options?: ContextLinesOptions): Integration;
interface ContextLinesOptions {
frameContextLines?: number;
}Adds session duration information to events, tracking time since Sentry initialization.
function sessionTimingIntegration(): Integration;Legacy class-based integration for caching events when offline and sending them when connection is restored. Deprecated in favor of offline transport wrapper.
class Offline implements Integration {
constructor(options?: { maxStoredEvents?: number });
}Legacy integration that adds transaction names to events based on stack frames. Deprecated and will be removed in v8.
class Transaction implements Integration {
// No configuration options
}// Integration base interface from @sentry/types
interface Integration {
name: string;
setupOnce?(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void;
setup?(client: Client): void;
processEvent?(event: Event, hint: EventHint, client: Client): Event | null | PromiseLike<Event | null>;
}
// Core Sentry types
interface Client<O extends ClientOptions = ClientOptions> {
getOptions(): O;
getDsn(): DsnComponents | undefined;
captureException(exception: any, hint?: EventHint, scope?: Scope): string;
captureMessage(message: string, level?: SeverityLevel, hint?: EventHint, scope?: Scope): string;
captureEvent(event: Event, hint?: EventHint, scope?: Scope): string;
// ... additional client methods
}
interface Event {
event_id?: string;
message?: string;
timestamp?: number;
level?: SeverityLevel;
platform?: string;
logger?: string;
fingerprint?: string[];
tags?: Record<string, string>;
extra?: Record<string, any>;
contexts?: Record<string, any>;
exception?: {
values?: Exception[];
};
// ... additional event properties
}
interface EventHint {
data?: any;
event_id?: string;
originalException?: Error | string;
syntheticException?: Error;
// ... additional hint properties
}
type EventProcessor = (event: Event, hint?: EventHint) => Event | null | PromiseLike<Event | null>;
// Stack frame type for rewriteFrames integration
interface StackFrame {
filename?: string;
function?: string;
module?: string;
platform?: string;
lineno?: number;
colno?: number;
abs_path?: string;
context_line?: string;
pre_context?: string[];
post_context?: string[];
in_app?: boolean;
instruction_addr?: string;
addr_mode?: string;
package?: string;
symbol?: string;
symbol_addr?: string;
image_addr?: string;
}
// Factory function type for modern integrations
type IntegrationFn = (...args: any[]) => Integration;
// Class type for legacy integrations
type IntegrationClass<T extends Integration = Integration> = new (...args: any[]) => T;