Module: ExpressGeoip

Defined in:
lib/express_analytics/default_logger.rb

Overview

TODO: Move this to ExpressGeoip

Instance Method Summary collapse

Instance Method Details

#lookup(remote_ip) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/express_analytics/default_logger.rb', line 80

def lookup(remote_ip)
  geo_data = {}
  if result = ExpressGeoip::GeoipLookup.lookup(request.remote_ip)
    if result.present?
      geo_data.merge!(geo_country_code: result.country.name,
                      geo_administrative_area: nil,
                      geo_locality: result.city.name,
                      geo_latitude: (result.location.present? ? result.location.latitude : nil),
                      geo_longitude: (result.location.present? ? result.location.latitude : nil) )
    end
  end
  geo_data
end