Guides adding, changing, and reviewing telemetry through the `@n8n/telemetry` event registry. Use when working on telemetry, analytics, tracking, product events
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-telemetry-2a3d0001f7e4 ,按照其中的说明把「n8n:telemetry」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
Events migrated to the registry live in packages/@n8n/telemetry as one entry per event — its exact emitted name, a description, and a zod schema typing its properties — organized per product domain in src/events/ and composed into TELEMETRY_EVENT.<DOMAIN>.<EVENT>. The package defines registered events and never depends on transport SDKs.
To find which events are registered, what they mean, or what properties they carry, run the catalog first:
pnpm --filter @n8n/telemetry catalog # human-readable, grouped by domain
pnpm --filter @n8n/telemetry catalog --json # structured, for programmatic use
The registry is being adopted incrementally. Events not yet registered do not appear in the catalog, so search track() call sites when the catalog has no match.
Pass the entry itself to track() — it resolves the emitted name internally:
import { TELEMETRY_EVENT } from '@n8n/telemetry';
telemetry.track(TELEMETRY_EVENT.PLATFORM.USER_IS_PART_OF_EXPERIMENT, {
name: experimentName,
variant,
});
Both track() implementations accept registry entries and plain strings. Plain strings remain supported for events that have not yet migrated:
packages/frontend/editor-ui/src/app/plugins/telemetry/index.tspackages/cli/src/telemetry/index.tsEntries get property autocomplete and compile-time checks — typo'd, missing, or wrongly typed properties fail typecheck. When the telemetry transport is initialized, track() additionally validates registered-event payloads via getEventValidationError (shared from @n8n/telemetry) and logs a warning on mismatch, including unrecognized properties that slipped past structural typing. A validation warning does not stop the event from being emitted.
pnpm --filter @n8n/telemetry catalog). If an existing event covers the same user action from another surface, augment it with a property instead of adding a near-duplicate event.User opened Credential modal is CREDENTIALS whether opened from the NDV, template setup, or chat. The trigger context goes into a source property.User pinned node data). No template interpolation in names — variability goes into properties. The name must snake_case cleanly into a BigQuery table name: no punctuation beyond spaces, no casing that collides after snake_casing.description stating what the event means and when it fires — a registry test rejects blank descriptions. Document individual properties with .describe() where the key alone is not obvious.import { z } from 'zod/v4'): snake_case keys, explicit .optional() where a call site may omit a value, z.looseObject()/.catchall() for genuinely dynamic remainders. Schemas must stay JSON-Schema-representable — no transforms, refinements, or z.date() (a registry test enforces this via z.toJSONSchema()).useTelemetry().track(...); backend either through a RelayEventMap handler in packages/cli/src/events/relays/telemetry.event-relay.ts (event-bus-driven) or a direct Telemetry.track(...) call — both reference the same registry entry..meta({ deprecated: true })) instead of removing.Do not retype event-name literals in tests:
useTelemetry().track or the backend Telemetry.track service and expect the registry entry itself with the payload.window.rudderanalytics.track to receive entry.name and the augmented payload.event field to equal entry.name and its properties to include the event payload.Experiment exposure and metric events follow n8n:experiments (.agents/skills/experiments/SKILL.md).