Add product analytics events to track user interactions in the Metabase frontend
analytics-events is an internal Metabase engineering skill for adding product analytics (Snowplow) events that track user interactions in the Metabase frontend. It solves the problem of doing this consistently within Metabase's typed event architecture, where simple events are declared where they are used rather than registered in a central union — the generic `trackSimpleEvent` validates the payload against a shared `SimpleEventSchema` at the call site, so a missing `event` name or any out-of-schema field becomes a compile error.
The skill provides a quick reference to the key files (core tracking functions, the shared schema, the legacy schema registry, and feature-specific `analytics.ts` files) and a checklist for adding an event: pick a snake_case, past-tense event name; add a tracking function that calls `trackSimpleEvent()`; keep any field unions as local types; import and call it at the interaction point; and specifically do not add an event type to the shared types file or any union. It documents the `SimpleEventSchema` fields (event, target_id, triggered_from, duration_ms, result, event_detail) and gives worked examples for each — including timing a success/failure outcome around an async operation — plus a note that custom/legacy schemas exist but new ones are essentially never added. Its declared tools are Read, Write, Edit, Grep, and Glob.
Target users are Metabase frontend engineers adding instrumentation to features. Typical use cases include tracking clicks, opens, creates, deletes, and filter applications, and recording outcome and duration for user actions. The skill only reads and edits frontend TypeScript source to add tracking calls; it involves no destructive operations, credentials, or data exfiltration.
Snowplow, via Metabase's typed event schemas. Most events use the generic `trackSimpleEvent`, which validates the payload against `SimpleEventSchema` at the call site.
In the feature's own `analytics.ts` file as a tracking function that calls `trackSimpleEvent()`. You should not add the event type to `metabase-types/analytics/event.ts` or to any union — simple events are declared where they are used.
A required snake_case `event` name plus optional `target_id`, `triggered_from`, `duration_ms`, `result` (e.g. success/failure), and `event_detail`. Anything outside the schema is a compile error.
Capture a start time, run the action, and call the tracking function in both success and failure paths passing `duration_ms` (now minus start) and `result`, as shown in the move-to-trash example.
It uses Read, Write, Edit, Grep, and Glob to read and edit frontend TypeScript, adding tracking functions and their call sites. It does not touch credentials or perform destructive operations.
Quick Setup:
.claude/skills/Repository
metabase/metabase