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
This commit is contained in:
@@ -48,6 +48,7 @@ export function CookieConsent() {
|
||||
necessary: true,
|
||||
analytics: legacyConsent === 'granted',
|
||||
marketing: false,
|
||||
functionality: true,
|
||||
timestamp: Date.now(),
|
||||
};
|
||||
storePreferences(migratedPrefs);
|
||||
@@ -91,6 +92,7 @@ export function CookieConsent() {
|
||||
necessary: true,
|
||||
analytics: true,
|
||||
marketing: false,
|
||||
functionality: true,
|
||||
timestamp: Date.now(),
|
||||
};
|
||||
handleSavePreferences(allAccepted);
|
||||
@@ -102,6 +104,7 @@ export function CookieConsent() {
|
||||
necessary: true,
|
||||
analytics: false,
|
||||
marketing: false,
|
||||
functionality: true,
|
||||
timestamp: Date.now(),
|
||||
};
|
||||
handleSavePreferences(allRejected);
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
'use client';
|
||||
|
||||
import { useEffect } from 'react';
|
||||
import { trackError } from '@/lib/analytics';
|
||||
|
||||
const IGNORED_ERRORS = [
|
||||
/_AutofillCallbackHandler/,
|
||||
/ResizeObserver loop limit exceeded/,
|
||||
/webkit\.messageHandlers/,
|
||||
/Non-Error promise rejection captured/,
|
||||
/^Loading CSS chunk.*failed$/,
|
||||
/^Loading chunk.*failed$/,
|
||||
/^Failed to fetch dynamically imported module/,
|
||||
/Script error/,
|
||||
/NetworkError/,
|
||||
];
|
||||
|
||||
function shouldIgnoreError(message: string): boolean {
|
||||
return IGNORED_ERRORS.some((pattern) => pattern.test(message));
|
||||
}
|
||||
|
||||
export function GlobalErrorTracker() {
|
||||
useEffect(() => {
|
||||
if (typeof window === 'undefined') return;
|
||||
|
||||
const handleGlobalError = (
|
||||
event: ErrorEvent
|
||||
) => {
|
||||
if (shouldIgnoreError(event.message)) return;
|
||||
|
||||
trackError(
|
||||
'javascript_error',
|
||||
event.message,
|
||||
false,
|
||||
{
|
||||
filename: event.filename || '',
|
||||
lineno: event.lineno || 0,
|
||||
colno: event.colno || 0,
|
||||
stack: event.error?.stack?.slice(0, 500) || '',
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const handleUnhandledRejection = (event: PromiseRejectionEvent) => {
|
||||
const message =
|
||||
event.reason?.message || String(event.reason) || 'Unknown promise rejection';
|
||||
|
||||
if (shouldIgnoreError(message)) return;
|
||||
|
||||
trackError(
|
||||
'unhandled_promise_rejection',
|
||||
message,
|
||||
false,
|
||||
{
|
||||
reason_type: event.reason?.constructor?.name || 'Unknown',
|
||||
stack: event.reason?.stack?.slice(0, 500) || '',
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const handleResourceError = () => {
|
||||
trackError('resource_loading_error', 'Failed to load resource', false);
|
||||
};
|
||||
|
||||
window.addEventListener('error', handleGlobalError, true);
|
||||
window.addEventListener('unhandledrejection', handleUnhandledRejection);
|
||||
document.addEventListener('error', handleResourceError, true);
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.log('[GA4] Global error tracker initialized');
|
||||
}
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('error', handleGlobalError, true);
|
||||
window.removeEventListener('unhandledrejection', handleUnhandledRejection);
|
||||
document.removeEventListener('error', handleResourceError, true);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user