Skip to content

Commit 9d5b60e

Browse files
AbhiPrasadcadesalaberry
authored andcommitted
feat(v8): Remove addGlobalEventProcessor (getsentry#11255)
ref getsentry#10100 Removes `addGlobalEventProcessor` and adds migration guide.
1 parent af3c928 commit 9d5b60e

File tree

8 files changed

+27
-39
lines changed

8 files changed

+27
-39
lines changed

MIGRATION.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ To make sure these integrations work properly you'll have to change how you
355355

356356
Removed top-level exports: `tracingOrigins`, `MetricsAggregator`, `metricsAggregatorIntegration`, `Severity`,
357357
`Sentry.configureScope`, `Span`, `spanStatusfromHttpCode`, `makeMain`, `lastEventId`, `pushScope`, `popScope`,
358-
`addGlobalEventProcessor`, `timestampWithMs`, `addExtensionMethods`
358+
`addGlobalEventProcessor`, `timestampWithMs`, `addExtensionMethods`, `addGlobalEventProcessor`
359359

360360
Removed `@sentry/utils` exports: `timestampWithMs`, `addOrUpdateIntegration`, `tracingContextFromHeaders`, `walk`
361361

@@ -370,6 +370,7 @@ Removed `@sentry/utils` exports: `timestampWithMs`, `addOrUpdateIntegration`, `t
370370
- [Removal of `addGlobalEventProcessor` in favour of `addEventProcessor`](./MIGRATION.md#removal-of-addglobaleventprocessor-in-favour-of-addeventprocessor)
371371
- [Removal of `lastEventId()` method](./MIGRATION.md#deprecate-lasteventid)
372372
- [Remove `void` from transport return types](./MIGRATION.md#remove-void-from-transport-return-types)
373+
- [Remove `addGlobalEventProcessor` in favor of `addEventProcessor`](./MIGRATION.md#remove-addglobaleventprocessor-in-favor-of-addeventprocessor)
373374

374375
#### Deprecation of `Hub` and `getCurrentHub()`
375376

@@ -540,7 +541,7 @@ addGlobalEventProcessor(event => {
540541

541542
```js
542543
// v8
543-
addEventProcessor(event => {
544+
Sentry.getGlobalScope().addEventProcessor(event => {
544545
delete event.extra;
545546
return event;
546547
});
@@ -569,6 +570,26 @@ interface Transport {
569570
}
570571
```
571572

573+
#### Remove `addGlobalEventProcessor` in favor of `addEventProcessor`
574+
575+
In v8, we are removing the `addGlobalEventProcessor` function in favor of `addEventProcessor`.
576+
577+
```js
578+
// v7
579+
addGlobalEventProcessor(event => {
580+
delete event.extra;
581+
return event;
582+
});
583+
```
584+
585+
```js
586+
// v8
587+
addEventProcessor(event => {
588+
delete event.extra;
589+
return event;
590+
});
591+
```
592+
572593
### Browser SDK (Browser, React, Vue, Angular, Ember, etc.)
573594

574595
Removed top-level exports: `Offline`, `makeXHRTransport`, `BrowserTracing`, `wrap`

packages/browser/src/exports.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ export type { BrowserOptions } from './client';
2020
export type { ReportDialogOptions } from './sdk';
2121

2222
export {
23-
// eslint-disable-next-line deprecation/deprecation
24-
addGlobalEventProcessor,
2523
addEventProcessor,
2624
addBreadcrumb,
2725
addIntegration,

packages/core/src/eventProcessors.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,8 @@
11
import type { Event, EventHint, EventProcessor } from '@sentry/types';
2-
import { SyncPromise, getGlobalSingleton, isThenable, logger } from '@sentry/utils';
2+
import { SyncPromise, isThenable, logger } from '@sentry/utils';
33

44
import { DEBUG_BUILD } from './debug-build';
55

6-
/**
7-
* Returns the global event processors.
8-
* @deprecated Global event processors will be removed in v8.
9-
*/
10-
export function getGlobalEventProcessors(): EventProcessor[] {
11-
return getGlobalSingleton<EventProcessor[]>('globalEventProcessors', () => []);
12-
}
13-
14-
/**
15-
* Add a EventProcessor to be kept globally.
16-
* @deprecated Use `addEventProcessor` instead. Global event processors will be removed in v8.
17-
*/
18-
export function addGlobalEventProcessor(callback: EventProcessor): void {
19-
// eslint-disable-next-line deprecation/deprecation
20-
getGlobalEventProcessors().push(callback);
21-
}
22-
236
/**
247
* Process an array of event processors, returning the processed event (or `null` if the event was dropped).
258
*/

packages/core/src/index.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@ export {
5454
export { makeSession, closeSession, updateSession } from './session';
5555
export { SessionFlusher } from './sessionflusher';
5656
export { Scope } from './scope';
57-
export {
58-
notifyEventProcessors,
59-
// eslint-disable-next-line deprecation/deprecation
60-
addGlobalEventProcessor,
61-
} from './eventProcessors';
57+
export { notifyEventProcessors } from './eventProcessors';
6258
export { getEnvelopeEndpointWithUrlEncodedAuth, getReportDialogEndpoint } from './api';
6359
export { BaseClient } from './baseclient';
6460
export { ServerRuntimeClient } from './server-runtime-client';

packages/core/src/utils/prepareEvent.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { GLOBAL_OBJ, addExceptionMechanism, dateTimestampInSeconds, normalize, t
1313

1414
import { DEFAULT_ENVIRONMENT } from '../constants';
1515
import { getGlobalScope } from '../currentScopes';
16-
import { getGlobalEventProcessors, notifyEventProcessors } from '../eventProcessors';
16+
import { notifyEventProcessors } from '../eventProcessors';
1717
import { Scope } from '../scope';
1818
import { applyScopeDataToEvent, mergeScopeData } from './applyScopeDataToEvent';
1919

@@ -35,8 +35,6 @@ export type ExclusiveEventHintOrCaptureContext =
3535
* Information that is already present in the event is never overwritten. For
3636
* nested objects, such as the context, keys are merged.
3737
*
38-
* Note: This also triggers callbacks for `addGlobalEventProcessor`, but not `beforeSend`.
39-
*
4038
* @param event The original event.
4139
* @param hint May contain additional information about the original exception.
4240
* @param scope A scope containing event metadata.
@@ -99,11 +97,8 @@ export function prepareEvent(
9997

10098
applyScopeDataToEvent(prepared, data);
10199

102-
// TODO (v8): Update this order to be: Global > Client > Scope
103100
const eventProcessors = [
104101
...clientEventProcessors,
105-
// eslint-disable-next-line deprecation/deprecation
106-
...getGlobalEventProcessors(),
107102
// Run scope event processors _after_ all other processors
108103
...data.eventProcessors,
109104
];

packages/node/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ export type { AddRequestDataToEventOptions, TransactionNamingScheme } from '@sen
2121
export type { NodeOptions } from './types';
2222

2323
export {
24-
// eslint-disable-next-line deprecation/deprecation
25-
addGlobalEventProcessor,
2624
addEventProcessor,
2725
addBreadcrumb,
2826
addIntegration,

packages/replay-internal/test/mocks/resetSdkMock.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { EventProcessor } from '@sentry/types';
2-
import { getGlobalSingleton, resetInstrumentationHandlers } from '@sentry/utils';
1+
import { resetInstrumentationHandlers } from '@sentry/utils';
32

43
import type { Replay as ReplayIntegration } from '../../src/integration';
54
import type { ReplayContainer } from '../../src/replay';
@@ -23,7 +22,6 @@ export async function resetSdkMock({ replayOptions, sentryOptions, autoStart }:
2322

2423
// Clear all handlers that have been registered
2524
resetInstrumentationHandlers();
26-
getGlobalSingleton<EventProcessor[]>('globalEventProcessors', () => []).length = 0;
2725

2826
const SentryUtils = await import('@sentry/utils');
2927
jest.spyOn(SentryUtils, 'addClickKeypressInstrumentationHandler').mockImplementation(handler => {

packages/utils/src/worldwide.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ export interface InternalGlobal {
4646
*/
4747
_sentryDebugIds?: Record<string, string>;
4848
__SENTRY__: {
49-
globalEventProcessors: any;
5049
hub: any;
5150
logger: any;
5251
extensions?: {

0 commit comments

Comments
 (0)