Avo Inspector overview

3 minute read

Avo Inspector SDK

Avo Inspector SDK extracts tracking plan information from your existing tracking calls. It provides methods to get the shape of an event you are going to send to the analytics platform and then to send that shape alongside the event name for analysis. The SDKs are distributed with the standard mechanism of the platform, like npm package, gradle dependency or a cocoapod.

Avo Inspector initialization

Before using the Avo Inspector SDK you need to obtain an API key from the Avo dashboard in the

and provide it to the initialization method.

Swift
Copy
1
let avoInspector = AvoInspector(apiKey: "YOUR_API_KEY", env: AvoInspectorEnv.dev)

Inspecting events

You need to call a method whenever event is tracked, either trackSchemaFromEvent(eventName: String, eventParams: Map) or trackSchema(eventName: String, eventSchema: Map)

The difference is that in the first method the event object is transformed into an event schema under the hood and in the second method you provide the event schema. Eventually in both methods the event schema is sent to Avo servers for analysis.

The event schema format is a map, similar to the format most events use, but with type names instead of actual values. For example if you track CheckoutCompleted event

json
Copy
1
2
3
4
5
6
7
8
{
"userId": 1337,
"emailAddress": "jane.doe@avo.app",
"productId": 45,
"revenue": 15.99,
"timestamp": 1579263014,
"deviceId": "sdf-23-trr-456-0000"
}

The following event schema would be sent to Avo:

json
Copy
1
2
3
4
5
6
7
8
{
"userId": "int",
"emailAddress": "string",
"productId": "int",
"revenue": "float",
"timestamp": "int",
"deviceId": "string"
}

Note: You can extract the schema separately with extractSchema(eventParams: Map), the same method that's used by trackSchemaFromEvent(eventName: String, eventParams: Map)

Example

Swift
Copy
1
2
3
4
func trackAppOpened(appOpenedEvent: Dictionary<String, Any>) {
tracker.track(eventName: "App Opened", eventParams: appOpenedEvent);
SceneDelegate.avoInspector?.trackSchema(fromEvent: "App Opened", eventParams: appOpenedEvent)
}

Supported event schema types in Avo Inspector

null int float boolean string combination of types, e.g. an optional integer would look like integer | null. If we've seen a mix of integers, strings and nulls it will be integer | string | null. List can be a part of combination. parametrized list, i. e. list<integer | null> nested objects

Bonus: this docs you are reading are open sourced, if you find anything wrong or missing, please open a pull request or an issue!

Batching

In order to ensure our SDK doesn't have a large impact on performance or battery life it supports event schemas batching. In production, default values are 30 schemas per batch and smaller batches are sent if more than 30 seconds pass between uploads. In development batching is disabled by default. You can change the values using AvoInspector.setBatchSize(newBatchSize: Int) and AvoInspector.setBatchFlushSeconds(newBatchFlushSeconds: Int) class methods to fine tune the library performance.

Implement the Inspector SDK

Now when you know how the Inspector SDK works it's good time to implement it in your application. Here is

.