adding-audit-events

Adds audit events to Nango endpoints by updating the vocabulary table, middleware, and webapp filters.

11.7k|1.3k|Updated Apr 9, 2020
One-click install
npx skills add https://github.com/NangoHQ/nango --skill adding-audit-events
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: adding-audit-events
Source: https://github.com/NangoHQ/nango/tree/main/.agents/skills/adding-audit-events
Command: npx skills add https://github.com/NangoHQ/nango --skill adding-audit-events

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Adding an audit event to a Nango endpoint touches many files across the monorepo — the vocabulary table, metadata types, middleware specs, route mounts, and the webapp filter list — and missing any one of them causes build errors or silently lost audit rows. This Skill provides the exact ordered workflow and gotchas so every audited endpoint is wired correctly.

Core Features & Use Cases

  • Vocabulary-first workflow: Start from AuditEventTable in packages/types/lib/audit-trail/event.ts and let the compiler drive the remaining changes across metadata types, middleware specs, and the webapp.
  • Middleware and mounting rules: Defines spec placement in packages/server/lib/middleware/audit/, barrel exports, and the requirement to mount audit middleware before withScope so denials are still recorded.
  • Gotcha coverage: Documents resolver timing (raw req.body before zod), targetFromResponse/metadataFromResponse for handler-generated values, and control-plane vs data-plane scoping.
  • Use Case: When adding a new integration.updated endpoint, follow the checklist to declare the action in the vocabulary, write the auditable spec, mount it before the scope check, add the webapp filter entry, and verify with a break-checked unit test.

Quick Start

Use the adding-audit-events skill to add an audit event for my new Nango endpoint and update all required files.

Frequently Asked Questions about adding-audit-events

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add an audit event to a Nango endpoint?

Add the action to AuditEventTable in packages/types/lib/audit-trail/event.ts first, then define its metadata shape, write an auditable middleware spec, export it from the barrel, mount it before withScope, and add the action to the webapp's actionsByResource constants.

Where should audit middleware be mounted in Nango routes?

Mount audit middleware before withScope in routes.public.ts or routes.private.ts, for example .post(apiAuth, auditThingDone, withScope('...'), handler). Mounting after the scope check means 403 denials are never recorded in the audit trail.

Should runtime traffic like proxy or sync execution be audited?

No. The Nango audit trail is control-plane only, covering configuration, state, and authentication events. Runtime traffic such as records, proxy calls, and sync execution is data plane and would generate millions of rows per month; mark those endpoints with a no-audit policy.

Why is req.body undefined or unvalidated in audit middleware?

Audit resolvers run before zod validation, so req.body, params, and query are raw regardless of the endpoint type. Use the guards in input.ts such as nonEmptyString, positiveInt, param, query, and bodyField to safely extract values.

How do I audit values only available after the handler runs?

Use targetFromResponse or metadataFromResponse instead of the request-based resolvers. Since target and metadata resolve before next(), any value the handler generates is unavailable at that point and must be read from the response.