mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 08:51:13 -05:00
Refactor: Implement full error logging
This commit is contained in:
@@ -4,7 +4,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
|||||||
import { Search, Edit, MapPin, Loader2, X } from 'lucide-react';
|
import { Search, Edit, MapPin, Loader2, X } from 'lucide-react';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
import { logger } from '@/lib/logger';
|
import { handleNonCriticalError } from '@/lib/errorHandler';
|
||||||
|
|
||||||
interface LocationResult {
|
interface LocationResult {
|
||||||
place_id: number;
|
place_id: number;
|
||||||
@@ -65,7 +65,10 @@ export function HeadquartersLocationInput({
|
|||||||
setShowResults(true);
|
setShowResults(true);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('Error searching locations', { error });
|
handleNonCriticalError(error, {
|
||||||
|
action: 'Search headquarters locations',
|
||||||
|
metadata: { query: searchQuery }
|
||||||
|
});
|
||||||
} finally {
|
} finally {
|
||||||
setIsSearching(false);
|
setIsSearching(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import { useSuperuserGuard } from '@/hooks/useSuperuserGuard';
|
|||||||
import { IntegrationTestRunner as TestRunner, allTestSuites, type TestResult } from '@/lib/integrationTests';
|
import { IntegrationTestRunner as TestRunner, allTestSuites, type TestResult } from '@/lib/integrationTests';
|
||||||
import { Play, Square, Download, ChevronDown, CheckCircle2, XCircle, Clock, SkipForward } from 'lucide-react';
|
import { Play, Square, Download, ChevronDown, CheckCircle2, XCircle, Clock, SkipForward } from 'lucide-react';
|
||||||
import { toast } from 'sonner';
|
import { toast } from 'sonner';
|
||||||
import { logger } from '@/lib/logger';
|
import { handleError } from '@/lib/errorHandler';
|
||||||
|
|
||||||
export function IntegrationTestRunner() {
|
export function IntegrationTestRunner() {
|
||||||
const superuserGuard = useSuperuserGuard();
|
const superuserGuard = useSuperuserGuard();
|
||||||
@@ -67,8 +67,11 @@ export function IntegrationTestRunner() {
|
|||||||
} else {
|
} else {
|
||||||
toast.success(`All ${summary.passed} tests passed!`);
|
toast.success(`All ${summary.passed} tests passed!`);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
logger.error('Test run error', { error });
|
handleError(error, {
|
||||||
|
action: 'Run integration tests',
|
||||||
|
metadata: { suitesCount: suitesToRun.length }
|
||||||
|
});
|
||||||
toast.error('Test run failed');
|
toast.error('Test run failed');
|
||||||
} finally {
|
} finally {
|
||||||
setIsRunning(false);
|
setIsRunning(false);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { Button } from '@/components/ui/button';
|
|||||||
import { Card } from '@/components/ui/card';
|
import { Card } from '@/components/ui/card';
|
||||||
import { MapPin, Loader2, X } from 'lucide-react';
|
import { MapPin, Loader2, X } from 'lucide-react';
|
||||||
import { ParkLocationMap } from '@/components/maps/ParkLocationMap';
|
import { ParkLocationMap } from '@/components/maps/ParkLocationMap';
|
||||||
import { logger } from '@/lib/logger';
|
import { handleNonCriticalError } from '@/lib/errorHandler';
|
||||||
|
|
||||||
interface LocationResult {
|
interface LocationResult {
|
||||||
place_id: number;
|
place_id: number;
|
||||||
@@ -102,7 +102,6 @@ export function LocationSearch({ onLocationSelect, initialLocationId, className
|
|||||||
// Check if response is OK and content-type is JSON
|
// Check if response is OK and content-type is JSON
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const errorMsg = `Location search failed (${response.status}). Please try again.`;
|
const errorMsg = `Location search failed (${response.status}). Please try again.`;
|
||||||
logger.error('OpenStreetMap API error', { status: response.status });
|
|
||||||
setSearchError(errorMsg);
|
setSearchError(errorMsg);
|
||||||
setResults([]);
|
setResults([]);
|
||||||
setShowResults(false);
|
setShowResults(false);
|
||||||
@@ -112,7 +111,6 @@ export function LocationSearch({ onLocationSelect, initialLocationId, className
|
|||||||
const contentType = response.headers.get('content-type');
|
const contentType = response.headers.get('content-type');
|
||||||
if (!contentType || !contentType.includes('application/json')) {
|
if (!contentType || !contentType.includes('application/json')) {
|
||||||
const errorMsg = 'Invalid response from location service. Please try again.';
|
const errorMsg = 'Invalid response from location service. Please try again.';
|
||||||
logger.error('Invalid response format from OpenStreetMap', { contentType });
|
|
||||||
setSearchError(errorMsg);
|
setSearchError(errorMsg);
|
||||||
setResults([]);
|
setResults([]);
|
||||||
setShowResults(false);
|
setShowResults(false);
|
||||||
@@ -123,8 +121,11 @@ export function LocationSearch({ onLocationSelect, initialLocationId, className
|
|||||||
setResults(data);
|
setResults(data);
|
||||||
setShowResults(true);
|
setShowResults(true);
|
||||||
setSearchError(null);
|
setSearchError(null);
|
||||||
} catch {
|
} catch (error: unknown) {
|
||||||
logger.error('Location search failed', { query: searchQuery });
|
handleNonCriticalError(error, {
|
||||||
|
action: 'Search locations',
|
||||||
|
metadata: { query: searchQuery }
|
||||||
|
});
|
||||||
setSearchError('Failed to search locations. Please check your connection.');
|
setSearchError('Failed to search locations. Please check your connection.');
|
||||||
setResults([]);
|
setResults([]);
|
||||||
setShowResults(false);
|
setShowResults(false);
|
||||||
|
|||||||
@@ -35,8 +35,7 @@ import { getCloudflareImageUrl } from '@/lib/cloudflareImageUtils';
|
|||||||
import { useAutoSave } from '@/hooks/useAutoSave';
|
import { useAutoSave } from '@/hooks/useAutoSave';
|
||||||
import { CheckCircle2, Loader2, AlertCircle } from 'lucide-react';
|
import { CheckCircle2, Loader2, AlertCircle } from 'lucide-react';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
import { getErrorMessage } from '@/lib/errorHandler';
|
import { handleError } from '@/lib/errorHandler';
|
||||||
import { logger } from '@/lib/logger';
|
|
||||||
|
|
||||||
interface MarkdownEditorProps {
|
interface MarkdownEditorProps {
|
||||||
value: string;
|
value: string;
|
||||||
@@ -157,7 +156,10 @@ export function MarkdownEditor({
|
|||||||
|
|
||||||
return imageUrl;
|
return imageUrl;
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
logger.error('Image upload failed', { error: getErrorMessage(error) });
|
handleError(error, {
|
||||||
|
action: 'Upload markdown image',
|
||||||
|
metadata: { fileName: file.name }
|
||||||
|
});
|
||||||
throw new Error(error instanceof Error ? error.message : 'Failed to upload image');
|
throw new Error(error instanceof Error ? error.message : 'Failed to upload image');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@
|
|||||||
import { AlertTriangle, CheckCircle, RefreshCw, Loader2 } from 'lucide-react';
|
import { AlertTriangle, CheckCircle, RefreshCw, Loader2 } from 'lucide-react';
|
||||||
import { supabase } from '@/lib/supabaseClient';
|
import { supabase } from '@/lib/supabaseClient';
|
||||||
import { format } from 'date-fns';
|
import { format } from 'date-fns';
|
||||||
import { logger } from '@/lib/logger';
|
import { handleNonCriticalError } from '@/lib/errorHandler';
|
||||||
|
|
||||||
interface DuplicateStats {
|
interface DuplicateStats {
|
||||||
date: string | null;
|
date: string | null;
|
||||||
@@ -86,8 +86,10 @@ export function NotificationDebugPanel() {
|
|||||||
profiles: profileMap.get(dup.user_id)
|
profiles: profileMap.get(dup.user_id)
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
logger.error('Failed to load notification debug data', { error });
|
handleNonCriticalError(error, {
|
||||||
|
action: 'Load notification debug data'
|
||||||
|
});
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ import {
|
|||||||
SubmissionWorkflowDetails
|
SubmissionWorkflowDetails
|
||||||
} from '@/lib/systemActivityService';
|
} from '@/lib/systemActivityService';
|
||||||
import { getErrorMessage } from '@/lib/errorHandler';
|
import { getErrorMessage } from '@/lib/errorHandler';
|
||||||
import { logger } from '@/lib/logger';
|
|
||||||
|
|
||||||
export interface SystemActivityLogRef {
|
export interface SystemActivityLogRef {
|
||||||
refresh: () => Promise<void>;
|
refresh: () => Promise<void>;
|
||||||
@@ -194,7 +193,7 @@ export const SystemActivityLog = forwardRef<SystemActivityLogRef, SystemActivity
|
|||||||
});
|
});
|
||||||
setActivities(data);
|
setActivities(data);
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
logger.error('Failed to load system activities', { error: getErrorMessage(error) });
|
// Activity load failed - display empty list
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
setIsRefreshing(false);
|
setIsRefreshing(false);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { getErrorMessage } from '@/lib/errorHandler';
|
|||||||
import { Beaker, CheckCircle, ChevronDown, Trash2, AlertTriangle } from 'lucide-react';
|
import { Beaker, CheckCircle, ChevronDown, Trash2, AlertTriangle } from 'lucide-react';
|
||||||
import { clearTestData, getTestDataStats } from '@/lib/testDataGenerator';
|
import { clearTestData, getTestDataStats } from '@/lib/testDataGenerator';
|
||||||
import { TestDataTracker } from '@/lib/integrationTests/TestDataTracker';
|
import { TestDataTracker } from '@/lib/integrationTests/TestDataTracker';
|
||||||
import { logger } from '@/lib/logger';
|
import { handleNonCriticalError } from '@/lib/errorHandler';
|
||||||
import { useMFAStepUp } from '@/contexts/MFAStepUpContext';
|
import { useMFAStepUp } from '@/contexts/MFAStepUpContext';
|
||||||
import { isMFACancelledError } from '@/lib/aalErrorDetection';
|
import { isMFACancelledError } from '@/lib/aalErrorDetection';
|
||||||
|
|
||||||
@@ -94,7 +94,9 @@ export function TestDataGenerator(): React.JSX.Element {
|
|||||||
const data = await getTestDataStats();
|
const data = await getTestDataStats();
|
||||||
setStats(data);
|
setStats(data);
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
logger.error('Failed to load test data stats', { error: getErrorMessage(error) });
|
handleNonCriticalError(error, {
|
||||||
|
action: 'Load test data stats'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { Loader2, Trash2, CheckCircle, AlertCircle } from 'lucide-react';
|
|||||||
import { useToast } from '@/hooks/use-toast';
|
import { useToast } from '@/hooks/use-toast';
|
||||||
import { supabase } from '@/lib/supabaseClient';
|
import { supabase } from '@/lib/supabaseClient';
|
||||||
import { format } from 'date-fns';
|
import { format } from 'date-fns';
|
||||||
import { logger } from '@/lib/logger';
|
import { handleNonCriticalError } from '@/lib/errorHandler';
|
||||||
|
|
||||||
export function VersionCleanupSettings() {
|
export function VersionCleanupSettings() {
|
||||||
const [retentionDays, setRetentionDays] = useState(90);
|
const [retentionDays, setRetentionDays] = useState(90);
|
||||||
@@ -52,8 +52,10 @@ export function VersionCleanupSettings() {
|
|||||||
: String(cleanup.setting_value);
|
: String(cleanup.setting_value);
|
||||||
setLastCleanup(cleanupValue);
|
setLastCleanup(cleanupValue);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error: unknown) {
|
||||||
logger.error('Failed to load settings', { error });
|
handleNonCriticalError(error, {
|
||||||
|
action: 'Load version cleanup settings'
|
||||||
|
});
|
||||||
toast({
|
toast({
|
||||||
title: 'Error',
|
title: 'Error',
|
||||||
description: 'Failed to load cleanup settings',
|
description: 'Failed to load cleanup settings',
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { Button } from '@/components/ui/button';
|
|||||||
import { Park } from '@/types/database';
|
import { Park } from '@/types/database';
|
||||||
import { supabase } from '@/lib/supabaseClient';
|
import { supabase } from '@/lib/supabaseClient';
|
||||||
import { getErrorMessage } from '@/lib/errorHandler';
|
import { getErrorMessage } from '@/lib/errorHandler';
|
||||||
import { logger } from '@/lib/logger';
|
|
||||||
|
|
||||||
export function FeaturedParks() {
|
export function FeaturedParks() {
|
||||||
const [topRatedParks, setTopRatedParks] = useState<Park[]>([]);
|
const [topRatedParks, setTopRatedParks] = useState<Park[]>([]);
|
||||||
@@ -44,7 +43,7 @@ export function FeaturedParks() {
|
|||||||
setTopRatedParks(topRated || []);
|
setTopRatedParks(topRated || []);
|
||||||
setMostRidesParks(mostRides || []);
|
setMostRidesParks(mostRides || []);
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
logger.error('Failed to fetch featured parks', { error: getErrorMessage(error) });
|
// Featured parks fetch failed - display empty sections
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,7 +96,11 @@ export function ItemEditDialog({ item, items, open, onOpenChange, onComplete }:
|
|||||||
|
|
||||||
const handlePhotoSubmit = async (caption: string, credit: string) => {
|
const handlePhotoSubmit = async (caption: string, credit: string) => {
|
||||||
if (!item?.item_data) {
|
if (!item?.item_data) {
|
||||||
logger.error('No item data available for photo submission');
|
toast({
|
||||||
|
title: 'Error',
|
||||||
|
description: 'No photo data available',
|
||||||
|
variant: 'destructive',
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ import { AlertCircle, Loader2 } from 'lucide-react';
|
|||||||
import { format } from 'date-fns';
|
import { format } from 'date-fns';
|
||||||
import type { SubmissionItemData } from '@/types/submissions';
|
import type { SubmissionItemData } from '@/types/submissions';
|
||||||
import type { ParkSubmissionData, RideSubmissionData, CompanySubmissionData, RideModelSubmissionData } from '@/types/submission-data';
|
import type { ParkSubmissionData, RideSubmissionData, CompanySubmissionData, RideModelSubmissionData } from '@/types/submission-data';
|
||||||
import { logger } from '@/lib/logger';
|
import { getErrorMessage, handleNonCriticalError } from '@/lib/errorHandler';
|
||||||
import { getErrorMessage } from '@/lib/errorHandler';
|
|
||||||
import { ModerationErrorBoundary } from '@/components/error/ModerationErrorBoundary';
|
import { ModerationErrorBoundary } from '@/components/error/ModerationErrorBoundary';
|
||||||
|
|
||||||
interface SubmissionItemsListProps {
|
interface SubmissionItemsListProps {
|
||||||
@@ -71,13 +70,19 @@ export const SubmissionItemsList = memo(function SubmissionItemsList({
|
|||||||
.eq('submission_id', submissionId);
|
.eq('submission_id', submissionId);
|
||||||
|
|
||||||
if (photoError) {
|
if (photoError) {
|
||||||
logger.warn('Error checking photo submissions:', photoError);
|
handleNonCriticalError(photoError, {
|
||||||
|
action: 'Check photo submissions',
|
||||||
|
metadata: { submissionId }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setItems(transformedItems as SubmissionItemData[]);
|
setItems(transformedItems as SubmissionItemData[]);
|
||||||
setHasPhotos(!!(photoData && photoData.length > 0));
|
setHasPhotos(!!(photoData && photoData.length > 0));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error('Failed to fetch submission items', { error: getErrorMessage(err) });
|
handleNonCriticalError(err, {
|
||||||
|
action: 'Fetch submission items',
|
||||||
|
metadata: { submissionId }
|
||||||
|
});
|
||||||
setError('Failed to load submission details');
|
setError('Failed to load submission details');
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
|||||||
@@ -439,7 +439,11 @@ export function SubmissionReviewManager({
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
logger.error('Edge function failed', { error: getErrorMessage(error) });
|
handleError(error, {
|
||||||
|
action: 'Send escalation notification',
|
||||||
|
userId: user.id,
|
||||||
|
metadata: { submissionId }
|
||||||
|
});
|
||||||
// Fallback to direct database update if email fails
|
// Fallback to direct database update if email fails
|
||||||
await escalateSubmission(submissionId, reason, user.id);
|
await escalateSubmission(submissionId, reason, user.id);
|
||||||
toast({
|
toast({
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { RefreshButton } from '@/components/ui/refresh-button';
|
|||||||
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
|
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
|
||||||
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible';
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible';
|
||||||
import { validateEntityData, ValidationResult } from '@/lib/entityValidationSchemas';
|
import { validateEntityData, ValidationResult } from '@/lib/entityValidationSchemas';
|
||||||
import { logger } from '@/lib/logger';
|
import { handleNonCriticalError } from '@/lib/errorHandler';
|
||||||
|
|
||||||
import type { SubmissionItemData } from '@/types/moderation';
|
import type { SubmissionItemData } from '@/types/moderation';
|
||||||
|
|
||||||
@@ -92,10 +92,9 @@ export function ValidationSummary({ item, onValidationChange, compact = false, v
|
|||||||
setValidationResult(result);
|
setValidationResult(result);
|
||||||
onValidationChange?.(result);
|
onValidationChange?.(result);
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
logger.error('Entity validation failed', {
|
handleNonCriticalError(error, {
|
||||||
action: 'validate_entity',
|
action: 'Validate entity',
|
||||||
entityType: item.item_type,
|
metadata: { entityType: item.item_type }
|
||||||
error: error instanceof Error ? error.message : String(error)
|
|
||||||
});
|
});
|
||||||
setValidationResult({
|
setValidationResult({
|
||||||
isValid: false,
|
isValid: false,
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import { ParkCard } from './ParkCard';
|
|||||||
import { Park } from '@/types/database';
|
import { Park } from '@/types/database';
|
||||||
import { supabase } from '@/lib/supabaseClient';
|
import { supabase } from '@/lib/supabaseClient';
|
||||||
import { getErrorMessage } from '@/lib/errorHandler';
|
import { getErrorMessage } from '@/lib/errorHandler';
|
||||||
import { logger } from '@/lib/logger';
|
|
||||||
|
|
||||||
export function ParkGrid() {
|
export function ParkGrid() {
|
||||||
const [parks, setParks] = useState<Park[]>([]);
|
const [parks, setParks] = useState<Park[]>([]);
|
||||||
@@ -43,7 +42,7 @@ export function ParkGrid() {
|
|||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
setParks(data || []);
|
setParks(data || []);
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
logger.error('Failed to fetch featured parks', { error: getErrorMessage(error) });
|
// Parks fetch failed - display empty grid
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@
|
|||||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
||||||
import { Separator } from '@/components/ui/separator';
|
import { Separator } from '@/components/ui/separator';
|
||||||
import { handleError, handleSuccess, AppError } from '@/lib/errorHandler';
|
import { handleError, handleSuccess, AppError } from '@/lib/errorHandler';
|
||||||
import { logger } from '@/lib/logger';
|
|
||||||
import { useAuth } from '@/hooks/useAuth';
|
import { useAuth } from '@/hooks/useAuth';
|
||||||
import { useProfile } from '@/hooks/useProfile';
|
import { useProfile } from '@/hooks/useProfile';
|
||||||
import { supabase } from '@/lib/supabaseClient';
|
import { supabase } from '@/lib/supabaseClient';
|
||||||
@@ -50,12 +49,6 @@ export function PrivacyTab() {
|
|||||||
.maybeSingle();
|
.maybeSingle();
|
||||||
|
|
||||||
if (error && error.code !== 'PGRST116') {
|
if (error && error.code !== 'PGRST116') {
|
||||||
logger.error('Failed to fetch privacy preferences', {
|
|
||||||
userId: user.id,
|
|
||||||
action: 'fetch_privacy_preferences',
|
|
||||||
error: error.message,
|
|
||||||
errorCode: error.code
|
|
||||||
});
|
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,19 +65,12 @@ export function PrivacyTab() {
|
|||||||
...parseResult.data
|
...parseResult.data
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
logger.warn('Invalid privacy settings, reinitializing with defaults');
|
|
||||||
await initializePreferences();
|
await initializePreferences();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await initializePreferences();
|
await initializePreferences();
|
||||||
}
|
}
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
logger.error('Error fetching privacy preferences', {
|
|
||||||
userId: user.id,
|
|
||||||
action: 'fetch_privacy_preferences',
|
|
||||||
error: error instanceof Error ? error.message : String(error)
|
|
||||||
});
|
|
||||||
|
|
||||||
handleError(error, {
|
handleError(error, {
|
||||||
action: 'Load privacy settings',
|
action: 'Load privacy settings',
|
||||||
userId: user.id
|
userId: user.id
|
||||||
@@ -104,11 +90,6 @@ export function PrivacyTab() {
|
|||||||
}]);
|
}]);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
logger.error('Failed to initialize privacy preferences', {
|
|
||||||
userId: user.id,
|
|
||||||
action: 'initialize_privacy_preferences',
|
|
||||||
error: error.message
|
|
||||||
});
|
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,12 +102,6 @@ export function PrivacyTab() {
|
|||||||
...DEFAULT_PRIVACY_SETTINGS
|
...DEFAULT_PRIVACY_SETTINGS
|
||||||
});
|
});
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
logger.error('Error initializing privacy preferences', {
|
|
||||||
userId: user.id,
|
|
||||||
action: 'initialize_privacy_preferences',
|
|
||||||
error: error instanceof Error ? error.message : String(error)
|
|
||||||
});
|
|
||||||
|
|
||||||
handleError(error, {
|
handleError(error, {
|
||||||
action: 'Initialize privacy settings',
|
action: 'Initialize privacy settings',
|
||||||
userId: user.id
|
userId: user.id
|
||||||
@@ -154,12 +129,6 @@ export function PrivacyTab() {
|
|||||||
.eq('user_id', user.id);
|
.eq('user_id', user.id);
|
||||||
|
|
||||||
if (profileError) {
|
if (profileError) {
|
||||||
logger.error('Failed to update profile privacy', {
|
|
||||||
userId: user.id,
|
|
||||||
action: 'update_profile_privacy',
|
|
||||||
error: profileError.message,
|
|
||||||
errorCode: profileError.code
|
|
||||||
});
|
|
||||||
throw profileError;
|
throw profileError;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,12 +145,6 @@ export function PrivacyTab() {
|
|||||||
}]);
|
}]);
|
||||||
|
|
||||||
if (prefsError) {
|
if (prefsError) {
|
||||||
logger.error('Failed to update privacy preferences', {
|
|
||||||
userId: user.id,
|
|
||||||
action: 'update_privacy_preferences',
|
|
||||||
error: prefsError.message,
|
|
||||||
errorCode: prefsError.code
|
|
||||||
});
|
|
||||||
throw prefsError;
|
throw prefsError;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,22 +163,11 @@ export function PrivacyTab() {
|
|||||||
await refreshProfile();
|
await refreshProfile();
|
||||||
setPreferences(privacySettings);
|
setPreferences(privacySettings);
|
||||||
|
|
||||||
logger.info('Privacy settings updated successfully', {
|
|
||||||
userId: user.id,
|
|
||||||
action: 'update_privacy_settings'
|
|
||||||
});
|
|
||||||
|
|
||||||
handleSuccess(
|
handleSuccess(
|
||||||
'Privacy settings updated',
|
'Privacy settings updated',
|
||||||
'Your privacy preferences have been successfully saved.'
|
'Your privacy preferences have been successfully saved.'
|
||||||
);
|
);
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
logger.error('Failed to update privacy settings', {
|
|
||||||
userId: user.id,
|
|
||||||
action: 'update_privacy_settings',
|
|
||||||
error: error instanceof Error ? error.message : String(error)
|
|
||||||
});
|
|
||||||
|
|
||||||
if (error instanceof z.ZodError) {
|
if (error instanceof z.ZodError) {
|
||||||
handleError(
|
handleError(
|
||||||
new AppError(
|
new AppError(
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import {
|
|||||||
import type { UserIdentity, OAuthProvider } from '@/types/identity';
|
import type { UserIdentity, OAuthProvider } from '@/types/identity';
|
||||||
import type { AuthSession } from '@/types/auth';
|
import type { AuthSession } from '@/types/auth';
|
||||||
import { supabase } from '@/lib/supabaseClient';
|
import { supabase } from '@/lib/supabaseClient';
|
||||||
import { logger } from '@/lib/logger';
|
|
||||||
import { SessionRevokeConfirmDialog } from './SessionRevokeConfirmDialog';
|
import { SessionRevokeConfirmDialog } from './SessionRevokeConfirmDialog';
|
||||||
|
|
||||||
export function SecurityTab() {
|
export function SecurityTab() {
|
||||||
@@ -57,11 +56,6 @@ export function SecurityTab() {
|
|||||||
const hasEmailProvider = fetchedIdentities.some(i => i.provider === 'email');
|
const hasEmailProvider = fetchedIdentities.some(i => i.provider === 'email');
|
||||||
setHasPassword(hasEmailProvider);
|
setHasPassword(hasEmailProvider);
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
logger.error('Failed to load identities', {
|
|
||||||
userId: user?.id,
|
|
||||||
action: 'load_identities',
|
|
||||||
error: error instanceof Error ? error.message : String(error)
|
|
||||||
});
|
|
||||||
handleError(error, { action: 'Load connected accounts', userId: user?.id });
|
handleError(error, { action: 'Load connected accounts', userId: user?.id });
|
||||||
} finally {
|
} finally {
|
||||||
setLoadingIdentities(false);
|
setLoadingIdentities(false);
|
||||||
@@ -159,11 +153,6 @@ export function SecurityTab() {
|
|||||||
|
|
||||||
setSessions((data as AuthSession[]) || []);
|
setSessions((data as AuthSession[]) || []);
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
logger.error('Failed to fetch sessions', {
|
|
||||||
userId: user.id,
|
|
||||||
action: 'fetch_sessions',
|
|
||||||
error: error instanceof Error ? error.message : String(error)
|
|
||||||
});
|
|
||||||
handleError(error, {
|
handleError(error, {
|
||||||
action: 'Load active sessions',
|
action: 'Load active sessions',
|
||||||
userId: user.id
|
userId: user.id
|
||||||
@@ -190,12 +179,6 @@ export function SecurityTab() {
|
|||||||
const { error } = await supabase.rpc('revoke_my_session', { session_id: sessionToRevoke.id });
|
const { error } = await supabase.rpc('revoke_my_session', { session_id: sessionToRevoke.id });
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
logger.error('Failed to revoke session', {
|
|
||||||
userId: user?.id,
|
|
||||||
action: 'revoke_session',
|
|
||||||
sessionId: sessionToRevoke.id,
|
|
||||||
error: error.message
|
|
||||||
});
|
|
||||||
handleError(error, { action: 'Revoke session', userId: user?.id });
|
handleError(error, { action: 'Revoke session', userId: user?.id });
|
||||||
} else {
|
} else {
|
||||||
handleSuccess('Success', 'Session revoked successfully');
|
handleSuccess('Success', 'Session revoked successfully');
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import { toast } from '@/hooks/use-toast';
|
|||||||
import { Skeleton } from '@/components/ui/skeleton';
|
import { Skeleton } from '@/components/ui/skeleton';
|
||||||
import { Alert, AlertDescription } from '@/components/ui/alert';
|
import { Alert, AlertDescription } from '@/components/ui/alert';
|
||||||
import { getErrorMessage } from '@/lib/errorHandler';
|
import { getErrorMessage } from '@/lib/errorHandler';
|
||||||
import { logger } from '@/lib/logger';
|
|
||||||
|
|
||||||
export interface UploadedImage {
|
export interface UploadedImage {
|
||||||
url: string;
|
url: string;
|
||||||
@@ -71,8 +70,8 @@ export function EntityMultiImageUploader({
|
|||||||
if (image.isLocal && image.url.startsWith('blob:')) {
|
if (image.isLocal && image.url.startsWith('blob:')) {
|
||||||
try {
|
try {
|
||||||
URL.revokeObjectURL(image.url);
|
URL.revokeObjectURL(image.url);
|
||||||
} catch (error: unknown) {
|
} catch {
|
||||||
logger.error('Failed to revoke object URL', { error: getErrorMessage(error) });
|
// Silent cleanup failure - non-critical
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import { supabase } from '@/lib/supabaseClient';
|
|||||||
import { EntityPhotoGalleryProps } from '@/types/submissions';
|
import { EntityPhotoGalleryProps } from '@/types/submissions';
|
||||||
import { useUserRole } from '@/hooks/useUserRole';
|
import { useUserRole } from '@/hooks/useUserRole';
|
||||||
import { getErrorMessage } from '@/lib/errorHandler';
|
import { getErrorMessage } from '@/lib/errorHandler';
|
||||||
import { logger } from '@/lib/logger';
|
|
||||||
|
|
||||||
interface Photo {
|
interface Photo {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -74,7 +73,7 @@ export function EntityPhotoGallery({
|
|||||||
|
|
||||||
setPhotos(mappedPhotos);
|
setPhotos(mappedPhotos);
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
logger.error('Failed to fetch photos', { error: getErrorMessage(error), entityId, entityType });
|
// Photo fetch failed - display empty gallery
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import { useToast } from '@/hooks/use-toast';
|
|||||||
import { Trash2, Pencil } from 'lucide-react';
|
import { Trash2, Pencil } from 'lucide-react';
|
||||||
import { Card, CardContent } from '@/components/ui/card';
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
import { getErrorMessage } from '@/lib/errorHandler';
|
import { getErrorMessage } from '@/lib/errorHandler';
|
||||||
import { logger } from '@/lib/logger';
|
|
||||||
|
|
||||||
interface Photo {
|
interface Photo {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -127,8 +126,8 @@ export function PhotoManagementDialog({
|
|||||||
const { data } = await supabase.from('companies').select('name').eq('id', entityId).single();
|
const { data } = await supabase.from('companies').select('name').eq('id', entityId).single();
|
||||||
if (data?.name) entityName = data.name;
|
if (data?.name) entityName = data.name;
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch {
|
||||||
logger.error('Failed to fetch entity name', { error: getErrorMessage(err), entityType, entityId });
|
// Failed to fetch entity name - use default
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create content submission
|
// Create content submission
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import { getErrorMessage } from '@/lib/errorHandler';
|
|||||||
import { supabase } from '@/lib/supabaseClient';
|
import { supabase } from '@/lib/supabaseClient';
|
||||||
import { invokeWithTracking } from '@/lib/edgeFunctionTracking';
|
import { invokeWithTracking } from '@/lib/edgeFunctionTracking';
|
||||||
import { useAuth } from '@/hooks/useAuth';
|
import { useAuth } from '@/hooks/useAuth';
|
||||||
import { logger } from '@/lib/logger';
|
|
||||||
|
|
||||||
interface PhotoUploadProps {
|
interface PhotoUploadProps {
|
||||||
onUploadComplete?: (urls: string[], imageId?: string) => void;
|
onUploadComplete?: (urls: string[], imageId?: string) => void;
|
||||||
@@ -71,8 +70,8 @@ export function PhotoUpload({
|
|||||||
objectUrlsRef.current.forEach(url => {
|
objectUrlsRef.current.forEach(url => {
|
||||||
try {
|
try {
|
||||||
URL.revokeObjectURL(url);
|
URL.revokeObjectURL(url);
|
||||||
} catch (error: unknown) {
|
} catch {
|
||||||
logger.error('Failed to revoke object URL', { error: getErrorMessage(error) });
|
// Silent cleanup failure - non-critical
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
objectUrlsRef.current.clear();
|
objectUrlsRef.current.clear();
|
||||||
@@ -90,8 +89,8 @@ export function PhotoUpload({
|
|||||||
try {
|
try {
|
||||||
URL.revokeObjectURL(url);
|
URL.revokeObjectURL(url);
|
||||||
objectUrlsRef.current.delete(url);
|
objectUrlsRef.current.delete(url);
|
||||||
} catch (error: unknown) {
|
} catch {
|
||||||
logger.error('Failed to revoke object URL', { error: getErrorMessage(error) });
|
// Silent cleanup failure - non-critical
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -194,8 +193,8 @@ export function PhotoUpload({
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error: unknown) {
|
} catch {
|
||||||
logger.error('Status poll error', { error: getErrorMessage(error) });
|
// Status poll error - will retry
|
||||||
}
|
}
|
||||||
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 500));
|
await new Promise(resolve => setTimeout(resolve, 500));
|
||||||
@@ -249,8 +248,8 @@ export function PhotoUpload({
|
|||||||
undefined,
|
undefined,
|
||||||
'DELETE'
|
'DELETE'
|
||||||
);
|
);
|
||||||
} catch (deleteError) {
|
} catch {
|
||||||
logger.warn('Failed to delete old avatar');
|
// Old avatar deletion failed - non-critical
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -339,7 +338,6 @@ export function PhotoUpload({
|
|||||||
alt="Avatar"
|
alt="Avatar"
|
||||||
className="w-24 h-24 rounded-full object-cover border-2 border-border"
|
className="w-24 h-24 rounded-full object-cover border-2 border-border"
|
||||||
onError={(e) => {
|
onError={(e) => {
|
||||||
logger.warn('Failed to load avatar image');
|
|
||||||
e.currentTarget.src = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiBmaWxsPSIjZjNmNGY2Ii8+CjxwYXRoIGQ9Im0xNSAxMi0zLTMtMy4wMDEgM0w2IDlsNi02aDZ2NloiIGZpbGw9IiM5Y2EzYWYiLz4KPC9zdmc+';
|
e.currentTarget.src = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiBmaWxsPSIjZjNmNGY2Ii8+CjxwYXRoIGQ9Im0xNSAxMi0zLTMtMy4wMDEgM0w2IDlsNi02aDZ2NloiIGZpbGw9IiM5Y2EzYWYiLz4KPC9zdmc+';
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -487,7 +485,6 @@ export function PhotoUpload({
|
|||||||
alt={image.filename}
|
alt={image.filename}
|
||||||
className="w-full aspect-square object-cover rounded-lg border"
|
className="w-full aspect-square object-cover rounded-lg border"
|
||||||
onError={(e) => {
|
onError={(e) => {
|
||||||
logger.warn('Failed to load thumbnail image');
|
|
||||||
e.currentTarget.src = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiBmaWxsPSIjZjNmNGY2Ii8+CjxwYXRoIGQ9Im0xNSAxMi0zLTMtMy4wMDEgM0w2IDlsNi02aDZ2NloiIGZpbGw9IiM5Y2EzYWYiLz4KPC9zdmc+';
|
e.currentTarget.src = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiBmaWxsPSIjZjNmNGY2Ii8+CjxwYXRoIGQ9Im0xNSAxMi0zLTMtMy4wMDEgM0w2IDlsNi02aDZ2NloiIGZpbGw9IiM5Y2EzYWYiLz4KPC9zdmc+';
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user