Files
moyosapp_beta.0.0.3.3_beta/sentry.server.config.ts
2026-01-16 19:04:48 +02:00

50 lines
1.6 KiB
TypeScript

// This file configures the initialization of Sentry on the server.
// The config you add here will be used whenever the server handles a request.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
import * as Sentry from "@sentry/nextjs";
// Use environment variable or fallback to hardcoded DSN (for backwards compatibility)
const dsn = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN || "https://ef941910db6c0ec10a61000dc90219b2@o4510675981041664.ingest.de.sentry.io/4510675983007824";
if (dsn) {
const isDevelopment = process.env.NODE_ENV === 'development';
const isProduction = process.env.NODE_ENV === 'production';
Sentry.init({
dsn,
// Environment
environment: process.env.NODE_ENV || 'development',
// Release tracking
release: process.env.NEXT_PUBLIC_APP_VERSION || process.env.VERCEL_GIT_COMMIT_SHA || undefined,
// Sample rates - lower in production
tracesSampleRate: isProduction ? 0.1 : 1.0, // 10% in production, 100% in dev
// Debug mode - only in development
debug: isDevelopment,
// Enable logs to be sent to Sentry
enableLogs: true,
// Enable sending user PII (Personally Identifiable Information)
// https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/options/#sendDefaultPii
sendDefaultPii: true,
// Ignore specific errors
ignoreErrors: [
// Database connection errors (handled gracefully)
'P1001',
'Can\'t reach database server',
// Network errors
'ECONNREFUSED',
'ETIMEDOUT',
// Next.js specific
'NEXT_REDIRECT',
'NEXT_NOT_FOUND',
],
});
}