Skip to content

Commit

Permalink
docs(js): Fix default integration examples
Browse files Browse the repository at this point in the history
  • Loading branch information
chargome committed Oct 16, 2024
1 parent 01c55e8 commit b52b122
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,19 @@ import {
Scope,
} from "@sentry/browser";

// filter integrations that use the global variable
const integrations = getDefaultIntegrations({}).filter((defaultIntegration) => {
return !["BrowserApiErrors", "Breadcrumbs", "GlobalHandlers"].includes(
defaultIntegration.name
);
});

const client = new BrowserClient({
dsn: "___PUBLIC_DSN___",
transport: makeFetchTransport,
stackParser: defaultStackParser,
integrations: integrations,
// filter integrations that use the global variable
integrations: (defaultIntegrations) =>
defaultIntegrations.filter(
(integration) =>
!["BrowserApiErrors", "Breadcrumbs", "GlobalHandlers"].includes(
integration.name
)
),
});

const scope = new Scope();
Expand Down Expand Up @@ -89,20 +90,18 @@ function happyIntegration() {
};
}

// filter integrations that use the global variable
const integrations = Sentry.getDefaultIntegrations({}).filter(
(defaultIntegration) => {
return !["BrowserApiErrors", "Breadcrumbs", "GlobalHandlers"].includes(
defaultIntegration.name
);
}
);

const client1 = new Sentry.BrowserClient({
dsn: "___PUBLIC_DSN___",
transport: Sentry.makeFetchTransport,
stackParser: Sentry.defaultStackParser,
integrations: [...integrations, happyIntegration()],
// filter integrations that use the global variable
integrations: (defaultIntegrations) => [
...defaultIntegrations.filter(
(integration) => !["BrowserApiErrors", "Breadcrumbs", "GlobalHandlers"].includes(integration.name)
),
happyIntegration(),
],
beforeSend(event) {
console.log("client 1", event);
return null; // Returning `null` prevents the event from being sent
Expand All @@ -115,7 +114,12 @@ const client2 = new Sentry.BrowserClient({
dsn: "___PUBLIC_DSN___", // Can be a different DSN
transport: Sentry.makeFetchTransport,
stackParser: Sentry.defaultStackParser,
integrations: [...integrations, happyIntegration()],
integrations: (defaultIntegrations) => [
...defaultIntegrations.filter(
(integration) => !["BrowserApiErrors", "Breadcrumbs", "GlobalHandlers"].includes(integration.name)
),
happyIntegration(),
],
beforeSend(event) {
console.log("client 2", event);
return null; // Returning `null` prevents the event from being sent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,15 @@ import {
Scope,
} from "@sentry/browser";

// filter integrations that use the global variable
const integrations = getDefaultIntegrations({}).filter((defaultIntegration) => {
return ![
"BrowserApiErrors",
"Breadcrumbs",
"GlobalHandlers",
].includes(defaultIntegration.name);
});

const client = new BrowserClient({
dsn: "___PUBLIC_DSN___",
transport: makeFetchTransport,
stackParser: defaultStackParser,
integrations: integrations,
// filter integrations that use the global variable
integrations: (defaultIntegrations) =>
defaultIntegrations.filter(
(integration) => !["BrowserApiErrors", "Breadcrumbs", "GlobalHandlers"].includes(integration.name)
),
});

const scope = new Scope();
Expand Down

0 comments on commit b52b122

Please sign in to comment.