Skip to content

acoomans/Spyglass

Repository files navigation

#Spyglass

Spyglass is an events tracking analytics library for iOS.

Usage

Get Spyglass code:

git clone git@github.com:acoomans/Spyglass.git

Then drag and drop the Spyglass directory in your project.

To get the dependencies, get the submodules:

cd Spyglass
git submodule update --init --recursive

Then drag and drop the Base64/Base64 and OpenUDID directories in your project.

Note: Disable ARC for OpenUDID.m ( -fno-objc-arc ).

Tracking

First, setup Spyglass server url:

[ACSpyglass sharedInstance].serverURL = [NSURL URLWithString:@"http://www.example.com/api/1"];

Optionaly, you can track the user:

[ACSpyglass sharedInstance].userIdentifier = @"black beard";

Start track events with:

[[ACSpyglass sharedInstance] track:@"Attack!" properties:@{
    @"roll" : [NSNumber numberWithInt:arc4random() % 74]
 }];

Events

Events have the following format:

  • deviceIdentifier: a string, defaults to openUUID
  • userIdentifier: a string identifying the user, to be set manually
  • timestamp: an integer, number of seconds since epoch
  • event: a string, name of the event to track
  • properties: a dictionary, containing any extra parameters needed

Events are sent by batch regularly (10 seconds by default). Events are sent as JSON encoded in base64. Example:

[
    {   'deviceIdentifier': 'bd95a47b733e4e06dae8c55c7adb055b3e207e2b',
        'event': 'Attack!',
        'properties': {   'roll': 28},
        'time': 1363203126,
        'userIdentifier': 'black beard'},
    {   'deviceIdentifier': 'bd95a47b733e4e06dae8c55c7adb055b3e207e2b',
        'event': 'Attack!',
        'properties': {   'roll': 67},
        'time': 1363203129,
        'userIdentifier': 'black beard'},
    {   'deviceIdentifier': 'bd95a47b733e4e06dae8c55c7adb055b3e207e2b',
        'event': 'Attack!',
        'properties': {   'roll': 58},
        'time': 1363203132,
        'userIdentifier': 'black beard'}
]

The server should return a json with result and code:

{
	'result': "ok",
	'code': 0
}

If the code is not 0, the events are considered as not recorded and will be kept in Spyglass queue and sent again in the next batch.

The server should check for duplicates before recording any event.

Documentation

install appledoc:

brew install appledoc

build the Documentation target,

the documentation will be automatically added to Xcode.

Testing

Run the server:

cd server
pip install -r requirements.txt
python server.py

Then run the SpyglassDemo target from Xcode

About

Events tracking analytics for iOS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published