lib/mixpanel/event.rb in mixpanel-3.0.2 vs lib/mixpanel/event.rb in mixpanel-3.1.0
- old
+ new
@@ -4,10 +4,14 @@
IMPORT_URL = 'http://api.mixpanel.com/import/'
def track(event, properties={}, options={})
track_event event, properties, options, TRACK_URL
end
+
+ def tracking_pixel(event, properties={}, options={})
+ build_url event, properties, options.merge(:url => TRACK_URL, :img => true)
+ end
def import(event, properties={}, options={})
track_event event, properties, options, IMPORT_URL
end
@@ -17,13 +21,11 @@
protected
def track_event(event, properties, options, default_url)
options.reverse_merge! :url => default_url, :async => @async, :api_key => @api_key
- data = build_event event, track_properties(properties)
- url = "#{options[:url]}?data=#{encoded_data(data)}"
- url += "&api_key=#{options[:api_key]}" if options[:api_key].present?
+ url = build_url event, properties, options
parse_response request(url, options[:async])
end
def ip
(@env['HTTP_X_FORWARDED_FOR'] || @env['REMOTE_ADDR'] || '').split(',').last
@@ -36,6 +38,14 @@
end
def build_event(event, properties)
{ :event => event, :properties => properties_hash(properties, EVENT_PROPERTIES) }
end
-end
\ No newline at end of file
+
+ def build_url event, properties, options
+ data = build_event event, track_properties(properties)
+ url = "#{options[:url]}?data=#{encoded_data(data)}"
+ url << "&api_key=#{options[:api_key]}" if options[:api_key].present?
+ url << "&img=1" if options[:img]
+ url
+ end
+end