Sha256: 41785cf6f71fbda2d80c48acc0c22b7aa57b73b9736343e40aaff6da6ddc60ff
Contents?: true
Size: 1.82 KB
Versions: 3
Compression:
Stored size: 1.82 KB
Contents
class RefererTracking::Sweeper < ActionController::Caching::Sweeper def after_create(record) if session && session["referer_tracking"] ses = session["referer_tracking"] ref_mod = RefererTracking::RefererTracking.new( :trackable_id => record.id, :trackable_type => record.class.to_s) ses.each_pair do |key, value| ref_mod[key] = value if ref_mod.has_attribute?(key) end req = assigns(:referer_tracking_request_add_infos) if req && req.is_a?(Hash) req.each_pair do |key, value| ref_mod[key] = value if ref_mod.has_attribute?(key) end end ref_mod[:ip] = request.ip ref_mod[:user_agent] = request.env['HTTP_USER_AGENT'] ref_mod[:current_request_url] = request.url ref_mod[:current_request_referer_url] = request.env["HTTP_REFERER"] # or request.headers["HTTP_REFERER"] ref_mod[:session_id] = request.session["session_id"] unless cookies[RefererTracking.set_referer_cookies_name].blank? cookie_ver, cookie_time_org, cookie_first_url, cookie_referer_url = cookies[RefererTracking.set_referer_cookies_name].to_s.split("|||") ref_mod[:cookie_first_url] = cookie_first_url ref_mod[:cookie_referer_url] = cookie_referer_url ref_mod[:cookie_time] = Time.at(cookie_time_org.to_i) end if RefererTracking.save_cookies begin ref_mod[:cookies_yaml] = cookies.instance_variable_get('@cookies').to_yaml rescue str = "referer_tracking after create problem encoding cookie yml, probably non utf8 chars #{e}" logger.error(str) ref_mod[:cookies_yaml] = "error: #{str}" end end ref_mod.save end rescue Exception => e Rails.logger.info "RefererTracking::Sweeper.after_create problem with creating record: #{e}" end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
referer_tracking-3.0.3 | lib/referer_tracking/sweeper.rb |
referer_tracking-3.0.2 | lib/referer_tracking/sweeper.rb |
referer_tracking-3.0.0 | lib/referer_tracking/sweeper.rb |