Getting Started
trakoo is one typed analytics API for TypeScript. Define your events once, choose your providers, and keep the same track() calls when your stack changes.
trakoo gives your TypeScript app a single, typed analytics API. You define the events your product emits, pick the providers you trust, and call track(). When your analytics stack changes, those call sites stay the same — you swap providers in one place, not across your codebase.
It runs in browsers, servers, and edge runtimes. The two environment-specific factories share the same event registry.
Get started with your coding agent
Give this prompt to your coding agent to load Trakoo’s integration guidance without installing the skill:
Run `npx skills use "https://github.com/multiplehats/trakoo" --skill "trakoo"` and follow the generated skill instructions now. Read its complete output, redirecting it to a temporary file first if necessary. Resolve relative paths from the supporting-files directory it provides.
To keep the guidance available in your project, install the Agent Skill instead.
Providers
Start with one provider and add more when you need them. Every provider is optional and independently configured.
Product analytics, feature flags, and session replay
BentoEmail automation and lifecycle events for identified users
PirschPrivacy-friendly, cookie-free web analytics
EmitKitServer-side event notifications and activity feeds
VisitorsLightweight web analytics with Stripe revenue attribution
ProxySend browser events through your own API endpoint
How it works
You describe your events once. That single definition becomes autocomplete, compile-time validation, and provider routing everywhere you track.
import { defineEvents, typed } from 'trakoo';
export const appEvents = defineEvents({
userSignedUp: {
name: 'user_signed_up',
category: 'user',
properties: typed<{
email: string;
plan: 'free' | 'pro' | 'enterprise';
}>()
}
});
Create an application-owned analytics instance with the providers you want. Passing the registry value infers every event type:
import { createClientAnalytics } from 'trakoo/client';
import {
PostHogClientProvider,
VisitorsClientProvider
} from 'trakoo/providers/client';
import { appEvents } from './events';
export const analytics = createClientAnalytics({
events: appEvents,
providers: [
new PostHogClientProvider({ token: import.meta.env.VITE_POSTHOG_KEY }),
new VisitorsClientProvider({ token: import.meta.env.VITE_VISITORS_TOKEN })
]
});
The root trakoo import contains shared types and environment-neutral event helpers. Import factories and providers from their client or server subpaths.
Then track from anywhere. TypeScript knows the valid event names and their required properties:
await analytics.track('user_signed_up', {
email: 'ada@example.com',
plan: 'pro'
});
Add Bento for lifecycle email later, or move browser events through the Proxy — the code calling analytics.track() doesn’t change.
Why trakoo
Typed events
Event names and properties are inferred from your definitions and enforced at every call site.
Provider-agnostic
Official providers for PostHog, Bento, Pirsch, EmitKit, Visitors, and a first-party proxy — plus a simple interface for your own.
Client and server
Stateful browser tracking for interactions, stateless server tracking for critical events — one shared event map.
Route events anywhere
Send page views to one provider, lifecycle events to another, and noisy events nowhere.
Next steps
Quick Start
Go from install to your first tracked event in a few minutes.
Installation
Install the core package and the SDKs each provider needs.
Core Concepts
Understand events, providers, and the client/server split.
Framework Guides
Wire trakoo into Next.js or SvelteKit end to end.
Agent Skill
Teach your coding agent trakoo’s conventions with npx skills add.
