Skip to content

Commit 7854fa1

Browse files
committed
add migration docs for client options
1 parent e4fbb11 commit 7854fa1

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- chore: Remove tslint from `@sentry-internal/typescript` (#4940)
2121
- feat: Add client report hook to makeTransport (#5008)
2222
- ref(build): Switch tsconfig target to es6 (#5005)
23+
- ref(core): Make event processing log warnings (#5010)
2324
- fix(hub): Add missing parameter to captureException docstring (#5001)
2425
- fix(serverless): Adjust v6 Lambda layer hotfix for v7 (#5006)
2526
- fix(tracing): Adjust sideEffects package.json entry for v7 (#4987)

MIGRATION.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,44 @@ import {
3232
} from '@sentry/minimal';
3333
```
3434

35+
## Explicit Client Options
36+
37+
In v7, we've updated the `Client` to have options seperate from the options passed into `Sentry.init`. This means that constructing a client now requires 3 options: `integrations`, `transport` and `stackParser`. These can be customized as you see fit.
38+
39+
```ts
40+
import { BrowserClient, defaultStackParsers, defaultIntegrations, makeFetchTransport } from '@sentry/browser';
41+
import { stackParserFromOptions } from '@sentry/utils';
42+
43+
// New in v7:
44+
const client = BrowserClient({
45+
transport: makeFetchTransport,
46+
stackParser: stackParserFromOptions(defaultStackParsers),
47+
integrations: [...defaultIntegrations],
48+
});
49+
50+
// Before:
51+
const client = BrowserClient();
52+
```
53+
54+
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:
55+
56+
```ts
57+
import { BrowserClient, defaultStackParsers, Integrations, makeFetchTransport } from '@sentry/browser';
58+
import { stackParserFromOptions } from '@sentry/utils';
59+
60+
// New in v7:
61+
const client = BrowserClient({
62+
transport: makeFetchTransport,
63+
stackParser: stackParserFromOptions(defaultStackParsers),
64+
integrations: [
65+
new Integrations.Breadcrumbs(),
66+
new Integrations.GlobalHandlers(),
67+
new Integrations.LinkedErrors(),
68+
new Integrations.Dedupe(),
69+
],
70+
});
71+
```
72+
3573
## Removal Of Old Platform Integrations From `@sentry/integrations` Package
3674

3775
The following classes will be removed from the `@sentry/integrations` package and can no longer be used:

0 commit comments

Comments
 (0)