Guidance for deciding when and how to add normalized audit event log calls in gt-cloud product code. Use when writing or reviewing security-sensitive mutations, auth flows, membership/permission changes, SSO/SCIM changes, API key changes, super-user access, or sensitive data-access actions that should create audit events.
Use this skill when deciding whether product code should create an audit event, and how to write that call correctly.
This skill is for adding or reviewing audit event log calls in product code. Do not redesign the audit system unless the product event you are wiring requires a narrowly scoped helper or enum change.
packages/node/src/database/audit/auditEventTypes.tspackages/node/src/database/audit/auditEventBuilders.tsrecordAuditEvent.ts and take the same AuditEventInfo):recordAuditEvent() — fail-closed; throws if the event cannot be written.tryRecordAuditEvent() — fail-open; identical except failures are logged and swallowed.resolveAuditScope() (project → org, org → enterprise backfill) unless scope: 'user-level'.actor: { type: AuditActorType.USER, ...user } (or GT_ADMIN / API_KEY / SYSTEM).Prisma.TransactionClient second argument — pass the tx to write the event atomically with the mutation it records (all-or-nothing).buildAuditRequestContext(headers)import { AuditActorType, AuditEventResult } from '@generaltranslation/db/client.js';
import { AuditEventType } from '@generaltranslation/node/database/audit/auditEventTypes.js';
import { buildAuditRequestContext } from '@generaltranslation/node/database/audit/requestContext.js';
import { recordAuditEvent, tryRecordAuditEvent } from '@generaltranslation/node/database/audit/recordAuditEvent.js';references/coverage.md.references/failure-and-placement.md.references/payloads.md.references/verification.md.event_type values: user.created, project.updated, enterprise.deleted, sso.provider.updated.AuditEventType limited to events that are actually wired to product code.AuditEventType entries are wired to real product code and are not stale or speculative.tryRecordAuditEvent() and should not hide primary operation failures.