: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(dashboards): warn when insights read out-of-date warehouse tables (#108746)
Daniel RCa129cddcd166
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 7ebbd97c95aa..67e20f037f0c 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -496,6 +496,10 @@ snapshots:hash: v1.k794b7964.fdfc67abaeb31b9a0d3a230ee9510916ffb36d5aad1d2321edaa896bb343ff9b.3W6qDwBKmZQGvb56bckNdiwYQhuA5gIf0DfLmUFN0eUcomponents-cards-insight-card--insight-card--light:hash: v1.k794b7964.623afbadbac0c53b481d42f50439e0fdc6353f01a3779b2d3d829b0247300d18.J36MTIFPey57K8AJiKNlIl8uivEtrCDx_29HJqocehA+ components-cards-insight-card--warehouse-sync-warning--dark:+ hash: v1.k794b7964.a2bf1677c0ca6c9d9ea5c52776a00006a9e84c4c35e0a0c7dfeb70ad7eac767c.8r2jeOLV3BYUDiOz2eary3Jf-XbUPY3v9q8bOP4khGQ+ components-cards-insight-card--warehouse-sync-warning--light:+ hash: v1.k794b7964.cb32569e632b20e2b6f64ae79595cb817a8a1073434b5d38a513123a5a3d5ba5.0jnIFtHrxk8FZwZPLRYEs4AO4vZwSHKCEX8FD2tEmEUcomponents-cards-insight-details--dashboard-filter-overrides--dark:hash: v1.k794b7964.94e9eb424e71eff3e6aea5ed2ef41f83c8b814d0a33ffa0da2ee09b0901c0c2b.Oq7Wk9gjSHBMkBYZwTKvKnN7PzU3G63hHAIBovDAOe4components-cards-insight-details--dashboard-filter-overrides--light:diff --git a/frontend/src/lib/components/Cards/InsightCard/InsightCard.stories.tsx b/frontend/src/lib/components/Cards/InsightCard/InsightCard.stories.tsxindex 9276b4b6f96f..6545fa2fb3e1 100644--- a/frontend/src/lib/components/Cards/InsightCard/InsightCard.stories.tsx+++ b/frontend/src/lib/components/Cards/InsightCard/InsightCard.stories.tsx@@ -515,3 +515,58 @@ export const AccessControlMixedPermissions: Story = {)},}++export const WarehouseSyncWarning: Story = {+ render: () => {+ const insight = {+ ...EXAMPLE_TRENDS,+ name: 'Monthly revenue by plan',+ warnings: [+ {+ type: 'warehouse_sync',+ message:+ 'Last sync of `invoices` (from Stripe) failed. Results reflect data from 5 days ago. Check the data warehouse source for details.',+ schema_name: 'invoices',+ source_id: 'source-1',+ source_type: 'Stripe',+ status: 'Failed',+ table_name: 'stripe_invoices',+ },+ {+ type: 'warehouse_sync',+ message:+ '`hubspot_deals` (from Hubspot) last synced 3 days ago, more than twice its configured sync interval. Results may be out of date.',+ schema_name: 'deals',+ source_id: 'source-2',+ source_type: 'Hubspot',+ status: 'Completed',+ table_name: 'hubspot_deals',+ },+ ],+ } as unknown as InsightModel++ return (+ <div className="flex gap-4 min-w-[50rem]">+ <div className="w-[32rem]">+ <InsightCardComponent+ tile={defaultTile}+ insight={insight}+ rename={() => {}}+ duplicate={() => {}}+ placement="SavedInsightGrid"+ />+ </div>+ {/* A narrow tile, so the tag has to share the title row with a truncated name. */}+ <div className="w-[16rem]">+ <InsightCardComponent+ tile={defaultTile}+ insight={insight}+ rename={() => {}}+ duplicate={() => {}}+ placement="SavedInsightGrid"+ />+ </div>+ </div>+ )+ },+}diff --git a/frontend/src/lib/components/Cards/InsightCard/InsightMeta.tsx b/frontend/src/lib/components/Cards/InsightCard/InsightMeta.tsxindex dc948780a0ed..665dd13c7636 100644--- a/frontend/src/lib/components/Cards/InsightCard/InsightMeta.tsx+++ b/frontend/src/lib/components/Cards/InsightCard/InsightMeta.tsx@@ -56,6 +56,8 @@ import { urls } from 'scenes/urls'import { insightsModel } from '~/models/insightsModel'import { queryScanHasActionableFinding } from '~/queries/nodes/DataNode/queryScan'import { QueryScanTileTooltip } from '~/queries/nodes/DataNode/QueryScanTileTooltip'+import { WarehouseSyncWarningList } from '~/queries/nodes/DataNode/WarehouseSyncWarningList'+import { outOfDateSyncWarnings } from '~/queries/nodes/DataNode/warehouseSyncWarnings'import { copyTableData, getInsightExportAdapter } from '~/queries/nodes/InsightViz/exportAdapters'import { useInsightDisplayOptions } from '~/queries/nodes/InsightViz/insightDisplayOptions'import { Node, NodeKind, ProductKey } from '~/queries/schema/schema-general'@@ -280,6 +282,16 @@ export function InsightMeta({canEditInsight && queryScan && scanFindings.length > 0 ? (<QueryScanTileTooltip summary={queryScan} findings={scanFindings} />) : null+ const syncWarnings = outOfDateSyncWarnings(insight.warnings)+ const warehouseSyncTooltip =+ syncWarnings.length > 0 ? (+ <div className="flex flex-col gap-1">+ <span>+ Some warehouse tables this insight reads are out of date, so its results may not be current:+ </span>+ <WarehouseSyncWarningList warnings={syncWarnings} />+ </div>+ ) : nullconst showDashboardAlertsMenuItem = isUsedAsDashboardTile && !!dashboardId && !!insight.id && canViewInsightconst canCreateAlertForInsight = areAlertsSupportedForInsight(query, {@@ -505,6 +517,7 @@ export function InsightMeta({showDescription={tile?.show_description !== false}dataRetentionWarning={dataRetentionWarning}queryScanTooltip={queryScanTooltip}+ warehouseSyncTooltip={warehouseSyncTooltip}queryScanActionable={queryScanHasActionableFinding(scanFindings)}infoPopover={showCompactTile ? (@@ -877,6 +890,7 @@ export function InsightMetaContent({dataRetentionWarning,queryScanTooltip,queryScanActionable,+ warehouseSyncTooltip,}: {title: stringfallbackTitle?: string@@ -892,6 +906,7 @@ export function InsightMetaContent({queryScanTooltip?: JSX.Element | null/** Whether the person can act on a finding. Without one the tile only notes that the query is slow. */queryScanActionable?: boolean+ warehouseSyncTooltip?: JSX.Element | null}): JSX.Element {const dataRetentionIndicator = dataRetentionWarning ? (<Tooltip title={dataRetentionWarning}>@@ -912,14 +927,17 @@ export function InsightMetaContent({)}</Tooltip>) : null+ const warehouseSyncIndicator = warehouseSyncTooltip ? (+ <Tooltip title={warehouseSyncTooltip} interactive>+ <LemonTag type="warning" size="small" className="ml-1.5 shrink-0" data-attr="insight-card-warehouse-sync">+ Out of date+ </LemonTag>+ </Tooltip>+ ) : null+ const hasTitleIndicator = !!(infoPopover || dataRetentionIndicator || queryScanIndicator || warehouseSyncIndicator)const titleContent = (<>- <span- className={clsx(- 'text-primary',- (infoPopover || dataRetentionIndicator || queryScanIndicator) && 'truncate'- )}- >+ <span className={clsx('text-primary', hasTitleIndicator && 'truncate')}>{title || <i>{fallbackTitle || 'Untitled'}</i>}</span>{(loading || loadingQueued) && (@@ -935,10 +953,7 @@ export function InsightMetaContent({<h4title={!compact ? title : undefined}data-attr="insight-card-title"- className={clsx(- (infoPopover || dataRetentionIndicator || queryScanIndicator) &&- 'inline-flex items-center overflow-visible'- )}+ className={clsx(hasTitleIndicator && 'inline-flex items-center overflow-visible')}>{link ? (<Link to={link} className="max-w-full truncate">@@ -949,6 +964,7 @@ export function InsightMetaContent({)}{dataRetentionIndicator}{queryScanIndicator}+ {warehouseSyncIndicator}{infoPopover}</h4>)diff --git a/frontend/src/queries/nodes/DataNode/WarehouseSyncWarningList.tsx b/frontend/src/queries/nodes/DataNode/WarehouseSyncWarningList.tsxnew file mode 100644index 000000000000..5e4995b6898c--- /dev/null+++ b/frontend/src/queries/nodes/DataNode/WarehouseSyncWarningList.tsx@@ -0,0 +1,30 @@+import { Link } from 'lib/lemon-ui/Link'+import { urls } from 'scenes/urls'++import { DataWarehouseSyncWarning } from '~/queries/schema/schema-general'++import { trimRedundantTail } from './warehouseSyncWarnings'++export function WarehouseSyncWarningList({ warnings }: { warnings: DataWarehouseSyncWarning[] }): JSX.Element {+ return (+ <ul className="list-disc pl-5">+ {warnings.map((warning, index) => (+ <li key={`${warning.table_name}-${warning.schema_name}-${index}`}>+ <span>{trimRedundantTail(warning.message)}</span>+ {warning.source_id && (+ <>+ {' '}+ <Link+ to={urls.dataWarehouseSource(`managed-${warning.source_id}`)}+ target="_blank"+ data-attr="warehouse-sync-warning-manage-source"+ >+ Manage source+ </Link>+ </>+ )}+ </li>+ ))}+ </ul>+ )+}diff --git a/frontend/src/queries/nodes/DataNode/warehouseSyncWarnings.test.ts b/frontend/src/queries/nodes/DataNode/warehouseSyncWarnings.test.tsnew file mode 100644index 000000000000..cb179d83de26--- /dev/null+++ b/frontend/src/queries/nodes/DataNode/warehouseSyncWarnings.test.ts@@ -0,0 +1,107 @@+import { DataWarehouseSyncWarning } from '~/queries/schema/schema-general'+import { DashboardTile, InsightModel, InsightShortId } from '~/types'++import { trimRedundantTail, warehouseSyncDashboardSummary } from './warehouseSyncWarnings'++function syncWarning(table: string): DataWarehouseSyncWarning {+ return {+ type: 'warehouse_sync',+ message: `Last sync of \`${table}\` (from Stripe) failed.`,+ schema_name: table,+ source_id: 'source-1',+ source_type: 'Stripe',+ status: 'Failed',+ table_name: `stripe_${table}`,+ }+}++function tile(id: number, insight: Partial<InsightModel> | null): DashboardTile {+ return { id, color: null, insight: insight ? (insight as InsightModel) : undefined }+}++describe('warehouseSyncWarnings', () => {+ describe('trimRedundantTail', () => {+ // Messages mirror those emitted by products/data_warehouse/backend/sync_status.py.+ test.each([+ [+ 'stale completed sync drops the redundant tail',+ '`postgres_posthog_team` (from Postgres) last synced 2 hours ago, more than twice its configured sync interval. Results may be out of date.',+ '`postgres_posthog_team` (from Postgres) last synced 2 hours ago, more than twice its configured sync interval.',+ ],+ [+ 'running sync keeps the in-progress note but drops the redundant tail',+ '`postgres_posthog_team` (from Postgres) last completed syncing 2 hours ago, more than twice its configured sync interval. A new sync is in progress but results may be out of date.',+ '`postgres_posthog_team` (from Postgres) last completed syncing 2 hours ago, more than twice its configured sync interval. A new sync is in progress.',+ ],+ [+ 'billing limit reached drops the redundant tail',+ 'Sync of `t` (from Stripe) is paused because the data warehouse billing limit has been reached. Results may be out of date.',+ 'Sync of `t` (from Stripe) is paused because the data warehouse billing limit has been reached.',+ ],+ [+ 'billing limit too low drops the redundant tail',+ 'Sync of `t` (from Stripe) is paused because the configured billing limit is too low. Results may be out of date.',+ 'Sync of `t` (from Stripe) is paused because the configured billing limit is too low.',+ ],+ [+ 'paused message without the tail is left unchanged',+ 'Sync of `t` (from Stripe) is paused. Results reflect the last successful sync from 2 hours ago.',+ 'Sync of `t` (from Stripe) is paused. Results reflect the last successful sync from 2 hours ago.',+ ],+ [+ 'failed message without the tail is left unchanged',+ 'Last sync of `t` (from Stripe) failed. Results reflect data from 2 hours ago. Check the data warehouse source for details.',+ 'Last sync of `t` (from Stripe) failed. Results reflect data from 2 hours ago. Check the data warehouse source for details.',+ ],+ ])('%s', (_name, input, expected) => {+ expect(trimRedundantTail(input)).toEqual(expected)+ })+ })++ it('summarizes the out-of-date sources behind a dashboard and the insights they affect', () => {+ const invoices = syncWarning('invoices')+ const leads: DataWarehouseSyncWarning = {+ ...syncWarning('leads'),+ source_id: 'source-2',+ source_type: 'Hubspot',+ }+ const tiles = [+ tile(1, { short_id: 'aaa' as InsightShortId, name: 'Revenue', warnings: [invoices] }),+ tile(2, { short_id: 'bbb' as InsightShortId, name: 'Pipeline', warnings: [invoices, leads] }),+ tile(3, { short_id: 'ccc' as InsightShortId, name: 'Healthy', warnings: null }),+ tile(4, { short_id: 'ddd' as InsightShortId, name: 'Deleted', warnings: [leads], deleted: true }),+ tile(5, {+ short_id: 'eee' as InsightShortId,+ name: 'Restricted',+ warnings: [{ type: 'access_control', message: 'Some objects are hidden.', resources: ['insight'] }],+ }),+ tile(6, null),+ // Paused an hour ago: the data is still current, so nothing here is out of date.+ tile(7, {+ short_id: 'fff' as InsightShortId,+ name: 'Paused recently',+ warnings: [{ ...syncWarning('refunds'), status: 'Paused', data_is_current: true }],+ }),+ ]++ const summary = warehouseSyncDashboardSummary(tiles)++ expect(summary?.sources).toEqual([+ { sourceType: 'Stripe', sourceId: 'source-1' },+ { sourceType: 'Hubspot', sourceId: 'source-2' },+ ])+ expect(summary?.insightCount).toEqual(2)+ expect(warehouseSyncDashboardSummary([tiles[2], tiles[4], tiles[5], tiles[6]])).toBeNull()+ })++ it('keeps the fingerprint when only the message age changes, and changes it when another table goes out of date', () => {+ const invoices = syncWarning('invoices')+ const fingerprint = (warnings: DataWarehouseSyncWarning[]): string | undefined =>+ warehouseSyncDashboardSummary([tile(1, { short_id: 'aaa' as InsightShortId, warnings })])?.fingerprint++ expect(fingerprint([{ ...invoices, message: 'Last sync of `invoices` failed a day ago.' }])).toEqual(+ fingerprint([invoices])+ )+ expect(fingerprint([invoices, syncWarning('charges')])).not.toEqual(fingerprint([invoices]))+ })+})diff --git a/frontend/src/queries/nodes/DataNode/warehouseSyncWarnings.ts b/frontend/src/queries/nodes/DataNode/warehouseSyncWarnings.tsnew file mode 100644index 000000000000..29ce3b1c85c7--- /dev/null+++ b/frontend/src/queries/nodes/DataNode/warehouseSyncWarnings.ts@@ -0,0 +1,76 @@+import { hashCodeForString } from 'lib/utils/strings'++import { AnalyticsQueryResponseBase, DataWarehouseSyncWarning } from '~/queries/schema/schema-general'+import { DashboardTile } from '~/types'++export interface WarehouseSyncDashboardSource {+ sourceType: string+ /** Null when the warning names no source to link to. */+ sourceId: string | null+}++export interface WarehouseSyncDashboardSummary {+ sources: WarehouseSyncDashboardSource[]+ insightCount: number+ /**+ * Identifies the set of out-of-date tables and their statuses. It ignores the message, whose+ * "3 days ago" text changes on every recompute.+ */+ fingerprint: string+}++// The backend `message` on a DataWarehouseSyncWarning is kept self-contained (it also feeds+// LLM/MCP contexts), so it restates "results may be out of date" — which the sync-warning banner+// header already says. Strip that redundant tail for display only, while preserving any+// "a new sync is in progress" detail. Messages without that tail (failed, paused) are left as-is.+export const trimRedundantTail = (message: string): string =>+ message+ .replace(/\.\s*(A new sync is in progress) but results may be out of date\.?\s*$/i, '. $1.')+ .replace(/\.\s*Results may be out of date\.?\s*$/i, '.')++export function warehouseSyncWarnings(+ warnings: AnalyticsQueryResponseBase['warnings'] | null | undefined+): DataWarehouseSyncWarning[] {+ return (warnings ?? []).filter((warning): warning is DataWarehouseSyncWarning => warning.type === 'warehouse_sync')+}++/**+ * The sync warnings whose data is behind its sync schedule. A sync paused recently still serves current+ * data, so a surface that says "out of date" leaves that warning out.+ */+export function outOfDateSyncWarnings(+ warnings: AnalyticsQueryResponseBase['warnings'] | null | undefined+): DataWarehouseSyncWarning[] {+ return warehouseSyncWarnings(warnings).filter((warning) => !warning.data_is_current)+}++/** The out-of-date warehouse sources behind a dashboard's insights, or null when every insight is current. */+export function warehouseSyncDashboardSummary(tiles: DashboardTile[]): WarehouseSyncDashboardSummary | null {+ const sources = new Map<string, WarehouseSyncDashboardSource>()+ const tables = new Set<string>()+ let insightCount = 0+ for (const tile of tiles) {+ const insight = tile.insight+ if (!insight || insight.deleted) {+ continue+ }+ const warnings = outOfDateSyncWarnings(insight.warnings)+ if (warnings.length === 0) {+ continue+ }+ insightCount += 1+ for (const warning of warnings) {+ const sourceKey = warning.source_id ?? warning.source_type+ sources.set(sourceKey, { sourceType: warning.source_type, sourceId: warning.source_id ?? null })+ tables.add(`${sourceKey}:${warning.schema_name}:${warning.table_name}:${warning.status}`)+ }+ }+ if (insightCount === 0) {+ return null+ }+ return {+ sources: [...sources.values()],+ insightCount,+ fingerprint: String(hashCodeForString([...tables].sort().join('|'))),+ }+}diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex 5dde400bab2c..fdf694d4202c 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -21376,6 +21376,10 @@"DataWarehouseSyncWarning": {"additionalProperties": false,"properties": {+ "data_is_current": {+ "description": "True when the last sync is still within the table's sync interval, so the data is current and the warning only says it will stop updating (a sync paused recently). False or absent when the data is out of date.",+ "type": "boolean"+ },"message": {"description": "Human-readable warning shown to the user","type": "string"diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.tsindex 91f7aa4bdbe8..12ad30b31806 100644--- a/frontend/src/queries/schema/schema-general.ts+++ b/frontend/src/queries/schema/schema-general.ts@@ -597,6 +597,11 @@ export interface DataWarehouseSyncWarning {status: string/** Human-readable warning shown to the user */message: string+ /**+ * True when the last sync is still within the table's sync interval, so the data is current and the+ * warning only says it will stop updating (a sync paused recently). False or absent when the data is out of date.+ */+ data_is_current?: boolean}export interface AccessControlFilterWarning {diff --git a/frontend/src/scenes/dashboard/Dashboard.tsx b/frontend/src/scenes/dashboard/Dashboard.tsxindex a1507c2f86ac..52363f8b20f5 100644--- a/frontend/src/scenes/dashboard/Dashboard.tsx+++ b/frontend/src/scenes/dashboard/Dashboard.tsx@@ -39,6 +39,7 @@ import { DashboardModalLoading } from './DashboardModalLoading'import { DashboardQueryScanBanner } from './DashboardQueryScanBanner'import { DashboardRetentionBanner } from './DashboardRetentionBanner'import { dashboardSubscribeNudgeLogic } from './dashboardSubscribeNudgeLogic'+import { DashboardWarehouseSyncBanner } from './DashboardWarehouseSyncBanner'import { DashboardZoomControl } from './DashboardZoomControl'import { EmptyDashboardComponent } from './EmptyDashboardComponent'@@ -248,6 +249,7 @@ function DashboardScene({<DashboardRetentionBanner /><DashboardFlagCalledBanner /><DashboardQueryScanBanner />+ <DashboardWarehouseSyncBanner /><SceneStickyBar showBorderBottom={false} className="flex gap-2 space-y-0"><DashboardFilterBar backTo={backTo} />diff --git a/frontend/src/scenes/dashboard/DashboardWarehouseSyncBanner.tsx b/frontend/src/scenes/dashboard/DashboardWarehouseSyncBanner.tsxnew file mode 100644index 000000000000..2b7662fbd448--- /dev/null+++ b/frontend/src/scenes/dashboard/DashboardWarehouseSyncBanner.tsx@@ -0,0 +1,43 @@+import { useValues } from 'kea'++import { LemonBanner } from 'lib/lemon-ui/LemonBanner'+import { pluralize } from 'lib/utils/strings'+import { urls } from 'scenes/urls'++import { warehouseSyncDashboardSummary } from '~/queries/nodes/DataNode/warehouseSyncWarnings'++import { dashboardLogic } from './dashboardLogic'++export function DashboardWarehouseSyncBanner(): JSX.Element | null {+ const { dashboard, insightTiles } = useValues(dashboardLogic)+ const summary = dashboard ? warehouseSyncDashboardSummary(insightTiles) : null+ if (!dashboard || !summary) {+ return null+ }++ const { sources, insightCount, fingerprint } = summary+ const onlySource = sources.length === 1 ? sources[0] : null+ const origin = onlySource ? onlySource.sourceType : `${sources.length} warehouse sources`++ return (+ <LemonBanner+ type="warning"+ className="mt-4 mb-2"+ data-attr="dashboard-warehouse-sync-warnings"+ // The fingerprint brings a dismissed banner back when another table goes out of date.+ dismissKey={`dashboard-warehouse-sync-${dashboard.id}-${fingerprint}`}+ action={+ onlySource?.sourceId+ ? {+ children: 'Manage source',+ to: urls.dataWarehouseSource(`managed-${onlySource.sourceId}`),+ targetBlank: true,+ 'data-attr': 'dashboard-warehouse-sync-manage-source',+ }+ : undefined+ }+ >+ {`Data from ${origin} is out of date, so ${pluralize(insightCount, 'insight')} on this dashboard may not show current numbers. Hover the Out of date tag on an insight for details.`}+ </LemonBanner>+ )+}diff --git a/frontend/src/scenes/dashboard/dashboardLogic.test.ts b/frontend/src/scenes/dashboard/dashboardLogic.test.tsindex 0db231fdb8ed..01f40805f1f7 100644--- a/frontend/src/scenes/dashboard/dashboardLogic.test.ts+++ b/frontend/src/scenes/dashboard/dashboardLogic.test.ts@@ -4151,6 +4151,29 @@ describe('dashboardLogic', () => {])})+ it('preserves sync warnings when a bare PATCH returns them null', async () => {+ const warning = {+ type: 'warehouse_sync' as const,+ message: 'Last sync of `invoices` (from Stripe) failed.',+ schema_name: 'invoices',+ source_id: 'source-1',+ source_type: 'Stripe',+ status: 'Failed',+ table_name: 'stripe_invoices',+ }+ insightsModel.actions.renameInsightSuccess({ ...insight800(), warnings: [warning] })+ await expectLogic(logic).toFinishAllListeners()++ insightsModel.actions.renameInsightSuccess({+ ...insight800(),+ name: 'renamed via bare patch',+ warnings: null,+ })+ await expectLogic(logic).toFinishAllListeners()++ expect(logic.values.insightTiles[0].insight!.warnings).toEqual([warning])+ })+it('replaces cached chart data when a full refresh returns non-null result', async () => {const newResult = [{ data: 'fresh' }]const newLastRefresh = '2024-01-01T00:00:00Z'diff --git a/frontend/src/scenes/dashboard/dashboardLogic.tsx b/frontend/src/scenes/dashboard/dashboardLogic.tsxindex 482fb74f5882..3971657da137 100644--- a/frontend/src/scenes/dashboard/dashboardLogic.tsx+++ b/frontend/src/scenes/dashboard/dashboardLogic.tsx@@ -2390,6 +2390,7 @@ export const dashboardLogic = kea<dashboardLogicType>([columns: item.columns ?? existing.columns,types: item.types ?? existing.types,query_scan: item.query_scan ?? existing.query_scan,+ warnings: item.warnings ?? existing.warnings,},}diff --git a/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx b/frontend/src/scenes/data-warehouse/editor/OutputPane.tsxindex 4cf60b86f4c7..b5a3429c268f 100644--- a/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx+++ b/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx@@ -40,7 +40,6 @@ import { TZLabel } from 'lib/components/TZLabel'import { PART_OF_WHOLE_DISPLAY_TYPES } from 'lib/constants'import { useCellCopyContextMenu } from 'lib/hooks/useCellCopyContextMenu'import { IconTableChart } from 'lib/lemon-ui/icons'-import { Link } from 'lib/lemon-ui/Link'import { LoadingBar } from 'lib/lemon-ui/LoadingBar'import { Spinner } from 'lib/lemon-ui/Spinner/Spinner'import { getAccessControlDisabledReason } from 'lib/utils/accessControlUtils'@@ -48,13 +47,14 @@ import { copyToClipboard } from 'lib/utils/copyToClipboard'import { tryJsonParse } from 'lib/utils/json'import { InsightErrorState, StatelessInsightLoadingState } from 'scenes/insights/EmptyStates'import { insightLogic } from 'scenes/insights/insightLogic'-import { urls } from 'scenes/urls'import { themeLogic } from '~/layout/navigation-3000/themeLogic'import { dataNodeLogic } from '~/queries/nodes/DataNode/dataNodeLogic'import { ElapsedTime } from '~/queries/nodes/DataNode/ElapsedTime'import { LoadPreviewText } from '~/queries/nodes/DataNode/LoadNext'import { QueryExecutionDetails } from '~/queries/nodes/DataNode/QueryExecutionDetails'+import { WarehouseSyncWarningList } from '~/queries/nodes/DataNode/WarehouseSyncWarningList'+import { warehouseSyncWarnings } from '~/queries/nodes/DataNode/warehouseSyncWarnings'import { DataTableRow } from '~/queries/nodes/DataTable/dataTableLogic'import { PartOfWholeChart } from '~/queries/nodes/DataVisualization/Components/Charts/PartOfWholeChart'import { SqlBoxPlot } from '~/queries/nodes/DataVisualization/Components/Charts/SqlBoxPlot'@@ -74,7 +74,6 @@ import { renderHogQLX } from '~/queries/nodes/HogQLX/render'import {type AccessControlFilterWarning,type DataTableNode,- type DataWarehouseSyncWarning,type HogQLQueryResponse,NodeKind,} from '~/queries/schema/schema-general'@@ -102,7 +101,6 @@ import { fixSQLErrorsLogic } from './fixSQLErrorsLogic'import { QueryIndexUsageBar } from './output-pane-tabs/QueryIndexUsageBar'import { OutputTab, outputPaneLogic } from './outputPaneLogic'import { sqlEditorLogic } from './sqlEditorLogic'-import { trimRedundantTail } from './syncWarnings'import TabScroller from './TabScroller'interface RowDetailsModalProps {@@ -1171,7 +1169,7 @@ const QueryWarningsBanner = ({ warnings }: { warnings?: HogQLQueryResponse['warnif (!warnings || warnings.length === 0) {return null}- const syncWarnings = warnings.filter((w): w is DataWarehouseSyncWarning => w.type === 'warehouse_sync')+ const syncWarnings = warehouseSyncWarnings(warnings)const acWarnings = warnings.filter((w): w is AccessControlFilterWarning => w.type === 'access_control')return (<>@@ -1182,24 +1180,7 @@ const QueryWarningsBanner = ({ warnings }: { warnings?: HogQLQueryResponse['warndata-attr="sql-editor-output-pane-sync-warnings">Some warehouse sources used by this query are out of date — results may not reflect current data:- <ul className="list-disc pl-5">- {syncWarnings.map((warning, index) => (- <li key={`${warning.table_name}-${warning.schema_name}-${index}`}>- {trimRedundantTail(warning.message)}- {warning.source_id && (- <>- {' '}- <Link- to={urls.dataWarehouseSource(`managed-${warning.source_id}`)}- target="_blank"- >- Manage source- </Link>- </>- )}- </li>- ))}- </ul>+ <WarehouseSyncWarningList warnings={syncWarnings} /></LemonBanner>)}{acWarnings.length > 0 && (diff --git a/frontend/src/scenes/data-warehouse/editor/syncWarnings.test.ts b/frontend/src/scenes/data-warehouse/editor/syncWarnings.test.tsdeleted file mode 100644index 54b66414b915..000000000000--- a/frontend/src/scenes/data-warehouse/editor/syncWarnings.test.ts+++ /dev/null@@ -1,41 +0,0 @@-import { trimRedundantTail } from './syncWarnings'--describe('syncWarnings', () => {- describe('trimRedundantTail', () => {- // Messages mirror those emitted by products/data_warehouse/backend/sync_status.py.- test.each([- [- 'stale completed sync drops the redundant tail',- '`postgres_posthog_team` (from Postgres) last synced 2 hours ago, more than twice its configured sync interval. Results may be out of date.',- '`postgres_posthog_team` (from Postgres) last synced 2 hours ago, more than twice its configured sync interval.',- ],- [- 'running sync keeps the in-progress note but drops the redundant tail',- '`postgres_posthog_team` (from Postgres) last completed syncing 2 hours ago, more than twice its configured sync interval. A new sync is in progress but results may be out of date.',- '`postgres_posthog_team` (from Postgres) last completed syncing 2 hours ago, more than twice its configured sync interval. A new sync is in progress.',- ],- [- 'billing limit reached drops the redundant tail',- 'Sync of `t` (from Stripe) is paused because the data warehouse billing limit has been reached. Results may be out of date.',- 'Sync of `t` (from Stripe) is paused because the data warehouse billing limit has been reached.',- ],- [- 'billing limit too low drops the redundant tail',- 'Sync of `t` (from Stripe) is paused because the configured billing limit is too low. Results may be out of date.',- 'Sync of `t` (from Stripe) is paused because the configured billing limit is too low.',- ],- [- 'paused message without the tail is left unchanged',- 'Sync of `t` (from Stripe) is paused. Results reflect the last successful sync from 2 hours ago.',- 'Sync of `t` (from Stripe) is paused. Results reflect the last successful sync from 2 hours ago.',- ],- [- 'failed message without the tail is left unchanged',- 'Last sync of `t` (from Stripe) failed. Results reflect data from 2 hours ago. Check the data warehouse source for details.',- 'Last sync of `t` (from Stripe) failed. Results reflect data from 2 hours ago. Check the data warehouse source for details.',- ],- ])('%s', (_name, input, expected) => {- expect(trimRedundantTail(input)).toEqual(expected)- })- })-})diff --git a/frontend/src/scenes/data-warehouse/editor/syncWarnings.ts b/frontend/src/scenes/data-warehouse/editor/syncWarnings.tsdeleted file mode 100644index 95bb330100a9..000000000000--- a/frontend/src/scenes/data-warehouse/editor/syncWarnings.ts+++ /dev/null@@ -1,8 +0,0 @@-// The backend `message` on a DataWarehouseSyncWarning is kept self-contained (it also feeds-// LLM/MCP contexts), so it restates "results may be out of date" — which the sync-warning banner-// header already says. Strip that redundant tail for display only, while preserving any-// "a new sync is in progress" detail. Messages without that tail (failed, paused) are left as-is.-export const trimRedundantTail = (message: string): string =>- message- .replace(/\.\s*(A new sync is in progress) but results may be out of date\.?\s*$/i, '. $1.')- .replace(/\.\s*Results may be out of date\.?\s*$/i, '.')diff --git a/frontend/src/scenes/insights/InsightAsScene.tsx b/frontend/src/scenes/insights/InsightAsScene.tsxindex 3ee441530ac1..caeea72d1bb4 100644--- a/frontend/src/scenes/insights/InsightAsScene.tsx+++ b/frontend/src/scenes/insights/InsightAsScene.tsx@@ -25,6 +25,7 @@ import { insightLogic } from './insightLogic'import { InsightQueryScanBanner } from './InsightQueryScanBanner'import { InsightSceneHeader } from './InsightSceneHeader'import { insightVizDataLogic } from './insightVizDataLogic'+import { InsightWarehouseSyncBanner } from './InsightWarehouseSyncBanner'import { SqlInsightFilters } from './SqlInsightFilters'export interface InsightAsSceneProps {@@ -103,6 +104,8 @@ export function InsightAsScene({ insightId, attachTo }: InsightAsSceneProps): JS{!isBIVisualizationNode(query) && <InsightQueryScanBanner insightProps={insightProps} />}+ <InsightWarehouseSyncBanner insightProps={insightProps} />+{!isEditing && !!insight.id && <SubscriptionSummaries insightId={insight.id} />}<SqlInsightFilters query={query} setQuery={setQuery}>diff --git a/frontend/src/scenes/insights/InsightWarehouseSyncBanner.tsx b/frontend/src/scenes/insights/InsightWarehouseSyncBanner.tsxnew file mode 100644index 000000000000..bd573afa19f9--- /dev/null+++ b/frontend/src/scenes/insights/InsightWarehouseSyncBanner.tsx@@ -0,0 +1,27 @@+import { useValues } from 'kea'++import { LemonBanner } from 'lib/lemon-ui/LemonBanner'++import { DataNodeLogicProps, dataNodeLogic } from '~/queries/nodes/DataNode/dataNodeLogic'+import { WarehouseSyncWarningList } from '~/queries/nodes/DataNode/WarehouseSyncWarningList'+import { outOfDateSyncWarnings } from '~/queries/nodes/DataNode/warehouseSyncWarnings'+import { insightVizDataNodeKey } from '~/queries/nodes/InsightViz/insightVizKeys'+import { InsightLogicProps } from '~/types'++export function InsightWarehouseSyncBanner({ insightProps }: { insightProps: InsightLogicProps }): JSX.Element | null {+ const { response, responseLoading } = useValues(+ dataNodeLogic({ key: insightVizDataNodeKey(insightProps) } as DataNodeLogicProps)+ )+ const syncWarnings = outOfDateSyncWarnings(response && 'warnings' in response ? response.warnings : null)+ // While a new query runs, the response still belongs to the previous query.+ if (responseLoading || syncWarnings.length === 0) {+ return null+ }++ return (+ <LemonBanner type="warning" data-attr="insight-warehouse-sync-warnings">+ Some warehouse tables this insight reads are out of date, so its results may not be current:+ <WarehouseSyncWarningList warnings={syncWarnings} />+ </LemonBanner>+ )+}diff --git a/frontend/src/scenes/insights/insightDataLogic.tsx b/frontend/src/scenes/insights/insightDataLogic.tsxindex bed0cdd9ee03..f97b8796202d 100644--- a/frontend/src/scenes/insights/insightDataLogic.tsx+++ b/frontend/src/scenes/insights/insightDataLogic.tsx@@ -331,6 +331,13 @@ export interface insightDataLogicActions {user_access_level: AccessControlLevelview_count?: number | undefinedviewers?: UserBasicType[] | undefined+ warnings?:+ | (+ | import('~/queries/schema/schema-general').AccessControlFilterWarning+ | import('~/queries/schema/schema-general').DataWarehouseSyncWarning+ )[]+ | null+ | undefined},payload?:| {@@ -381,6 +388,13 @@ export interface insightDataLogicActions {user_access_level: AccessControlLevelview_count?: number | undefinedviewers?: UserBasicType[] | undefined+ warnings?:+ | (+ | import('~/queries/schema/schema-general').AccessControlFilterWarning+ | import('~/queries/schema/schema-general').DataWarehouseSyncWarning+ )[]+ | null+ | undefined}payload?: {filtersOverride: DashboardFilter | null | undefineddiff --git a/frontend/src/scenes/insights/insightLogic.tsx b/frontend/src/scenes/insights/insightLogic.tsxindex 34d0eb8e54c7..6283390099dc 100644--- a/frontend/src/scenes/insights/insightLogic.tsx+++ b/frontend/src/scenes/insights/insightLogic.tsx@@ -88,6 +88,7 @@ import type { ProductIntentProperties } from '../../lib/utils/product-intents'import type { Noun } from '../../models/groupsModel'import type { QueryStatus, ResolvedDateRangeResponse } from '../../queries/schema/schema-general'import type { QueryScanSummary } from '../../queries/schema/schema-general'+import type { AccessControlFilterWarning, DataWarehouseSyncWarning } from '../../queries/schema/schema-general'import type { CohortType, DashboardTileBasicType, TeamPublicType, TeamType, UserBasicType, UserType } from '../../types'import { teamLogic } from '../teamLogic'import { insightDataLogic, isInsightSceneInstance } from './insightDataLogic'@@ -246,6 +247,7 @@ export interface insightLogicActions {user_access_level: AccessControlLevelview_count?: number | undefinedviewers?: UserBasicType[] | undefined+ warnings?: (AccessControlFilterWarning | DataWarehouseSyncWarning)[] | null | undefined},payload?: {filtersOverride: DashboardFilter | null | undefined@@ -294,6 +296,7 @@ export interface insightLogicActions {user_access_level: AccessControlLevelview_count?: number | undefinedviewers?: UserBasicType[] | undefined+ warnings?: (AccessControlFilterWarning | DataWarehouseSyncWarning)[] | null | undefined}payload?: {filtersOverride: DashboardFilter | null | undefined@@ -422,6 +425,7 @@ export interface insightLogicActions {user_access_level?: AccessControlLevel | undefinedview_count?: number | undefinedviewers?: UserBasicType[] | undefined+ warnings?: (AccessControlFilterWarning | DataWarehouseSyncWarning)[] | null | undefined},payload?: {metadataUpdate: Partial<@@ -469,6 +473,7 @@ export interface insightLogicActions {user_access_level?: AccessControlLevel | undefinedview_count?: number | undefinedviewers?: UserBasicType[] | undefined+ warnings?: (AccessControlFilterWarning | DataWarehouseSyncWarning)[] | null | undefined}payload?: {metadataUpdate: Partial<diff --git a/frontend/src/types.ts b/frontend/src/types.tsindex f0e83ae89423..e5f91e291965 100644--- a/frontend/src/types.ts+++ b/frontend/src/types.ts@@ -47,6 +47,7 @@ import type {} from '~/generated/core/api.schemas'import { RootAssistantMessage } from '~/queries/schema/schema-assistant-messages'import type {+ AnalyticsQueryResponseBase,CoreEvent,CurrencyCode,CustomerAnalyticsConfig,@@ -2709,6 +2710,7 @@ export interface InsightModel<R extends Node<Record<string, any>> = Node<Record<query: R | nullquery_status?: QueryStatusquery_scan?: QueryScanSummary+ warnings?: AnalyticsQueryResponseBase['warnings'] | nullis_cached?: booleanfilter_override_context?: InsightFilterOverrideContextApi | nullresolved_date_range?: ResolvedDateRangeResponse | nulldiff --git a/posthog/schema.py b/posthog/schema.pyindex 127aef6e41cf..091dbf1aedf5 100644--- a/posthog/schema.py+++ b/posthog/schema.py@@ -1245,6 +1245,14 @@ class DataWarehouseSyncWarning(BaseModel):model_config = ConfigDict(extra="forbid",)+ data_is_current: bool | None = Field(+ default=None,+ description=(+ "True when the last sync is still within the table's sync interval, so the"+ " data is current and the warning only says it will stop updating (a sync"+ " paused recently). False or absent when the data is out of date."+ ),+ )message: str = Field(..., description="Human-readable warning shown to the user")schema_name: str = Field(...,diff --git a/products/customer_analytics/frontend/generated/api.schemas.ts b/products/customer_analytics/frontend/generated/api.schemas.tsindex 02404a14894a..79db238d26f3 100644--- a/products/customer_analytics/frontend/generated/api.schemas.ts+++ b/products/customer_analytics/frontend/generated/api.schemas.ts@@ -1964,6 +1964,8 @@ export interface DataWarehouseSourceUsageApi {}export interface DataWarehouseSyncWarningApi {+ /** True when the last sync is still within the table's sync interval, so the data is current and the warning only says it will stop updating (a sync paused recently). False or absent when the data is out of date. */+ data_is_current?: boolean | null/** Human-readable warning shown to the user */message: string/** Name of the ExternalDataSchema responsible for syncing the table */diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.tsindex 4101a0f34242..905b145d9ff3 100644--- a/products/dashboards/frontend/generated/api.schemas.ts+++ b/products/dashboards/frontend/generated/api.schemas.ts@@ -2235,6 +2235,8 @@ export interface DataWarehouseSourceUsageApi {}export interface DataWarehouseSyncWarningApi {+ /** True when the last sync is still within the table's sync interval, so the data is current and the warning only says it will stop updating (a sync paused recently). False or absent when the data is out of date. */+ data_is_current?: boolean | null/** Human-readable warning shown to the user */message: string/** Name of the ExternalDataSchema responsible for syncing the table */diff --git a/products/data_warehouse/backend/sync_status.py b/products/data_warehouse/backend/sync_status.pyindex d450960e406f..b37f58dd152d 100644--- a/products/data_warehouse/backend/sync_status.py+++ b/products/data_warehouse/backend/sync_status.py@@ -108,7 +108,7 @@ def _build_warning_for_schema(source_type = schema.source.source_type if schema.source_id else "unknown"source_id = str(schema.source_id) if schema.source_id else None- def build(*, status: str, message: str) -> DataWarehouseSyncWarning:+ def build(*, status: str, message: str, data_is_current: bool = False) -> DataWarehouseSyncWarning:return DataWarehouseSyncWarning(table_name=table_name,schema_name=schema.name,@@ -116,6 +116,7 @@ def _build_warning_for_schema(source_id=source_id,status=status,message=message,+ data_is_current=data_is_current,)if schema_status == ExternalDataSchemaStatus.FAILED:@@ -137,6 +138,8 @@ def _build_warning_for_schema(return build(status=ExternalDataSchemaStatus.PAUSED,message=_paused_sync_message(table_name, source_type, schema, now),+ # A sync paused recently still serves current data. Surfaces that say "out of date" skip it.+ data_is_current=schema.last_synced_at is not None and not _is_stale(schema, now),)# Enabled and healthy: warn only once data is actually stale (covers RUNNING and idle COMPLETED).diff --git a/products/data_warehouse/backend/test/test_sync_status.py b/products/data_warehouse/backend/test/test_sync_status.pyindex 3c112d3f612f..b1473ee661e8 100644--- a/products/data_warehouse/backend/test/test_sync_status.py+++ b/products/data_warehouse/backend/test/test_sync_status.py@@ -109,6 +109,7 @@ class TestWarehouseSyncWarnings(BaseTest):assert warning.source_type == ExternalDataSourceType.STRIPEassert warning.source_id == str(self.source.id)assert warning.status == str(status)+ assert warning.data_is_current is (status == ExternalDataSchema.Status.PAUSED)assert "stripe_charge" in warning.messagedef test_failed_does_not_leak_raw_error(self) -> None:@@ -247,6 +248,7 @@ class TestWarehouseSyncWarnings(BaseTest):assert "current as of" in messageassert "won't update" in messageassert "reflect the last successful sync" not in message+ assert warnings[0].data_is_current is Truedef test_paused_and_stale_reflects_last_sync(self) -> None:self._make_schema(@@ -258,6 +260,7 @@ class TestWarehouseSyncWarnings(BaseTest):warnings = get_warehouse_sync_warnings(self.table, now=self.now)assert len(warnings) == 1assert "reflect the last successful sync" in warnings[0].message+ assert warnings[0].data_is_current is Falsedef test_paused_and_never_synced(self) -> None:self._make_schema(@@ -268,6 +271,7 @@ class TestWarehouseSyncWarnings(BaseTest):warnings = get_warehouse_sync_warnings(self.table, now=self.now)assert len(warnings) == 1assert "hasn't completed a sync yet" in warnings[0].message+ assert warnings[0].data_is_current is Falsedef test_warning_when_completed_but_stale(self) -> None:self._make_schema(diff --git a/products/marketing_analytics/frontend/generated/api.schemas.ts b/products/marketing_analytics/frontend/generated/api.schemas.tsindex 283fbe8c5370..c2e12cd584a3 100644--- a/products/marketing_analytics/frontend/generated/api.schemas.ts+++ b/products/marketing_analytics/frontend/generated/api.schemas.ts@@ -1808,6 +1808,8 @@ export interface DataWarehouseSourceUsageApi {}export interface DataWarehouseSyncWarningApi {+ /** True when the last sync is still within the table's sync interval, so the data is current and the warning only says it will stop updating (a sync paused recently). False or absent when the data is out of date. */+ data_is_current?: boolean | null/** Human-readable warning shown to the user */message: string/** Name of the ExternalDataSchema responsible for syncing the table */diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.tsindex 7da2ac073a8c..229c1a1558cc 100644--- a/products/product_analytics/frontend/generated/api.schemas.ts+++ b/products/product_analytics/frontend/generated/api.schemas.ts@@ -1099,6 +1099,8 @@ export interface DataWarehouseSourceUsageApi {}export interface DataWarehouseSyncWarningApi {+ /** True when the last sync is still within the table's sync interval, so the data is current and the warning only says it will stop updating (a sync paused recently). False or absent when the data is out of date. */+ data_is_current?: boolean | null/** Human-readable warning shown to the user */message: string/** Name of the ExternalDataSchema responsible for syncing the table */diff --git a/products/product_analytics/frontend/insights/activityDescriptions.tsx b/products/product_analytics/frontend/insights/activityDescriptions.tsxindex 623c6f7fca8b..78670173b621 100644--- a/products/product_analytics/frontend/insights/activityDescriptions.tsx+++ b/products/product_analytics/frontend/insights/activityDescriptions.tsx@@ -255,6 +255,7 @@ const insightActionsMapping: Record<dashboard_tiles: () => null,query_status: () => null,query_scan: () => null,+ warnings: () => null,user_access_level: () => null,_create_in_folder: () => null,last_viewed_at: () => null,diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex e4a7ba9fa40e..e261266fdccc 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -2765,6 +2765,8 @@ export namespace Schemas {}export interface DataWarehouseSyncWarning {+ /** True when the last sync is still within the table's sync interval, so the data is current and the warning only says it will stop updating (a sync paused recently). False or absent when the data is out of date. */+ data_is_current?: boolean | null;/** Human-readable warning shown to the user */message: string;/** Name of the ExternalDataSchema responsible for syncing the table */