Avo Inspector Go SDK
Quick Start Guide
Find the Quick Start Guide in our GitHub repo (opens in a new tab).
Installation
Our library is distributed as a Go module:
go get github.com/avohq/go-avo-inspector
Use the latest GitHub release tag to get the latest version of the library.
Import
import (
avoinspector "github.com/avohq/go-avo-inspector"
)
Initialization
Obtain the API key by opening your Avo.app workspace settings (opens in a new tab), selecting the source you want to add and then click the Inspector Setup tab.
You will need to create an instance of AvoInspector
.
func NewAvoInspector(
apiKey string,
env AvoInspectorEnv,
appVersion string,
appName string
) (*AvoInspector, error)
Parameters:
apiKey string
- the API key you get in Inspector tab of your Avo workspaceenv AvoInspectorEnv
- current environment: AvoInspectorEnv.Dev, AvoInspectorEnv.Staging or AvoInspectorEnv.ProdappVersion string
- app version to attribute the events toappName string
- application name
Sending event schemas to Avo Inspector
This is the core of the Avo Inspector SDK.
Call the following method every time an event is tracked, so Inspector can analyze the event's schema and spot problems.
Option 1
func (inspector *AvoInspector) TrackSchemaFromEvent(
eventName string,
eventProperties map[string]interface{}
) ([]Property, error)
Example usage:
func trackEvent(eventName string, eventParams map[string]interface{}) { tracker.Track(eventName, eventParams) avoInspector.TrackSchemaFromEvent(eventName, eventParams) }
Extracts event schema from event properties represented by the second parameter map[string]interface{}
and sends the schema to Avo for analysis.
Parameters:
eventName string
- event name, sometimes referred as event type.eventProperties map[string]interface{}
- actual event properties, which will be converted to event schema on the device and the event schema will be sent to Avo. Resulting keys will be JSON fields keys and resulting values will be JSON fields values types converted to schema types.Example format:
map[string]interface{}{
"greeting": "hello",
"answer": 42,
}
Return Type:
[]avoinspector.Property
containing event schema, so you can verify that conversion was correct. Example format:
[]Property{
{
PropertyName: "greeting",
PropertyType: "string",
Children: nil,
},
{
PropertyName: "answer",
PropertyType: "int",
Children: nil,
}
}
See this for details about event schema structure and schema types.
Other methods
1. Print logs
func (c *AvoInspector) ShouldLog(shouldLog bool)
shouldLog
controls printing of tracked event schemas and other helpful information to logcat. Enabled by default in development environments.
Parameters:
shouldLog bool
- sets whether Avo Inspector SDK will print logs to console.