or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

console-capture.mdcontext-lines.mddebug-integration.mderror-deduplication.mdextra-error-data.mdframe-rewriting.mdhttp-client.mdindex.mdoffline-support.mdreporting-observer.mdsession-timing.mdtransaction-integration.md
tile.json

tessl/npm-sentry--integrations

Pluggable integrations that enhance Sentry JavaScript SDKs with additional error tracking, monitoring, and debugging capabilities.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@sentry/integrations@7.120.x

To install, run

npx @tessl/cli install tessl/npm-sentry--integrations@7.120.0

index.mddocs/

Sentry Integrations

The @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:

  • Client-side migration guide
  • Server-side migration guide

Package Information

  • Package Name: @sentry/integrations
  • Package Type: npm
  • Language: TypeScript/JavaScript
  • Installation: npm install @sentry/integrations

Core Imports

All 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');

Basic Usage

import * as Sentry from '@sentry/browser';
import { captureConsoleIntegration, dedupeIntegration } from '@sentry/integrations';

Sentry.init({
  dsn: 'YOUR_DSN',
  integrations: [
    captureConsoleIntegration({
      levels: ['error', 'warn']
    }),
    dedupeIntegration()
  ]
});

Architecture

The integrations package follows a dual-pattern architecture:

  • Modern Function-based: Each integration exports a factory function that returns an integration object. Uses defineIntegration() for consistent behavior.
  • Legacy Class-based: Each integration exports a class that implements the Integration interface. Converted from function-based using convertIntegrationFnToClass().
  • Hook System: Integrations can hook into various points in the Sentry event pipeline through methods like setup(), setupOnce(), and processEvent().
  • Client Integration: Most integrations register event handlers or processors with the Sentry client when activated.

Capabilities

Console Capture

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[];
}

Console Capture

Error Deduplication

Removes duplicate error events based on message, exception, stacktrace, and fingerprint comparison. Prevents spam from repeated errors.

function dedupeIntegration(): Integration;

Error Deduplication

Debug 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;
}

Debug Integration

Extra Error Data

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

Extra Error Data

HTTP Client Monitoring

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;

HTTP Client Monitoring

Frame Rewriting

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;

Frame Rewriting

Reporting Observer

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';

Reporting Observer

Context Lines

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

Context Lines

Session Timing

Adds session duration information to events, tracking time since Sentry initialization.

function sessionTimingIntegration(): Integration;

Session Timing

Offline Support

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

Offline Support

Transaction Integration

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
}

Transaction Integration

Core Types

// 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;