Skip to content

Commit

Permalink
Added Appboy support
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Herzog committed Jun 23, 2016
1 parent 33687a9 commit 5749ed3
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 3 deletions.
1 change: 1 addition & 0 deletions ARAnalytics.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
+ (void)setupMobileAppTrackerWithAdvertiserID:(NSString *)advertiserID conversionKey:(NSString *)conversionKey allowedEvents:(NSArray *)allowedEvents;
+ (void)setupLaunchKitWithAPIToken:(NSString *)token;
+ (void)setupLeanplumWithAppId:(NSString *)appId developmentKey:(NSString *)developmentKey productionKey:(NSString *)productionKey;
+ (void)setupAppboy;

/// Add a provider manually
+ (void)setupProvider:(ARAnalyticalProvider *)provider;
Expand Down
7 changes: 7 additions & 0 deletions ARAnalytics.m
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,13 @@ + (void)setupLeanplumWithAppId:(NSString *)appId developmentKey:(NSString *)deve
#endif
}

+ (void)setupAppboy {
#ifdef AR_APPBOY_EXISTS
AppboyProvider *provider = [[AppboyProvider alloc] initWithIdentifier:nil];
[self setupProvider:provider];
#endif
}

#pragma mark -
#pragma mark User Setup

Expand Down
3 changes: 2 additions & 1 deletion ARAnalytics.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Pod::Spec.new do |s|
launchkit = { :spec_name => "LaunchKit", :dependency => "LaunchKit" }
firebase = { :spec_name => "Firebase", :dependency => "Firebase/Core" }
leanplum = { :spec_name => "Leanplum", :dependency => "Leanplum-iOS-SDK"}
appboy = { :spec_name => "Appboy", :dependency => "Appboy-iOS-SDK"}

kissmetrics_mac = { :spec_name => "KISSmetricsOSX", :dependency => "KISSmetrics", :osx => true, :provider => "KISSmetrics" }
# countly_mac = { :spec_name => "CountlyOSX", :dependency => "Countly", :osx => true, :provider => "Countly" }
Expand All @@ -57,7 +58,7 @@ Pod::Spec.new do |s|
parseAnalytics_mac = { :spec_name => "ParseAnalyticsOSX", :dependency => "Parse", :osx => true, :provider => "ParseAnalytics", :has_extension => true }


all_analytics = [mixpanel, localytics, flurry, google, kissmetrics, crittercism, crashlytics, fabric, bugsnag, countly, helpshift, kissmetrics_mac, mixpanel_mac, tapstream, newRelic, amplitude, hockeyApp, hockeyAppLib, hockeyApp_mac, parseAnalytics, parseAnalytics_mac, heap, chartbeat, umeng, librato, segmentio, swrve, yandex, adjust, appsflyer, branch, snowplow, sentry, intercom, keen, adobe, installtracker, appsee, mobileapptracker, launchkit, firebase, leanplum]
all_analytics = [mixpanel, localytics, flurry, google, kissmetrics, crittercism, crashlytics, fabric, bugsnag, countly, helpshift, kissmetrics_mac, mixpanel_mac, tapstream, newRelic, amplitude, hockeyApp, hockeyAppLib, hockeyApp_mac, parseAnalytics, parseAnalytics_mac, heap, chartbeat, umeng, librato, segmentio, swrve, yandex, adjust, appsflyer, branch, snowplow, sentry, intercom, keen, adobe, installtracker, appsee, mobileapptracker, launchkit, firebase, leanplum, appboy]

# To make the pod spec API cleaner, subspecs are "iOS/KISSmetrics"

Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# ARAnalytics

## master
## Master

* changed return type of init methods to instancetype instead of id (@BenchR267)
* Added support for Appboy (@BenchR267)

## Version 3.10.1

Expand Down
4 changes: 4 additions & 0 deletions Providers/ARAnalyticsProviders.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
#import "LeanplumProvider.h"
#endif

#ifdef AR_APPBOY_EXISTS
#import "AppboyProvider.h"
#endif

#ifdef AR_PARSEANALYTICS_EXISTS
#import "ParseAnalyticsProvider.h"
#endif
Expand Down
11 changes: 11 additions & 0 deletions Providers/AppboyProvider.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#import "ARAnalyticalProvider.h"

/**
* Use this provider to track events to Appboy.
*
* NOTE: You still need to setup Appboy in your AppDelegate (needs application and launchOptions)!
* Use [Appboy startWithApiKey:@"YOUR-API-KEY" inApplication:application withLaunchOptions:launchOptions]; for this.
*/
@interface AppboyProvider : ARAnalyticalProvider

@end
53 changes: 53 additions & 0 deletions Providers/AppboyProvider.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#import "AppboyProvider.h"
#import "ARAnalyticsProviders.h"
#import <Appboy-iOS-SDK/AppboyKit.h>

@implementation AppboyProvider
#ifdef AR_APPBOY_EXISTS

- (void)identifyUserWithID:(NSString *)userID andEmailAddress:(NSString *)email {
NSAssert([Appboy sharedInstance], @"You need to call [Appboy startWithApiKey:inApplication:withLaunchOptions:] before setting the user id!");
[[Appboy sharedInstance] changeUser:userID];
}

- (void)setUserProperty:(NSString *)property toValue:(id)value {

NSAssert([Appboy sharedInstance], @"You need to call [Appboy startWithApiKey:inApplication:withLaunchOptions:] before setting user properties!");

if ([value isKindOfClass:[NSString class]]) {
[[Appboy sharedInstance].user setCustomAttributeWithKey:property andStringValue:value];
}
else if ([value isKindOfClass:[NSNumber class]]) {
[[Appboy sharedInstance].user setCustomAttributeWithKey:property andDoubleValue:[value doubleValue]];
}
else if ([value isKindOfClass:[NSDate class]]) {
[[Appboy sharedInstance].user setCustomAttributeWithKey:property andDateValue:value];
}
else {
NSLog(@"Appboy is not able to track user properties that are not strings, numbers or dates.");
}
}

- (void)event:(NSString *)event withProperties:(NSDictionary *)properties {
NSAssert([Appboy sharedInstance], @"You need to call [Appboy startWithApiKey:inApplication:withLaunchOptions:] before setting user properties!");
[[Appboy sharedInstance] logCustomEvent:event withProperties:properties];
}

- (void)didShowNewPageView:(NSString *)pageTitle {
[self didShowNewPageView:pageTitle withProperties:nil];
}

- (void)didShowNewPageView:(NSString *)pageTitle withProperties:(NSDictionary *)properties {

// Appboy does not use pageViews, so a pageView is just another custom event
[self event:pageTitle withProperties:properties];
}

- (void)incrementUserProperty:(NSString *)counterName byInt:(NSNumber *)amount {

[[Appboy sharedInstance].user incrementCustomUserAttribute:counterName by:amount.integerValue];
}

#endif

@end
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ Note, however, that on iOS `syslogd` will not keep logs around for a long time,
Full list of subspecs
----

iOS: `Mixpanel`, `Localytics`, `Flurry`, `GoogleAnalytics`, `Firebase`, `KISSmetrics`, `Crittercism`, `Countly`, `Bugsnag`, `Helpshift`, `Tapstream`, `NewRelic`, `Amplitude`, `HockeyApp`, `HockeyAppLib`, `ParseAnalytics`, `HeapAnalytics`, `Chartbeat`, `UMengAnalytics`, `Segmentio`, `Swrve`, `YandexMobileMetrica`, `Adjust`, `Intercom`, `Librato`, `Crashlytics`, `Fabric`, `AppsFlyer`, `Branch`, `Snowplow`, `Sentry`, `Keen`, `Adobe`, `MobileAppTracker` & `Leanplum`.
iOS: `Mixpanel`, `Localytics`, `Flurry`, `GoogleAnalytics`, `Firebase`, `KISSmetrics`, `Crittercism`, `Countly`, `Bugsnag`, `Helpshift`, `Tapstream`, `NewRelic`, `Amplitude`, `HockeyApp`, `HockeyAppLib`, `ParseAnalytics`, `HeapAnalytics`, `Chartbeat`, `UMengAnalytics`, `Segmentio`, `Swrve`, `YandexMobileMetrica`, `Adjust`, `Intercom`, `Librato`, `Crashlytics`, `Fabric`, `AppsFlyer`, `Branch`, `Snowplow`, `Sentry`, `Keen`, `Adobe`, `MobileAppTracker`, `Leanplum` & `Appboy`.

OSX: `KISSmetricsOSX`, `HockeyAppOSX`, `MixpanelOSX` & `ParseAnalyticsOSX`.

Expand Down

0 comments on commit 5749ed3

Please sign in to comment.