31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/mixpanel_rails.rb', line 31
def process_mixpanel_queue
unless response.redirect_url && request.host == URI.parse(response.redirect_url).host
mixpanel = Mixpanel::Tracker.new(MixpanelRails::Railtie.config.mixpanel_rails.token, request.env, true)
distinct_id = mixpanel_distinct_id.bind(self).call
params = {}
params[:distinct_id] = distinct_id if distinct_id
params.merge!(register_with_mixpanel)
if request.env["Rack-Middleware-PDFKit"] || response.redirect_url
mixpanel_queue.each {|s| mixpanel.track_event(s, params) }
else
name_tag = mixpanel_name_tag.bind(self).call
mixpanel.append_api(:register, params)
mixpanel.append_api(:name_tag, name_tag) if name_tag
mixpanel_queue.each {|s| mixpanel.append_api :track, s }
end
session.delete :register_with_mixpanel
session.delete :mixpanel_queue
end
end
|