: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): hide metrics tab for direct connect sources (#75376)
Jovan Sakovice1bbe7bf7f77
diff --git a/frontend/src/scenes/data-warehouse/settings/DataWarehouseSourceScene.test.ts b/frontend/src/scenes/data-warehouse/settings/DataWarehouseSourceScene.test.tsindex 9c89866f7e4e..232ee2af1e37 100644--- a/frontend/src/scenes/data-warehouse/settings/DataWarehouseSourceScene.test.ts+++ b/frontend/src/scenes/data-warehouse/settings/DataWarehouseSourceScene.test.ts@@ -1,6 +1,7 @@import {getDefaultDataWarehouseSourceSceneTab,isManagedSourceSceneId,+ shouldShowManagedSourceMetricsTab,shouldShowManagedSourceSyncsTab,} from 'products/data_warehouse/frontend/scenes/SourceScene/SourceScene'@@ -25,4 +26,13 @@ describe('DataWarehouseSourceScene', () => {expect(shouldShowManagedSourceSyncsTab({ access_method: 'direct' })).toEqual(false)expect(shouldShowManagedSourceSyncsTab({ access_method: 'warehouse' })).toEqual(true)})++ it.each([+ [null, true, false],+ [{ access_method: 'direct' as const }, true, false],+ [{ access_method: 'warehouse' as const }, true, true],+ [{ access_method: 'warehouse' as const }, false, false],+ ])('hides the metrics tab for direct query sources (source %p, flag %p)', (source, flagEnabled, expected) => {+ expect(shouldShowManagedSourceMetricsTab(source, flagEnabled)).toEqual(expected)+ })})diff --git a/products/data_warehouse/frontend/scenes/SchemaScene/SchemaScene.tsx b/products/data_warehouse/frontend/scenes/SchemaScene/SchemaScene.tsxindex 0559b41404b3..e4198a83034b 100644--- a/products/data_warehouse/frontend/scenes/SchemaScene/SchemaScene.tsx+++ b/products/data_warehouse/frontend/scenes/SchemaScene/SchemaScene.tsx@@ -18,7 +18,7 @@ import { ActivityScope } from '~/types'import { cleanSourceId } from 'products/data_warehouse/frontend/utils'-import { shouldShowManagedSourceSyncsTab } from '../SourceScene/SourceScene'+import { shouldShowManagedSourceMetricsTab, shouldShowManagedSourceSyncsTab } from '../SourceScene/SourceScene'import { SyncsTab } from '../SourceScene/tabs/SyncsTab'import { ConfigurationTab } from './ConfigurationTab'import { MetricsTab } from './MetricsTab'@@ -65,7 +65,7 @@ function SchemaSceneContent({ sourceId, schemaId }: SchemaSceneProps): JSX.Elemeconst cleanedSourceId = cleanSourceId(sourceId)const showSyncs = shouldShowManagedSourceSyncsTab(source)- const showMetrics = !!featureFlags[FEATURE_FLAGS.DWH_SOURCE_METRICS]+ const showMetrics = shouldShowManagedSourceMetricsTab(source, !!featureFlags[FEATURE_FLAGS.DWH_SOURCE_METRICS])const showDescriptions = !!featureFlags[FEATURE_FLAGS.DATA_WAREHOUSE_SEMANTIC_ENRICHMENT]const showColumnsSection = supportsColumnSelectionconst visibleSections = SCHEMA_CONFIGURATION_SECTIONS.filter(@@ -73,22 +73,19 @@ function SchemaSceneContent({ sourceId, schemaId }: SchemaSceneProps): JSX.Eleme)useEffect(() => {- if (!showMetrics && currentTab === 'metrics') {- setCurrentTab('configuration')- }- }, [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.+ // Wait for the source before deciding a tab is unavailable. While it's null `showSyncs` and+ // `showMetrics` are 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])+ if (!showMetrics && currentTab === 'metrics') {+ setCurrentTab('configuration')+ }+ }, [source, showSyncs, showMetrics, currentTab, setCurrentTab])useEffect(() => {if (!showColumnsSection && currentSection === 'columns') {diff --git a/products/data_warehouse/frontend/scenes/SourceScene/SourceScene.tsx b/products/data_warehouse/frontend/scenes/SourceScene/SourceScene.tsxindex de2782df1b20..cbce3d0e9cd6 100644--- a/products/data_warehouse/frontend/scenes/SourceScene/SourceScene.tsx+++ b/products/data_warehouse/frontend/scenes/SourceScene/SourceScene.tsx@@ -72,6 +72,15 @@ export function shouldShowManagedSourceSyncsTab(return !!source && source.access_method !== 'direct'}+// Every metric on this tab counts syncs or synced rows, so there's nothing to show for a direct+// connect source — it queries the origin database instead of syncing into the warehouse.+export function shouldShowManagedSourceMetricsTab(+ source: Pick<ExternalDataSource, 'access_method'> | null | undefined,+ metricsFeatureFlagEnabled: boolean+): boolean {+ return metricsFeatureFlagEnabled && shouldShowManagedSourceSyncsTab(source)+}+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface sourceSceneLogicValues {breadcrumbName: string@@ -271,7 +280,7 @@ function ManagedSourceTabs({const showSyncsTab = shouldShowManagedSourceSyncsTab(source)const showWebhookTab = !!source?.supports_webhooks- const showMetricsTab = !!featureFlags[FEATURE_FLAGS.DWH_SOURCE_METRICS]+ const showMetricsTab = shouldShowManagedSourceMetricsTab(source, !!featureFlags[FEATURE_FLAGS.DWH_SOURCE_METRICS])useEffect(() => {// Wait until the source has loaded before deciding a tab is unavailable.