Fixed data inconsistency in Post Analytics > Overview tab#24558
Fixed data inconsistency in Post Analytics > Overview tab#24558
Conversation
WalkthroughThe changes in the code remove the extraction of unused date and timezone variables and consolidate two sets of query parameters into a single Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🔇 Additional comments (4)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
| const {data, loading: tbLoading} = useTinybirdQuery({ | ||
| endpoint: 'api_kpis', | ||
| statsConfig: statsConfig || {id: ''}, | ||
| params: params | ||
| }); | ||
|
|
There was a problem hiding this comment.
TL;DR: the "Unique Visitors" metric was using the value from this API call, which used the all time data, but the chart filtered from the post.published_at timestamp.
Since some "unique visitors" can be attributed to the day before the post.published_at timestamp, this resulted in different data for the metric than the chart.
|
This fixes the inconsistency on the Post Analytics > Overview tab itself, and between the Overview <> Web Traffic tabs. It does not fix the fact that a "unique visitor" can be attributed to the day before a post is published, since we use the first pageview of the visit to define its timestamp. This is a stickier issue to solve, but this at least makes it less obvious to a user. |
ref https://linear.app/ghost/issue/PROD-2243/inconsistency-in-the-post-analytics-overview-data-compared-to-post
On the Post Analytics > Overview tab, the top level metric shown for unique visitors and the sum of the actual data in the chart can show different values. The metric and the chart are using separate requests to the same API endpoint with different
date_fromparameters, resulting in slightly different numbers, i.e. it's possible to see "1 unique visitor" but with 0 for every data point on the chart:This fixes that by removing the duplicate API call, so the data for the metric and the chart use the same exact underlying data.