Skip to content

Commit 6ef8c8c

Browse files
committed
feat: Stop passing defaultIntegrations as client option
1 parent f2a777a commit 6ef8c8c

File tree

56 files changed

+439
-320
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+439
-320
lines changed

.size-limit.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ module.exports = [
3030
);
3131

3232
config.optimization.minimize = true;
33-
config.optimization.minimizer = [new TerserPlugin()];
33+
config.optimization.minimizer = [
34+
new TerserPlugin({
35+
terserOptions: {
36+
ecma: 'es2020',
37+
},
38+
}),
39+
];
3440

3541
return config;
3642
},
@@ -69,7 +75,13 @@ module.exports = [
6975
);
7076

7177
config.optimization.minimize = true;
72-
config.optimization.minimizer = [new TerserPlugin()];
78+
config.optimization.minimizer = [
79+
new TerserPlugin({
80+
terserOptions: {
81+
ecma: 'es2020',
82+
},
83+
}),
84+
];
7385

7486
return config;
7587
},
@@ -248,7 +260,13 @@ module.exports = [
248260
);
249261

250262
config.optimization.minimize = true;
251-
config.optimization.minimizer = [new TerserPlugin()];
263+
config.optimization.minimizer = [
264+
new TerserPlugin({
265+
terserOptions: {
266+
ecma: 'es2020',
267+
},
268+
}),
269+
];
252270

253271
return config;
254272
},

packages/angular/src/sdk.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
browserSessionIntegration,
66
globalHandlersIntegration,
77
httpContextIntegration,
8-
init as browserInit,
8+
initWithDefaultIntegrations,
99
linkedErrorsIntegration,
1010
setContext,
1111
} from '@sentry/browser';
@@ -49,14 +49,14 @@ export function getDefaultIntegrations(_options: BrowserOptions = {}): Integrati
4949
*/
5050
export function init(options: BrowserOptions): Client | undefined {
5151
const opts = {
52-
defaultIntegrations: getDefaultIntegrations(),
5352
...options,
5453
};
5554

5655
applySdkMetadata(opts, 'angular');
5756

5857
checkAndSetAngularVersion();
59-
return browserInit(opts);
58+
59+
return initWithDefaultIntegrations(opts, getDefaultIntegrations);
6060
}
6161

6262
function checkAndSetAngularVersion(): void {

packages/astro/src/client/sdk.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import type { BrowserOptions } from '@sentry/browser';
22
import {
33
browserTracingIntegration,
44
getDefaultIntegrations as getBrowserDefaultIntegrations,
5-
init as initBrowserSdk,
5+
initWithDefaultIntegrations,
66
} from '@sentry/browser';
7-
import { applySdkMetadata } from '@sentry/core';
87
import type { Client, Integration } from '@sentry/core';
8+
import { applySdkMetadata } from '@sentry/core';
99

1010
// Tree-shakable guard to remove all code related to tracing
1111
declare const __SENTRY_TRACING__: boolean;
@@ -17,13 +17,12 @@ declare const __SENTRY_TRACING__: boolean;
1717
*/
1818
export function init(options: BrowserOptions): Client | undefined {
1919
const opts = {
20-
defaultIntegrations: getDefaultIntegrations(options),
2120
...options,
2221
};
2322

2423
applySdkMetadata(opts, 'astro', ['astro', 'browser']);
2524

26-
return initBrowserSdk(opts);
25+
return initWithDefaultIntegrations(opts, getDefaultIntegrations);
2726
}
2827

2928
function getDefaultIntegrations(options: BrowserOptions): Integration[] {

packages/astro/src/index.types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ import sentryAstro from './index.server';
1414

1515
/** Initializes Sentry Astro SDK */
1616
export declare function init(options: Options | clientSdk.BrowserOptions | NodeOptions): Client | undefined;
17+
export declare function initWithDefaultIntegrations(
18+
options: Options | clientSdk.BrowserOptions | NodeOptions,
19+
getDefaultIntegrations: (options: Options) => Integration[],
20+
): Client | undefined;
1721

1822
export declare const linkedErrorsIntegration: typeof clientSdk.linkedErrorsIntegration;
1923
export declare const contextLinesIntegration: typeof clientSdk.contextLinesIntegration;

packages/astro/test/client/sdk.test.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { afterEach, describe, expect, it, vi } from 'vitest';
22

3-
import type { BrowserClient } from '@sentry/browser';
43
import {
54
browserTracingIntegration,
65
getActiveSpan,
@@ -9,11 +8,11 @@ import {
98
getIsolationScope,
109
} from '@sentry/browser';
1110
import * as SentryBrowser from '@sentry/browser';
12-
import { SDK_VERSION, getClient } from '@sentry/browser';
11+
import { SDK_VERSION } from '@sentry/browser';
1312

1413
import { init } from '../../src/client/sdk';
1514

16-
const browserInit = vi.spyOn(SentryBrowser, 'init');
15+
const browserInit = vi.spyOn(SentryBrowser, 'initWithDefaultIntegrations');
1716

1817
describe('Sentry client SDK', () => {
1918
describe('init', () => {
@@ -45,6 +44,7 @@ describe('Sentry client SDK', () => {
4544
},
4645
},
4746
}),
47+
expect.any(Function),
4848
);
4949
});
5050

@@ -54,45 +54,39 @@ describe('Sentry client SDK', () => {
5454
['tracesSampler', { tracesSampler: () => 1.0 }],
5555
['no tracing option set', {}],
5656
])('adds browserTracingIntegration if tracing is enabled via %s', (_, tracingOptions) => {
57-
init({
57+
const client = init({
5858
dsn: 'https://public@dsn.ingest.sentry.io/1337',
5959
...tracingOptions,
6060
});
6161

62-
const integrationsToInit = browserInit.mock.calls[0]![0]?.defaultIntegrations;
63-
const browserTracing = getClient<BrowserClient>()?.getIntegrationByName('BrowserTracing');
64-
65-
expect(integrationsToInit).toContainEqual(expect.objectContaining({ name: 'BrowserTracing' }));
62+
const browserTracing = client?.getIntegrationByName('BrowserTracing');
6663
expect(browserTracing).toBeDefined();
6764
});
6865

6966
it("doesn't add browserTracingIntegration if `__SENTRY_TRACING__` is set to false", () => {
7067
(globalThis as any).__SENTRY_TRACING__ = false;
7168

72-
init({
69+
const client = init({
7370
dsn: 'https://public@dsn.ingest.sentry.io/1337',
7471
tracesSampleRate: 1,
7572
});
7673

77-
const integrationsToInit = browserInit.mock.calls[0]![0]?.defaultIntegrations || [];
78-
const browserTracing = getClient<BrowserClient>()?.getIntegrationByName('BrowserTracing');
79-
80-
expect(integrationsToInit).not.toContainEqual(expect.objectContaining({ name: 'BrowserTracing' }));
74+
const browserTracing = client?.getIntegrationByName('BrowserTracing');
8175
expect(browserTracing).toBeUndefined();
8276

8377
delete (globalThis as any).__SENTRY_TRACING__;
8478
});
8579

8680
it('Overrides the automatically default browserTracingIntegration instance with a a user-provided browserTracingIntegration instance', () => {
87-
init({
81+
const client = init({
8882
dsn: 'https://public@dsn.ingest.sentry.io/1337',
8983
integrations: [
9084
browserTracingIntegration({ finalTimeout: 10, instrumentNavigation: false, instrumentPageLoad: false }),
9185
],
9286
tracesSampleRate: 1,
9387
});
9488

95-
const browserTracing = getClient<BrowserClient>()?.getIntegrationByName('BrowserTracing');
89+
const browserTracing = client?.getIntegrationByName('BrowserTracing');
9690
expect(browserTracing).toBeDefined();
9791

9892
// no active span means the settings were respected

packages/aws-serverless/src/sdk.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
flush,
1818
getCurrentScope,
1919
getDefaultIntegrationsWithoutPerformance,
20-
initWithoutDefaultIntegrations,
20+
initWithDefaultIntegrations,
2121
startSpanManual,
2222
withScope,
2323
} from '@sentry/node';
@@ -77,13 +77,12 @@ export function getDefaultIntegrations(_options: Options): Integration[] {
7777
*/
7878
export function init(options: NodeOptions = {}): NodeClient | undefined {
7979
const opts = {
80-
defaultIntegrations: getDefaultIntegrations(options),
8180
...options,
8281
};
8382

8483
applySdkMetadata(opts, 'aws-serverless');
8584

86-
return initWithoutDefaultIntegrations(opts);
85+
return initWithDefaultIntegrations(opts, getDefaultIntegrations);
8786
}
8887

8988
/** */

packages/aws-serverless/test/sdk.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jest.mock('@sentry/node', () => {
2525
const original = jest.requireActual('@sentry/node');
2626
return {
2727
...original,
28-
initWithoutDefaultIntegrations: (options: unknown) => {
28+
initWithDefaultIntegrations: (options: unknown) => {
2929
mockInit(options);
3030
},
3131
startInactiveSpan: (...args: unknown[]) => {

packages/browser/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
export * from './exports';
22

3+
export { initWithDefaultIntegrations } from './sdk';
4+
35
export { reportingObserverIntegration } from './integrations/reportingobserver';
46
export { httpClientIntegration } from './integrations/httpclient';
57
export { contextLinesIntegration } from './integrations/contextlines';

0 commit comments

Comments
 (0)