Skip to content

Commit de12484

Browse files
authored
FIx sentry integrations lazy loading (#6634)
* fix: lazy load sentry integrations Closes #6621 Signed-off-by: Iakhub Seitasanov <[email protected]> * fix: remove deprecated sentry api --------- Signed-off-by: Iakhub Seitasanov <[email protected]>
1 parent d08f44c commit de12484

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

sentry.client.config.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import {
2-
Dedupe,
3-
Breadcrumbs,
4-
HttpContext,
5-
LinkedErrors,
62
BrowserClient,
7-
getCurrentHub,
83
defaultStackParser,
94
makeFetchTransport,
5+
setCurrentClient,
6+
breadcrumbsIntegration,
7+
dedupeIntegration,
8+
httpContextIntegration,
9+
linkedErrorsIntegration,
1010
} from '@sentry/nextjs';
1111

1212
import {
@@ -28,10 +28,10 @@ export const sentryClient = new BrowserClient({
2828
stackParser: defaultStackParser,
2929
// All supported Integrations by us
3030
integrations: [
31-
new Dedupe(),
32-
new HttpContext(),
33-
new Breadcrumbs(),
34-
new LinkedErrors(),
31+
dedupeIntegration(),
32+
httpContextIntegration(),
33+
breadcrumbsIntegration(),
34+
linkedErrorsIntegration(),
3535
],
3636
// We only want to allow ingestion from these pre-selected allowed URLs
3737
// Note that the vercel.app prefix is for our Pull Request Branch Previews
@@ -59,10 +59,14 @@ export const sentryClient = new BrowserClient({
5959
});
6060

6161
// Attaches this Browser Client to Sentry
62-
getCurrentHub().bindClient(sentryClient);
62+
setCurrentClient(sentryClient);
6363

6464
// Loads this Dynamically to avoid adding this to the main bundle (initial load)
65-
import('@sentry/nextjs').then(({ Replay, BrowserTracing }) => {
66-
sentryClient.addIntegration(new Replay({ maskAllText: false }));
67-
sentryClient.addIntegration(new BrowserTracing());
68-
});
65+
const lazyLoadSentryIntegrations = async () => {
66+
const { addIntegration, replayIntegration, browserTracingIntegration } =
67+
await import('@sentry/nextjs');
68+
addIntegration(replayIntegration({ maskAllText: false }));
69+
addIntegration(browserTracingIntegration());
70+
};
71+
72+
lazyLoadSentryIntegrations();

0 commit comments

Comments
 (0)