lib/mixpanel/event.rb in mixpanel-4.0.6 vs lib/mixpanel/event.rb in mixpanel-4.0.7

- old
+ new

@@ -34,12 +34,12 @@ protected def track_event(event, properties, options, default_url) default = {:url => default_url, :async => @async, :api_key => @api_key} options = default.merge(options) - url = build_url(event, properties, options) - parse_response request(url, options[:async]) + data = build_data(event, properties, options) + parse_response post_request(options[:url], data, options[:async]) end def track_properties(properties, include_token=true) default = {:time => Time.now, :ip => ip} properties = default.merge(properties) @@ -48,9 +48,19 @@ properties_hash(properties, EVENT_PROPERTIES) end def build_event(event, properties) { :event => event, :properties => properties_hash(properties, EVENT_PROPERTIES) } + end + + def build_data event, properties, options + params = {} + data = build_event event, track_properties(properties) + params[:data] = encoded_data(data) + params[:api_key] = options[:api_key] if options.fetch(:api_key, nil) + params[:img] = 1 if options[:img] + params[:test] = 1 if options[:test] + params end def build_url event, properties, options data = build_event event, track_properties(properties) url = "#{options[:url]}?data=#{encoded_data(data)}"