CocoaPods trunk is moving to be read-only. Read more on the blog, there are 9 months to go.
| TestsTested | ✗ |
| LangLanguage | Obj-CObjective C |
| License | MIT |
| ReleasedLast Release | Dec 2014 |
Maintained by Sean McGary.
An iOS client for harvestd analytics collector
Add it to your Podfile
pod 'Harvest', '0.1.0'
Then run
pod install
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);
}];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"
}];
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"];