Data validation

3 minute read

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:

Console
Copy
1
[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

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

Inspector

The Avo Inspector analyzes your current state of tracking and guides the way from your current messy taxonomy to more consistent and reliable tracking across teams, products, and platforms.

Start monitoring the health of your tracking today with Inspector.

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