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 before-send
and before-send-transaction
, there are two key differences:
before-send
andbefore-send-transaction
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
before-send
,before-send-transaction
, and processors added withSentry.add-global-event-processor
run globally, regardless of scope, processors added withscope.add-event-processor
only run on events captured while that scope is active.
Like before-send
and before-send-transaction
, 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").