# Audit log

Who did what, in sentences, with agents and keys told apart from people, the changes behind each event, and export.

> chatcn Pro: needs a Pro license (https://chatcn.dev/pro). Install from the `@chatcn-pro` registry with your license token; setup at https://chatcn.dev/docs/chatcn-pro.

Example: Audit log. A week of events from people, agents, a key and the system. Open one to see what changed, filter, or export. Preview: https://chatcn.dev/preview/audit-log-demo

## Installation

```bash
npx shadcn@latest add @chatcn-pro/audit-log
```

## Usage

```tsx
import { AuditLog } from "@/components/ui/chatcn/pro/audit-log"

<AuditLog
  events={[
    {
      id: "evt_1",
      at: "2026-03-18T14:05:00Z",
      actor: { kind: "member", name: "Maya Lindqvist" },
      action: "policy.model_blocked",
      summary: "blocked Claude Opus 5.5 for the workspace",
      category: "settings",
      ip: "81.214.6.20",
      location: "Stockholm, SE",
      changes: [{ field: "Code default", from: "Claude Opus 5.5", to: "Claude Sonnet 5.5" }],
    },
  ]}
  categories={[{ id: "settings", label: "Settings" }, { id: "agents", label: "Agents" }]}
  hasMore={cursor !== null}
  onLoadMore={loadOlder}
/>
```

Each event reads as a sentence: the actor in bold and what they did. Agents and API keys have their own marks and name the person they acted for, so work done by AI is never mistaken for work done by hand. Events are grouped by day under sticky headings. Open one to see what changed in a before and after table, the event name, the exact time with its time zone and where it came from. Filter by category, by kind of actor and by text; Export downloads a CSV of exactly the events that match, or pass `onExport` to do it on your server. Load older pages in from your cursor.

## Examples

### States

Example: States. Nothing logged yet, and a narrow frame. Preview: https://chatcn.dev/preview/audit-log-states

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `events` | `AuditEvent[]` | `{ id, at, actor, action, summary, category, ip?, location?, changes? }` |
| `categories` | `{ id, label }[]` | The category filter |
| `hasMore`, `loadingMore`, `onLoadMore` |  | Older events |
| `onExport` | `(events) => void` | Default downloads a CSV of the filtered events |
| `now`, `locale` |  | Today and Yesterday, and times |
| `labels` | `Partial<AuditLogLabels>` | Every string, for translation |

## Accessibility

- Each event is a disclosure button that reports whether it is open.
- Changes are a real table with row headers.
- Category filters are toggle buttons that report their state; the actor filter is a radio group.

## Motion

The chevron turns 90 degrees over 150 ms. Nothing else moves.

Source: https://chatcn.dev/docs/components/audit-log