Skip to content

Commit 3532b33

Browse files
authored
feat: Export browser integrations individually (#5028)
In this PR, we switch to exporting everything individually. This means users don't have import the entire `INTEGRATIONS` object in, allowing it to be treeshaken.
1 parent c9e8997 commit 3532b33

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- **(breaking)**: ref(node): Remove raven-node backward-compat code (#4942)
2121
- chore: Remove tslint from `@sentry-internal/typescript` (#4940)
2222
- feat: Add client report hook to makeTransport (#5008)
23+
- feat: Export browser integrations individually (#5028)
2324
- ref(build): Switch tsconfig target to es6 (#5005)
2425
- ref(core): Make event processing log warnings instead of errors (#5010)
2526
- fix(hub): Add missing parameter to captureException docstring (#5001)

MIGRATION.md

+12-8
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import { BrowserClient, defaultStackParser, defaultIntegrations, makeFetchTransp
4343
const client = new BrowserClient({
4444
transport: makeFetchTransport,
4545
stackParser: defaultStackParser,
46-
integrations: [...defaultIntegrations],
46+
integrations: defaultIntegrations,
4747
});
4848

4949
// Before:
@@ -53,18 +53,22 @@ const client = new BrowserClient();
5353
Since you now explicitly pass in the dependencies of the client, you can also tree-shake out dependencies that you do not use this way. For example, you can tree-shake out the SDK's default integrations and only use the ones that you want like so:
5454

5555
```ts
56-
import { BrowserClient, defaultStackParser, Integrations, makeFetchTransport } from '@sentry/browser';
56+
import {
57+
BrowserClient,
58+
Breadcrumbs,
59+
Dedupe,
60+
defaultStackParser,
61+
GlobalHandlers,
62+
Integrations,
63+
makeFetchTransport,
64+
LinkedErrors,
65+
} from '@sentry/browser';
5766

5867
// New in v7:
5968
const client = new BrowserClient({
6069
transport: makeFetchTransport,
6170
stackParser: defaultStackParser,
62-
integrations: [
63-
new Integrations.Breadcrumbs(),
64-
new Integrations.GlobalHandlers(),
65-
new Integrations.LinkedErrors(),
66-
new Integrations.Dedupe(),
67-
],
71+
integrations: [new Breadcrumbs(), new GlobalHandlers(), new LinkedErrors(), new Dedupe()],
6872
});
6973
```
7074

packages/browser/src/exports.ts

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ export {
4141
setTags,
4242
setUser,
4343
withScope,
44+
FunctionToString,
45+
InboundFilters,
4446
} from '@sentry/core';
4547

4648
export { BrowserClient } from './client';
@@ -56,3 +58,4 @@ export {
5658
} from './stack-parsers';
5759
export { defaultIntegrations, forceLoad, init, lastEventId, onLoad, showReportDialog, flush, close, wrap } from './sdk';
5860
export { SDK_NAME } from './version';
61+
export { GlobalHandlers, TryCatch, Breadcrumbs, LinkedErrors, UserAgent, Dedupe } from './integrations';

packages/core/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export { initAndBind } from './sdk';
2828
export { createTransport } from './transports/base';
2929
export { SDK_VERSION } from './version';
3030
export { getIntegrationsToSetup } from './integration';
31+
export { FunctionToString, InboundFilters } from './integrations';
3132

3233
import * as Integrations from './integrations';
3334

0 commit comments

Comments
 (0)