Skip to content

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

feat(data-warehouse): add schema-scoped syncs tab (#73541)

Luke Belton23fcc31dd155
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index ad144be92c1c..6488407df8f4 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -6451,6 +6451,7 @@ export interface ExternalDataSourceSchema extends SimpleExternalDataSourceSchema
export interface ExternalDataSchemaSourceSummary {
id: string
source_type: ExternalDataSourceType
+ access_method?: ExternalDataSource['access_method']
supports_column_selection?: boolean
supports_row_filters?: boolean
user_access_level: AccessControlLevel | null
diff --git a/products/data_warehouse/frontend/scenes/SchemaScene/ConfigurationTab.tsx b/products/data_warehouse/frontend/scenes/SchemaScene/ConfigurationTab.tsx
index 23d9ac5d6d61..7a83ae7a8e04 100644
--- a/products/data_warehouse/frontend/scenes/SchemaScene/ConfigurationTab.tsx
+++ b/products/data_warehouse/frontend/scenes/SchemaScene/ConfigurationTab.tsx
@@ -83,7 +83,8 @@ export interface ConfigurationTabProps {
source: SchemaSceneSource | null
section: SchemaConfigurationSection
onConfigureSyncMethod: () => void
- onViewSyncHistory: () => void
+ /** Omitted when the source has no sync history to link to. */
+ syncHistoryUrl?: string
}
export function ConfigurationTab({
@@ -92,7 +93,7 @@ export function ConfigurationTab({
source,
section,
onConfigureSyncMethod,
- onViewSyncHistory,
+ syncHistoryUrl,
}: ConfigurationTabProps): JSX.Element {
const logic = schemaSceneLogic({ sourceId, schemaId: schema.id })
const { isProjectTime, refreshingSchemas, resyncingSchema, supportsRowFilters } = useValues(logic)
@@ -110,7 +111,7 @@ export function ConfigurationTab({
cancelSchema={cancelSchema}
updateSchema={updateSchema}
onConfigureSyncMethod={onConfigureSyncMethod}
- onViewSyncHistory={onViewSyncHistory}
+ syncHistoryUrl={syncHistoryUrl}
/>
)
case 'sync-method':
@@ -178,7 +179,7 @@ function DetailsSection({
cancelSchema,
updateSchema,
onConfigureSyncMethod,
- onViewSyncHistory,
+ syncHistoryUrl,
}: {
source: ExternalDataSource | null
schema: ExternalDataSourceSchema
@@ -186,7 +187,7 @@ function DetailsSection({
cancelSchema: (schema: ExternalDataSourceSchema) => void
updateSchema: (schema: ExternalDataSourceSchema) => void
onConfigureSyncMethod: () => void
- onViewSyncHistory: () => void
+ syncHistoryUrl?: string
}): JSX.Element {
const syncedTableName = schema.table?.hogql_name ?? schema.table?.name
@@ -346,9 +347,11 @@ function DetailsSection({
)}
</SourceEditorAction>
)}
- <LemonButton type="secondary" onClick={onViewSyncHistory}>
- View sync history
- </LemonButton>
+ {syncHistoryUrl && (
+ <LemonButton type="secondary" to={syncHistoryUrl}>
+ View sync history
+ </LemonButton>
+ )}
</div>
</div>
)
diff --git a/products/data_warehouse/frontend/scenes/SchemaScene/SchemaScene.tsx b/products/data_warehouse/frontend/scenes/SchemaScene/SchemaScene.tsx
index ba23b10986c6..0559b41404b3 100644
--- a/products/data_warehouse/frontend/scenes/SchemaScene/SchemaScene.tsx
+++ b/products/data_warehouse/frontend/scenes/SchemaScene/SchemaScene.tsx
@@ -1,5 +1,4 @@
import { useActions, useValues } from 'kea'
-import { combineUrl, router } from 'kea-router'
import { useEffect } from 'react'
import { LemonButton, LemonSkeleton } from '@posthog/lemon-ui'
@@ -19,6 +18,8 @@ import { ActivityScope } from '~/types'
import { cleanSourceId } from 'products/data_warehouse/frontend/utils'
+import { shouldShowManagedSourceSyncsTab } from '../SourceScene/SourceScene'
+import { SyncsTab } from '../SourceScene/tabs/SyncsTab'
import { ConfigurationTab } from './ConfigurationTab'
import { MetricsTab } from './MetricsTab'
import {
@@ -63,6 +64,7 @@ function SchemaSceneContent({ sourceId, schemaId }: SchemaSceneProps): JSX.Eleme
const { featureFlags } = useValues(featureFlagLogic)
const cleanedSourceId = cleanSourceId(sourceId)
+ const showSyncs = shouldShowManagedSourceSyncsTab(source)
const showMetrics = !!featureFlags[FEATURE_FLAGS.DWH_SOURCE_METRICS]
const showDescriptions = !!featureFlags[FEATURE_FLAGS.DATA_WAREHOUSE_SEMANTIC_ENRICHMENT]
const showColumnsSection = supportsColumnSelection
@@ -76,6 +78,18 @@ function SchemaSceneContent({ sourceId, schemaId }: SchemaSceneProps): JSX.Eleme
}
}, [showMetrics, currentTab, setCurrentTab])
+ useEffect(() => {
+ // Wait for the source before deciding the tab is unavailable. While it's null `showSyncs` is
+ // false, so a URL-selected "syncs" tab would get bounced to Configuration and push a bogus
+ // history entry over the URL the user actually navigated to.
+ if (!source) {
+ return
+ }
+ if (!showSyncs && currentTab === 'syncs') {
+ setCurrentTab('configuration')
+ }
+ }, [source, showSyncs, currentTab, setCurrentTab])
+
useEffect(() => {
if (!showColumnsSection && currentSection === 'columns') {
setCurrentSection('details')
@@ -117,12 +131,8 @@ function SchemaSceneContent({ sourceId, schemaId }: SchemaSceneProps): JSX.Eleme
source={source}
section={currentSection}
onConfigureSyncMethod={() => setCurrentSection('sync-method')}
- onViewSyncHistory={() =>
- router.actions.push(
- combineUrl(urls.dataWarehouseSource(sourceId, 'syncs'), {
- schema: schema.name,
- }).url
- )
+ syncHistoryUrl={
+ showSyncs ? urls.dataWarehouseSourceSchema(sourceId, schema.id, 'syncs') : undefined
}
/>
}
@@ -131,6 +141,23 @@ function SchemaSceneContent({ sourceId, schemaId }: SchemaSceneProps): JSX.Eleme
},
]
+ if (showSyncs) {
+ tabs.push({
+ label: 'Syncs',
+ key: 'syncs',
+ content: (
+ <div className="flex flex-col gap-2">
+ <div className="flex justify-end">
+ <LemonButton type="secondary" size="small" to={urls.dataWarehouseSource(sourceId, 'syncs')}>
+ View all syncs for source
+ </LemonButton>
+ </div>
+ <SyncsTab id={cleanedSourceId} lockedSchema={schema.name} />
+ </div>
+ ),
+ })
+ }
+
if (showMetrics) {
tabs.push({
label: 'Metrics',
@@ -145,7 +172,10 @@ function SchemaSceneContent({ sourceId, schemaId }: SchemaSceneProps): JSX.Eleme
content: <ActivityLog id={schema.id} scope={ActivityScope.EXTERNAL_DATA_SCHEMA} />,
})
- const activeTab = !showMetrics && currentTab === 'metrics' ? 'configuration' : currentTab
+ const activeTab =
+ (!showMetrics && currentTab === 'metrics') || (!showSyncs && currentTab === 'syncs')
+ ? 'configuration'
+ : currentTab
return (
<SceneContent>
diff --git a/products/data_warehouse/frontend/scenes/SchemaScene/schemaSceneLogic.ts b/products/data_warehouse/frontend/scenes/SchemaScene/schemaSceneLogic.ts
index fc7eff629b50..2d412fb19d52 100644
--- a/products/data_warehouse/frontend/scenes/SchemaScene/schemaSceneLogic.ts
+++ b/products/data_warehouse/frontend/scenes/SchemaScene/schemaSceneLogic.ts
@@ -23,7 +23,7 @@ import {
import { cleanSourceId } from 'products/data_warehouse/frontend/utils'
-export const SCHEMA_SCENE_TABS = ['configuration', 'metrics', 'history'] as const
+export const SCHEMA_SCENE_TABS = ['configuration', 'syncs', 'metrics', 'history'] as const
export type SchemaSceneTab = (typeof SCHEMA_SCENE_TABS)[number]
export const SCHEMA_CONFIGURATION_SECTIONS = [
@@ -84,7 +84,7 @@ export interface schemaSceneLogicActions {
section: 'columns' | 'danger-zone' | 'descriptions' | 'details' | 'schedule' | 'sync-method'
}
_setCurrentTab: (tab: SchemaSceneTab) => {
- tab: 'configuration' | 'history' | 'metrics'
+ tab: 'configuration' | 'history' | 'metrics' | 'syncs'
}
cancelSchema: (schema: ExternalDataSourceSchema) => {
schema: ExternalDataSourceSchema
@@ -135,7 +135,7 @@ export interface schemaSceneLogicActions {
section: 'columns' | 'danger-zone' | 'descriptions' | 'details' | 'schedule' | 'sync-method'
}
setCurrentTab: (tab: SchemaSceneTab) => {
- tab: 'configuration' | 'history' | 'metrics'
+ tab: 'configuration' | 'history' | 'metrics' | 'syncs'
}
setIsProjectTime: (isProjectTime: boolean) => {
isProjectTime: boolean
diff --git a/products/data_warehouse/frontend/scenes/SourceScene/tabs/SyncsTab.tsx b/products/data_warehouse/frontend/scenes/SourceScene/tabs/SyncsTab.tsx
index e327b6dedc31..511c59d85661 100644
--- a/products/data_warehouse/frontend/scenes/SourceScene/tabs/SyncsTab.tsx
+++ b/products/data_warehouse/frontend/scenes/SourceScene/tabs/SyncsTab.tsx
@@ -26,11 +26,14 @@ const StatusTagSetting: Record<ExternalDataJob['status'], LemonTagType> = {
interface SyncsTabProps {
id: string
+ // When set, the tab is locked to this single schema's jobs and the schema filter is hidden.
+ // Used by the schema detail page's Syncs tab.
+ lockedSchema?: string
}
const LOG_LEVELS: LogEntryLevel[] = ['LOG', 'INFO', 'WARN', 'WARNING', 'ERROR']
-export const SyncsTab = ({ id }: SyncsTabProps): JSX.Element => {
+export const SyncsTab = ({ id, lockedSchema }: SyncsTabProps): JSX.Element => {
const logic = sourceSettingsLogic({ id, availableSources: {} })
const { timezone } = useValues(teamLogic)
const { user } = useValues(userLogic)
@@ -38,12 +41,24 @@ export const SyncsTab = ({ id }: SyncsTabProps): JSX.Element => {
const { loadJobs, loadMoreJobs, setSelectedSchemas } = useActions(logic)
const showDebugLogs = user?.is_staff || user?.is_impersonated
- // Apply a `?schema=<name>` deep link once on mount so links from the schemas list and the
- // schema configuration page land here pre-filtered to a single schema.
+ // Lock to a single schema when asked, otherwise apply a `?schema=<name>` deep link once on
+ // mount so links from the schemas list and the schema configuration page land here filtered.
useEffect(() => {
- const schemaParam = router.values.searchParams.schema
- if (schemaParam) {
- setSelectedSchemas(Array.isArray(schemaParam) ? schemaParam : [schemaParam])
+ if (!lockedSchema) {
+ const schemaParam = router.values.searchParams.schema
+ if (schemaParam) {
+ setSelectedSchemas(Array.isArray(schemaParam) ? schemaParam : [schemaParam])
+ }
+ return
+ }
+ setSelectedSchemas([lockedSchema])
+ // `sourceSettingsLogic` is keyed by source id and shared with the source page, which can
+ // keep it mounted past this tab. Release the lock on the way out, or the source's own
+ // Syncs tab stays filtered to this one schema.
+ return () => {
+ if (logic.isMounted()) {
+ logic.actions.setSelectedSchemas([])
+ }
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
@@ -65,7 +80,7 @@ export const SyncsTab = ({ id }: SyncsTabProps): JSX.Element => {
return (
<>
- {schemaOptions.length > 1 && (
+ {!lockedSchema && schemaOptions.length > 1 && (
<>
<div className="flex items-center gap-2 mb-2">
<LemonLabel>Schema</LemonLabel>
diff --git a/products/warehouse_sources/backend/presentation/views/external_data_schema.py b/products/warehouse_sources/backend/presentation/views/external_data_schema.py
index ec3f1c68b57a..805c562ffeeb 100644
--- a/products/warehouse_sources/backend/presentation/views/external_data_schema.py
+++ b/products/warehouse_sources/backend/presentation/views/external_data_schema.py
@@ -349,9 +349,9 @@ class ExternalDataSchemaSerializer(serializers.ModelSerializer):
# the runtime behaviour (a read-only SerializerMethodField backed by get_source) is correct.
source = serializers.SerializerMethodField( # type: ignore[assignment]
read_only=True,
- help_text="Lightweight parent-source summary (id, source_type, column-selection support, the requesting "
- "user's access level). Only populated on the single-schema retrieve endpoint — `null` elsewhere — so "
- "read-only views can render without fetching the full source and all its schemas.",
+ help_text="Lightweight parent-source summary (id, source_type, access_method, column-selection support, "
+ "the requesting user's access level). Only populated on the single-schema retrieve endpoint — `null` "
+ "elsewhere — so read-only views can render without fetching the full source and all its schemas.",
)
class Meta:
@@ -442,6 +442,7 @@ class ExternalDataSchemaSerializer(serializers.ModelSerializer):
"properties": {
"id": {"type": "string"},
"source_type": {"type": "string"},
+ "access_method": {"type": "string"},
"supports_column_selection": {"type": "boolean"},
"supports_row_filters": {"type": "boolean"},
"user_access_level": {"type": "string", "nullable": True},
@@ -472,6 +473,8 @@ class ExternalDataSchemaSerializer(serializers.ModelSerializer):
return {
"id": str(source.id),
"source_type": source.source_type,
+ # The schema page hides sync-history UI for direct-query sources, which have no jobs.
+ "access_method": source.access_method,
"supports_column_selection": source_supports_column_selection(source.source_type),
"supports_row_filters": source_supports_row_filters(source.source_type),
"user_access_level": user_access_level,
diff --git a/products/warehouse_sources/backend/tests/api/test_external_data_schema.py b/products/warehouse_sources/backend/tests/api/test_external_data_schema.py
index 0a396211f428..1305e5af626a 100644
--- a/products/warehouse_sources/backend/tests/api/test_external_data_schema.py
+++ b/products/warehouse_sources/backend/tests/api/test_external_data_schema.py
@@ -3442,6 +3442,8 @@ class TestExternalDataSchemaRetrieveSource(APIBaseTest):
summary = response.json()["source"]
assert summary["id"] == str(source.id)
assert summary["source_type"] == source_type.value
+ # The schema page reads this to hide sync-history UI on direct-query sources.
+ assert summary["access_method"] == source.access_method
assert summary["supports_column_selection"] is expected_column_selection
assert summary["supports_row_filters"] is expected_row_filters
assert "user_access_level" in summary
diff --git a/products/warehouse_sources/frontend/generated/api.schemas.ts b/products/warehouse_sources/frontend/generated/api.schemas.ts
index fc911a4f0af2..66157a71a9eb 100644
--- a/products/warehouse_sources/frontend/generated/api.schemas.ts
+++ b/products/warehouse_sources/frontend/generated/api.schemas.ts
@@ -121,12 +121,13 @@ export type ExternalDataSchemaApiAvailableColumnsItem = {
}
/**
- * Lightweight parent-source summary (id, source_type, column-selection support, the requesting user's access level). Only populated on the single-schema retrieve endpoint — `null` elsewhere — so read-only views can render without fetching the full source and all its schemas.
+ * Lightweight parent-source summary (id, source_type, access_method, column-selection support, the requesting user's access level). Only populated on the single-schema retrieve endpoint — `null` elsewhere — so read-only views can render without fetching the full source and all its schemas.
* @nullable
*/
export type ExternalDataSchemaApiSource = {
readonly id?: string
readonly source_type?: string
+ readonly access_method?: string
readonly supports_column_selection?: boolean
readonly supports_row_filters?: boolean
/** @nullable */
@@ -230,7 +231,7 @@ export interface ExternalDataSchemaApi {
/** Column metadata (name, data type, nullable) for this schema. For SQL sources this is the source-side schema discovered via `refresh_schemas`; for other sources (and once synced) it falls back to the synced table's columns. Empty only before the first successful sync/refresh. */
readonly available_columns: readonly ExternalDataSchemaApiAvailableColumnsItem[]
/**
- * Lightweight parent-source summary (id, source_type, column-selection support, the requesting user's access level). Only populated on the single-schema retrieve endpoint — `null` elsewhere — so read-only views can render without fetching the full source and all its schemas.
+ * Lightweight parent-source summary (id, source_type, access_method, column-selection support, the requesting user's access level). Only populated on the single-schema retrieve endpoint — `null` elsewhere — so read-only views can render without fetching the full source and all its schemas.
* @nullable
*/
readonly source: ExternalDataSchemaApiSource
@@ -273,12 +274,13 @@ export type PatchedExternalDataSchemaApiAvailableColumnsItem = {
}
/**
- * Lightweight parent-source summary (id, source_type, column-selection support, the requesting user's access level). Only populated on the single-schema retrieve endpoint — `null` elsewhere — so read-only views can render without fetching the full source and all its schemas.
+ * Lightweight parent-source summary (id, source_type, access_method, column-selection support, the requesting user's access level). Only populated on the single-schema retrieve endpoint — `null` elsewhere — so read-only views can render without fetching the full source and all its schemas.
* @nullable
*/
export type PatchedExternalDataSchemaApiSource = {
readonly id?: string
readonly source_type?: string
+ readonly access_method?: string
readonly supports_column_selection?: boolean
readonly supports_row_filters?: boolean
/** @nullable */
@@ -382,7 +384,7 @@ export interface PatchedExternalDataSchemaApi {
/** Column metadata (name, data type, nullable) for this schema. For SQL sources this is the source-side schema discovered via `refresh_schemas`; for other sources (and once synced) it falls back to the synced table's columns. Empty only before the first successful sync/refresh. */
readonly available_columns?: readonly PatchedExternalDataSchemaApiAvailableColumnsItem[]
/**
- * Lightweight parent-source summary (id, source_type, column-selection support, the requesting user's access level). Only populated on the single-schema retrieve endpoint — `null` elsewhere — so read-only views can render without fetching the full source and all its schemas.
+ * Lightweight parent-source summary (id, source_type, access_method, column-selection support, the requesting user's access level). Only populated on the single-schema retrieve endpoint — `null` elsewhere — so read-only views can render without fetching the full source and all its schemas.
* @nullable
*/
readonly source?: PatchedExternalDataSchemaApiSource
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index d7b44c32efa8..9fd83252b78a 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -28104,12 +28104,13 @@ export namespace Schemas {
};
/**
- * Lightweight parent-source summary (id, source_type, column-selection support, the requesting user's access level). Only populated on the single-schema retrieve endpoint — `null` elsewhere — so read-only views can render without fetching the full source and all its schemas.
+ * Lightweight parent-source summary (id, source_type, access_method, column-selection support, the requesting user's access level). Only populated on the single-schema retrieve endpoint — `null` elsewhere — so read-only views can render without fetching the full source and all its schemas.
* @nullable
*/
export type ExternalDataSchemaSource = {
readonly id?: string;
readonly source_type?: string;
+ readonly access_method?: string;
readonly supports_column_selection?: boolean;
readonly supports_row_filters?: boolean;
/** @nullable */
@@ -28297,7 +28298,7 @@ export namespace Schemas {
/** Column metadata (name, data type, nullable) for this schema. For SQL sources this is the source-side schema discovered via `refresh_schemas`; for other sources (and once synced) it falls back to the synced table's columns. Empty only before the first successful sync/refresh. */
readonly available_columns: readonly ExternalDataSchemaAvailableColumnsItem[];
/**
- * Lightweight parent-source summary (id, source_type, column-selection support, the requesting user's access level). Only populated on the single-schema retrieve endpoint — `null` elsewhere — so read-only views can render without fetching the full source and all its schemas.
+ * Lightweight parent-source summary (id, source_type, access_method, column-selection support, the requesting user's access level). Only populated on the single-schema retrieve endpoint — `null` elsewhere — so read-only views can render without fetching the full source and all its schemas.
* @nullable
*/
readonly source: ExternalDataSchemaSource;
@@ -48819,12 +48820,13 @@ export namespace Schemas {
};
/**
- * Lightweight parent-source summary (id, source_type, column-selection support, the requesting user's access level). Only populated on the single-schema retrieve endpoint — `null` elsewhere — so read-only views can render without fetching the full source and all its schemas.
+ * Lightweight parent-source summary (id, source_type, access_method, column-selection support, the requesting user's access level). Only populated on the single-schema retrieve endpoint — `null` elsewhere — so read-only views can render without fetching the full source and all its schemas.
* @nullable
*/
export type PatchedExternalDataSchemaSource = {
readonly id?: string;
readonly source_type?: string;
+ readonly access_method?: string;
readonly supports_column_selection?: boolean;
readonly supports_row_filters?: boolean;
/** @nullable */
@@ -48928,7 +48930,7 @@ export namespace Schemas {
/** Column metadata (name, data type, nullable) for this schema. For SQL sources this is the source-side schema discovered via `refresh_schemas`; for other sources (and once synced) it falls back to the synced table's columns. Empty only before the first successful sync/refresh. */
readonly available_columns?: readonly PatchedExternalDataSchemaAvailableColumnsItem[];
/**
- * Lightweight parent-source summary (id, source_type, column-selection support, the requesting user's access level). Only populated on the single-schema retrieve endpoint — `null` elsewhere — so read-only views can render without fetching the full source and all its schemas.
+ * Lightweight parent-source summary (id, source_type, access_method, column-selection support, the requesting user's access level). Only populated on the single-schema retrieve endpoint — `null` elsewhere — so read-only views can render without fetching the full source and all its schemas.
* @nullable
*/
readonly source?: PatchedExternalDataSchemaSource;