You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(js sdks): Add addGlobalEventProcessor to Event Processors page (#5803)
This adds the top-level `addGlobalEventProcessor` method to the Enriching Events -> Event Processors page alongside `addEventProcessor`.
Note that though this page is in the `common` section, it only applies to the JS-based SDKs (browser, node, and react native), as they are the only ones not included in the `notSupported` list.
Copy file name to clipboardExpand all lines: src/platforms/common/enriching-events/event-processors.mdx
+26-8Lines changed: 26 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: Event Processors
3
3
sidebar_order: 300
4
-
description: "Learn more about how you can add your own `eventProcessor` on the current scope."
4
+
description: "Learn more about how you can add your own event processors globally or to the current scope."
5
5
notSupported:
6
6
- android
7
7
- apple
@@ -22,27 +22,45 @@ notSupported:
22
22
- unreal
23
23
---
24
24
25
-
With `eventProcessors` you can hook into the process of enriching the event with additional data. You can add your own `eventProcessor` on the current scope. The difference between `beforeSend` and `eventProcessors` is that `eventProcessors` run on the scope level whereas `beforeSend` runs globally, no matter which scope you're in.
26
-
Also, `eventProcessors` optionally receive the hint (see: <PlatformLinkto="/configuration/filtering/#using-hints">hints</PlatformLink>).
25
+
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`, there are two key differences:
26
+
27
+
-`beforeSend` is guaranteed to be run last, after all other event processors, which means it gets 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.
28
+
- While `beforeSend` and processors added with `Sentry.addGlobalEventProcessor` run globally, regardless of scope, processors added with `scope.addEventProcessor` only run on events captured while that scope is active.
29
+
30
+
Both `beforeSend` and event processors are passed two arguments, the event itself and <PlatformLinkto="/configuration/filtering/#using-hints">a `hint` object</PlatformLink> containing extra metadata.
31
+
32
+
Event processors added to the global scope will run on every event sent after they are added.
27
33
28
34
```javascript
29
-
// This will be set globally for every succeeding event send
30
35
Sentry.configureScope(function(scope) {
31
36
scope.addEventProcessor(function(event, hint) {
32
37
// Add anything to the event here
33
-
// returning null will drop the event
38
+
// returning `null` will drop the event
34
39
returnevent;
35
40
});
36
41
});
37
42
38
-
// Using withScope, will only call the event processor for all "sends"
39
-
// that happen within withScope
43
+
// You can do the same thing using `addGlobalEventProcessor`
0 commit comments