lib/landable/traffic/user_tracker.rb in landable-1.13.1 vs lib/landable/traffic/user_tracker.rb in landable-1.13.2

- old
+ new

@@ -26,27 +26,24 @@ p.mime_type = request.format.to_s p.path = request.path p.query_string = untracked_parameters.to_query p.request_id = request.uuid - p.click_id = tracking_parameters["click_id"] + p.click_id = tracking_parameters['click_id'] p.http_status = response.status p.visit_id = @visit_id - # this is strange, yes, but is it better than a db call? - p.created_at = Time.current - - p.response_time = ( Time.now - @start_time ) * 1000 + current_time = Time.now + p.created_at = current_time + p.response_time = (current_time - @start_time) * 1000 end end def save p = record_page_view - if Landable.configuration.amqp_service_enabled - EventPublisher.publish(p) - end + EventPublisher.publish(p) if Landable.configuration.amqp_service_enabled session[:landable] = { KEYS[:visit_id] => @visit_id, KEYS[:visit_time] => Time.current, KEYS[:visitor_id] => @visitor_id, @@ -56,15 +53,23 @@ } end def identify(identifier) visit = Visit.find(@visit_id) - owner = Owner.where(owner: identifier).first_or_create + begin + owner = Owner.where(owner: identifier).first_or_create + rescue ActiveRecord::RecordNotUnique + retry + end visit.owner = owner visit.save! - Ownership.where(cookie_id: @cookie_id, owner: owner).first_or_create + begin + Ownership.where(cookie_id: @cookie_id, owner: owner).first_or_create + rescue ActiveRecord::RecordNotUnique + retry + end end end end end