GithubHelp home page GithubHelp logo

leocb / penguin-datalayer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dp6/penguin-datalayer

0.0 0.0 0.0 415 KB

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

Home Page: https://dp6.github.io/penguin-datalayer

JavaScript 100.00%

penguin-datalayer's Introduction

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]

penguin-datalayer's People

Contributors

vandersonmaroni avatar gabriel-tellaroli avatar ghusta-fernandes avatar danstos avatar joaquimsn 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.