Skip to main content
Filtering allows you to control which events, breadcrumbs, and spans are sent to Sentry, helping reduce noise and protect sensitive data.

Event Filtering with beforeSend

The beforeSend hook processes all error events before they’re sent:
Returning null from beforeSend drops the event entirely. Use this carefully to avoid losing important error data.

Event Hint

The hint parameter contains the original error and additional context:

Transaction Filtering with beforeSendSpan

Filter performance data before sending:
Starting in SDK v9, you cannot drop spans in beforeSendSpan by returning null. This hook is for modifying span data only. To control which spans are created, configure integrations instead.

Filtering with Integrations

Inbound Filters Integration

The inboundFiltersIntegration (enabled by default) filters common noise:

Common Ignore Patterns

Filter breadcrumbs before they’re added:

Filtering Sensitive Data

Scrubbing Request Data

Scrubbing User Data

Use sendDefaultPii: false to prevent the SDK from sending PII by default. Then explicitly set only the user data you want to send.

Filtering by Error Type

Filtering by User

Filtering by Environment

It’s usually better to disable Sentry entirely in development rather than filtering in beforeSend:

Filtering Network Requests

HTTP Client Integration

Filter outgoing request breadcrumbs:

Filtering Third-Party Errors

Use the thirdPartyErrorFilterIntegration to filter errors from third-party scripts:

Advanced Filtering Patterns

Rate Limiting Specific Errors

Conditional Filtering Based on Context

Best Practices

When possible, explicitly allow what you want rather than denying what you don’t:
It’s more efficient to prevent events from being created than to filter them in beforeSend:
In beforeSend and beforeBreadcrumb, always explicitly return or drop:
Overly aggressive filtering can hide important issues. Start conservative and refine based on actual noise.
In development, log what you’re filtering to verify your rules:

Complete Example

Next Steps

Error Handling

Best practices for error handling

Performance Monitoring

Optimize performance monitoring