: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(dashboards): add AI prompt composer experiment (#88632)
Matt Puac5e5a3ef5162
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex 1105cb2a763c..d3d09762d416 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -285,6 +285,7 @@ export const FEATURE_FLAGS = {CUSTOMER_ANALYTICS_JOURNEYS: 'customer-analytics-journeys', // owner: @arthurdedeus #team-customer-analyticsCUSTOMER_ANALYTICS_TRACK_RULES: 'customer-analytics-track-rules', // owner: @arthurdedeus #team-customer-analyticsCUSTOMER_PROFILE_CONFIG_BUTTON: 'customer-profile-config-button', // owner: @arthurdedeus #team-customer-analytics+ DASHBOARD_AI_PROMPT_COMPOSER: 'dashboard-ai-prompt-composer', // owner: @mattp #team-analytics-platform multivariate=control,copy,composerDASHBOARD_AUTO_PREVIEW_LIMIT: 'dashboard-auto-preview-limit', // owner: @pauldambra #team-product-analyticsDASHBOARD_CUSTOMIZATION: 'dashboard-customization', // owner: @MattPua #team-analytics-platformDASHBOARD_EXPORT_NUDGE: 'dashboard-export-nudge', // owner: #team-analytics-platform multivariate=control,test, nudges people who just exported a dashboard toward a recurring subscriptiondiff --git a/frontend/src/lib/utils/eventUsageLogic.ts b/frontend/src/lib/utils/eventUsageLogic.tsindex e8fbc506f7d4..201415703538 100644--- a/frontend/src/lib/utils/eventUsageLogic.ts+++ b/frontend/src/lib/utils/eventUsageLogic.ts@@ -701,12 +701,27 @@ export interface eventUsageLogicActions {action: 'discarded' | 'kept_editing' | 'shown'dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null}+ reportDashboardEmptyAddChartClicked: (dashboardId: number | undefined) => {+ dashboardId: number | undefined+ }reportDashboardEmptyAiPromptClicked: (promptLabel: string,- dashboardId: number | undefined+ dashboardId: number | undefined,+ promptType: 'custom_prompt' | 'starter_question') => {dashboardId: number | undefinedpromptLabel: string+ promptType: 'custom_prompt' | 'starter_question'+ }+ reportDashboardEmptyAiPromptSubmitted: (+ dashboardId: number | undefined,+ promptType: 'custom_prompt' | 'starter_question'+ ) => {+ dashboardId: number | undefined+ promptType: 'custom_prompt' | 'starter_question'+ }+ reportDashboardEmptyWebAnalyticsClicked: (dashboardId: number | undefined) => {+ dashboardId: number | undefined}reportDashboardExported: (dashboardId: number,@@ -2443,10 +2458,21 @@ export const eventUsageLogic = kea<eventUsageLogicType>([source: DashboardEventSource) => ({ dashboardId, insightId, source }),/** Empty-state AI prompt chips (ai-first empty dashboard only). */- reportDashboardEmptyAiPromptClicked: (promptLabel: string, dashboardId: number | undefined) => ({+ reportDashboardEmptyAiPromptClicked: (+ promptLabel: string,+ dashboardId: number | undefined,+ promptType: 'starter_question' | 'custom_prompt'+ ) => ({promptLabel,dashboardId,+ promptType,}),+ reportDashboardEmptyAiPromptSubmitted: (+ dashboardId: number | undefined,+ promptType: 'custom_prompt' | 'starter_question'+ ) => ({ dashboardId, promptType }),+ reportDashboardEmptyAddChartClicked: (dashboardId: number | undefined) => ({ dashboardId }),+ reportDashboardEmptyWebAnalyticsClicked: (dashboardId: number | undefined) => ({ dashboardId }),reportDashboardExported: (dashboardId: number, exportFormat: ExporterFormat) => ({dashboardId,exportFormat,@@ -3519,9 +3545,29 @@ export const eventUsageLogic = kea<eventUsageLogicType>([source,})},- reportDashboardEmptyAiPromptClicked: async ({ promptLabel, dashboardId }) => {+ reportDashboardEmptyAiPromptClicked: async ({ promptLabel, dashboardId, promptType }) => {posthog.capture('dashboard empty ai prompt clicked', {prompt_label: promptLabel,+ dashboard_id: dashboardId,+ prompt_type: promptType,+ source: 'web',+ })+ },+ reportDashboardEmptyAiPromptSubmitted: async ({ dashboardId, promptType }) => {+ posthog.capture('dashboard empty ai prompt submitted', {+ dashboard_id: dashboardId,+ prompt_type: promptType,+ source: 'web',+ })+ },+ reportDashboardEmptyAddChartClicked: async ({ dashboardId }) => {+ posthog.capture('dashboard empty add chart clicked', {+ dashboard_id: dashboardId,+ source: 'web',+ })+ },+ reportDashboardEmptyWebAnalyticsClicked: async ({ dashboardId }) => {+ posthog.capture('dashboard empty web analytics clicked', {dashboard_id: dashboardId,source: 'web',})diff --git a/frontend/src/scenes/dashboard/DashboardAiPromptComposer.tsx b/frontend/src/scenes/dashboard/DashboardAiPromptComposer.tsxnew file mode 100644index 000000000000..6ad6534a76f5--- /dev/null+++ b/frontend/src/scenes/dashboard/DashboardAiPromptComposer.tsx@@ -0,0 +1,195 @@+import { useActions, useValues } from 'kea'+import type { FormEvent } from 'react'++import { LemonButton } from 'lib/lemon-ui/LemonButton'+import { LemonTextArea } from 'lib/lemon-ui/LemonTextArea/LemonTextArea'+import { Link } from 'lib/lemon-ui/Link'+import { eventUsageLogic } from 'lib/utils/eventUsageLogic'++import { dashboardAiPromptComposerLogic } from './dashboardAiPromptComposerLogic'++type SamplePromptPreview = 'activity' | 'adoption' | 'retention' | 'paths'++const SAMPLE_PROMPTS: { question: string; prompt: string; preview: SamplePromptPreview }[] = [+ {+ question: 'What does user activity look like this week?',+ prompt: 'Build a product activity dashboard for the past 7 days. Show daily active users, new and returning users, top events, and day-over-day change. Add the insights to this dashboard.',+ preview: 'activity',+ },+ {+ question: 'How is my feature being adopted?',+ prompt: 'Build a feature adoption dashboard. Show unique users for each key feature, adoption over time, new adopters, and retention of adopters. Add the insights to this dashboard.',+ preview: 'adoption',+ },+ {+ question: 'What brings users back after they sign up?',+ prompt: 'Build a retention dashboard. Show weekly retention cohorts, returning users after signup, and retention by signup source. Add the insights to this dashboard.',+ preview: 'retention',+ },+ {+ question: 'Which paths lead users to activation?',+ prompt: 'Build a user paths dashboard. Show the most common event sequences before activation, where users drop off, and the paths used by activated users. Add the insights to this dashboard.',+ preview: 'paths',+ },+]++function SamplePromptPreview({ preview }: { preview: SamplePromptPreview }): JSX.Element {+ if (preview === 'activity') {+ return (+ <svg+ aria-hidden+ className="h-8 w-16 shrink-0 text-[var(--color-product-product-analytics-light)]"+ viewBox="0 0 80 40"+ >+ <rect x="2" y="4" width="9" height="32" fill="currentColor" />+ <rect x="17" y="14" width="9" height="22" fill="currentColor" opacity="0.25" />+ <rect x="32" y="8" width="9" height="28" fill="currentColor" opacity="0.45" />+ <rect x="47" y="18" width="9" height="18" fill="currentColor" />+ <rect x="62" y="11" width="9" height="25" fill="currentColor" opacity="0.65" />+ </svg>+ )+ }++ if (preview === 'adoption') {+ return (+ <svg+ aria-hidden+ className="h-8 w-16 shrink-0 text-[var(--color-product-product-analytics-light)]"+ viewBox="0 0 80 40"+ >+ <rect x="2" y="4" width="28" height="32" rx="2" fill="currentColor" opacity="0.9" />+ <rect x="36" y="4" width="19" height="7" rx="1" fill="currentColor" opacity="0.25" />+ <rect x="36" y="17" width="34" height="7" rx="1" fill="currentColor" />+ <rect x="36" y="30" width="12" height="6" rx="1" fill="currentColor" opacity="0.4" />+ </svg>+ )+ }++ if (preview === 'retention') {+ return (+ <svg+ aria-hidden+ className="h-8 w-16 shrink-0 text-[var(--color-product-product-analytics-light)]"+ viewBox="0 0 80 40"+ >+ <path+ d="M4 31C16 27 19 11 31 15s12 16 23 10 13-16 22-20"+ fill="none"+ stroke="currentColor"+ strokeWidth="4"+ />+ <circle cx="4" cy="31" r="3" fill="currentColor" />+ <circle cx="31" cy="15" r="3" fill="currentColor" opacity="0.7" />+ <circle cx="54" cy="25" r="3" fill="currentColor" opacity="0.5" />+ <circle cx="76" cy="5" r="3" fill="currentColor" opacity="0.3" />+ </svg>+ )+ }++ return (+ <svg+ aria-hidden+ className="h-8 w-16 shrink-0 text-[var(--color-product-product-analytics-light)]"+ viewBox="0 0 80 40"+ >+ <path d="M10 10h20l12 10h20" fill="none" stroke="currentColor" strokeWidth="4" />+ <circle cx="10" cy="10" r="5" fill="currentColor" />+ <circle cx="42" cy="20" r="5" fill="currentColor" opacity="0.6" />+ <circle cx="62" cy="20" r="5" fill="currentColor" opacity="0.35" />+ </svg>+ )+}++export type DashboardAiPromptComposerProps = {+ dashboardId?: number+ disabledReason?: string | null+ onOpenAiWithPrompt: (prompt: string) => void+}++export function DashboardAiPromptComposer({+ dashboardId,+ disabledReason,+ onOpenAiWithPrompt,+}: DashboardAiPromptComposerProps): JSX.Element {+ const { prompt, promptSource } = useValues(dashboardAiPromptComposerLogic)+ const { setPrompt } = useActions(dashboardAiPromptComposerLogic)+ const { reportDashboardEmptyAiPromptClicked, reportDashboardEmptyAiPromptSubmitted } = useActions(eventUsageLogic)++ const submitPrompt = (event: FormEvent<HTMLFormElement>): void => {+ event.preventDefault()++ const question = prompt.trim()+ if (!question) {+ return+ }++ reportDashboardEmptyAiPromptClicked(+ promptSource === 'starter_question' ? 'Starter question' : 'Custom question',+ dashboardId,+ promptSource+ )+ reportDashboardEmptyAiPromptSubmitted(dashboardId, promptSource)+ onOpenAiWithPrompt(question)+ setPrompt('')+ }++ return (+ <form className="w-full" onSubmit={submitPrompt}>+ <label htmlFor="dashboard-ai-prompt-composer-input" className="block text-sm font-semibold mb-1">+ What do you want to learn?+ </label>+ <LemonTextArea+ id="dashboard-ai-prompt-composer-input"+ value={prompt}+ onChange={setPrompt}+ placeholder="For example, which pages convert best?"+ minRows={3}+ maxRows={5}+ disabled={!!disabledReason}+ data-attr="dashboard-ai-prompt-composer-input"+ />+ <div className="flex items-center justify-between gap-4 mt-2">+ <Link+ to="https://posthog.com/docs/web-analytics/web-vs-product-analytics"+ target="_blank"+ targetBlankIcon+ className="text-sm"+ >+ Learn about product analytics+ </Link>+ <LemonButton+ type="primary"+ htmlType="submit"+ disabledReason={disabledReason || (prompt.trim() ? undefined : 'Enter a question')}+ data-attr="dashboard-ai-prompt-composer-submit"+ >+ Build it for me+ </LemonButton>+ </div>+ <div className="mt-5">+ <p className="text-sm font-semibold m-0 mb-2">Start with a question</p>+ <div className="flex flex-col gap-2">+ {SAMPLE_PROMPTS.map(({ question, prompt, preview }) => (+ <LemonButton+ key={question}+ type="secondary"+ htmlType="button"+ fullWidth+ className="!h-14 !rounded-lg !border-border !bg-bg-surface-primary !px-0 !py-0 !text-left !text-base !font-normal shadow-none hover:!bg-fill-secondary"+ onClick={() => {+ reportDashboardEmptyAiPromptClicked(question, dashboardId, 'starter_question')+ setPrompt(prompt, 'starter_question')+ }}+ disabledReason={disabledReason || undefined}+ >+ <span className="flex w-full items-center justify-between gap-4">+ <span>{question}</span>+ <SamplePromptPreview preview={preview} />+ </span>+ </LemonButton>+ ))}+ </div>+ </div>+ </form>+ )+}diff --git a/frontend/src/scenes/dashboard/DashboardHeader.test.tsx b/frontend/src/scenes/dashboard/DashboardHeader.test.tsxindex 290dcd3e33b4..64029fd949d7 100644--- a/frontend/src/scenes/dashboard/DashboardHeader.test.tsx+++ b/frontend/src/scenes/dashboard/DashboardHeader.test.tsx@@ -160,26 +160,40 @@ describe('DashboardHeader', () => {scenario: 'View mode, can edit',dashboardMode: null as DashboardMode | null,canEdit: true,- visible: ['dashboard-share-button', 'dashboard-add-tile', 'dashboard-edit-mode-button'],- notVisible: ['dashboard-edit-mode-discard', 'dashboard-edit-mode-save'],+ visible: [],+ notVisible: [+ 'dashboard-add-tile',+ 'dashboard-share-button',+ 'dashboard-edit-mode-button',+ 'dashboard-edit-mode-discard',+ 'dashboard-edit-mode-save',+ ],},{scenario: 'View mode, cannot edit',dashboardMode: null as DashboardMode | null,canEdit: false,- visible: ['dashboard-share-button', 'dashboard-add-tile'],- notVisible: ['dashboard-edit-mode-discard', 'dashboard-edit-mode-save', 'dashboard-edit-mode-button'],+ visible: [],+ notVisible: [+ 'dashboard-add-tile',+ 'dashboard-share-button',+ 'dashboard-edit-mode-discard',+ 'dashboard-edit-mode-save',+ 'dashboard-edit-mode-button',+ ],},{scenario: 'Filter edit mode',dashboardMode: DashboardMode.Edit,dashboardModeSource: DashboardEventSource.DashboardFilters,canEdit: true,- visible: ['dashboard-add-tile', 'dashboard-edit-layout-customize-dropdown'],+ visible: [],notVisible: [+ 'dashboard-add-tile','dashboard-edit-mode-discard','dashboard-edit-mode-save','dashboard-share-button',+ 'dashboard-edit-layout-customize-dropdown','add-text-tile-to-dashboard','dashboard-add-graph-header',],@@ -189,13 +203,14 @@ describe('DashboardHeader', () => {dashboardMode: DashboardMode.Edit,dashboardModeSource: DashboardEventSource.SceneCommonButtons,canEdit: true,- visible: [- 'dashboard-edit-mode-discard',- 'dashboard-edit-mode-save',- 'dashboard-edit-layout-customize-dropdown',+ visible: ['dashboard-edit-mode-discard', 'dashboard-edit-mode-save'],+ notVisible: ['dashboard-add-tile',+ 'dashboard-share-button',+ 'dashboard-edit-layout-customize-dropdown',+ 'add-text-tile-to-dashboard',+ 'dashboard-add-graph-header',],- notVisible: ['dashboard-share-button', 'add-text-tile-to-dashboard', 'dashboard-add-graph-header'],},{scenario: 'Fullscreen mode',diff --git a/frontend/src/scenes/dashboard/DashboardHeaderActions.tsx b/frontend/src/scenes/dashboard/DashboardHeaderActions.tsxindex 95f80cbac248..f67388649a02 100644--- a/frontend/src/scenes/dashboard/DashboardHeaderActions.tsx+++ b/frontend/src/scenes/dashboard/DashboardHeaderActions.tsx@@ -82,13 +82,13 @@ export function getAddTileMenuItems({}export function DashboardAddTileButton(): JSX.Element | null {- const { dashboard, dashboardWidgetsEnabled } = useValues(dashboardLogic)+ const { dashboard, dashboardWidgetsEnabled, tiles } = useValues(dashboardLogic)const { loadDashboard, setAddWidgetModalOpen, setPendingInsertion, openAddInsightModal } =useActions(dashboardLogic)const { push } = useActions(router)const { reportDashboardAddMenuOpened } = useActions(eventUsageLogic)- if (!dashboard) {+ if (!dashboard || tiles.length === 0) {return null}@@ -230,7 +230,7 @@ export function EditModeActions(): JSX.Element {<><DashboardSubscribeButton />{layoutEditMode && <DashboardEditSaveCancelButtons />}- {dashboardCustomizationEnabled && (+ {dashboardCustomizationEnabled && tiles.length > 0 && (<LemonMenuitems={[{ label: () => <DashboardCustomizeMenu /> }]}closeOnClickInside={false}@@ -290,28 +290,25 @@ export function ViewModeActions(): JSX.Element {return (<><DashboardSubscribeButton />- <LemonButton- type="secondary"- data-attr="dashboard-share-button"- onClick={() => push(urls.dashboardSharing(dashboard.id))}- size="small"- icon={<IconShare fontSize="16" />}- disabledReason={- tiles.length === 0- ? 'Add at least one tile before sharing this dashboard'- : (sharingDisabledReason ?? undefined)- }- >- Share- </LemonButton>- {canEditDashboard && (+ {tiles.length > 0 && (+ <LemonButton+ type="secondary"+ data-attr="dashboard-share-button"+ onClick={() => push(urls.dashboardSharing(dashboard.id))}+ size="small"+ icon={<IconShare fontSize="16" />}+ disabledReason={sharingDisabledReason ?? undefined}+ >+ Share+ </LemonButton>+ )}+ {canEditDashboard && tiles.length > 0 && (<Shortcutname="EnterEditMode"scope={Scene.Dashboard}keybind={[keyBinds.edit]}intent="Enter edit mode"interaction="click"- disabled={tiles.length === 0}><LemonButtontype="secondary"@@ -321,17 +318,10 @@ export function ViewModeActions(): JSX.Element {icon={<IconGridMasonry fontSize="16" />}tooltip="Customize dashboard"tooltipPlacement="top"- disabledReason={- tiles.length === 0 ? 'Add at least one tile to customize this dashboard' : undefined- }sideAction={dashboardCustomizationEnabled? {'data-attr': 'dashboard-edit-layout-customize-dropdown',- disabledReason:- tiles.length === 0- ? 'Add at least one tile to customize this dashboard'- : undefined,dropdown: {closeOnClickInside: false,placement: 'bottom-end',diff --git a/frontend/src/scenes/dashboard/DashboardSceneMenuBar.tsx b/frontend/src/scenes/dashboard/DashboardSceneMenuBar.tsxindex a0b61c70dbb6..346259860978 100644--- a/frontend/src/scenes/dashboard/DashboardSceneMenuBar.tsx+++ b/frontend/src/scenes/dashboard/DashboardSceneMenuBar.tsx@@ -148,13 +148,15 @@ function DashboardSceneMenuBarInner(): JSX.Element | null {<IconNotebook />Notebook from dashboard</SceneMenuBarItem>- <SceneMenuBarItem- onClick={() => push(urlForSubscriptions({ dashboardId: dashboard.id }))}- data-attr={`${RESOURCE_TYPE}-menubar-subscribe`}- >- <IconBell />- Subscription- </SceneMenuBarItem>+ {tiles.length > 0 && (+ <SceneMenuBarItem+ onClick={() => push(urlForSubscriptions({ dashboardId: dashboard.id }))}+ data-attr={`${RESOURCE_TYPE}-menubar-subscribe`}+ >+ <IconBell />+ Subscription+ </SceneMenuBarItem>+ )}</SceneMenuBarSubMenu><SceneMenuBarSeparator /></>@@ -276,7 +278,7 @@ function DashboardSceneMenuBarInner(): JSX.Element | null {<IconCopy />Duplicate</SceneMenuBarItem>- {canEditDashboard && hasDashboardColors && (+ {canEditDashboard && hasDashboardColors && tiles.length > 0 && (<SceneMenuBarItemopensFloatingUionClick={() => showInsightColorsModal(dashboard.id)}diff --git a/frontend/src/scenes/dashboard/DashboardScenePanel.tsx b/frontend/src/scenes/dashboard/DashboardScenePanel.tsxindex 790e6893693f..d70249be72ae 100644--- a/frontend/src/scenes/dashboard/DashboardScenePanel.tsx+++ b/frontend/src/scenes/dashboard/DashboardScenePanel.tsx@@ -50,6 +50,7 @@ export function DashboardScenePanel(): JSX.Element | null {asDashboardTemplate,effectiveDashboardVariableOverrides,apiUrl,+ tiles,} = useValues(dashboardLogic)const { setDashboardMode, updateDashboardTags, togglePinned, setTerraformModalOpen } = useActions(dashboardLogic)const { createNotebookFromDashboard } = useActions(notebooksModel)@@ -115,7 +116,7 @@ export function DashboardScenePanel(): JSX.Element | null {{dashboard && canEditDashboard && (<>- {hasDashboardColors && (+ {hasDashboardColors && tiles.length > 0 && (<ButtonPrimitiveonClick={() => showInsightColorsModal(dashboard.id)}menuItem@@ -133,7 +134,9 @@ export function DashboardScenePanel(): JSX.Element | null {<IconNotebook />Create notebook from dashboard</ButtonPrimitive>- <SceneSubscribeButton dashboardId={dashboard.id} dataAttrKey={RESOURCE_TYPE} />+ {tiles.length > 0 && (+ <SceneSubscribeButton dashboardId={dashboard.id} dataAttrKey={RESOURCE_TYPE} />+ )}<SceneExportDropdownMenudropdownMenuItems={[{diff --git a/frontend/src/scenes/dashboard/DashboardSubscribeButton.tsx b/frontend/src/scenes/dashboard/DashboardSubscribeButton.tsxindex deab3d9f0d68..fc807521b310 100644--- a/frontend/src/scenes/dashboard/DashboardSubscribeButton.tsx+++ b/frontend/src/scenes/dashboard/DashboardSubscribeButton.tsx@@ -38,10 +38,10 @@ function SubscribeIcon({ dashboardId }: { dashboardId: number }): JSX.Element {}export function DashboardSubscribeButton(): JSX.Element | null {- const { dashboard, canEditDashboard } = useValues(dashboardLogic)+ const { dashboard, canEditDashboard, tiles } = useValues(dashboardLogic)const { push } = useActions(router)- if (!dashboard || !canEditDashboard) {+ if (!dashboard || !canEditDashboard || tiles.length === 0) {return null}diff --git a/frontend/src/scenes/dashboard/EmptyDashboardComponent.test.tsx b/frontend/src/scenes/dashboard/EmptyDashboardComponent.test.tsxindex 73d8e31351ed..9bc224c2843f 100644--- a/frontend/src/scenes/dashboard/EmptyDashboardComponent.test.tsx+++ b/frontend/src/scenes/dashboard/EmptyDashboardComponent.test.tsx@@ -19,7 +19,7 @@ import { dashboardLogic } from './dashboardLogic'import { EmptyDashboardComponent } from './EmptyDashboardComponent'jest.mock('./emptyDashboardAiStarterPrompts', () => ({- EmptyDashboardAiStarterPrompts: () => null,+ EmptyDashboardAiStarterPrompts: () => <div>Create a chart from a question</div>,}))const MOCK_DASHBOARD: DashboardType<QueryBasedInsightModel> = {@@ -86,7 +86,7 @@ describe('EmptyDashboardComponent', () => {return { logic }}- async function openGetStartedDropdown(): Promise<void> {+ async function openAddFirstChartDropdown(): Promise<void> {await userEvent.click(document.querySelector('[data-attr="dashboard-add-dropdown"]')!)}@@ -96,7 +96,23 @@ describe('EmptyDashboardComponent', () => {expect(document.querySelector('[data-attr="dashboard-loading-controls"]')).toBeInTheDocument()})- it('opens the insight picker when Get started is clicked', async () => {+ it('shows clear paths to add an existing chart or create one with PostHog AI', () => {+ const { logic } = renderEmptyState()++ expect(screen.getByText('Build your dashboard')).toBeInTheDocument()+ expect(+ screen.getByText(+ 'Add a chart from your library, or start with a question about what matters to your product.'+ )+ ).toBeInTheDocument()+ expect(screen.getByText('Add an existing chart')).toBeInTheDocument()+ expect(screen.getByText('or View Web Analytics')).toBeInTheDocument()+ expect(screen.getByText('Create a chart from a question')).toBeInTheDocument()++ logic.unmount()+ })++ it('opens the insight picker when Add your first chart is clicked', async () => {const { logic } = renderEmptyState()await userEvent.click(document.querySelector('[data-attr="dashboard-add-graph-header"]')!)@@ -118,7 +134,7 @@ describe('EmptyDashboardComponent', () => {const pushSpy = jest.spyOn(router.actions, 'push')const { logic } = renderEmptyState()- await openGetStartedDropdown()+ await openAddFirstChartDropdown()await userEvent.click(screen.getByText('Widget'))expect(pushSpy).toHaveBeenCalledWith(urls.featurePreview(FEATURE_FLAGS.DASHBOARD_WIDGETS))@@ -128,10 +144,10 @@ describe('EmptyDashboardComponent', () => {logic.unmount()})- it('shows the shared dashboard add options in the Get started dropdown', async () => {+ it('shows the shared dashboard add options in the Add your first chart dropdown', async () => {const { logic } = renderEmptyState()- await openGetStartedDropdown()+ await openAddFirstChartDropdown()expect(screen.getByText('Content')).toBeInTheDocument()expect(screen.getByText('Charts')).toBeInTheDocument()@@ -143,10 +159,10 @@ describe('EmptyDashboardComponent', () => {logic.unmount()})- it('shows Widget in the Get started dropdown when dashboard widgets flag is enabled', async () => {+ it('shows Widget in the Add your first chart dropdown when dashboard widgets flag is enabled', async () => {const { logic } = renderEmptyState({ widgetsEnabled: true })- await openGetStartedDropdown()+ await openAddFirstChartDropdown()expect(screen.getByText('Widget')).toBeInTheDocument()expect(screen.getByText('NEW')).toBeInTheDocument()@@ -157,7 +173,7 @@ describe('EmptyDashboardComponent', () => {it('opens the add widget modal when Widget is clicked', async () => {const { logic } = renderEmptyState({ widgetsEnabled: true })- await openGetStartedDropdown()+ await openAddFirstChartDropdown()await userEvent.click(screen.getByText('Widget'))expect(logic.values.addWidgetModalOpen).toBe(true)diff --git a/frontend/src/scenes/dashboard/EmptyDashboardComponent.tsx b/frontend/src/scenes/dashboard/EmptyDashboardComponent.tsxindex c7980f442598..28b9f5f6dcfc 100644--- a/frontend/src/scenes/dashboard/EmptyDashboardComponent.tsx+++ b/frontend/src/scenes/dashboard/EmptyDashboardComponent.tsx@@ -8,9 +8,13 @@ import { DashboardLoadingState } from '@posthog/products-dashboards/frontend/comimport { pngHoggie } from 'lib/brand/hoggies'import { AccessControlAction } from 'lib/components/AccessControlAction'import { ProductIntroduction } from 'lib/components/ProductIntroduction/ProductIntroduction'+import { FEATURE_FLAGS } from 'lib/constants'import { LemonButton } from 'lib/lemon-ui/LemonButton'import { LemonMenuOverlay } from 'lib/lemon-ui/LemonMenu'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { eventUsageLogic } from 'lib/utils/eventUsageLogic'import { maxGlobalLogic } from 'scenes/max/maxGlobalLogic'+import { urls } from 'scenes/urls'import { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePanelStateLogic'import {@@ -22,6 +26,7 @@ import {} from '~/types'import { addInsightToDashboardLogic } from './addInsightToDashboardModalLogic'+import { DashboardAiPromptComposer } from './DashboardAiPromptComposer'import { DASHBOARD_CANNOT_EDIT_MESSAGE } from './DashboardHeader'import { getAddTileMenuItems } from './DashboardHeaderActions'import { dashboardLogic } from './dashboardLogic'@@ -29,10 +34,7 @@ import { EmptyDashboardAiStarterPrompts } from './emptyDashboardAiStarterPromptsconst HedgehogChart = pngHoggie(chartPng)-const DASHBOARD_DOCS_URL = 'https://posthog.com/docs/product-analytics/dashboards'--const BASE_TEXT =- 'A simple first step is to add an insight from your library. Over time this becomes the home for the data you care about most.'+const BASE_TEXT = 'Add a chart from your library, or start with a question about what matters to your product.'function DashboardEmptyActions({canEdit,@@ -43,6 +45,7 @@ function DashboardEmptyActions({onAddWidget,push,onOpenAiWithPrompt,+ promptExperience,}: {canEdit: booleandashboard: DashboardType<QueryBasedInsightModel> | null | undefined@@ -52,11 +55,31 @@ function DashboardEmptyActions({onAddWidget: () => voidpush: (path: string) => voidonOpenAiWithPrompt: (prompt: string) => void+ promptExperience: string | boolean | undefined}): JSX.Element {+ const { reportDashboardEmptyAddChartClicked, reportDashboardEmptyWebAnalyticsClicked } = useActions(eventUsageLogic)const chipDisabledReason = !canEdit ? DASHBOARD_CANNOT_EDIT_MESSAGE : aiDisabledReason || undefined+ const handleAddInsight = (): void => {+ reportDashboardEmptyAddChartClicked(dashboard?.id)+ onAddInsight()+ }return (<div className="flex flex-col gap-4 w-full max-w-full">+ {promptExperience === 'composer' ? (+ <DashboardAiPromptComposer+ dashboardId={dashboard?.id}+ disabledReason={chipDisabledReason}+ onOpenAiWithPrompt={onOpenAiWithPrompt}+ />+ ) : !aiDisabledReason ? (+ <EmptyDashboardAiStarterPrompts+ dashboardId={dashboard?.id}+ chipDisabledReason={chipDisabledReason}+ onOpenAiWithPrompt={onOpenAiWithPrompt}+ variant={promptExperience === 'copy' ? 'copy' : 'control'}+ />+ ) : null}<div className="flex flex-wrap items-center justify-center gap-x-4 gap-y-2 @min-[48rem]/main-content:justify-start">{dashboard && (<AccessControlAction@@ -68,7 +91,7 @@ function DashboardEmptyActions({data-attr="dashboard-add-graph-header"type="primary"icon={<IconPlus />}- onClick={onAddInsight}+ onClick={handleAddInsight}disabledReason={canEdit ? null : DASHBOARD_CANNOT_EDIT_MESSAGE}sideAction={{dropdown: {@@ -78,7 +101,7 @@ function DashboardEmptyActions({items={getAddTileMenuItems({dashboardId: dashboard.id,dashboardWidgetsEnabled,- onAddInsight,+ onAddInsight: handleAddInsight,push,setAddWidgetModalOpen: onAddWidget,})}@@ -90,16 +113,18 @@ function DashboardEmptyActions({'data-attr': 'dashboard-add-dropdown',}}>- Get started+ Add an existing chart</LemonButton></AccessControlAction>)}+ <LemonButton+ type="secondary"+ to={urls.webAnalytics()}+ onClick={() => reportDashboardEmptyWebAnalyticsClicked(dashboard?.id)}+ >+ or View Web Analytics+ </LemonButton></div>- <EmptyDashboardAiStarterPrompts- dashboardId={dashboard?.id}- chipDisabledReason={chipDisabledReason}- onOpenAiWithPrompt={onOpenAiWithPrompt}- /></div>)}@@ -111,6 +136,10 @@ function EmptyDashboardContent({ canEdit }: { canEdit: boolean }): JSX.Element {const { push } = useActions(router)const { openSidePanel } = useActions(sidePanelStateLogic)const { dataProcessingAccepted, dataProcessingApprovalDisabledReason } = useValues(maxGlobalLogic)+ const { featureFlags } = useValues(featureFlagLogic)+ const promptExperience = dataProcessingAccepted+ ? featureFlags[FEATURE_FLAGS.DASHBOARD_AI_PROMPT_COMPOSER]+ : undefinedconst aiDisabledReason =!dataProcessingAccepted &&@@ -130,14 +159,13 @@ function EmptyDashboardContent({ canEdit }: { canEdit: boolean }): JSX.Element {<ProductIntroductionproductName="Dashboard"thingName="insight"- titleOverride="So empty. So much potential."- description={BASE_TEXT}+ titleOverride="Build your dashboard"+ description={dataProcessingAccepted ? BASE_TEXT : 'Add a chart from your library.'}isEmpty={true}customHog={HedgehogChart}hogLayout="responsive"useMainContentContainerQueries={true}- docsURL={DASHBOARD_DOCS_URL}- className="mt-2 mb-2 px-4 @min-[40rem]/main-content:px-8 py-4 @min-[48rem]/main-content:py-14"+ className="mt-2 mb-2 py-4 @min-[48rem]/main-content:py-14"contentClassName="[&>div:last-child]:!mt-4"actionElementOverride={<DashboardEmptyActions@@ -149,6 +177,7 @@ function EmptyDashboardContent({ canEdit }: { canEdit: boolean }): JSX.Element {onAddWidget={() => setAddWidgetModalOpen(true)}push={push}onOpenAiWithPrompt={onOpenAiWithPrompt}+ promptExperience={promptExperience}/>}/>diff --git a/frontend/src/scenes/dashboard/dashboardAiPromptChips.tsx b/frontend/src/scenes/dashboard/dashboardAiPromptChips.tsxindex 273f7c5389d3..60826adbc350 100644--- a/frontend/src/scenes/dashboard/dashboardAiPromptChips.tsx+++ b/frontend/src/scenes/dashboard/dashboardAiPromptChips.tsx@@ -20,7 +20,7 @@ export type DashboardAiPromptChipsProps = {dataAttrPrefix: stringclassName?: stringmaxChips?: number- /** Defaults to empty-dashboard copy. */+ title?: stringdescription?: string}@@ -32,6 +32,7 @@ export function DashboardAiPromptChips({dataAttrPrefix,className,maxChips,+ title = 'Try PostHog AI',description = 'Pick a topic below. PostHog AI does the work so you can look at the data you care about quickly.',}: DashboardAiPromptChipsProps): JSX.Element {const { reportDashboardEmptyAiPromptClicked } = useActions(eventUsageLogic)@@ -43,7 +44,7 @@ export function DashboardAiPromptChips({<div className="rounded-xl border-2 border-[var(--color-ai)] bg-bg-surface-primary p-4"><div className="flex items-center gap-2 mb-1"><IconSparkles className="text-ai size-4 shrink-0" />- <span className="text-sm font-semibold">Try PostHog AI</span>+ <span className="text-sm font-semibold">{title}</span></div><p className="text-sm text-secondary m-0 mb-3">{description}</p><div className="flex flex-wrap gap-2">@@ -56,7 +57,7 @@ export function DashboardAiPromptChips({disabledReason={chipDisabledReason || undefined}data-attr={`${dataAttrPrefix}-${chip.id}`}onClick={() => {- reportDashboardEmptyAiPromptClicked(chip.label, dashboardId)+ reportDashboardEmptyAiPromptClicked(chip.label, dashboardId, 'starter_question')onOpenAiWithPrompt(chip.prompt)}}>diff --git a/frontend/src/scenes/dashboard/dashboardAiPromptComposerLogic.test.ts b/frontend/src/scenes/dashboard/dashboardAiPromptComposerLogic.test.tsnew file mode 100644index 000000000000..12ecbd9581e8--- /dev/null+++ b/frontend/src/scenes/dashboard/dashboardAiPromptComposerLogic.test.ts@@ -0,0 +1,15 @@+import { initKeaTests } from '~/test/init'++import { dashboardAiPromptComposerLogic } from './dashboardAiPromptComposerLogic'++describe('dashboardAiPromptComposerLogic', () => {+ beforeEach(() => {+ initKeaTests()+ })++ it('starts with an empty prompt', () => {+ dashboardAiPromptComposerLogic.mount()++ expect(dashboardAiPromptComposerLogic.values.prompt).toBe('')+ })+})diff --git a/frontend/src/scenes/dashboard/dashboardAiPromptComposerLogic.ts b/frontend/src/scenes/dashboard/dashboardAiPromptComposerLogic.tsnew file mode 100644index 000000000000..2c08fb01b28a--- /dev/null+++ b/frontend/src/scenes/dashboard/dashboardAiPromptComposerLogic.ts@@ -0,0 +1,39 @@+import { MakeLogicType, actions, kea, path, reducers } from 'kea'++type PromptSource = 'custom_prompt' | 'starter_question'++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface dashboardAiPromptComposerLogicValues {+ prompt: string+ promptSource: PromptSource+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface dashboardAiPromptComposerLogicActions {+ setPrompt: (+ prompt: string,+ promptSource?: PromptSource+ ) => {+ prompt: string+ promptSource: PromptSource+ }+}++export type dashboardAiPromptComposerLogicType = MakeLogicType<+ dashboardAiPromptComposerLogicValues,+ dashboardAiPromptComposerLogicActions+>++export const dashboardAiPromptComposerLogic = kea<dashboardAiPromptComposerLogicType>([+ path(['scenes', 'dashboard', 'dashboardAiPromptComposerLogic']),+ actions({+ setPrompt: (prompt: string, promptSource: PromptSource = 'custom_prompt') => ({+ prompt,+ promptSource,+ }),+ }),+ reducers({+ prompt: ['', { setPrompt: (_, { prompt }) => prompt }],+ promptSource: ['custom_prompt' as PromptSource, { setPrompt: (_, { promptSource }) => promptSource }],+ }),+])diff --git a/frontend/src/scenes/dashboard/emptyDashboardAiStarterPrompts.tsx b/frontend/src/scenes/dashboard/emptyDashboardAiStarterPrompts.tsxindex 843e8d8f10ba..9860053bf46b 100644--- a/frontend/src/scenes/dashboard/emptyDashboardAiStarterPrompts.tsx+++ b/frontend/src/scenes/dashboard/emptyDashboardAiStarterPrompts.tsx@@ -28,11 +28,21 @@ export const EMPTY_DASHBOARD_AI_PROMPT_CHIPS: readonly DashboardAiPromptChip[] =},]+const OUTCOME_FOCUSED_DASHBOARD_AI_PROMPT_CHIPS: readonly DashboardAiPromptChip[] = [+ ...EMPTY_DASHBOARD_AI_PROMPT_CHIPS.slice(0, 2),+ {+ id: 'activation_retention',+ label: 'See what brings users back after they sign up',+ prompt: 'Build an activation and retention dashboard. Show new signups, users who complete a key activation event, weekly retention cohorts, and the top paths to activation. Add insights I can save to this dashboard.',+ },+]+export type EmptyDashboardAiStarterPromptsProps = {dashboardId?: numberchipDisabledReason?: string | nullonOpenAiWithPrompt: (prompt: string) => voidclassName?: string+ variant?: 'control' | 'copy'}export function EmptyDashboardAiStarterPrompts({@@ -40,16 +50,21 @@ export function EmptyDashboardAiStarterPrompts({chipDisabledReason,onOpenAiWithPrompt,className,+ variant = 'control',}: EmptyDashboardAiStarterPromptsProps): JSX.Element {+ const isCopyVariant = variant === 'copy'+return (<DashboardAiPromptChips- chips={EMPTY_DASHBOARD_AI_PROMPT_CHIPS}+ chips={isCopyVariant ? OUTCOME_FOCUSED_DASHBOARD_AI_PROMPT_CHIPS : EMPTY_DASHBOARD_AI_PROMPT_CHIPS}dashboardId={dashboardId}chipDisabledReason={chipDisabledReason}onOpenAiWithPrompt={onOpenAiWithPrompt}dataAttrPrefix="dashboard-empty-ai-prompt"className={className}maxChips={3}+ title={isCopyVariant ? 'What matters most to you?' : undefined}+ description={isCopyVariant ? "Choose a topic, and we'll build a dashboard around it." : undefined}/>)}