tracking
What it does
This skill explains how an app sends usage events through one tracking function to one or more analytics services. It is for developers adding analytics or connecting a new analytics provider.
When to use it
- ✓When you want to record an event, such as a user saving a new note, in an app.
- ✓When you set up a built-in analytics service through environment settings.
- ✓When you add a custom analytics provider for a different service.
Skill link
https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/tracking/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Track when someone saves a new note in this app so I can see it in my analytics tool.”
5 new skills a week. 1 minute to read.
How it works
The app sends each event through one tracking function to every connected provider. Providers are set up from environment variables and send in batches, and a failure never blocks the user.
Technical content (original SKILL.md)
Original text by the author, straight from 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
- At server startup,
registerBuiltinProviders()checks env vars and registers any configured providers. - Application code calls
track(eventName, properties, source)from actions, plugins, or server routes. - The registry fans out the event to every registered provider. Errors are caught and logged -- a failing provider never crashes the caller.
- 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
FAQ
Can a failing analytics service break the app?
No. Errors are caught and logged, so requests keep going.
Which services are built in?
The skill names PostHog, Mixpanel, Amplitude, and a generic webhook.
How are events sent?
Built-in providers batch events, sending every 10 seconds or every 50 events, whichever comes first.
Details
Original description by the author
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
Popularity
- GitHub stars
- 7.6k
- Ranking position
- #13186
- License
- MIT
- Updated
- 11/2/2026
Comments
- …
More skills from this repository
design-exploration
7.6kHelps your agent explore several UI design directions side by side, let you pick one, and then refine the chosen design.
visual-edit
7.6kHelps your agent open a running local app in a visual editor so you can review and edit its real screens together.
turn-into-app
7.6kTurns a workflow, spreadsheet or project into a polished visual app, with populated screens and an agent working behind the controls.
visual-plan
7.6kTurns a plain text plan into an interactive visual plan with diagrams, file maps, code snippets and open questions.
Similar skills
gitcrawl
394kLets your agent search a saved archive of GitHub issues and pull requests, group duplicates, and check their current status on GitHub.
slacrawl
394kLets your agent search and count messages in a local Slack archive, check how fresh that archive is, and refresh it when needed.
goplaces
394kHelps your agent search for places, get their details and reviews, and resolve place names using Google Places, with JSON output for scripts.