: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 destination chart and show every sync run (#109775)
Tom Owersbaf2cc36c8d0
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex a90e138f7fce..3446b3d42d16 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -9543,13 +9543,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.089b369b2c14ad62186846aeac2ba199350bbeb5938006a990813e86d2fe792f.azI7UlC6LJfxK7oem6akS12yttmxtUrAz2PgfjOGnAY+ hash: v1.k794b7964.37c9a1fc5b577570e5e9b335d39c3d5ecdcffb1a79869be4c15b75fac4d08e5b.Kgr83CF5IOkKAdyHYcofo29cTHn0tlLMNOx9xlfhCB0scenes-app-etl--healthy--light:- hash: v1.k794b7964.67c3c8bf986874ac2693e23f437912b8bb6413c6cbadc94a6d64f66367f934a5.uXG2VLv-329pEEzeWTK9fdpDOkzxlHxHV10dACQf-w4+ hash: v1.k794b7964.a101fbf2bb7570eabb56a2dd2a7b536f103f544ec1db0fe859c568c8e439828e.r3rhY6vYx3o1WC80g6MO8X8OiEuStYShcFzaCvqKO80scenes-app-etl--needs-attention--dark:- hash: v1.k794b7964.a692bc11bcb8f43aacf00cbb903710fa4e3a206af239753d259009b65d15fbe2.twpUxi4BgMP4HedYol3gY2Fv3UFrCg3L5ZNXkKo9irE+ hash: v1.k794b7964.088f22663ddc7743a45263b97b06c63475f440b0553af54a9988593b394515e1.gf50EpD2gDMAKHLvHe08xAjgTN7RUxzejQ2XvGr3q9cscenes-app-etl--needs-attention--light:- hash: v1.k794b7964.b5d11ee783dc6a1d388ea3df499d22a9c81bf0b5bed8741a5dd0b8ab0f9a455b.9wG3DFbZidOv5H33JDzkCqs7m3mYeaSJb8peEZu564s+ hash: v1.k794b7964.ece2af8c07b1e69d0a885ea37d63f7aeac57ac4b71702c46ee49feb133cde67f.0ZbyBXdGqfTo1qTzbqyYsOg08ePKZKveJTcFKz56bsgscenes-app-events--event-explorer--dark:hash: v1.k794b7964.3bf3b01d0972be5ad8fe4a7408d20b10e2431ea8f28874aa0a63f7623c1af97c.ONFJgVNjjG1f32eqlxRZuleSgdLpLGIcFhHN2S4yvhkscenes-app-events--event-explorer--light:diff --git a/products/data_warehouse/backend/presentation/pipeline_stats.py b/products/data_warehouse/backend/presentation/pipeline_stats.pyindex 45643d5833e9..078ac5d4e233 100644--- a/products/data_warehouse/backend/presentation/pipeline_stats.py+++ b/products/data_warehouse/backend/presentation/pipeline_stats.py@@ -37,12 +37,28 @@ class PipelineActivityQuerySerializer(serializers.Serializer):)+class RunningActivityQuerySerializer(PipelineActivityQuerySerializer):+ kind = serializers.ChoiceField(+ choices=["all", "import", "model"],+ required=False,+ default="all",+ help_text=(+ "Which runs to return: 'import' for warehouse source syncs, 'model' for materialized "+ "view runs, 'all' for both. Defaults to 'all'."+ ),+ )++class CompletedActivityQuerySerializer(PipelineActivityQuerySerializer):outcome = serializers.ChoiceField(- choices=["completed", "failed"],+ choices=["completed", "failed", "all"],required=False,default="completed",- help_text="Which outcome to return: 'completed' or 'failed'. Defaults to 'completed'.",+ help_text=(+ "Which outcome to return: 'completed', 'failed', or 'all' for every run that "+ "finished either way. Defaults to 'completed'. Running jobs come from "+ "`running_activity` instead."+ ),)kind = serializers.ChoiceField(choices=["all", "import", "model"],@@ -121,6 +137,11 @@ class PipelineActivityRowSerializer(serializers.Serializer):latest_error = serializers.CharField(allow_null=True, help_text="Error the run ended with, if any.")workflow_run_id = serializers.CharField(allow_null=True, help_text="Temporal run id, for finding the run's logs.")origin = serializers.CharField(allow_null=True, help_text="Where a materialized view came from. Null for syncs.")+ source_id = serializers.CharField(+ allow_null=True,+ required=False,+ help_text="Id of the source the run belongs to, for linking to it. Null for model runs.",+ )class PipelineActivityResponseSerializer(serializers.Serializer):diff --git a/products/data_warehouse/backend/presentation/views/data_warehouse.py b/products/data_warehouse/backend/presentation/views/data_warehouse.pyindex 9af996ff7174..91062a91c3c4 100644--- a/products/data_warehouse/backend/presentation/views/data_warehouse.py+++ b/products/data_warehouse/backend/presentation/views/data_warehouse.py@@ -63,6 +63,7 @@ from products.data_warehouse.backend.presentation.pipeline_stats import (PipelineErrorSerializer,PipelineJobStatsResponseSerializer,PipelineRowsStatsResponseSerializer,+ RunningActivityQuerySerializer,)from products.managed_warehouse.backend.presentation import views as managed_warehousefrom products.warehouse_sources.backend.facade.hogql import get_view_or_table_by_name@@ -175,6 +176,7 @@ FAILED_EXTERNAL_JOB_STATUSES = [# this is one parameter rather than a second near-copy of the union query.ACTIVITY_OUTCOME_COMPLETED = "completed"ACTIVITY_OUTCOME_FAILED = "failed"+ACTIVITY_OUTCOME_ALL = "all"ACTIVITY_KIND_ALL = "all"ACTIVITY_KIND_IMPORT = "import"@@ -190,6 +192,12 @@ ACTIVITY_OUTCOME_STATUSES: dict[str, tuple[list[str], list[str]]] = {list(FAILED_EXTERNAL_JOB_STATUSES),[DataModelingJob.Status.FAILED],),+ # Every run that finished, however it finished. Running jobs are not here; they come+ # from `running_activity`.+ ACTIVITY_OUTCOME_ALL: (+ [ExternalDataJobStatus.COMPLETED, *FAILED_EXTERNAL_JOB_STATUSES],+ [DataModelingJob.Status.COMPLETED, DataModelingJob.Status.FAILED],+ ),}@@ -458,10 +466,11 @@ class DataWarehouseViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):return breakdown@extend_schema(+ parameters=[RunningActivityQuerySerializer],responses={200: PipelineActivityResponseSerializer,500: OpenApiResponse(response=PipelineErrorSerializer, description="The activity query failed."),- }+ },)@action(methods=["GET"], detail=False)def running_activity(self, request: Request, **kwargs) -> Response:@@ -469,6 +478,13 @@ class DataWarehouseViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):Returns currently running activities (jobs with status 'Running').Supports pagination and cutoff time filtering."""+ kind = request.GET.get("kind", ACTIVITY_KIND_ALL)+ if kind not in ACTIVITY_KINDS:+ supported = ", ".join(sorted(ACTIVITY_KINDS))+ return Response(+ {"error": f"Invalid kind parameter. Must be one of: {supported}."},+ status=status.HTTP_400_BAD_REQUEST,+ )DEFAULT_LIMIT = 20MAX_LIMIT = 50DEFAULT_CUTOFF_DAYS = 30@@ -498,7 +514,7 @@ class DataWarehouseViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):SELECT edj.id, edsrc.source_type as type, eds.name, edj.status,COALESCE(edj.rows_synced, 0) as rows, edj.created_at,edj.finished_at, edj.latest_error, edj.workflow_run_id,- null as origin+ null as origin, edj.pipeline_id as source_idFROM posthog_externaldatajob edjLEFT JOIN posthog_externaldataschema eds ON edj.schema_id = eds.idLEFT JOIN posthog_externaldatasource edsrc ON eds.source_id = edsrc.id@@ -510,15 +526,17 @@ class DataWarehouseViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):SELECT dmj.id, 'Materialized view' as type, dwsq.name, dmj.status,COALESCE(dmj.rows_materialized, 0) as rows, dmj.created_at,dmj.last_run_at as finished_at, dmj.error as latest_error, dmj.workflow_run_id,- dwsq.origin as origin+ dwsq.origin as origin, null::uuid as source_idFROM posthog_datamodelingjob dmjLEFT JOIN posthog_datawarehousesavedquery dwsq ON dmj.saved_query_id = dwsq.idWHERE dmj.team_id = %s AND dmj.status = 'Running' AND dmj.created_at >= %sAND (dwsq.id IS NULL OR dwsq.id = ANY(%s::uuid[])))SELECT * FROM external_jobs+ WHERE %s IN (%s, %s)UNION ALLSELECT * FROM modeling_jobs+ WHERE %s IN (%s, %s)ORDER BY created_at DESCLIMIT %s OFFSET %s""",@@ -530,6 +548,14 @@ class DataWarehouseViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):self.team_id,cutoff_time,saved_query_ids,+ # Placeholders bind in SQL text order, so both kind filters come after+ # every CTE parameter, not next to the CTE they read.+ kind,+ ACTIVITY_KIND_ALL,+ ACTIVITY_KIND_IMPORT,+ kind,+ ACTIVITY_KIND_ALL,+ ACTIVITY_KIND_MODEL,limit + 1,offset,],@@ -621,7 +647,7 @@ class DataWarehouseViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):SELECT edj.id, edsrc.source_type as type, eds.name, edj.status,COALESCE(edj.rows_synced, 0) as rows, edj.created_at,edj.finished_at, edj.latest_error, edj.workflow_run_id,- null as origin+ null as origin, edj.pipeline_id as source_idFROM posthog_externaldatajob edjLEFT JOIN posthog_externaldataschema eds ON edj.schema_id = eds.idLEFT JOIN posthog_externaldatasource edsrc ON eds.source_id = edsrc.id@@ -633,7 +659,7 @@ class DataWarehouseViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):SELECT dmj.id, 'Materialized view' as type, dwsq.name, dmj.status,COALESCE(dmj.rows_materialized, 0) as rows, dmj.created_at,dmj.last_run_at as finished_at, dmj.error as latest_error, dmj.workflow_run_id,- dwsq.origin+ dwsq.origin, null::uuid as source_idFROM posthog_datamodelingjob dmjLEFT JOIN posthog_datawarehousesavedquery dwsq ON dmj.saved_query_id = dwsq.idWHERE dmj.team_id = %s AND dmj.status = ANY(%s) AND dmj.created_at >= %sdiff --git a/products/data_warehouse/backend/tests/api/test_data_warehouse.py b/products/data_warehouse/backend/tests/api/test_data_warehouse.pyindex bab369bc98ac..6f427907a876 100644--- a/products/data_warehouse/backend/tests/api/test_data_warehouse.py+++ b/products/data_warehouse/backend/tests/api/test_data_warehouse.py@@ -289,6 +289,50 @@ class TestDataWarehouseAPI(APIBaseTest):self.assertTrue(all(row["type"] == "Materialized view" for row in models))self.assertEqual(len(both), len(imports) + len(models))+ def test_completed_activity_all_outcome_returns_both(self) -> None:+ # The ETL runs list shows every sync, not only the failures, so a caller needs one+ # request that spans both rather than two it has to merge.+ endpoint = f"/api/projects/{self.team.id}/data_warehouse/completed_activity"+ source = ExternalDataSource.objects.create(+ source_id="both-id",+ connection_id="conn-id",+ destination_id="dest-id",+ team=self.team,+ source_type="Stripe",+ )+ schema = ExternalDataSchema.objects.create(name="charges", team=self.team, source=source)+ ExternalDataJob.objects.create(+ pipeline_id=source.pk, schema=schema, team=self.team, rows_synced=5, status="Completed"+ )+ ExternalDataJob.objects.create(+ pipeline_id=source.pk, schema=schema, team=self.team, rows_synced=0, status="Failed"+ )++ statuses = {row["status"] for row in self.client.get(f"{endpoint}?outcome=all").json()["results"]}++ self.assertIn("Completed", statuses)+ self.assertIn("Failed", statuses)++ def test_completed_activity_reports_the_source_id(self) -> None:+ # Without this the runs list cannot link a run back to its source.+ endpoint = f"/api/projects/{self.team.id}/data_warehouse/completed_activity"+ source = ExternalDataSource.objects.create(+ source_id="link-id",+ connection_id="conn-id",+ destination_id="dest-id",+ team=self.team,+ source_type="Stripe",+ )+ schema = ExternalDataSchema.objects.create(name="charges", team=self.team, source=source)+ ExternalDataJob.objects.create(+ pipeline_id=source.pk, schema=schema, team=self.team, rows_synced=5, status="Completed"+ )++ results = self.client.get(f"{endpoint}?outcome=completed&kind=import").json()["results"]++ self.assertEqual(len(results), 1)+ self.assertEqual(results[0]["source_id"], str(source.id))+def test_completed_activity_rejects_an_unknown_kind(self) -> None:endpoint = f"/api/projects/{self.team.id}/data_warehouse/completed_activity"response = self.client.get(f"{endpoint}?kind=nonsense")@@ -599,6 +643,27 @@ class TestDataWarehouseAPI(APIBaseTest):self.assertIn("Stripe", types)self.assertIn("Materialized view", types)+ def test_activity_uses_pipeline_id_for_schema_less_jobs(self):+ source = ExternalDataSource.objects.create(+ source_id="test-id", connection_id="conn-id", destination_id="dest-id", team=self.team, source_type="Stripe"+ )+ running_job = ExternalDataJob.objects.create(+ pipeline=source, schema=None, team=self.team, status=ExternalDataJob.Status.RUNNING+ )+ completed_job = ExternalDataJob.objects.create(+ pipeline=source, schema=None, team=self.team, status=ExternalDataJob.Status.COMPLETED+ )++ running_response = self.client.get(f"/api/projects/{self.team.id}/data_warehouse/running_activity?kind=import")+ completed_response = self.client.get(+ f"/api/projects/{self.team.id}/data_warehouse/completed_activity?kind=import"+ )++ self.assertEqual(running_response.json()["results"][0]["id"], str(running_job.id))+ self.assertEqual(running_response.json()["results"][0]["source_id"], str(source.id))+ self.assertEqual(completed_response.json()["results"][0]["id"], str(completed_job.id))+ self.assertEqual(completed_response.json()["results"][0]["source_id"], str(source.id))+def test_completed_activity_returns_only_completed_jobs(self):"""Test completed_activity endpoint returns only jobs with status 'Completed'"""endpoint = f"/api/projects/{self.team.id}/data_warehouse/completed_activity"diff --git a/products/data_warehouse/frontend/generated/api.schemas.ts b/products/data_warehouse/frontend/generated/api.schemas.tsindex 2c360e43e5fb..0d1e7b7087da 100644--- a/products/data_warehouse/frontend/generated/api.schemas.ts+++ b/products/data_warehouse/frontend/generated/api.schemas.ts@@ -130,6 +130,11 @@ export interface PipelineActivityRowApi {* @nullable*/origin: string | null+ /**+ * Id of the source the run belongs to, for linking to it. Null for model runs.+ * @nullable+ */+ source_id?: string | null}export interface PipelineActivityResponseApi {@@ -5299,10 +5304,11 @@ export type DataWarehouseCompletedActivityRetrieveParams = {*/offset?: number/**- * Which outcome to return: 'completed' or 'failed'. Defaults to 'completed'.+ * Which outcome to return: 'completed', 'failed', or 'all' for every run that finished either way. Defaults to 'completed'. Running jobs come from `running_activity` instead.** * `completed` - completed* * `failed` - failed+ * * `all` - all* @minLength 1*/outcome?: DataWarehouseCompletedActivityRetrieveOutcome@@ -5323,6 +5329,7 @@ export type DataWarehouseCompletedActivityRetrieveOutcome =export const DataWarehouseCompletedActivityRetrieveOutcome = {Completed: 'completed',Failed: 'failed',+ All: 'all',} as constexport type DataWarehouseJobStatsRetrieveParams = {@@ -5407,6 +5414,39 @@ export type DataWarehouseManagedWarehouseSourceSchemasRetrieveParams = {source_id: string}+export type DataWarehouseRunningActivityRetrieveParams = {+ /**+ * Only include runs created within this many days of now. Defaults to 30.+ */+ cutoff_days?: number+ /**+ * Which runs to return: 'import' for warehouse source syncs, 'model' for materialized view runs, 'all' for both. Defaults to 'all'.+ *+ * * `all` - all+ * * `import` - import+ * * `model` - model+ * @minLength 1+ */+ kind?: DataWarehouseRunningActivityRetrieveKind+ /**+ * Max rows to return. Capped at 50 server-side. Defaults to 20.+ */+ limit?: number+ /**+ * Rows to skip, for pagination. Defaults to 0.+ */+ offset?: number+}++export type DataWarehouseRunningActivityRetrieveKind =+ (typeof DataWarehouseRunningActivityRetrieveKind)[keyof typeof DataWarehouseRunningActivityRetrieveKind]++export const DataWarehouseRunningActivityRetrieveKind = {+ All: 'all',+ Import: 'import',+ Model: 'model',+} as const+export type FixHogqlListParams = {/*** Number of results to return per page.diff --git a/products/data_warehouse/frontend/generated/api.ts b/products/data_warehouse/frontend/generated/api.tsindex 5bc72816e4ac..b461ae049bbd 100644--- a/products/data_warehouse/frontend/generated/api.ts+++ b/products/data_warehouse/frontend/generated/api.ts@@ -27,6 +27,7 @@ import type {DataWarehouseManagedViewSetUpdateResponseApi,DataWarehouseManagedWarehouseMonitoringTimeseriesRetrieveParams,DataWarehouseManagedWarehouseSourceSchemasRetrieveParams,+ DataWarehouseRunningActivityRetrieveParams,DataWarehouseSavedQueryApi,DataWarehouseSavedQueryColumnAnnotationApi,DataWarehouseSavedQueryDraftApi,@@ -631,8 +632,23 @@ export const dataWarehouseResetPasswordCreate = async (})}-export const getDataWarehouseRunningActivityRetrieveUrl = (projectId: string) => {- return `/api/projects/${projectId}/data_warehouse/running_activity/`+export const getDataWarehouseRunningActivityRetrieveUrl = (+ projectId: string,+ params?: DataWarehouseRunningActivityRetrieveParams+) => {+ const normalizedParams = new URLSearchParams()++ Object.entries(params || {}).forEach(([key, value]) => {+ if (value !== undefined) {+ normalizedParams.append(key, value === null ? 'null' : String(value))+ }+ })++ const stringifiedParams = normalizedParams.toString()++ return stringifiedParams.length > 0+ ? `/api/projects/${projectId}/data_warehouse/running_activity/?${stringifiedParams}`+ : `/api/projects/${projectId}/data_warehouse/running_activity/`}/**@@ -641,9 +657,10 @@ export const getDataWarehouseRunningActivityRetrieveUrl = (projectId: string) =>*/export const dataWarehouseRunningActivityRetrieve = async (projectId: string,+ params?: DataWarehouseRunningActivityRetrieveParams,options?: RequestInit): Promise<PipelineActivityResponseApi> => {- return apiMutator<PipelineActivityResponseApi>(getDataWarehouseRunningActivityRetrieveUrl(projectId), {+ return apiMutator<PipelineActivityResponseApi>(getDataWarehouseRunningActivityRetrieveUrl(projectId, params), {...options,method: 'GET',})diff --git a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.stories.tsx b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.stories.tsxindex 80729505d967..95527964449b 100644--- a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.stories.tsx+++ b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.stories.tsx@@ -84,6 +84,7 @@ const FAILED_RUNS = {latest_error: 'Authentication error: expired API key',workflow_run_id: 'wf-1',origin: null,+ source_id: '1',},{id: 'run-2',@@ -96,6 +97,27 @@ const FAILED_RUNS = {latest_error: 'Schema drift: column "forecast_category" changed type text to numeric',workflow_run_id: 'wf-2',origin: null,+ source_id: '2',+ },+ ],+}++const RUNNING_RUNS = {+ next: null,+ previous: null,+ results: [+ {+ id: 'run-3',+ type: 'Stripe',+ name: 'customers',+ status: 'Running',+ rows: 0,+ created_at: '2026-09-25T09:00:00Z',+ finished_at: null,+ latest_error: null,+ workflow_run_id: 'wf-3',+ origin: null,+ source_id: '1',},],}@@ -154,6 +176,7 @@ function mocks(health: Record<string, unknown>, runs: Record<string, unknown>):'/api/projects/:team_id/data_warehouse/total_rows_stats': ROWS_STATS,'/api/projects/:team_id/data_warehouse/data_health_issues': health,'/api/projects/:team_id/data_warehouse/completed_activity': runs,+ '/api/projects/:team_id/data_warehouse/running_activity': RUNNING_RUNS,'/api/projects/:team_id/external_data_sources': SOURCES,'/api/projects/:team_id/external_data_sources/wizard': {},'/api/projects/:team_id/external_data_destinations': DESTINATIONS,@@ -172,6 +195,10 @@ const meta: Meta<typeof PipelineOverviewScene> = {viewMode: 'story',// The scene refuses to render without this, so every story has to carry it.featureFlags: [FEATURE_FLAGS.WAREHOUSE_MULTI_DESTINATION],+ testOptions: {+ waitForLoadersToDisappear: false,+ waitForSelector: '[data-attr="etl-run-view-source"]',+ },},}export default metadiff --git a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.tsx b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.tsxindex c02c4bb37003..bf1f4b897d58 100644--- a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.tsx+++ b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/PipelineOverviewScene.tsx@@ -22,7 +22,7 @@ import { PipelineHealth } from './PipelineHealth'import type { PipelineStatsWindow } from './pipelineOverviewSceneLogic'import { pipelineOverviewSceneLogic } from './pipelineOverviewSceneLogic'import { PipelineStatTiles } from './PipelineStatTiles'-import { RecentFailures } from './RecentFailures'+import { RecentRuns } from './RecentRuns'import { RowsByDestination } from './RowsByDestination'export const scene: SceneExport = {@@ -94,9 +94,17 @@ export function PipelineOverviewScene(): JSX.Element {</>) : null}+ <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>++ <SceneDivider /><SceneSectiontitle="Runs"- description="Runs that failed in this window. A table can be broken here with no recent run, if nothing retried it."+ description="Every sync in this window, newest first. Runs in flight appear as they start."actions={<LemonSelect<PipelineStatsWindow>size="small"@@ -111,16 +119,7 @@ export function PipelineOverviewScene(): JSX.Element {/>}>- <RecentFailures />- </SceneSection>-- <SceneDivider />-- <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 />+ <RecentRuns /></SceneSection><SceneDivider />diff --git a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/RecentFailures.tsx b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/RecentFailures.tsxdeleted file mode 100644index 161c6d174946..000000000000--- a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/RecentFailures.tsx+++ /dev/null@@ -1,70 +0,0 @@-import { useValues } from 'kea'--import { LemonSkeleton, LemonTable, LemonTag } from '@posthog/lemon-ui'--import { TZLabel } from 'lib/components/TZLabel'--import type { PipelineActivityRowApi } from 'products/data_warehouse/frontend/generated/api.schemas'--import { pipelineOverviewSceneLogic } from './pipelineOverviewSceneLogic'--export function RecentFailures(): JSX.Element {- const { failedRuns, recentFailures, recentFailuresLoading } = useValues(pipelineOverviewSceneLogic)-- if (recentFailuresLoading && recentFailures === null) {- return <LemonSkeleton className="h-24 w-full" />- }-- if (recentFailures !== null && failedRuns.length === 0) {- return (- <div className="rounded border border-primary bg-surface-primary px-4 py-6 text-center text-muted">- No runs have failed recently.- </div>- )- }-- return (- <LemonTable<PipelineActivityRowApi>- id="etl-recent-failures"- dataSource={failedRuns}- rowKey="id"- size="small"- loading={recentFailuresLoading && recentFailures !== null}- nouns={['run', 'runs']}- columns={[- {- title: 'Table',- key: 'name',- render: (_, run) => (- <div className="flex min-w-0 flex-col">- <span className="truncate font-medium">{run.name ?? 'Unnamed'}</span>- <span className="text-xs text-muted">{run.type ?? 'Unknown'}</span>- </div>- ),- },- {- title: 'Status',- key: 'status',- width: 150,- render: (_, run) => <LemonTag type="danger">{run.status}</LemonTag>,- },- {- title: 'Error',- key: 'latest_error',- render: (_, run) =>- run.latest_error ? (- <span className="line-clamp-2 font-mono text-xs text-secondary">{run.latest_error}</span>- ) : (- <span className="text-muted">—</span>- ),- },- {- title: 'When',- key: 'created_at',- width: 140,- render: (_, run) => <TZLabel time={run.created_at} />,- },- ]}- />- )-}diff --git a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/RecentRuns.tsx b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/RecentRuns.tsxnew file mode 100644index 000000000000..f7d05bfe887f--- /dev/null+++ b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/RecentRuns.tsx@@ -0,0 +1,126 @@+import { useValues } from 'kea'++import { LemonButton, LemonSkeleton, LemonTable, LemonTag, Spinner } from '@posthog/lemon-ui'+import type { LemonTagType } from '@posthog/lemon-ui'++import { TZLabel } from 'lib/components/TZLabel'+import { humanFriendlyNumber } from 'lib/utils/numbers'+import { urls } from 'scenes/urls'++import type { PipelineActivityRowApi } from 'products/data_warehouse/frontend/generated/api.schemas'++import { pipelineOverviewSceneLogic } from './pipelineOverviewSceneLogic'++const STATUS_TAG_TYPES: Record<string, LemonTagType> = {+ Running: 'primary',+ Completed: 'success',+ Failed: 'danger',+ BillingLimitReached: 'warning',+ BillingLimitTooLow: 'warning',+}++const STATUS_LABELS: Record<string, string> = {+ BillingLimitReached: 'Billing limit',+ BillingLimitTooLow: 'Billing limit',+}++export function RecentRuns(): JSX.Element {+ const { recentRunRows, recentRuns, recentRunsLoading } = useValues(pipelineOverviewSceneLogic)++ if (recentRunsLoading && recentRuns === null) {+ return <LemonSkeleton className="h-24 w-full" />+ }++ if (recentRuns !== null && recentRunRows.length === 0) {+ return (+ <div className="rounded border border-primary bg-surface-primary px-4 py-6 text-center text-muted">+ No syncs have run in this window.+ </div>+ )+ }++ return (+ <LemonTable<PipelineActivityRowApi>+ id="etl-recent-runs"+ dataSource={recentRunRows}+ rowKey="id"+ size="small"+ loading={recentRunsLoading && recentRuns !== null}+ nouns={['run', 'runs']}+ columns={[+ {+ title: 'Table',+ key: 'name',+ render: (_, run) => (+ <div className="flex min-w-0 flex-col">+ <span className="truncate font-medium">{run.name ?? 'Unnamed'}</span>+ <span className="text-xs text-muted">{run.type ?? 'Unknown'}</span>+ </div>+ ),+ },+ {+ title: 'Status',+ key: 'status',+ width: 140,+ render: (_, run) => (+ <span className="flex items-center gap-1.5">+ {run.status === 'Running' ? <Spinner className="text-sm" /> : null}+ <LemonTag type={STATUS_TAG_TYPES[run.status] ?? 'default'}>+ {STATUS_LABELS[run.status] ?? run.status}+ </LemonTag>+ </span>+ ),+ },+ {+ title: 'Rows',+ key: 'rows',+ align: 'right',+ width: 90,+ // A running job has not reported its rows yet, so a zero would read as+ // "moved nothing" rather than "still going".+ render: (_, run) =>+ run.status === 'Running' ? (+ <span className="text-muted">—</span>+ ) : (+ <span className="tabular-nums">{humanFriendlyNumber(run.rows ?? 0)}</span>+ ),+ },+ {+ title: 'Error',+ key: 'latest_error',+ render: (_, run) =>+ run.latest_error ? (+ <span className="line-clamp-2 font-mono text-xs text-secondary">{run.latest_error}</span>+ ) : (+ <span className="text-muted">—</span>+ ),+ },+ {+ title: 'When',+ key: 'created_at',+ width: 140,+ render: (_, run) => <TZLabel time={run.created_at} />,+ },+ {+ title: '',+ key: 'actions',+ width: 80,+ render: (_, run) => {+ const sourceId = (run as { source_id?: string | null }).source_id+ // The source scene keys on a prefixed id; a bare UUID renders nothing.+ return sourceId ? (+ <LemonButton+ type="tertiary"+ size="xsmall"+ to={urls.dataWarehouseSource(`managed-${sourceId}`, 'syncs')}+ data-attr="etl-run-view-source"+ >+ View+ </LemonButton>+ ) : null+ },+ },+ ]}+ />+ )+}diff --git a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.test.ts b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.test.tsindex c83577a686b5..b9cbb8d20268 100644--- a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.test.ts+++ b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.test.ts@@ -9,6 +9,7 @@ jest.mock('products/data_warehouse/frontend/generated/api', () => ({dataWarehouseTotalRowsStatsRetrieve: jest.fn(),dataWarehouseDataHealthIssuesRetrieve: jest.fn(),dataWarehouseCompletedActivityRetrieve: jest.fn(),+ dataWarehouseRunningActivityRetrieve: jest.fn(),}))jest.mock('products/warehouse_sources/frontend/generated/api', () => ({@@ -44,6 +45,7 @@ describe('pipelineOverviewSceneLogic', () => {api.dataWarehouseTotalRowsStatsRetrieve.mockResolvedValue({ total_rows: 0 })api.dataWarehouseDataHealthIssuesRetrieve.mockResolvedValue({ results: [], count: 0 })api.dataWarehouseCompletedActivityRetrieve.mockResolvedValue({ results: [], next: null, previous: null })+ api.dataWarehouseRunningActivityRetrieve.mockResolvedValue({ results: [], next: null, previous: null })wsApi.externalDataDestinationsList.mockResolvedValue({ results: [] })wsApi.externalDataSourcesList.mockResolvedValue({ results: [] })metrics.loadAppMetricsTimeSeries.mockResolvedValue({ labels: [], interval: 'day', timezone: 'UTC', series: [] })@@ -136,20 +138,55 @@ describe('pipelineOverviewSceneLogic', () => {],})- await expectLogic(logic, () => logic.actions.loadRecentFailures()).toFinishAllListeners()+ await expectLogic(logic, () => logic.actions.loadRecentRuns()).toFinishAllListeners()- expect(logic.values.failedRuns.map((r: any) => r.id)).toEqual(['r2'])+ expect(logic.values.recentRunRows.map((r: any) => r.id)).toEqual(['r2'])})- it('asks for failed runs, not completed ones', async () => {- // Without the outcome parameter this endpoint returns successes, so the failures section- // would quietly list runs that worked.- await expectLogic(logic, () => logic.actions.loadRecentFailures()).toFinishAllListeners()+ it('asks for every finished run, plus the ones in flight', async () => {+ // The section lists all runs now, not only failures, and a sync that started seconds ago+ // has not finished — so it only appears if the running endpoint is asked too.+ api.dataWarehouseCompletedActivityRetrieve.mockResolvedValue({+ results: [{ id: 'done', type: 'Stripe', name: 'charges', status: 'Completed' }],+ next: null,+ previous: null,+ })+ api.dataWarehouseRunningActivityRetrieve.mockResolvedValue({+ results: [{ id: 'live', type: 'Stripe', name: 'invoices', status: 'Running' }],+ next: null,+ previous: null,+ })++ await expectLogic(logic, () => logic.actions.loadRecentRuns()).toFinishAllListeners()expect(api.dataWarehouseCompletedActivityRetrieve).toHaveBeenCalledWith(expect.anything(),- expect.objectContaining({ outcome: 'failed' })+ expect.objectContaining({ outcome: 'all' }))+ expect(api.dataWarehouseRunningActivityRetrieve).toHaveBeenCalledWith(+ expect.anything(),+ expect.objectContaining({ kind: 'import', cutoff_days: 7, limit: 50 })+ )+ // Running first, so what is happening now is at the top of the table.+ expect(logic.values.recentRunRows.map((r: any) => r.id)).toEqual(['live', 'done'])+ })++ it('prefers a finished run when it also appears in the running response', async () => {+ const run = { id: 'same', type: 'Stripe', name: 'charges' }+ api.dataWarehouseCompletedActivityRetrieve.mockResolvedValue({+ results: [{ ...run, status: 'Completed' }],+ next: null,+ previous: null,+ })+ api.dataWarehouseRunningActivityRetrieve.mockResolvedValue({+ results: [{ ...run, status: 'Running' }],+ next: null,+ previous: null,+ })++ await expectLogic(logic, () => logic.actions.loadRecentRuns()).toFinishAllListeners()++ expect(logic.values.recentRunRows).toEqual([expect.objectContaining({ id: 'same', status: 'Completed' })])})it('leaves the billing-period row total alone when the window changes', async () => {@@ -204,7 +241,10 @@ describe('pipelineOverviewSceneLogic', () => {const asked = metrics.loadAppMetricsTimeSeries.mock.calls.map(([request]: any[]) => request)expect(asked.map((r: any) => r.instanceId).sort()).toEqual(['dest-1', 'dest-2'])- expect(asked.every((r: any) => r.breakdownBy === undefined)).toBe(true)+ // The query interpolates `breakdownBy` with no fallback, so omitting it emits+ // `undefined AS breakdown` and the whole chart fails to load. This asserted the+ // omission before, which is how that shipped.+ expect(asked.every((r: any) => r.breakdownBy === 'instance_id')).toBe(true)// Both bounds go straight into `toDateTime(...)`, so a relative string or a missing// `dateTo` makes the query throw instead of returning rows.asked.forEach((r: any) => {@@ -241,7 +281,7 @@ describe('pipelineOverviewSceneLogic', () => {expect(api.dataWarehouseCompletedActivityRetrieve).toHaveBeenCalledWith(expect.anything(),- expect.objectContaining({ outcome: 'failed', kind: 'import' })+ expect.objectContaining({ outcome: 'all', kind: 'import' }))})diff --git a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.ts b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.tsindex 9065db5ce817..ae443d2e13d6 100644--- a/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.ts+++ b/products/warehouse_sources/frontend/scenes/PipelineOverviewScene/pipelineOverviewSceneLogic.ts@@ -20,6 +20,7 @@ import { Breadcrumb } from '~/types'import {dataWarehouseCompletedActivityRetrieve,+ dataWarehouseRunningActivityRetrieve,dataWarehouseDataHealthIssuesRetrieve,dataWarehouseJobStatsRetrieve,dataWarehouseTotalRowsStatsRetrieve,@@ -27,7 +28,6 @@ import {import type {DataHealthIssueApi,DataHealthIssuesResponseApi,- PipelineActivityResponseApi,PipelineActivityRowApi,PipelineJobStatsResponseApi,PipelineRowsStatsResponseApi,@@ -81,12 +81,12 @@ export interface pipelineOverviewSceneLogicValues {rowsStatsLoading: booleanhealthIssues: DataHealthIssuesResponseApi | nullhealthIssuesLoading: boolean- recentFailures: PipelineActivityResponseApi | null- recentFailuresLoading: boolean+ recentRuns: { finished: PipelineActivityRowApi[]; running: PipelineActivityRowApi[] } | null+ recentRunsLoading: booleanbreadcrumbs: Breadcrumb[]issuesBySeverity: DataHealthIssueApi[]failingSyncCount: number- failedRuns: PipelineActivityRowApi[]+ recentRunRows: PipelineActivityRowApi[]destinations: ExternalDataDestinationApi[] | nulldestinationsLoading: booleansources: ExternalDataSourceSerializersApi[] | null@@ -105,7 +105,7 @@ export interface pipelineOverviewSceneLogicActions {loadJobStats: () => anyloadRowsStats: () => anyloadHealthIssues: () => any- loadRecentFailures: () => any+ loadRecentRuns: () => anyloadDestinations: () => anyloadSources: () => anyloadDestinationRowSeries: () => any@@ -224,6 +224,11 @@ export const pipelineOverviewSceneLogic = kea<pipelineOverviewSceneLogicType>([appSource: WAREHOUSE_APP_SOURCE,metricName: 'rows_synced',instanceId: destination.id,+ // The time-series query interpolates `breakdownBy` with no+ // fallback, so omitting it emits `undefined AS breakdown` and+ // the query fails to resolve. `instance_id` is already pinned+ // to one destination by `instanceId`, so this yields one series.+ breakdownBy: 'instance_id',interval,dateFrom,dateTo,@@ -243,22 +248,35 @@ export const pipelineOverviewSceneLogic = kea<pipelineOverviewSceneLogicType>([},},],- recentFailures: [- null as PipelineActivityResponseApi | null,+ recentRuns: [+ null as { finished: PipelineActivityRowApi[]; running: PipelineActivityRowApi[] } | null,{- loadRecentFailures: async () =>- await dataWarehouseCompletedActivityRetrieve(String(values.currentTeamId), {- outcome: 'failed',- // Imports only. Without this a team with many failing views fills every- // page with them and this list renders empty.- kind: 'import',- // 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,- }),+ loadRecentRuns: async () => {+ const [finished, running] = await Promise.all([+ dataWarehouseCompletedActivityRetrieve(String(values.currentTeamId), {+ // Everything that finished, not just the failures.+ outcome: 'all',+ // Imports only. Without this a team with many failing views fills+ // every page with them and this list renders empty.+ kind: 'import',+ // The window control sits in this section's own header. Without this+ // the endpoint falls back to its own 30-day default.+ cutoff_days: values.window,+ limit: 50,+ }),+ // In-flight runs come from a separate endpoint, so a sync that started+ // seconds ago appears at the top rather than waiting until it finishes.+ dataWarehouseRunningActivityRetrieve(String(values.currentTeamId), {+ kind: 'import',+ cutoff_days: values.window,+ limit: 50,+ }),+ ])+ return {+ finished: (finished.results ?? []) as PipelineActivityRowApi[],+ running: (running.results ?? []) as PipelineActivityRowApi[],+ }+ },},],})),@@ -332,10 +350,20 @@ export const pipelineOverviewSceneLogic = kea<pipelineOverviewSceneLogicType>([],/** Whether anything is wrong. The health section is hidden when nothing is. */hasIssues: [(s: any) => [s.issuesBySeverity], (issues: DataHealthIssueApi[]): boolean => issues.length > 0],- failedRuns: [- (s: any) => [s.recentFailures],- (recentFailures: PipelineActivityResponseApi | null): PipelineActivityRowApi[] =>- (recentFailures?.results ?? []).filter((run) => run.type !== MATERIALIZED_VIEW_ACTIVITY_TYPE),+ /** Running first, then finished newest-first. Model runs are another product's. */+ recentRunRows: [+ (s: any) => [s.recentRuns],+ (+ answer: { finished: PipelineActivityRowApi[]; running: PipelineActivityRowApi[] } | null+ ): PipelineActivityRowApi[] => {+ if (!answer) {+ return []+ }+ const isImport = (run: PipelineActivityRowApi): boolean => run.type !== MATERIALIZED_VIEW_ACTIVITY_TYPE+ const finished = answer.finished.filter(isImport)+ const finishedIds = new Set(finished.map((run) => run.id))+ return [...answer.running.filter((run) => isImport(run) && !finishedIds.has(run.id)), ...finished]+ },],// A first load shows skeletons; a refresh keeps the numbers on screen and dims them, so// polling does not make the page flash.@@ -355,7 +383,7 @@ export const pipelineOverviewSceneLogic = kea<pipelineOverviewSceneLogicType>([setWindow: () => {actions.loadJobStats()actions.loadDestinationRowSeries()- actions.loadRecentFailures()+ actions.loadRecentRuns()},refresh: () => actions.loadEverything(),// The series are fetched one destination at a time, so the destination list has to land@@ -365,7 +393,7 @@ export const pipelineOverviewSceneLogic = kea<pipelineOverviewSceneLogicType>([actions.loadJobStats()actions.loadRowsStats()actions.loadHealthIssues()- actions.loadRecentFailures()+ actions.loadRecentRuns()actions.loadDestinations()actions.loadSources()},@@ -374,6 +402,9 @@ export const pipelineOverviewSceneLogic = kea<pipelineOverviewSceneLogicType>([pollStats: () => {actions.loadJobStats()actions.loadHealthIssues()+ // The runs list is the one table worth moving under the reader: a sync that starts+ // while the page is open should appear without a refresh.+ actions.loadRecentRuns()},})),afterMount(({ actions, cache }: any) => {diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 37bfd8917a38..dd273e9b2fe1 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -82969,6 +82969,11 @@ export namespace Schemas {* @nullable*/origin: string | null;+ /**+ * Id of the source the run belongs to, for linking to it. Null for model runs.+ * @nullable+ */+ source_id?: string | null;}export interface PipelineActivityResponse {@@ -113860,10 +113865,11 @@ export namespace Schemas {*/offset?: number;/**- * Which outcome to return: 'completed' or 'failed'. Defaults to 'completed'.+ * Which outcome to return: 'completed', 'failed', or 'all' for every run that finished either way. Defaults to 'completed'. Running jobs come from `running_activity` instead.** * `completed` - completed* * `failed` - failed+ * * `all` - all* @minLength 1*/outcome?: DataWarehouseCompletedActivityRetrieveOutcome;@@ -113884,6 +113890,7 @@ export namespace Schemas {export const DataWarehouseCompletedActivityRetrieveOutcome = {Completed: 'completed',Failed: 'failed',+ All: 'all',} as const;export type DataWarehouseJobStatsRetrieveParams = {@@ -113968,6 +113975,39 @@ export namespace Schemas {source_id: string;};+ export type DataWarehouseRunningActivityRetrieveParams = {+ /**+ * Only include runs created within this many days of now. Defaults to 30.+ */+ cutoff_days?: number;+ /**+ * Which runs to return: 'import' for warehouse source syncs, 'model' for materialized view runs, 'all' for both. Defaults to 'all'.+ *+ * * `all` - all+ * * `import` - import+ * * `model` - model+ * @minLength 1+ */+ kind?: DataWarehouseRunningActivityRetrieveKind;+ /**+ * Max rows to return. Capped at 50 server-side. Defaults to 20.+ */+ limit?: number;+ /**+ * Rows to skip, for pagination. Defaults to 0.+ */+ offset?: number;+ };++ export type DataWarehouseRunningActivityRetrieveKind = typeof DataWarehouseRunningActivityRetrieveKind[keyof typeof DataWarehouseRunningActivityRetrieveKind];+++ export const DataWarehouseRunningActivityRetrieveKind = {+ All: 'all',+ Import: 'import',+ Model: 'model',+ } as const;+export type DatasetItemsListParams = {/*** Return archived items instead of active items.