API Reference
defineCatalog
Assemble event definitions into a single typed catalog — the source of truth for track(), validation and wiring.
Assembles your defineEvent definitions into one catalog: the single source of truth of your analytics coverage. It verifies event-name uniqueness and anchors all type inference — the union of event names and the literal union of tags are derived from it.
import { defineCatalog } from 'dotyc'Signature
function defineCatalog<Events extends Record<string, EventDefinition>>(
events: Events
): Catalog<Events>Parameters
| Parameter | Description |
|---|---|
events | An object whose values are event definitions created with defineEvent. The object keys are local identifiers only — the wire name is the one given to defineEvent. |
Return value
A Catalog object. Pass it to:
createEmitter— typestrack()by inferencecreateWiring— types matchers (tags,events) against the inferred literal unionscreateDispatcher— drives strict validation and computed fields at ingest
Example
import { defineCatalog } from 'dotyc'
import { featureUsed, projectCreated, checkoutCompleted } from './events'
export const catalog = defineCatalog({
featureUsed,
projectCreated,
checkoutCompleted,
})The catalog is client-safe: it contains no secrets, no adapters, no wiring. Keep it in a shared file (e.g. packages/analytics/events.ts) imported by both the emitter and the ingest side.
Notes
- Duplicate names throw. Two definitions with the same wire name are rejected at catalog creation.
track()uses the event name, not the catalog key.dotyc.track('feature_used', ...)— the string passed todefineEvent— nottrack('featureUsed', ...).- Tags become a typed union. Every tag used anywhere in the catalog joins an inferred literal union; wiring matchers are typed against it, so a tag typo in the wiring is a compile error.