Skip to main content

Module audit

Module audit 

Source
Expand description

Append-only audit trail of every change to product data and users (only the optional retention, purge_older_than, removes old entries – and records that it did).

Structs§

AuditFilter
Mentions
Items and change orders the text of an entry (or notification) names besides its subject. A reader must be allowed to see all of them; otherwise the entry is redacted for that reader.

Constants§

EXPORT_MAX
Most entries in one export (export); narrow the filter for more.

Functions§

export
The audit log as an export (#152 step 8): the entries of list with the same filter, visibility and redaction, newest first, at most EXPORT_MAX. Returns the entries and whether more matched.
for_entities
History of a set of entities (e.g. an item and all of its revisions) the caller already checked. Entries that name an item the actor may not see are redacted.
list
Lists audit entries, newest first. Returns the page and the total count. Administrators only (/admin/audit): every entry except those about items, changes, requests or groups the administrator’s need-to-know policy hides (see visible_clause); entries that name such items are redacted.
purge_older_than
Removes the audit entries older than retention_days (housekeeping, TEAMCRAFT_AUDIT_RETENTION_DAYS; the caller skips it for 0 = keep for ever) and records the removal as one audit.purge entry with the count and the time span removed – in one transaction, so entries never vanish without that record. Returns the number of entries removed.
recent
Most recent activity the actor may see: entries about items, revisions, changes, requests and groups it may read; user, webhook and assistant entries only for admins (and the user’s own).
record
Writes an audit entry. Call it inside the transaction of the change it documents, so that both are committed (or rolled back) together.
record_mentioning
Like record for an entry whose summary or details name other items or change orders (labels of a change’s revisions, flagged dependents, a linked change): redacted for readers who may not see all of them.
record_related
Like record for an entry that also talks about a second item (BOM child, reference target, basis item, item added to a change, …): the entry is redacted for readers who may not see that item.
to_csv
An export as CSV: id,at,username,action,entity_type,entity_id,summary,details (details as JSON).