All files / app instrumentation-client.ts

0% Statements 0/12
0% Branches 0/4
0% Functions 0/1
0% Lines 0/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46                                                                                           
import * as Sentry from "@sentry/nextjs";
 
const baseUrl = process.env.NEXT_PUBLIC_BASE_URL;
const projectId = 5887585;
 
Sentry.init({
  // Locally there's nowhere to send events to, and the API instrumentation just adds overhead
  enabled: process.env.NODE_ENV !== "development",
 
  dsn: `https://5594adb1a53e41bfbb9f2cc5c91e2dbd@o782870.ingest.sentry.io/${projectId}`,
 
  // Ad-blockers prevent events from being sent to Sentry. This is a workaround.
  // See https://docs.sentry.io/platforms/javascript/troubleshooting/#using-the-tunnel-option
  // Note that nginx removes /sentry-tunnel, and forwards the rest untouched.
  tunnel: `${baseUrl}/sentry-tunnel/api/${projectId}/envelope/`,
 
  environment: process.env.NEXT_PUBLIC_COUCHERS_ENV,
 
  // Adds request headers and IP for users, for more info visit:
  // https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/options/#sendDefaultPii
  sendDefaultPii: true,
 
  beforeSend(event) {
    // Chrome's page translation swaps text nodes for <font> elements behind React's back, which
    // causes DOM errors like "Failed to execute 'insertBefore' on 'Node'"
    const { classList } = document.documentElement;
    event.tags = {
      ...event.tags,
      is_chrome_translated: classList.contains("translated-ltr") || classList.contains("translated-rtl"),
    };
    const flags = window.couchersFlags;
    if (flags) {
      event.contexts = { ...event.contexts, feature_flags: flags };
    }
    return event;
  },
 
  // Note: if you want to override the automatic release value, do not set a
  // `release` value here - use the environment variable `SENTRY_RELEASE`, so
  // that it will also get attached to your source maps
});
 
// This export will instrument router navigations, and is only relevant if you enable tracing.
// `captureRouterTransitionStart` is available from SDK version 9.12.0 onwards
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;