feat: Implement comprehensive error logging

This commit is contained in:
gpt-engineer-app[bot]
2025-11-04 19:04:06 +00:00
parent 40529b17e2
commit 6e64b80106
8 changed files with 151 additions and 35 deletions

View File

@@ -20,8 +20,7 @@ import {
} from '@/components/ui/form';
import { Input } from '@/components/ui/input';
import { Button } from '@/components/ui/button';
import { handleError, handleSuccess, AppError, getErrorMessage } from '@/lib/errorHandler';
import { logger } from '@/lib/logger';
import { handleError, handleSuccess, handleNonCriticalError, AppError, getErrorMessage } from '@/lib/errorHandler';
import { supabase } from '@/lib/supabaseClient';
import { Loader2, Mail, CheckCircle2, AlertCircle } from 'lucide-react';
import { TurnstileCaptcha } from '@/components/auth/TurnstileCaptcha';
@@ -179,10 +178,14 @@ export function EmailChangeDialog({ open, onOpenChange, currentEmail, userId }:
}
}).then(({ error }) => {
if (error) {
logger.error('Failed to log email change', {
handleNonCriticalError(error, {
action: 'Log email change audit',
userId,
action: 'email_change_audit_log',
error: error.message
metadata: {
oldEmail: currentEmail,
newEmail: data.newEmail,
auditType: 'email_change_initiated'
}
});
}
});
@@ -199,10 +202,13 @@ export function EmailChangeDialog({ open, onOpenChange, currentEmail, userId }:
timestamp: new Date().toISOString(),
}
}).catch(error => {
logger.error('Failed to send security notification', {
handleNonCriticalError(error, {
action: 'Send email change notification',
userId,
action: 'email_change_notification',
error: error instanceof Error ? error.message : String(error)
metadata: {
notificationType: 'security-alert',
alertType: 'email_change_initiated'
}
});
});
}
@@ -215,11 +221,6 @@ export function EmailChangeDialog({ open, onOpenChange, currentEmail, userId }:
setStep('success');
} catch (error: unknown) {
const errorMsg = getErrorMessage(error);
logger.error('Email change failed', {
userId,
action: 'email_change',
error: errorMsg,
});
const hasMessage = error instanceof Error || (typeof error === 'object' && error !== null && 'message' in error);
const hasStatus = typeof error === 'object' && error !== null && 'status' in error;