Objective-C component for the DeskMetrics analytics service
BSD-2-CLAUSE License
ObjectiveMetrics is a Objective-C implementation of the desktop application analytics service DeskMetrics. You link against ObjectiveMetrics and specify what events you want to track via an intuitive API, and we take care of having them delivered to DeskMetrics, so that they'll show up on your dashboard.
There's no known reason it wouldn't work on earlier iOS versions, but it has not been tested.
The preferred way of using ObjectiveMetrics is now CocoaPods. To start using ObjectiveMetrics, all you need is to add the following to your Podfile:
pod 'ObjectiveMetrics'
This works for both iOS and OS X. Now, you just need to take the following steps to use it:
#import <ObjectiveMetrics/ObjectiveMetics.h>
to your files that will beDMTracker
a startWithApplicationId:
message withapplicationDidFinishLaunching:
.DMTracker
a stop
message when your application isapplicationWillTerminate:
.If you'd like to set up ObjectiveMetrics WITHOUT using CocoaPods, you can attempt to follow the instructions in our non-cocoapods readme.
Be warned, instructions for setting it up without cocoapods are not as frequently updated or as well tested as the ones you see in this file.
To track any event, you need the following at the start of the file:
#import <ObjectiveMetrics/ObjectiveMetrics.h>
Or, under iOS (iPhone):
#import "DMTracker.h"
Then, anywhere you want to track an event, retrieve the DMTracker singleton instance using:
[DMTracker defaultTracker]
On this instance, you can call any number of tracking events. It is very
important that you call the startWithApplicationId:
method soon after your app
starts. This is because it initializes the session and prepares the DMTracker
for more tracking events:
[[DMTracker defaultInstance] startWithApplicationId:@"MY APP ID HERE"];
You should then call stop
when your application is shutting down, to track an
"app exiting" event and attempt to send the events to the server. If they can't
be sent, they'll be sent the next time the application starts.
Here are the different methods you can call: (See DMTracker.h for a list that's guaranteed updated)
DMTracker *tracker = [DMTracker defaultInstance];
[tracker trackEvent:@"Event"];
[tracker trackEvent:@"Event with properties"
withProperties:@{@"Name": @"Joe Smith"}];
[tracker trackLog:@"Time is now %@", [NSDate date]];
ObjectiveMetrics uses other open-source libraries, and is covered by a couple of licenses: