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 the same way in the browser and on the server, ships zero dependencies, and works on the edge.
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 type { CreateEventDefinition, EventCollection } from 'trakoo';
export const appEvents = {
userSignedUp: {
name: 'user_signed_up',
category: 'user',
properties: {} as {
email: string;
plan: 'free' | 'pro' | 'enterprise';
}
}
} as const satisfies EventCollection<Record<string, CreateEventDefinition<string>>>;
export type AppEvents = typeof appEvents;
Create an analytics instance with the providers you want, typed by those events:
import { createClientAnalytics } from 'trakoo/client';
import {
PostHogClientProvider,
VisitorsClientProvider
} from 'trakoo/providers/client';
import type { AppEvents } from './events';
export const analytics = createClientAnalytics<AppEvents>({
providers: [
new PostHogClientProvider({ token: import.meta.env.VITE_POSTHOG_KEY }),
new VisitorsClientProvider({ token: import.meta.env.VITE_VISITORS_TOKEN })
]
});
Then track from anywhere. TypeScript knows the valid event names and their required properties:
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.
