cofacts / rumors-api

GraphQL API server for clients like rumors-site and rumors-line-bot
https://api.cofacts.tw
MIT License
109 stars 26 forks source link

fetchStatsFromGA script now warns about sampled data #290

Closed MrOrz closed 1 year ago

MrOrz commented 1 year ago

When back filling old analytics data, we found that the fetched LIFF stats are inconsistent with the numbers on Google Analytics.

We can reproduce this on local machine, and found that the inaccuracy only happens when the data is sampled: https://developers.google.com/analytics/devguides/reporting/core/v4/basics#sampling

If we specify a shorter date range when running the script, the inconsistency will be gone.

This PR adds a warning message when sampled data is detected from the Google Analytics Reporting API response.

圖片

Sampling should only happens when we manually back-fill the data. The hourly cron job should not have that much of data that triggers Google Analytics samplng.

coveralls commented 1 year ago

Coverage Status

Coverage increased (+0.01%) to 87.768% when pulling 4aac44c901ef46b5e512909c22b5a492b74bca76 on warn-about-sampled into 985911c62e94f6d15e330f61d9bc1d05d9263480 on master.