Files
novalon-website/sentry.client.config.ts
张翔 8840c4398a feat: downgrade tech stack to stable versions and integrate GA4 error monitoring
- Downgrade Next.js 16→14.2, React 19→18.3, Tailwind 4→3.4
- Add comprehensive GA4 error monitoring system
- Create Jenkins CI/CD pipeline with quality gates
- Fix build issues: ESLint, SWC conflict, config format
- Add documentation for deployment and error tracking
2026-05-12 12:45:18 +08:00

77 lines
1.9 KiB
TypeScript

import * as Sentry from '@sentry/nextjs';
const SENTRY_DSN = process.env.NEXT_PUBLIC_SENTRY_DSN || '';
if (SENTRY_DSN) {
Sentry.init({
dsn: SENTRY_DSN,
environment: process.env.NODE_ENV || 'development',
enabled: process.env.NODE_ENV !== 'development',
tracesSampleRate: process.env.NODE_ENV === 'production' ? 0.2 : 0,
replaysSessionSampleRate: 0,
replaysOnErrorSampleRate: 1.0,
ignoreErrors: [
/_AutofillCallbackHandler/,
/NetworkError/,
/webkit\.messageHandlers/,
/Non-Error promise rejection captured/,
/^Loading CSS chunk.*failed/,
/^Loading chunk.*failed/,
/^Failed to fetch dynamically imported module/,
],
denyUrls: [
/extensions\//i,
/^chrome:\/\//i,
/webappstoolbars/i,
/safari-extension:/i,
/mypersonalassistant/i,
],
initialScope: {
tags: {
project: 'novalon-website',
version: process.env.npm_package_version || 'unknown',
deployment: process.env.NODE_ENV || 'unknown',
},
user: {
id: 'anonymous',
segment: 'visitor',
},
},
beforeSend(event) {
if (event.request?.url) {
event.request.url = event.request.url.replace(/\/[a-f0-9]{32}/gi, '/[hash]');
}
if (event.breadcrumbs) {
event.breadcrumbs = event.breadcrumbs.filter((breadcrumb) => {
return !(
breadcrumb.category === 'console' &&
breadcrumb.level === 'log'
);
});
}
return event;
},
integrations: [
Sentry.browserTracingIntegration(),
Sentry.replayIntegration({
maskAllText: true,
blockAllMedia: true,
}),
],
});
console.log('[Sentry] Client-side monitoring initialized');
} else {
console.warn('[Sentry] NEXT_PUBLIC_SENTRY_DSN not configured, error monitoring disabled');
}
export default Sentry;