Skip to content

Commit 53c5a63

Browse files
authored
docs(js): Fix default integration examples (#11577)
1 parent 01c55e8 commit 53c5a63

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

docs/platforms/javascript/common/best-practices/multiple-sentry-instances.mdx

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,19 @@ import {
3737
Scope,
3838
} from "@sentry/browser";
3939

40-
// filter integrations that use the global variable
41-
const integrations = getDefaultIntegrations({}).filter((defaultIntegration) => {
42-
return !["BrowserApiErrors", "Breadcrumbs", "GlobalHandlers"].includes(
43-
defaultIntegration.name
44-
);
45-
});
4640

4741
const client = new BrowserClient({
4842
dsn: "___PUBLIC_DSN___",
4943
transport: makeFetchTransport,
5044
stackParser: defaultStackParser,
51-
integrations: integrations,
45+
// filter integrations that use the global variable
46+
integrations: (defaultIntegrations) =>
47+
defaultIntegrations.filter(
48+
(integration) =>
49+
!["BrowserApiErrors", "Breadcrumbs", "GlobalHandlers"].includes(
50+
integration.name
51+
)
52+
),
5253
});
5354

5455
const scope = new Scope();
@@ -89,20 +90,18 @@ function happyIntegration() {
8990
};
9091
}
9192

92-
// filter integrations that use the global variable
93-
const integrations = Sentry.getDefaultIntegrations({}).filter(
94-
(defaultIntegration) => {
95-
return !["BrowserApiErrors", "Breadcrumbs", "GlobalHandlers"].includes(
96-
defaultIntegration.name
97-
);
98-
}
99-
);
10093

10194
const client1 = new Sentry.BrowserClient({
10295
dsn: "___PUBLIC_DSN___",
10396
transport: Sentry.makeFetchTransport,
10497
stackParser: Sentry.defaultStackParser,
105-
integrations: [...integrations, happyIntegration()],
98+
// filter integrations that use the global variable
99+
integrations: (defaultIntegrations) => [
100+
...defaultIntegrations.filter(
101+
(integration) => !["BrowserApiErrors", "Breadcrumbs", "GlobalHandlers"].includes(integration.name)
102+
),
103+
happyIntegration(),
104+
],
106105
beforeSend(event) {
107106
console.log("client 1", event);
108107
return null; // Returning `null` prevents the event from being sent
@@ -115,7 +114,12 @@ const client2 = new Sentry.BrowserClient({
115114
dsn: "___PUBLIC_DSN___", // Can be a different DSN
116115
transport: Sentry.makeFetchTransport,
117116
stackParser: Sentry.defaultStackParser,
118-
integrations: [...integrations, happyIntegration()],
117+
integrations: (defaultIntegrations) => [
118+
...defaultIntegrations.filter(
119+
(integration) => !["BrowserApiErrors", "Breadcrumbs", "GlobalHandlers"].includes(integration.name)
120+
),
121+
happyIntegration(),
122+
],
119123
beforeSend(event) {
120124
console.log("client 2", event);
121125
return null; // Returning `null` prevents the event from being sent

docs/platforms/javascript/common/best-practices/shared-environments.mdx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,15 @@ import {
5959
Scope,
6060
} from "@sentry/browser";
6161

62-
// filter integrations that use the global variable
63-
const integrations = getDefaultIntegrations({}).filter((defaultIntegration) => {
64-
return ![
65-
"BrowserApiErrors",
66-
"Breadcrumbs",
67-
"GlobalHandlers",
68-
].includes(defaultIntegration.name);
69-
});
70-
7162
const client = new BrowserClient({
7263
dsn: "___PUBLIC_DSN___",
7364
transport: makeFetchTransport,
7465
stackParser: defaultStackParser,
75-
integrations: integrations,
66+
// filter integrations that use the global variable
67+
integrations: (defaultIntegrations) =>
68+
defaultIntegrations.filter(
69+
(integration) => !["BrowserApiErrors", "Breadcrumbs", "GlobalHandlers"].includes(integration.name)
70+
),
7671
});
7772

7873
const scope = new Scope();

0 commit comments

Comments
 (0)