mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-25 11:51:14 -05:00
Implement Phase 1 audit logging
Add centralized admin action logger and integrate logging for: - Alert resolutions (system, rate limit, grouped) - Role grants/revokes in UserRoleManager - Incident creation/acknowledgement/resolution - Moderation lock overrides Includes file updates and usage across relevant components to ensure consistent audit trails.
This commit is contained in:
@@ -151,6 +151,16 @@ export function useResolveAlert() {
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (id: string) => {
|
||||
// Fetch full alert details before resolving
|
||||
const { data: alert, error: fetchError } = await supabase
|
||||
.from('rate_limit_alerts')
|
||||
.select('*')
|
||||
.eq('id', id)
|
||||
.single();
|
||||
|
||||
if (fetchError) throw fetchError;
|
||||
|
||||
// Resolve the alert
|
||||
const { data, error } = await supabase
|
||||
.from('rate_limit_alerts')
|
||||
.update({ resolved_at: new Date().toISOString() })
|
||||
@@ -159,6 +169,18 @@ export function useResolveAlert() {
|
||||
.single();
|
||||
|
||||
if (error) throw error;
|
||||
|
||||
// Log to audit trail
|
||||
const { logAdminAction } = await import('@/lib/adminActionAuditHelpers');
|
||||
await logAdminAction('rate_limit_alert_resolved', {
|
||||
alert_id: id,
|
||||
metric_type: alert.metric_type,
|
||||
metric_value: alert.metric_value,
|
||||
threshold_value: alert.threshold_value,
|
||||
function_name: alert.function_name,
|
||||
time_window_ms: alert.time_window_ms,
|
||||
});
|
||||
|
||||
return data;
|
||||
},
|
||||
onSuccess: () => {
|
||||
|
||||
Reference in New Issue
Block a user