Skip to content

Commit

Permalink
feat: load ondemand
Browse files Browse the repository at this point in the history
  • Loading branch information
ovflowd committed Nov 22, 2023
1 parent 7310d28 commit 35580f5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
4 changes: 2 additions & 2 deletions next.constants.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ export const SENTRY_TUNNEL = (components = '') =>
*/
export const SENTRY_EXTENSIONS = {
__SENTRY_DEBUG__: false,
__SENTRY_TRACING__: true,
__SENTRY_TRACING__: false,
__RRWEB_EXCLUDE_IFRAME__: true,
__RRWEB_EXCLUDE_SHADOW_DOM__: true,
__SENTRY_EXCLUDE_REPLAY_WORKER__: false,
__SENTRY_EXCLUDE_REPLAY_WORKER__: true,
};
24 changes: 11 additions & 13 deletions sentry.client.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import {
BrowserClient,
Dedupe,
Replay,
Breadcrumbs,
HttpContext,
LinkedErrors,
BrowserTracing,
defaultStackParser,
BrowserClient,
getCurrentHub,
defaultStackParser,
makeFetchTransport,
} from '@sentry/nextjs';

Expand All @@ -30,18 +28,14 @@ export const sentryClient = new BrowserClient({
stackParser: defaultStackParser,
// All supported Integrations by us
integrations: [
new Replay(),
new Dedupe(),
new HttpContext(),
new Breadcrumbs(),
new LinkedErrors(),
new BrowserTracing(),
],
// We only want to capture errors from _next folder on production
// We don't want to capture errors from preview branches here
allowUrls: ['https://nodejs.org/', /^https:\/\/.+\.vercel\.app/],
// Enables Sentry Tracing Feature
enableTracing: true,
// Percentage of events to send to Sentry (1% of them) (for performance metrics)
tracesSampleRate: SENTRY_CAPTURE_RATE,
// Percentage of events to send to Sentry (1% of them) (for session replays)
Expand All @@ -58,13 +52,17 @@ export const sentryClient = new BrowserClient({
const exception = hint.originalException as Error;

// We only want to capture Errors that have a Stack Trace and that are not Anonymous Errors
if (exception?.stack && !exception.stack.includes('<anonymous>')) {
return event;
}

return null;
return exception?.stack && !exception.stack.includes('<anonymous>')
? event
: null;
},
});

// Attaches this Browser Client to Sentry
getCurrentHub().bindClient(sentryClient);

// Loads this Dynamically to avoid adding this to the main bundle (initial load)
import('@sentry/nextjs').then(({ Replay, BrowserTracing }) => {
sentryClient.addIntegration(new Replay({ maskAllText: false }));
sentryClient.addIntegration(new BrowserTracing());
});
2 changes: 0 additions & 2 deletions sentry.server.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ init({
enabled: SENTRY_ENABLE,
// Provide Sentry's Secret Key
dsn: SENTRY_DSN,
// Enables Sentry Tracing Feature
enableTracing: true,
// Percentage of events to send to Sentry (1% of them) (for performance metrics)
tracesSampleRate: SENTRY_CAPTURE_RATE,
// Percentage of events to send to Sentry (all of them) (for profiling metrics)
Expand Down

0 comments on commit 35580f5

Please sign in to comment.