chore: Improve location display in sidebar (#1509)
- Log IP Address on widget load - Save country code to contact
This commit is contained in:
@@ -24,8 +24,12 @@ class ContactIpLookupJob < ApplicationJob
|
||||
ip = get_contact_ip(contact)
|
||||
return if ip.blank?
|
||||
|
||||
contact.additional_attributes['city'] = Geocoder.search(ip).first.city
|
||||
contact.additional_attributes['country'] = Geocoder.search(ip).first.country
|
||||
geocoder_result = Geocoder.search(ip).first
|
||||
return unless geocoder_result
|
||||
|
||||
contact.additional_attributes['city'] = geocoder_result.city
|
||||
contact.additional_attributes['country'] = geocoder_result.country
|
||||
contact.additional_attributes['country_code'] = geocoder_result.country_code
|
||||
contact.save!
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user