: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(growth): introduce the pushed product when its setup screen won't (#100625)
Rafael Audibert88ff4ebbdb8b
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex e948f6241757..6f0afd1f9847 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -1537,13 +1537,13 @@ snapshots:components-mcp-use-case-card--surveys-create--light:hash: v1.k794b7964.693a3cba67de29bb7ecea8b07f3ae05b0201c2785fa2f2d4975e481b6fdc349e.ROQjP-mA4zsLzJifJv9uIKLgwuM0h84NwoFZJ90rSyccomponents-navpanelproductpush--all-products--dark:- hash: v1.k794b7964.9e44cddfaa216d00c536dd2d749e496d4dd9bd4c88f561e7eee9b60e01b857f9.05gwQFooDhrcIsy2Jku7wPQUfgJwsKRR5eNMgfBgj-A+ hash: v1.k794b7964.d6cc4da0e30950f4e3bf7338d86856529e48c45785bae5a85ccf4fd3ed7c3ad0.8n61Z9x6l3I3qfdAzk46yr7fAFHoYNdo3tjEKyJlcIocomponents-navpanelproductpush--all-products--light:- hash: v1.k794b7964.fbd1bfae33d177ba7bf98c8e17fa4f7db3afd668287f05dbe6d6d307436ddefa.rF5Pz8KyjQhD9nkd9YfDt0vPiAkTF60uSqGpt72JDxI+ hash: v1.k794b7964.f171803c193a7589c83985b1e42340813e7558fa19345f9df173a87bb7b98e0e.LKXF85iTBQuCHYxIkq7On1HqHFlneYIuYV2Rzce3Ceocomponents-navpanelproductpush--default-fallback--dark:- hash: v1.k794b7964.020f807f2d17fdf515b84c8800c37e0b6d8b0bda09421fbe1f0d3bcf9aeb23d4.C0OD2Gur0abSVWhBC5aarFDYTYRrudc-F6CjqvjhJ5o+ hash: v1.k794b7964.55b32fb0731f082c6605b657a7e1777e3cd14f674dc4d8aeba35f4fc95c7a5ae.TH7bgugVkjMiQ9zFp1Fg00BfjFm82Qkqjr7_GpeBzlAcomponents-navpanelproductpush--default-fallback--light:- hash: v1.k794b7964.06ad78d5182a189840a64537f4fffe5aae18b33328c8da550e09227aa506d3af.C5iY4j46abCd6Uf6SVnMZegPSQP9oqMPFb5dSeCdmzo+ hash: v1.k794b7964.9b2877b96dd501ff69cd42ba8bcc894307fe29468cd428fa1f22c82a691e3dc3.rdQtwImqV-1Lflo0SB893D5BUJewOFuzmAlyUqhJiPIcomponents-networkrequest-navigationitem--all-slow--dark:hash: v1.k794b7964.d09d9acbf8cb33a45a26cc9fd6e238dd97fa80b5b38c244dab95cd662d085c42.iV22pgH-xBLY-79NVxnPiKvZQ3vbBvZ7uthloHKd9Sccomponents-networkrequest-navigationitem--all-slow--light:@@ -2088,6 +2088,18 @@ snapshots:hash: v1.k794b7964.5715b2b6618e07bbfb8f79e9d5693ab827f784a258ee467db80efc020864e878.89v_z0AYjKYJJsLJOg_DNCSfkBAb_b8D7luHlZem-b0components-product-empty-state--workflows-needs-setup--light:hash: v1.k794b7964.7224c6486a41259cae1f14e8c4681a4c724cfa55732bb73a8790e69e5ce0ff3b.FAgjbudwnM6xpKppdCytepsCZSZPI5FudRun6qm6Re8+ components-productpushwelcomemodal--dashboards--dark:+ hash: v1.k794b7964.093e430930815868657ad56de557f36d9d8c86f9f5739e8c6f0300f81e680c0b.4S-pxcGMqO00c_k9y4xYz4PSJda1F0i8LMrriMPrKIo+ components-productpushwelcomemodal--dashboards--light:+ hash: v1.k794b7964.aefd60ba35f1a1d0a1b360dcc6703fff8faefce7aa2b1bfa6cfef05f537a1ddb.vsq_-Nf4792Z-FHxBgs2fiCwPyzECaK4DPD_iG36UTU+ components-productpushwelcomemodal--fallback-to-card-copy--dark:+ hash: v1.k794b7964.e6716e4ff274885b997f7a5589be08ea3a8ae8ef055f7b2cd75875d3db12a718.OJbTna0PtsNkJOlGJTZIg0B2yeSwj3uqq0gssYD7znE+ components-productpushwelcomemodal--fallback-to-card-copy--light:+ hash: v1.k794b7964.e84b438eb0eae6fd91918d5242e1907701840c2db36c4edbd04d177ec6bf7c47.6FzcrqB87TJa5rmTnVa6tZmZoHcCxotDahFwfETrmm8+ components-productpushwelcomemodal--product-analytics--dark:+ hash: v1.k794b7964.9958298a2ee8c052b088362c501fee04cb5841baef1792cf8cb92d442d90777a.W9G5fJIF3OAk10nIoHnAeBKuUgyHPfv31qS_agm5_ms+ components-productpushwelcomemodal--product-analytics--light:+ hash: v1.k794b7964.4a98ac4cd414a5ac9f2cc9189e1a969f359fe8cbde1bf5caf9cabcea322f4050.-zp2tGAD1sQWOI7Tekxt1UZVv2kaM5FRHH00eXpJ7uEcomponents-productsetup-productsetuppopover--default--dark:hash: v1.k794b7964.8577f1ec7bdb47266c031df353e220d017de2e86125924d5da8b0f052c6ce1a6.cA5-fWqyOm-PbSjy7Y8JZ4rQXAe7hn0soi6VkQ36dfccomponents-productsetup-productsetuppopover--default--light:diff --git a/frontend/src/layout/GlobalModals.tsx b/frontend/src/layout/GlobalModals.tsxindex fddf3bfeb96c..5364ec86340e 100644--- a/frontend/src/layout/GlobalModals.tsx+++ b/frontend/src/layout/GlobalModals.tsx@@ -5,6 +5,7 @@ import { ItemSelectModal } from 'lib/components/FileSystem/ItemSelectModal/ItemSimport { LinkToModal } from 'lib/components/FileSystem/LinkTo/LinkTo'import { MoveToModal } from 'lib/components/FileSystem/MoveTo/MoveTo'import { HedgehogMode } from 'lib/components/HedgehogMode/HedgehogMode'+import { MaybeProductPushWelcome } from 'lib/components/NavPanelAdvertisement/MaybeProductPushWelcome'import { SuperpowersModal } from 'lib/components/Superpowers/Superpowers'import { superpowersLogic } from 'lib/components/Superpowers/superpowersLogic'import { TimeSensitiveAuthenticationModal } from 'lib/components/TimeSensitiveAuthentication/TimeSensitiveAuthentication'@@ -87,6 +88,7 @@ export function GlobalModals(): JSX.Element {{superpowersEnabled && <SuperpowersModal />}<ConfigureHomeModal isOpen={isConfigureHomeModalOpen} onClose={hideConfigureHomeModal} /><MaybeWelcomeDialog />+ <MaybeProductPushWelcome /><MaybePhaiOnboarding /><ComposeTicketModal /></>diff --git a/frontend/src/lib/components/DebugNotice.tsx b/frontend/src/lib/components/DebugNotice.tsxindex 137e4ec9d03e..5958ba7d2a94 100644--- a/frontend/src/lib/components/DebugNotice.tsx+++ b/frontend/src/lib/components/DebugNotice.tsx@@ -66,7 +66,7 @@ export function DebugNotice({ isCollapsed }: DebugNoticeProps): JSX.Element | nu)}return (- <div className="border rounded bg-primary overflow-hidden w-full font-mono text-xs *:flex *:items-center *:gap-2 *:pl-2 *:pr-0.5 *:h-7 *:border-l-4">+ <div className="mb-2 border rounded bg-primary overflow-hidden w-full font-mono text-xs *:flex *:items-center *:gap-2 *:pl-2 *:pr-0.5 *:h-7 *:border-l-4"><div className="border-brand-blue justify-between"><Tooltiptitle={diff --git a/frontend/src/lib/components/NavPanelAdvertisement/MaybeProductPushWelcome.tsx b/frontend/src/lib/components/NavPanelAdvertisement/MaybeProductPushWelcome.tsxnew file mode 100644index 000000000000..95b36bc906d5--- /dev/null+++ b/frontend/src/lib/components/NavPanelAdvertisement/MaybeProductPushWelcome.tsx@@ -0,0 +1,81 @@+import { useActions, useValues } from 'kea'+import { router } from 'kea-router'+import { useEffect } from 'react'++import {+ EMPTY_STATE_PARAM,+ forcedModeFromParam,+ productEmptyStateGateRender,+} from 'lib/components/ProductEmptyState/gateRender'+import { productSetupStatusLogic } from 'lib/components/ProductEmptyState/productSetupStatusLogic'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { sceneLogic } from 'scenes/sceneLogic'++import { navPanelProductPushWelcomeLogic } from './navPanelProductPushWelcomeLogic'+import { type PendingProductPushWelcome, shouldShowProductPushWelcome } from './navPanelProductPushWelcomeVisibility'+import { ProductPushWelcomeModal } from './ProductPushWelcomeModal'++/**+ * Mounted in GlobalModals so it survives the navigation the advertisement click starts, and mounts+ * nothing at all until a click has something to follow up on.+ */+export function MaybeProductPushWelcome(): JSX.Element | null {+ const { pending, openFor } = useValues(navPanelProductPushWelcomeLogic)++ // The setup status below is keyed by product, so the card being introduced has to be known+ // before any of it can be mounted.+ const welcome = openFor ?? pending+ if (!welcome) {+ return null+ }+ return <ProductPushWelcome welcome={welcome} isOpen={!!openFor} />+}++function ProductPushWelcome({+ welcome,+ isOpen,+}: {+ welcome: PendingProductPushWelcome+ isOpen: boolean+}): JSX.Element | null {+ const { activeExportedScene, activeSceneProductKey, activeSceneId, activeSceneComponentParams } =+ useValues(sceneLogic)+ const { featureFlags, receivedFeatureFlags } = useValues(featureFlagLogic)+ const { searchParams } = useValues(router)+ const { status, skipped } = useValues(productSetupStatusLogic({ productKey: welcome.productKey }))+ const { openWelcome, closeWelcome } = useActions(navPanelProductPushWelcomeLogic)++ const sceneEmptyState = activeExportedScene?.emptyState+ const gatesPushedProduct = sceneEmptyState?.config.productKey === welcome.productKey+ // The gate renders more than the setup status: `?empty_state=1` forces the screen onto a product+ // that has data, and a flag or a `scenes` scope takes it away from a product that has none.+ const ready = shouldShowProductPushWelcome({+ pending: welcome,+ activeSceneProductKey,+ pushedProductGate:+ sceneEmptyState && gatesPushedProduct+ ? productEmptyStateGateRender({+ emptyState: sceneEmptyState,+ activeSceneId,+ params: activeSceneComponentParams,+ featureFlags,+ receivedFeatureFlags,+ forcedMode: forcedModeFromParam(searchParams[EMPTY_STATE_PARAM]),+ status,+ skipped,+ })+ : null,+ })++ useEffect(() => {+ if (!isOpen && ready) {+ openWelcome(welcome)+ }+ }, [isOpen, ready, welcome, openWelcome])++ if (!isOpen) {+ return null+ }+ const config = gatesPushedProduct ? sceneEmptyState?.config : undefined+ return <ProductPushWelcomeModal welcome={welcome} config={config} onClose={closeWelcome} />+}diff --git a/frontend/src/lib/components/NavPanelAdvertisement/ProductPushWelcomeModal.stories.tsx b/frontend/src/lib/components/NavPanelAdvertisement/ProductPushWelcomeModal.stories.tsxnew file mode 100644index 000000000000..4c1c8a5d4a4d--- /dev/null+++ b/frontend/src/lib/components/NavPanelAdvertisement/ProductPushWelcomeModal.stories.tsx@@ -0,0 +1,55 @@+import type { Meta, StoryObj } from '@storybook/react'++import { ProductKey } from '~/queries/schema/schema-general'++import { dashboardsEmptyState } from 'products/dashboards/frontend/emptyState/dashboardsEmptyState'+import { productAnalyticsEmptyState } from 'products/product_analytics/frontend/emptyState/productAnalyticsEmptyState'++import type { PendingProductPushWelcome } from './navPanelProductPushWelcomeVisibility'+import { ProductPushWelcomeModal } from './ProductPushWelcomeModal'++const meta = {+ title: 'Components/ProductPushWelcomeModal',+ component: ProductPushWelcomeModal,+ parameters: { layout: 'fullscreen', viewMode: 'story' },+} satisfies Meta<typeof ProductPushWelcomeModal>++export default meta+type Story = StoryObj<typeof meta>++const welcomeFor = (productKey: ProductKey, label: string, text: string): PendingProductPushWelcome => ({+ campaignId: 'campaign-1',+ productKey,+ label,+ text,+})++// The product the modal exists for: every project sends events, so its setup screen never shows.+export const ProductAnalytics: Story = {+ args: {+ welcome: welcomeFor(ProductKey.PRODUCT_ANALYTICS, 'Product analytics', 'Insights, funnels, trends.'),+ config: productAnalyticsEmptyState.config,+ onClose: () => {},+ },+}++// Projects are created with dashboards already in them, so this one hides the same way.+export const Dashboards: Story = {+ args: {+ welcome: welcomeFor(ProductKey.DASHBOARDS, 'Dashboards', 'Every number your team checks, on one page.'),+ config: dashboardsEmptyState.config,+ onClose: () => {},+ },+}++// The fallback shape, for a push whose scene has no setup screen to take copy from.+export const FallbackToCardCopy: Story = {+ args: {+ welcome: welcomeFor(+ ProductKey.SESSION_REPLAY,+ 'Session replay',+ 'Your team logs a lot of errors. Watch the sessions they happened in.'+ ),+ onClose: () => {},+ },+}diff --git a/frontend/src/lib/components/NavPanelAdvertisement/ProductPushWelcomeModal.tsx b/frontend/src/lib/components/NavPanelAdvertisement/ProductPushWelcomeModal.tsxnew file mode 100644index 000000000000..eeaeb971f6f7--- /dev/null+++ b/frontend/src/lib/components/NavPanelAdvertisement/ProductPushWelcomeModal.tsx@@ -0,0 +1,108 @@+import type { CSSProperties } from 'react'++import { IconBook } from '@posthog/icons'++import type { ProductEmptyStateConfig, ProductEmptyStateText } from 'lib/components/ProductEmptyState/types'+import { LemonButton } from 'lib/lemon-ui/LemonButton'+import { LemonModal } from 'lib/lemon-ui/LemonModal'++import { ProductHogHero } from './navPanelAdShared'+import { getProductPushDisplay } from './navPanelProductPushDisplay'+import type { ProductPushWelcomeCloseSource } from './navPanelProductPushWelcomeLogic'+import type { PendingProductPushWelcome } from './navPanelProductPushWelcomeVisibility'++// Same treatment the setup screen gives the product icon, over accents this sets locally.+const ACCENT_TEXT = 'text-[var(--empty-state-accent)] dark:text-[var(--empty-state-accent-dark)]'++/**+ * `config` is the setup screen the scene would have shown if the product had no data. Taking the+ * pitch from there keeps one description of each product: the user who needs setup reads it on the+ * setup screen, and the user who already has data reads the same words here.+ */+export function ProductPushWelcomeModal({+ welcome,+ config,+ onClose,+}: {+ welcome: PendingProductPushWelcome+ config?: ProductEmptyStateConfig+ onClose: (source: ProductPushWelcomeCloseSource) => void+}): JSX.Element {+ const text = config?.text['needs-setup']+ const productName = config?.productName ?? welcome.label++ return (+ <LemonModal+ isOpen+ onClose={() => onClose('modal_close')}+ width={480}+ title={+ <span className="flex items-center gap-2" style={accentVariables(config)}>+ {config ? <span className={`flex ${ACCENT_TEXT}`}>{config.icon}</span> : null}+ <span>Welcome to {productName}</span>+ </span>+ }+ data-attr="product-push-welcome"+ footer={+ <div className="flex w-full items-center justify-between gap-2">+ {config?.docsUrl ? (+ <LemonButton+ type="tertiary"+ size="small"+ icon={<IconBook />}+ to={config.docsUrl}+ targetBlank+ data-attr="product-push-welcome-docs"+ >+ Read the docs+ </LemonButton>+ ) : (+ <div />+ )}+ <LemonButton+ type="primary"+ onClick={() => onClose('start_exploring')}+ data-attr="product-push-welcome-close"+ >+ Start exploring+ </LemonButton>+ </div>+ }+ >+ {config && text ? (+ <ProductIntro config={config} text={text} />+ ) : (+ // A product with no setup screen has only the card's own blurb to introduce it.+ <div className="overflow-hidden rounded border bg-surface-primary text-xs">+ <ProductHogHero+ hero={getProductPushDisplay(welcome.productKey)}+ title={welcome.label}+ text={welcome.text}+ />+ </div>+ )}+ </LemonModal>+ )+}++function ProductIntro({ config, text }: { config: ProductEmptyStateConfig; text: ProductEmptyStateText }): JSX.Element {+ const Hedgehog = config.hedgehog+ return (+ <div className="flex items-start gap-4" style={accentVariables(config)}>+ {Hedgehog ? <Hedgehog className="w-24 shrink-0" /> : null}+ <div className="flex min-w-0 flex-col gap-1">+ <h3 className="m-0 text-base font-semibold">{text.headline}</h3>+ <p className="m-0 text-sm text-secondary">{text.lead}</p>+ </div>+ </div>+ )+}++function accentVariables(config?: ProductEmptyStateConfig): CSSProperties | undefined {+ return config+ ? ({+ '--empty-state-accent': config.accentColor,+ '--empty-state-accent-dark': config.accentColorDark ?? config.accentColor,+ } as CSSProperties)+ : undefined+}diff --git a/frontend/src/lib/components/NavPanelAdvertisement/navPanelAdShared.tsx b/frontend/src/lib/components/NavPanelAdvertisement/navPanelAdShared.tsxindex c49990148a9d..a62822ccc254 100644--- a/frontend/src/lib/components/NavPanelAdvertisement/navPanelAdShared.tsx+++ b/frontend/src/lib/components/NavPanelAdvertisement/navPanelAdShared.tsx@@ -178,7 +178,9 @@ export function AdvertisementCard({)return (- <div className="overflow-hidden rounded border bg-surface-primary text-xs shadow-sm transition-shadow hover:shadow-md">+ // The gap to the nav footer's buttons belongs to the card, not the footer, so it goes away+ // with the card when there is nothing to advertise.+ <div className="mb-2 overflow-hidden rounded border bg-surface-primary text-xs shadow-sm transition-shadow hover:shadow-md">{hero ? (<ProductHogHero hero={hero} title={title} text={text} topRight={dismissButton} />) : (diff --git a/frontend/src/lib/components/NavPanelAdvertisement/navPanelProductPushAdLogic.test.ts b/frontend/src/lib/components/NavPanelAdvertisement/navPanelProductPushAdLogic.test.tsnew file mode 100644index 000000000000..4b287435a4bf--- /dev/null+++ b/frontend/src/lib/components/NavPanelAdvertisement/navPanelProductPushAdLogic.test.ts@@ -0,0 +1,54 @@+import * as productIntents from 'lib/utils/product-intents'++import { ProductKey } from '~/queries/schema/schema-general'+import { initKeaTests } from '~/test/init'++import type { ProductPushCampaignApi } from 'products/growth/frontend/generated/api.schemas'++import { navPanelProductPushAdLogic } from './navPanelProductPushAdLogic'+import { navPanelProductPushWelcomeLogic } from './navPanelProductPushWelcomeLogic'++const campaignFor = (productKey: string, productPath: string | null): ProductPushCampaignApi => ({+ id: '0197c2a2-0000-0000-0000-000000000000',+ product_key: productKey,+ product_path: productPath,+ reason_text: 'Watch real sessions.',+ started_at: '2026-07-01T00:00:00Z',+ ends_at: '2026-07-31T00:00:00Z',+})++describe('navPanelProductPushAdLogic', () => {+ let logic: ReturnType<typeof navPanelProductPushAdLogic.build>++ beforeEach(() => {+ initKeaTests()+ jest.spyOn(productIntents, 'addProductIntent').mockResolvedValue(null)+ })++ afterEach(() => {+ logic?.unmount()+ jest.restoreAllMocks()+ })++ // The welcome modal follows the click through the navigation it starts, so a click that can+ // never land on the pushed product's own scene must not leave one queued behind.+ it.each([+ [+ 'a click into the app queues the welcome it will open there',+ ProductKey.SESSION_REPLAY,+ 'Session replay',+ true,+ ],+ ['a click that leaves the app queues nothing', ProductKey.POSTHOG_DESKTOP, 'PostHog Desktop', false],+ ['a click on a surface with no product scene queues nothing', ProductKey.SELF_DRIVING, null, false],+ ])('%s', (_description, productKey, productPath, queued) => {+ logic = navPanelProductPushAdLogic({ campaign: campaignFor(productKey, productPath) })+ logic.mount()++ logic.actions.reportAdClicked()++ expect(navPanelProductPushWelcomeLogic.findMounted()?.values.pending?.productKey ?? null).toBe(+ queued ? productKey : null+ )+ })+})diff --git a/frontend/src/lib/components/NavPanelAdvertisement/navPanelProductPushAdLogic.ts b/frontend/src/lib/components/NavPanelAdvertisement/navPanelProductPushAdLogic.tsindex d11975a5a6ae..9e49d55b2f62 100644--- a/frontend/src/lib/components/NavPanelAdvertisement/navPanelProductPushAdLogic.ts+++ b/frontend/src/lib/components/NavPanelAdvertisement/navPanelProductPushAdLogic.ts@@ -3,6 +3,7 @@ import posthog from 'posthog-js'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { addProductIntent } from 'lib/utils/product-intents'+import { isExternalLink } from 'lib/utils/url'import { getTreeItemsProducts } from '~/products'import { FileSystemImport, ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'@@ -13,6 +14,7 @@ import type { FeatureFlagsSet } from '../../logic/featureFlagLogic'import { NAV_PANEL_CARD_TYPE, type ProductPushDisplay } from './navPanelAdShared'import { navPanelAdvertisementLogic } from './NavPanelAdvertisementLogic'import { getProductPushDisplay } from './navPanelProductPushDisplay'+import { navPanelProductPushWelcomeLogic } from './navPanelProductPushWelcomeLogic'export type NavPanelProductPushAdLogicProps = {campaign: ProductPushCampaignApi@@ -36,6 +38,9 @@ export interface navPanelProductPushAdLogicValues {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface navPanelProductPushAdLogicActions {+ setPendingWelcome: (welcome: import('./navPanelProductPushWelcomeVisibility').PendingProductPushWelcome) => {+ welcome: import('./navPanelProductPushWelcomeVisibility').PendingProductPushWelcome+ } // navPanelProductPushWelcomeLogicreportAdClicked: () => {value: true}@@ -78,6 +83,7 @@ export const navPanelProductPushAdLogic = kea<navPanelProductPushAdLogicType>([navPanelAdvertisementLogic({ dismissKey: dismissKey(props.campaign) }),['hidden'],],+ actions: [navPanelProductPushWelcomeLogic, ['setPendingWelcome']],})),actions({reportAdShown: true,@@ -120,7 +126,7 @@ export const navPanelProductPushAdLogic = kea<navPanelProductPushAdLogicType>([!hidden && !!destination && !flagGated,],}),- listeners(({ props }) => {+ listeners(({ props, values, actions }) => {const eventProperties = {campaign_id: props.campaign.id,product_key: props.campaign.product_key,@@ -133,11 +139,25 @@ export const navPanelProductPushAdLogic = kea<navPanelProductPushAdLogicType>([reportAdClicked: () => {posthog.capture('nav panel product push clicked', eventProperties)if (Object.values(ProductKey).includes(props.campaign.product_key as ProductKey)) {+ const productKey = props.campaign.product_key as ProductKeyaddProductIntent({- product_type: props.campaign.product_key as ProductKey,+ product_type: productKey,intent_context: ProductIntentContext.NAV_PANEL_ADVERTISEMENT_CLICKED,metadata: { campaign_id: props.campaign.id },})+ // The welcome opens on the pushed product's own scene, so only a click that can+ // reach one queues it. An external destination opens a new tab and leaves this one+ // where it is. A surface such as Slack or Self-driving has no catalog entry, so no+ // scene identifies it and no setup gate covers it, which would leave its welcome+ // queued and never opened.+ if (values.label && values.productInfo && !isExternalLink(values.destination)) {+ actions.setPendingWelcome({+ campaignId: props.campaign.id,+ productKey,+ label: values.label,+ text: props.campaign.reason_text || values.display.tagline,+ })+ }}},reportAdDismissed: () => {diff --git a/frontend/src/lib/components/NavPanelAdvertisement/navPanelProductPushWelcomeLogic.ts b/frontend/src/lib/components/NavPanelAdvertisement/navPanelProductPushWelcomeLogic.tsnew file mode 100644index 000000000000..57231b7dd3f4--- /dev/null+++ b/frontend/src/lib/components/NavPanelAdvertisement/navPanelProductPushWelcomeLogic.ts@@ -0,0 +1,88 @@+import { MakeLogicType, actions, kea, listeners, path, reducers } from 'kea'+import posthog from 'posthog-js'++import { NAV_PANEL_CARD_TYPE } from './navPanelAdShared'+import type { PendingProductPushWelcome } from './navPanelProductPushWelcomeVisibility'++/** Which control closed the welcome modal, reported as the `source` of `welcome closed`. */+export type ProductPushWelcomeCloseSource = 'start_exploring' | 'modal_close'++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface navPanelProductPushWelcomeLogicValues {+ openFor: PendingProductPushWelcome | null+ pending: PendingProductPushWelcome | null+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface navPanelProductPushWelcomeLogicActions {+ closeWelcome: (source: ProductPushWelcomeCloseSource) => {+ source: ProductPushWelcomeCloseSource+ }+ openWelcome: (welcome: PendingProductPushWelcome) => {+ welcome: PendingProductPushWelcome+ }+ setPendingWelcome: (welcome: PendingProductPushWelcome) => {+ welcome: PendingProductPushWelcome+ }+}++export type navPanelProductPushWelcomeLogicType = MakeLogicType<+ navPanelProductPushWelcomeLogicValues,+ navPanelProductPushWelcomeLogicActions+>++/**+ * Carries a click on the nav product push card through to the product's own scene. Both values are+ * in-memory: the card links within the app, so the navigation preserves them, and a click the user+ * never followed through on should not resurface in a new tab.+ */+export const navPanelProductPushWelcomeLogic = kea<navPanelProductPushWelcomeLogicType>([+ path(['lib', 'components', 'NavPanelAdvertisement', 'navPanelProductPushWelcomeLogic']),+ actions({+ setPendingWelcome: (welcome: PendingProductPushWelcome) => ({ welcome }),+ openWelcome: (welcome: PendingProductPushWelcome) => ({ welcome }),+ closeWelcome: (source: ProductPushWelcomeCloseSource) => ({ source }),+ }),+ reducers({+ pending: [+ null as PendingProductPushWelcome | null,+ {+ setPendingWelcome: (_, { welcome }) => welcome,+ // Opening consumes the click, so one click can only ever raise one modal.+ openWelcome: () => null,+ closeWelcome: () => null,+ },+ ],+ openFor: [+ null as PendingProductPushWelcome | null,+ {+ openWelcome: (_, { welcome }) => welcome,+ closeWelcome: () => null,+ setPendingWelcome: () => null,+ },+ ],+ }),+ listeners(({ selectors }) => ({+ openWelcome: ({ welcome }) => {+ posthog.capture('nav panel product push welcome shown', {+ campaign_id: welcome.campaignId,+ product_key: welcome.productKey,+ card_type: NAV_PANEL_CARD_TYPE.PRODUCT_PUSH,+ })+ },+ // `openFor` is already cleared by the time this runs, so the card it described comes from+ // the state the close acted on.+ closeWelcome: ({ source }, _, __, previousState) => {+ const welcome = selectors.openFor(previousState)+ if (!welcome) {+ return+ }+ posthog.capture('nav panel product push welcome closed', {+ campaign_id: welcome.campaignId,+ product_key: welcome.productKey,+ card_type: NAV_PANEL_CARD_TYPE.PRODUCT_PUSH,+ source,+ })+ },+ })),+])diff --git a/frontend/src/lib/components/NavPanelAdvertisement/navPanelProductPushWelcomeVisibility.test.ts b/frontend/src/lib/components/NavPanelAdvertisement/navPanelProductPushWelcomeVisibility.test.tsnew file mode 100644index 000000000000..bc824626304d--- /dev/null+++ b/frontend/src/lib/components/NavPanelAdvertisement/navPanelProductPushWelcomeVisibility.test.ts@@ -0,0 +1,135 @@+import {+ type ProductEmptyStateGateRender,+ productEmptyStateGateRender,+} from 'lib/components/ProductEmptyState/gateRender'+import type { SceneProductEmptyState } from 'lib/components/ProductEmptyState/types'+import { FEATURE_FLAGS } from 'lib/constants'++import { ProductKey } from '~/queries/schema/schema-general'++import { type PendingProductPushWelcome, shouldShowProductPushWelcome } from './navPanelProductPushWelcomeVisibility'++const PENDING: PendingProductPushWelcome = {+ campaignId: 'campaign-1',+ productKey: ProductKey.PRODUCT_ANALYTICS,+ label: 'Product analytics',+ text: 'Insights, funnels, trends, and retention.',+}++const emptyState = (extra: Partial<SceneProductEmptyState> = {}, skippable?: boolean): SceneProductEmptyState =>+ ({ config: { productKey: ProductKey.PRODUCT_ANALYTICS, skippable }, ...extra }) as SceneProductEmptyState++type GateArgs = Parameters<typeof productEmptyStateGateRender>[0]++const gateRender = (overrides: Partial<GateArgs> = {}): ProductEmptyStateGateRender =>+ productEmptyStateGateRender({+ emptyState: emptyState(),+ activeSceneId: 'ProductAnalytics',+ params: {},+ featureFlags: {},+ receivedFeatureFlags: true,+ forcedMode: null,+ status: 'needs-setup',+ skipped: false,+ ...overrides,+ })++describe('shouldShowProductPushWelcome', () => {+ // The modal stands in for a setup screen the user will not see, so the two must never both+ // claim the scene, and the one case the modal exists for (a gated scene that has data) must+ // still reach it.+ it.each<[string, Partial<Parameters<typeof shouldShowProductPushWelcome>[0]>, boolean]>([+ ['no click to follow up on', { pending: null }, false],+ [+ 'still on the scene the click came from',+ { activeSceneProductKey: ProductKey.SESSION_REPLAY, pushedProductGate: null },+ false,+ ],+ [+ 'on a scene that belongs to one product and gates on the pushed one',+ {+ pending: { ...PENDING, productKey: ProductKey.DASHBOARDS },+ activeSceneProductKey: ProductKey.PRODUCT_ANALYTICS,+ pushedProductGate: 'scene',+ },+ true,+ ],+ ['the scene gates on setup and is still resolving it', { pushedProductGate: 'loading' }, false],+ ['the scene is showing the setup screen', { pushedProductGate: 'setup' }, false],+ ['the gate handed the scene through', { pushedProductGate: 'scene' }, true],+ ['the scene has no setup screen for the pushed product', { pushedProductGate: null }, true],+ ])('%s', (_description, overrides, expected) => {+ expect(+ shouldShowProductPushWelcome({+ pending: PENDING,+ activeSceneProductKey: ProductKey.PRODUCT_ANALYTICS,+ pushedProductGate: 'setup',+ ...overrides,+ })+ ).toBe(expected)+ })++ // What the gate declares is not what it renders: it stands down for a flag or a scene scope,+ // and `?empty_state=1` puts the setup screen on a product that has data. Reading the setup+ // status alone gets both of those backwards.+ it.each<[string, Partial<GateArgs>, boolean]>([+ ['the product needs setup, so the gate is showing the screen', {}, false],+ ['the product is waiting for its first events', { status: 'waiting-for-data' }, false],+ ['detection is still running', { status: 'loading' }, false],+ ['the product already has data', { status: 'has-data' }, true],+ ['detection failed and the gate failed open', { status: 'unknown' }, true],+ ['the user skipped the setup screen', { skipped: true }, true],+ [+ 'the user skipped a product that cannot be skipped',+ { emptyState: emptyState({}, false), skipped: true },+ false,+ ],+ [+ 'the gate is off because its own feature flag is disabled',+ { emptyState: emptyState({ featureFlag: FEATURE_FLAGS.SCENE_MENU_BAR }) },+ true,+ ],+ [+ "the gate's own feature flag has not arrived yet",+ {+ emptyState: emptyState({ featureFlag: FEATURE_FLAGS.SCENE_MENU_BAR }),+ receivedFeatureFlags: false,+ },+ false,+ ],+ [+ 'the gate is scoped to scenes this one is not among',+ { emptyState: emptyState({ scenes: ['SomeOtherScene'] }) },+ true,+ ],+ [+ 'the gate is bypassed by its bypass flag',+ {+ emptyState: emptyState({ bypassFeatureFlag: FEATURE_FLAGS.SCENE_MENU_BAR }),+ featureFlags: { [FEATURE_FLAGS.SCENE_MENU_BAR]: true },+ },+ true,+ ],+ [+ 'the bypass flag has not arrived yet',+ {+ emptyState: emptyState({ bypassFeatureFlag: FEATURE_FLAGS.SCENE_MENU_BAR }),+ receivedFeatureFlags: false,+ },+ false,+ ],+ [+ 'the setup screen is forced onto a product that has data',+ { status: 'has-data', forcedMode: 'needs-setup' },+ false,+ ],+ ])('%s', (_description, overrides, expected) => {+ expect(+ shouldShowProductPushWelcome({+ pending: PENDING,+ activeSceneProductKey: ProductKey.PRODUCT_ANALYTICS,+ pushedProductGate: gateRender(overrides),+ })+ ).toBe(expected)+ })+})diff --git a/frontend/src/lib/components/NavPanelAdvertisement/navPanelProductPushWelcomeVisibility.ts b/frontend/src/lib/components/NavPanelAdvertisement/navPanelProductPushWelcomeVisibility.tsnew file mode 100644index 000000000000..d2ddafc86108--- /dev/null+++ b/frontend/src/lib/components/NavPanelAdvertisement/navPanelProductPushWelcomeVisibility.ts@@ -0,0 +1,45 @@+import type { ProductEmptyStateGateRender } from 'lib/components/ProductEmptyState/gateRender'++import type { ProductKey } from '~/queries/schema/schema-general'++export interface PendingProductPushWelcome {+ campaignId: string+ productKey: ProductKey+ label: string+ /** The blurb the card showed, which is the campaign's reason text when it set one. */+ text: string+}++export interface ProductPushWelcomeVisibility {+ pending: PendingProductPushWelcome | null+ activeSceneProductKey: ProductKey | null+ /** What the active scene's setup gate puts on screen, or null if no gate covers the pushed product. */+ pushedProductGate: ProductEmptyStateGateRender | null+}++/**+ * Product analytics is the case this exists for: every project sends events, so its setup screen+ * never shows and the click ends on a full insight list that says nothing about why the user is there.+ */+export function shouldShowProductPushWelcome({+ pending,+ activeSceneProductKey,+ pushedProductGate,+}: ProductPushWelcomeVisibility): boolean {+ if (!pending) {+ return false+ }+ // The click starts a navigation, so hold the modal back until the pushed product's own scene is+ // the one on screen. It also keeps the modal off surfaces that are not products, such as the+ // integration settings pages the Slack and GitHub cards link to. A scene can belong to one+ // product and gate on another - the dashboard list sits under product analytics and gates on+ // dashboards - so either side identifying the product counts as arriving.+ if (activeSceneProductKey !== pending.productKey && !pushedProductGate) {+ return false+ }+ if (!pushedProductGate) {+ return true+ }+ // The modal stands in for the setup screen, so it waits for the gate to hand the scene through.+ return pushedProductGate === 'scene'+}diff --git a/frontend/src/lib/components/ProductEmptyState/ProductEmptyStateGate.tsx b/frontend/src/lib/components/ProductEmptyState/ProductEmptyStateGate.tsxindex ac45e191490d..4e6b41cce8c9 100644--- a/frontend/src/lib/components/ProductEmptyState/ProductEmptyStateGate.tsx+++ b/frontend/src/lib/components/ProductEmptyState/ProductEmptyStateGate.tsx@@ -11,42 +11,16 @@ import { sceneLogic } from 'scenes/sceneLogic'import { SceneContent } from '~/layout/scenes/components/SceneContent'import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'+import {+ EMPTY_STATE_PARAM,+ activeProductEmptyStateGateRender,+ forcedModeFromParam,+ productEmptyStateGateActivation,+} from './gateRender'import { ProductEmptyState } from './ProductEmptyState'import { productSetupStatusLogic } from './productSetupStatusLogic'import { SetupReminderContext } from './setupReminderContext'-import type { GatedScene, ProductEmptyStateConfig, ProductEmptyStateMode, SceneProductEmptyState } from './types'--/**- * Search param that puts the setup screen on a scene that already has data, so anyone can- * review an empty state without emptying a project. `?empty_state=1` shows the `needs-setup`- * screen, `?empty_state=waiting-for-data` shows the other mode, and dropping the param- * returns the real scene.- */-export const EMPTY_STATE_PARAM = 'empty_state'--function forcedModeFromParam(value: unknown): ProductEmptyStateMode | null {- if (value === 'waiting-for-data') {- return 'waiting-for-data'- }- // kea-router parses search params before we see them, so `?empty_state=1` arrives as the- // number 1 and a bare `?empty_state` as null. Match those forms exactly rather than any- // truthy value, so a param we don't recognize leaves the real scene alone.- if (value === null || value === 1 || value === true || value === '1' || value === 'true') {- return 'needs-setup'- }- return null-}--function coversCurrentSurface(- gated: GatedScene,- activeSceneId: string | null,- params: Record<string, string | undefined>-): boolean {- if (typeof gated === 'string') {- return gated === activeSceneId- }- return gated.scene === activeSceneId && gated.tabs.includes(params.tab)-}+import type { ProductEmptyStateConfig, SceneProductEmptyState } from './types'export interface ProductEmptyStateGateProps {emptyState: SceneProductEmptyState@@ -76,25 +50,24 @@ export function ProductEmptyStateGate({ emptyState, params, children }: ProductE// When the empty state is flag-gated or scoped to specific scenes or tabs, stay a strict// no-op otherwise — don't even mount detection (the inner component mounts it).- if (emptyState.featureFlag && !featureFlags[emptyState.featureFlag]) {+ const activation = productEmptyStateGateActivation({+ emptyState,+ activeSceneId,+ params: params ?? {},+ featureFlags,+ receivedFeatureFlags,+ forcedMode,+ })+ if (activation === 'off') {return <>{children}</>}- if (- emptyState.scenes &&- !emptyState.scenes.some((gated) => coversCurrentSurface(gated, activeSceneId, params ?? {}))- ) {- return <>{children}</>- }- if (emptyState.bypassFeatureFlag && !receivedFeatureFlags && !forcedMode) {+ if (activation === 'awaiting-flags') {return (<ProductSceneFrame config={emptyState.config} SceneNav={emptyState.SceneNav}><SpinnerOverlay sceneLevel /></ProductSceneFrame>)}- if (emptyState.bypassFeatureFlag && featureFlags[emptyState.bypassFeatureFlag] && !forcedMode) {- return <>{children}</>- }return <ProductEmptyStateGateInner emptyState={emptyState}>{children}</ProductEmptyStateGateInner>}@@ -108,23 +81,30 @@ function ProductEmptyStateGateInner({ emptyState, children }: ProductEmptyStateGconst { searchParams } = useValues(router)const forcedMode = forcedModeFromParam(searchParams[EMPTY_STATE_PARAM])- // A lingering local skip is ignored for non-skippable products (the button may have been- // shown before the product opted out of skipping). Derived once, because the empty-state- // branch below has to reach the same verdict: honoring the skip there but not here would- // render the bare scene with neither the setup screen nor the reminder banner, and a- // non-skippable product has no button left to clear the stored flag with.+ // Has to reach the same verdict as the helper: a skip honored here but not there renders the+ // bare scene with neither the setup screen nor the reminder banner.const skipHonored = skipped && config.skippable !== false+ const gateRender = activeProductEmptyStateGateRender({ config, forcedMode, status, skipped })- // Forcing wins over skip, over the detected status, and over detection still loading.- // The whole point is to see the screen on a project that would never show it on its own.- if (forcedMode) {+ if (gateRender === 'setup') {return (<ProductSceneFrame config={config} SceneNav={emptyState.SceneNav}>- <ProductEmptyState config={config} mode={forcedMode} preview />+ <ProductEmptyState config={config} mode={forcedMode ?? mode} preview={!!forcedMode} />+ </ProductSceneFrame>+ )+ }+ if (gateRender === 'loading') {+ // One consistent loading treatment app-wide, the same scene-level spinner shown while+ // scene chunks load. `productSetupPreloadLogic` answers this ahead of time only for+ // products that declare a `setupProbe` in their manifest, which is an event-based+ // signal. Entity-count products have none, so for them the spinner is the normal path+ // on every entry, including every trip back from a detail page.+ return (+ <ProductSceneFrame config={config} SceneNav={emptyState.SceneNav}>+ <SpinnerOverlay sceneLevel /></ProductSceneFrame>)}-if (skipHonored) {// Skip bypasses the screen, not detection: render the scene, plus a "Set up" reminder// until data lands, so there's always a way back to setup.@@ -154,25 +134,6 @@ function ProductEmptyStateGateInner({ emptyState, children }: ProductEmptyStateG</>)}- if (status === 'loading') {- // One consistent loading treatment app-wide, the same scene-level spinner shown while- // scene chunks load. `productSetupPreloadLogic` answers this ahead of time only for- // products that declare a `setupProbe` in their manifest, which is an event-based- // signal. Entity-count products have none, so for them the spinner is the normal path- // on every entry, including every trip back from a detail page.- return (- <ProductSceneFrame config={config} SceneNav={emptyState.SceneNav}>- <SpinnerOverlay sceneLevel />- </ProductSceneFrame>- )- }- if (!skipHonored && (status === 'needs-setup' || status === 'waiting-for-data')) {- return (- <ProductSceneFrame config={config} SceneNav={emptyState.SceneNav}>- <ProductEmptyState config={config} mode={mode} />- </ProductSceneFrame>- )- }return <>{children}</>}diff --git a/frontend/src/lib/components/ProductEmptyState/gateRender.ts b/frontend/src/lib/components/ProductEmptyState/gateRender.tsnew file mode 100644index 000000000000..5d97463d6642--- /dev/null+++ b/frontend/src/lib/components/ProductEmptyState/gateRender.ts@@ -0,0 +1,134 @@+/**+ * What `ProductEmptyStateGate` decides, kept out of the component because the gate is a lazy chunk+ * and the surfaces that ask the same question are in the eager graph.+ */++import type { FeatureFlagsSet } from 'lib/logic/featureFlagLogic'++import type {+ GatedScene,+ ProductEmptyStateConfig,+ ProductEmptyStateMode,+ ProductSetupStatus,+ SceneProductEmptyState,+} from './types'++/**+ * Search param that puts the setup screen on a scene that already has data, so anyone can+ * review an empty state without emptying a project. `?empty_state=1` shows the `needs-setup`+ * screen, `?empty_state=waiting-for-data` shows the other mode, and dropping the param+ * returns the real scene.+ */+export const EMPTY_STATE_PARAM = 'empty_state'++export function forcedModeFromParam(value: unknown): ProductEmptyStateMode | null {+ if (value === 'waiting-for-data') {+ return 'waiting-for-data'+ }+ // kea-router parses search params before we see them, so `?empty_state=1` arrives as the+ // number 1 and a bare `?empty_state` as null. Match those forms exactly rather than any+ // truthy value, so a param we don't recognize leaves the real scene alone.+ if (value === null || value === 1 || value === true || value === '1' || value === 'true') {+ return 'needs-setup'+ }+ return null+}++function coversCurrentSurface(+ gated: GatedScene,+ activeSceneId: string | null,+ params: Record<string, string | undefined>+): boolean {+ if (typeof gated === 'string') {+ return gated === activeSceneId+ }+ return gated.scene === activeSceneId && gated.tabs.includes(params.tab)+}++export type ProductEmptyStateGateActivation = 'off' | 'awaiting-flags' | 'on'++/** What a gated scene puts on screen. */+export type ProductEmptyStateGateRender = 'scene' | 'setup' | 'loading'++export interface ProductEmptyStateGateSurface {+ emptyState: SceneProductEmptyState+ activeSceneId: string | null+ params: Record<string, string | undefined>+ featureFlags: FeatureFlagsSet+ receivedFeatureFlags: boolean+ forcedMode: ProductEmptyStateMode | null+}++export interface ProductEmptyStateGateStatus {+ config: ProductEmptyStateConfig+ forcedMode: ProductEmptyStateMode | null+ status: ProductSetupStatus+ skipped: boolean+}++export function productEmptyStateGateActivation({+ emptyState,+ activeSceneId,+ params,+ featureFlags,+ receivedFeatureFlags,+ forcedMode,+}: ProductEmptyStateGateSurface): ProductEmptyStateGateActivation {+ if (emptyState.featureFlag) {+ // An unset flag reads the same as a flag that has not arrived, so wait rather than hand the+ // scene through and take the setup screen back once the flags land.+ if (!receivedFeatureFlags) {+ return 'awaiting-flags'+ }+ if (!featureFlags[emptyState.featureFlag]) {+ return 'off'+ }+ }+ if (emptyState.scenes && !emptyState.scenes.some((gated) => coversCurrentSurface(gated, activeSceneId, params))) {+ return 'off'+ }+ if (emptyState.bypassFeatureFlag && !forcedMode) {+ if (!receivedFeatureFlags) {+ return 'awaiting-flags'+ }+ if (featureFlags[emptyState.bypassFeatureFlag]) {+ return 'off'+ }+ }+ return 'on'+}++export function activeProductEmptyStateGateRender({+ config,+ forcedMode,+ status,+ skipped,+}: ProductEmptyStateGateStatus): ProductEmptyStateGateRender {+ // Forcing wins over skip, over the detected status, and over detection still loading.+ // The whole point is to see the screen on a project that would never show it on its own.+ if (forcedMode) {+ return 'setup'+ }+ // A lingering local skip is ignored for non-skippable products (the button may have been+ // shown before the product opted out of skipping).+ if (skipped && config.skippable !== false) {+ return 'scene'+ }+ if (status === 'loading') {+ return 'loading'+ }+ return status === 'needs-setup' || status === 'waiting-for-data' ? 'setup' : 'scene'+}++export function productEmptyStateGateRender(+ surface: ProductEmptyStateGateSurface & Omit<ProductEmptyStateGateStatus, 'config'>+): ProductEmptyStateGateRender {+ const activation = productEmptyStateGateActivation(surface)+ if (activation === 'off') {+ return 'scene'+ }+ if (activation === 'awaiting-flags') {+ return 'loading'+ }+ return activeProductEmptyStateGateRender({ ...surface, config: surface.emptyState.config })+}