Skip to content

Commit

Permalink
ensure event processors are also applied without scope
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea committed Sep 15, 2023
1 parent b5b39ba commit 7a361b3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/core/src/utils/prepareEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Client, ClientOptions, Event, EventHint, StackFrame, StackParser }
import { dateTimestampInSeconds, GLOBAL_OBJ, normalize, resolvedSyncPromise, truncate, uuid4 } from '@sentry/utils';

import { DEFAULT_ENVIRONMENT } from '../constants';
import { getGlobalEventProcessors, notifyEventProcessors } from '../eventProcessors';
import { Scope } from '../scope';

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

const clientEventProcessors = client && client.getEventProcessors ? client.getEventProcessors() : [];

// This should be the last thing called, since we want that
// {@link Hub.addEventProcessor} gets the finished prepared event.
//
Expand All @@ -72,11 +75,10 @@ export function prepareEvent(
}

// In case we have a hub we reassign it.
result = finalScope.applyToEvent(
prepared,
hint,
client && client.getEventProcessors ? client.getEventProcessors() : [],
);
result = finalScope.applyToEvent(prepared, hint, clientEventProcessors);
} else {
// Apply client & global event processors even if there is no scope
result = notifyEventProcessors([...clientEventProcessors, ...getGlobalEventProcessors()], prepared, hint);
}

return result.then(evt => {
Expand Down

0 comments on commit 7a361b3

Please sign in to comment.