venthrive-api / utils /audit.py
GitHub Actions
Sync from GitHub · 2026-10-20 19:36 UTC
a32af27
Raw History Blame Contribute Delete
582 Bytes
"""
Writes to the admin audit trail (backend/sql/admin_audit_schema.sql). Never
raises — a failed audit write must not break the action it's recording.
"""
from utils.supabase_client import get_supabase
def log_action(actor: str, kind: str, action: str, summary: str, target: str | None = None) -> None:
try:
get_supabase().table("admin_audit_log").insert({
"actor": actor, "kind": kind, "action": action, "target": target, "summary": summary,
}).execute()
except Exception as e:
print(f"[audit] failed to log {kind}/{action}: {e}")