Skip to content

feat: Export browser integrations individually #5028

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- **(breaking)**: ref(node): Remove raven-node backward-compat code (#4942)
- chore: Remove tslint from `@sentry-internal/typescript` (#4940)
- feat: Add client report hook to makeTransport (#5008)
- feat: Export browser integrations individually (#5028)
- ref(build): Switch tsconfig target to es6 (#5005)
- ref(core): Make event processing log warnings instead of errors (#5010)
- fix(hub): Add missing parameter to captureException docstring (#5001)
Expand Down
20 changes: 12 additions & 8 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import { BrowserClient, defaultStackParser, defaultIntegrations, makeFetchTransp
const client = new BrowserClient({
transport: makeFetchTransport,
stackParser: defaultStackParser,
integrations: [...defaultIntegrations],
integrations: defaultIntegrations,
});

// Before:
Expand All @@ -53,18 +53,22 @@ const client = new BrowserClient();
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:

```ts
import { BrowserClient, defaultStackParser, Integrations, makeFetchTransport } from '@sentry/browser';
import {
BrowserClient,
Breadcrumbs,
Dedupe,
defaultStackParser,
GlobalHandlers,
Integrations,
makeFetchTransport,
LinkedErrors,
} from '@sentry/browser';

// New in v7:
const client = new BrowserClient({
transport: makeFetchTransport,
stackParser: defaultStackParser,
integrations: [
new Integrations.Breadcrumbs(),
new Integrations.GlobalHandlers(),
new Integrations.LinkedErrors(),
new Integrations.Dedupe(),
],
integrations: [new Breadcrumbs(), new GlobalHandlers(), new LinkedErrors(), new Dedupe()],
});
```

Expand Down
3 changes: 3 additions & 0 deletions packages/browser/src/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export {
setTags,
setUser,
withScope,
FunctionToString,
InboundFilters,
} from '@sentry/core';

export { BrowserClient } from './client';
Expand All @@ -56,3 +58,4 @@ export {
} from './stack-parsers';
export { defaultIntegrations, forceLoad, init, lastEventId, onLoad, showReportDialog, flush, close, wrap } from './sdk';
export { SDK_NAME } from './version';
export { GlobalHandlers, TryCatch, Breadcrumbs, LinkedErrors, UserAgent, Dedupe } from './integrations';
1 change: 1 addition & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export { initAndBind } from './sdk';
export { createTransport } from './transports/base';
export { SDK_VERSION } from './version';
export { getIntegrationsToSetup } from './integration';
export { FunctionToString, InboundFilters } from './integrations';

import * as Integrations from './integrations';

Expand Down