lib/mixpanel/person.rb in mixpanel-3.5.1 vs lib/mixpanel/person.rb in mixpanel-3.5.2
- old
+ new
@@ -5,10 +5,14 @@
def set(distinct_id, properties={}, options={})
engage :set, distinct_id, properties, options
end
+ def unset(distinct_id, property, options={})
+ engage :unset, distinct_id, property, options
+ end
+
def increment(distinct_id, properties={}, options={})
engage :add, distinct_id, properties, options
end
def track_charge(distinct_id, amount, time=Time.now, options={})
@@ -51,11 +55,16 @@
default = {:async => @async, :url => PERSON_URL}
options = default.merge(options)
request_properties = person_request_properties(request_properties_or_distinct_id)
- data = build_person action, request_properties, properties
+ if action == :unset
+ data = build_person_unset request_properties, properties
+ else
+ data = build_person action, request_properties, properties
+ end
+
url = "#{options[:url]}?data=#{encoded_data(data)}"
parse_response request(url, options[:async])
end
def person_request_properties(request_properties_or_distinct_id)
@@ -67,7 +76,11 @@
end
end
def build_person(action, request_properties, person_properties)
properties_hash(request_properties, PERSON_REQUEST_PROPERTIES).merge({ "$#{action}".to_sym => properties_hash(person_properties, PERSON_PROPERTIES) })
+ end
+
+ def build_person_unset(request_properties, property)
+ properties_hash(request_properties, PERSON_REQUEST_PROPERTIES).merge({ "$unset".to_sym => [property] })
end
end