Avo Inspector Flutter and Dart SDK
Quick Start Guide
Find the Quick Start Guide in our GitHub repo.
Installation
With Flutter:
flutter pub add avo_inspector
This will add a line like this to your package’s pubspec.yaml (and run an implicit flutter pub get):
dependencies:
avo_inspector: ^0.9.9
Import
Now in your Dart code, you can use:
import 'package:avo_inspector/avo_inspector.dart';
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:
AvoInspector avoInspector = await AvoInspector.create(
apiKey: "my_key",
env: AvoInspectorEnv.dev,
appVersion: "1.0",
appName: "Hello Flutter");
Parameters:
apiKey
- the API key you get in Inspector Setup Guide in your Avo Workspaceenv
- current environment:AvoInspectorEnv.dev
,AvoInspectorEnv.staging
orAvoInspectorEnv.prod
appVersion
- your application version. Some 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 method gets the actual tracking event parameters, extracts the schema automatically and sends it to Avo Inspector backend. Just call this method at the same place you call your analytics tools’ track methods with the same parameters.
avoInspector.trackSchemaFromEvent(
eventName: "Event name",
eventProperties: {
"String Prop": "Prop Value",
"Float Prop": 1.0,
"Boolean Prop": true});
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 will be sent to Avo. The resulting keys will be object field names and the values will be object field value types converted to schema types.
Configuring Logs
Logs are enabled by default in the dev mode and disabled in prod and staging modes.
AvoInspector.shouldLog = true;
Parameters:
shouldLog
- boolean flag that sets whether Avo Inspector SDK will print logs
Batching control
In order to ensure our SDK doesn’t have a large impact on performance or battery life it supports event schemas batching.
Default batch size is 30 and default batch flush timeout is 30 seconds. In development mode batching is disabled.
AvoBatcher.batchSizeThreshold = 10;
AvoBatcher.batchFlushSecondsThreshold = 10;