Skip to content

Commit 09334b6

Browse files
committed
ref: Make setupOnce optional in integrations
1 parent 4f92ff0 commit 09334b6

36 files changed

+9
-77
lines changed

packages/browser/src/integrations/breadcrumbs.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ const _breadcrumbsIntegration = ((options: Partial<BreadcrumbsOptions> = {}) =>
7070

7171
return {
7272
name: INTEGRATION_NAME,
73-
// TODO v8: Remove this
74-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
7573
setup(client) {
7674
if (_options.console) {
7775
addConsoleInstrumentationHandler(_getConsoleBreadcrumbHandler(client));

packages/browser/src/integrations/dedupe.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ const _dedupeIntegration = (() => {
1111

1212
return {
1313
name: INTEGRATION_NAME,
14-
// TODO v8: Remove this
15-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
1614
processEvent(currentEvent) {
1715
// We want to ignore any non-error type events, e.g. transactions or replays
1816
// These should never be deduped, and also not be compared against as _previousEvent.

packages/browser/src/integrations/httpcontext.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ const INTEGRATION_NAME = 'HttpContext';
88
const _httpContextIntegration = (() => {
99
return {
1010
name: INTEGRATION_NAME,
11-
// TODO v8: Remove this
12-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
1311
preprocessEvent(event) {
1412
// if none of the information we want exists, don't bother
1513
if (!WINDOW.navigator && !WINDOW.location && !WINDOW.document) {

packages/browser/src/integrations/linkederrors.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ const _linkedErrorsIntegration = ((options: LinkedErrorsOptions = {}) => {
1919

2020
return {
2121
name: INTEGRATION_NAME,
22-
// TODO v8: Remove this
23-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
2422
preprocessEvent(event, hint, client) {
2523
const options = client.getOptions();
2624

packages/browser/src/profiling/integration.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const _browserProfilingIntegration = (() => {
2222
return {
2323
name: INTEGRATION_NAME,
2424
// TODO v8: Remove this
25-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
2625
setup(client) {
2726
const scope = getCurrentScope();
2827

packages/core/src/integration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export function setupIntegration(client: Client, integration: Integration, integ
129129
integrationIndex[integration.name] = integration;
130130

131131
// `setupOnce` is only called the first time
132-
if (installedIntegrations.indexOf(integration.name) === -1) {
132+
if (installedIntegrations.indexOf(integration.name) === -1 && typeof integration.setupOnce === 'function') {
133133
// eslint-disable-next-line deprecation/deprecation
134134
integration.setupOnce(addGlobalEventProcessor, getCurrentHub);
135135
installedIntegrations.push(integration.name);

packages/core/src/integrations/inboundfilters.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ const INTEGRATION_NAME = 'InboundFilters';
3333
const _inboundFiltersIntegration = ((options: Partial<InboundFiltersOptions> = {}) => {
3434
return {
3535
name: INTEGRATION_NAME,
36-
// TODO v8: Remove this
37-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
3836
processEvent(event, _hint, client) {
3937
const clientOptions = client.getOptions();
4038
const mergedOptions = _mergeOptions(options, clientOptions);

packages/core/src/integrations/linkederrors.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ const _linkedErrorsIntegration = ((options: LinkedErrorsOptions = {}) => {
1818

1919
return {
2020
name: INTEGRATION_NAME,
21-
// TODO v8: Remove this
22-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
2321
preprocessEvent(event, hint, client) {
2422
const options = client.getOptions();
2523

packages/core/src/integrations/metadata.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ const INTEGRATION_NAME = 'ModuleMetadata';
99
const _moduleMetadataIntegration = (() => {
1010
return {
1111
name: INTEGRATION_NAME,
12-
// TODO v8: Remove this
13-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
1412
setup(client) {
1513
// We need to strip metadata from stack frames before sending them to Sentry since these are client side only.
1614
client.on('beforeEnvelope', envelope => {

packages/core/src/integrations/requestdata.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ const _requestDataIntegration = ((options: RequestDataIntegrationOptions = {}) =
7575

7676
return {
7777
name: INTEGRATION_NAME,
78-
// TODO v8: Remove this
79-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
8078
processEvent(event, _hint, client) {
8179
// Note: In the long run, most of the logic here should probably move into the request data utility functions. For
8280
// the moment it lives here, though, until https://github.com/getsentry/sentry-javascript/issues/5718 is addressed.

packages/deno/src/integrations/context.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ async function addDenoRuntimeContext(event: Event): Promise<Event> {
5555
const _denoContextIntegration = (() => {
5656
return {
5757
name: INTEGRATION_NAME,
58-
// TODO v8: Remove this
59-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
6058
processEvent(event) {
6159
return addDenoRuntimeContext(event);
6260
},

packages/deno/src/integrations/contextlines.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ const _contextLinesIntegration = ((options: ContextLinesOptions = {}) => {
5252

5353
return {
5454
name: INTEGRATION_NAME,
55-
// TODO v8: Remove this
56-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
5755
processEvent(event) {
5856
return addSourceContext(event, contextLines);
5957
},

packages/deno/src/integrations/globalhandlers.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ const _globalHandlersIntegration = ((options?: GlobalHandlersIntegrations) => {
3131

3232
return {
3333
name: INTEGRATION_NAME,
34-
// TODO v8: Remove this
35-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
3634
setup(client) {
3735
if (_options.error) {
3836
installGlobalErrorHandler(client);

packages/deno/src/integrations/normalizepaths.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ const _normalizePathsIntegration = (() => {
7070

7171
return {
7272
name: INTEGRATION_NAME,
73-
// TODO v8: Remove this
74-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
7573
processEvent(event) {
7674
// This error.stack hopefully contains paths that traverse the app cwd
7775
const error = new Error();

packages/integrations/src/captureconsole.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ const _captureConsoleIntegration = ((options: CaptureConsoleOptions = {}) => {
2020

2121
return {
2222
name: INTEGRATION_NAME,
23-
// TODO v8: Remove this
24-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
2523
setup(client) {
2624
if (!('console' in GLOBAL_OBJ)) {
2725
return;

packages/integrations/src/contextlines.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ const _contextLinesIntegration = ((options: ContextLinesOptions = {}) => {
2323

2424
return {
2525
name: INTEGRATION_NAME,
26-
// TODO v8: Remove this
27-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
2826
processEvent(event) {
2927
return addSourceContext(event, contextLines);
3028
},

packages/integrations/src/debug.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ const _debugIntegration = ((options: DebugOptions = {}) => {
2424

2525
return {
2626
name: INTEGRATION_NAME,
27-
// TODO v8: Remove this
28-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
2927
setup(client) {
3028
client.on('beforeSendEvent', (event: Event, hint?: EventHint) => {
3129
if (_options.debugger) {

packages/integrations/src/dedupe.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ const _dedupeIntegration = (() => {
1111

1212
return {
1313
name: INTEGRATION_NAME,
14-
// TODO v8: Remove this
15-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
1614
processEvent(currentEvent) {
1715
// We want to ignore any non-error type events, e.g. transactions or replays
1816
// These should never be deduped, and also not be compared against as _previousEvent.

packages/integrations/src/extraerrordata.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ const _extraErrorDataIntegration = ((options: Partial<ExtraErrorDataOptions> = {
2727
const { depth = 3, captureErrorCause = true } = options;
2828
return {
2929
name: INTEGRATION_NAME,
30-
// TODO v8: Remove this
31-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
3230
processEvent(event, hint) {
3331
return _enhanceEventWithErrorData(event, hint, depth, captureErrorCause);
3432
},

packages/integrations/src/httpclient.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ const _httpClientIntegration = ((options: Partial<HttpClientOptions> = {}) => {
4747

4848
return {
4949
name: INTEGRATION_NAME,
50-
// TODO v8: Remove this
51-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
5250
setup(client): void {
5351
_wrapFetch(client, _options);
5452
_wrapXHR(client, _options);

packages/integrations/src/rewriteframes.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ const _rewriteFramesIntegration = ((options: RewriteFramesOptions = {}) => {
7171

7272
return {
7373
name: INTEGRATION_NAME,
74-
// TODO v8: Remove this
75-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
7674
processEvent(originalEvent) {
7775
let processedEvent = originalEvent;
7876

packages/integrations/src/sessiontiming.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ const _sessionTimingIntegration = (() => {
88

99
return {
1010
name: INTEGRATION_NAME,
11-
// TODO v8: Remove this
12-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
1311
processEvent(event) {
1412
const now = Date.now();
1513

packages/node/src/integrations/anr/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ const INTEGRATION_NAME = 'Anr';
5555
const _anrIntegration = ((options: Partial<AnrIntegrationOptions> = {}) => {
5656
return {
5757
name: INTEGRATION_NAME,
58-
// TODO v8: Remove this
59-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
6058
setup(client: NodeClient) {
6159
if (NODE_VERSION.major < 16 || (NODE_VERSION.major === 16 && NODE_VERSION.minor < 17)) {
6260
throw new Error('ANR detection requires Node 16.17.0 or later');

packages/node/src/integrations/console.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ const INTEGRATION_NAME = 'Console';
88
const _consoleIntegration = (() => {
99
return {
1010
name: INTEGRATION_NAME,
11-
// TODO v8: Remove this
12-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
1311
setup(client) {
1412
addConsoleInstrumentationHandler(({ args, level }) => {
1513
if (getClient() !== client) {

packages/node/src/integrations/context.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,6 @@ const _nodeContextIntegration = ((options: ContextOptions = {}) => {
102102

103103
return {
104104
name: INTEGRATION_NAME,
105-
// TODO v8: Remove this
106-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
107105
processEvent(event) {
108106
return addContext(event);
109107
},

packages/node/src/integrations/contextlines.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ const _contextLinesIntegration = ((options: ContextLinesOptions = {}) => {
4040

4141
return {
4242
name: INTEGRATION_NAME,
43-
// TODO v8: Remove this
44-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
4543
processEvent(event) {
4644
return addSourceContext(event, contextLines);
4745
},

packages/node/src/integrations/local-variables/local-variables-async.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,6 @@ const _localVariablesAsyncIntegration = ((options: LocalVariablesIntegrationOpti
220220

221221
return {
222222
name: INTEGRATION_NAME,
223-
// TODO v8: Remove this
224-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
225223
setup(client: NodeClient) {
226224
const clientOptions = client.getOptions();
227225

packages/node/src/integrations/modules.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ function _getModules(): { [key: string]: string } {
7979
const _modulesIntegration = (() => {
8080
return {
8181
name: INTEGRATION_NAME,
82-
// TODO v8: Remove this
83-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
8482
processEvent(event) {
8583
event.modules = {
8684
...event.modules,

packages/node/src/integrations/onuncaughtexception.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ const _onUncaughtExceptionIntegration = ((options: Partial<OnUncaughtExceptionOp
4848

4949
return {
5050
name: INTEGRATION_NAME,
51-
// TODO v8: Remove this
52-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
5351
setup(client: NodeClient) {
5452
global.process.on('uncaughtException', makeErrorHandler(client, _options));
5553
},

packages/node/src/integrations/onunhandledrejection.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ const _onUnhandledRejectionIntegration = ((options: Partial<OnUnhandledRejection
2121

2222
return {
2323
name: INTEGRATION_NAME,
24-
// TODO v8: Remove this
25-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
2624
setup(client) {
2725
global.process.on('unhandledRejection', makeUnhandledPromiseHandler(client, { mode }));
2826
},

packages/node/src/integrations/spotlight.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ const _spotlightIntegration = ((options: Partial<SpotlightConnectionOptions> = {
2121

2222
return {
2323
name: INTEGRATION_NAME,
24-
// TODO v8: Remove this
25-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
2624
setup(client) {
2725
if (typeof process === 'object' && process.env && process.env.NODE_ENV !== 'development') {
2826
logger.warn("[Spotlight] It seems you're not in dev mode. Do you really want to have Spotlight enabled?");

packages/replay-canvas/src/canvas.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ export const _replayCanvasIntegration = ((options: Partial<ReplayCanvasOptions>
6666

6767
return {
6868
name: INTEGRATION_NAME,
69-
// eslint-disable-next-line @typescript-eslint/no-empty-function
70-
setupOnce() {},
7169
getOptions(): ReplayCanvasIntegrationOptions {
7270
const { quality, enableManualSnapshot } = _canvasOptions;
7371

packages/types/src/integration.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ export interface IntegrationFnResult {
2424
/**
2525
* This hook is only called once, even if multiple clients are created.
2626
* It does not receives any arguments, and should only use for e.g. global monkey patching and similar things.
27-
*
28-
* NOTE: In v8, this will become optional.
2927
*/
30-
setupOnce(): void;
28+
setupOnce?(): void;
3129

3230
/**
3331
* Set up an integration for the given client.
@@ -74,10 +72,8 @@ export interface Integration {
7472
/**
7573
* This hook is only called once, even if multiple clients are created.
7674
* It does not receives any arguments, and should only use for e.g. global monkey patching and similar things.
77-
*
78-
* NOTE: In v8, this will become optional, and not receive any arguments anymore.
7975
*/
80-
setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void;
76+
setupOnce?(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void;
8177

8278
/**
8379
* Set up an integration for the given client.

packages/vercel-edge/src/integrations/wintercg-fetch.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ const _winterCGFetch = ((options: Partial<Options> = {}) => {
8787

8888
return {
8989
name: INTEGRATION_NAME,
90-
// TODO v8: Remove this again
91-
// eslint-disable-next-line @typescript-eslint/no-empty-function
9290
setupOnce() {
9391
addFetchInstrumentationHandler(handlerData => {
9492
const client = getClient();

packages/vercel-edge/test/wintercg-fetch.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('WinterCGFetch instrumentation', () => {
4343
addFetchInstrumentationHandlerSpy.mockImplementationOnce(() => undefined);
4444

4545
const integration = winterCGFetchIntegration();
46-
integration.setupOnce();
46+
integration.setupOnce!();
4747
integration.setup!(client);
4848

4949
const [fetchInstrumentationHandlerCallback] = addFetchInstrumentationHandlerSpy.mock.calls[0];
@@ -77,7 +77,7 @@ describe('WinterCGFetch instrumentation', () => {
7777
addFetchInstrumentationHandlerSpy.mockImplementationOnce(() => undefined);
7878

7979
const integration = winterCGFetchIntegration();
80-
integration.setupOnce();
80+
integration.setupOnce!();
8181
// integration.setup!(client) is not called!
8282

8383
const [fetchInstrumentationHandlerCallback] = addFetchInstrumentationHandlerSpy.mock.calls[0];
@@ -97,7 +97,7 @@ describe('WinterCGFetch instrumentation', () => {
9797
addFetchInstrumentationHandlerSpy.mockImplementationOnce(() => undefined);
9898

9999
const integration = winterCGFetchIntegration();
100-
integration.setupOnce();
100+
integration.setupOnce!();
101101
integration.setup!(client);
102102

103103
const [fetchInstrumentationHandlerCallback] = addFetchInstrumentationHandlerSpy.mock.calls[0];
@@ -121,7 +121,7 @@ describe('WinterCGFetch instrumentation', () => {
121121
return url === 'http://only-acceptable-url.com/';
122122
},
123123
});
124-
integration.setupOnce();
124+
integration.setupOnce!();
125125
integration.setup!(client);
126126

127127
const [fetchInstrumentationHandlerCallback] = addFetchInstrumentationHandlerSpy.mock.calls[0];
@@ -145,7 +145,7 @@ describe('WinterCGFetch instrumentation', () => {
145145
addFetchInstrumentationHandlerSpy.mockImplementationOnce(() => undefined);
146146

147147
const integration = winterCGFetchIntegration();
148-
integration.setupOnce();
148+
integration.setupOnce!();
149149
integration.setup!(client);
150150

151151
const [fetchInstrumentationHandlerCallback] = addFetchInstrumentationHandlerSpy.mock.calls[0];
@@ -182,7 +182,7 @@ describe('WinterCGFetch instrumentation', () => {
182182
addFetchInstrumentationHandlerSpy.mockImplementationOnce(() => undefined);
183183

184184
const integration = winterCGFetchIntegration({ breadcrumbs: false });
185-
integration.setupOnce();
185+
integration.setupOnce!();
186186
integration.setup!(client);
187187

188188
const [fetchInstrumentationHandlerCallback] = addFetchInstrumentationHandlerSpy.mock.calls[0];

packages/vue/src/integration.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ const _vueIntegration = ((integrationOptions: Partial<VueOptions> = {}) => {
2525
return {
2626
name: INTEGRATION_NAME,
2727
// TODO v8: Remove this
28-
setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
2928
setup(client) {
3029
_setupIntegration(client, integrationOptions);
3130
},

0 commit comments

Comments
 (0)