diff --git a/packages/core/src/baseclient.ts b/packages/core/src/baseclient.ts index 238fc57c47bd..068d34a8b809 100644 --- a/packages/core/src/baseclient.ts +++ b/packages/core/src/baseclient.ts @@ -9,8 +9,8 @@ import { Severity, Status, } from '@sentry/types'; -import { getGlobalObject, uuid4 } from '@sentry/utils/misc'; import { forget } from '@sentry/utils/async'; +import { getGlobalObject, uuid4 } from '@sentry/utils/misc'; import { truncate } from '@sentry/utils/string'; import { BackendClass } from './basebackend'; import { Dsn } from './dsn'; diff --git a/packages/core/src/interfaces.ts b/packages/core/src/interfaces.ts index 8cf34b1f95ce..e7f142f56db3 100644 --- a/packages/core/src/interfaces.ts +++ b/packages/core/src/interfaces.ts @@ -47,6 +47,11 @@ export interface Options { */ dsn?: string; + /** + * If this is set to false, default integrations will not be added. + */ + defaultIntegrations?: boolean; + /** * List of integrations that should be installed after SDK was initialized. * Accepts either a list of integrations or a function that receives diff --git a/packages/core/src/sdk.ts b/packages/core/src/sdk.ts index 4bc35e9f8825..f3410c0173d9 100644 --- a/packages/core/src/sdk.ts +++ b/packages/core/src/sdk.ts @@ -36,7 +36,7 @@ export function initAndBind( // there needs to be a client on the hub already. getCurrentHub().bindClient(client); - let integrations = [...defaultIntegrations]; + let integrations = options.defaultIntegrations === false ? [] : [...defaultIntegrations]; if (Array.isArray(options.integrations)) { const providedIntegrationsNames = options.integrations.map(i => i.name); integrations = [ diff --git a/packages/core/test/lib/sdk.test.ts b/packages/core/test/lib/sdk.test.ts index 206dd7ea6705..1a2d2592fc7b 100644 --- a/packages/core/test/lib/sdk.test.ts +++ b/packages/core/test/lib/sdk.test.ts @@ -31,6 +31,16 @@ describe('SDK', () => { expect(DEFAULT_INTEGRATIONS[1].handler.mock.calls.length).toBe(1); }); + test('not installs default integrations', () => { + const DEFAULT_INTEGRATIONS: Integration[] = [ + new MockIntegration('MockIntegration 1'), + new MockIntegration('MockIntegration 2'), + ]; + initAndBind(TestClient, { defaultIntegrations: false }, DEFAULT_INTEGRATIONS); + expect(DEFAULT_INTEGRATIONS[0].handler.mock.calls.length).toBe(0); + expect(DEFAULT_INTEGRATIONS[1].handler.mock.calls.length).toBe(0); + }); + test('installs integrations provided through options', () => { const integrations: Integration[] = [ new MockIntegration('MockIntegration 1'),