一键导入
autotel-events
track(), Event API, subscribers (e.g. PostHog). Configure subscribers in init(); use track() or Event for product/analytics events.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
track(), Event API, subscribers (e.g. PostHog). Configure subscribers in init(); use track() or Event for product/analytics events.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use this skill when instrumenting AI/LLM/agent code with OpenTelemetry GenAI semantic conventions — traceGenAI() spans, token usage and cost, gen_ai.* attributes, GenAI metric views, content/evaluation events, the Vercel AI SDK bridge, or the agent identity/delegation/policy/audit governance layer. This is the canonical home for everything GenAI in autotel (the core `autotel` package is AI-free).
Review TypeScript/JavaScript code for OpenTelemetry instrumentation patterns and guide adoption of autotel. Covers Next.js, Nuxt, Nitro, TanStack Start, SvelteKit, NestJS, Express, Hono, Fastify, Elysia, Cloudflare Workers, AWS Lambda, edge runtimes, and standalone Node. Detects unstructured tracing, missing span attributes, manual exporter setup, broken context propagation, exposed PII, and ad-hoc error handling. Covers spans, metrics, logs, structured errors, the autotel processor pipeline (tail-sampling, attribute redaction, span-name normalisation, filtering, baggage), built-in enrichers (user agent, geo, request size) and custom `defineEnricher`, `defineWorkerFetch` for Cloudflare async drains, multi-vendor OTLP backends (Honeycomb, Datadog, Grafana Cloud, Sentry, Axiom, HyperDX), `composeSpanProcessors` / `composeSubscribers` / `composePostProcessors` for pipelines, AI SDK observability with gen-ai semantic conventions, and end-to-end OTLP testing.
Query OpenTelemetry telemetry (traces, metrics, logs, LLM analytics) via the autotel CLI. Use when the user asks about a production issue, slow request, error spike, expensive LLM call, or any "what is happening in my service" question. Each command returns one JSON document on stdout — parse it and answer from the data.
OpenTelemetry instrumentation for MCP (Model Context Protocol). instrumentMCPServer, instrumentMCPClient; W3C trace context via _meta; tools, resources, prompts. Security observability: annotation hints, payload-size & char-budget signals, pluggable prompt-injection classifier, spotlighting.
When to use trace vs span vs request logger vs events in Autotel. Init once at startup, package exports (autotel, autotel/event, autotel/testing). Use for setup and choosing the right API.
trace(), span(), instrument(), init(). Factory vs direct pattern, name inference. Sync init; use node-require for optional deps. Load when wrapping handlers or functions with spans.
| name | autotel-events |
| description | track(), Event API, subscribers (e.g. PostHog). Configure subscribers in init(); use track() or Event for product/analytics events. |
Send product and analytics events with track(name, attributes) or the Event class from autotel/event. Configure subscribers (e.g. PostHog) in init(); they receive events automatically.
For observability events in new code, prefer log-based correlated events (OTel Logs API model) over introducing new direct span-event instrumentation.
import { init, track } from 'autotel';
import { PostHogSubscriber } from 'autotel-subscribers/posthog';
init({
service: 'my-app',
subscribers: [new PostHogSubscriber({ apiKey: 'phc_...' })],
});
track('checkout.started', { userId: 'u_123', cartId: 'c_456' });
With Event instance (optional override of subscribers):
import { Event } from 'autotel/event';
const event = new Event('checkout');
event.trackEvent('application.submitted', { jobId: '123', userId: '456' });
Simple track (uses subscribers from init):
track('signup.completed', { plan: 'pro', source: 'web' });
Event with custom subscribers:
import { Event } from 'autotel/event';
import { PostHogSubscriber } from 'autotel-subscribers/posthog';
const event = new Event('onboarding', {
subscribers: [new PostHogSubscriber({ apiKey: 'phc_other_project' })],
});
event.trackEvent('step.completed', { step: 2 });
Validation and config: See getEventsConfig(), getValidationConfig() from init; event names and attributes can be validated.
Wrong:
track('signup', { plan: 'pro' });
Correct:
init({
service: 'my-app',
subscribers: [new PostHogSubscriber({ apiKey: 'phc_...' })],
});
track('signup', { plan: 'pro' });
Subscribers are configured in init(). track() sends to those subscribers; without init or without subscribers, events may not reach the backend.
Source: packages/autotel/src/event.ts
Targets autotel v2.23.x.