// This file configures the initialization of Sentry for server and edge runtime.
// The config you add here will be used whenever the server handles a request or edge features are loaded.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#create-initialization-config-files
import * as Sentry from '@sentry/nextjs';

export async function register() {
  if (process.env.NEXT_RUNTIME === 'nodejs') {
    // Server configuration
    Sentry.init({
      dsn: 'https://6bbb841ff7b785e4f69e9a32335f8b91@o1183403.ingest.sentry.io/4506389154562048',

      // Adjust this value in production, or use tracesSampler for greater control
      tracesSampleRate: 0,
      sampleRate: 0.001,

      // Setting this option to true will print useful information to the console while you're setting up Sentry.
      debug: false,
      // turn off client reports since most of them are due to sampling rate. might want to enable and just filter these out in the future
      // https://develop.sentry.dev/sdk/telemetry/client-reports/
      sendClientReports: false,
    });
  }

  if (process.env.NEXT_RUNTIME === 'edge') {
    // Edge configuration
    Sentry.init({
      dsn: 'https://6bbb841ff7b785e4f69e9a32335f8b91@o1183403.ingest.sentry.io/4506389154562048',

      // Adjust this value in production, or use tracesSampler for greater control
      tracesSampleRate: 0,
      sampleRate: 0.001,

      // Setting this option to true will print useful information to the console while you're setting up Sentry.
      debug: false,
      // turn off client reports since most of them are due to sampling rate. might want to enable and just filter these out in the future
      // https://develop.sentry.dev/sdk/telemetry/client-reports/
      sendClientReports: false,
    });
  }
}

export const onRequestError = Sentry.captureRequestError;
