Refactor: Remove Cronitor RUM tracking

This commit is contained in:
gpt-engineer-app[bot]
2025-11-05 15:59:05 +00:00
parent 1f93e7433b
commit 6e1ff944c8
6 changed files with 56 additions and 184 deletions

View File

@@ -58,18 +58,6 @@ export const breadcrumb = {
level: 'info',
data,
});
// Track critical user actions in Cronitor
const criticalActions = ['submit', 'delete', 'update', 'create', 'login', 'logout'];
const isCritical = criticalActions.some(ca => action.toLowerCase().includes(ca));
if (isCritical && typeof window !== 'undefined' && window.cronitor) {
window.cronitor.track('critical_user_action', {
action,
component,
timestamp: new Date().toISOString(),
});
}
},
apiCall: (endpoint: string, method: string, status?: number) => {
@@ -81,19 +69,6 @@ export const breadcrumb = {
level: isError ? 'error' : 'info',
data: { endpoint, method, status },
});
// Track significant API calls in Cronitor
if (typeof window !== 'undefined' && window.cronitor) {
// Only track errors and slow requests
if (isError || (status && status >= 500)) {
window.cronitor.track('api_error', {
endpoint,
method,
status,
severity: status >= 500 ? 'high' : 'medium',
});
}
}
},
stateChange: (description: string, data?: Record<string, any>) => {

View File

@@ -4,16 +4,6 @@ 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;
@@ -167,25 +157,6 @@ 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();
@@ -281,21 +252,6 @@ 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();

View File

@@ -243,28 +243,9 @@ export async function withRetry<T>(
error: error instanceof Error ? error.message : String(error)
});
// Track exhausted retries in Cronitor
if (typeof window !== 'undefined' && window.cronitor) {
window.cronitor.track('retries_exhausted', {
totalAttempts: config.maxAttempts,
error: error instanceof Error ? error.name : 'UnknownError',
severity: 'high',
});
}
throw error;
}
// Track retry attempts in Cronitor
if (attempt > 0 && typeof window !== 'undefined' && window.cronitor) {
window.cronitor.track('retry_attempt', {
attempt: attempt + 1,
maxAttempts: config.maxAttempts,
error: error instanceof Error ? error.name : 'UnknownError',
willRetry: attempt < config.maxAttempts - 1,
});
}
// Calculate delay for next attempt
const delay = calculateBackoffDelay(attempt, config);

View File

@@ -1,23 +0,0 @@
declare module '@cronitorio/cronitor-rum' {
export interface CronitorConfig {
debug?: boolean;
trackMode?: 'history' | 'off';
}
export function load(apiKey: string, config?: CronitorConfig): void;
export function track(eventName: string, data?: Record<string, any>): void;
export function error(error: Error | string, metadata?: Record<string, any>): void;
}
declare global {
interface Window {
cronitor?: {
track: (eventName: string, data?: Record<string, any>) => void;
error: (error: Error | string, metadata?: Record<string, any>) => void;
};
}
}
export {};