zevarito/mixpanel — pull request #45 by sturgill (2012-10-04 01:16:15+00:00)
Title: People Tracking

This gem has done well with pushing events from a backend server, but I wasn't sure how to use it to push changes to people (using the set and add methods).

Sample code to set an attribute:

```ruby
mixpanel = Mixpanel::Tracker.new TOKEN, env, {:action => :person}
mixpanel.update_person UNIQUE_IDENTIFIER, :set, {'$email' => 'me@domain.com'}
```

Sample code to use the increment function:

```ruby
mixpanel = Mixpanel::Tracker.new TOKEN, env, {:action => :person}
mixpanel.update_person UNIQUE_IDENTIFIER, :add, {'Points Earned' => 500}
```

The `update_person` method takes 3 parameters: the unique identifier, what action to take (either `:set` or `:add`) and a hash of values to pass to the server (consistent with the JS API).

In `Mixpanel::Tracker.new`, the options hash no longer has an `:import` key, but has an `:action` key (as shown above) that can be set to one of three options: `:track`, `:import`, and `:person`. The default value is `:track` unless otherwise set.