Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including ski-mask with all npm packages installed. Try it out:

var skiMask = require("ski-mask")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

ski-mask v1.1.3

Schema validation tool for Snowplow Iglu JSON schemas.

NPM

Ski Mask

Schema validation tool for Snowplow Iglu JSON schemas.


Command line Usage

  1. Install ski-mask
npm install ski-mask -g
# Or
yarn global add ski-mask
  1. Grab a valid Iglu resolver.json file that resolves to your Iglu server(s).

  2. Run ski-mask to validate the payload.

ski-mask -r ./path/to/resolver.json -d ./path/to/snowplow-payload-data.json

Example

  1. Prepare your data.json file that represents your Snowplow Payload.
{
    "schema": "iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0",
    "data": {
        "event_name": "link_click",
        "schema": "iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-0",
        "data": {
            "targetUrl": "https://myawesomeurl.com/data",
            "elementId": "bestElementEver"
        }
    }
}
  1. Grab your Iglu resolver config file and name it something like resolver.json.
{
    "schema": "iglu:com.snowplowanalytics.iglu/resolver-config/jsonschema/1-0-0",
    "data":
    {
        "cachesize": 500,
        "repositories":
        [
            {
                "name": "iglu central",
                "priority": 0,
                "vendorprefixes":
                [
                    "com.snowplowanalytics.snowplow"
                ],
                "connection":
                {
                    "http":
                    {
                        "uri": "http://iglucentral.com"
                    }
                }
            },
            {
                "name": "my iglu server",
                "priority": 1,
                "vendorprefixes":
                [
                    "com.my-iglu-server"
                ],
                "connection":
                {
                    "http":
                    {
                        "uri": "http://awesome-schemas.my-iglu-server.com"
                    }
                }
            }
        ]
    }
}
  1. Run ski-mask to validate the payload.
ski-mask -r ./path/to/resolver.json -d ./path/to/snowplow-payload-data.json

Programmatic usage

  1. Add ski-mask to your package.json
npm install ski-mask --dev
# or
yarn add ski-mask --dev
  1. Use the API
const skiMask = require('ski-mask');
// or import validate from 'ski-mask'


const payload = {
    "schema": "iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0",
    "data": {
        "event_name": "link_click",
        "schema": "iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-0",
        "data": {
            "targetUrl": "https://myawesomeurl.com/data",
            "elementId": "bestElementEver"
        }
    }
};

const resolverConfig = {
    "schema": "iglu:com.snowplowanalytics.iglu/resolver-config/jsonschema/1-0-0",
    "data":
    {
        "cacheSize": 500,
        "repositories":
        [
            {
                "name": "Iglu Central",
                "priority": 0,
                "vendorPrefixes":
                [
                    "com.snowplowanalytics.snowplow"
                ],
                "connection":
                {
                    "http":
                    {
                        "uri": "http://iglucentral.com"
                    }
                }
            },
            {
                "name": "My Iglu Server",
                "priority": 1,
                "vendorPrefixes":
                [
                    "com.my-iglu-server"
                ],
                "connection":
                {
                    "http":
                    {
                        "uri": "http://awesome-schemas.my-iglu-server.com"
                    }
                }
            }
        ]
    }
};

skiMask.validate(payload, resolverConfig).then(
    msg => console.log(msg)
)

// Will yield a result object

// {
//   success: true,
//   message: 'All Valid'
// }

// or

// {
//   success: false,
//   message: 'some error message',
//   context: 'some context for the error message'
// }
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free