Skip to content

avohq/ios-avo-inspector

Repository files navigation

AvoInspector

Version License Platform

Avo documentation

This is a quick start guide. For more information about the Inspector project please read the Avo documentation.

Installation

Swift Package Manager

You can include Inspector with SPM from this repo

Cocoapods

AvoInspector is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'AvoInspector'

The latest version can be found in GitHub releases tab.

Import

Obj-C

#import <AvoInspector/AvoInspector.h>

Swift

import AvoInspector

Initialization

Obtain the API key at Avo.app

Obj-C

AvoInspector *avoInspector = [[AvoInspector alloc] initWithApiKey:@"apiKey" env: AvoInspectorEnvDev];

Swift

let avoInspector = AvoInspector(apiKey: "apiKey", env: AvoInspectorEnv.dev)

Enabling logs

Logs are enabled by default in the dev mode and disabled in prod mode based on the init flag.

Obj-C

[AvoInspector setLogging:YES];

Swift

AvoInspector.setLogging(true)

Integrating with Avo Codegen

The setup is lightweight and is covered in this guide.

Every event sent with Avo Function after this integration will automatically be sent to Inspector.

Sending event schemas for events reported outside of Codegen

Whenever you send tracking event call one of the following methods:

Read more in the Avo documentation

1.

This methods get actual tracking event parameters, extract schema automatically and send it to Inspector backend. It is the easiest way to use the library, just call this method at the same place you call your analytics tools' track methods with the same parameters.

Obj-C

[avoInspector trackSchemaFromEvent:@"Event Name" eventParams:@{@"id": @"sdf-334fsg-334f", @"number": @41}];

Swift

avoInspector.trackSchema(fromEvent: "Event Name", eventParams: ["id": "sdf-334fsg-334f", "number": 41])

2.

If you prefer to extract data schema manually you would use this method.

Obj-C

[avoInspector trackSchema:@"Event Name" eventSchema:@{@"id": [[AvoString alloc] init], @"number": [[AvoInt alloc] init]}];

Swift

avoInspector.trackSchema("Event Name", eventSchema: ["id": AvoString(), "number": AvoInt()])

Extracting event schema manually

Obj-C

NSDictionary * schema = [avoInspector extractSchema:@{@"id": @"sdf-334fsg-334f", @"number": @41}];

Swift

let schema = avoInspector.extractSchema(["id": "sdf-334fsg-334f", "number": 41])

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 debug mode default batch flush timeout is 1 second, i.e. the SDK batches schemas of events sent withing one second.

Obj-C

[AvoInspector setBatchSize:15];
[AvoInspector setBatchFlushSeconds:10];

Swift

AvoInspector.setBatchSize(15)
AvoInspector.setBatchFlushSeconds(10)

Example App

To run the example project, clone the repo, and run pod install from the Example directory first.

Author

Avo (https://www.avo.app), friends@avo.app

License

AvoInspector is available under the MIT license. See the LICENSE file for more info.