mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 10:51:12 -05:00
feat: Implement comprehensive error logging
This commit is contained in:
@@ -8,7 +8,7 @@ import { Separator } from '@/components/ui/separator';
|
||||
import { Zap, Mail, Lock, User, Eye, EyeOff } from 'lucide-react';
|
||||
import { supabase } from '@/lib/supabaseClient';
|
||||
import { useToast } from '@/hooks/use-toast';
|
||||
import { handleError } from '@/lib/errorHandler';
|
||||
import { handleError, handleNonCriticalError } from '@/lib/errorHandler';
|
||||
import { TurnstileCaptcha } from './TurnstileCaptcha';
|
||||
import { notificationService } from '@/lib/notificationService';
|
||||
import { useCaptchaBypass } from '@/hooks/useCaptchaBypass';
|
||||
@@ -16,8 +16,6 @@ import { MFAChallenge } from './MFAChallenge';
|
||||
import { verifyMfaUpgrade } from '@/lib/authService';
|
||||
import { setAuthMethod } from '@/lib/sessionFlags';
|
||||
import { validateEmailNotDisposable } from '@/lib/emailValidation';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { logger } from '@/lib/logger';
|
||||
import type { SignInOptions } from '@/types/supabase-auth';
|
||||
|
||||
interface AuthModalProps {
|
||||
@@ -276,15 +274,23 @@ export function AuthModal({ open, onOpenChange, defaultTab = 'signin' }: AuthMod
|
||||
if (error) throw error;
|
||||
|
||||
if (data.user) {
|
||||
const userId = data.user.id;
|
||||
notificationService.createSubscriber({
|
||||
subscriberId: data.user.id,
|
||||
subscriberId: userId,
|
||||
email: formData.email,
|
||||
firstName: formData.username,
|
||||
data: {
|
||||
username: formData.username,
|
||||
}
|
||||
}).catch(err => {
|
||||
logger.error('Failed to register Novu subscriber', { error: getErrorMessage(err) });
|
||||
handleNonCriticalError(err, {
|
||||
action: 'Register Novu subscriber',
|
||||
userId,
|
||||
metadata: {
|
||||
email: formData.email,
|
||||
context: 'post_signup'
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user