Audit Logs
Persist normalized Paymesh activity as structured audit entries with filters, actor resolution, batching, and request metadata capture.
What the plugin adds
The audit log plugin contributes:
- one custom
audit_logstable - automatic persistence for matching webhook events
- a lazy runtime client with
create,list, andprune - event filtering and redaction options
Setup
import { auditLog } from "@paymesh/audit-logs";
auditLog({
events: ["payment.*", "customer.*", "checkout.*"],
mode: "async",
retention: "1y",
includeRequestInfo: true,
actor({ request }) {
const email = request?.headers.get("x-user-email");
if (!email) return null;
return {
type: "user",
id: "user_123",
email,
};
},
});Important options
Key options in the current codebase:
eventsexcludemodefailureModeretentionredactincludeDiffincludeProviderMetadataincludeRequestInfoactorbatch
Manual entries
await paymesh.auditLog.create({
action: "invoice.sent",
resource: {
type: "invoice",
id: "inv_123",
},
message: "Invoice sent to customer",
});