: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
fix(data-warehouse): repair the ETL health links and chart rows over time (#107966)
Tom Owersc02829163023
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 384f325782ae..8e481c13c852 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -8813,13 +8813,13 @@ snapshots:scenes-app-errortracking-linkedreports--several-reports-across-states--light:hash: v1.k794b7964.fe2161a3bb0e898689ef58a342d071c353ded71ac270a62998ea566055359e7a.AnoCs1sNoTY6J1yl24yuZPh_1Jkjugz-jnYxHgY8ZyUscenes-app-etl--healthy--dark:- hash: v1.k794b7964.f97114fdf950bf28e82743f7dbd64d712d59c32ddb7e39c9d92518a40150b335.QxGeTzoXytUfBX6y_nmgVPqvaQqtKcOvDx4SuToXdtw+ hash: v1.k794b7964.b014fe822cfc470eb04981917b5f28638647cac8feca4fa137c1b79365640623.S9NpXGsBnfAsXSAD2XWHhfIMtA2YmupBLf9DtD-_3EIscenes-app-etl--healthy--light:- hash: v1.k794b7964.e87e236939c2f5ce17ddd1db0b35993cbd5880500cf91b9d7f07e6e8ff6c5d16.cKL4CPwGG5PxuIadBIIRylCLQUFX3hIxA05T3T1DrX0+ hash: v1.k794b7964.d4c8ae82bcc3ad153bc7dc72f1f372c0d98d5a05a127bb4ab8cccb105f68f435.ylQlvdaOh5Ft3BQNFe1i_9bXUNUKU2lbRadlbNFHVSMscenes-app-etl--needs-attention--dark:- hash: v1.k794b7964.921bac212428a17d90c76afa7fcd2cc184b49750fa1c31bed4d1b5e608fb6436.K0vj_KRaZKq1bLp6riYM6YnHdVi0I7jedojW6YfLvDk+ hash: v1.k794b7964.97f183b4042023e78af8255ca342bc71e45d7ab44471d2b43872cd4b628fc55e.smS95IlHDwVE-094LYjLyY8mViUovxYg0aTO-rOCw10scenes-app-etl--needs-attention--light:- hash: v1.k794b7964.c0551483dd11af0fef0680c4aa13343cc2962ea9a350f203435ac577da182699.7bPbMAMAsvaJNhudkkKPijhKiAQJDGk8lCkVtwUsGUI+ hash: v1.k794b7964.2c94576a10f6fab4a0940e803595c3251949ef656be2987d81a6b9783daf8133.UQ4cUFdnrkJH7YP2T7UelzPoLX8rBK9E6QFFIWZLijwscenes-app-events--event-explorer--dark:hash: v1.k794b7964.3bf3b01d0972be5ad8fe4a7408d20b10e2431ea8f28874aa0a63f7623c1af97c.ONFJgVNjjG1f32eqlxRZuleSgdLpLGIcFhHN2S4yvhkscenes-app-events--event-explorer--light:diff --git a/frontend/src/lib/components/AppMetrics/appMetricsLogic.ts b/frontend/src/lib/components/AppMetrics/appMetricsLogic.tsindex a2616a9585e3..3d60c29838df 100644--- a/frontend/src/lib/components/AppMetrics/appMetricsLogic.ts+++ b/frontend/src/lib/components/AppMetrics/appMetricsLogic.ts@@ -35,7 +35,7 @@ export type AppMetricsCommonParams = {instanceId?: stringmetricName?: string | string[]metricKind?: string | string[]- breakdownBy?: 'metric_name' | 'metric_kind' | 'app_source_id'+ breakdownBy?: 'metric_name' | 'metric_kind' | 'app_source_id' | 'instance_id'interval?: 'day' | 'hour' | 'minute'dateFrom?: stringdateTo?: stringdiff --git a/products/data_warehouse/backend/presentation/views/data_warehouse.py b/products/data_warehouse/backend/presentation/views/data_warehouse.pyindex 63cd18e5c23e..9fa901cdb56f 100644--- a/products/data_warehouse/backend/presentation/views/data_warehouse.py+++ b/products/data_warehouse/backend/presentation/views/data_warehouse.py@@ -912,7 +912,10 @@ class DataWarehouseViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):"status": sync_status,"error": schema.latest_error,"failed_at": schema.last_synced_at.isoformat() if schema.last_synced_at else None,- "url": f"/data-warehouse/sources/{schema.source_id}" if schema.source_id else None,+ # The source scene keys on a prefixed id, so a bare UUID renders a+ # broken page. Every ExternalDataSource uses the `managed-` prefix,+ # direct-connect ones included.+ "url": f"/data-warehouse/sources/managed-{schema.source_id}" if schema.source_id else None,})@@ -929,7 +932,7 @@ class DataWarehouseViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):"status": "failed","error": None,"failed_at": source.updated_at.isoformat() if source.updated_at else None,- "url": f"/data-warehouse/sources/{source.id}",+ "url": f"/data-warehouse/sources/managed-{source.id}",})diff --git a/products/data_warehouse/backend/tests/api/test_data_warehouse.py b/products/data_warehouse/backend/tests/api/test_data_warehouse.pyindex adc8855c7024..1ec6ee0a4fe1 100644--- a/products/data_warehouse/backend/tests/api/test_data_warehouse.py+++ b/products/data_warehouse/backend/tests/api/test_data_warehouse.py@@ -247,6 +247,25 @@ class TestDataWarehouseAPI(APIBaseTest):self.assertEqual(syncs[0]["status"], expected_status)self.assertEqual(syncs[0]["name"], "charges")self.assertEqual(syncs[0]["error"], "it broke")+ # The source scene keys on a prefixed id, so a bare UUID renders a broken page.+ self.assertEqual(syncs[0]["url"], f"/data-warehouse/sources/managed-{source.id}")++ def test_data_health_issues_links_a_failed_source_with_a_prefixed_id(self) -> None:+ endpoint = f"/api/projects/{self.team.id}/data_warehouse/data_health_issues"+ source = ExternalDataSource.objects.create(+ source_id="broken-id",+ connection_id="conn-id",+ destination_id="dest-id",+ team=self.team,+ source_type="Stripe",+ status=ExternalDataSource.Status.ERROR,+ )++ results = self.client.get(endpoint).json()["results"]++ sources = [issue for issue in results if issue["type"] == "source"]+ self.assertEqual(len(sources), 1)+ self.assertEqual(sources[0]["url"], f"/data-warehouse/sources/managed-{source.id}")def test_data_health_issues_ignores_a_sync_that_is_switched_off(self) -> None:# A table the user turned off is not a problem to report, however it last ended.diff --git a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineHealth.tsx b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineHealth.tsxindex ecc846d4ff73..62365e88eb26 100644--- a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineHealth.tsx+++ b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineHealth.tsx@@ -1,6 +1,6 @@import { useValues } from 'kea'-import { LemonSkeleton, LemonTable, LemonTag, Link } from '@posthog/lemon-ui'+import { LemonButton, LemonSkeleton, LemonTable, LemonTag, Link } from '@posthog/lemon-ui'import type { LemonTagType } from '@posthog/lemon-ui'import { TZLabel } from 'lib/components/TZLabel'@@ -92,11 +92,28 @@ export function PipelineHealth(): JSX.Element {),},{- title: 'Since',+ // The endpoint sends the last *successful* sync here, not the moment the+ // failure started, so "Never" is the honest reading of a null.+ title: 'Last synced',key: 'failed_at',width: 140,render: (_, issue) =>- issue.failed_at ? <TZLabel time={issue.failed_at} /> : <span className="text-muted">—</span>,+ issue.failed_at ? (+ <TZLabel time={issue.failed_at} />+ ) : (+ <span className="text-muted">Never</span>+ ),+ },+ {+ title: '',+ key: 'actions',+ width: 80,+ render: (_, issue) =>+ issue.url ? (+ <LemonButton type="secondary" size="xsmall" to={issue.url}>+ View+ </LemonButton>+ ) : null,},]}/>diff --git a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.stories.tsx b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.stories.tsxindex 273e656b45da..bf5939e851a0 100644--- a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.stories.tsx+++ b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.stories.tsx@@ -128,6 +128,27 @@ const SOURCES = {],}+// `loadAppMetricsTimeSeries` reads each row as [labels, breakdown, values], so the destination+// chart needs the raw HogQL shape rather than the parsed one.+const DAYS = ['2026-09-22', '2026-09-23', '2026-09-24', '2026-09-25', '2026-09-26', '2026-09-27', '2026-09-28']++const ROWS_QUERY = {+ results: [+ [DAYS, 'dest-1', [120000, 98000, 141000, 132000, 87000, 155000, 149000]],+ [DAYS, 'dest-2', [41000, 38000, 52000, 47000, 12000, 61000, 58000]],+ // A schema-keyed row. `rows_for` emits one per run and it must not become a series.+ [DAYS, '019df4a8-f218-0000-3c14-14195257f2fb', [161000, 136000, 193000, 179000, 99000, 216000, 207000]],+ ],+}++const DESTINATIONS = {+ count: 2,+ results: [+ { id: 'dest-1', name: 'PostHog warehouse', type: 'PostHogWarehouse' },+ { id: 'dest-2', name: 'Analytics Postgres', type: 'Postgres' },+ ],+}+function mocks(health: Record<string, unknown>, runs: Record<string, unknown>): ReturnType<typeof mswDecorator> {return mswDecorator({get: {@@ -137,7 +158,10 @@ function mocks(health: Record<string, unknown>, runs: Record<string, unknown>):'/api/projects/:team_id/data_warehouse/completed_activity': runs,'/api/projects/:team_id/external_data_sources': SOURCES,'/api/projects/:team_id/external_data_sources/wizard': {},- '/api/projects/:team_id/external_data_destinations': { count: 0, results: [] },+ '/api/projects/:team_id/external_data_destinations': DESTINATIONS,+ },+ post: {+ '/api/projects/:team_id/query/:query_kind/': ROWS_QUERY,},})}diff --git a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.tsx b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.tsxindex 517d5612035e..7b9dbcb4299c 100644--- a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.tsx+++ b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.tsx@@ -80,10 +80,7 @@ export function PipelineOverviewScene(): JSX.Element {vertical space, and its absence already says there is nothing wrong. */}{hasIssues ? (<>- <SceneSection- title="Needs attention"- description="Sources and tables that have stopped, most serious first."- >+ <SceneSection title="Needs attention" description="Tables and sources that have stopped syncing."><PipelineHealth /></SceneSection>@@ -93,7 +90,7 @@ export function PipelineOverviewScene(): JSX.Element {<SceneSectiontitle="Runs"- description="How many runs finished, and how many of them failed."+ description="Runs that failed in this window. A table can be broken here with no recent run, if nothing retried it."actions={<LemonSelect<PipelineStatsWindow>size="small"@@ -113,7 +110,10 @@ export function PipelineOverviewScene(): JSX.Element {<SceneDivider />- <SceneSection title="Rows synced by destination" description="Where the imported rows were written.">+ <SceneSection+ title="Rows synced by destination"+ description="Rows written to each destination. A row that reaches two destinations counts against both, so the series stack."+ ><RowsByDestination /></SceneSection>diff --git a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineStatTiles.tsx b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineStatTiles.tsxindex 5f387fc60772..07f0a7c65299 100644--- a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineStatTiles.tsx+++ b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineStatTiles.tsx@@ -47,6 +47,9 @@ export function PipelineStatTiles(): JSX.Element {healthIssuesLoading,failingSyncCount,issuesBySeverity,+ syncingTableCount,+ sources,+ sourcesLoading,} = useValues(pipelineOverviewSceneLogic)// `job_stats` reports syncs and materialized view runs separately, and every count here@@ -69,10 +72,10 @@ export function PipelineStatTiles(): JSX.Element {loading={rowsStatsLoading && rowsStats === null}/><StatTile- label="Sync runs"- value={humanFriendlyNumber(syncJobs?.total ?? 0)}- sub={`${humanFriendlyNumber(syncJobs?.successful ?? 0)} succeeded`}- loading={jobStatsLoading && jobStats === null}+ label="Tables syncing"+ value={humanFriendlyNumber(syncingTableCount)}+ sub="Switched on across every source"+ loading={sourcesLoading && sources === null}/><StatTilelabel="Needs attention"diff --git a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/RowsByDestination.tsx b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/RowsByDestination.tsxindex bac9fe57731f..498991cb6812 100644--- a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/RowsByDestination.tsx+++ b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/RowsByDestination.tsx@@ -1,17 +1,21 @@import { useValues } from 'kea'-import { LemonSkeleton, LemonTag } from '@posthog/lemon-ui'+import { LemonSkeleton } from '@posthog/lemon-ui'+import { TimeSeriesLineChart } from '@posthog/quill-charts'-import { humanFriendlyLargeNumber, humanFriendlyNumber } from 'lib/utils/numbers'+import { useChartTheme } from 'lib/charts/hooks'+import { teamLogic } from 'scenes/teamLogic'import { pipelineOverviewSceneLogic } from './pipelineOverviewSceneLogic'export function RowsByDestination(): JSX.Element {- const { rowsByDestination, destinationRowTotals, destinationRowTotalsLoading, destinationsLoading } =+ const { rowsByDestination, destinationRowSeries, destinationRowSeriesLoading, destinationsLoading, window } =useValues(pipelineOverviewSceneLogic)+ const { currentTeam } = useValues(teamLogic)+ const theme = useChartTheme()- if ((destinationRowTotalsLoading && destinationRowTotals === null) || destinationsLoading) {- return <LemonSkeleton className="h-24 w-full" />+ if ((destinationRowSeriesLoading && destinationRowSeries === null) || destinationsLoading) {+ return <LemonSkeleton className="h-64 w-full" />}if (rowsByDestination.length === 0) {@@ -22,34 +26,24 @@ export function RowsByDestination(): JSX.Element {)}- // Bars are relative to the busiest destination rather than the total, so a single dominant- // destination does not flatten every other bar to nothing.- const busiest = Math.max(...rowsByDestination.map((row) => row.rows))-return (- <div className="flex flex-col gap-2 rounded border border-primary bg-surface-primary p-4">- {rowsByDestination.map((row) => (- <div key={row.id} className="flex flex-col gap-1">- <div className="flex flex-wrap items-baseline justify-between gap-2">- <span className="flex items-center gap-2 min-w-0">- <span className="truncate font-medium">{row.name}</span>- <LemonTag type="muted" size="small">- {row.type}- </LemonTag>- </span>- <span className="tabular-nums font-medium" title={humanFriendlyNumber(row.rows)}>- {humanFriendlyLargeNumber(row.rows)}- </span>- </div>- <div className="h-1.5 w-full overflow-hidden rounded bg-border">- <div- className="h-full rounded bg-brand-blue"- // Width is the one value that has to be computed from the data.- style={{ width: `${Math.max(2, (row.rows / busiest) * 100)}%` }}- />- </div>- </div>- ))}+ // The chart fills its container, so it needs a definite height AND a flex column here.+ // Without both, the canvas resolves to zero height and draws nothing.+ <div className="flex h-80 flex-col overflow-hidden rounded border border-primary bg-surface-primary p-3">+ <TimeSeriesLineChart+ series={rowsByDestination}+ labels={destinationRowSeries?.labels ?? []}+ theme={theme}+ config={{+ xAxis: {+ timezone: currentTeam?.timezone ?? 'UTC',+ interval: window === 1 ? 'hour' : 'day',+ },+ yAxis: { format: 'short' },+ legend: { show: true, position: 'bottom' },+ tooltip: { pinnable: true },+ }}+ /></div>)}diff --git a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.test.ts b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.test.tsindex b3214b85c9c4..5a9aa2d236d4 100644--- a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.test.ts+++ b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.test.ts@@ -13,10 +13,11 @@ jest.mock('products/data_warehouse/frontend/generated/api', () => ({jest.mock('products/warehouse_sources/frontend/generated/api', () => ({externalDataDestinationsList: jest.fn(),+ externalDataSourcesList: jest.fn(),}))jest.mock('lib/components/AppMetrics/appMetricsLogic', () => ({- loadAppMetricsTotals: jest.fn(),+ loadAppMetricsTimeSeries: jest.fn(),}))const api = jest.requireMock('products/data_warehouse/frontend/generated/api')@@ -44,7 +45,8 @@ describe('pipelineOverviewSceneLogic', () => {api.dataWarehouseDataHealthIssuesRetrieve.mockResolvedValue({ results: [], count: 0 })api.dataWarehouseCompletedActivityRetrieve.mockResolvedValue({ results: [], next: null, previous: null })wsApi.externalDataDestinationsList.mockResolvedValue({ results: [] })- metrics.loadAppMetricsTotals.mockResolvedValue({})+ wsApi.externalDataSourcesList.mockResolvedValue({ results: [] })+ metrics.loadAppMetricsTimeSeries.mockResolvedValue({ labels: [], interval: 'day', timezone: 'UTC', series: [] })logic = pipelineOverviewSceneLogic()logic.mount()})@@ -150,7 +152,7 @@ describe('pipelineOverviewSceneLogic', () => {)})- it('reloads only the run counts when the window changes', async () => {+ it('leaves the billing-period row total alone when the window changes', async () => {// Rows are per billing period and health is current state, so refetching them on a window// change would be three wasted requests per click.api.dataWarehouseJobStatsRetrieve.mockClear()@@ -185,11 +187,35 @@ describe('pipelineOverviewSceneLogic', () => {// `dateTo` makes the query throw instead of returning rows.await expectLogic(logic).toFinishAllListeners()- const [request] = metrics.loadAppMetricsTotals.mock.calls[0]+ const [request] = metrics.loadAppMetricsTimeSeries.mock.calls[0]expect(request.metricName).toEqual('rows_synced')- expect(request.breakdownBy).toEqual(['instance_id'])+ expect(request.breakdownBy).toEqual('instance_id')expect(Date.parse(request.dateFrom)).not.toBeNaN()expect(Date.parse(request.dateTo)).not.toBeNaN()expect(Date.parse(request.dateFrom)).toBeLessThan(Date.parse(request.dateTo))})++ it('counts only the tables switched on across every page', async () => {+ logic.unmount()+ wsApi.externalDataSourcesList.mockReset()+ wsApi.externalDataSourcesList+ .mockResolvedValueOnce({+ next: '/api/projects/1/external_data_sources/?limit=100&offset=2',+ results: [+ { id: 'a', schemas: [{ should_sync: true }, { should_sync: false }] },+ { id: 'b', schemas: [] },+ ],+ })+ .mockResolvedValueOnce({+ next: null,+ results: [{ id: 'c', schemas: [{ should_sync: true }, { should_sync: true }] }],+ })++ logic.mount()+ await expectLogic(logic).toFinishAllListeners()++ expect(logic.values.syncingTableCount).toEqual(3)+ expect(wsApi.externalDataSourcesList).toHaveBeenNthCalledWith(1, expect.anything(), { limit: 100, offset: 0 })+ expect(wsApi.externalDataSourcesList).toHaveBeenNthCalledWith(2, expect.anything(), { limit: 100, offset: 2 })+ })})diff --git a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.ts b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.tsindex d4725b289af6..2c2ca406bf7e 100644--- a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.ts+++ b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.ts@@ -12,7 +12,7 @@ import {} from 'kea'import { loaders } from 'kea-loaders'-import { loadAppMetricsTotals } from 'lib/components/AppMetrics/appMetricsLogic'+import { type AppMetricsTimeSeriesResponse, loadAppMetricsTimeSeries } from 'lib/components/AppMetrics/appMetricsLogic'import { dayjs } from 'lib/dayjs'import { teamLogic } from 'scenes/teamLogic'@@ -32,8 +32,14 @@ import type {PipelineJobStatsResponseApi,PipelineRowsStatsResponseApi,} from 'products/data_warehouse/frontend/generated/api.schemas'-import { externalDataDestinationsList } from 'products/warehouse_sources/frontend/generated/api'-import type { ExternalDataDestinationApi } from 'products/warehouse_sources/frontend/generated/api.schemas'+import {+ externalDataDestinationsList,+ externalDataSourcesList,+} from 'products/warehouse_sources/frontend/generated/api'+import type {+ ExternalDataDestinationApi,+ ExternalDataSourceSerializersApi,+} from 'products/warehouse_sources/frontend/generated/api.schemas'/** Windows `job_stats` accepts. Anything else is a 400. */export type PipelineStatsWindow = 1 | 7 | 30@@ -83,9 +89,12 @@ export interface pipelineOverviewSceneLogicValues {failedRuns: PipelineActivityRowApi[]destinations: ExternalDataDestinationApi[] | nulldestinationsLoading: boolean- destinationRowTotals: Record<string, { total: number }> | null- destinationRowTotalsLoading: boolean- rowsByDestination: { id: string; name: string; type: string; rows: number }[]+ sources: ExternalDataSourceSerializersApi[] | null+ sourcesLoading: boolean+ syncingTableCount: number+ destinationRowSeries: AppMetricsTimeSeriesResponse | null+ destinationRowSeriesLoading: boolean+ rowsByDestination: { key: string; label: string; data: number[]; type: 'area'; fill: { opacity: number } }[]hasIssues: booleanloadingFirstTime: boolean}@@ -97,7 +106,8 @@ export interface pipelineOverviewSceneLogicActions {loadHealthIssues: () => anyloadRecentFailures: () => anyloadDestinations: () => any- loadDestinationRowTotals: () => any+ loadSources: () => any+ loadDestinationRowSeries: () => anyrefresh: () => { value: true }loadEverything: () => { value: true }pollStats: () => { value: true }@@ -161,23 +171,41 @@ export const pipelineOverviewSceneLogic = kea<pipelineOverviewSceneLogicType>([* alone — so a raw `instance_id` breakdown mixes all three. The destination-keyed rows* are picked out in `rowsByDestination` by matching against the team's real destinations.*/- destinationRowTotals: [- null as Record<string, { total: number }> | null,+ sources: [+ null as ExternalDataSourceSerializersApi[] | null,+ {+ loadSources: async () => {+ const sources: ExternalDataSourceSerializersApi[] = []+ let offset = 0+ let hasNextPage = true++ while (hasNextPage) {+ const page = await externalDataSourcesList(String(values.currentTeamId), { limit: 100, offset })+ sources.push(...(page.results ?? []))+ offset += page.results?.length ?? 0+ hasNextPage = Boolean(page.next) && (page.results?.length ?? 0) > 0+ }++ return sources+ },+ },+ ],+ destinationRowSeries: [+ null as AppMetricsTimeSeriesResponse | null,{- loadDestinationRowTotals: async () =>- await loadAppMetricsTotals(+ loadDestinationRowSeries: async () =>+ await loadAppMetricsTimeSeries({appSource: WAREHOUSE_APP_SOURCE,metricName: 'rows_synced',- breakdownBy: ['instance_id'],+ breakdownBy: 'instance_id',+ // An hourly grain over a day keeps the 24-hour window from collapsing+ // to a single point.+ interval: values.window === 1 ? 'hour' : 'day',// Both bounds are interpolated into `toDateTime(...)`, so they have to- // be absolute timestamps. The upper bound sits an hour ahead because- // the comparison is exclusive and rows land continuously.+ // be absolute timestamps.dateFrom: dayjs().subtract(values.window, 'day').toISOString(),- dateTo: dayjs().add(1, 'hour').toISOString(),- // Bounded so a team with many schemas cannot silently truncate the- // destination rows out of the result.- limit: 500,+ dateTo: dayjs().toISOString(),},values.currentTeam?.timezone ?? 'UTC'),@@ -189,6 +217,9 @@ export const pipelineOverviewSceneLogic = kea<pipelineOverviewSceneLogicType>([loadRecentFailures: async () =>await dataWarehouseCompletedActivityRetrieve(String(values.currentTeamId), {outcome: 'failed',+ // The window control sits in this section's own header. Without this the+ // endpoint falls back to its own 30-day default and ignores the control.+ cutoff_days: values.window,// Over-fetch: the endpoint has no sync-only filter, so view runs are// dropped client-side and a page of them would otherwise show nothing.limit: 50,@@ -213,27 +244,59 @@ export const pipelineOverviewSceneLogic = kea<pipelineOverviewSceneLogicType>([(healthIssues: DataHealthIssuesResponseApi | null): number =>(healthIssues?.results ?? []).filter((issue) => issue.type === 'external_data_sync').length,],- /** Rows written per destination over the window, biggest first. */+ /**+ * One chart series per destination, biggest first so the legend order matches the stack.+ * `rows_for` emits `rows_synced` under three instance ids per run — the schema, the+ * destination, and `<schema>/<destination>` — so only ids matching a real destination are+ * kept, which drops the schema-level and combined rows rather than double counting them.+ */rowsByDestination: [- (s: any) => [s.destinationRowTotals, s.destinations],+ (s: any) => [s.destinationRowSeries, s.destinations],(- totals: Record<string, { total: number }> | null,+ series: AppMetricsTimeSeriesResponse | null,destinations: ExternalDataDestinationApi[] | null- ): { id: string; name: string; type: string; rows: number }[] => {- if (!totals || !destinations) {+ ): {+ key: string+ label: string+ data: number[]+ type: 'area'+ fill: { opacity: number }+ }[] => {+ if (!series || !destinations) {return []}- return destinations- .map((destination) => ({- id: destination.id,- name: destination.name,- type: destination.type,- rows: totals[destination.id]?.total ?? 0,+ const byId = new Map(destinations.map((d) => [d.id, d]))+ return series.series+ .filter((s) => byId.has(s.name))+ .map((s) => ({+ key: s.name,+ label: byId.get(s.name)?.name ?? s.name,+ data: s.values,+ type: 'area' as const,+ // `fill` is what makes an area series fill; `type` alone draws a line.+ // The chart stacks area series and offers no way not to, so the section+ // copy says the total is row-writes rather than rows.+ fill: { opacity: 0.25 },+ total: s.values.reduce((a, b) => a + b, 0),}))- .filter((row) => row.rows > 0)- .sort((a, b) => b.rows - a.rows)+ .sort((a, b) => b.total - a.total)+ .map(({ total: _total, ...rest }) => rest)},],+ /**+ * Tables PostHog imports on a schedule. Counts schemas switched on rather than every+ * schema a source offers, so it matches what the pipeline actually runs.+ */+ syncingTableCount: [+ (s: any) => [s.sources],+ (sources: ExternalDataSourceSerializersApi[] | null): number =>+ (sources ?? []).reduce(+ (total, source) =>+ total ++ ((source.schemas ?? []) as { should_sync?: boolean }[]).filter((s) => s.should_sync).length,+ 0+ ),+ ],/** Whether anything is wrong. The health section is hidden when nothing is. */hasIssues: [(s: any) => [s.issuesBySeverity], (issues: DataHealthIssueApi[]): boolean => issues.length > 0],failedRuns: [@@ -254,11 +317,12 @@ export const pipelineOverviewSceneLogic = kea<pipelineOverviewSceneLogicType>([],}),listeners(({ actions }: any) => ({- // Only the run counts are windowed. Rows are reported per billing period and health is- // current state, so neither changes with the window.+ // Health is current state and rows are reported per billing period, so neither is+ // windowed. Everything else is.setWindow: () => {actions.loadJobStats()- actions.loadDestinationRowTotals()+ actions.loadDestinationRowSeries()+ actions.loadRecentFailures()},refresh: () => actions.loadEverything(),loadEverything: () => {@@ -267,7 +331,8 @@ export const pipelineOverviewSceneLogic = kea<pipelineOverviewSceneLogicType>([actions.loadHealthIssues()actions.loadRecentFailures()actions.loadDestinations()- actions.loadDestinationRowTotals()+ actions.loadSources()+ actions.loadDestinationRowSeries()},// Only the headline numbers poll. Reloading the tables under someone mid-read moves rows// they are looking at, and they change far less often than the counts do.