import { logger } from "../logger"; import { prisma } from "./db"; /** Best-effort audit row. Never throws to the caller. */ export async function logAdminRuleRead(opts: { ruleId: string; adminEmail: string; adminUserId: string | null; path: string; }): Promise { try { await prisma.adminRuleReadLog.create({ data: { ruleId: opts.ruleId, adminEmail: opts.adminEmail.trim().toLowerCase(), adminUserId: opts.adminUserId, path: opts.path.slice(0, 500), }, }); } catch (err) { logger.warn("[admin-rule-read] failed to write log", err); } }