PostHog / posthog

🦔 PostHog provides open-source product analytics, session recording, feature flagging and A/B testing that you can self-host.
https://posthog.com
Other
19.35k stars 1.13k forks source link

feat(insights): Update backend query cache staleness #23329

Open webjunkie opened 4 days ago

webjunkie commented 4 days ago

Problem

TLDR: Async dashboards trigger query calculations too often (mins or hrs). Current dashboard auto trigger (in frontend) is 20h.

We are improving the async behavior of dashboards to ultimately show fresher data on dashboards both normal and shared ones. There is a feature flagged "async dashboard" loading, which triggers calculations on the backend according to staleness. However, the existing frontend logic was to trigger auto refresh when the cache is 20 hours old (albeit users just clicked the refresh button when they want). Considering the backend staleness deems an insight stale after a few minutes or hours, this is a pretty a large difference that leads to quite some more calculations when rolling out the async dashboard more.

Changes

Future plans

Does this work well for both Cloud and self-hosted?

n/a

How did you test this code?

Added tests Checked dashboard and query behavior

github-actions[bot] commented 4 days ago

Size Change: +2 B (0%)

Total Size: 1.06 MB

ℹ️ View Unchanged | Filename | Size | Change | | :--- | :---: | :---: | | `frontend/dist/toolbar.js` | 1.06 MB | +2 B (0%) |

compressed-size-action

posthog-bot commented 1 day ago

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

Triggered by this commit.

👉 Review this PR's diff of snapshots.

posthog-bot commented 1 day ago

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

Triggered by this commit.

👉 Review this PR's diff of snapshots.