Skip to content

Commit 93db2dc

Browse files
authored
feat(core): Update addEventProcessor to add to isolation scope (#10606)
Instead of to the client. This was done to ensure this would be "global" without using the fully global event processors (which need to be removed in a separate step). But in the new model, it makes more sense to add them to the isolation scope.
1 parent 31faca3 commit 93db2dc

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

packages/core/src/baseclient.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ import {
4949
import { getEnvelopeEndpointWithUrlEncodedAuth } from './api';
5050
import { DEBUG_BUILD } from './debug-build';
5151
import { createEventEnvelope, createSessionEnvelope } from './envelope';
52-
import { getClient } from './exports';
5352
import { getIsolationScope } from './hub';
5453
import type { IntegrationIndex } from './integration';
5554
import { afterSetupIntegrations } from './integration';
@@ -933,17 +932,3 @@ function isErrorEvent(event: Event): event is ErrorEvent {
933932
function isTransactionEvent(event: Event): event is TransactionEvent {
934933
return event.type === 'transaction';
935934
}
936-
937-
/**
938-
* Add an event processor to the current client.
939-
* This event processor will run for all events processed by this client.
940-
*/
941-
export function addEventProcessor(callback: EventProcessor): void {
942-
const client = getClient();
943-
944-
if (!client || !client.addEventProcessor) {
945-
return;
946-
}
947-
948-
client.addEventProcessor(callback);
949-
}

packages/core/src/exports.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type {
77
CustomSamplingContext,
88
Event,
99
EventHint,
10+
EventProcessor,
1011
Extra,
1112
Extras,
1213
FinishedCheckIn,
@@ -382,6 +383,15 @@ export function getCurrentScope(): Scope {
382383
return getCurrentHub().getScope();
383384
}
384385

386+
/**
387+
* Add an event processor.
388+
* This will be added to the current isolation scope, ensuring any event that is processed in the current execution
389+
* context will have the processor applied.
390+
*/
391+
export function addEventProcessor(callback: EventProcessor): void {
392+
getIsolationScope().addEventProcessor(callback);
393+
}
394+
385395
/**
386396
* Start a session on the current isolation scope.
387397
*

packages/core/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export {
3434
endSession,
3535
captureSession,
3636
withActiveSpan,
37+
addEventProcessor,
3738
} from './exports';
3839
export {
3940
// eslint-disable-next-line deprecation/deprecation
@@ -58,7 +59,7 @@ export {
5859
addGlobalEventProcessor,
5960
} from './eventProcessors';
6061
export { getEnvelopeEndpointWithUrlEncodedAuth, getReportDialogEndpoint } from './api';
61-
export { BaseClient, addEventProcessor } from './baseclient';
62+
export { BaseClient } from './baseclient';
6263
export { ServerRuntimeClient } from './server-runtime-client';
6364
export { initAndBind, setCurrentClient } from './sdk';
6465
export { createTransport } from './transports/base';

0 commit comments

Comments
 (0)