diff --git a/ARAnalytics.h b/ARAnalytics.h index 7f930be..27d6db0 100644 --- a/ARAnalytics.h +++ b/ARAnalytics.h @@ -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; diff --git a/ARAnalytics.m b/ARAnalytics.m index 218a62a..7b11915 100644 --- a/ARAnalytics.m +++ b/ARAnalytics.m @@ -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 diff --git a/ARAnalytics.podspec b/ARAnalytics.podspec index 00192bf..fb812e2 100644 --- a/ARAnalytics.podspec +++ b/ARAnalytics.podspec @@ -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" } @@ -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" diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fd8d6b..46ee645 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Providers/ARAnalyticsProviders.h b/Providers/ARAnalyticsProviders.h index ac1513a..827a390 100644 --- a/Providers/ARAnalyticsProviders.h +++ b/Providers/ARAnalyticsProviders.h @@ -75,6 +75,10 @@ #import "LeanplumProvider.h" #endif +#ifdef AR_APPBOY_EXISTS +#import "AppboyProvider.h" +#endif + #ifdef AR_PARSEANALYTICS_EXISTS #import "ParseAnalyticsProvider.h" #endif diff --git a/Providers/AppboyProvider.h b/Providers/AppboyProvider.h new file mode 100644 index 0000000..4eba410 --- /dev/null +++ b/Providers/AppboyProvider.h @@ -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 diff --git a/Providers/AppboyProvider.m b/Providers/AppboyProvider.m new file mode 100644 index 0000000..c274d8b --- /dev/null +++ b/Providers/AppboyProvider.m @@ -0,0 +1,53 @@ +#import "AppboyProvider.h" +#import "ARAnalyticsProviders.h" +#import + +@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 diff --git a/README.md b/README.md index 68e0fb2..335a63a 100644 --- a/README.md +++ b/README.md @@ -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`.