Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(dashboards): keep refreshed tiles when persisting last_refresh (#77687)

Christiaan Hendriksen00af80f6f724
diff --git a/frontend/src/models/dashboardsModel.tsx b/frontend/src/models/dashboardsModel.tsx
index bef0942ad4d6..3d80b6638125 100644
--- a/frontend/src/models/dashboardsModel.tsx
+++ b/frontend/src/models/dashboardsModel.tsx
@@ -484,7 +484,7 @@ export const dashboardsModel = kea<dashboardsModelType>([
}
if (discardResult) {
- return values.dashboard
+ return null
}
const mappedDashboard = getQueryBasedDashboard(response)
diff --git a/frontend/src/scenes/dashboard/dashboardLogic.test.ts b/frontend/src/scenes/dashboard/dashboardLogic.test.ts
index 22862b35284d..41018621d830 100644
--- a/frontend/src/scenes/dashboard/dashboardLogic.test.ts
+++ b/frontend/src/scenes/dashboard/dashboardLogic.test.ts
@@ -1437,6 +1437,31 @@ describe('dashboardLogic', () => {
expect(logic.values.oldestRefreshed?.toISOString()).toEqual(dayjs(staleIso).toISOString())
expect(logic.values.effectiveLastRefresh?.toISOString()).toEqual(dayjs(staleIso).toISOString())
})
+
+ it('persisting the last refresh keeps refreshed results instead of an earlier snapshot', async () => {
+ await expectLogic(logic).toFinishAllListeners()
+
+ const snapshot = logic.values.dashboard!
+ dashboardsModel.actions.updateDashboardSuccess(snapshot)
+
+ const insight = snapshot.tiles.find((tile) => !!tile.insight)!.insight!
+ const freshResult = [{ count: 42 }]
+
+ await expectLogic(logic, () => {
+ dashboardsModel.actions.updateDashboardInsight(
+ { ...insight, result: freshResult, query: insight.query ?? null },
+ undefined,
+ 5
+ )
+ }).toFinishAllListeners()
+
+ await expectLogic(dashboardsModel, () => {
+ logic.actions.updateDashboardLastRefresh(now())
+ }).toDispatchActions(['updateDashboard', 'updateDashboardSuccess'])
+
+ const refreshedTile = logic.values.tiles.find((tile) => tile.insight?.short_id === insight.short_id)
+ expect(refreshedTile?.insight?.result).toEqual(freshResult)
+ })
})
describe('insight refresh', () => {