: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(marketing-analytics): say when a connected ad source is missing its tables (#101672)
Tom Owers04fd36b8731e
diff --git a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/components/settings/ExternalDataSourceConfiguration.tsx b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/components/settings/ExternalDataSourceConfiguration.tsxindex b72fbd10541a..1dd5e485968c 100644--- a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/components/settings/ExternalDataSourceConfiguration.tsx+++ b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/components/settings/ExternalDataSourceConfiguration.tsx@@ -34,6 +34,7 @@ import {VALID_NON_NATIVE_MARKETING_SOURCES,VALID_SELF_MANAGED_MARKETING_SOURCES,findSchemaByFieldName,+ nativeSourceDisplayLabel,} from '../../logic/utils'import { AddIntegrationButton } from '../MarketingAnalyticsFilters/AddIntegrationButton'import { ColumnMappingModal } from './ColumnMappingModal'@@ -60,7 +61,8 @@ type UnifiedSource = {}export function ExternalDataSourceConfiguration(): JSX.Element {- const { allExternalTablesWithStatus, loading, hasNoConfiguredSources } = useValues(marketingAnalyticsLogic)+ const { allExternalTablesWithStatus, loading, hasNoConfiguredSources, unconfiguredNativeSources } =+ useValues(marketingAnalyticsLogic)const { updateSourceMapping } = useActions(marketingAnalyticsSettingsLogic)const [editingTable, setEditingTable] = useState<ExternalTable | null>(null)const restrictedReason = useRestrictedArea({@@ -184,12 +186,21 @@ export function ExternalDataSourceConfiguration(): JSX.Element {title="Data source configuration"description="Connect and configure data sources to enable marketing analytics. Native sources sync automatically, while warehouse and self-managed sources need column mapping.">- {hasNoConfiguredSources && (- <LemonBanner type="error" className="mb-4">- To use the Marketing analytics dashboard, you need at least one data source properly configured. Add- a native integration (like Google Ads or Facebook Ads) or connect a data warehouse source below.- </LemonBanner>- )}+ {hasNoConfiguredSources &&+ (unconfiguredNativeSources.length > 0 ? (+ <LemonBanner type="warning" className="mb-4">+ {unconfiguredNativeSources.length === 1+ ? `${nativeSourceDisplayLabel(unconfiguredNativeSources[0].source_type)} is connected but isn't syncing the tables marketing analytics needs.`+ : "Your ad integrations are connected but aren't syncing the tables marketing analytics needs."}{' '}+ Open the source settings below and turn on the tables listed under "To sync".+ </LemonBanner>+ ) : (+ <LemonBanner type="error" className="mb-4">+ To use the Marketing analytics dashboard, you need at least one data source properly configured.+ Add a native integration (like Google Ads or Facebook Ads) or connect a data warehouse source+ below.+ </LemonBanner>+ ))}<PaginationControlshasMoreItems={hasMoreSources}showAll={showAll}diff --git a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAnalyticsLogic.test.ts b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAnalyticsLogic.test.tsindex c9a3d653a7c9..1535fad7dfab 100644--- a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAnalyticsLogic.test.ts+++ b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAnalyticsLogic.test.ts@@ -200,6 +200,36 @@ describe('marketingAnalyticsLogic', () => {expect(logic.values.includeConversionGoals).toBe(true)})+ it('separates an ad source missing its required tables from having no source at all', async () => {+ logic = marketingAnalyticsLogic()+ logic.mount()+ await expectLogic(logic).toFinishAllListeners()++ const metaSource = (shouldSync: boolean): ExternalDataSource =>+ ({+ id: 'meta-source',+ source_type: 'MetaAds',+ schemas: [+ { id: 'campaigns', name: 'campaigns', should_sync: shouldSync },+ { id: 'campaign_stats', name: 'campaign_stats', should_sync: shouldSync },+ ],+ }) as ExternalDataSource++ await expectLogic(logic, () =>+ logic.actions.loadSourcesSuccess({ count: 1, next: null, previous: null, results: [metaSource(false)] })+ ).toFinishAllListeners()+ databaseTableListLogic.actions.loadDatabaseSuccess({ tables: {}, joins: [] })++ expect(logic.values.hasNoConfiguredSources).toBe(true)+ expect(logic.values.unconfiguredNativeSources.map((source) => source.id)).toEqual(['meta-source'])++ await expectLogic(logic, () =>+ logic.actions.loadSourcesSuccess({ count: 1, next: null, previous: null, results: [metaSource(true)] })+ ).toFinishAllListeners()++ expect(logic.values.unconfiguredNativeSources).toEqual([])+ })+it('keeps the selection and drops an unknown key from a filter saved by an older build', async () => {localStorage.setItem(STORAGE_KEY,diff --git a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAnalyticsLogic.ts b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAnalyticsLogic.tsindex eb7d0ac90eae..04912f548c38 100644--- a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAnalyticsLogic.ts+++ b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAnalyticsLogic.ts@@ -318,6 +318,7 @@ export interface marketingAnalyticsLogicValues {setupSection: SetupSectionshouldFilterTestAccounts: booleantileColumnSelection: validColumnsForTiles+ unconfiguredNativeSources: ExternalDataSource[]uniqueConversionGoalName: stringvalidExternalTables: ExternalTable[]validNativeSources: NativeSource[]@@ -523,6 +524,10 @@ export interface marketingAnalyticsLogicMeta {nativeSources: ExternalDataSource[],dataWarehouseTables: DatabaseSchemaDataWarehouseTable[]) => NativeSource[]+ unconfiguredNativeSources: (+ nativeSources: ExternalDataSource[],+ validNativeSources: NativeSource[]+ ) => ExternalDataSource[]uniqueConversionGoalName: (conversionGoalInput: ConversionGoalFilter,conversion_goals: ConversionGoalFilter[]@@ -1029,6 +1034,13 @@ export const marketingAnalyticsLogic = kea<marketingAnalyticsLogicType>([}, [])},],+ unconfiguredNativeSources: [+ (s) => [s.nativeSources, s.validNativeSources],+ (nativeSources: ExternalDataSource[], validNativeSources: NativeSource[]): ExternalDataSource[] => {+ const validIds = new Set(validNativeSources.map(({ source }) => source.id))+ return nativeSources.filter((source) => !validIds.has(source.id))+ },+ ],uniqueConversionGoalName: [(s) => [s.conversionGoalInput, s.conversion_goals],(conversionGoalInput: ConversionGoalFilter | null, conversion_goals: ConversionGoalFilter[]): string => {