Skip to content

Commit 837bbd1

Browse files
authored
ref: Make setupOnce optional in integrations (#10729)
This is now properly optional 🎉
1 parent e4dc5a7 commit 837bbd1

37 files changed

+26
-94
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/integrations/test/reportingobserver.test.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('ReportingObserver', () => {
5050
const reportingObserver = reportingObserverIntegration();
5151

5252
expect(() => {
53-
reportingObserver.setupOnce();
53+
reportingObserver.setupOnce!();
5454
}).not.toThrow();
5555

5656
expect(mockReportingObserverConstructor).not.toHaveBeenCalled();
@@ -59,7 +59,7 @@ describe('ReportingObserver', () => {
5959

6060
it('should use default report types', () => {
6161
const reportingObserver = reportingObserverIntegration();
62-
reportingObserver.setupOnce();
62+
reportingObserver.setupOnce!();
6363
reportingObserver.setup?.(mockClient);
6464

6565
expect(mockReportingObserverConstructor).toHaveBeenCalledTimes(1);
@@ -71,7 +71,7 @@ describe('ReportingObserver', () => {
7171

7272
it('should use user-provided report types', () => {
7373
const reportingObserver = reportingObserverIntegration({ types: ['crash'] });
74-
reportingObserver.setupOnce();
74+
reportingObserver.setupOnce!();
7575
reportingObserver.setup?.(mockClient);
7676

7777
expect(mockReportingObserverConstructor).toHaveBeenCalledTimes(1);
@@ -83,7 +83,7 @@ describe('ReportingObserver', () => {
8383

8484
it('should use `buffered` option', () => {
8585
const reportingObserver = reportingObserverIntegration();
86-
reportingObserver.setupOnce();
86+
reportingObserver.setupOnce!();
8787
reportingObserver.setup?.(mockClient);
8888

8989
expect(mockReportingObserverConstructor).toHaveBeenCalledTimes(1);
@@ -95,7 +95,7 @@ describe('ReportingObserver', () => {
9595

9696
it('should call `observe` function', () => {
9797
const reportingObserver = reportingObserverIntegration();
98-
reportingObserver.setupOnce();
98+
reportingObserver.setupOnce!();
9999
reportingObserver.setup?.(mockClient);
100100

101101
expect(mockObserve).toHaveBeenCalledTimes(1);
@@ -105,7 +105,7 @@ describe('ReportingObserver', () => {
105105
describe('handler', () => {
106106
it('should abort gracefully and not do anything when integration is not installed', () => {
107107
const reportingObserver = reportingObserverIntegration();
108-
reportingObserver.setupOnce();
108+
reportingObserver.setupOnce!();
109109
// without calling setup, the integration is not registered
110110

111111
const handler = mockReportingObserverConstructor.mock.calls[0][0];
@@ -119,7 +119,7 @@ describe('ReportingObserver', () => {
119119

120120
it('should capture messages', () => {
121121
const reportingObserver = reportingObserverIntegration();
122-
reportingObserver.setupOnce();
122+
reportingObserver.setupOnce!();
123123
reportingObserver.setup?.(mockClient);
124124
const handler = mockReportingObserverConstructor.mock.calls[0][0];
125125

@@ -133,7 +133,7 @@ describe('ReportingObserver', () => {
133133

134134
it('should set extra including the url of a report', () => {
135135
const reportingObserver = reportingObserverIntegration();
136-
reportingObserver.setupOnce();
136+
reportingObserver.setupOnce!();
137137
reportingObserver.setup?.(mockClient);
138138
const handler = mockReportingObserverConstructor.mock.calls[0][0];
139139

@@ -148,7 +148,7 @@ describe('ReportingObserver', () => {
148148

149149
it('should set extra including the report body if available', () => {
150150
const reportingObserver = reportingObserverIntegration();
151-
reportingObserver.setupOnce();
151+
reportingObserver.setupOnce!();
152152
reportingObserver.setup?.(mockClient);
153153
const handler = mockReportingObserverConstructor.mock.calls[0][0];
154154

@@ -163,7 +163,7 @@ describe('ReportingObserver', () => {
163163

164164
it('should not set extra report body extra when no body is set', () => {
165165
const reportingObserver = reportingObserverIntegration();
166-
reportingObserver.setupOnce();
166+
reportingObserver.setupOnce!();
167167
reportingObserver.setup?.(mockClient);
168168
const handler = mockReportingObserverConstructor.mock.calls[0][0];
169169

@@ -174,7 +174,7 @@ describe('ReportingObserver', () => {
174174

175175
it('should capture report details from body on crash report', () => {
176176
const reportingObserver = reportingObserverIntegration();
177-
reportingObserver.setupOnce();
177+
reportingObserver.setupOnce!();
178178
reportingObserver.setup?.(mockClient);
179179
const handler = mockReportingObserverConstructor.mock.calls[0][0];
180180

@@ -192,7 +192,7 @@ describe('ReportingObserver', () => {
192192

193193
it('should capture report message from body on deprecation report', () => {
194194
const reportingObserver = reportingObserverIntegration();
195-
reportingObserver.setupOnce();
195+
reportingObserver.setupOnce!();
196196
reportingObserver.setup?.(mockClient);
197197
const handler = mockReportingObserverConstructor.mock.calls[0][0];
198198

@@ -209,7 +209,7 @@ describe('ReportingObserver', () => {
209209

210210
it('should capture report message from body on intervention report', () => {
211211
const reportingObserver = reportingObserverIntegration();
212-
reportingObserver.setupOnce();
212+
reportingObserver.setupOnce!();
213213
reportingObserver.setup?.(mockClient);
214214
const handler = mockReportingObserverConstructor.mock.calls[0][0];
215215

@@ -226,7 +226,7 @@ describe('ReportingObserver', () => {
226226

227227
it('should use fallback message when no body is available', () => {
228228
const reportingObserver = reportingObserverIntegration();
229-
reportingObserver.setupOnce();
229+
reportingObserver.setupOnce!();
230230
reportingObserver.setup?.(mockClient);
231231
const handler = mockReportingObserverConstructor.mock.calls[0][0];
232232

@@ -242,7 +242,7 @@ describe('ReportingObserver', () => {
242242

243243
it('should use fallback message when no body details are available for crash report', () => {
244244
const reportingObserver = reportingObserverIntegration();
245-
reportingObserver.setupOnce();
245+
reportingObserver.setupOnce!();
246246
reportingObserver.setup?.(mockClient);
247247
const handler = mockReportingObserverConstructor.mock.calls[0][0];
248248

@@ -255,7 +255,7 @@ describe('ReportingObserver', () => {
255255

256256
it('should use fallback message when no body message is available for deprecation report', () => {
257257
const reportingObserver = reportingObserverIntegration();
258-
reportingObserver.setupOnce();
258+
reportingObserver.setupOnce!();
259259
reportingObserver.setup?.(mockClient);
260260
const handler = mockReportingObserverConstructor.mock.calls[0][0];
261261

@@ -272,7 +272,7 @@ describe('ReportingObserver', () => {
272272

273273
it('should use fallback message when no body message is available for intervention report', () => {
274274
const reportingObserver = reportingObserverIntegration();
275-
reportingObserver.setupOnce();
275+
reportingObserver.setupOnce!();
276276
reportingObserver.setup?.(mockClient);
277277
const handler = mockReportingObserverConstructor.mock.calls[0][0];
278278

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

0 commit comments

Comments
 (0)