.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
geogroup withmarket/country/currencycan 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
warnmode you get aschemaWarningsfield in the response; inrejectmode 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
| Field | Description |
|---|---|
type | string, number, integer, boolean, object, array |
required | If true, the property must be present |
description | Free-form, shown in the dashboard |
dimension | Marks the property as a fact dimension (see warehouse-native) — usable for slicing metrics |
enum | List of allowed values (string/number) |
pattern | Regex (string types) |
format | Built-in formats: uuid, email, uri, date-time |
minimum, maximum | Numeric bounds |
items | Element schema for array types |
properties | Nested fields for object types |
Schema enforcement
schemaEnforcement controls what happens when an event arrives that doesn’t match its schema:
| Value | Behaviour |
|---|---|
off | No validation. Events pass through. |
warn (default) | Validate; surface violations in the API response and dev-mode console; still accept the event into the pipeline. |
reject | Validate; drop invalid events. Their decisionId is unaffected (the user is still in their assignment), but the bad event never lands in metrics. |
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: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
TrafficalEventNameunion of all your event names - A
TrafficalEventPropertiesmap from event name to its property type - Per-event interfaces (
CheckoutCompletedProperties, etc.) - A
TypedTrackfunction type
4. Type the SDK client
The SDK accepts aTEvents generic that constrains track():
track() is typed.
5. Dev-mode console warnings
PassonSchemaWarnings 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:
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
schemaEnforcement: reject to make violations hard errors.
7. Schema versioning
Schemas have aschemaVersion 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 nexttraffical 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
- CLI:
generate-types - Events
- Warehouse-native: fact dimensions — dimensions from event properties power slicing