Schema Enforcer

Last updated:

How does this app work?

The app enables you to enforce a schema on events in PostHog as they are ingested. It does this by preventing ingestion if the event:

  • Is missing a required property
  • Has a property with the wrong type
  • Is not included in the file and onlyIngestEventsFromFile is true

It also:

  • Removes all other properties from an event except selected ones if acceptOnlySchemaProps is true
  • Configuration is done via a JSON file uploaded as an attachment

What are the requirements for this app?

The Schema Enforcer app requires either PostHog Cloud, or a self-hosted PostHog instance running version 1.30.0 or later.

Not running 1.30.0? Find out how to update your self-hosted PostHog deployment!

How do I install the Schema Enforcer for PostHog?

  1. Log in to your PostHog instance
  2. Click 'Apps' on the left-hand tool bar
  3. Search for 'Schema Enforcer'
  4. Select the app, press 'Install' and follow the on-screen instructions

How do I configure the Schema Enforcer?

Below is an example configuration file:

{
"onlyIngestEventsFromFile": true,
"eventSchemas": {
"testEvent": {
"acceptOnlySchemaProps": true,
"schema": {
"foo": {
"type": "string",
"required": false
},
"bar": {
"type": "number",
"required": true
},
"baz": {
"type": "boolean",
"required": false
}
}
}
}
}

Configuration

OptionDescription
Event Schema JSON File
Type: attachment
Required: True
A valid JSON file

Is the source code for this app available?

PostHog is open-source and so are all apps on the platform. The source code for the Schema Enforcer is available on NPM.

Who created this app?

A lot of people worked on this app! We'd like to thank the following PostHog team members...

For creating the Schema Enforcer. Thank you, all!

Who maintains this app?

This app is maintained by PostHog. If you have issues with the app not functioning as intended, please raise a bug report to let us know!

What if I have feedback on this app?

We love feature requests and feedback! Please create an issue to tell us what you think.

What if my question isn't answered above?

We love answering questions. Ask us anything via our Support page.

You can also join the PostHog Community Slack group to collaborate with others and get advice on developing your own PostHog apps.

Questions?

Was this page useful?

Next article

Taxonomy Standardizer

What does the Taxonomy Standardizer app do? This app standardizes all your event names into a single pattern, so that data becomes more consistent and marketing teams aren't driven wild. What taxonomies are supported? This app can convert from any of these taxonomies, to any other. Camel Case: helloThereHedgehog Pascal Case: HelloThereHedgehog Snake Case: hello_there_hedgehog Kebab Case: hello-there-hedgehog Spaces: hello there hedgehog What are the requirements for this app? The Taxonomy…

Read next article