Schema Enforcer

Last updated:

|Edit this page

The transformation 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

Requirements

Using this requires either PostHog Cloud with the data pipelines add-on, or a self-hosted PostHog instance running a recent version of the Docker image.

Installation

  1. Log in to your PostHog instance
  2. Click "Data pipeline" in the left sidebar
  3. Search for 'Schema Enforcer'
  4. Select the transformation, press 'Install' and follow the on-screen instructions

Configuration

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
}
}
}
}
}

Additional configuration

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

FAQ

Is the source code for this transformation available?

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

Who created this transformation?

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?

This is maintained by PostHog. If you have issues with it not functioning as intended, please let us know!

What if I have feedback on this destination?

We love feature requests and feedback. Please tell us what you think.

What if my question isn't answered above?

We love answering questions. Ask us anything via our community forum.

Questions?

Was this page useful?

Next article

Troubleshooting and FAQs

My transformation or destination isn't working, what do I do? Checking that the transformation or destination is enabled with the correct configuration options in the data pipeline tab . You can find the correct configuration options in the transformation or destination's documentation by searching for it in the destinations, transformations, or filtering sections of the docs. Click "Logs & metrics" and go to the Metrics tab to check that the transformation or destination is processing…

Read next article