// This file configures the initialization of Sentry on the client.
// The config you add here will be used whenever a users loads a page in their browser.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/

import * as Sentry from "@sentry/nextjs"

// Required for Next.js router instrumentation
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart

const isProduction = process.env.NODE_ENV === "production"

Sentry.init({
  dsn: isProduction
    ? "https://0fa0f40b2d709e4f1eb9aac76ff9e6be@o4506833230561280.ingest.us.sentry.io/4506833279582208"
    : undefined,

  // Sample 10% in production, 100% in dev
  tracesSampleRate: isProduction ? 0.1 : 1,

  // Setting this option to true will print useful information to the console while you're setting up Sentry.
  debug: false,

  replaysOnErrorSampleRate: 1.0,

  // This sets the sample rate to be 10%. You may want this to be 100% while
  // in development and sample at a lower rate in production
  replaysSessionSampleRate: 0.1,

  // Replay is lazy-loaded below to keep it out of the initial bundle (~300 KB).
  // browserTracingIntegration must be eager (not supported by lazyLoadIntegration).
  integrations: [Sentry.browserTracingIntegration({ enableLongAnimationFrame: true })],
})

// Lazy-load Session Replay so the ~300 KB replay bundle is fetched after
// the page is interactive rather than blocking initial load.
Sentry.lazyLoadIntegration("replayIntegration").then(replayIntegration => {
  Sentry.addIntegration(
    replayIntegration({
      maskAllText: true,
      blockAllMedia: true,
    }),
  )
})
