mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 09:31:13 -05:00
feat: Integrate Cronitor RUM
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user