GitXplorerGitXplorer
m

motion_panel

public
0 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
8c3bed16768adecc02e01f8fd16b64c5aca276ed

Added the add method to people

ttombroomfield committed 10 years ago
Unverified
ba8ca91f4582f9c6a7c5a5ac8d43d35deadb0f61

Version bump

ttombroomfield committed 10 years ago
Unverified
b078dab3dea762e3979f807e0ec2bc20d2e09c4f

Added set_once to peoples

ttombroomfield committed 10 years ago
Unverified
05178b269648d6ec4fff04f0b89ee8f808f62501

Added configuration options

ttombroomfield committed 10 years ago
Unverified
d6f344eaea2984eff9e285ccfeedb6c504c3eaba

README update

ttombroomfield committed 10 years ago
Unverified
812470ec8afa11ed99dbe800f4bacbd78f2bd2f7

Added default attributes to calls

ttombroomfield committed 10 years ago

README

The README file for this repository.

MotionPanel

A native RubyMotion wrapper around the Mixpanel API.

For updates, find me here or follow me on twitter

##Installation MotionPanel requires the AFMotion library, please ensure it is installed correctly.

Gemfile

gem 'motion_panel'

Rakefile

require 'motion_panel'

then run bundle install and you should be good to go.

##Tracking an event Before you start tracking events, you must initialize it with your project token.

Mixpanel.shared_instance_with_token(YOUR_MIXPANEL_TOKEN)

From then on, you can simple access the client without the token:

Mixpanel.shared_instance

You can then use the shared instance to track events:

Mixpanel.shared_instance.track('Example event', attribute: 'Value', second_attribute: 'Second value')

The following attributes will be included by default for every call:

  • app_version
  • ios_version
  • orientation
  • resolution
  • retina?

Tracking people

Every user must have a distinct_id, this could be a database ID or an email address.

To track a user

Mixpanel.shared_instance.people.set(distinct_id, '$first_name' => 'Tom',
                                                 '$last_name' => 'Broomfield',
                                                 'occupation' => 'Developer')

Please be aware that the properties with the '$' prefix are special Mixpanel attributes. Refer to the Mixpanel documentation for more information.

You can also use the set_once method. This will work in the same way to the set method, except it will not overwrite existing property values. This is useful for properties like "First login date".

Mixpanel.shared_instance.people.set_once(distinct_id, 'First login' => '19/04/2015')

The add method will increment numerical values. A great example of this is tracking sign in count.

Mixpanel.shared_instance.people.add(distinct_id, 'Log in count' => 1)

##Config Configuration can be changed through the Mixpanel.config object.

Mixpanel.config.disable_on_simulator # Blocks all calls if device is a simulator. Default: false
Mixpanel.config.disable_in_development # Blocks all calls if app is in development environment. Default: false
Mixpanel.config.disable_in_test # Blocks all calls if app is in the test environment. Default: true

##TODO

  • Block on development and test environment configuration option.
  • Better exceptions.
  • Alternate interface for a better Ruby experience.

Feel free to shoot through a PR or open an issue.

Thankyou to the incredible people at Mixpanel and RubyMotion for the great services they provide to developers.