Skip to content

Instantly share code, notes, and snippets.

@jaybaird
Created February 5, 2013 01:45
Show Gist options
  • Save jaybaird/4711433 to your computer and use it in GitHub Desktop.
Save jaybaird/4711433 to your computer and use it in GitHub Desktop.
Sensible analytics functions using LLVM's overloadable
NSString * eventForCategoryAction(NSString *category, NSString *action) {
return [NSString stringWithFormat:@"%@:%@", (category) ? category : @"default", action]
}
void __attribute__((overloadable)) TrackEvent(NSString *category, NSString *action, NSDictionary *infoDict) {
[Flurry trackEvent:eventForCategory(category, action) withParameters:infoDict];
}
void __attribute__((overloadable)) TrackEvent(NSString *category, NSString *action) {
TrackEvent(category, action, nil);
}
void __attribute__((overloadable)) TrackEvent(NSString *action) {
TrackEvent(nil, action, nil);
}
void __attribute__((overloadable)) TrackTimedEvent(NSString *category, NSString *action, NSDictionary *infoDict) {
[Flurry trackEvent:eventForCategoryAction(category, action) withParameters:infoDict timed:YES];
}
void __attribute__((overloadable)) TrackTimedEvent(NSString *category, NSString *action) {
TrackTimedEvent(category, action, nil);
}
void __attribute__((overloadable)) TrackTimedEvent(NSString *action) {
TrackTimedEvent(nil, action, nil);
}
void __attribute__((overloadable)) StopTimedEvent(NSString *category, NSString *action, NSDictionary *infoDict) {
[Flurry endTimedEvent:eventForCategoryAction(category, action) withParameters:infoDict];
}
void __attribute__((overloadable)) StopTimedEvent(NSString *category, NSString *action) {
StopTimedEvent(category, action, nil);
}
void __attribute__((overloadable)) StopTimedEvent(NSString *action) {
StopTimedEvent(nil, action, nil);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment