Skip to main content
Custom integrations allow you to extend the Sentry SDK with your own functionality, such as capturing custom data, filtering events, or integrating with third-party services.

Integration Basics

An integration is a function that returns an integration object with specific methods:

Simple Integration Example

Add custom data to all events:
Usage:

Integration Lifecycle Methods

setupOnce()

Called once when the SDK initializes. Use for global setup:

setup(client)

Called for each client instance. Use for client-specific setup:

processEvent(event, hint, client)

Process events before they’re sent:

Advanced Integrations

Automatic Instrumentation

Capture breadcrumbs from custom events:

Third-Party Service Integration

Integrate with analytics or logging services:

Performance Monitoring Integration

Add custom performance tracking:

Integration with Options

Accept configuration options:
Usage:

Client Hooks

Listen to SDK events:

Filtering Events

Drop events based on custom logic:

Testing Integrations

Best Practices

Always use defineIntegration for proper typing and structure:
Don’t let integration errors crash the app:
Clean up resources when the integration is removed:
Provide clear documentation on:
  • What the integration does
  • Available options
  • Performance impact
  • Browser/Node compatibility
Each integration should have a single, clear purpose. Don’t create “god integrations” that do too much.

Complete Example

Usage:

Next Steps

Custom Transports

Build custom transport layers

OpenTelemetry

Integrate with OpenTelemetry