Files
awoooi/apps/web/sentry.client.config.ts
OG T 9bff46a1b0 feat: integrate Sentry + fix CI/CD issues
Sentry Integration (補強 SignOz):
- Add @sentry/nextjs for frontend error tracking + session replay
- Add sentry-sdk[fastapi] for backend error tracking
- Create sentry.client/server/edge.config.ts
- Integrate with next.config.js + instrumentation.ts
- Add Sentry exception capture in FastAPI error handler
- Create deployment scripts for Self-Hosted @ 192.168.0.110

CI/CD Fixes:
- Fix F821 Undefined name 'Field' in incidents.py
- Add NEXT_PUBLIC_API_URL env var to CI build step
- Add build-arg to Docker build verification

E2E Test Improvements:
- Fix strict mode violations in dashboard-acceptance tests
- Add timeout increase for Phase 4 demo tests
- Make tests more resilient to UI variations

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-24 15:19:52 +08:00

57 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Sentry Client Configuration
* ===========================
* 前端錯誤追蹤與效能監控
*
* 部署: Self-Hosted @ 192.168.0.110
* 整合策略: 補強 SignOz專注 Error Tracking + Session Replay
*/
import * as Sentry from '@sentry/nextjs'
// 只在有 DSN 時初始化 (環境變數控制)
if (process.env.NEXT_PUBLIC_SENTRY_DSN) {
Sentry.init({
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
// 環境標識
environment: process.env.NODE_ENV,
// 效能監控取樣率 (生產環境降低以節省資源)
tracesSampleRate: process.env.NODE_ENV === 'production' ? 0.2 : 1.0,
// Session Replay 設定 (Sentry 獨家功能)
replaysSessionSampleRate: 0.1, // 10% 隨機 session
replaysOnErrorSampleRate: 1.0, // 100% 錯誤 session
// 整合設定
integrations: [
Sentry.replayIntegration({
// 隱私保護: 遮蔽敏感資料
maskAllText: false,
maskAllInputs: true,
blockAllMedia: false,
}),
Sentry.browserTracingIntegration(),
],
// 忽略常見的非錯誤
ignoreErrors: [
// 網路錯誤 (使用者網路問題)
'Failed to fetch',
'NetworkError',
'Load failed',
// 瀏覽器擴充套件
'ResizeObserver loop limit exceeded',
// 第三方腳本
/^Script error\.?$/,
],
// 只在生產環境發送
enabled: process.env.NODE_ENV === 'production',
// Debug 模式 (開發時啟用)
debug: process.env.NODE_ENV === 'development',
})
}