DebugBundle
SDKs

Universal SDK Interface

The complete interface contract shared by every DebugBundle SDK — methods, config fields, behavior guarantees, and volume controls.

Every DebugBundle SDK implements this universal interface contract. Language-specific naming conventions differ (camelCase for JavaScript/PHP, snake_case for Python), but the semantics, behavior guarantees, and volume control rules are identical.

Core Methods

Every SDK exposes these methods:

MethodPurposeReturns
init(config)Initialize the SDK with configuration. Must be called once before any capture.void
captureException(error, context?)Capture an error/exception with optional context.void
captureLog(message, level, context?)Capture a structured log event.void
captureRequest(request, response, context?)Capture an HTTP request/response pair.void
captureMessage(message, level?, context?)Capture a diagnostic message.void
setContext(key, value)Attach persistent context to all future events.void
probe(label, data, opts?)Buffer diagnostic data in a ring buffer.void
flush()Force-send all buffered events.Promise<void>

Language Naming Conventions

LanguageStyleExample
Node.jscamelCasedebugbundle.captureException(err)
BrowsercamelCasedebugbundle.captureException(err)
Pythonsnake_casedebugbundle.capture_exception(err)
PHPcamelCase (PSR)DebugBundle::captureException($e)

Configuration Fields

All SDKs accept these common configuration fields:

FieldTypeDefaultDescription
projectTokenstringRequired. Project token for ingestion auth (dbundle_proj_...).
environmentstringauto-detectDeployment environment: production, staging, development, etc.
servicestringauto-detectService name for multi-service projects.
enabledbooleantrueKill switch — set to false to disable all capture.
redactFieldsstring[]Default setAdditional field names to redact before transmission.
sampleRatenumber1.0Event sampling rate (0.0–1.0). Applied per-event.
batchSizenumberSDK-specificMax events per batch (Node: 50, Browser: 25).
flushIntervalnumber (ms)SDK-specificMax time before batch send (Node: 2000, Browser: 5000).
endpointstringhttps://api.debugbundle.com/v1/eventsIngestion endpoint URL.
transportstringauto-detecthttp, file, or relay (browser only).
localEventsDirstring.debugbundle/local/eventsDirectory for file transport output.

Browser-Specific Fields

FieldTypeDefaultDescription
maxBreadcrumbsnumber10Ring buffer size for breadcrumbs.
breadcrumbsOnErrorOnlybooleantrueOnly ship breadcrumbs alongside exceptions.
captureNetworkbooleantrueCapture network request breadcrumbs.
captureClicksbooleantrueCapture click event breadcrumbs.
captureRouteChangesbooleantrueCapture navigation breadcrumbs.
captureConsolebooleanfalseCapture console.error/console.warn breadcrumbs.
networkFilterobjectFilter network breadcrumbs by URL, status code, response time.
sessionSampleRatenumber1.0Session-level sampling (all-or-nothing per session).
maxEventsPerSessionnumber100Hard cap per session; only exceptions permitted after cap.

Transport Modes

ModeSDKDescription
httpAllDirect HTTPS to ingestion API. Default for connected projects.
fileNode, Python, PHPWrite events to local filesystem for CLI processing. Default for local-only projects.
relayBrowserSend events through your backend relay endpoint instead of directly to DebugBundle.

Transport is automatically selected based on your .debugbundle/local/connection.json mode:

  • Local-onlyfile transport (server SDKs), relay or http (browser)
  • Connectedhttp transport

Event Envelope

Every captured event is wrapped in a standard envelope:

{
  "event_id": "evt_01HXYZ...",
  "event_type": "backend_exception",
  "timestamp": "2026-03-24T10:30:00.000Z",
  "service": { "name": "api-server", "environment": "production" },
  "sdk": { "name": "@debugbundle/sdk-node", "version": "1.0.0" },
  "context": { "user_id": "usr_123" },
  "payload": { /* event-type-specific data */ }
}

Event Types

TypeSourceDescription
backend_exceptionServer SDKsUnhandled or manually captured exceptions.
frontend_exceptionBrowser SDKJavaScript errors and promise rejections.
request_eventServer SDKsHTTP request/response pairs.
log_eventAll SDKsStructured log entries.
frontend_breadcrumbBrowser SDKUser interaction breadcrumbs (clicks, navigation, network).
deploy_metadataCLI / APIDeployment information.
error_suppressedAll SDKsAggregated duplicate errors from volume control.
probe_eventAll SDKsDiagnostic ring buffer snapshots.

Volume Control

All SDKs implement mandatory volume control to prevent event storms:

Duplicate Suppression

When the SDK captures the same error repeatedly:

  1. First 3 occurrences in a 30-second window → sent normally
  2. Subsequent duplicates → aggregated into a single error_suppressed event with occurrence count
  3. Window resets after 30 seconds of silence

"Same error" is determined by fingerprinting: error class + message + top stack frame.

Loop Protection

Prevents runaway error loops from flooding the ingestion API:

  1. Trigger: More than 10 identical errors in 2 seconds
  2. Action: Force suppression — all events for that fingerprint held in buffer
  3. Checkpoint: Every 30 seconds, one event released to check if the loop has stopped
  4. Reset: After 60 seconds with no new occurrences, normal capture resumes

Buffer Retention

  • Events are never dropped on transport failure
  • SDK respects Retry-After headers from the ingestion API
  • Buffer has a hard size limit (configurable per SDK) to prevent memory exhaustion
  • On buffer overflow, oldest non-exception events are evicted first

Probes

Probes are diagnostic ring buffers that capture application state over time:

// Node.js
debugbundle.probe('db_pool', () => ({
  active: pool.activeCount,
  idle: pool.idleCount,
  waiting: pool.waitingCount,
}));

Probe Types

TypeDescriptionTrigger
Always-onCaptures data at every probe call.Automatic, based on interval.
LazyCaptures only when an incident is being processed.On-demand during bundle generation.
HeavyCaptures detailed/expensive data. Remote-activation only (paid tiers).Activated via API/CLI/MCP.

Ring Buffer

Probe data is stored in a fixed-size ring buffer (default 10 entries). When the buffer is full, the oldest entry is overwritten. This keeps memory usage constant regardless of probe frequency.

Safety Guarantees

Every SDK enforces these guarantees:

  1. Never throw — SDK methods never throw uncaught exceptions into user code
  2. Never block — SDK methods never block the request/response cycle
  3. Never crash — SDK failures are caught internally and swallowed silently
  4. Graceful degradation — If the ingestion API is unreachable, events are buffered and retried
  5. Memory bounded — Buffers have hard limits to prevent memory exhaustion

Redaction

All SDKs apply automatic redaction before events leave the process:

Default Redacted Fields

password, secret, token, authorization, cookie, set-cookie, x-api-key, credit_card, card_number, cvv, ssn, social_security

Custom Redaction

debugbundle.init({
  projectToken: process.env.DEBUGBUNDLE_PROJECT_TOKEN,
  redactFields: ['x-custom-secret', 'internal_id'],
});

Custom fields are merged with defaults — you cannot disable default redaction.

SDK Comparison Matrix

FeatureNode.jsBrowserPythonPHP
Status✅ Shipped✅ Shipped🔜 Coming Soon🔜 Coming Soon
Package@debugbundle/sdk-node@debugbundle/sdk-browserdebugbundle-pythondebugbundle/sdk-php
Framework integrationsExpress, Fastify, Next.jsDjango, Flask, FastAPILaravel, Symfony
Logger integrationspino, winston, bunyanlogging, structlog, loguruMonolog
Breadcrumbs
Relay handler✅ (exports)
Probes
File transport

Next Steps

On this page