analytics
Schema management
A sample blog post written in markdown, rendered in a PostHog-inspired docs layout.
February 26, 2026#analytics#events#schema
Schema management
Schema management lets you define and enforce the structure of your events using typed property groups. This keeps analytics clean, consistent, and easy to reason about over time.
Why schema-first tracking helps
- Prevents event drift across frontend and backend teams
- Improves dashboard reliability by enforcing consistent properties
- Makes onboarding easier with documented event contracts
- Reduces debugging time when running product experiments
A good event schema is like a public API: version it, document it, and review changes.
Event naming conventions
Use action-oriented names and keep properties explicit.
| Pattern | Example | Why it works |
|---|---|---|
entity_action | user_signed_up | Easy to scan and search |
entity_action_context | payment_failed_card | Adds precise context |
system_action | job_retried | Useful for backend telemetry |
Recommended event payload
json
{
"event": "user_signed_up",
"distinct_id": "usr_12345",
"properties": {
"plan": "pro",
"signup_method": "google",
"country": "IN",
"is_enterprise": false
}
}Use inline hints like distinct_id and plan consistently across all services.
Rollout checklist
- Define the event and required properties in markdown.
- Implement tracking in code and add tests for payload shape.
- Validate in staging and monitor first production captures.
- Share examples with the team and mark the schema as stable.
TypeScript helper example
ts
type SignupEvent = {
event: "user_signed_up";
distinct_id: string;
properties: {
plan: "free" | "pro" | "enterprise";
signup_method: "google" | "email" | "github";
country?: string;
};
};
export function trackSignup(client: { capture: (event: SignupEvent) => void }, payload: SignupEvent) {
client.capture(payload);
}Common mistakes to avoid
- Sending optional fields with inconsistent types (for example
is_paidas both string and boolean) - Renaming properties without a migration plan
- Capturing sensitive personal data accidentally
- Tracking too many low-signal events
For implementation details, see PostHog docs.