// MUST be imported before anything else in main.ts so Sentry can patch modules // before they're loaded. See https://docs.sentry.io/platforms/javascript/guides/nestjs/ import "dotenv/config"; import * as Sentry from "@sentry/nestjs"; import { nodeProfilingIntegration } from "@sentry/profiling-node"; const dsn = process.env.SENTRY_DSN || "https://931a9c8d2bcc49918e3ba4d11510f910@o4511360959250432.ingest.de.sentry.io/4511360960823376"; // We ship a custom OpenTelemetry SDK in src/telemetry/tracing.ts. When it's enabled, // Sentry must NOT register its own OTel pipeline or we'd double-instrument // HTTP/Express/Nest. The trade-off: Sentry tracing + profiling rely on its OTel, // so they're effectively disabled when the custom pipeline is on. const customOtelEnabled = process.env.OTEL_ENABLED === "true"; if (dsn && process.env.NODE_ENV !== "test") { Sentry.init({ dsn, environment: process.env.NODE_ENV || "development", sendDefaultPii: true, enableLogs: true, skipOpenTelemetrySetup: customOtelEnabled, integrations: customOtelEnabled ? [] : [nodeProfilingIntegration()], tracesSampleRate: customOtelEnabled ? 0 : 1.0, profileSessionSampleRate: customOtelEnabled ? 0 : 1.0, profileLifecycle: "trace", }); }