feat: Integrate Cronitor RUM

This commit is contained in:
gpt-engineer-app[bot]
2025-11-05 15:07:31 +00:00
parent e1ffba593a
commit 0106bdb1d5
7 changed files with 160 additions and 16 deletions

View File

@@ -4,6 +4,16 @@ import { supabase } from '@/integrations/supabase/client';
import { breadcrumbManager } from './errorBreadcrumbs';
import { captureEnvironmentContext } from './environmentContext';
// Cronitor RUM integration
declare global {
interface Window {
cronitor?: {
track: (eventName: string, data?: Record<string, any>) => void;
error: (error: Error | string, metadata?: Record<string, any>) => void;
};
}
}
export type ErrorContext = {
action: string;
userId?: string;
@@ -123,6 +133,25 @@ export const handleError = (
});
}
// Track error in Cronitor RUM
if (typeof window !== 'undefined' && window.cronitor) {
try {
window.cronitor.error(
error instanceof Error ? error : new Error(errorMessage),
{
errorId,
errorName,
action: context.action,
userId: context.userId,
supabaseError: supabaseErrorDetails,
breadcrumbCount: breadcrumbManager.getAll().length,
}
);
} catch (cronitorError) {
logger.error('Failed to track error in Cronitor', { cronitorError });
}
}
// Log to database with breadcrumbs (non-blocking)
try {
const envContext = captureEnvironmentContext();
@@ -218,6 +247,21 @@ export const handleNonCriticalError = (
severity: 'low',
});
// Track non-critical error in Cronitor (lower severity)
if (typeof window !== 'undefined' && window.cronitor) {
try {
window.cronitor.track('non_critical_error', {
errorId,
errorMessage,
action: context.action,
userId: context.userId,
severity: 'low',
});
} catch (cronitorError) {
logger.error('Failed to track non-critical error in Cronitor', { cronitorError });
}
}
// Log to database with breadcrumbs (non-blocking, fire-and-forget)
try {
const envContext = captureEnvironmentContext();