Avo
  • About
  • Plans
  • Docs
  • Blog
  • Jobs
  • Login
  • Get started
  • About
  • Plans
  • Docs
  • Blog
  • Jobs
  • Login
  • Get started

Data Validation

Table of Contents

How Avo validates data

The validation goes through Avo's generated tracking libraries. Avo generates a function per event that validates the sturcture of the event and it's properties.

Constraints can be added to properties to validate against:

  • string properies: a finite list of allowed string values
  • int and float properties: a minimum and/ maximum value
  • object properties: exact structure of the allowed keys and types of values in the object

The validation feedback provided by Avo differs by the type of programming language and development platform used. The feedback can be in form of a web or mobile debugger, console logs or complie errors. Validation logs and warnings are by default only sent in the development environment, not in production. Strict mode validation can be enabled in development, which throws errors instead of logging them.

Dynamically typed languages

For dynamically typed languages, the generated code runs validation when the function gets called, and logs warnings or errors if the data doesn't match the correct structure.

Example for Node JS: When an event is sent from a NodeJS server in development a message like this will be logged out via console.log:

[avo] Event Sent: <event name>, Event Props: <event properties>, User Props: <userProperties>

In addition to this, Avo will log out details on any failed validations. By default these messages will be logged out with console.error, but that can be configured via the reportFailureAs key in the options object passed into initAvo and/or validateAvoEvent, reportFailureAs can be set to 'error', 'warn' or 'log'.

Statically typed languages

For statically typed languages, much of the validation happens on compile time, while value limitations which cannot be expressed through type systems, yield runtime logs or warnings

Web and Mobile debuggers

Complete mobile debuggers docs

When developing on a front end application it can be useful to see the event stream while navigating through the product. Avo provides debuggers for the following platforms - some of them are currently in beta, get in touch if you'd like access:

The debugger displays the events triggered in chronological order with the properties that are sent with the events. If there are any errors in the a event or it's properties, the debugger marks the event red and displays the issue. Potential issues include:

  • Unexpected event or property name
  • Property of a wrong type
  • Property does not match defined constraints
Web debugger exampleWeb debugger example

Accessing the web debugger

The debuggers are on by default in development but can be accessed in production:

  • Web: add the avo_debug=1 query parameter to the URL

Data health dashboard

The data health dashboard currently provides an overview of the health of your data in development the last 24 hours. Data health for a longer period and for propduction data is coming soon!

The "Errors" tab in the data health dashboard provides an overview over validation errors from all sources. The top error is the most frequent one from the last 24h, the second one is the second most frequent one and so on. Each error can be expanded to display the specific validation error that occured in each invocation of the event.

In the example below the "Signup Start" event was sent with an invalid value for the Platform property once. Then the error was fixed and all following invocations were valid. However, 100% of the "Signup Complete" invocations errored because of an invalid value of the "Authentication Method" property.

Web debugger example

Generating the custom tracking libraries

  • To get the code generated libraries you use the Avo CLI or copy the file from the Implement tab in the Avo UI
  • The libraries are constructed based on the event definitions in the web app,¬†that support the PM / analytics manager in defining consistent data structures.
  • Each development platform and programming language generate its own tracking library
    • For example iOS:Swift, iOS:Objective-C, Android:Kotlin, Web:React, etc.
  • The code generated libraries contain a function per each event, and the function performs data validation based on the event structure definition.
    • For example: A "Cart Updated" event with an "Item Count" property, would generate a function with the following signature in Swift:
      • cartUpdated(itemCount: Int)

To get started see our quickstart page.

How Avo validates data

Validating without code changes

For applications that already have tracking in place, Avo supports validation by providing a validateAvoEvent function. The function uses the custom generated tracking libraries to validate the existing event calls.

Follow these steps to get started:

  • Step 1: Enable the validateAvoEvent function in your desired source
    1. Go to the Connections tab in Avo
    2. Select the source you want to use the function in
    3. Turn on "Event validation function"
  • Step 2: Generate an Avo.js file with the validateAvoEvent function enabled.
  • Step 3: Import Avo where your analytics calls are passed through:
    const Avo = require('./Avo');
  • Step 4: Call Avo.validateAvoEvent with name of event and the event properties:
    if (ENVIRONMENT == 'dev') {
    // The validateAvoEvent should only be called in development
    Avo.validateAvoEvent({eventName, eventProperties, env: ENVIRONMENT});
    }

Now all your analytics calls will be validated against the tracking plan defined in your Avo workspace and will feed the Avo health dashboard with reports about unexpected/invalid events and properties.

Get in touch if you want to learn more about Avo's data validation.