mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 21:31:13 -05:00
feat: Implement comprehensive error logging
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { useState, useEffect, useRef, useCallback } from 'react';
|
||||
import { supabase } from '@/lib/supabaseClient';
|
||||
import { toast } from 'sonner';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { getErrorMessage, handleNonCriticalError } from '@/lib/errorHandler';
|
||||
import type { EntityType, EntityVersion } from '@/types/versioning';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
@@ -211,7 +211,14 @@ export function useEntityVersions(entityType: EntityType, entityId: string) {
|
||||
try {
|
||||
supabase.removeChannel(channelRef.current);
|
||||
} catch (error: unknown) {
|
||||
logger.error('Failed to cleanup realtime subscription', { entityType, entityId, error: getErrorMessage(error) });
|
||||
handleNonCriticalError(error, {
|
||||
action: 'Cleanup realtime subscription',
|
||||
metadata: {
|
||||
entityType,
|
||||
entityId,
|
||||
context: 'unmount_cleanup'
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
channelRef.current = null;
|
||||
}
|
||||
@@ -243,7 +250,14 @@ export function useEntityVersions(entityType: EntityType, entityId: string) {
|
||||
return () => {
|
||||
if (channelRef.current) {
|
||||
supabase.removeChannel(channelRef.current).catch((error) => {
|
||||
logger.error('Failed to cleanup realtime subscription', { entityType, entityId, error: getErrorMessage(error) });
|
||||
handleNonCriticalError(error, {
|
||||
action: 'Cleanup realtime subscription',
|
||||
metadata: {
|
||||
entityType,
|
||||
entityId,
|
||||
context: 'unmount_cleanup'
|
||||
}
|
||||
});
|
||||
});
|
||||
channelRef.current = null;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { useUnitPreferences } from '@/hooks/useUnitPreferences';
|
||||
import { handleNonCriticalError } from '@/lib/errorHandler';
|
||||
import { logger } from '@/lib/logger';
|
||||
import * as storage from '@/lib/localStorage';
|
||||
|
||||
@@ -26,7 +27,14 @@ export function useLocationAutoDetect() {
|
||||
autoDetectPreferences().then(() => {
|
||||
storage.setItem('location_detection_attempted', 'true');
|
||||
}).catch((error) => {
|
||||
logger.error('Failed to auto-detect location', { error });
|
||||
handleNonCriticalError(error, {
|
||||
action: 'Auto-detect user location',
|
||||
userId: user?.id,
|
||||
metadata: {
|
||||
autoDetectEnabled: preferences.auto_detect,
|
||||
context: 'initial_load'
|
||||
}
|
||||
});
|
||||
storage.setItem('location_detection_attempted', 'true');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useState, useEffect, useCallback, useRef } from 'react';
|
||||
import { supabase } from '@/lib/supabaseClient';
|
||||
import { useAuth } from './useAuth';
|
||||
import { useToast } from './use-toast';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { getErrorMessage, handleNonCriticalError } from '@/lib/errorHandler';
|
||||
import { getSubmissionTypeLabel } from '@/lib/moderation/entities';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
@@ -358,9 +358,14 @@ export const useModerationQueue = (config?: UseModerationQueueConfig) => {
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json().catch((parseError) => {
|
||||
logger.warn('Failed to parse claim error response', {
|
||||
error: getErrorMessage(parseError),
|
||||
status: response.status
|
||||
handleNonCriticalError(parseError, {
|
||||
action: 'Parse claim error response',
|
||||
userId: user.id,
|
||||
metadata: {
|
||||
submissionId,
|
||||
httpStatus: response.status,
|
||||
context: 'claim_submission_error_parsing'
|
||||
}
|
||||
});
|
||||
return { message: 'Failed to claim submission' };
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user