Filtering
Adding Sentry to your app gives you a great deal of very valuable information about errors and performance you wouldn't otherwise get. And lots of information is good -- as long as it's the right information, at a reasonable volume.
The Sentry SDKs have several configuration options to help you filter out events.
We also offer Inbound Filters to filter events in sentry.io. We recommend filtering at the client level though, because it removes the overhead of sending events you don't actually want. Learn more about the fields available in an event.
Filtering Error Events
Configure your SDK to filter error events by using the beforeSend
callback method and configuring, enabling, or disabling integrations.
Using beforeSend
All Sentry SDKs support the beforeSend
callback method. beforeSend
is called immediately before the event is sent to the server, so it’s the final place where you can edit its data. It receives the event object as a parameter, so you can use that to modify the event’s data or drop it completely (by returning null
) based on custom logic and the data available on the event.
import Sentry
SentrySDK.start { options in
options.dsn = "https://examplePublicKey@o0.ingest.sentry.io/0"
options.beforeSend = { event in
// modify event here or return NULL to discard the event
return event
}
}
Note also that breadcrumbs can be filtered, as discussed in our Breadcrumbs documentation.
- Package:
- cocoapods:sentry-cocoa
- Version:
- 8.32.0
- Repository:
- https://github.com/getsentry/sentry-cocoa