Skip to content

Commit b5b39ba

Browse files
committed
ref(core): Run client eventProcessors before global ones
1 parent d8b879a commit b5b39ba

File tree

2 files changed

+29
-22
lines changed

2 files changed

+29
-22
lines changed

packages/core/src/scope.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,11 @@ export class Scope implements ScopeInterface {
467467
* @param hint Object containing additional information about the original exception, for use by the event processors.
468468
* @hidden
469469
*/
470-
public applyToEvent(event: Event, hint: EventHint = {}): PromiseLike<Event | null> {
470+
public applyToEvent(
471+
event: Event,
472+
hint: EventHint = {},
473+
additionalEventProcessors?: EventProcessor[],
474+
): PromiseLike<Event | null> {
471475
if (this._extra && Object.keys(this._extra).length) {
472476
event.extra = { ...this._extra, ...event.extra };
473477
}
@@ -517,7 +521,12 @@ export class Scope implements ScopeInterface {
517521
propagationContext: this._propagationContext,
518522
};
519523

520-
return notifyEventProcessors([...getGlobalEventProcessors(), ...this._eventProcessors], event, hint);
524+
// TODO (v8): Update this order to be: Global > Client > Scope
525+
return notifyEventProcessors(
526+
[...(additionalEventProcessors || []), ...getGlobalEventProcessors(), ...this._eventProcessors],
527+
event,
528+
hint,
529+
);
521530
}
522531

523532
/**

packages/core/src/utils/prepareEvent.ts

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import type { Client, ClientOptions, Event, EventHint, StackFrame, StackParser }
22
import { dateTimestampInSeconds, GLOBAL_OBJ, normalize, resolvedSyncPromise, truncate, uuid4 } from '@sentry/utils';
33

44
import { DEFAULT_ENVIRONMENT } from '../constants';
5-
import { notifyEventProcessors } from '../eventProcessors';
65
import { Scope } from '../scope';
76

87
/**
@@ -73,28 +72,27 @@ export function prepareEvent(
7372
}
7473

7574
// In case we have a hub we reassign it.
76-
result = finalScope.applyToEvent(prepared, hint);
75+
result = finalScope.applyToEvent(
76+
prepared,
77+
hint,
78+
client && client.getEventProcessors ? client.getEventProcessors() : [],
79+
);
7780
}
7881

79-
return result
80-
.then(evt => {
81-
// Process client-scoped event processors
82-
return client && client.getEventProcessors ? notifyEventProcessors(client.getEventProcessors(), evt, hint) : evt;
83-
})
84-
.then(evt => {
85-
if (evt) {
86-
// We apply the debug_meta field only after all event processors have ran, so that if any event processors modified
87-
// file names (e.g.the RewriteFrames integration) the filename -> debug ID relationship isn't destroyed.
88-
// This should not cause any PII issues, since we're only moving data that is already on the event and not adding
89-
// any new data
90-
applyDebugMeta(evt);
91-
}
82+
return result.then(evt => {
83+
if (evt) {
84+
// We apply the debug_meta field only after all event processors have ran, so that if any event processors modified
85+
// file names (e.g.the RewriteFrames integration) the filename -> debug ID relationship isn't destroyed.
86+
// This should not cause any PII issues, since we're only moving data that is already on the event and not adding
87+
// any new data
88+
applyDebugMeta(evt);
89+
}
9290

93-
if (typeof normalizeDepth === 'number' && normalizeDepth > 0) {
94-
return normalizeEvent(evt, normalizeDepth, normalizeMaxBreadth);
95-
}
96-
return evt;
97-
});
91+
if (typeof normalizeDepth === 'number' && normalizeDepth > 0) {
92+
return normalizeEvent(evt, normalizeDepth, normalizeMaxBreadth);
93+
}
94+
return evt;
95+
});
9896
}
9997

10098
/**

0 commit comments

Comments
 (0)