: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
feat(marketing): gate the complete source onboarding (#113983)
Javier Bahamondesf3f3505e7628
diff --git a/docs/internal/marketing-source-suggestions.md b/docs/internal/marketing-source-suggestions.mdindex 8b31a8b1c565..f3464589969d 100644--- a/docs/internal/marketing-source-suggestions.md+++ b/docs/internal/marketing-source-suggestions.md@@ -140,3 +140,96 @@ Blocked required imports show Needs attention with a Manage source link.Dashboard dismissals use the shared Setup restore controls.Source refresh failures retain the previous list and allow a later retry.Native source readiness checks include required schema failures and paused imports.++## Source onboarding++Marketing analytics skips source onboarding when a marketing source is configured, including sources whose first sync is still running.+For projects without sources, onboarding scans UTM-tagged events and suggests matching ad platforms.+Users can continue to the dashboard at any time, connect more platforms while a sync runs, or choose from all supported sources when no platform is detected.+The event scan is cached for seven days per project and lookback window; source connection and sync health continue to use current configuration.+Use **Scan events again** in Setup → Sources to bypass the event cache.+The dashboard keeps pending source suggestions and sync status visible so missing spend data is not mistaken for zero spend.+Conversion goals are configured within the product rather than as an onboarding step.++The source onboarding shows scan progress while it runs, then detected platforms and their connection benefits.+**Browse integrations** opens the complete source selector without leaving the dashboard.+The scan message states its seven-day detection window.++On the current dashboard, spend and ad performance tiles stay hidden until a source supplies data.+The connection notice or detected-source suggestions explain what needs to be connected.++Source health refreshes on window focus without replacing the resolved dashboard or cached event suggestions with a loading screen.+Health-only changes refresh source metadata and validation without forcing all dashboard queries to run again.+Campaign reporting waits for every required campaign and campaign-statistics schema to be enabled and finish its first sync.+The initial source check shows separate loading states for Ad performance and Search performance, without offering connections before the source list is known.+Projects without sources show a connection card instead of empty metric placeholders.+Search performance stays visible while the paid-source event scan runs, fails, or returns no platforms.+Search performance remains behind `marketing-analytics-organic-keywords`.+The paid-source onboarding and automatic dashboard scan are behind `marketing-analytics-source-onboarding`.+Disabling this flag restores the original welcome, source connection, and conversion-goal wizard, including its source catalog and dashboard loading state.+The source scan, enhanced catalog, dashboard section changes, and header feedback action require this flag.+Google Search Console onboarding stays behind its independent `marketing-analytics-organic-keywords` flag.+Mounting source setup state does not start the UTM audit; Integration health loads the audit when opened.+Search onboarding stays independent under `marketing-analytics-organic-keywords`.+The read-only setup plan is available with `marketing-analytics-source-onboarding`, `marketing-analytics-setup`, or `new-marketing-analytics-dashboard`; other setup operations keep their existing flag requirements.++Source setup uses a consistent panel for connection checks, event scanning, suggestions, empty results, and recoverable errors.+Detected platforms show concise evidence with expandable details.+Configured connections show their first-sync status beside pending platforms.+The manual catalog supports search and returning to suggestions.+The current dashboard shows metric filters only once marketing data is available; beta feedback is available in the scene header.++Source setup panels are centered within the scene.+**Browse integrations** opens the searchable catalog in place; **Back to suggestions** restores the pending connections without another scan.+When `marketing-analytics-organic-keywords` enables Search performance, setup and the manual catalog show Google Search Console as an optional organic-search connection, separate from detected ad platforms.++The source setup panel explains how connections centralize campaign performance and how conversion goals based on PostHog events measure conversion costs and return on ad spend.+When Search performance is enabled, it also explains paid-keyword and organic-query analysis for optimizing search ads.+Pending-source cards offer the source connection buttons and **Browse integrations**; they do not redirect users to Setup to review the same suggestions.++Manual event scans are available from onboarding and the dashboard with **Scan again**.+A successful scan starts a one-hour cooldown per project; the server also reuses the scan during this cooldown.+Failed scans can be retried. Suggested connections stay visible during a refresh.+When no platforms are detected, the panel explains how UTM parameters on ad links help PostHog identify platforms.++With Search performance enabled, a connected Google Search Console source also skips onboarding.+The current dashboard shows Search performance below a compact ad-source connection panel when no ad data is ready.+Search Console does not unlock ad spend metrics; its sync and data readiness remain independent.++The Search Console connection card explains how connecting Google Ads adds paid keyword, spend, and conversion data alongside organic search queries.++When none of Google Ads, Bing Ads, or Google Search Console is connected, the enabled Search performance flag shows a separate search connection card with all three integrations.++Search connections appear as a separate card below both the source suggestions and the manual integration catalog.++The integration catalog opened inside the dashboard has no continue action because the user is already on the dashboard.+The initial onboarding catalog offers **Skip for now** when no sources are connected.++The integration catalog places its back action in the same footer as the browse action in suggestions.+The separate search connection card offers Google Ads, Bing Ads, and Google Search Console with their connection states.++The legacy dashboard and ad performance tab show search tables only after a search source is connected. Without one, the connection card remains visible without empty filter controls.++Dashboard sections keep the Ad performance and Search performance headings outside their setup cards. The cards retain titles that describe the current setup state.++The empty ad setup card uses the money hedgehog illustration. The search connection card uses the magnifying glass hedgehog. Both sit to the right of their headings and descriptions.++The money hedgehog stays in the manual integration catalog so switching from suggestions keeps the same illustration.++Integration buttons show the external-link icon because their connection panels open in a new tab.++The native integration catalog uses a consistent display order: Google Ads, Meta Ads, Bing Ads, LinkedIn Ads, TikTok Ads, Reddit Ads, Pinterest Ads, Snapchat Ads, OpenAI Ads, Apple Ads, Amazon Ads, Rokt Ads, and X Ads. Google Search Console stays in the search section.++The separate Ad performance tab is available only with `new-marketing-analytics-dashboard` enabled.+Enabling Search performance alone keeps paid and organic reporting inside the current Dashboard tab.++Detected-source suggestions keep the money hedgehog in the header, matching the empty state and manual catalog.++Resolved ad-source panels retain the money hedgehog while connections wait or sync, including the compact panel above organic search.+Storybook covers Search Console without ads and ads without Search Console, with ready and first-sync variants.++A connected Google Ads or Bing Ads source shows Search performance below the ad metrics or first-sync panel.+The full search connection card appears only when no search source is connected, so a paid-only project does not repeat Search performance above its ad metrics.++The rescan cooldown uses the server scan time. Failed plan requests can retry without a fresh scan.+Search controls and the Search Console connection action remain available during paid sync.diff --git a/frontend/src/scenes/marketing-analytics/MarketingAnalyticsScene.tsx b/frontend/src/scenes/marketing-analytics/MarketingAnalyticsScene.tsxindex 8418d6ce359f..928c73891c6d 100644--- a/frontend/src/scenes/marketing-analytics/MarketingAnalyticsScene.tsx+++ b/frontend/src/scenes/marketing-analytics/MarketingAnalyticsScene.tsx@@ -2,8 +2,8 @@ import clsx from 'clsx'import { BindLogic, useActions, useValues } from 'kea'import { useEffect } from 'react'-import { IconGear, IconSparkles } from '@posthog/icons'-import { LemonBanner, LemonButton, LemonSkeleton, LemonSwitch, LemonTabs, Link } from '@posthog/lemon-ui'+import { IconComment, IconGear, IconSparkles } from '@posthog/icons'+import { LemonBanner, LemonButton, LemonSwitch, LemonTabs, LemonSkeleton, Spinner, Link } from '@posthog/lemon-ui'import { FEATURE_FLAGS } from 'lib/constants'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'@@ -29,7 +29,10 @@ import { dataNodeCollectionLogic } from '~/queries/nodes/DataNode/dataNodeCollecimport { ProductKey } from '~/queries/schema/schema-general'import { sourcesDataLogic } from 'products/data_warehouse/frontend/shared/logics/sourcesDataLogic'+import { DetectedSources } from 'products/marketing_analytics/frontend/dashboard/DetectedSources'import { NewMarketingAnalyticsDashboard } from 'products/marketing_analytics/frontend/dashboard/NewMarketingAnalyticsDashboard'+import { SearchConsoleSource } from 'products/marketing_analytics/frontend/dashboard/SearchConsoleSource'+import { SourceSetupPanel } from 'products/marketing_analytics/frontend/dashboard/SourceSetupPanel'import { marketingAnalyticsEmptyState } from 'products/marketing_analytics/frontend/emptyState/marketingAnalyticsEmptyState'import { SearchPerformanceTab } from 'products/marketing_analytics/frontend/search/SearchPerformanceTab'import { useAttachedContext } from 'products/posthog_ai/frontend/api/logics'@@ -92,6 +95,142 @@ const QueryTileItem = ({ tile }: { tile: QueryTile }): JSX.Element => {)}+const LegacySearchConnectionCard = (): JSX.Element | null => {+ const { dataWarehouseSources, isAdPerformance } = useValues(marketingAnalyticsLogic)+ const { showOnboarding } = useValues(marketingOnboardingLogic)+ if (showOnboarding && !isAdPerformance) {+ return null+ }+ return dataWarehouseSources?.results.some((source) =>+ ['GoogleAds', 'BingAds', 'GoogleSearchConsole'].includes(source.source_type)+ ) ? null : (+ <SearchConsoleSource />+ )+}++const MarketingAnalyticsDashboard = (): JSX.Element => {+ const { featureFlags } = useValues(featureFlagLogic)+ return featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_SOURCE_ONBOARDING] ? (+ <SourceMarketingAnalyticsDashboard />+ ) : (+ <>+ <LegacyMarketingAnalyticsDashboard />+ <LegacySearchConnectionCard />+ </>+ )+}++const SourceMarketingAnalyticsDashboard = (): JSX.Element => {+ const { featureFlags } = useValues(featureFlagLogic)+ const {+ hasSources,+ dataWarehouseSources,+ hasSyncedMarketingSources,+ nativeSources,+ validExternalTables,+ loading,+ isAdPerformance,+ includeConversionGoals,+ } = useValues(marketingAnalyticsLogic)+ const { setAdPerformanceConversionGoals } = useActions(marketingAnalyticsLogic)+ const { loadSources } = useActions(sourcesDataLogic)+ const { sourcesLoadError } = useValues(sourcesDataLogic)+ const { conversion_goals } = useValues(marketingAnalyticsSettingsLogic)+ const { tiles: marketingTiles } = useValues(marketingAnalyticsTilesLogic)+ const { showOnboarding } = useValues(marketingOnboardingLogic)+ const { completeOnboarding } = useActions(marketingOnboardingLogic)++ // Reload sources on every navigation to this scene so newly configured+ // data warehouse sources are picked up without a full page refresh+ useEffect(() => {+ loadSources()+ }, [loadSources])++ const hasSearchConsole =+ !!featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_ORGANIC_KEYWORDS] &&+ !!dataWarehouseSources?.results.some((source) => source.source_type === 'GoogleSearchConsole')+ const hasConfiguredSources = nativeSources.length > 0 || validExternalTables.length > 0 || hasSearchConsole++ useEffect(() => {+ if (!isAdPerformance && !loading && hasConfiguredSources && showOnboarding) {+ completeOnboarding()+ }+ }, [loading, hasConfiguredSources, showOnboarding, completeOnboarding, isAdPerformance])++ if (!isAdPerformance && !featureFlags[FEATURE_FLAGS.WEB_ANALYTICS_MARKETING]) {+ return (+ <>+ <LemonBanner type="info">+ You can enable marketing analytics in the feature preview settings{' '}+ <Link to="https://app.posthog.com/settings/user-feature-previews#marketing-analytics">here</Link>.+ </LemonBanner>+ </>+ )+ }++ if (!dataWarehouseSources) {+ return (+ <>+ <h2 className="max-w-3xl w-full mx-auto mt-6 mb-0">Ad performance</h2>+ {featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_SOURCE_ONBOARDING] ? (+ <SourceSetupPanel+ state={sourcesLoadError ? 'error' : 'checking'}+ onRetry={loadSources}+ rescanLoading={loading}+ />+ ) : (+ <div className="flex justify-center p-8">+ <Spinner />+ </div>+ )}+ <SearchConsoleSource />+ </>+ )+ }++ if (!isAdPerformance && !hasConfiguredSources && showOnboarding) {+ return (+ <>+ <Onboarding completeOnboarding={completeOnboarding} />+ </>+ )+ }++ return (+ <>+ {isAdPerformance && conversion_goals.length > 0 && (+ <LemonSwitch+ className="mt-4"+ label="Include conversion goals"+ checked={includeConversionGoals}+ onChange={setAdPerformanceConversionGoals}+ data-attr="marketing-ad-performance-conversion-goals"+ />+ )}+ <LegacyOAuthReconnectBanner />+ {hasSyncedMarketingSources && <MarketingAnalyticsSourceStatusBanner />}+ <h2+ className={+ hasSyncedMarketingSources || hasSearchConsole ? 'mt-6 mb-0' : 'max-w-3xl w-full mx-auto mt-6 mb-0'+ }+ >+ Ad performance+ </h2>+ <DetectedSources compact={hasSearchConsole && !hasSyncedMarketingSources} />+ {!dataWarehouseSources?.results.some((source) =>+ ['GoogleAds', 'BingAds', 'GoogleSearchConsole'].includes(source.source_type)+ ) && <SearchConsoleSource />}+ {hasSources && hasSyncedMarketingSources && (+ <div className="mt-4 grid grid-cols-1 md:grid-cols-2 2xl:grid-cols-3 gap-x-4 gap-y-12">+ {marketingTiles?.map((tile, i) => (+ <QueryTileItem key={i} tile={tile} />+ ))}+ </div>+ )}+ </>+ )+}+// Loading placeholder that mirrors the real dashboard layout — an overview metric row, a chart card,// and a table card — instead of a single thin bar, so the page doesn't visibly reflow when data lands.const MarketingAnalyticsDashboardSkeleton = (): JSX.Element => (@@ -120,7 +259,7 @@ const MarketingAnalyticsDashboardSkeleton = (): JSX.Element => (</div>)-const MarketingAnalyticsDashboard = (): JSX.Element => {+const LegacyMarketingAnalyticsDashboard = (): JSX.Element => {const { featureFlags } = useValues(featureFlagLogic)const { hasSources, hasNoConfiguredSources, loading, isAdPerformance, includeConversionGoals } =useValues(marketingAnalyticsLogic)@@ -229,11 +368,17 @@ const MarketingAnalyticsDashboard = (): JSX.Element => {const MarketingAnalyticsContent = (): JSX.Element => {const { featureFlags } = useValues(featureFlagLogic)- const { activeTab } = useValues(marketingAnalyticsLogic)+ const { activeTab, hasSyncedMarketingSources, dataWarehouseSources } = useValues(marketingAnalyticsLogic)const { setActiveTab, setSetupSection } = useActions(marketingAnalyticsLogic)const { integrationSettingsModal } = useValues(marketingAnalyticsSettingsLogic)const { closeIntegrationSettingsModal } = useActions(marketingAnalyticsSettingsLogic)+ const hasConnectedSearchSource =+ !!featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_ORGANIC_KEYWORDS] &&+ !!dataWarehouseSources?.results.some((source) =>+ ['GoogleAds', 'BingAds', 'GoogleSearchConsole'].includes(source.source_type)+ )+// The redesigned dashboard replaces the current one under the same "Dashboard" tab when its flag is// on, so the eventual cutover is just flipping the flag — no tab rename, no extra tab key to strand.const dashboard = (@@ -242,8 +387,24 @@ const MarketingAnalyticsContent = (): JSX.Element => {<NewMarketingAnalyticsDashboard />) : (<>- <MarketingAnalyticsFilters tabs={<></>} />+ {(!featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_SOURCE_ONBOARDING] ||+ hasSyncedMarketingSources ||+ hasConnectedSearchSource) && (+ <MarketingAnalyticsFilters+ tabs={<></>}+ searchOnly={+ !!featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_SOURCE_ONBOARDING] &&+ !hasSyncedMarketingSources &&+ hasConnectedSearchSource+ }+ />+ )}<MarketingAnalyticsDashboard />+ {hasConnectedSearchSource && (+ <div className="mt-8">+ <SearchPerformanceTab />+ </div>+ )}</>)}{/* Both dashboards carry the campaign breakdown, whose mapping menus open this modal, so it@@ -284,16 +445,28 @@ const MarketingAnalyticsContent = (): JSX.Element => {const tabs = [{ key: MarketingAnalyticsTab.DASHBOARD, label: 'Dashboard', content: dashboard },...(featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_NEW_DASHBOARD] ||- featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_ORGANIC_KEYWORDS]+ (!featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_SOURCE_ONBOARDING] &&+ featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_ORGANIC_KEYWORDS])? [{key: MarketingAnalyticsTab.AD_PERFORMANCE,label: 'Ad performance',content: (<>- <MarketingAnalyticsFilters tabs={<></>} />+ {(!featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_SOURCE_ONBOARDING] ||+ hasSyncedMarketingSources ||+ hasConnectedSearchSource) && (+ <MarketingAnalyticsFilters+ tabs={<></>}+ searchOnly={+ !!featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_SOURCE_ONBOARDING] &&+ !hasSyncedMarketingSources &&+ hasConnectedSearchSource+ }+ />+ )}<MarketingAnalyticsDashboard />- {featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_ORGANIC_KEYWORDS] && (+ {hasConnectedSearchSource && (<div className="mt-8"><SearchPerformanceTab /></div>@@ -373,6 +546,7 @@ const MarketingAnalyticsContent = (): JSX.Element => {if (!tabIsRendered && !absorbed) {setActiveTab(activeTab === MarketingAnalyticsTab.SEARCH_PERFORMANCE &&+ featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_NEW_DASHBOARD] &&featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_ORGANIC_KEYWORDS]? MarketingAnalyticsTab.AD_PERFORMANCE: MarketingAnalyticsTab.DASHBOARD@@ -488,12 +662,10 @@ const MarketingAnalyticsAIToolWrapper = ({ children }: { children: React.ReactNoexport function MarketingAnalyticsScene(): JSX.Element {const { featureFlags } = useValues(featureFlagLogic)- const newDashboardEnabled = !!featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_NEW_DASHBOARD]- useEffect(() => {- if (newDashboardEnabled) {- return setupPlanLogic.mount()- }- }, [newDashboardEnabled])+ const setupEnabled =+ !!featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_SOURCE_ONBOARDING] ||+ !!featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_NEW_DASHBOARD]+ useEffect(() => (setupEnabled ? setupPlanLogic.mount() : undefined), [setupEnabled])const { activeTab } = useValues(marketingAnalyticsLogic)return (@@ -510,6 +682,16 @@ export function MarketingAnalyticsScene(): JSX.Element {}}actions={<>+ {featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_SOURCE_ONBOARDING] && (+ <LemonButton+ type="secondary"+ size="small"+ icon={<IconComment />}+ id="marketing-analytics-feedback-button"+ >+ Send feedback+ </LemonButton>+ )}<LemonButtonto="https://posthog.com/docs/web-analytics/marketing-analytics"type="secondary"diff --git a/frontend/src/scenes/marketing-analytics/Onboarding/Onboarding.tsx b/frontend/src/scenes/marketing-analytics/Onboarding/Onboarding.tsxindex d720b10695f6..1440917155db 100644--- a/frontend/src/scenes/marketing-analytics/Onboarding/Onboarding.tsx+++ b/frontend/src/scenes/marketing-analytics/Onboarding/Onboarding.tsx@@ -7,12 +7,17 @@ import { LemonButton, LemonCard, Link } from '@posthog/lemon-ui'import { pngHoggie } from 'lib/brand/hoggies'import { ProductIntroduction } from 'lib/components/ProductIntroduction/ProductIntroduction'+import { FEATURE_FLAGS } from 'lib/constants'import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { eventUsageLogic } from 'lib/utils/eventUsageLogic'import { teamLogic } from 'scenes/teamLogic'import { ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'+import { SearchConsoleSource } from 'products/marketing_analytics/frontend/dashboard/SearchConsoleSource'+import { SourceOnboarding } from 'products/marketing_analytics/frontend/dashboard/SourceOnboarding'+import { MarketingAnalyticsSourceStatusBanner } from '../../web-analytics/tabs/marketing-analytics/frontend/components/MarketingAnalyticsSourceStatusBanner'import { ConversionGoalsConfiguration } from '../../web-analytics/tabs/marketing-analytics/frontend/components/settings/ConversionGoalsConfiguration'import { marketingAnalyticsLogic } from '../../web-analytics/tabs/marketing-analytics/frontend/logic/marketingAnalyticsLogic'@@ -28,6 +33,18 @@ interface OnboardingProps {}export function Onboarding({ completeOnboarding }: OnboardingProps): JSX.Element {+ const { featureFlags } = useValues(featureFlagLogic)+ return featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_SOURCE_ONBOARDING] ? (+ <SourceOnboarding completeOnboarding={completeOnboarding} />+ ) : (+ <>+ <LegacyOnboarding completeOnboarding={completeOnboarding} />+ <SearchConsoleSource />+ </>+ )+}++function LegacyOnboarding({ completeOnboarding }: OnboardingProps): JSX.Element {const { reportMarketingAnalyticsOnboardingViewed, reportMarketingAnalyticsOnboardingCompleted } =useActions(eventUsageLogic)const { addProductIntent } = useActions(teamLogic)diff --git a/frontend/src/scenes/marketing-analytics/Onboarding/marketingOnboardingLogic.ts b/frontend/src/scenes/marketing-analytics/Onboarding/marketingOnboardingLogic.tsindex 155f1c0eac8d..33e65d2feecf 100644--- a/frontend/src/scenes/marketing-analytics/Onboarding/marketingOnboardingLogic.ts+++ b/frontend/src/scenes/marketing-analytics/Onboarding/marketingOnboardingLogic.ts@@ -10,6 +10,8 @@ const STEP_ORDER: MarketingOnboardingStep[] = ['welcome', 'add-source', 'conversexport interface marketingOnboardingLogicValues {currentStep: MarketingOnboardingStepisLastStep: boolean+ manualSourceSearch: string+ showManualSources: booleanshowOnboarding: boolean}@@ -24,6 +26,12 @@ export interface marketingOnboardingLogicActions {resetOnboarding: () => {value: true}+ setManualSourceSearch: (search: string) => {+ search: string+ }+ setShowManualSources: (show: boolean) => {+ show: boolean+ }setShowOnboarding: (show: boolean) => {show: boolean}@@ -50,6 +58,8 @@ export const marketingOnboardingLogic = kea<marketingOnboardingLogicType>([path(['scenes', 'marketing-analytics', 'Onboarding', 'marketingOnboardingLogic']),actions({+ setManualSourceSearch: (search: string) => ({ search }),+ setShowManualSources: (show: boolean) => ({ show }),setStep: (step: MarketingOnboardingStep) => ({ step }),goToNextStep: true,completeOnboarding: true,@@ -58,6 +68,15 @@ export const marketingOnboardingLogic = kea<marketingOnboardingLogicType>([}),reducers({+ manualSourceSearch: ['', { setManualSourceSearch: (_, { search }) => search, resetOnboarding: () => '' }],+ showManualSources: [+ false,+ {+ setShowManualSources: (_, { show }) => show,+ resetOnboarding: () => false,+ completeOnboarding: () => false,+ },+ ],currentStep: [(localStorage.getItem(MARKETING_ONBOARDING_STORAGE_KEYS.STEP) as MarketingOnboardingStep) || 'welcome',{diff --git a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/components/MarketingAnalyticsFilters/MarketingAnalyticsFilters.tsx b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/components/MarketingAnalyticsFilters/MarketingAnalyticsFilters.tsxindex c614fe4100e8..925dbb106c60 100644--- a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/components/MarketingAnalyticsFilters/MarketingAnalyticsFilters.tsx+++ b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/components/MarketingAnalyticsFilters/MarketingAnalyticsFilters.tsx@@ -27,7 +27,13 @@ import { ConversionGoalFilterButton } from './ConversionGoalFilterButton'import { ConversionGoalModal } from './ConversionGoalModal'import { IntegrationFilter } from './IntegrationFilter'-export const MarketingAnalyticsFilters = ({ tabs }: { tabs: JSX.Element }): JSX.Element => {+export const MarketingAnalyticsFilters = ({+ tabs,+ searchOnly = false,+}: {+ tabs: JSX.Element+ searchOnly?: boolean+}): JSX.Element => {const { featureFlags } = useValues(featureFlagLogic)const { compareFilter, dateFilter, shouldFilterTestAccounts, optionsOpen, isAdPerformance } =useValues(marketingAnalyticsLogic)@@ -62,8 +68,8 @@ export const MarketingAnalyticsFilters = ({ tabs }: { tabs: JSX.Element }): JSX.><ReloadAll /></Shortcut>- <ConversionGoalFilterButton />- {showSearch && <IntegrationFilter />}+ {!searchOnly && <ConversionGoalFilterButton />}+ {(showSearch || searchOnly) && <IntegrationFilter />}</div>}right={diff --git a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/setupPlanLogic.test.ts b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/setupPlanLogic.test.tsindex e4edc3dc3810..8aed4c678832 100644--- a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/setupPlanLogic.test.ts+++ b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/setupPlanLogic.test.ts@@ -7,6 +7,7 @@ import { initKeaTests } from '~/test/init'import { marketingAnalyticsSettingsLogic } from './marketingAnalyticsSettingsLogic'import type { ApplyOp, SetupPlanResponse, Suggestion } from './setupPlanLogic'import { setupPlanLogic } from './setupPlanLogic'+import { utmAuditLogic } from './utmAuditLogic'jest.mock('posthog-js')@@ -33,6 +34,7 @@ const suggestion = (overrides: Partial<Suggestion> = {}): Suggestion => ({const plan = (suggestions: Suggestion[]): SetupPlanResponse => ({suggestions,+ source_scanned_at: new Date(Date.now()).toISOString(),readiness: [],degraded: [],truncated: false,@@ -132,6 +134,7 @@ describe('setupPlanLogic', () => {})it('refreshes the sibling logics that would otherwise go stale', async () => {+ utmAuditLogic.mount()// apply_setup_ops writes config server-side, bypassing updateCurrentTeam. If// these don't fire, the manual settings sections show stale data right next to// the suggestion that just changed it — which reads as a bug.@@ -139,7 +142,7 @@ describe('setupPlanLogic', () => {'loadSetupPlan','loadCurrentTeam',marketingAnalyticsSettingsLogic.actionTypes.loadMarketingAnalyticsConfig,- 'loadAuditData',+ utmAuditLogic.actionTypes.loadAuditData,])})@@ -396,6 +399,36 @@ describe('setupPlanLogic', () => {expect(urls[1]).toContain('refresh=true')})+ it('does not restart the cooldown when the server returns an old cached scan', async () => {+ useMocks({+ get: {+ '/api/projects/:team_id/marketing_analytics/setup_plan': () => [+ 200,+ { ...plan([]), source_scanned_at: new Date(Date.now() - 6 * 24 * 60 * 60 * 1000).toISOString() },+ ],+ },+ })+ await expectLogic(logic, () => logic.actions.loadSetupPlan()).toFinishAllListeners()+ expect(logic.values.sourceScanDisabledReason).toBeNull()+ })++ it('retries a failed initial request during a persisted scan cooldown without forcing a scan', async () => {+ const urls: string[] = []+ useMocks({+ get: {+ '/api/projects/:team_id/marketing_analytics/setup_plan': ({ request }) => {+ urls.push(request.url)+ return urls.length === 1 ? [503, { detail: 'unavailable' }] : [200, plan([])]+ },+ },+ })+ logic.actions.recordSourceScan(logic.values.currentTeamId!, Date.now())+ await expectLogic(logic, () => logic.actions.loadSetupPlan()).toDispatchActions(['loadSetupPlanFailure'])+ expect(logic.values.sourceScanDisabledReason).toBeNull()+ await expectLogic(logic, () => logic.actions.rescanSources()).toDispatchActions(['loadSetupPlanSuccess'])+ expect(new URL(urls[1]).searchParams.get('refresh')).toBe('false')+ })+describe('retrying syncs', () => {const TARGETS = [{ source_id: 'src-a', display_name: 'Google Ads' },diff --git a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/setupPlanLogic.ts b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/setupPlanLogic.tsindex 4ddd8b2b63b3..84aaf9ba9d3a 100644--- a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/setupPlanLogic.ts+++ b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/setupPlanLogic.ts@@ -113,7 +113,6 @@ export interface setupPlanLogicValues {export interface setupPlanLogicActions {loadMarketingAnalyticsConfig: () => any // marketingAnalyticsSettingsLogicloadCurrentTeam: () => any // teamLogic- loadAuditData: () => any // utmAuditLogicapplyAllSafe: () => {value: true}@@ -217,7 +216,8 @@ export interface setupPlanLogicMeta {sourceScanDisabledReason: (sourceScanTimes: Record<number, number>,currentTeamId: number | null,- scanClock: number+ scanClock: number,+ setupPlan: SetupPlanResponse | null) => string | nullsuggestions: (setupPlan: SetupPlanResponse | null) => Suggestion[]readiness: (setupPlan: SetupPlanResponse | null) => CapabilityReadiness[]@@ -246,14 +246,7 @@ export const setupPlanLogic = kea<setupPlanLogicType>([path(['scenes', 'web-analytics', 'tabs', 'marketing-analytics', 'frontend', 'logic', 'setupPlanLogic']),connect(() => ({values: [teamLogic, ['currentTeamId'], marketingAnalyticsSettingsLogic, ['setupEntryPointLabel']],- actions: [- teamLogic,- ['loadCurrentTeam'],- marketingAnalyticsSettingsLogic,- ['loadMarketingAnalyticsConfig'],- utmAuditLogic,- ['loadAuditData'],- ],+ actions: [teamLogic, ['loadCurrentTeam'], marketingAnalyticsSettingsLogic, ['loadMarketingAnalyticsConfig']],})),actions({rescanSources: true,@@ -390,8 +383,16 @@ export const setupPlanLogic = kea<setupPlanLogicType>([}),selectors({sourceScanDisabledReason: [- (s) => [s.sourceScanTimes, s.currentTeamId, s.scanClock],- (times: Record<number, number>, teamId: number | null, now: number): string | null => {+ (s) => [s.sourceScanTimes, s.currentTeamId, s.scanClock, s.setupPlan],+ (+ times: Record<number, number>,+ teamId: number | null,+ now: number,+ plan: SetupPlanResponse | null+ ): string | null => {+ if (!plan) {+ return null+ }const remaining = (times[teamId ?? 0] ?? 0) + 60 * 60 * 1000 - nowreturn remaining > 0 ? `You can scan again in ${Math.ceil(remaining / 60000)} minutes.` : null},@@ -450,16 +451,13 @@ export const setupPlanLogic = kea<setupPlanLogicType>([rescanSources: () => {actions.setScanClock(Date.now())if (!values.setupPlanLoading && !values.sourceScanDisabledReason) {- actions.loadSetupPlan({ refresh: true })+ actions.loadSetupPlan({ refresh: !!values.setupPlan })}},- loadSetupPlanSuccess: ({ setupPlan, payload }) => {- if (- !setupPlan.degraded.length &&- values.currentTeamId !== null &&- (payload?.refresh || !values.sourceScanTimes[values.currentTeamId])- ) {- actions.recordSourceScan(values.currentTeamId, Date.now())+ loadSetupPlanSuccess: ({ setupPlan }) => {+ if (values.currentTeamId !== null) {+ const scannedAt = setupPlan.source_scanned_at ? Date.parse(setupPlan.source_scanned_at) : 0+ actions.recordSourceScan(values.currentTeamId, Number.isFinite(scannedAt) ? scannedAt : 0)actions.setScanClock(Date.now())}},@@ -696,7 +694,7 @@ export const setupPlanLogic = kea<setupPlanLogicType>([// UTM-catalogue and campaign-spend ClickHouse queries the plan just ran,// so a conversion-goal change would pay for a scan it can't affect.if (ops.some((candidate) => AUDIT_AFFECTING_OPS.has(candidate.op))) {- actions.loadAuditData()+ utmAuditLogic.findMounted()?.actions.loadAuditData()}}},diff --git a/products/marketing_analytics/backend/api.py b/products/marketing_analytics/backend/api.pyindex 01ea2df85ed0..5f8634743cac 100644--- a/products/marketing_analytics/backend/api.py+++ b/products/marketing_analytics/backend/api.py@@ -918,6 +918,15 @@ class CapabilityReadinessSerializer(serializers.Serializer):class SetupPlanResponseSerializer(serializers.Serializer):+ source_scanned_at = serializers.SerializerMethodField(+ help_text="Time of the latest seven-day source scan, including cached scans. Null if no scan time is available."+ )++ def get_source_scanned_at(self, obj: dict[str, object]) -> str | None:+ team_id = self.context.get("team_id")+ scanned_at = cache.get(f"marketing_analytics:source_scan:v1:{team_id}:7:scanned_at") if team_id else None+ return scanned_at.isoformat() if scanned_at else None+suggestions = SuggestionSerializer(many=True, help_text="Ranked suggestions, most important first")readiness = CapabilityReadinessSerializer(many=True, help_text="Per-capability readiness, with the suggestions blocking each"@@ -1667,7 +1676,7 @@ class MarketingAnalyticsViewSet(TeamAndOrgViewSetMixin, GenericViewSet):if not request.validated_query_data["refresh"]:cached = cache.get(cache_key)if cached is not None:- return Response(SetupPlanResponseSerializer(cached).data)+ return Response(SetupPlanResponseSerializer(cached, context={"team_id": self.team.pk}).data)try:plan = async_to_sync(get_setup_plan)(self.team,@@ -1683,7 +1692,7 @@ class MarketingAnalyticsViewSet(TeamAndOrgViewSetMixin, GenericViewSet):# whatever caused them has recovered.if not plan.degraded:cache.set(cache_key, payload, _SETUP_PLAN_CACHE_SECONDS)- return Response(SetupPlanResponseSerializer(payload).data)+ return Response(SetupPlanResponseSerializer(payload, context={"team_id": self.team.pk}).data)except Exception:logger.exception("marketing_setup_plan_failed", team_id=self.team.pk)return Response(diff --git a/products/marketing_analytics/backend/test_api_setup_plan.py b/products/marketing_analytics/backend/test_api_setup_plan.pyindex e5d2d206ce8c..a0f3572d1ada 100644--- a/products/marketing_analytics/backend/test_api_setup_plan.py+++ b/products/marketing_analytics/backend/test_api_setup_plan.py@@ -1,7 +1,11 @@+from datetime import timedelta++import time_machinefrom posthog.test.base import APIBaseTestfrom unittest.mock import patchfrom django.core.cache import cache+from django.utils import timezonefrom parameterized import parameterized@@ -64,6 +68,19 @@ class TestSetupPlanEndpoint(APIBaseTest):flag.start()self.addCleanup(flag.stop)+ @time_machine.travel("2026-10-07T12:00:00Z", tick=False)+ def test_cached_plan_reports_the_actual_seven_day_scan_time(self) -> None:+ scanned_at = timezone.now() - timedelta(days=6)+ cache.set(f"marketing_analytics:source_scan:v1:{self.team.pk}:7:scanned_at", scanned_at)+ cache.set(f"marketing_analytics:source_scan:v1:{self.team.pk}:90:scanned_at", timezone.now())+ with patch(_PLAN_TARGET, return_value=_plan().model_copy(update={"degraded": []})) as build:+ first = self.client.get(self.url)+ second = self.client.get(self.url)+ self.assertEqual(first.status_code, 200)+ self.assertEqual(second.json()["source_scanned_at"], scanned_at.isoformat())+ self.assertEqual(first.json()["source_scanned_at"], second.json()["source_scanned_at"])+ build.assert_called_once()+def test_returns_the_plan(self):with patch(_PLAN_TARGET, return_value=_plan()):response = self.client.get(self.url)diff --git a/products/marketing_analytics/frontend/dashboard/DetectedSources.tsx b/products/marketing_analytics/frontend/dashboard/DetectedSources.tsxnew file mode 100644index 000000000000..7f9cc471d3bc--- /dev/null+++ b/products/marketing_analytics/frontend/dashboard/DetectedSources.tsx@@ -0,0 +1,96 @@+import { useActions, useValues } from 'kea'++import { LemonButton } from '@posthog/lemon-ui'++import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { marketingOnboardingLogic } from 'scenes/marketing-analytics/Onboarding/marketingOnboardingLogic'+import { teamLogic } from 'scenes/teamLogic'+import { marketingAnalyticsLogic } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAnalyticsLogic'+import { setupPlanLogic } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/logic/setupPlanLogic'+import {+ nativeSourceConnectionStatus,+ nativeSourceDisplayLabel,+} from 'scenes/web-analytics/tabs/marketing-analytics/frontend/logic/utils'++import { detectedSourcesLogic } from './detectedSourcesLogic'+import { SourceCatalog } from './SourceCatalog'+import { SourceSetupPanel } from './SourceSetupPanel'++export function DetectedSources({ compact = false }: { compact?: boolean }): JSX.Element | null {+ const { visibleSuggestions, dismissedSuggestions, setupPlan, setupPlanLoading, sourceScanDisabledReason } =+ useValues(setupPlanLogic)+ const { rescanSources, restoreAllDismissed } = useActions(setupPlanLogic)+ const { currentTeamId } = useValues(teamLogic)+ const { featureFlags } = useValues(featureFlagLogic)+ const { showIntegrations } = useValues(detectedSourcesLogic({ teamId: currentTeamId ?? 0 }))+ const { dismissSource, setShowIntegrations } = useActions(detectedSourcesLogic({ teamId: currentTeamId ?? 0 }))+ const { allAvailableSourcesWithStatus, nativeSources, hasSyncedMarketingSources } =+ useValues(marketingAnalyticsLogic)+ const { setManualSourceSearch } = useActions(marketingOnboardingLogic)+ const sources = visibleSuggestions.filter(+ (suggestion) =>+ suggestion.kind === 'connect_source' &&+ suggestion.apply?.op === 'open_source_wizard' &&+ !nativeSources.some((source) => source.source_type === suggestion.apply?.kind) &&+ !allAvailableSourcesWithStatus.some((source) => source.source_type === suggestion.apply?.kind)+ )+ const connections = nativeSources.map((source) => ({+ id: source.id,+ name: nativeSourceDisplayLabel(source.source_type),+ sourceType: source.source_type,+ ...nativeSourceConnectionStatus(source),+ }))+ const openIntegrations = (): void => {+ setManualSourceSearch('')+ setShowIntegrations(true)+ }+ if (!featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_SOURCE_ONBOARDING]) {+ return null+ }+ if (showIntegrations) {+ return (+ <SourceCatalog+ hasSources={connections.length > 0 || hasSyncedMarketingSources}+ onBack={() => setShowIntegrations(false)}+ />+ )+ }+ if (hasSyncedMarketingSources && !sources.length) {+ return null+ }+ return (+ <SourceSetupPanel+ compact={compact}+ state={+ connections.length+ ? 'waiting'+ : setupPlanLoading && !setupPlan+ ? 'scanning'+ : !setupPlan+ ? 'error'+ : sources.length+ ? 'suggestions'+ : dismissedSuggestions.some((suggestion) => suggestion.kind === 'connect_source')+ ? 'dismissed'+ : 'empty'+ }+ suggestions={sources}+ connections={connections}+ onRetry={rescanSources}+ rescanLoading={setupPlanLoading}+ rescanDisabledReason={sourceScanDisabledReason}+ onDismiss={dismissSource}+ onRestore={restoreAllDismissed}+ footer={+ <LemonButton+ type={sources.length || connections.length ? 'secondary' : 'primary'}+ onClick={openIntegrations}+ data-attr="marketing-dashboard-connect-source"+ >+ Browse integrations+ </LemonButton>+ }+ />+ )+}diff --git a/products/marketing_analytics/frontend/dashboard/SourceCatalog.tsx b/products/marketing_analytics/frontend/dashboard/SourceCatalog.tsxnew file mode 100644index 000000000000..9b58ac5745cf--- /dev/null+++ b/products/marketing_analytics/frontend/dashboard/SourceCatalog.tsx@@ -0,0 +1,222 @@+import { useActions, useValues } from 'kea'++import * as moneyPng from '@posthog/brand/hoggies/png/money'+import { IconArrowRight, IconCheckCircle, IconExternal, IconInfo } from '@posthog/icons'+import { LemonButton, LemonCard, LemonInput, Link, Tooltip } from '@posthog/lemon-ui'++import { pngHoggie } from 'lib/brand/hoggies'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { eventUsageLogic } from 'lib/utils/eventUsageLogic'+import { addProjectIdIfMissing } from 'lib/utils/kea-router'+import { marketingOnboardingLogic } from 'scenes/marketing-analytics/Onboarding/marketingOnboardingLogic'+import { teamLogic } from 'scenes/teamLogic'+import { urls } from 'scenes/urls'+import { marketingAnalyticsLogic } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAnalyticsLogic'+import {+ VALID_NON_NATIVE_MARKETING_SOURCES,+ VALID_SELF_MANAGED_MARKETING_SOURCES,+ getEnabledNativeMarketingSourcesInDisplayOrder,+ nativeSourceDisplayLabel,+} from 'scenes/web-analytics/tabs/marketing-analytics/frontend/logic/utils'++import { ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'++import { SourceIcon } from 'products/data_warehouse/frontend/shared/components/SourceIcon'++const HedgehogMoney = pngHoggie(moneyPng)++interface MarketingSource {+ id: string+ isConnected: boolean+ category: 'native' | 'external' | 'self-managed'+}++interface SourceCatalogProps {+ onContinue?: () => void+ hasSources: boolean+ onBack?: () => void+}++export function SourceCatalog({ onContinue, hasSources, onBack }: SourceCatalogProps): JSX.Element {+ const { manualSourceSearch } = useValues(marketingOnboardingLogic)+ const { setManualSourceSearch } = useActions(marketingOnboardingLogic)+ const { validExternalTables, validNativeSources } = useValues(marketingAnalyticsLogic)+ const { featureFlags } = useValues(featureFlagLogic)+ const { reportMarketingAnalyticsDataSourceConnected } = useActions(eventUsageLogic)+ const { addProductIntent } = useActions(teamLogic)++ const enabledNativeSources = getEnabledNativeMarketingSourcesInDisplayOrder(featureFlags)++ const allSources: MarketingSource[] = [+ ...enabledNativeSources.map((sourceType) => ({+ id: sourceType,+ isConnected: validNativeSources.some((source) => source.source.source_type === sourceType),+ category: 'native' as const,+ })),+ ...VALID_NON_NATIVE_MARKETING_SOURCES.map((sourceType) => ({+ id: sourceType,+ isConnected: validExternalTables.some((table) => table.source_type === sourceType),+ category: 'external' as const,+ })),+ ...VALID_SELF_MANAGED_MARKETING_SOURCES.map((sourceType) => ({+ id: sourceType,+ isConnected: validExternalTables.some((table) => table.source_type === sourceType),+ category: 'self-managed' as const,+ })),+ ]++ const handleSourceSelect = (sourceId: string): void => {+ reportMarketingAnalyticsDataSourceConnected(sourceId)+ addProductIntent({+ product_type: ProductKey.MARKETING_ANALYTICS,+ intent_context: ProductIntentContext.MARKETING_ANALYTICS_DATA_SOURCE_CONNECTED,+ metadata: { source_type: sourceId },+ })+ window.open(+ addProjectIdIfMissing(+ urls.dataWarehouseSourceNew(sourceId, urls.marketingAnalyticsApp(), 'Marketing analytics')+ ),+ '_blank',+ 'noopener'+ )+ }++ const nativeSources = allSources.filter(+ (s) =>+ nativeSourceDisplayLabel(s.id).toLowerCase().includes(manualSourceSearch.toLowerCase()) &&+ s.category === 'native'+ )+ const externalSources = allSources.filter(+ (s) =>+ nativeSourceDisplayLabel(s.id).toLowerCase().includes(manualSourceSearch.toLowerCase()) &&+ s.category === 'external'+ )+ const selfManagedSources = allSources.filter(+ (s) =>+ nativeSourceDisplayLabel(s.id).toLowerCase().includes(manualSourceSearch.toLowerCase()) &&+ s.category === 'self-managed'+ )++ const totalConnected = validNativeSources.length + validExternalTables.length++ return (+ <LemonCard hoverEffect={false} className="max-w-3xl w-full mx-auto mt-6 !p-0 overflow-hidden">+ <div className="p-6 space-y-3">+ {/* Header */}+ <div className="flex items-start justify-between gap-4">+ <div className="min-w-0 flex-1">+ <h3 className="text-base font-semibold mb-0.5">Connect your marketing sources</h3>+ <p className="text-xs text-muted-alt">+ {hasSources+ ? `${totalConnected} source${totalConnected !== 1 ? 's' : ''} connected. Choose another platform to connect.`+ : 'Choose a platform to start importing spend data.'}+ </p>+ </div>+ <HedgehogMoney className="w-20 shrink-0" />+ </div>++ <LemonInput+ type="search"+ placeholder="Search integrations"+ aria-label="Search integrations"+ value={manualSourceSearch}+ onChange={setManualSourceSearch}+ />+ {!nativeSources.length && !externalSources.length && !selfManagedSources.length && (+ <p className="text-secondary">No integrations match your search.</p>+ )}+ {/* Native Sources */}+ {nativeSources.length > 0 && (+ <div>+ <div className="text-xs font-medium text-muted mb-1.5">Native integrations (recommended)</div>+ <div className="flex flex-wrap gap-2">+ {nativeSources.map((source) => (+ <SourceChip key={source.id} source={source} onSelect={handleSourceSelect} />+ ))}+ </div>+ </div>+ )}++ {/* External Sources */}+ {externalSources.length > 0 && (+ <div>+ <div className="text-xs font-medium text-muted mb-1.5 flex items-center gap-1">+ Data warehouse+ <Tooltip+ title="Import marketing data you already have in a data warehouse like BigQuery."+ delayMs={0}+ >+ <IconInfo className="w-3 h-3 cursor-help" />+ </Tooltip>+ </div>+ <div className="flex flex-wrap gap-2">+ {externalSources.map((source) => (+ <SourceChip key={source.id} source={source} onSelect={handleSourceSelect} />+ ))}+ </div>+ </div>+ )}++ {/* Self-managed Sources */}+ {selfManagedSources.length > 0 && (+ <div>+ <div className="text-xs font-medium text-muted mb-1.5 flex items-center gap-1">+ Self-managed+ <Tooltip+ title="Connect your own data source (e.g. S3, GCS) where you already store marketing data."+ delayMs={0}+ >+ <IconInfo className="w-3 h-3 cursor-help" />+ </Tooltip>+ </div>+ <div className="flex flex-wrap gap-2">+ {selfManagedSources.map((source) => (+ <SourceChip key={source.id} source={source} onSelect={handleSourceSelect} />+ ))}+ </div>+ </div>+ )}+ </div>+ <div className="border-t p-4 flex flex-wrap items-center justify-between gap-3 bg-bg-light">+ {onBack && (+ <LemonButton type="secondary" size="small" onClick={onBack}>+ Back to suggestions+ </LemonButton>+ )}+ <Link+ to="https://posthog.com/docs/web-analytics/marketing-analytics"+ target="_blank"+ className="text-xs"+ >+ View docs+ </Link>+ {onContinue && (+ <LemonButton+ type="primary"+ size="small"+ onClick={onContinue}+ sideIcon={<IconArrowRight />}+ data-attr="marketing-onboarding-continue"+ >+ {hasSources ? 'Continue to dashboard' : 'Skip for now'}+ </LemonButton>+ )}+ </div>+ </LemonCard>+ )+}++function SourceChip({ source, onSelect }: { source: MarketingSource; onSelect: (id: string) => void }): JSX.Element {+ return (+ <LemonButton+ type="secondary"+ icon={<SourceIcon type={source.id} size="small" disableTooltip />}+ sideIcon={<IconExternal className="!w-3 !h-3 text-muted" />}+ onClick={() => onSelect(source.id)}+ data-attr="marketing-manual-connect-source"+ >+ {nativeSourceDisplayLabel(source.id)}+ {source.isConnected && <IconCheckCircle className="ml-2 text-success" />}+ </LemonButton>+ )+}diff --git a/products/marketing_analytics/frontend/dashboard/SourceOnboarding.tsx b/products/marketing_analytics/frontend/dashboard/SourceOnboarding.tsxnew file mode 100644index 000000000000..9bec3463b814--- /dev/null+++ b/products/marketing_analytics/frontend/dashboard/SourceOnboarding.tsx@@ -0,0 +1,79 @@+import { useActions, useValues } from 'kea'++import { FEATURE_FLAGS } from 'lib/constants'+import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { eventUsageLogic } from 'lib/utils/eventUsageLogic'+import { marketingOnboardingLogic } from 'scenes/marketing-analytics/Onboarding/marketingOnboardingLogic'+import { teamLogic } from 'scenes/teamLogic'+import { MarketingAnalyticsSourceStatusBanner } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/components/MarketingAnalyticsSourceStatusBanner'+import { marketingAnalyticsLogic } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAnalyticsLogic'+import { setupPlanLogic } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/logic/setupPlanLogic'++import { ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'++import { detectedSourcesLogic } from 'products/marketing_analytics/frontend/dashboard/detectedSourcesLogic'+import { SearchConsoleSource } from 'products/marketing_analytics/frontend/dashboard/SearchConsoleSource'+import { SourceOnboardingScan } from 'products/marketing_analytics/frontend/dashboard/SourceOnboardingScan'++import { SourceCatalog } from './SourceCatalog'++export function SourceOnboarding({ completeOnboarding }: { completeOnboarding: () => void }): JSX.Element {+ const { reportMarketingAnalyticsOnboardingViewed, reportMarketingAnalyticsOnboardingCompleted } =+ useActions(eventUsageLogic)+ const { addProductIntent } = useActions(teamLogic)+ const { currentTeamId } = useValues(teamLogic)+ useValues(detectedSourcesLogic({ teamId: currentTeamId ?? 0 }))+ const { setupPlan, setupPlanLoading, visibleSuggestions, dismissedSuggestions, sourceScanDisabledReason } =+ useValues(setupPlanLogic)+ const { rescanSources, restoreAllDismissed } = useActions(setupPlanLogic)+ const { showManualSources } = useValues(marketingOnboardingLogic)+ const { setShowManualSources } = useActions(marketingOnboardingLogic)+ const { hasSources } = useValues(marketingAnalyticsLogic)+ const { featureFlags } = useValues(featureFlagLogic)+ const sourceOnboardingEnabled = !!featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_SOURCE_ONBOARDING]++ useOnMountEffect(() => {+ reportMarketingAnalyticsOnboardingViewed()+ })++ const handleComplete = (): void => {+ reportMarketingAnalyticsOnboardingCompleted(hasSources)+ addProductIntent({+ product_type: ProductKey.MARKETING_ANALYTICS,+ intent_context: ProductIntentContext.MARKETING_ANALYTICS_ONBOARDING_COMPLETED,+ metadata: { has_sources: hasSources },+ })+ completeOnboarding()+ }++ return (+ <div className="space-y-4">+ <MarketingAnalyticsSourceStatusBanner />+ {!sourceOnboardingEnabled || showManualSources ? (+ <SourceCatalog+ onContinue={handleComplete}+ hasSources={hasSources}+ onBack={sourceOnboardingEnabled ? () => setShowManualSources(false) : undefined}+ />+ ) : (+ <SourceOnboardingScan+ loading={setupPlanLoading && !setupPlan}+ failed={!setupPlan && !setupPlanLoading}+ suggestions={visibleSuggestions.filter(+ (suggestion) =>+ suggestion.kind === 'connect_source' && suggestion.apply?.op === 'open_source_wizard'+ )}+ dismissed={dismissedSuggestions.some((suggestion) => suggestion.kind === 'connect_source')}+ onRestore={restoreAllDismissed}+ onManual={() => setShowManualSources(true)}+ onContinue={handleComplete}+ onRescan={rescanSources}+ rescanLoading={setupPlanLoading}+ rescanDisabledReason={sourceScanDisabledReason}+ />+ )}+ <SearchConsoleSource />+ </div>+ )+}diff --git a/products/marketing_analytics/frontend/dashboard/detectedSourcesLogic.test.ts b/products/marketing_analytics/frontend/dashboard/detectedSourcesLogic.test.tsnew file mode 100644index 000000000000..b254d279bd3f--- /dev/null+++ b/products/marketing_analytics/frontend/dashboard/detectedSourcesLogic.test.ts@@ -0,0 +1,88 @@+import { MOCK_TEAM_ID } from 'lib/api.mock'++import { expectLogic } from 'kea-test-utils'++import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { setupPlanLogic } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/logic/setupPlanLogic'++import { useMocks } from '~/mocks/jest'+import { initKeaTests } from '~/test/init'++import { detectedSourcesLogic } from './detectedSourcesLogic'++describe('detectedSourcesLogic', () => {+ let setupPlanRequests: number++ beforeEach(() => {+ setupPlanRequests = 0+ useMocks({+ get: {+ '/api/projects/:team_id/marketing_analytics/setup_plan': () => {+ setupPlanRequests += 1+ return [200, { suggestions: [], readiness: [], degraded: [], truncated: false, summary: '' }]+ },+ },+ })+ initKeaTests()+ featureFlagLogic.mount()+ featureFlagLogic.actions.setFeatureFlags([], {})+ setupPlanLogic.mount()+ })++ it('starts the scan when the onboarding flag arrives after mount', async () => {+ const logic = detectedSourcesLogic({ teamId: MOCK_TEAM_ID })+ logic.mount()+ expect(setupPlanLogic.values.setupPlanLoading).toBe(false)++ await expectLogic(setupPlanLogic, () => {+ featureFlagLogic.actions.setFeatureFlags([], {+ [FEATURE_FLAGS.MARKETING_ANALYTICS_SOURCE_ONBOARDING]: true,+ })+ featureFlagLogic.actions.setFeatureFlags([], {+ [FEATURE_FLAGS.MARKETING_ANALYTICS_SOURCE_ONBOARDING]: true,+ })+ }).toDispatchActions(['loadSetupPlan', 'loadSetupPlanSuccess'])+ expect(setupPlanRequests).toBe(1)+ logic.unmount()+ })+ it('restores dashboard dismissals through the shared Setup controls', async () => {+ const logic = detectedSourcesLogic({ teamId: MOCK_TEAM_ID })+ logic.mount()+ const id = 'connect_source:GoogleAds'+ setupPlanLogic.actions.loadSetupPlanSuccess({+ suggestions: [+ {+ id,+ kind: 'connect_source',+ source: 'deterministic',+ severity: 'info',+ confidence: 0.8,+ title: 'Connect Google Ads',+ evidence: 'Campaign tracking found in recent events.',+ unlocks: ['cost'],+ apply: { op: 'open_source_wizard', kind: 'GoogleAds' },+ also_recommended: [],+ safe_to_batch: false,+ rank_score: 10,+ integration: 'GoogleAds',+ deep_link: null,+ docs_url: null,+ spend_at_risk: 0,+ event_volume: 12,+ },+ ],+ readiness: [],+ degraded: [],+ truncated: false,+ summary: '',+ source_scanned_at: null,+ })+ logic.actions.dismissSource(id)+ expect(setupPlanLogic.values.visibleSuggestions).toHaveLength(0)+ expect(setupPlanLogic.values.dismissedSuggestions).toHaveLength(1)+ setupPlanLogic.actions.restoreSuggestion(id)+ expect(setupPlanLogic.values.visibleSuggestions).toHaveLength(1)+ logic.unmount()+ })+})diff --git a/products/marketing_analytics/frontend/generated/api.schemas.ts b/products/marketing_analytics/frontend/generated/api.schemas.tsindex c2e12cd584a3..5f0eed07b956 100644--- a/products/marketing_analytics/frontend/generated/api.schemas.ts+++ b/products/marketing_analytics/frontend/generated/api.schemas.ts@@ -2286,6 +2286,11 @@ export interface CapabilityReadinessApi {}export interface SetupPlanResponseApi {+ /**+ * Time of the latest seven-day source scan, including cached scans. Null if no scan time is available.+ * @nullable+ */+ readonly source_scanned_at: string | null/** Ranked suggestions, most important first */suggestions: SuggestionApi[]/** Per-capability readiness, with the suggestions blocking each */diff --git a/products/marketing_analytics/frontend/search/SearchPerformanceTab.tsx b/products/marketing_analytics/frontend/search/SearchPerformanceTab.tsxindex 2a9b74dc52dd..216c60a05a4f 100644--- a/products/marketing_analytics/frontend/search/SearchPerformanceTab.tsx+++ b/products/marketing_analytics/frontend/search/SearchPerformanceTab.tsx@@ -17,7 +17,11 @@ import { searchPerformanceLogic } from './searchPerformanceLogic'import { SearchPerformanceTable } from './SearchPerformanceTable'import { SearchSourceSuggestions } from './SearchSourceSuggestions'-export function SearchPerformanceTab(): JSX.Element {+export function SearchPerformanceTab({+ showSourceSuggestions = true,+}: {+ showSourceSuggestions?: boolean+}): JSX.Element {const {dataWarehouseSources,dataWarehouseSourcesLoading,@@ -36,7 +40,7 @@ export function SearchPerformanceTab(): JSX.Element {} = useValues(searchPerformanceLogic)const { loadSources, setMetrics, setSearch, setBreakdown, setChannel, selectRow, clearFilters } =useActions(searchPerformanceLogic)- const loading = !sourcesError && (dataWarehouseSourcesLoading || !dataWarehouseSources)+ const loading = !sourcesError && !dataWarehouseSourcesreturn (<div className="@container flex flex-col gap-4 pb-8" data-attr="marketing-search-performance">@@ -69,13 +73,16 @@ export function SearchPerformanceTab(): JSX.Element {</div>{loading ? (<LemonSkeleton repeat={5} className="h-10" />- ) : sourcesError ? (- <LemonBanner type="error" action={{ children: 'Try again', onClick: loadSources, loading }}>+ ) : sourcesError && !dataWarehouseSources ? (+ <LemonBanner+ type="error"+ action={{ children: 'Try again', onClick: loadSources, loading: dataWarehouseSourcesLoading }}+ >Could not load your search sources. Try again to view search performance.</LemonBanner>) : (<>- {!hasActiveFilters && <SearchSourceSuggestions />}+ {showSourceSuggestions && !hasActiveFilters && <SearchSourceSuggestions />}{sourceNotices.map(({ sourceId, message }) => (<LemonBannerkey={sourceId}diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 0767602bee30..55abd3f763fc 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -101124,6 +101124,11 @@ export namespace Schemas {}export interface SetupPlanResponse {+ /**+ * Time of the latest seven-day source scan, including cached scans. Null if no scan time is available.+ * @nullable+ */+ readonly source_scanned_at: string | null;/** Ranked suggestions, most important first */suggestions: Suggestion[];/** Per-capability readiness, with the suggestions blocking each */