diff --git a/config/initializers/geocoder.rb b/config/initializers/geocoder.rb index 6dd5d7e..37727c2 100644 --- a/config/initializers/geocoder.rb +++ b/config/initializers/geocoder.rb @@ -1,11 +1,19 @@ Geocoder.configure( - # IP-address geolocation service used by `request.location`. - # ipinfo.io works without an API key at low volume; add an ipinfo_token to the - # Rails credentials to raise the rate limit. For a no-rate-limit / - # privacy-friendly setup, swap this for an offline MaxMind GeoLite2 lookup - # (ip_lookup: :geoip2 + the .mmdb file). - ip_lookup: :ipinfo_io, - ipinfo_io: { api_key: Rails.application.credentials.ipinfo_token.presence }, + # IP-address geolocation, used by ResolvePlayerCountryJob to tag each player + # with the country they played from. + # + # The credential is an **IPinfo Lite** token, so we use the Lite lookup: that + # is the endpoint the token is issued for (api.ipinfo.io/lite), and it is free + # and unmetered. It returns country + ASN only -- no city, no coordinates -- + # which is all we need, since the job only reads `country_code`. + # + # Pointing this at :ipinfo_io instead still "works" (the token is accepted on + # ipinfo.io//geo) but bills against the metered standard API, so a busy + # day can start returning 429s -- which are swallowed below and silently cost + # us a player's country. For a no-rate-limit / offline setup, swap in MaxMind + # GeoLite2 (ip_lookup: :geoip2 + the .mmdb file). + ip_lookup: :ipinfo_io_lite, + ipinfo_io_lite: { api_key: Rails.application.credentials.ipinfo_token.presence }, # A slow or unreachable geo service must never hold up the start of the game. timeout: 2,