/**
 * Sentry Server Configuration
 * ===========================
 * Next.js Server-Side 錯誤追蹤
 *
 * 部署: Self-Hosted @ 192.168.0.110
 */

import * as Sentry from '@sentry/nextjs'

if (process.env.SENTRY_DSN) {
  Sentry.init({
    dsn: process.env.SENTRY_DSN,

    // 環境標識
    environment: process.env.NODE_ENV,

    // Server-side 效能監控
    tracesSampleRate: process.env.NODE_ENV === 'production' ? 0.2 : 1.0,

    // 忽略常見的非錯誤
    ignoreErrors: [
      'ECONNREFUSED',
      'ENOTFOUND',
      'ETIMEDOUT',
    ],

    // 只在生產環境發送
    enabled: process.env.NODE_ENV === 'production',
  })
}
