Skip to content

Commit bcadb6c

Browse files
authored
feat(js): Update JS troubleshooting for new v7 client (#5342)
Update instructions for client constructor in docs.
1 parent ab66dde commit bcadb6c

File tree

1 file changed

+12
-2
lines changed
  • src/platforms/javascript/common/troubleshooting

1 file changed

+12
-2
lines changed

src/platforms/javascript/common/troubleshooting/index.mdx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,13 @@ This also helps to prevent tracking of any parent application errors in case you
266266
inside of it. In this example we use `@sentry/browser` but it's also applicable to `@sentry/node`.
267267

268268
```javascript
269-
import { BrowserClient } from "@sentry/browser";
269+
import { BrowserClient, defaultStackParser, defaultIntegrations, makeFetchTransport } from "@sentry/browser";
270270

271271
const client = new BrowserClient({
272272
dsn: "___PUBLIC_DSN___",
273+
transport: makeFetchTransport,
274+
stackParser: defaultStackParser,
275+
integrations: defaultIntegrations,
273276
});
274277

275278
client.captureException(new Error("example"));
@@ -278,10 +281,13 @@ client.captureException(new Error("example"));
278281
While the above sample should work perfectly fine, some methods like `configureScope` and `withScope` are missing on the `Client` because the `Hub` takes care of the state management. That's why it may be easier to create a new `Hub` and bind your `Client` to it. The result is the same but you will also get state management with it.
279282

280283
```javascript
281-
import { BrowserClient, Hub } from "@sentry/browser";
284+
import { BrowserClient, defaultStackParser, defaultIntegrations, makeFetchTransport } from "@sentry/browser";
282285

283286
const client = new BrowserClient({
284287
dsn: "___PUBLIC_DSN___",
288+
transport: makeFetchTransport,
289+
stackParser: defaultStackParser,
290+
integrations: defaultIntegrations,
285291
});
286292

287293
const hub = new Hub(client);
@@ -335,6 +341,8 @@ HappyIntegration.id = "HappyIntegration";
335341

336342
const client1 = new Sentry.BrowserClient({
337343
dsn: "___PUBLIC_DSN___",
344+
transport: Sentry.makeFetchTransport,
345+
stackParser: Sentry.defaultStackParser,
338346
integrations: [...Sentry.defaultIntegrations, new HappyIntegration()],
339347
beforeSend(event) {
340348
console.log("client 1", event);
@@ -345,6 +353,8 @@ const hub1 = new Sentry.Hub(client1);
345353

346354
const client2 = new Sentry.BrowserClient({
347355
dsn: "___PUBLIC_DSN___", // Can be a different DSN
356+
transport: Sentry.makeFetchTransport,
357+
stackParser: Sentry.defaultStackParser,
348358
integrations: [...Sentry.defaultIntegrations, new HappyIntegration()],
349359
beforeSend(event) {
350360
console.log("client 2", event);

0 commit comments

Comments
 (0)