CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-sentry--integrations

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

Pending
Overview
Eval results
Files

console-capture.mddocs/

Console Capture

Captures Console API calls (console.log, console.error, console.warn, etc.) as Sentry events. This integration is useful for debugging and monitoring console output in production environments.

Capabilities

Modern Function-based Integration

/**
 * Captures Console API calls as Sentry events
 * @param options - Configuration options for console capture
 * @returns Integration instance
 */
function captureConsoleIntegration(options?: CaptureConsoleOptions): Integration;

interface CaptureConsoleOptions {
  /** Console levels to capture. Defaults to all available console levels */
  levels?: string[];
}

Usage Examples:

import { captureConsoleIntegration } from '@sentry/integrations';

// Capture all console levels (default)
const consoleIntegration = captureConsoleIntegration();

// Capture only errors and warnings
const errorWarningConsole = captureConsoleIntegration({
  levels: ['error', 'warn']
});

// Capture specific levels
const customLevels = captureConsoleIntegration({
  levels: ['error', 'warn', 'info', 'debug']
});

Legacy Class-based Integration (Deprecated)

/**
 * Legacy class-based console capture integration
 * @deprecated Use captureConsoleIntegration() instead
 */
class CaptureConsole implements Integration {
  constructor(options?: { levels?: string[] });
  name: string;
  setup(client: Client): void;
}

Configuration

Console Levels

The levels option accepts an array of console method names. Available levels are:

  • 'debug' - console.debug() calls
  • 'info' - console.info() calls
  • 'warn' - console.warn() calls
  • 'error' - console.error() calls
  • 'log' - console.log() calls
  • 'assert' - console.assert() calls
  • 'trace' - console.trace() calls

If not specified, all available console levels are captured (uses CONSOLE_LEVELS from @sentry/utils which contains: ['debug', 'info', 'warn', 'error', 'log', 'assert', 'trace']).

Behavior

Event Creation

  • Regular console calls: Creates message events with the console arguments
  • console.assert(): Creates message events when assertion fails (first argument is false)
  • console.error() with Error objects: Creates exception events when Error objects are found in arguments
  • Event metadata: All events include:
    • logger: 'console' field
    • level set based on console method used
    • extra.arguments containing the original console arguments
    • Exception mechanism with type: 'console' and handled: false

Argument Processing

Console arguments are processed as follows:

  • Arguments are joined with spaces for the message text
  • Original arguments are preserved in extra.arguments
  • Error objects are converted to exception events when possible
  • console.assert() uses arguments after the first (assertion condition) for the message

Usage in Sentry Configuration:

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

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

// These will now be captured as Sentry events:
console.error('API request failed', { status: 404 });
console.warn('Deprecated function used');
console.assert(false, 'Assertion failed with details');

Install with Tessl CLI

npx tessl i tessl/npm-sentry--integrations

docs

console-capture.md

context-lines.md

debug-integration.md

error-deduplication.md

extra-error-data.md

frame-rewriting.md

http-client.md

index.md

offline-support.md

reporting-observer.md

session-timing.md

transaction-integration.md

tile.json