Skip to content

feat(core): Update addEventProcessor to add to isolation scope #10606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions packages/core/src/baseclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import {
import { getEnvelopeEndpointWithUrlEncodedAuth } from './api';
import { DEBUG_BUILD } from './debug-build';
import { createEventEnvelope, createSessionEnvelope } from './envelope';
import { getClient } from './exports';
import { getIsolationScope } from './hub';
import type { IntegrationIndex } from './integration';
import { afterSetupIntegrations } from './integration';
Expand Down Expand Up @@ -933,17 +932,3 @@ function isErrorEvent(event: Event): event is ErrorEvent {
function isTransactionEvent(event: Event): event is TransactionEvent {
return event.type === 'transaction';
}

/**
* Add an event processor to the current client.
* This event processor will run for all events processed by this client.
*/
export function addEventProcessor(callback: EventProcessor): void {
const client = getClient();

if (!client || !client.addEventProcessor) {
return;
}

client.addEventProcessor(callback);
}
10 changes: 10 additions & 0 deletions packages/core/src/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {
CustomSamplingContext,
Event,
EventHint,
EventProcessor,
Extra,
Extras,
FinishedCheckIn,
Expand Down Expand Up @@ -382,6 +383,15 @@ export function getCurrentScope(): Scope {
return getCurrentHub().getScope();
}

/**
* Add an event processor.
* This will be added to the current isolation scope, ensuring any event that is processed in the current execution
* context will have the processor applied.
*/
export function addEventProcessor(callback: EventProcessor): void {
getIsolationScope().addEventProcessor(callback);
}

/**
* Start a session on the current isolation scope.
*
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export {
endSession,
captureSession,
withActiveSpan,
addEventProcessor,
} from './exports';
export {
// eslint-disable-next-line deprecation/deprecation
Expand All @@ -58,7 +59,7 @@ export {
addGlobalEventProcessor,
} from './eventProcessors';
export { getEnvelopeEndpointWithUrlEncodedAuth, getReportDialogEndpoint } from './api';
export { BaseClient, addEventProcessor } from './baseclient';
export { BaseClient } from './baseclient';
export { ServerRuntimeClient } from './server-runtime-client';
export { initAndBind, setCurrentClient } from './sdk';
export { createTransport } from './transports/base';
Expand Down