Skip to content

Commit a34aeaf

Browse files
committed
ensure event processors are also applied without scope
1 parent 17a07e8 commit a34aeaf

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

packages/core/src/utils/prepareEvent.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ 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 { getGlobalEventProcessors, notifyEventProcessors } from '../eventProcessors';
56
import { Scope } from '../scope';
67

78
/**
@@ -54,6 +55,8 @@ export function prepareEvent(
5455
// We prepare the result here with a resolved Event.
5556
let result = resolvedSyncPromise<Event | null>(prepared);
5657

58+
const clientEventProcessors = client && client.getEventProcessors ? client.getEventProcessors() : [];
59+
5760
// This should be the last thing called, since we want that
5861
// {@link Hub.addEventProcessor} gets the finished prepared event.
5962
//
@@ -72,11 +75,11 @@ export function prepareEvent(
7275
}
7376

7477
// In case we have a hub we reassign it.
75-
result = finalScope.applyToEvent(
76-
prepared,
77-
hint,
78-
client && client.getEventProcessors ? client.getEventProcessors() : [],
79-
);
78+
result = finalScope.applyToEvent(prepared, hint, clientEventProcessors);
79+
} else {
80+
// Apply client & global event processors even if there is no scope
81+
// TODO (v8): Update the order to be Global > Client
82+
result = notifyEventProcessors([...clientEventProcessors, ...getGlobalEventProcessors()], prepared, hint);
8083
}
8184

8285
return result.then(evt => {

0 commit comments

Comments
 (0)