Skip to content

Why @xtandard/audit

Every B2B SaaS ends up needing an audit log its customers can see — it is on every enterprise security questionnaire. The options today:

  • WorkOS Audit Logs / Pangea are excellent — and SaaS, priced per event, with your customers’ activity data in someone else’s cloud.
  • Retraced (Apache-2.0) is a standalone service with Postgres, Elasticsearch and NSQ to operate, and has had no release since 2024.
  • ORM plugins (paper_trail, audited, drizzle-audit, …) record row diffs, not tenant-facing business events, and have no viewer, export, streaming or verification.

@xtandard/audit is the 20% everyone needs, as a library: a typed event model, pluggable storage, keyset search, per-tenant hash chains with signed checkpoints and an offline verifier, a customer-facing portal you embed in your product, CSV/JSON exports, SIEM streaming, retention and GDPR erasure that keeps the chain verifiable. The full market survey is in docs/research/landscape.md.

Part of the xtandard ecosystem: its closest siblings, @xtandard/webhooks and @xtandard/flags, share the same architecture and design system.

flowchart LR
  subgraph host["your app process"]
    A[app code] -- "record()" --> C[core]
    UI[admin UI / customer portal] --> C
    S[stream runner] --> C
  end
  C <--> DB[(your database)]
  S -- "batches + signed checkpoints" --> SIEM[Datadog / Splunk / S3 / webhooks]
  P[customer / auditor] -- "verify bundle" --> V[zero-dep verifier]
  • Record plane — record() validates (typed per action), applies transforms (redact/mask/hash), chains the event into its tenant’s hash chain and appends it. Synchronous-commit: it throws rather than silently dropping. A buffered createRecorder() exists for fire-and-forget hot paths, with retries, a fallback sink and backpressure.
  • Control plane — query, export, verify, checkpoints, retention, erasure, the action catalog. Hook-guarded, authorized, and self-audited (exports and erasures land in the tenant’s own log).
  • Streams read the log by per-tenant sequence cursors — nothing sits on the record path, nothing is lost when a SIEM is down.