ashcrow / flask-track-usage

Basic metrics tracking for the Flask framework.
Other
53 stars 33 forks source link

GeoIP url function needing update #44

Closed JohnAD closed 6 years ago

JohnAD commented 6 years ago

The current default for GeoIP is:

app.config['TRACK_USAGE_FREEGEOIP_ENDPOINT'] = 'http://freegeoip.net/json/'

which, according to ipstack.com, is being deprecated. It will stop working July 2018. Fortunately, they are keeping up the free service. But it is now requiring a login to get an API key:

http://api.ipstack.com/134.201.250.155?access_key=YOUR_ACCESS_KEY

What I'd like to do is generate a PR to update this (and the docs).

I'm thinking of having it make use a .format wildcard in the form of:

app.config['TRACK_USAGE_FREEGEOIP_ENDPOINT'] = 'http://api.ipstack.com/{ip}?access_key=YOUR_ACCESS_KEY'

and then updating the documentation to state that the config MUST be updated so that the user can set his/her API key.

JohnAD commented 6 years ago

I could also document alternatives such as:

Free:

NonFree:

JohnAD commented 6 years ago

I could make it backward compatible by searching for {ip} in the string. If missing, use the old behavior. Otherwise, use the new one.

ashcrow commented 6 years ago

Great catch @JohnAD. I hadn't noticed the announcement.

I could make it backward compatible by searching for {ip} in the string. If missing, use the old behavior. Otherwise, use the new one.

Sounds reasonable to me. If you do it against master we can release it in the 1.x and rebase it into the 2.x code. Don't forget to use thelegacy parameter OR update the code to use the new schema from ipstack.

I could also document alternatives such as:

I think that's a nice to have. I haven't looked at the alternatives to ensure they return the same schema.