Skip to main content
Traffical events are typed end-to-end. You declare property schemas in .traffical/config.yaml, the CLI generates TypeScript types from those schemas, the SDK type-checks your track() calls, the edge validates events on the way in, and the dashboard surfaces violations. The full chain is opt-in — you can ignore everything on this page and track() still works. But once you have a few events, types catch a lot of bugs before they hit production.

What you get

  • Compile-time safety. Bad event names, missing required properties, wrong property types — all become TypeScript errors at build time, before the code runs.
  • Reuse via property groups. A geo group with market / country / currency can be attached to many events. Edit the group once; every event using it inherits the changes.
  • Edge validation. The Traffical edge validates incoming events against the schema. In warn mode you get a schemaWarnings field in the response; in reject mode invalid events are dropped before reaching the pipeline.
  • Dev-mode console warnings. The SDK can surface violations to the console at development time so you see them while building, not after deploy.

1. Declare schemas in .traffical/config.yaml

Event property schemas live alongside the event definition:

Property fields

Schema enforcement

schemaEnforcement controls what happens when an event arrives that doesn’t match its schema: warn is the right default. Switch to reject only after you’re confident in the schema — invalid events in reject mode disappear, which can hide bugs.

2. Property groups for reuse

If the same fields appear on many events, declare them once as a property group:
Then reference them from events:
The CLI resolves groups locally, so traffical generate-types produces types that include the group’s fields — no extra plumbing.

3. Push and generate types

push syncs schemas and property groups to Traffical (creating, updating, or pruning). generate-types writes a .traffical/traffical.generated.ts file with:
  • A TrafficalEventName union of all your event names
  • A TrafficalEventProperties map from event name to its property type
  • Per-event interfaces (CheckoutCompletedProperties, etc.)
  • A TypedTrack function type
A typical generated file:
You can pull and regenerate in one step:

4. Type the SDK client

The SDK accepts a TEvents generic that constrains track():
What you get with the type parameter:
The React, Svelte, and React Native SDKs accept the same generic — pass it once to the provider/client and every track() is typed.

5. Dev-mode console warnings

Pass onSchemaWarnings to the client to receive validation feedback from the edge:
warnings is an array of { eventName, propertyPath, code, message } — one per violation across the batch. You’ll see things like:
In dev, this catches schema bugs before you ship. In production, you typically silence the callback — the dashboard’s Events → Explorer shows the same violations in aggregate.

6. Reading violations in the dashboard

The dashboard’s Events → Explorer shows:
  • Volume by event
  • A “schema violations” facet showing which events had warnings, broken down by violation code
  • Per-violation drill-in to see example payloads
If you see violations climbing, fix the offending code (or update the schema if the schema is wrong). When the violation rate is essentially zero, you can switch the event to schemaEnforcement: reject to make violations hard errors.

7. Schema versioning

Schemas have a schemaVersion field. Bump it when you make a breaking change (renaming a required field, changing an enum value, etc.). The dashboard preserves old versions for historical event lookup; new events are validated against the current version. A useful convention: MAJOR-MINOR-PATCH where:
  • MAJOR for breaking changes (rename, type change, new required field)
  • MINOR for additive non-breaking changes (new optional field, new enum value)
  • PATCH for documentation-only changes

8. Property groups in CI

Property groups are versioned independently. When you change a group, every event referencing it picks up the new version on next traffical push. Run traffical status in CI to catch drift — you don’t want a group definition in the dashboard that’s out of sync with what your code expects.

End-to-end summary

Reference