auth()->id(), 'action' => $action, 'description' => $description, 'before_data' => self::redact($before), 'after_data' => self::redact($after), 'request_id' => request()->header('X-Request-ID') ?: (string) Str::uuid(), 'subject_type' => $subject ? get_class($subject) : null, 'subject_id' => $subject?->id, 'ip_address' => request()->ip(), 'user_agent' => request()->userAgent(), ]); } catch (\Exception $e) { // Silent fail for logging } } private static function redact(?array $data): ?array { if ($data === null) { return null; } foreach ($data as $key => $value) { if (in_array((string) $key, ['password', 'token', 'content', 'notes', 'recording_url'], true)) { $data[$key] = '[REDACTED]'; } elseif (is_array($value)) { $data[$key] = self::redact($value); } } return $data; } }