Skip to content
trakoo
Esc
navigateopen⌘Jpreview
On this page

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.

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

Next steps

Was this page helpful?