Saltar al contenido
Skillpedia
Análisis y hojas de cálculo7,6 mil · #13186

tracking

Qué hace

Esta skill explica cómo una app envía eventos de uso a través de una única función de seguimiento a uno o varios servicios de analítica. Es para desarrolladores que añaden analítica o conectan un proveedor nuevo.

Cuándo usarla

  • ✓Cuando quieres registrar un evento, como que un usuario guarda una nota nueva, en la app.
  • ✓Cuando configuras un servicio de analítica integrado mediante variables de entorno.
  • ✓Cuando añades un proveedor de analítica personalizado para otro servicio.

Link de la skill

https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/tracking/SKILL.md

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/tracking/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“Registra cuando alguien guarde una nota nueva en esta app para poder verlo en mi herramienta de analítica.”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

La app envía cada evento a través de una función de seguimiento a todos los proveedores conectados. Los proveedores se configuran con variables de entorno y envían por lotes, y un fallo nunca bloquea al usuario.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de GitHub.

Tracking

Rule

The tracking system provides a single server-side track() call that fans out to all registered providers, plus the browser-side trackEvent() counterpart. Built-in providers auto-register from env vars - set the var and tracking starts. Custom providers can be registered for any analytics backend. Both surfaces are best-effort and never block request handling.

How It Works

  1. At server startup, registerBuiltinProviders() checks env vars and registers any configured providers.
  2. Application code calls track(eventName, properties, source) from actions, plugins, or server routes.
  3. The registry fans out the event to every registered provider. Errors are caught and logged -- a failing provider never crashes the caller.
  4. Built-in providers batch HTTP calls (flush every 10 seconds or 50 events, whichever comes first). Each send times out after 10 seconds.

API

track(name, properties?, source?)

Fire an analytics event. source is either a { userId, anonymousId, sessionId } meta object or an action's ctx passed straight through.

import { track } from "@agent-native/core/tracking";

// From an action — pass ctx; userId comes from ctx.userEmail.
run: async ({ name }, ctx) => {
  track("meal.logged", { mealName: name, calories: 350 }, ctx);
};

// From a plugin or route with no ctx.
track(
  "meal.logged",
  { mealName: "Salad", calories: 350 },
  { userId: "user@example.com" },
);

The caller's browser session comes from the ambient request context (RequestContext.browserSessionId, set from the X-Agent-Native-Session-Id header), so it resolves the same whether the UI called the action or the agent did. Pass sessionId in the meta object to override it — routes that run outside a request context, such as /_agent-native/track, do exactly that. Providers map it to their own session field: $session_id for PostHog (which joins the event to session replay), session_id as a property for Mixpanel and Amplitude, a top-level sessionId for webhooks and Agent-Native Analytics. It is absent for callers with no browser — cron, CLI, MCP, A2A.

identify(userId, traits?)

Identify a user with traits. Forwarded to providers that support it.

import { identify } from "@agent-native/core/tracking";

identify("user@example.com", { plan: "pro", company: "ExampleCo" });

registerTrackingProvider(provider)

Register a custom provider.

import { registerTrackingProvider } from "@agent-native/core/tracking";

registerTrackingProvider({
  name: "my-analytics",
  track(event) {
    // Send event to your backend
  },
  identify(userId, traits) {
    // Optional
  },
  flush() {
    // Optional -- called on graceful shutdown
  },
});

flushTracking()

Flush all providers (call before process exit).

Built-in Providers

Set the env var and the provider auto-registers at startup. No SDK dependencies -- all providers use raw HTTP.

Provider Env vars
PostHog POSTHOG_API_KEY (required), POSTHOG_HOST (optional, defaults to https://us.i.posthog.com), POSTHOG_ERROR_TRACKING=false (optional opt-out)
Mixpanel MIXPANEL_TOKEN
Amplitude AMPLITUDE_API_KEY
Agent-Native Analytics AGENT_NATIVE_ANALYTICS_PUBLIC_KEY (server), AGENT_NATIVE_ANALYTICS_ENDPOINT (optional, defaults to https://analytics.agent-native.com/track)
Webhook TRACKING_WEBHOOK_URL (required), TRACKING_WEBHOOK_AUTH (optional, sent as Authorization header)

Multiple providers can be active simultaneously. All receive every event.

Browser-side trackEvent() also forwards to Agent-Native Analytics when VITE_AGENT_NATIVE_ANALYTICS_PUBLIC_KEY is present. Use VITE_AGENT_NATIVE_ANALYTICS_ENDPOINT to override the default browser endpoint. The built-in Agent-Nat

Preguntas frecuentes

¿Un servicio de analítica que falla puede romper la app?

No. Los errores se capturan y se registran, y las peticiones siguen su curso.

¿Qué servicios vienen integrados?

La skill nombra PostHog, Mixpanel, Amplitude y un webhook genérico.

¿Cómo se envían los eventos?

Los proveedores integrados envían por lotes, cada 10 segundos o cada 50 eventos, lo que ocurra primero.

Detalles

Descripción original del autor

Server-side analytics tracking with pluggable providers. Use when adding analytics events, registering custom tracking providers, or configuring built-in providers (PostHog, Mixpanel, Amplitude, Webhook).

repo: BuilderIO/agent-native

Popularidad

Estrellas en GitHub
7,6 mil
Posición en el ranking
#13186
Licencia
MIT
Actualizada
2/11/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas