Skip to content

trackkit / index / EventMap

Type Alias: EventMap

EventMap = Record<string, Record<string, unknown>>

Defined in: types.ts:67

A mapping from event names to their expected property shapes.

Define your own event map to get compile-time checking of track() calls:

ts
type MyEvents = {
  signup_completed: { plan: 'free' | 'pro' };
  purchase:         { amount: number; currency: string };
};

const analytics = createAnalytics<MyEvents>({ ... });
analytics.track('signup_completed', { plan: 'pro' });   // ✅ compiles
analytics.track('signup_completed', { plan: 'gold' });   // ❌ type error

When no event map is supplied (the default), any string name and any props are accepted — identical to the pre-typed-events behaviour.

Released under the MIT License.