Permalink
Browse files

adding region and city to special person properties. adding set_once …

…to person
  • Loading branch information...
1 parent ebcd56c commit b25e378b1dfcb1f9d433f7b1fe1283664f3dafc3 @michaelglass michaelglass committed Apr 17, 2013
Showing with 21 additions and 5 deletions.
  1. +2 −0 CHANGELOG.md
  2. +15 −5 lib/mixpanel/person.rb
  3. +4 −0 spec/mixpanel/tracker_spec.rb
View
@@ -2,6 +2,8 @@ April 2013
----------
* Delete a user from mixpanel (dennisvdvliet)
+* Ability to set_once properties (Michael Glass)
+* Use mixpanel script version 2.2. Replaced person.identify with unified identify. Added person.alias. (Milo Winningham)
Bump: 3.5.2 Feb 24, 2013
@@ -1,5 +1,7 @@
module Mixpanel::Person
- PERSON_PROPERTIES = %w{email created first_name last_name name last_login username country_code}
+ #from https://mixpanel.com/docs/people-analytics/special-properties
+ PERSON_PROPERTIES = %w{email created first_name last_name name last_login username country_code region city}
+ #from https://mixpanel.com/docs/people-analytics/people-http-specification-insert-data
PERSON_REQUEST_PROPERTIES = %w{token distinct_id ip ignore_time}
PERSON_URL = 'http://api.mixpanel.com/engage/'
@@ -11,6 +13,10 @@ def unset(distinct_id, property, options={})
engage :unset, distinct_id, property, options
end
+ def set_once(distinct_id, properties={}, options={})
+ engage :set_once, distinct_id, properties, options
+ end
+
def increment(distinct_id, properties={}, options={})
engage :add, distinct_id, properties, options
end
@@ -25,6 +31,10 @@ def track_charge(distinct_id, amount, time=Time.now, options={})
engage :append, distinct_id, charge_properties, options
end
+ def delete(distinct_id)
+ engage 'delete', distinct_id, {}, {}
+ end
+
def reset_charges(distinct_id, options={})
engage :set, distinct_id, { '$transactions' => [] }, options
end
@@ -33,6 +43,10 @@ def append_set(properties={})
append 'people.set', properties_hash(properties, PERSON_PROPERTIES)
end
+ def append_set_once(properties = {})
+ append 'people.set_once', properties_hash(properties, PERSON_PROPERTIES)
+ end
+
def append_increment(property, increment=1)
append 'people.increment', property, increment
end
@@ -53,10 +67,6 @@ def append_alias(aliased_id)
append 'alias', aliased_id
end
- def delete(distinct_id)
- engage 'delete', distinct_id, {}, {}
- end
-
protected
def engage(action, request_properties_or_distinct_id, properties, options)
@@ -56,6 +56,10 @@
@mixpanel.set('person-a', { :email => 'me@domain.com', :likeable => false }).should == true
end
+ it "should set an attribute once" do
+ @mixpanel.set_once('person-a', { :email => 'me@domain.com', :likeable => false }).should == true
+ end
+
it "should set attributes with request properties" do
@mixpanel.set({ :distinct_id => 'person-a', :ignore_time => true }, { :email => 'me@domain.com', :likeable => false }).should == true
end

0 comments on commit b25e378

Please sign in to comment.