Skip to content

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

feat(growth): add promoted product sidebar entry and experiment plumbing (#60677)

Paul D'Ambrabd490a928ba6
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index bf67acb92528..b8c0b257923e 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -1991,7 +1991,7 @@ snapshots:
filters-taxonomic-filter-headless--properties--dark:
hash: v1.k794b7964.4ee695e5751c6f73e9742ab0cfeecf61b5adfe829cf3a0d49ab2877cae8b212f.jPN9l5TDgLRy9NzHenXHCU903UDg8-GdeGpf4PXt7aA
filters-taxonomic-filter-headless--properties--light:
- hash: v1.k794b7964.7af6b884e5d826df422db99e4a99d2172f3316561a499dbe386ea098b1fc54a9.rti2DMpqC0WEtd_AtG838vQlgQMHfwjBAR4uLN_HnUk
+ hash: v1.k794b7964.afa422fd784363e602da5668ab488a823260acba8c2b1168dc85bcbf434d3ddf.Wjl32UIE5KhBda_SpJYwXKZ2FGmnlFbtzv4uKDaJRIs
filters-taxonomic-filter-headless--suggested-filters-with-recents--dark:
hash: v1.k794b7964.f524f5031bba44f2753215e83b93aa50741a3efc012fcddcc61025e4f851ba2c.sm5eih05jClMTS8zKltGelRiDYSI_2RmOFRZjjLwsAc
filters-taxonomic-filter-headless--suggested-filters-with-recents--light:
@@ -4953,7 +4953,7 @@ snapshots:
scenes-app-insights-funnels--funnel-left-to-right-edit-viewports--wide--dark:
hash: v1.k794b7964.c47bdb853ef9b6becfb675e2ca0bdbdb0c1b4385cf2442d50dd92752d90f7906.URrKOLP9uUjbKWcui2yOA7hm_JsXsbkAlOcWJshoQrI
scenes-app-insights-funnels--funnel-left-to-right-edit-viewports--wide--light:
- hash: v1.k794b7964.c63132bb5b13cbe97938ebdb2e59e320ebc338bd12b2d3bfd6af81e56270650a.KSiw8WpvjWXIDh87ExL4cPnopVJlTXvzU8N8ruh6Hi8
+ hash: v1.k794b7964.6c391cbc05b64230fbd8defdbb960b131fd433409817497873fb9ffc705cd360.EIwByuofuT77yP259A9ffqfjSFwW9MrUDOvsZNA_aZM
scenes-app-insights-funnels--funnel-time-to-convert--dark:
hash: v1.k794b7964.d64808d2bfc36017f89b57feeaa373e20188738a622801207fa1beb59d02fdd9.cFuKF_Ow887Z3X3BoNhtTvkUWY2vips9HDBe-B02eQE
scenes-app-insights-funnels--funnel-time-to-convert--light:
@@ -5746,6 +5746,30 @@ snapshots:
hash: v1.k794b7964.05e7bbc357febe22dfaa9241cb67690c18d9a35be02078cd9fa93c3c6f448159.nJY9sqBszcQpgYRsJoUuBns50rA3wUj-QZqbf7NZbOQ
scenes-app-project-homepage--project-homepage--light:
hash: v1.k794b7964.853928313ecadc1d9daf77ddf3779f4dc42c14853b28ed9bb91dffeb5a751bbf.knbN_bMGgzgR-EoNShaqPQYhnEiWBS7_pLFWcxnka7c
+ scenes-app-promoted-product--control-no-product--dark:
+ hash: v1.k794b7964.3b25fca077ac0cc807ec471f615c94ef53b7273dea61017ca102b7c18aaaaef7.A7YCfdN3WKN3jg-PvXfWQ8DwNGDfWfWDs4a8aP5t3nc
+ scenes-app-promoted-product--control-no-product--light:
+ hash: v1.k794b7964.91546265166e73a713e1c95fae1b19d0fa6832b534fb5bf1129db0ac3a64f632.3PLnKRylgeX4xI6U4_afIIfRlnzJBrQlr7n2Yt_IRFY
+ scenes-app-promoted-product--control-with-product--dark:
+ hash: v1.k794b7964.3b25fca077ac0cc807ec471f615c94ef53b7273dea61017ca102b7c18aaaaef7.AzVJy2LeSChV_lNh2-a0n3aPUEg5XvLZF4gGX4hqxCo
+ scenes-app-promoted-product--control-with-product--light:
+ hash: v1.k794b7964.7cb1c2bd9b90795d6b9f972485097c753662232ae2913a62127ece3fbfe32896.kTCukuFnAjzfTmKCJ5VWoDmhQCzCAtB4ZmO17lAk0hM
+ scenes-app-promoted-product--intent-no-product--dark:
+ hash: v1.k794b7964.3b90c051ab58859c3f29ef6e3bad8c5334ad03f3b2e90953716e11eb3e801067.9JD9NrDzSaDwXWDRcm-NTYoXCPrrzcs9wUCXKjKrFIc
+ scenes-app-promoted-product--intent-no-product--light:
+ hash: v1.k794b7964.38b748ef36202767bd8ec460d65727fdc542f55689103864040ddd7ae975cb7d.XKID5NafvWNZiwpEQjxqQOrqnozOxfxR-39JQJ1YIXo
+ scenes-app-promoted-product--intent-plus-no-product--dark:
+ hash: v1.k794b7964.28647750dad09e9f56eaa1cc359e9984842595ee36c88654819f2b8562dc537e.sVVGIbJvoX3wjOnyA_727aZ7cJRDr5_t5EGvUbrEc38
+ scenes-app-promoted-product--intent-plus-no-product--light:
+ hash: v1.k794b7964.5b49322fc2487406ccbb1a857bc4f42808d8275e007a3b5ff7330efc514050a9.jI3XYvY4L5opXHulCPGdrzaHQBRysUIN2uoTnwrQnLQ
+ scenes-app-promoted-product--intent-plus-with-product--dark:
+ hash: v1.k794b7964.06fcf35f764644efecde6c1fc995b28f8e93ed8e4f0906215f3ecc81d67aa41a.iExzX_hgUR3pBFNkqURRNfxJ3-MhZWh-KbtixBU9CZI
+ scenes-app-promoted-product--intent-plus-with-product--light:
+ hash: v1.k794b7964.155640024eacb4f5cfc8641e8a93df0c445be8c5ec134dad882affdbff10d441.OjqFI4LoZsjtX31mo9PaWxtvu1WuEkNRXTbz1SKkziw
+ scenes-app-promoted-product--intent-with-product--dark:
+ hash: v1.k794b7964.a96bf879923bbc50e0c0a8a5fd4c51247ba600a88be9f6f59ffc0cc3355a49d2.FaiZyTP77YnTIxNb61oBpo64DxT9q-nm8jKgEviq08M
+ scenes-app-promoted-product--intent-with-product--light:
+ hash: v1.k794b7964.a520d81ca3c66ae61e8fa10602ed5f40da3d97bee4efd9daf03009c238a8b0dc.Ruf-wJ_f_UjycVlKd7vE_z2t-r_SY8cC5bO-NSR0Ao4
scenes-app-revenue-analytics--revenue-analytics-dashboard--dark:
hash: v1.k794b7964.7c2a90fe3c3a969c054186bb666664efa891d65d411a546539a968518938ea71.OoOKh-Mc_IiPWTgIV4QNPtACZXPPktfU7bjGk-q-uLE
scenes-app-revenue-analytics--revenue-analytics-dashboard--light:
diff --git a/frontend/src/generated/core/api.schemas.ts b/frontend/src/generated/core/api.schemas.ts
index 7fa3d0403b06..a780bdfd9fbb 100644
--- a/frontend/src/generated/core/api.schemas.ts
+++ b/frontend/src/generated/core/api.schemas.ts
@@ -2145,6 +2145,14 @@ export interface PatchedProjectBackwardCompatApi {
readonly available_setup_task_ids?: readonly AvailableSetupTaskIdsEnumApi[]
}
+export interface PromotedProductIntentApi {
+ /**
+ * The product key the team selected as their primary product during onboarding (e.g. `session_replay`, `web_analytics`, `product_analytics`), or `null` if no primary onboarding product intent has been captured for this team.
+ * @nullable
+ */
+ product_key: string | null
+}
+
export interface SharePasswordApi {
readonly id: number
readonly created_at: string
diff --git a/frontend/src/generated/core/api.ts b/frontend/src/generated/core/api.ts
index 60f2b4007ac0..71ceb0b9437f 100644
--- a/frontend/src/generated/core/api.ts
+++ b/frontend/src/generated/core/api.ts
@@ -53,6 +53,7 @@ import type {
ProjectBackwardCompatApi,
ProjectSecretAPIKeyApi,
ProjectSecretApiKeysListParams,
+ PromotedProductIntentApi,
PropertyDefinitionsListParams,
SharingConfigurationApi,
SubscriptionApi,
@@ -890,6 +891,27 @@ export const organizationsProjectsLogsConfigPartialUpdate = async (
)
}
+export const getOrganizationsProjectsPromotedProductIntentRetrieveUrl = (organizationId: string, id: number) => {
+ return `/api/organizations/${organizationId}/projects/${id}/promoted_product_intent/`
+}
+
+/**
+ * Return the product key (e.g. `session_replay`, `web_analytics`) this team selected as their primary product during onboarding. Resolved from the team's most recent primary-onboarding `ProductIntent` record (the one carrying the `onboarding product selected - primary` context) — not from the `user showed product intent` event, which also fires for non-onboarding contexts. Returns `null` when no primary onboarding product intent has been captured (e.g. teams created before this signal existed, or where onboarding was skipped).
+ */
+export const organizationsProjectsPromotedProductIntentRetrieve = async (
+ organizationId: string,
+ id: number,
+ options?: RequestInit
+): Promise<PromotedProductIntentApi> => {
+ return apiMutator<PromotedProductIntentApi>(
+ getOrganizationsProjectsPromotedProductIntentRetrieveUrl(organizationId, id),
+ {
+ ...options,
+ method: 'GET',
+ }
+ )
+}
+
export const getOrganizationsProjectsResetTokenPartialUpdateUrl = (organizationId: string, id: number) => {
return `/api/organizations/${organizationId}/projects/${id}/reset_token/`
}
diff --git a/frontend/src/layout/GlobalModals.tsx b/frontend/src/layout/GlobalModals.tsx
index 66e911085b76..c22da72e46be 100644
--- a/frontend/src/layout/GlobalModals.tsx
+++ b/frontend/src/layout/GlobalModals.tsx
@@ -20,12 +20,15 @@ import { InviteModal } from 'scenes/settings/organization/InviteModal'
import { PreviewingCustomCssModal } from 'scenes/themes/PreviewingCustomCssModal'
import { MaybeWelcomeDialog } from 'scenes/welcome/WelcomeDialog'
+import { promotedProductLogic } from '~/layout/panel-layout/ai-first/promotedProductLogic'
+
import { ComposeTicketModal } from 'products/conversations/frontend/components/ComposeTicket'
import { LogsViewerModal } from 'products/logs/frontend/components/LogsViewer/LogsViewerModal'
import type { globalModalsLogicType } from './GlobalModalsType'
import { navigationLogic } from './navigation/navigationLogic'
import { ConfigureHomeModal } from './scenes/ConfigureHomeModal'
+import { ConfigurePromotedProductModal } from './scenes/ConfigurePromotedProductModal'
import { GoodbyeTabsModal } from './scenes/GoodbyeTabsModal'
export const globalModalsLogic = kea<globalModalsLogicType>([
@@ -68,6 +71,8 @@ export function GlobalModals(): JSX.Element {
const { superpowersEnabled } = useValues(superpowersLogic)
const { isConfigureHomeModalOpen } = useValues(navigationLogic)
const { hideConfigureHomeModal } = useActions(navigationLogic)
+ const { isConfigureModalOpen: isConfigurePromotedProductModalOpen } = useValues(promotedProductLogic)
+ const { hideConfigureModal: hideConfigurePromotedProductModal } = useActions(promotedProductLogic)
return (
<>
@@ -88,6 +93,10 @@ export function GlobalModals(): JSX.Element {
<ItemSelectModal />
{superpowersEnabled && <SuperpowersModal />}
<ConfigureHomeModal isOpen={isConfigureHomeModalOpen} onClose={hideConfigureHomeModal} />
+ <ConfigurePromotedProductModal
+ isOpen={isConfigurePromotedProductModalOpen}
+ onClose={hideConfigurePromotedProductModal}
+ />
<GoodbyeTabsModal />
<MaybeWelcomeDialog />
<ComposeTicketModal />
diff --git a/frontend/src/layout/panel-layout/ai-first/NavLink.tsx b/frontend/src/layout/panel-layout/ai-first/NavLink.tsx
index 1449c60e83fb..0af247783aec 100644
--- a/frontend/src/layout/panel-layout/ai-first/NavLink.tsx
+++ b/frontend/src/layout/panel-layout/ai-first/NavLink.tsx
@@ -1,4 +1,4 @@
-import { useActions, useValues } from 'kea'
+import { useValues } from 'kea'
import { IconGear } from '@posthog/icons'
@@ -8,24 +8,38 @@ import { cn } from 'lib/utils/css-classes'
import { removeProjectIdIfPresent } from 'lib/utils/router-utils'
import { urls } from 'scenes/urls'
-import { navigationLogic } from '~/layout/navigation/navigationLogic'
import { panelLayoutLogic } from '~/layout/panel-layout/panelLayoutLogic'
+export interface NavLinkSideAction {
+ onClick: (e: React.MouseEvent) => void
+ tooltip: string
+ 'data-attr'?: string
+}
+
interface NavLinkProps {
to: string
label: string
icon: React.ReactNode
isCollapsed: boolean
'data-attr'?: string
- onClick?: () => void
+ onClick?: (e: React.MouseEvent) => void
+ sideAction?: NavLinkSideAction
}
-export function NavLink({ to, label, icon, isCollapsed, 'data-attr': dataAttr, onClick }: NavLinkProps): JSX.Element {
+export function NavLink({
+ to,
+ label,
+ icon,
+ isCollapsed,
+ 'data-attr': dataAttr,
+ onClick,
+ sideAction,
+}: NavLinkProps): JSX.Element {
const { pathname } = useValues(panelLayoutLogic)
- const { showConfigureHomeModal } = useActions(navigationLogic)
const isHomePage = to === urls.projectRoot()
const currentPath = removeProjectIdIfPresent(pathname)
const isActive = currentPath === to || (isHomePage && currentPath === urls.projectHomepage())
+ const hasSideActionRight = !!sideAction && !isCollapsed
return (
<ButtonGroupPrimitive
@@ -38,7 +52,7 @@ export function NavLink({ to, label, icon, isCollapsed, 'data-attr': dataAttr, o
iconOnly: isCollapsed,
className: 'group -outline-offset-2',
active: isActive,
- hasSideActionRight: isHomePage && !isCollapsed,
+ hasSideActionRight,
}}
to={to}
data-attr={dataAttr}
@@ -65,18 +79,18 @@ export function NavLink({ to, label, icon, isCollapsed, 'data-attr': dataAttr, o
</span>
)}
</Link>
- {isHomePage && !isCollapsed && (
+ {hasSideActionRight && sideAction && (
<ButtonPrimitive
className="group -outline-offset-2"
iconOnly
isSideActionRight
onClick={(e) => {
e.stopPropagation()
- showConfigureHomeModal()
+ sideAction.onClick(e)
}}
- tooltip="Configure home"
+ tooltip={sideAction.tooltip}
tooltipPlacement="right"
- data-attr="nav-configure-home"
+ data-attr={sideAction['data-attr']}
>
<IconGear className="size-3 text-tertiary opacity-70 group-hover:text-primary group-hover:opacity-100" />
</ButtonPrimitive>
diff --git a/frontend/src/layout/panel-layout/ai-first/PromotedProductNavItem.stories.tsx b/frontend/src/layout/panel-layout/ai-first/PromotedProductNavItem.stories.tsx
new file mode 100644
index 000000000000..9f878c3dd405
--- /dev/null
+++ b/frontend/src/layout/panel-layout/ai-first/PromotedProductNavItem.stories.tsx
@@ -0,0 +1,101 @@
+import { Meta, StoryObj, type Decorator } from '@storybook/react'
+
+import { FEATURE_FLAGS } from 'lib/constants'
+import { getAppContext } from 'lib/utils/getAppContext'
+import { App } from 'scenes/App'
+import { urls } from 'scenes/urls'
+
+import { mswDecorator } from '~/mocks/browser'
+
+import { localStorageOverrideKey, localStorageProductKey } from './promotedProductLogic'
+
+/**
+ * The promoted-product entry lives in the left project nav, so these stories render the
+ * full `App` with the navigation captured. We vary only the two inputs that decide what
+ * the slot shows: the `promoted-product` flag variant and whether the team has a primary
+ * onboarding product. With no product, `intent`/`intent_plus` fall back to a dashboards link.
+ */
+const withPromotedProductIntent =
+ (intent: string | null): Decorator =>
+ (Story) => {
+ const ctx = getAppContext()
+ const teamId = ctx?.current_team?.id
+ if (teamId != null) {
+ // Clear any leakage from a previous story so AppContext is the only source.
+ window.localStorage.removeItem(localStorageProductKey(teamId))
+ window.localStorage.removeItem(localStorageOverrideKey(teamId))
+ }
+ if (ctx) {
+ ctx.promoted_product_intent = intent
+ }
+ return <Story />
+ }
+
+const meta: Meta = {
+ component: App,
+ title: 'Scenes-App/Promoted Product',
+ parameters: {
+ layout: 'fullscreen',
+ viewMode: 'story',
+ pageUrl: urls.dashboards(),
+ testOptions: {
+ includeNavigationInSnapshot: true,
+ },
+ },
+ decorators: [
+ mswDecorator({
+ get: {
+ '/api/projects/:team_id/dashboard_templates/': {},
+ '/api/projects/:id/integrations': { results: [] },
+ '/api/organizations/:organization_id/pipeline_destinations/': { results: [] },
+ '/api/projects/:id/pipeline_destination_configs/': { results: [] },
+ '/api/projects/:id/batch_exports/': { results: [] },
+ '/api/projects/:id/surveys/': { results: [] },
+ '/api/projects/:id/surveys/responses_count/': { results: [] },
+ '/api/environments/:team_id/exports/': { results: [] },
+ '/api/environments/:team_id/events': { results: [] },
+ },
+ post: {
+ '/api/environments/:team_id/query/:kind': {},
+ },
+ }),
+ ],
+}
+export default meta
+
+type Story = StoryObj
+
+const PROMOTED_PRODUCT = 'session_replay'
+
+// control: the entry never renders, with or without a product.
+export const ControlNoProduct: Story = {
+ parameters: { featureFlags: { [FEATURE_FLAGS.PROMOTED_PRODUCT]: 'control' } },
+ decorators: [withPromotedProductIntent(null)],
+}
+
+export const ControlWithProduct: Story = {
+ parameters: { featureFlags: { [FEATURE_FLAGS.PROMOTED_PRODUCT]: 'control' } },
+ decorators: [withPromotedProductIntent(PROMOTED_PRODUCT)],
+}
+
+// intent: renders the entry; falls back to a dashboards link when there's no product.
+export const IntentNoProduct: Story = {
+ parameters: { featureFlags: { [FEATURE_FLAGS.PROMOTED_PRODUCT]: 'intent' } },
+ decorators: [withPromotedProductIntent(null)],
+}
+
+export const IntentWithProduct: Story = {
+ parameters: { featureFlags: { [FEATURE_FLAGS.PROMOTED_PRODUCT]: 'intent' } },
+ decorators: [withPromotedProductIntent(PROMOTED_PRODUCT)],
+}
+
+// intent_plus: same as intent, plus the configure cog.
+export const IntentPlusNoProduct: Story = {
+ parameters: { featureFlags: { [FEATURE_FLAGS.PROMOTED_PRODUCT]: 'intent_plus' } },
+ decorators: [withPromotedProductIntent(null)],
+}
+
+export const IntentPlusWithProduct: Story = {
+ parameters: { featureFlags: { [FEATURE_FLAGS.PROMOTED_PRODUCT]: 'intent_plus' } },
+ decorators: [withPromotedProductIntent(PROMOTED_PRODUCT)],
+}
diff --git a/frontend/src/layout/panel-layout/ai-first/PromotedProductNavItem.tsx b/frontend/src/layout/panel-layout/ai-first/PromotedProductNavItem.tsx
new file mode 100644
index 000000000000..ee1d737485f1
--- /dev/null
+++ b/frontend/src/layout/panel-layout/ai-first/PromotedProductNavItem.tsx
@@ -0,0 +1,53 @@
+import { useActions, useValues } from 'kea'
+
+import { IconDashboard } from '@posthog/icons'
+
+import { getProductIcon } from 'scenes/onboarding/utils'
+
+import { NavLink } from './NavLink'
+import {
+ FALLBACK_PRODUCT_KEY,
+ labelForPromotedProductKey,
+ promotedProductLogic,
+ urlForPromotedProductKey,
+} from './promotedProductLogic'
+
+interface PromotedProductNavItemProps {
+ isCollapsed: boolean
+}
+
+export function PromotedProductNavItem({ isCollapsed }: PromotedProductNavItemProps): JSX.Element | null {
+ const { shouldRenderEntry, shouldRenderCog, effectiveProductKey } = useValues(promotedProductLogic)
+ const { trackPromotedProductClick, showConfigureModal } = useActions(promotedProductLogic)
+
+ if (!shouldRenderEntry || !effectiveProductKey) {
+ return null
+ }
+
+ const icon =
+ effectiveProductKey === FALLBACK_PRODUCT_KEY ? (
+ <IconDashboard />
+ ) : (
+ getProductIcon(null, { productType: effectiveProductKey })
+ )
+
+ return (
+ <NavLink
+ to={urlForPromotedProductKey(effectiveProductKey) ?? '#'}
+ label={labelForPromotedProductKey(effectiveProductKey)}
+ icon={icon}
+ isCollapsed={isCollapsed}
+ data-attr="nav-item-promoted-product"
+ onClick={() => trackPromotedProductClick()}
+ sideAction={
+ shouldRenderCog
+ ? {
+ onClick: () => showConfigureModal(),
+ tooltip: 'Configure promoted product',
+ 'data-attr': 'nav-configure-promoted-product',
+ }
+ : undefined
+ }
+ />
+ )
+}
diff --git a/frontend/src/layout/panel-layout/ai-first/promotedProductLogic.test.ts b/frontend/src/layout/panel-layout/ai-first/promotedProductLogic.test.ts
new file mode 100644
index 000000000000..b6c39cb3a9db
--- /dev/null
+++ b/frontend/src/layout/panel-layout/ai-first/promotedProductLogic.test.ts
@@ -0,0 +1,287 @@
+import { MOCK_TEAM_ID } from 'lib/api.mock'
+
+import { expectLogic } from 'kea-test-utils'
+import posthog from 'posthog-js'
+
+import { FEATURE_FLAGS } from 'lib/constants'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+
+import { initKeaTests } from '~/test/init'
+
+import { localStorageOverrideKey, localStorageProductKey, promotedProductLogic } from './promotedProductLogic'
+
+const PRODUCT_KEY = localStorageProductKey(MOCK_TEAM_ID)
+const OVERRIDE_KEY = localStorageOverrideKey(MOCK_TEAM_ID)
+
+jest.mock('posthog-js')
+const mockedPosthog = posthog as jest.Mocked<typeof posthog>
+
+describe('promotedProductLogic', () => {
+ let logic: ReturnType<typeof promotedProductLogic.build>
+
+ const setFlagVariant = (variant: string | boolean | undefined): void => {
+ featureFlagLogic.actions.setFeatureFlags(
+ variant ? [FEATURE_FLAGS.PROMOTED_PRODUCT] : [],
+ variant ? { [FEATURE_FLAGS.PROMOTED_PRODUCT]: variant } : {}
+ )
+ }
+
+ const mountLogic = (): void => {
+ logic = promotedProductLogic()
+ logic.mount()
+ }
+
+ beforeEach(() => {
+ jest.clearAllMocks()
+ window.localStorage.clear()
+ initKeaTests()
+ featureFlagLogic.mount()
+ })
+
+ afterEach(() => {
+ if (logic) {
+ logic.unmount()
+ }
+ })
+
+ describe('variant gating', () => {
+ it.each([
+ ['control', false, false],
+ ['control_b', false, false],
+ ['intent', true, false],
+ ['intent_plus', true, true],
+ ])('variant=%s -> shouldRenderEntry=%s shouldRenderCog=%s', async (variant, renderEntry, renderCog) => {
+ window.localStorage.setItem(PRODUCT_KEY, 'session_replay')
+ mountLogic()
+ setFlagVariant(variant)
+
+ await expectLogic(logic).toMatchValues({
+ variant,
+ shouldRenderEntry: renderEntry,
+ shouldRenderCog: renderCog,
+ })
+ })
+
+ it('hides entry when flag is missing', async () => {
+ window.localStorage.setItem(PRODUCT_KEY, 'session_replay')
+ mountLogic()
+ setFlagVariant(undefined)
+
+ await expectLogic(logic).toMatchValues({
+ variant: null,
+ shouldRenderEntry: false,
+ })
+ })
+
+ it('falls back to dashboards when no intent is available', async () => {
+ mountLogic()
+ setFlagVariant('intent')
+
+ await expectLogic(logic).toMatchValues({
+ effectiveProductKey: 'dashboards',
+ shouldRenderEntry: true,
+ })
+ })
+ })
+
+ describe('effectiveProductKey', () => {
+ it('resolves from localStorage when set', async () => {
+ window.localStorage.setItem(PRODUCT_KEY, 'web_analytics')
+ mountLogic()
+ setFlagVariant('intent')
+
+ await expectLogic(logic).toMatchValues({ effectiveProductKey: 'web_analytics' })
+ })
+
+ it('intent_plus prefers override over onboarding intent', async () => {
+ window.localStorage.setItem(PRODUCT_KEY, 'session_replay')
+ window.localStorage.setItem(OVERRIDE_KEY, 'web_analytics')
+ mountLogic()
+ setFlagVariant('intent_plus')
+
+ await expectLogic(logic).toMatchValues({ effectiveProductKey: 'web_analytics' })
+ })
+
+ it('intent variant ignores the override (cog is intent_plus only)', async () => {
+ window.localStorage.setItem(PRODUCT_KEY, 'session_replay')
+ window.localStorage.setItem(OVERRIDE_KEY, 'web_analytics')
+ mountLogic()
+ setFlagVariant('intent')
+
+ await expectLogic(logic).toMatchValues({ effectiveProductKey: 'session_replay' })
+ })
+
+ it('falls back to dashboards for an unknown product key', async () => {
+ window.localStorage.setItem(PRODUCT_KEY, 'fictional_product')
+ mountLogic()
+ setFlagVariant('intent')
+
+ await expectLogic(logic).toMatchValues({
+ effectiveProductKey: 'dashboards',
+ shouldRenderEntry: true,
+ })
+ })
+
+ it('ignores an unknown override', async () => {
+ window.localStorage.setItem(PRODUCT_KEY, 'session_replay')
+ window.localStorage.setItem(OVERRIDE_KEY, 'not_a_product')
+ mountLogic()
+ setFlagVariant('intent_plus')
+
+ await expectLogic(logic).toMatchValues({ effectiveProductKey: 'session_replay' })
+ })
+ })
+
+ describe('defaultProductKey', () => {
+ it.each([
+ ['web_analytics', 'web_analytics'],
+ ['fictional_product', 'dashboards'],
+ ])('intent=%s -> defaultProductKey=%s', async (intent, expected) => {
+ window.localStorage.setItem(PRODUCT_KEY, intent)
+ mountLogic()
+ setFlagVariant('intent_plus')
+
+ await expectLogic(logic).toMatchValues({ defaultProductKey: expected })
+ })
+
+ it('falls back to dashboards with no intent', async () => {
+ mountLogic()
+ setFlagVariant('intent_plus')
+
+ await expectLogic(logic).toMatchValues({ defaultProductKey: 'dashboards' })
+ })
+ })
+
+ describe('tracking', () => {
+ it('captures click with the product key', async () => {
+ window.localStorage.setItem(PRODUCT_KEY, 'session_replay')
+ mountLogic()
+ setFlagVariant('intent')
+
+ logic.actions.trackPromotedProductClick()
+
+ expect(mockedPosthog.capture).toHaveBeenCalledWith(
+ 'promoted product clicked',
+ expect.objectContaining({ variant: 'intent', product_key: 'session_replay' })
+ )
+ })
+
+ it('does not capture click for a non-entry variant', async () => {
+ mountLogic()
+ setFlagVariant('control')
+
+ logic.actions.trackPromotedProductClick()
+
+ expect(mockedPosthog.capture).not.toHaveBeenCalledWith('promoted product clicked', expect.anything())
+ })
+
+ it('captures config opened with the current product', async () => {
+ window.localStorage.setItem(PRODUCT_KEY, 'session_replay')
+ mountLogic()
+ setFlagVariant('intent_plus')
+
+ logic.actions.showConfigureModal()
+
+ expect(mockedPosthog.capture).toHaveBeenCalledWith(
+ 'promoted product config opened',
+ expect.objectContaining({ variant: 'intent_plus', current_product: 'session_replay' })
+ )
+ })
+
+ it('persists override to localStorage and captures config changed', async () => {
+ window.localStorage.setItem(PRODUCT_KEY, 'session_replay')
+ mountLogic()
+ setFlagVariant('intent_plus')
+
+ logic.actions.setOverride('web_analytics', logic.values.effectiveProductKey)
+
+ expect(window.localStorage.getItem(OVERRIDE_KEY)).toBe('web_analytics')
+ expect(mockedPosthog.capture).toHaveBeenCalledWith(
+ 'promoted product config changed',
+ expect.objectContaining({ variant: 'intent_plus', from: 'session_replay', to: 'web_analytics' })
+ )
+
+ await expectLogic(logic).toMatchValues({ effectiveProductKey: 'web_analytics' })
+ })
+
+ it('captures the product showing at change time as `from` on repeated overrides', async () => {
+ window.localStorage.setItem(PRODUCT_KEY, 'session_replay')
+ mountLogic()
+ setFlagVariant('intent_plus')
+
+ logic.actions.setOverride('web_analytics', logic.values.effectiveProductKey)
+ logic.actions.setOverride('feature_flags', logic.values.effectiveProductKey)
+
+ expect(mockedPosthog.capture).toHaveBeenLastCalledWith(
+ 'promoted product config changed',
+ expect.objectContaining({ from: 'web_analytics', to: 'feature_flags' })
+ )
+ })
+
+ it('clearOverride removes localStorage entry, reverts to intent, and reports the change', async () => {
+ window.localStorage.setItem(PRODUCT_KEY, 'session_replay')
+ window.localStorage.setItem(OVERRIDE_KEY, 'web_analytics')
+ mountLogic()
+ setFlagVariant('intent_plus')
+
+ logic.actions.clearOverride(logic.values.effectiveProductKey)
+
+ expect(window.localStorage.getItem(OVERRIDE_KEY)).toBeNull()
+ expect(mockedPosthog.capture).toHaveBeenCalledWith(
+ 'promoted product config changed',
+ expect.objectContaining({ from: 'web_analytics', to: 'session_replay' })
+ )
+ await expectLogic(logic).toMatchValues({ effectiveProductKey: 'session_replay' })
+ })
+ })
+
+ describe('modal state', () => {
+ it('opens and closes the configure modal', async () => {
+ mountLogic()
+
+ await expectLogic(logic).toMatchValues({ isConfigureModalOpen: false })
+
+ logic.actions.showConfigureModal()
+ await expectLogic(logic).toMatchValues({ isConfigureModalOpen: true })
+
+ logic.actions.hideConfigureModal()
+ await expectLogic(logic).toMatchValues({ isConfigureModalOpen: false })
+ })
+
+ it('seeds the pending product from effectiveProductKey every time the modal opens', async () => {
+ window.localStorage.setItem(PRODUCT_KEY, 'session_replay')
+ mountLogic()
+ setFlagVariant('intent_plus')
+
+ logic.actions.showConfigureModal()
+ await expectLogic(logic).toMatchValues({ pendingProduct: 'session_replay' })
+
+ logic.actions.setOverride('web_analytics', logic.values.effectiveProductKey)
+ logic.actions.hideConfigureModal()
+ logic.actions.showConfigureModal()
+ await expectLogic(logic).toMatchValues({ pendingProduct: 'web_analytics' })
+ })
+ })
+
+ describe('team-scoped storage', () => {
+ it('ignores values stored under a different team id', () => {
+ // Simulate a different project's value lingering in this browser.
+ window.localStorage.setItem(localStorageProductKey(MOCK_TEAM_ID + 1), 'session_replay')
+ mountLogic()
+ setFlagVariant('intent')
+
+ // Current team has no stored intent, so falls through to APP_CONTEXT/null.
+ expect(logic.values.promotedProductIntent).toBeNull()
+ })
+
+ it('writes the override under the current-team key, not a global one', () => {
+ mountLogic()
+ setFlagVariant('intent_plus')
+ logic.actions.setOverride('web_analytics', logic.values.effectiveProductKey)
+
+ expect(window.localStorage.getItem(OVERRIDE_KEY)).toBe('web_analytics')
+ // The legacy global key should not be touched.
+ expect(window.localStorage.getItem('posthog-promoted-product-override')).toBeNull()
+ })
+ })
+})
diff --git a/frontend/src/layout/panel-layout/ai-first/promotedProductLogic.ts b/frontend/src/layout/panel-layout/ai-first/promotedProductLogic.ts
new file mode 100644
index 000000000000..dba166f50012
--- /dev/null
+++ b/frontend/src/layout/panel-layout/ai-first/promotedProductLogic.ts
@@ -0,0 +1,258 @@
+import { actions, afterMount, connect, kea, listeners, path, reducers, selectors } from 'kea'
+import posthog from 'posthog-js'
+
+import { FEATURE_FLAGS } from 'lib/constants'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import { getAppContext } from 'lib/utils/getAppContext'
+
+import type { promotedProductLogicType } from './promotedProductLogicType'
+
+const PROMOTED_PRODUCT_VARIANTS = ['control', 'control_b', 'intent', 'intent_plus'] as const
+export type PromotedProductVariant = (typeof PROMOTED_PRODUCT_VARIANTS)[number]
+
+/** Product the slot falls back to when an entry-showing variant resolves no onboarding product or override. */
+export const FALLBACK_PRODUCT_KEY = 'dashboards'
+
+/** True for variants that should render the promoted-product sidebar entry. */
+export function variantShowsEntry(variant: PromotedProductVariant | null): boolean {
+ return variant === 'intent' || variant === 'intent_plus'
+}
+
+/** True for variants that let the user override the promoted product via the configure modal. */
+export function variantAllowsOverride(variant: PromotedProductVariant | null): boolean {
+ return variant === 'intent_plus'
+}
+
+// localStorage keys are team-scoped: a single browser can be logged into multiple
+// projects, and the promoted product for project A shouldn't leak into project B.
+// `currentTeamId()` resolves the team from `getAppContext()` (always present after auth).
+function currentTeamId(): number | null {
+ const id = getAppContext()?.current_team?.id
+ return typeof id === 'number' ? id : null
+}
+
+export function localStorageProductKey(teamId: number): string {
+ return `posthog-promoted-product:${teamId}`
+}
+
+export function localStorageOverrideKey(teamId: number): string {
+ return `posthog-promoted-product-override:${teamId}`
+}
+
+/**
+ * Single source of truth for the promoted-product registry — one record per product,
+ * so a product's url and label can't drift apart. The helpers below index it directly.
+ *
+ * Labels follow PostHog's sentence-case convention (CLAUDE.md) — proper-noun
+ * acronyms (LLM, AI) stay capitalised, everything else is sentence case.
+ */
+interface PromotedProductInfo {
+ url: string
+ /** Display label shown in the sidebar entry and the configure modal. */
+ label: string
+}
+
+const PRODUCT_REGISTRY: Record<string, PromotedProductInfo> = {
+ dashboards: { url: '/dashboard', label: 'Dashboards' },
+ product_analytics: { url: '/insights', label: 'Product analytics' },
+ web_analytics: { url: '/web', label: 'Web analytics' },
+ session_replay: { url: '/replay', label: 'Session replay' },
+ llm_analytics: { url: '/ai-observability', label: 'LLM analytics' },
+ error_tracking: { url: '/error_tracking', label: 'Error tracking' },
+ feature_flags: { url: '/feature_flags', label: 'Feature flags' },
+ experiments: { url: '/experiments', label: 'Experiments' },
+ surveys: { url: '/surveys', label: 'Surveys' },
+ logs: { url: '/logs', label: 'Logs' },
+ data_warehouse: { url: '/data-warehouse', label: 'Data warehouse' },
+ workflows: { url: '/workflows', label: 'Workflows' },
+ marketing_analytics: { url: '/marketing', label: 'Marketing analytics' },
+}
+
+/** Selectable product keys for the configure modal, in registry order. */
+export const PROMOTED_PRODUCT_KEYS: string[] = Object.keys(PRODUCT_REGISTRY)
+
+export function labelForPromotedProductKey(productKey: string): string {
+ return PRODUCT_REGISTRY[productKey]?.label ?? productKey
+}
+
+export function urlForPromotedProductKey(productKey: string): string | null {
+ return PRODUCT_REGISTRY[productKey]?.url ?? null
+}
+
+/** Returns the product key when it names a known promoted product, otherwise null. */
+export function resolveProductKey(productKey: string | null | undefined): string | null {
+ return productKey && productKey in PRODUCT_REGISTRY ? productKey : null
+}
+
+function readLocalStorageString(key: string): string | null {
+ try {
+ return window.localStorage.getItem(key)
+ } catch {
+ return null
+ }
+}
+
+function readPromotedProductFromStorage(): string | null {
+ const teamId = currentTeamId()
+ if (teamId === null) {
+ return null
+ }
+ return readLocalStorageString(localStorageProductKey(teamId))
+}
+
+function readPromotedProductOverrideFromStorage(): string | null {
+ const teamId = currentTeamId()
+ if (teamId === null) {
+ return null
+ }
+ return resolveProductKey(readLocalStorageString(localStorageOverrideKey(teamId)))
+}
+
+/** Persist (or, with `null`, clear) the team-scoped override. Best-effort — failures are ignored. */
+function persistOverride(productKey: string | null): void {
+ const teamId = currentTeamId()
+ if (teamId === null) {
+ return
+ }
+ const key = localStorageOverrideKey(teamId)
+ try {
+ if (productKey === null) {
+ window.localStorage.removeItem(key)
+ } else {
+ window.localStorage.setItem(key, productKey)
+ }
+ } catch {
+ // ignore — override is best-effort persistence in localStorage
+ }
+}
+
+export const promotedProductLogic = kea<promotedProductLogicType>([
+ path(['layout', 'panel-layout', 'ai-first', 'promotedProductLogic']),
+
+ connect(() => ({
+ values: [featureFlagLogic, ['featureFlags']],
+ })),
+
+ actions({
+ // `from` is the product showing at click time (effectiveProductKey) — passed in
+ // because by the time the listener runs the override reducer has already changed it.
+ setOverride: (productKey: string, from: string | null) => ({ productKey, from }),
+ clearOverride: (from: string | null) => ({ from }),
+ showConfigureModal: true,
+ hideConfigureModal: true,
+ trackPromotedProductClick: true,
+ refreshIntentFromStorage: true,
+ refreshOverrideFromStorage: true,
+ setPendingProduct: (productKey: string) => ({ productKey }),
+ }),
+
+ reducers({
+ isConfigureModalOpen: [
+ false,
+ {
+ showConfigureModal: () => true,
+ hideConfigureModal: () => false,
+ },
+ ],
+ promotedProductIntent: [
+ null as string | null,
+ {
+ refreshIntentFromStorage: () =>
+ readPromotedProductFromStorage() ?? getAppContext()?.promoted_product_intent ?? null,
+ },
+ ],
+ override: [
+ null as string | null,
+ {
+ setOverride: (_, { productKey }) => productKey,
+ clearOverride: () => null,
+ refreshOverrideFromStorage: () => readPromotedProductOverrideFromStorage(),
+ },
+ ],
+ // Pending product for the configure modal. We can't initialise it from
+ // `effectiveProductKey` here (reducer can't read selectors), so a listener on
+ // `showConfigureModal` reseeds it from the current product every time the modal
+ // opens — preventing stale state in the always-mounted modal in `GlobalModals`.
+ pendingProduct: [
+ FALLBACK_PRODUCT_KEY as string,
+ {
+ setPendingProduct: (_, { productKey }) => productKey,
+ },
+ ],
+ }),
+
+ selectors({
+ variant: [
+ (s) => [s.featureFlags],
+ (featureFlags): PromotedProductVariant | null => {
+ const raw = featureFlags[FEATURE_FLAGS.PROMOTED_PRODUCT]
+ return PROMOTED_PRODUCT_VARIANTS.includes(raw as PromotedProductVariant)
+ ? (raw as PromotedProductVariant)
+ : null
+ },
+ ],
+ // The product the slot shows with no override — onboarding intent, else the fallback.
+ // Drives the "Reset to default (…)" label so the user sees what reset reverts to.
+ defaultProductKey: [
+ (s) => [s.promotedProductIntent],
+ (intent): string => resolveProductKey(intent) ?? FALLBACK_PRODUCT_KEY,
+ ],
+ effectiveProductKey: [
+ (s) => [s.variant, s.override, s.defaultProductKey],
+ (variant, override, defaultProductKey): string | null => {
+ if (!variantShowsEntry(variant)) {
+ return null
+ }
+ return variantAllowsOverride(variant) && override ? override : defaultProductKey
+ },
+ ],
+ shouldRenderEntry: [(s) => [s.variant], (variant): boolean => variantShowsEntry(variant)],
+ shouldRenderCog: [(s) => [s.variant], (variant): boolean => variantAllowsOverride(variant)],
+ }),
+
+ listeners(({ actions, values }) => {
+ const captureConfigChanged = (from: string | null, to: string | null): void => {
+ posthog.capture('promoted product config changed', {
+ variant: values.variant,
+ from,
+ to,
+ })
+ }
+ return {
+ setOverride: ({ productKey, from }) => {
+ persistOverride(productKey)
+ captureConfigChanged(from, productKey)
+ },
+ clearOverride: ({ from }) => {
+ persistOverride(null)
+ captureConfigChanged(from, values.defaultProductKey)
+ },
+ showConfigureModal: () => {
+ // Seed the pending product from the current effectiveProductKey so the modal
+ // always opens reflecting the user's current promoted product, even after
+ // Reset-to-default or a fresh page load.
+ const productKey = values.effectiveProductKey ?? FALLBACK_PRODUCT_KEY
+ actions.setPendingProduct(productKey)
+ posthog.capture('promoted product config opened', {
+ variant: values.variant,
+ current_product: productKey,
+ })
+ },
+ trackPromotedProductClick: () => {
+ const productKey = values.effectiveProductKey
+ if (!productKey) {
+ return
+ }
+ posthog.capture('promoted product clicked', {
+ variant: values.variant,
+ product_key: productKey,
+ })
+ },
+ }
+ }),
+
+ afterMount(({ actions }) => {
+ actions.refreshIntentFromStorage()
+ actions.refreshOverrideFromStorage()
+ }),
+])
diff --git a/frontend/src/layout/panel-layout/ai-first/tabs/NavTabBrowse.tsx b/frontend/src/layout/panel-layout/ai-first/tabs/NavTabBrowse.tsx
index 7d6753f8a9e2..cec61cf70ecc 100644
--- a/frontend/src/layout/panel-layout/ai-first/tabs/NavTabBrowse.tsx
+++ b/frontend/src/layout/panel-layout/ai-first/tabs/NavTabBrowse.tsx
@@ -30,7 +30,9 @@ import { removeProjectIdIfPresent } from 'lib/utils/router-utils'
import { sceneLogic } from 'scenes/sceneLogic'
import { urls } from 'scenes/urls'
+import { navigationLogic } from '~/layout/navigation/navigationLogic'
import { NavLink } from '~/layout/panel-layout/ai-first/NavLink'
+import { PromotedProductNavItem } from '~/layout/panel-layout/ai-first/PromotedProductNavItem'
import { PanelLayoutNavIdentifier, panelLayoutLogic } from '~/layout/panel-layout/panelLayoutLogic'
import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'
import { ProjectTree } from '~/layout/panel-layout/ProjectTree/ProjectTree'
@@ -165,6 +167,7 @@ export function NavTabBrowse(): JSX.Element {
const { recentItems, recentItemsLoading } = useValues(navRecentsLogic)
const { isEditMode, checkedItems } = useValues(inlineEditAppsLogic)
const { enterEditMode, saveAndExitEditMode, toggleProduct } = useActions(inlineEditAppsLogic)
+ const { showConfigureHomeModal } = useActions(navigationLogic)
const currentPath = removeProjectIdIfPresent(pathname)
function handlePanelTriggerClick(item: PanelLayoutNavIdentifier): void {
@@ -210,8 +213,15 @@ export function NavTabBrowse(): JSX.Element {
isCollapsed={isLayoutNavCollapsed}
data-attr="nav-item-home"
onClick={() => posthog.capture('nav item clicked', { item: 'home' })}
+ sideAction={{
+ onClick: () => showConfigureHomeModal(),
+ tooltip: 'Configure home',
+ 'data-attr': 'nav-configure-home',
+ }}
/>
+ <PromotedProductNavItem isCollapsed={isLayoutNavCollapsed} />
+
{isProductAutonomyEnabled && (
<NavLink
to={urls.inbox()}
diff --git a/frontend/src/layout/scenes/ConfigurePromotedProductModal.tsx b/frontend/src/layout/scenes/ConfigurePromotedProductModal.tsx
new file mode 100644
index 000000000000..ead83ebb8f0f
--- /dev/null
+++ b/frontend/src/layout/scenes/ConfigurePromotedProductModal.tsx
@@ -0,0 +1,70 @@
+import { useActions, useValues } from 'kea'
+
+import { LemonButton, LemonSelect } from '@posthog/lemon-ui'
+
+import { LemonModal } from 'lib/lemon-ui/LemonModal'
+
+import {
+ labelForPromotedProductKey,
+ PROMOTED_PRODUCT_KEYS,
+ promotedProductLogic,
+} from '~/layout/panel-layout/ai-first/promotedProductLogic'
+
+export interface ConfigurePromotedProductModalProps {
+ isOpen: boolean
+ onClose: () => void
+}
+
+const PRODUCT_OPTIONS = PROMOTED_PRODUCT_KEYS.map((value) => ({ value, label: labelForPromotedProductKey(value) }))
+
+export function ConfigurePromotedProductModal({ isOpen, onClose }: ConfigurePromotedProductModalProps): JSX.Element {
+ const { pendingProduct, defaultProductKey, override, effectiveProductKey } = useValues(promotedProductLogic)
+ const { setPendingProduct, setOverride, clearOverride } = useActions(promotedProductLogic)
+
+ const handleSave = (): void => {
+ setOverride(pendingProduct, effectiveProductKey)
+ onClose()
+ }
+
+ const handleReset = (): void => {
+ clearOverride(effectiveProductKey)
+ onClose()
+ }
+
+ return (
+ <LemonModal
+ isOpen={isOpen}
+ onClose={onClose}
+ title="Configure promoted product"
+ description="Choose the product to show at the top of the navbar."
+ width="30rem"
+ footer={
+ <div className="flex w-full justify-between gap-2">
+ <LemonButton
+ type="tertiary"
+ onClick={handleReset}
+ disabledReason={override ? undefined : 'No override to reset'}
+ >
+ Reset to default ({labelForPromotedProductKey(defaultProductKey)})
+ </LemonButton>
+ <div className="flex gap-2">
+ <LemonButton type="secondary" onClick={onClose}>
+ Cancel
+ </LemonButton>
+ <LemonButton type="primary" onClick={handleSave} data-attr="configure-promoted-product-save">
+ Save
+ </LemonButton>
+ </div>
+ </div>
+ }
+ >
+ <LemonSelect<string>
+ fullWidth
+ value={pendingProduct}
+ onChange={(value) => setPendingProduct(value)}
+ options={PRODUCT_OPTIONS}
+ data-attr="configure-promoted-product-select"
+ />
+ </LemonModal>
+ )
+}
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index d7c94e3622c6..fd4307e4155a 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -190,6 +190,7 @@ export const FEATURE_FLAGS = {
BOX_PLOT_INSIGHT: 'box-plot-insight', // owner: @pauldambra #team-product-analytics
CALENDAR_HEATMAP_INSIGHT: 'calendar-heatmap-insight', // owner: @jabahamondes #team-web-analytics
COOKIELESS_SERVER_HASH_MODE_SETTING: 'cookieless-server-hash-mode-setting', // owner: #team-web-analytics
+ EXPERIMENT_INTERVAL_TIMESERIES: 'experiments-interval-timeseries', // owner: @jurajmajerik #team-experiments
/* The below flag is used to activate unmounting charts outside the viewport, as we're currently investigating frontend performance
issues related to this and want to know the impact of having it on vs. off. */
EXPERIMENTAL_DASHBOARD_ITEM_RENDERING: 'experimental-dashboard-item-rendering', // owner: @thmsobrmlr #team-product-analytics
@@ -225,6 +226,8 @@ export const FEATURE_FLAGS = {
WEB_ANALYTICS_REFERRER_URL_DRILLDOWN: 'web-analytics-referrer-url-drilldown', // owner: @jabahamondes #team-web-analytics
// Temporary feature flags, still WIP, should be removed eventually
+ AA_TEST_BAYESIAN_LEGACY: 'aa-test-bayesian-legacy', // owner: #team-experiments
+ AA_TEST_BAYESIAN_NEW: 'aa-test-bayesian-new', // owner: #team-experiments
ACTION_REFERENCE_COUNT: 'action-reference-count', // owner: @andyzzhao #team-product-analytics, gates bulk action reference counting on actions list
ADVANCE_MARKETING_ANALYTICS_SETTINGS: 'advance-marketing-analytics-settings', // owner: @jabahamondes #team-web-analytics
AI_EVENTS_TABLE_ROLLOUT: 'ai-events-table-rollout', // owner: #team-ai-observability, gates reads off the dedicated ai_events table
@@ -294,6 +297,7 @@ export const FEATURE_FLAGS = {
EXPERIMENTS_LLM_PROMPTS: 'experiments-llm-prompts', // owner: @jurajmajerik #team-experiments
EXPERIMENTS_SHOW_SQL: 'experiments-show-sql', // owner: @jurajmajerik #team-experiments
EXPERIMENTS_SYNC_QUERIES: 'experiments-sync-queries', // owner: @andehen #team-experiments
+ EXPERIMENTS_TEMPLATES: 'experiments-templates', // owner: @rodrigoi #team-experiments
FEATURE_FLAG_COHORT_CREATION: 'feature-flag-cohort-creation', // owner: #team-feature-flags
FEATURE_FLAG_CREATION_INTENTS: 'feature-flag-creation-intents', // owner: #team-feature-flags
FEATURE_FLAG_DRAG_DROP_CONDITIONS: 'feature-flag-drag-drop-conditions', // owner: @gustavo #team-feature-flags
@@ -432,6 +436,7 @@ export const FEATURE_FLAGS = {
PRODUCT_TOURS_LOCALIZATION: 'product-tours-localization', // owner: @adboio #team-surveys
PROJECT_SECRET_API_KEYS: 'project-secret-api-keys', // owner: #team-platform-features
PROMOTED_EVENT_PROPERTIES_EDIT: 'promoted-event-properties-edit', // owner: @pauldambra #team-product-analytics, gates the primary-property picker on the event definition edit page (flag slug kept as `promoted-event-properties-edit` to avoid migrating teams that already toggled it on)
+ PROMOTED_PRODUCT: 'promoted-product', // owner: @pauldambra #team-growth multivariate=control,control_b,intent,intent_plus, experiment for surfacing the team's primary onboarding product directly under Home
PROMPT_MANAGEMENT: 'prompt-management', // owner: #team-ai-observability
PROPERTY_ACCESS_CONTROL: 'property-access-control', // owner: @reecejones #team-platform-features
PROVISION_MANAGED_WAREHOUSE_BETA: 'provision-managed-warehouse-beta', // owner: @EDsCODE #team-managed-warehouse
diff --git a/frontend/src/scenes/onboarding/productSelection/productSelectionLogic.ts b/frontend/src/scenes/onboarding/productSelection/productSelectionLogic.ts
index f3639c10727c..905a978f5095 100644
--- a/frontend/src/scenes/onboarding/productSelection/productSelectionLogic.ts
+++ b/frontend/src/scenes/onboarding/productSelection/productSelectionLogic.ts
@@ -8,6 +8,7 @@ import { USE_CASE_OPTIONS, UseCaseOption, getRecommendedProducts } from 'scenes/
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
+import { localStorageProductKey } from '~/layout/panel-layout/ai-first/promotedProductLogic'
import { ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'
import { OnboardingStepKey } from '~/types'
@@ -292,6 +293,20 @@ export const productSelectionLogic = kea<productSelectionLogicType>([
})
})
+ // Mirror the primary onboarding choice into localStorage so the experimental
+ // 'Promoted product' sidebar entry can render immediately, without waiting
+ // for the ClickHouse-backed APP_CONTEXT value to catch up with ingestion lag.
+ if (values.firstProductOnboarding && values.currentTeam?.id) {
+ try {
+ window.localStorage.setItem(
+ localStorageProductKey(values.currentTeam.id),
+ values.firstProductOnboarding
+ )
+ } catch {
+ // localStorage disabled — APP_CONTEXT will be the fallback after ingestion.
+ }
+ }
+
// Analytics
window.posthog?.capture('onboarding_products_confirmed', {
recommendation_source: values.recommendationSource,
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index b9b085066a5d..267d51118665 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -4792,6 +4792,7 @@ export interface AppContext {
effective_resource_access_control: Record<AccessControlResourceType, AccessControlLevel>
resource_access_control: Record<AccessControlResourceType, AccessControlLevel>
custom_products: UserProductListItem[]
+ promoted_product_intent?: string | null
commit_sha?: string
/** Whether the user was autoswitched to the current item's team. */
switched_team: TeamType['id'] | null
diff --git a/posthog/api/project.py b/posthog/api/project.py
index a3cc096355b9..d95656e52792 100644
--- a/posthog/api/project.py
+++ b/posthog/api/project.py
@@ -17,7 +17,9 @@ from posthog.schema import ProductKey
from posthog.api.routing import TeamAndOrgViewSetMixin
from posthog.api.shared import ProjectBackwardCompatBasicSerializer
from posthog.api.team import (
+ PROMOTED_PRODUCT_INTENT_DESCRIPTION,
TEAM_CONFIG_MEMBER_FIELDS_SET,
+ PromotedProductIntentSerializer,
TeamSerializer,
get_or_mint_live_events_token,
handle_conversations_token_on_update,
@@ -41,6 +43,7 @@ from posthog.models.activity_logging.activity_log import (
from posthog.models.activity_logging.activity_page import activity_page_response
from posthog.models.group_type_mapping import cached_group_types_for_project
from posthog.models.organization import Organization, OrganizationMembership
+from posthog.models.product_intent import promoted_product_lookup
from posthog.models.product_intent.product_intent import (
ProductIntent,
ProductIntentSerializer,
@@ -943,6 +946,18 @@ class ProjectViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixin, viewsets
)
return activity_page_response(activity_page, limit, page, request)
+ @extend_schema(
+ tags=["platform_features"],
+ responses={200: PromotedProductIntentSerializer},
+ description=PROMOTED_PRODUCT_INTENT_DESCRIPTION,
+ )
+ @action(methods=["GET"], detail=True, required_scopes=["project:read"], url_path="promoted_product_intent")
+ def promoted_product_intent(self, request: request.Request, **kwargs) -> response.Response:
+ project = self.get_object()
+ team = project.passthrough_team
+ product_key = promoted_product_lookup.get_promoted_product_intent(team.pk)
+ return response.Response({"product_key": product_key})
+
@action(
methods=["PATCH"],
detail=True,
diff --git a/posthog/api/team.py b/posthog/api/team.py
index 30c4aeb5620d..31a0a0b67dd7 100644
--- a/posthog/api/team.py
+++ b/posthog/api/team.py
@@ -46,6 +46,7 @@ from posthog.models.event_ingestion_restriction_config import EventIngestionRest
from posthog.models.filters.utils import validate_group_type_index
from posthog.models.group_type_mapping import cached_group_types_for_team
from posthog.models.organization import OrganizationMembership
+from posthog.models.product_intent import promoted_product_lookup
from posthog.models.product_intent.product_intent import (
ProductIntentSerializer,
cached_product_intents_for_team,
@@ -144,6 +145,27 @@ def _format_serializer_errors(serializer_errors: dict) -> str:
return ". ".join(error_messages)
+PROMOTED_PRODUCT_INTENT_DESCRIPTION = (
+ "Return the product key (e.g. `session_replay`, `web_analytics`) this team selected as their primary "
+ "product during onboarding. Resolved from the team's most recent primary-onboarding `ProductIntent` "
+ "record (the one carrying the `onboarding product selected - primary` context) — not from the "
+ "`user showed product intent` event, which also fires for non-onboarding contexts. Returns `null` when no "
+ "primary onboarding product intent has been captured (e.g. teams created before this signal existed, or "
+ "where onboarding was skipped)."
+)
+
+
+class PromotedProductIntentSerializer(serializers.Serializer):
+ product_key = serializers.CharField(
+ allow_null=True,
+ help_text=(
+ "The product key the team selected as their primary product during onboarding "
+ "(e.g. `session_replay`, `web_analytics`, `product_analytics`), or `null` if no "
+ "primary onboarding product intent has been captured for this team."
+ ),
+ )
+
+
class CachingTeamSerializer(serializers.ModelSerializer):
"""
This serializer is used for caching teams.
@@ -2036,6 +2058,17 @@ class TeamViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixin, viewsets.Mo
return response.Response(TeamSerializer(team, context=self.get_serializer_context()).data)
+ @extend_schema(
+ tags=["platform_features"],
+ responses={200: PromotedProductIntentSerializer},
+ description=PROMOTED_PRODUCT_INTENT_DESCRIPTION,
+ )
+ @action(methods=["GET"], detail=True, required_scopes=["project:read"], url_path="promoted_product_intent")
+ def promoted_product_intent(self, request: request.Request, **kwargs) -> response.Response:
+ team = self.get_object()
+ product_key = promoted_product_lookup.get_promoted_product_intent(team.pk)
+ return response.Response({"product_key": product_key})
+
@action(methods=["GET"], detail=True, required_scopes=["project:read"], url_path="event_ingestion_restrictions")
def event_ingestion_restrictions(self, request, **kwargs):
team = self.get_object()
diff --git a/posthog/api/test/test_team.py b/posthog/api/test/test_team.py
index e65cf42136b8..5c0dd7559372 100644
--- a/posthog/api/test/test_team.py
+++ b/posthog/api/test/test_team.py
@@ -1616,6 +1616,29 @@ def team_api_test_factory():
assert response.status_code == status.HTTP_400_BAD_REQUEST
+ @patch("posthog.models.product_intent.promoted_product_lookup.get_promoted_product_intent")
+ def test_promoted_product_intent_returns_helper_value(
+ self, mock_get_promoted_product_intent: MagicMock
+ ) -> None:
+ mock_get_promoted_product_intent.return_value = "session_replay"
+
+ response = self.client.get(f"/api/environments/{self.team.id}/promoted_product_intent/")
+
+ assert response.status_code == status.HTTP_200_OK
+ assert response.json() == {"product_key": "session_replay"}
+ mock_get_promoted_product_intent.assert_called_once_with(self.team.pk)
+
+ @patch("posthog.models.product_intent.promoted_product_lookup.get_promoted_product_intent")
+ def test_promoted_product_intent_returns_null_when_helper_returns_none(
+ self, mock_get_promoted_product_intent: MagicMock
+ ) -> None:
+ mock_get_promoted_product_intent.return_value = None
+
+ response = self.client.get(f"/api/environments/{self.team.id}/promoted_product_intent/")
+
+ assert response.status_code == status.HTTP_200_OK
+ assert response.json() == {"product_key": None}
+
@patch("posthog.event_usage.report_user_action")
@freeze_time("2024-01-01T00:00:00Z")
def test_can_add_product_intent(self, mock_report_user_action: MagicMock) -> None:
diff --git a/posthog/models/product_intent/promoted_product_lookup.py b/posthog/models/product_intent/promoted_product_lookup.py
new file mode 100644
index 000000000000..8f0d46d072b9
--- /dev/null
+++ b/posthog/models/product_intent/promoted_product_lookup.py
@@ -0,0 +1,38 @@
+from posthog.schema import ProductIntentContext, ProductKey
+
+from posthog.models.product_intent.product_intent import ProductIntent
+
+_VALID_PRODUCT_KEYS: frozenset[str] = frozenset(p.value for p in ProductKey)
+_PRIMARY_ONBOARDING_CONTEXT: str = ProductIntentContext.ONBOARDING_PRODUCT_SELECTED___PRIMARY.value
+
+
+def get_promoted_product_intent(team_id: int) -> str | None:
+ """Return the team's promoted onboarding product, or None.
+
+ Backs the experimental sidebar 'Promoted product' entry. Reads from the
+ `ProductIntent` Postgres model rather than the `user showed product intent`
+ ClickHouse event — the event is now emitted for many non-onboarding contexts
+ (e.g. `intent_context = 'feature flag created'`), whereas the model's
+ `contexts` dict lets us match the primary-onboarding context directly.
+
+ The query is cheap because it is anchored on the indexed `team_id` FK and a
+ team has only a handful of `ProductIntent` rows (one per product, via the
+ team+product_type unique constraint) — the `contexts__has_key` JSON predicate
+ is evaluated in-memory over those few rows, not via a JSON index. No per-team
+ cache needed.
+
+ Caveat: `updated_at` is `auto_now`, so it bumps on *any* context write to a
+ product's row, not only primary-onboarding. For a team that selected one
+ primary product (the overwhelming common case) this returns that product;
+ in the rare case of multiple primary selections it returns whichever row was
+ most recently touched. Good enough for an experiment — tighten if it graduates.
+ """
+ intent = (
+ ProductIntent.objects.filter(team_id=team_id, contexts__has_key=_PRIMARY_ONBOARDING_CONTEXT)
+ .order_by("-updated_at")
+ .values_list("product_type", flat=True)
+ .first()
+ )
+ if intent is None or intent not in _VALID_PRODUCT_KEYS:
+ return None
+ return intent
diff --git a/posthog/models/test/test_promoted_product_lookup.py b/posthog/models/test/test_promoted_product_lookup.py
new file mode 100644
index 000000000000..68b0e684a770
--- /dev/null
+++ b/posthog/models/test/test_promoted_product_lookup.py
@@ -0,0 +1,84 @@
+from datetime import datetime, timedelta
+
+from posthog.test.base import BaseTest
+
+from django.utils import timezone
+
+from posthog.schema import ProductKey
+
+from posthog.models.product_intent.product_intent import ProductIntent
+from posthog.models.product_intent.promoted_product_lookup import get_promoted_product_intent
+
+
+class TestPromotedProductLookup(BaseTest):
+ def _create_intent(
+ self,
+ product_key: str,
+ contexts: dict[str, int] | None = None,
+ updated_at: datetime | None = None,
+ team=None,
+ ) -> ProductIntent:
+ intent = ProductIntent.objects.create(
+ team=team or self.team,
+ product_type=product_key,
+ contexts=contexts if contexts is not None else {"onboarding product selected - primary": 1},
+ )
+ if updated_at is not None:
+ # auto_now=True on `updated_at` blocks normal assignment — use a raw update.
+ ProductIntent.objects.filter(pk=intent.pk).update(updated_at=updated_at)
+ intent.refresh_from_db()
+ return intent
+
+ def test_returns_none_when_no_intent_exists(self) -> None:
+ assert get_promoted_product_intent(self.team.pk) is None
+
+ def test_returns_product_key_from_primary_intent(self) -> None:
+ self._create_intent(ProductKey.SESSION_REPLAY.value)
+
+ assert get_promoted_product_intent(self.team.pk) == "session_replay"
+
+ def test_ignores_intent_without_primary_onboarding_context(self) -> None:
+ # Same product, but only ever marked via secondary or a non-onboarding context.
+ self._create_intent(
+ ProductKey.SESSION_REPLAY.value,
+ contexts={"onboarding product selected - secondary": 1, "feature flag created": 1},
+ )
+
+ assert get_promoted_product_intent(self.team.pk) is None
+
+ def test_returns_most_recently_updated_primary_intent(self) -> None:
+ now = timezone.now()
+ self._create_intent(ProductKey.PRODUCT_ANALYTICS.value, updated_at=now - timedelta(days=2))
+ self._create_intent(ProductKey.SESSION_REPLAY.value, updated_at=now - timedelta(days=1))
+ self._create_intent(ProductKey.WEB_ANALYTICS.value, updated_at=now)
+
+ assert get_promoted_product_intent(self.team.pk) == "web_analytics"
+
+ def test_scopes_by_team(self) -> None:
+ other_team = self.organization.teams.create(name="other")
+ self._create_intent(ProductKey.SESSION_REPLAY.value)
+ self._create_intent(ProductKey.WEB_ANALYTICS.value, team=other_team)
+
+ assert get_promoted_product_intent(self.team.pk) == "session_replay"
+ assert get_promoted_product_intent(other_team.pk) == "web_analytics"
+
+ def test_rejects_unknown_product_key(self) -> None:
+ # A stray product_type that isn't in the ProductKey enum — defensive guard
+ # against schema drift between the model and the enum.
+ self._create_intent("not_a_real_product")
+
+ assert get_promoted_product_intent(self.team.pk) is None
+
+ def test_ignores_event_noise_from_other_contexts(self) -> None:
+ # The `feature flag created` intent_context emits the same event as
+ # primary-onboarding but is unrelated — make sure we don't pick it up.
+ self._create_intent(
+ ProductKey.FEATURE_FLAGS.value,
+ contexts={"feature flag created": 7},
+ )
+ self._create_intent(
+ ProductKey.SESSION_REPLAY.value,
+ contexts={"onboarding product selected - primary": 1},
+ )
+
+ assert get_promoted_product_intent(self.team.pk) == "session_replay"
diff --git a/posthog/utils.py b/posthog/utils.py
index 7702914d6a58..b2e391eea93d 100644
--- a/posthog/utils.py
+++ b/posthog/utils.py
@@ -581,6 +581,18 @@ def _build_template_context(
)
posthog_app_context["custom_products"] = user_product_list.data
+ with tracer.start_as_current_span("template.promoted_product_intent"):
+ from posthog.models.product_intent.promoted_product_lookup import get_promoted_product_intent
+
+ # Best-effort — the promoted-product sidebar entry is experimental.
+ # If the lookup fails for any reason, hide it for this request
+ # rather than 500ing the page render.
+ try:
+ posthog_app_context["promoted_product_intent"] = get_promoted_product_intent(user.team.pk)
+ except Exception:
+ capture_exception()
+ posthog_app_context["promoted_product_intent"] = None
+
# Merge caller-provided keys into posthog_app_context (e.g. oauth_application from the authorize view)
if "oauth_application" in context:
posthog_app_context["oauth_application"] = context.pop("oauth_application")
diff --git a/products/platform_features/frontend/generated/api.schemas.ts b/products/platform_features/frontend/generated/api.schemas.ts
index ad9fbec0f853..88de0d3027ea 100644
--- a/products/platform_features/frontend/generated/api.schemas.ts
+++ b/products/platform_features/frontend/generated/api.schemas.ts
@@ -715,6 +715,14 @@ export interface PatchedCommentApi {
source_comment?: string | null
}
+export interface PromotedProductIntentApi {
+ /**
+ * The product key the team selected as their primary product during onboarding (e.g. `session_replay`, `web_analytics`, `product_analytics`), or `null` if no primary onboarding product intent has been captured for this team.
+ * @nullable
+ */
+ product_key: string | null
+}
+
export interface PinnedSceneTabApi {
/** Stable identifier for the tab. Generated client-side; safe to omit on create. */
id?: string
diff --git a/products/platform_features/frontend/generated/api.ts b/products/platform_features/frontend/generated/api.ts
index 24c730e104f7..fdd18e8422d5 100644
--- a/products/platform_features/frontend/generated/api.ts
+++ b/products/platform_features/frontend/generated/api.ts
@@ -38,6 +38,7 @@ import type {
PatchedPinnedSceneTabsApi,
PatchedRoleApi,
PinnedSceneTabsApi,
+ PromotedProductIntentApi,
RoleApi,
RoleMembershipApi,
RolesListParams,
@@ -910,6 +911,24 @@ export const commentsCountRetrieve = async (projectId: string, options?: Request
})
}
+export const getEnvironmentsPromotedProductIntentRetrieveUrl = (projectId: string, id: number) => {
+ return `/api/projects/${projectId}/environments/${id}/promoted_product_intent/`
+}
+
+/**
+ * Return the product key (e.g. `session_replay`, `web_analytics`) this team selected as their primary product during onboarding. Resolved from the team's most recent primary-onboarding `ProductIntent` record (the one carrying the `onboarding product selected - primary` context) — not from the `user showed product intent` event, which also fires for non-onboarding contexts. Returns `null` when no primary onboarding product intent has been captured (e.g. teams created before this signal existed, or where onboarding was skipped).
+ */
+export const environmentsPromotedProductIntentRetrieve = async (
+ projectId: string,
+ id: number,
+ options?: RequestInit
+): Promise<PromotedProductIntentApi> => {
+ return apiMutator<PromotedProductIntentApi>(getEnvironmentsPromotedProductIntentRetrieveUrl(projectId, id), {
+ ...options,
+ method: 'GET',
+ })
+}
+
export const getUserHomeSettingsRetrieveUrl = (uuid: string) => {
return `/api/user_home_settings/${uuid}/`
}
diff --git a/products/platform_features/mcp/tools.yaml b/products/platform_features/mcp/tools.yaml
index da9a271e1a76..a8e3c41dfdce 100644
--- a/products/platform_features/mcp/tools.yaml
+++ b/products/platform_features/mcp/tools.yaml
@@ -235,6 +235,9 @@ tools:
comments-update:
operation: comments_update
enabled: false
+ environments-promoted-product-intent-retrieve:
+ operation: environments_promoted_product_intent_retrieve
+ enabled: false
members-destroy:
operation: members_destroy
enabled: false
@@ -325,6 +328,24 @@ tools:
organizations-update:
operation: update
enabled: false
+ promoted-product-intent-get:
+ operation: environments_promoted_product_intent_retrieve
+ enabled: true
+ scopes:
+ - project:read
+ annotations:
+ readOnly: true
+ destructive: false
+ idempotent: true
+ title: Get the team's promoted product.
+ description: >
+ Get the product key the team selected as their primary product during onboarding (e.g. `session_replay`,
+ `web_analytics`, `product_analytics`), or `null` if no primary onboarding product intent has been captured.
+ Use this to bias disambiguation when the user's request is ambiguous about which PostHog product they mean —
+ for example, if their primary product is `session_replay`, treat a vague reference to "watch a session" as
+ referring to a session recording rather than a survey response.
+ feature_flag: promoted-product
+ feature_flag_variant: intent_plus
role-get:
operation: roles_retrieve
enabled: true
diff --git a/services/mcp/definitions/core.yaml b/services/mcp/definitions/core.yaml
index ef2530becda7..f069a79c8d80 100644
--- a/services/mcp/definitions/core.yaml
+++ b/services/mcp/definitions/core.yaml
@@ -191,6 +191,9 @@ tools:
organizations-projects-logs-config-retrieve:
operation: organizations_projects_logs_config_retrieve
enabled: false
+ organizations-projects-promoted-product-intent-retrieve:
+ operation: organizations_projects_promoted_product_intent_retrieve
+ enabled: false
project-get:
operation: organizations_projects_retrieve
enabled: true
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index 819a51a55ed7..9a2ad6325e69 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -3933,6 +3933,22 @@
"readOnlyHint": false
}
},
+ "promoted-product-intent-get": {
+ "description": "Get the product key the team selected as their primary product during onboarding (e.g. `session_replay`, `web_analytics`, `product_analytics`), or `null` if no primary onboarding product intent has been captured. Use this to bias disambiguation when the user's request is ambiguous about which PostHog product they mean — for example, if their primary product is `session_replay`, treat a vague reference to \"watch a session\" as referring to a session recording rather than a survey response.",
+ "category": "Platform Features",
+ "feature": "platform_features",
+ "summary": "Get the team's promoted product.",
+ "title": "Get the team's promoted product.",
+ "required_scopes": ["project:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ },
+ "feature_flag": "promoted-product",
+ "feature_flag_variant": "intent_plus"
+ },
"proxy-create": {
"description": "Create a new managed reverse proxy for a custom domain. Provide the domain (e.g. 'e.example.com') that will proxy requests to PostHog. The response includes the CNAME target — the user must add a CNAME DNS record pointing their domain to this target. Once DNS propagates, the proxy is automatically verified and an SSL certificate is issued. The proxy starts in 'waiting' status until DNS is verified.",
"category": "Reverse proxy",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index 25bec2641ae7..04e47c636561 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -4216,6 +4216,22 @@
"readOnlyHint": true
}
},
+ "promoted-product-intent-get": {
+ "description": "Get the product key the team selected as their primary product during onboarding (e.g. `session_replay`, `web_analytics`, `product_analytics`), or `null` if no primary onboarding product intent has been captured. Use this to bias disambiguation when the user's request is ambiguous about which PostHog product they mean — for example, if their primary product is `session_replay`, treat a vague reference to \"watch a session\" as referring to a session recording rather than a survey response.",
+ "category": "Platform Features",
+ "feature": "platform_features",
+ "summary": "Get the team's promoted product.",
+ "title": "Get the team's promoted product.",
+ "required_scopes": ["project:read"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": true
+ },
+ "feature_flag": "promoted-product",
+ "feature_flag_variant": "intent_plus"
+ },
"proxy-create": {
"description": "Create a new managed reverse proxy for a custom domain. Provide the domain (e.g. 'e.example.com') that will proxy requests to PostHog. The response includes the CNAME target — the user must add a CNAME DNS record pointing their domain to this target. Once DNS propagates, the proxy is automatically verified and an SSL certificate is issued. The proxy starts in 'waiting' status until DNS is verified.",
"category": "Reverse proxy",
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index ed471924d116..23f6ad0dbf76 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -34420,6 +34420,14 @@ export namespace Schemas {
payload: ProjectProfilePayload;
}
+ export interface PromotedProductIntent {
+ /**
+ * The product key the team selected as their primary product during onboarding (e.g. `session_replay`, `web_analytics`, `product_analytics`), or `null` if no primary onboarding product intent has been captured for this team.
+ * @nullable
+ */
+ product_key: string | null;
+ }
+
export interface Property {
/**
You can use a simplified version:
diff --git a/services/mcp/src/generated/platform_features/api.ts b/services/mcp/src/generated/platform_features/api.ts
index 3bec123b95c9..bdfe807bf485 100644
--- a/services/mcp/src/generated/platform_features/api.ts
+++ b/services/mcp/src/generated/platform_features/api.ts
@@ -3,7 +3,7 @@
* MCP service uses these Zod schemas for generated tool handlers.
* To regenerate: hogli build:openapi
*
- * PostHog API - MCP 19 enabled ops
+ * PostHog API - MCP 20 enabled ops
* OpenAPI spec version: 1.0.0
*/
import * as zod from 'zod'
@@ -447,6 +447,18 @@ export const CommentsCountRetrieveParams = /* @__PURE__ */ zod.object({
),
})
+/**
+ * Return the product key (e.g. `session_replay`, `web_analytics`) this team selected as their primary product during onboarding. Resolved from the team's most recent primary-onboarding `ProductIntent` record (the one carrying the `onboarding product selected - primary` context) — not from the `user showed product intent` event, which also fires for non-onboarding contexts. Returns `null` when no primary onboarding product intent has been captured (e.g. teams created before this signal existed, or where onboarding was skipped).
+ */
+export const EnvironmentsPromotedProductIntentRetrieveParams = /* @__PURE__ */ zod.object({
+ id: zod.number().describe('A unique integer value identifying this environment (aka team).'),
+ project_id: zod
+ .string()
+ .describe(
+ "Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/."
+ ),
+})
+
/**
* Get the authenticated user's pinned sidebar tabs and configured homepage for the current team. Pass `@me` as the UUID.
*/
diff --git a/services/mcp/src/tools/generated/platform_features.ts b/services/mcp/src/tools/generated/platform_features.ts
index 30f7a8c2a3fa..f152ec6e0d82 100644
--- a/services/mcp/src/tools/generated/platform_features.ts
+++ b/services/mcp/src/tools/generated/platform_features.ts
@@ -12,6 +12,7 @@ import {
CommentsListQueryParams,
CommentsRetrieveParams,
CommentsThreadRetrieveParams,
+ EnvironmentsPromotedProductIntentRetrieveParams,
ListQueryParams,
MembersListQueryParams,
RetrieveParams,
@@ -379,6 +380,24 @@ const organizationsList = (): ToolBase<
},
})
+const PromotedProductIntentGetSchema = EnvironmentsPromotedProductIntentRetrieveParams.omit({ project_id: true })
+
+const promotedProductIntentGet = (): ToolBase<
+ typeof PromotedProductIntentGetSchema,
+ Schemas.PromotedProductIntent
+> => ({
+ name: 'promoted-product-intent-get',
+ schema: PromotedProductIntentGetSchema,
+ handler: async (context: Context, params: z.infer<typeof PromotedProductIntentGetSchema>) => {
+ const projectId = await context.stateManager.getProjectId()
+ const result = await context.api.request<Schemas.PromotedProductIntent>({
+ method: 'GET',
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/environments/${encodeURIComponent(String(params.id))}/promoted_product_intent/`,
+ })
+ return result
+ },
+})
+
const RoleGetSchema = RolesRetrieveParams.omit({ organization_id: true })
const roleGet = (): ToolBase<typeof RoleGetSchema, Schemas.Role> => ({
@@ -495,6 +514,7 @@ export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {
'org-members-list': orgMembersList,
'organization-get': organizationGet,
'organizations-list': organizationsList,
+ 'promoted-product-intent-get': promotedProductIntentGet,
'role-get': roleGet,
'role-members-list': roleMembersList,
'roles-list': rolesList,
diff --git a/services/mcp/tests/unit/tool-filtering.test.ts b/services/mcp/tests/unit/tool-filtering.test.ts
index 4860c5a6341c..17f3e282f01f 100644
--- a/services/mcp/tests/unit/tool-filtering.test.ts
+++ b/services/mcp/tests/unit/tool-filtering.test.ts
@@ -709,9 +709,10 @@ describe('Tool Filtering - Feature Flags', () => {
'notebooks-collaboration',
'replay-vision',
'tasks',
+ 'promoted-product',
])
)
- expect(flags).toHaveLength(10)
+ expect(flags).toHaveLength(11)
})
// Exercise the real predicate (toolPassesFlagGate) over hand-rolled entries
@@ -829,7 +830,7 @@ describe('Tool Filtering - Feature Flags', () => {
expect(tools).toContain('unrelated-tool')
})
- it.each(['control_a', 'control_b', 'intent', false, true, undefined])(
+ it.each(['control', 'control_b', 'intent', false, true, undefined])(
'hides variant-gated tool when flag value is %p',
(flagValue) => {
const tools = filterByFeatureFlags(variantToolEntries, { 'promoted-product': flagValue })