chore: Improve location display in sidebar (#1509)

- Log IP Address on widget load
- Save country code to contact
This commit is contained in:
Pranav Raj S
2020-12-13 22:23:56 +05:30
committed by GitHub
parent 060ef4a427
commit edb09d5a9c
10 changed files with 57 additions and 33 deletions

View File

@@ -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