18F / analytics-reporter

Lightweight analytics reporting and publishing tool for Digital Analytics Program's Google Analytics 360 data.

Home Page:https://analytics.usa.gov/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Retry GA4 API calls with exponential backoff

levinmr opened this issue · comments

Currently any calls to the GA4 API which encounter an error are lost. This does happen occasionally; a call is delayed and times out, or we hit a rate limit from google on our account.

I have seen behavior where GA4 calls begin to be rate limited or exceeding a quota if we have many deploys per day (Each deploy runs all the daily reports, so many deploys in a single day can result in a very high number of GA4 API calls)

This can be a problem for daily reports because we may lose a full day of data for the failed report, and potentially display incorrect/stale data on the site.

This ticket adds retry behavior for all GA4 API calls with exponential backoff to attempt to prevent rate limiting and also to make the app more resilient to transient failures in our dependent systems