Latest 0.1.1
Homepage https://github.com/seanmcgary/harvestd-ios
License MIT
Platforms ios 6.0, requires ARC
Dependencies AFNetworking
Authors

harvest-ios

An iOS client for harvestd analytics collector

Install

Add it to your Podfile

pod 'Harvest', '0.1.0'

Then run

pod install

Implementation

The best place to initialize everything is probably in your app delegate. Harvest is a singleton and can thus be called from anywhere you include the header.

#import <Harvest/Harvest.h>

+ (void)initialize
{

    [Harvest setApiToken:@"<some unique token>" andHostname:@"http://harvested.server.com"];    

}

Often times there might be some properties that you want included on every event. You can do this by passing an NSDictionary to the includeData function:

NSDictionary *includeData = @{
                                @"source": @"my cool ios app",
                             };
[Harvest includeData: includeData];

If you have potentially variable data you’d like to set before each track event is fired, you can register a block/callback by calling setPretrackBlock.

[Harvest setPretrackHandler:^void (NSString * eventName, NSDictionary *data, void(^cb)(NSString *, NSDictionary *)){
    // do some stuff then call back
    cb(eventName, data);
}];

Tracking events

To track an event, you’ll an event name and any attributes you want recorded with the event.


[Harvest trackEvent:@"my cool event" withData:@{
    @"yo": "dawg"
}];

Identifying users

You can also identify a user by calling the identify function. This should be called when a user goes from an anonymous to known state. The identifier passed should be something unique – an email or unique id generated by your DB would be good choices.

[Harvest identifyUser:@"1234"];

Latest podspec

{
    "name": "Harvest",
    "version": "0.1.1",
    "summary": "Client library for the Harvestd analytics collector",
    "homepage": "https://github.com/seanmcgary/harvestd-ios",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Sean McGary": "[email protected]"
    },
    "source": {
        "git": "https://github.com/seanmcgary/harvestd-ios.git",
        "tag": "0.1.1"
    },
    "source_files": "Harvest",
    "exclude_files": "Classes/Exclude",
    "platforms": {
        "ios": "6.0"
    },
    "requires_arc": true,
    "dependencies": {
        "AFNetworking": [
            "2.3.1"
        ]
    }
}

Pin It on Pinterest

Share This