Skip to content
Analytics framework for iOS
Objective-C Other
Find file
Latest commit dffc6f5 Apr 15, 2016 @twobitlabs Merge pull request #43 from kdawgwilk/patch-1
Add AnalyticsKitTimedEventHelper which Crashlytics depends on
Failed to load latest commit information.
AnalyticsKit Added os_trace_error per #20 Jan 30, 2016
Categories Fixed compiler warnings due to format string types. Jan 30, 2016
Providers Fixed compiler warnings due to format string types. Jan 31, 2016
.gitignore added workspace and user files to .gitignore Mar 24, 2014
.travis.yml updated Xcode to 7.2, as Mixpanel build seems to fail on Xcode 6 Jan 22, 2016
AnalyticsKit.h Added project file and unit tests so the project can be built and ver… Mar 24, 2014
AnalyticsKit.m Added activity tracing for logEvent methods. Activity tracing does no… Mar 3, 2016
AnalyticsKit.podspec Add AnalyticsKitTimedEventHelper which Crashlytics depends on Apr 15, 2016
AnalyticsKitDebugProvider.h updated debug provider to use UIAlertController instead of UIAlertVie… Jan 29, 2016
AnalyticsKitDebugProvider.m updated debug provider to use UIAlertController instead of UIAlertVie… Jan 29, 2016
AnalyticsKitEvent.h Added project file and unit tests so the project can be built and ver… Mar 24, 2014
AnalyticsKitEvent.m Added project file and unit tests so the project can be built and ver… Mar 24, 2014
AnalyticsKitUnitTestProvider.h Added instance method on unit test provider to clear events Nov 14, 2012
AnalyticsKitUnitTestProvider.m Fix xcode 6.3 warning Apr 16, 2015
CONTRIBUTING.md template file for contributing Jun 12, 2014
LICENSE Update and rename MIT-LICENSE to LICENSE Oct 3, 2013
README.md Add example pointing Cocoapods to repo and Crashlytics subspec Apr 15, 2016

README.md

Build Status Gitter chat

AnalyticsKit

The goal of AnalyticsKit is to provide a consistent API for analytics regardless of the provider. With AnalyticsKit, you just call one logging method and AnalyticsKit relays that logging message to each registered provider. AnalyticsKit works in both Swift and Objective-C projects

Supported Providers

Unsupported Providers

The following providers are included but not supported. YMMV.

  • New Relic

    We've had a number of problems integrating the New Relic framework into the test app, so we can't verify that events are logged correctly.

If you would like to add support for a new provider or to update the code for an existing one, simply fork the master repo, make your changes, and submit a pull request.

How to Use

CocoaPods

***Please Note -- While we welcome contributions, Two Bit Labs does not officially support CocoaPods for AnalyticsKit. If you run into problems integrating AnalyticsKit using CocoaPods, please log a GitHub issue. Due to this we are not able to deploy the latest version, if you would like the latest version you can point the pod to this repo eg.

pod 'AnalyticsKit', :git => 'https://github.com/twobitlabs/AnalyticsKit.git'

If your project uses CocoaPods, you can simply include AnalyticsKit for full provider support, or you can specify your provider using CocoaPods subspecs.

  • AdjustIO - pod 'AnalyticsKit/AdjustIO'
  • Crashlytics - pod 'AnalyticsKit/Crashlytics'
  • Flurry - pod 'AnalyticsKit/Flurry'
  • Google Analytics - pod 'AnalyticsKit/GoogleAnalytics'
  • Localytics - pod 'AnalyticsKit/Localytics'
  • Mixpanel - pod 'AnalyticsKit/Mixpanel'
  • New Relic - pod 'AnalyticsKit/NewRelic'
  • TestFlight - pod 'AnalyticsKit/TestFlight'

***Please Note -- The Parse subspec has been removed, as it won't integrate correctly using CocoaPods.

Installation

  1. Download the provider's SDK and add it to your project, or install via cocoapods.
  2. Add AnalyticsKit to your project either as a git submodule or copying the source into your project. In Xcode, only include AnalyticsKit.h/.m and any providers you plan to use.
  3. In your AppDelegate's applicationDidFinishLaunchingWithOptions: method, create an array with your provider instance(s) and call initializeLoggers:.

Objective-C:

Initialize AnalyticsKit in applicationDidFinishLaunchingWithOptions

AnalyticsKitFlurryProvider *flurry = [[AnalyticsKitFlurryProvider alloc] initWithAPIKey:@"[YOUR KEY]"];
[AnalyticsKit initializeLoggers:@[flurry]];

To log an event, simply call the logEvent: method.

[AnalyticsKit logEvent:@"Log In" withProperties:infoDict];

Depending on which analytics providers you use you may need to include the following method calls in your app delegate (or just go ahead and include them to be safe):

[AnalyticsKit applicationWillEnterForeground]; 
[AnalyticsKit applicationDidEnterBackground];  
[AnalyticsKit applicationWillTerminate];  

Swift:

Import AnalyticsKit and any providers in your bridging header:

#import "AnalyticsKit.h"
#import "AnalyticsKitNewRelicProvider.h"

Initialize AnalyticsKit in application:didFinishLaunchingWithOptions:

let newRelic = AnalyticsKitNewRelicProvider(APIKey: "[YOUR KEY]")
AnalyticsKit.initializeLoggers([newRelic])

Depending on which analytics providers you use you may need to include the following method calls in your app delegate (or just go ahead and include them to be safe):

AnalyticsKit.applicationWillEnterForeground()
AnalyticsKit.applicationDidEnterBackground() 
AnalyticsKit.applicationWillTerminate]()

See AnalyticsKit.h for an exhaustive list of the logging methods available.

Apple Watch Analytics

AnalyticsKit now provides support for logging from your Apple Watch Extension.

Supported Providers

Installation

  1. If you haven't already done so, follow the installation steps above to add your provider's SDK and AnalyticsKit to your project.
  2. Adding Provider's API Key.

Objective-C:

Initialize AnalyticsKit in awakeWithContext

AnalyticsKitWatchExtensionFlurryProvider *flurry = [AnalyticsKitWatchExtensionFlurryProvider new];
[AnalyticsKit initializeLoggers:@[flurry]];

To log an event, simply call the logEvent: method.

[AnalyticsKit logEvent:@"Launching Watch App"];

Swift:

Import AnalyticsKit and any providers in your bridging header:

#import "AnalyticsKit.h"
#import "AnalyticsKitWatchExtensionFlurryProvider.h"

Initialize AnalyticsKit in awakeWithContext

let flurryLogger = AnalyticsKitWatchExtensionFlurryProvider()
AnalyticsKit.initializeLoggers([flurryLogger])

To log an event, simply call the logEvent method.

AnalyticsKit.logEvent("Launching Watch App");

Contributors

Something went wrong with that request. Please try again.