Avo Inspector Node.js SDK

2 minute read

Quick Start Guide

Find the Quick Start Guide in our GitHub repo.

Installation

The library is distributed with NPM, install with npm:

Terminal
Copy
$
npm i node-avo-inspector

or yarn:

Terminal
Copy
$
yarn add node-avo-inspector

Import

TypeScript
Copy
1
import * as Inspector from "node-avo-inspector";

Initialization

Obtain the API key in Inspector tab in your Avo.app workspace.

You will need to create an instance of AvoInspector with the constructor:

TypeScript
Copy
1
2
3
4
5
6
constructor(options: {
apiKey: string;
env: AvoInspectorEnv;
version: string;
appName?: string;
});

All the following methods are available in the AvoInspector class.

Parameters:

  • apiKey - the API key you get in your Avo account
  • env - current environment: "dev", "staging" or "prod"
  • appVersion - your application version. A lot of Inspector features rely on versioning and you need to provide a comparable string here to get value from them. We recommend using semantic versioning or integers that are incremented in every release.
  • appName - your application name. Optional; Provide it to make it easier to distinguish between data from different apps.

Sending event schemas to Avo Inspector

This is the core of the Avo Inspector SDK.

TypeScript
Copy
1
2
3
trackSchemaFromEvent(eventName: string, eventProperties: {
[propName: string]: any;
}): void;

Parameters:

  • eventName - string event name, also known as event type.
  • eventProperties - The actual event properties, which will be converted to an event schema on the device and the event schema sent to Avo. The resulting keys will be object field names and the values will be object field value types converted to schema types.
Example format:
JavaScript
Copy
1
2
3
4
5
var eventProperties = {
userId: 1337,
emailAddress: 'jane.doe@avo.app',
key: 'value',
};

Configuring Logs

enableLogging controls printing of tracked event schemas and other helpful information to logcat. Enabled by default in development environments.

JavaScript
Copy
1
enableLogging(enable: boolean): void;

Parameters:

  • enable - boolean flag that sets whether Avo Inspector SDK will print logs .