GithubHelp home page GithubHelp logo

isabella232 / schema-enforcer-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from posthog/schema-enforcer-plugin

0.0 0.0 0.0 117 KB

Enforce event schemas at ingestion for PostHog events.

Home Page: https://www.npmjs.com/package/posthog-schema-enforcer-plugin

License: MIT License

JavaScript 24.09% TypeScript 75.91%

schema-enforcer-plugin's Introduction

PostHog Schema Enforcer Plugin mascot

PostHog Schema Enforcer Plugin (WIP)

Objective

This plugin allows users to specify schemas for events ingested so that they can prevent the ingestion of events that don't match a specified schema.

What it currently does

Prevents 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 a plugin attachment

Example config file

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

To Do

Short Term

  • Create an interface to generate the config file (In Progress)
  • Friendlier config (e.g. accept 1, 'true', and true for toggles)
  • More config options, such as:
    • List of events to ingest
    • Thresholds (e.g. 'greater than' for number type)
    • Default values
    • ...
  • Tests

Future

  • Accept YAML
  • Powerful threshold and filtering
  • More options for what to do with "bad events" beyond not ingesting them

Questions?

schema-enforcer-plugin's People

Contributors

mariusandra avatar samwinslow avatar yakkomajuri avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.