Skip to content

Commit 18e252a

Browse files
authored
feat: Add defaultIntegrations option (#1532)
1 parent a1fab14 commit 18e252a

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

packages/core/src/interfaces.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ export interface Options {
4747
*/
4848
dsn?: string;
4949

50+
/**
51+
* If this is set to false, default integrations will not be added.
52+
*/
53+
defaultIntegrations?: boolean;
54+
5055
/**
5156
* List of integrations that should be installed after SDK was initialized.
5257
* Accepts either a list of integrations or a function that receives

packages/core/src/sdk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function initAndBind<F extends Client, O extends Options>(
3636
// there needs to be a client on the hub already.
3737
getCurrentHub().bindClient(client);
3838

39-
let integrations = [...defaultIntegrations];
39+
let integrations = options.defaultIntegrations === false ? [] : [...defaultIntegrations];
4040
if (Array.isArray(options.integrations)) {
4141
const providedIntegrationsNames = options.integrations.map(i => i.name);
4242
integrations = [

packages/core/test/lib/sdk.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ describe('SDK', () => {
3131
expect(DEFAULT_INTEGRATIONS[1].handler.mock.calls.length).toBe(1);
3232
});
3333

34+
test('not installs default integrations', () => {
35+
const DEFAULT_INTEGRATIONS: Integration[] = [
36+
new MockIntegration('MockIntegration 1'),
37+
new MockIntegration('MockIntegration 2'),
38+
];
39+
initAndBind(TestClient, { defaultIntegrations: false }, DEFAULT_INTEGRATIONS);
40+
expect(DEFAULT_INTEGRATIONS[0].handler.mock.calls.length).toBe(0);
41+
expect(DEFAULT_INTEGRATIONS[1].handler.mock.calls.length).toBe(0);
42+
});
43+
3444
test('installs integrations provided through options', () => {
3545
const integrations: Integration[] = [
3646
new MockIntegration('MockIntegration 1'),

0 commit comments

Comments
 (0)