GFDRR / thinkhazard

ThinkHazard!
http://thinkhazard.org/
GNU General Public License v3.0
33 stars 19 forks source link

[GSWBTH-10] Tracks API usage statistics #881

Closed tkohr closed 4 years ago

tkohr commented 4 years ago

PR sends hits to GA to track API usage (when production.ini is used).

A custom report is set up in GA interface to display this data.

tkohr commented 4 years ago

Reading requests-futures doc, if you call .result() here you're making it synchronous again.

Ah really !? I didn't get that on the first read. I will get rid of it as google will rarely not respond with a status 200 and the status is not even a confirmation if the hit is valid / counted.

tonio commented 4 years ago
  File "/app/thinkhazard/views/report.py", line 264, in report_json
    GoogleAnalytics().hit(request.path, "report-division_code-hazard_type")
  File "/app/thinkhazard/analytics.py", line 29, in __init__
    self.debug = "" if os.environ['INI_FILE'] == "production.ini" else "/debug"
  File "/usr/local/lib/python3.8/os.py", line 675, in __getitem__
    raise KeyError(key) from None
KeyError: 'INI_FILE'

Travis fail.

tonio commented 4 years ago

Looks like travis doesn't need to be updated if #882 is merged. Maybe @arnaud-morvan can merge it if he's happy with, and you can rebase this one.