Skip to content

Crawler assistido para validação de objetos enviados à camada de dados (Data Layer)

Notifications You must be signed in to change notification settings

leocb/penguin-datalayer

 
 

Repository files navigation

Penguin DataLayer

semantic-release

Read this in other languages: Português-BR

The Penguin DataLayer is an Open Source tool developed by DP6 with the objective to help in the validation process of implementing the data layer, by using a schema that faithfully represents the keys, values and expected data types. The tool acts as a crawler, following data layer triggers and validating every object sent against a schema.

Table of contents

Install

To install the current version:

npm install -i

After installing the library, the directory structure should look like the following:

├── config
├── lib
├── results
└── schema

How to use

The DataLayer Penguin validates every hit sent to the Data Layer. To ensure every hit is sent correctly formulated and with the expected values, it's necessary to include two manually generated files:

  • JSON Schema
  • Config

Both config files should be generated through the following sheet: Ludwig - Schema & Config

The config file must be saved in the config folder, and the JSON Schema in the schema folder. Example:

├── config
│   ├── config_example.json
├── results
└── schema
    ├── schema_example.json

To execute the validator, you must pass the config file as a parameter:

npm start config_example.json

After executing this command, the validator will spin up a Chromium instance, reading the initial URL config, data layer name and JSON Schema.

Every hit sent automatically to the data layer will be automatically validated, however, the validator will need human interaction in case any hit needs interaction to be sent (click, form fill, etc.)

By default, the validation logs are available in the folder results, in pdf or xlsx format, depending on the parameter defined in the command line when DataLayer Penguin is executed, Example:

npm start config_example.json pdf

or

npm start config_example.json xlsx

JSON Schema

The JSON Schema is a structure that allows the validation of JSON documents. This structures is used in the project because it allows for the declaration of expected data in the data layer.

Supported Types

The following types are supported:

  • String
  • Number
  • Boolean
  • Object
  • Array

Validation Rules

The following validation rules are accepted:

  • Enum (Equals): Used when you need to validate the equality between the expected value versus the value sent to the data layer
  • Pattern (Regex - String): It's possible to create regular expressions to validate the keys values
  • minItems (Array): Validates the minimum number of items in the array
  • Required: When a value is mandatory for a key

JSON Schema Structure

The following is an example of a JSON Schema:

{
  "$schema": "",
  "title": "Schema example",
  "array": {
    "$id": "#/properties/schema",
    "type": "array",
    "items": [
      {
        "type": "object",
        "properties": {
          "event": {
            "type": "string",
            "enum": ["teste"]
          },
          "key1": {
            "type": "object",
            "properties": {
              "key1_sub1": {
                "type": "number"
              },
              "key1_sub2": {
                "type": "string",
                "pattern": "teste|test|.*"
              },
              "key1_sub3": {
                "type": "string",
                "enum": ["producao"]
              },
              "key1_sub4": {
                "type": "boolean"
              }
            },
            "required": ["key1_sub1", "key1_sub2", "key1_sub3", "key1_sub4"]
          }
        },
        "required": ["event"]
      }
    ]
  }
}

How to contribute

Pull requests are welcome! We'd love your help to level up this module. Feel free to look at the open issues for something to do. In case you have a new feature request or bug report, please open a new issue so our team can investigate it

Mandatory Requisites

We only accept contributions that follows these requisites:

Support:

DP6 Koopa-troopa Team

e-mail: mailto:[email protected]

About

Crawler assistido para validação de objetos enviados à camada de dados (Data Layer)

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%