Event Processors
You can enrich events with additional data by adding your own event processors, either on the scope level or globally. Though event processors are similar to beforeSend
and beforeSendTransaction
, there are two key differences:
beforeSend
andbeforeSendTransaction
are guaranteed to be run last, after all other event processors, (which means they get the final version of the event right before it's sent, hence the name). Event processors added with either of the methods below run in an undetermined order, which means changes to the event may still be made after the event processor runs.- While
beforeSend
,beforeSendTransaction
, and processors added withSentry.addGlobalEventProcessor
run globally, regardless of scope, processors added withscope.addEventProcessor
only run on events captured while that scope is active.
Like beforeSend
and beforeSendTransaction
, event processors are passed two arguments, the event itself and a hint
object containing extra metadata.
Event processors added to the current scope will run on every event sent after they are added.
Copied
Sentry.addEventProcessor(function (event, hint) {
// Add anything to the event here
// returning `null` will drop the event
return event;
});
Event processors added to a local scope using withScope
only apply to events captured inside that scope.
Copied
Sentry.withScope(function (scope) {
scope.addEventProcessor(function (event, hint) {
// Add anything to the event here
// returning `null` will drop the event
return event;
});
// The event processor will apply to this event
Sentry.captureMessage("Test");
});
// The event processor will NOT apply to this event
Sentry.captureMessage("Test2");
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").
- Package:
- npm:@sentry/react-native
- Version:
- 5.20.0
- Repository:
- https://github.com/getsentry/sentry-react-native