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(surveys): replace the custom empty state with the product empty state (#90628)

Rafael Audibertb6e968ec0fd0
diff --git a/docs/internal/product-empty-state-adoption.md b/docs/internal/product-empty-state-adoption.md
index e3f7827b6bcc..9f6229330b63 100644
--- a/docs/internal/product-empty-state-adoption.md
+++ b/docs/internal/product-empty-state-adoption.md
@@ -54,7 +54,7 @@ Rows marked "in review" are not on `master` yet. See "Regenerating the lists" fo
| Logs | `products/logs/frontend/LogsScene.tsx` | on master |
| Tracing | `products/tracing/frontend/TracingScene.tsx` | on master |
| Metrics | `products/metrics/frontend/MetricsScene.tsx` | on master |
-| Surveys | `frontend/src/scenes/surveys/Surveys.tsx` | in review |
+| Surveys | `frontend/src/scenes/surveys/Surveys.tsx` | on master |
| Session replay | `frontend/src/scenes/session-recordings/SessionRecordings.tsx` | in review |
| Web vitals | `frontend/src/scenes/web-analytics/WebAnalyticsScene.tsx` | in review |
| Data warehouse sources | `products/data_warehouse/frontend/scenes/SourcesScene/SourcesScene.tsx` | in review |
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 538bab5c5b7d..5ea2ecb1aa29 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -1864,6 +1864,10 @@ snapshots:
hash: v1.k794b7964.369d8902d1857ba89bc0995bbf90de39a2664d4c0ad9d7457b2c6c2972c65865.Q3OsOnoxbBawKNFS75yyCxSY3RTWKLXvDelOZhZQ6BE
components-product-empty-state--support-waiting-for-data--light:
hash: v1.k794b7964.81466638b2ad508f29fb15596fe41e493559cb42d140fc9a0631a5beb52a90af.eTpjSWKyf2FL3SoGdY-EGFLGwLo407-BlQiMsILXDkc
+ components-product-empty-state--surveys-needs-setup--dark:
+ hash: v1.k794b7964.48e0b204f4d32e3f43354e173336cdfd6686f18df2c4b5fa180ea8a31a0235da.s_YKrWdUSThhx49a5WBAhgjGd4H-UB4Ok6nPC3lInE4
+ components-product-empty-state--surveys-needs-setup--light:
+ hash: v1.k794b7964.605f8db038c8045d9b471fb9b6f9fcf8d00a08f76b83c8dac975fed59daa25d2.Khbj1vgQ8N6v8XHihiQfjF3d-TClZLLUf9hoY6VAPRE
components-product-empty-state--tracing-needs-setup--dark:
hash: v1.k794b7964.31166d2274ea22226bc3281a0fe2f39caef85292a870fa58b0339964bcb2cb6b.xl8D1Zuw7EzZn8ptdhasdeA8LNEskINpumcYVM619Jg
components-product-empty-state--tracing-needs-setup--light:
diff --git a/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.stories.tsx b/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.stories.tsx
index 579a8c84ab08..7fdf8dac78ca 100644
--- a/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.stories.tsx
+++ b/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.stories.tsx
@@ -21,6 +21,7 @@ import { metricsEmptyState } from 'products/metrics/frontend/emptyState/metricsE
import { productToursEmptyState } from 'products/product_tours/frontend/emptyState/productToursEmptyState'
import { replayVisionEmptyState } from 'products/replay_vision/frontend/emptyState/replayVisionEmptyState'
import { llmSkillsEmptyState } from 'products/skills/frontend/emptyState/llmSkillsEmptyState'
+import { surveysEmptyState } from 'products/surveys/frontend/emptyState/surveysEmptyState'
import { tracingEmptyState } from 'products/tracing/frontend/emptyState/tracingEmptyState'
import { userInterviewsEmptyState } from 'products/user_interviews/frontend/emptyState/userInterviewsEmptyState'
@@ -236,3 +237,8 @@ export const TracingNeedsSetup: ProductEmptyStateStory = productEmptyStateStory(
export const MetricsNeedsSetup: ProductEmptyStateStory = productEmptyStateStory(metricsEmptyState, 'needs-setup', {
mocks: { get: { '/api/projects/:team_id/metrics/has_metrics/': [200, { hasMetrics: false }] } },
})
+
+// Surveys detection counts surveys (live + archived) on mount - answer "none yet".
+export const SurveysNeedsSetup: ProductEmptyStateStory = productEmptyStateStory(surveysEmptyState, 'needs-setup', {
+ mocks: { get: { '/api/projects/:team_id/surveys/': [200, { count: 0, results: [] }] } },
+})
diff --git a/frontend/src/scenes/surveys/Surveys.tsx b/frontend/src/scenes/surveys/Surveys.tsx
index 4b3af831e0c9..59e32b2dd1d9 100644
--- a/frontend/src/scenes/surveys/Surveys.tsx
+++ b/frontend/src/scenes/surveys/Surveys.tsx
@@ -19,6 +19,8 @@ import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
import { ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'
import { AccessControlLevel, AccessControlResourceType, ActivityScope } from '~/types'
+import { surveysEmptyState } from 'products/surveys/frontend/emptyState/surveysEmptyState'
+
import { SURVEY_CREATED_SOURCE } from './constants'
import { DuplicateToProjectModal } from './DuplicateToProjectModal'
import { SurveySettings, SurveysDisabledBanner } from './SurveySettings'
@@ -28,6 +30,7 @@ export const scene: SceneExport = {
component: Surveys,
logic: surveysLogic,
productKey: ProductKey.SURVEYS,
+ emptyState: surveysEmptyState,
}
function NewSurveyButton(): JSX.Element {
diff --git a/frontend/src/scenes/surveys/components/SurveysTable.tsx b/frontend/src/scenes/surveys/components/SurveysTable.tsx
index 4753c03e56b5..9f97b961e296 100644
--- a/frontend/src/scenes/surveys/components/SurveysTable.tsx
+++ b/frontend/src/scenes/surveys/components/SurveysTable.tsx
@@ -17,7 +17,6 @@ import { cn } from 'lib/utils/css-classes'
import stringWithWBR from 'lib/utils/stringWithWBR'
import { organizationLogic } from 'scenes/organizationLogic'
import { Scene } from 'scenes/sceneTypes'
-import { SurveysEmptyState } from 'scenes/surveys/components/empty-state/SurveysEmptyState'
import { SdkVersionWarnings } from 'scenes/surveys/components/SdkVersionWarnings'
import { SurveyStatusTag } from 'scenes/surveys/components/SurveyStatusTag'
import { SURVEY_TYPE_LABEL_MAP, SurveyQuestionLabel } from 'scenes/surveys/constants'
@@ -347,16 +346,8 @@ export function SurveysTable(): JSX.Element {
)
const hasSearchTerm = Boolean(searchTerm.trim())
- const hasActiveFilters =
- hasSearchTerm || filters.status !== 'any' || filters.type !== 'any' || filters.created_by != null
const isInitialDataLoad = surveys.length === 0 && hasNextPage
const isTableLoading = dataLoading || isInitialDataLoad
- const shouldShowEmptyState =
- !isTableLoading && tab === SurveysTabs.Active && !hasActiveFilters && surveys.length === 0
-
- if (shouldShowEmptyState) {
- return <SurveysEmptyState />
- }
return (
<>
diff --git a/frontend/src/scenes/surveys/components/empty-state/SurveysEmptyState.tsx b/frontend/src/scenes/surveys/components/empty-state/SurveysEmptyState.tsx
deleted file mode 100644
index afd4b13eafe7..000000000000
--- a/frontend/src/scenes/surveys/components/empty-state/SurveysEmptyState.tsx
+++ /dev/null
@@ -1,266 +0,0 @@
-import { useActions, useValues } from 'kea'
-import { router } from 'kea-router'
-import { useEffect, useRef, useState } from 'react'
-
-import * as reporterPng from '@posthog/brand/hoggies/png/reporter'
-import { IconArrowRight, IconSparkles } from '@posthog/icons'
-import { LemonButton, LemonTextArea } from '@posthog/lemon-ui'
-
-import { pngHoggie } from 'lib/brand/hoggies'
-import { MCPUseCaseCard } from 'lib/components/MCPHint/MCPUseCaseCard'
-import { FEATURE_FLAGS } from 'lib/constants'
-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
-import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
-import { useMaxTool } from 'scenes/max/useMaxTool'
-import { QuickSurveyModal } from 'scenes/surveys/QuickSurveyModal'
-import { FeaturedTemplateCard, TemplateCard } from 'scenes/surveys/SurveyTemplates'
-import { teamLogic } from 'scenes/teamLogic'
-import { urls } from 'scenes/urls'
-
-import { Survey } from '~/types'
-
-import {
- QuickSurveyFromTemplate,
- SURVEY_CREATED_SOURCE,
- SurveyTemplate,
- SurveyTemplateType,
- defaultSurveyAppearance,
- defaultSurveyTemplates,
-} from '../../constants'
-import { surveysLogic } from '../../surveysLogic'
-
-const HedgehogReporter = pngHoggie(reporterPng)
-
-const TEMPLATE_TYPES = [SurveyTemplateType.NPS, SurveyTemplateType.CSAT, SurveyTemplateType.PMF]
-
-function SurveysEmptyStateContent(): JSX.Element {
- const { currentTeam } = useValues(teamLogic)
- const { reportSurveyTemplateClicked } = useActions(eventUsageLogic)
- const { handleMaxSurveyCreated } = useActions(surveysLogic)
-
- const [quickModalOpen, setQuickModalOpen] = useState<boolean>(false)
- const [quickSurveyContext, setQuickSurveyContext] = useState<QuickSurveyFromTemplate | undefined>(undefined)
-
- const { openMax } = useMaxTool({
- identifier: 'create_survey',
- initialMaxPrompt: `Create a survey to collect `,
- callback: (toolOutput) => handleMaxSurveyCreated(toolOutput, SURVEY_CREATED_SOURCE.SURVEY_EMPTY_STATE),
- })
-
- const templateToSurvey = (template: SurveyTemplate): Partial<Survey> & SurveyTemplate => {
- return {
- ...template,
- name: template.templateType,
- appearance: {
- ...template.appearance,
- ...currentTeam?.survey_config?.appearance,
- },
- }
- }
-
- // Get the three priority templates - most popular based on the Surveys dashboard
- const priorityTemplates = defaultSurveyTemplates
- .filter((template) =>
- [SurveyTemplateType.OpenFeedback, SurveyTemplateType.NPS, SurveyTemplateType.CSAT].includes(
- template.templateType
- )
- )
- .map(templateToSurvey)
-
- const featuredTemplate = defaultSurveyTemplates
- .filter((t) => t.featured)
- .slice(0, 1)
- .map(templateToSurvey)
- .at(0)
-
- const handleTemplateClick = (survey: SurveyTemplate): void => {
- reportSurveyTemplateClicked(survey.templateType, SURVEY_CREATED_SOURCE.SURVEY_EMPTY_STATE)
- if (survey.quickSurvey) {
- setQuickSurveyContext(survey.quickSurvey)
- setQuickModalOpen(true)
- } else {
- router.actions.push(urls.surveyWizard('new', survey.templateType))
- }
- }
-
- return (
- <>
- <div className="border-2 border-dashed border-primary w-full p-4 rounded">
- <div className="flex items-center justify-center">
- <div className="space-y-6">
- <div>
- <h2 className="mb-0">Create your first survey</h2>
- <p className="mb-0">
- Choose from our most popular templates to get started quickly, or create your own from
- scratch.
- </p>
- </div>
-
- <MCPUseCaseCard surfaceKey="surveys.create" className="!mt-0 w-full" />
-
- {featuredTemplate && (
- <div>
- <FeaturedTemplateCard
- template={featuredTemplate}
- idx={0}
- reportSurveyTemplateClicked={() => {}}
- surveyAppearance={featuredTemplate.appearance ?? {}}
- handleTemplateClick={handleTemplateClick}
- />
- </div>
- )}
- <div className="grid grid-cols-1 md:grid-cols-3 gap-4">
- {priorityTemplates.map((template, idx) => (
- <TemplateCard
- key={template.templateType}
- template={template}
- idx={idx + 1}
- reportSurveyTemplateClicked={() => {}}
- surveyAppearance={template.appearance ?? defaultSurveyAppearance}
- handleTemplateClick={handleTemplateClick}
- />
- ))}
- </div>
-
- <div className="flex items-center gap-x-4 gap-y-2 flex-wrap">
- <LemonButton type="primary" icon={<IconSparkles />} onClick={() => openMax?.()}>
- Create your own custom survey with PostHog AI
- </LemonButton>
- <LemonButton type="secondary" onClick={() => router.actions.push(urls.surveyWizard())}>
- See all other templates
- </LemonButton>
- </div>
- </div>
- </div>
- </div>
- <QuickSurveyModal
- context={quickSurveyContext?.context}
- isOpen={quickModalOpen}
- onCancel={() => setQuickModalOpen(false)}
- modalTitle={quickSurveyContext?.modalTitle}
- info={quickSurveyContext?.info}
- />
- </>
- )
-}
-
-function SurveysEmptyStateAIContent(): JSX.Element {
- const [prompt, setPrompt] = useState('')
-
- const { reportSurveyTemplateClicked, reportSurveyAiPromptSubmitted } = useActions(eventUsageLogic)
- const { handleMaxSurveyCreated } = useActions(surveysLogic)
- const { openMax } = useMaxTool({
- identifier: 'create_survey',
- initialMaxPrompt: `!${prompt.trim()}`,
- callback: (toolOutput) => handleMaxSurveyCreated(toolOutput, SURVEY_CREATED_SOURCE.SURVEY_EMPTY_STATE),
- })
- const textAreaRef = useRef<HTMLTextAreaElement>(null)
-
- const handleSubmit = (): void => {
- if (prompt.trim()) {
- reportSurveyAiPromptSubmitted(SURVEY_CREATED_SOURCE.SURVEY_EMPTY_STATE)
- openMax?.()
- setPrompt('')
- }
- }
-
- const templates = defaultSurveyTemplates.filter((t) => TEMPLATE_TYPES.includes(t.templateType))
-
- const handleTemplateClick = (survey: SurveyTemplate): void => {
- reportSurveyTemplateClicked(survey.templateType, 'empty_state')
- router.actions.push(urls.surveyWizard('new', survey.templateType))
- }
-
- return (
- <div className="w-full max-w-5xl mx-auto py-10 px-4">
- <div className="text-center mb-6">
- <HedgehogReporter className="size-20 mx-auto -mb-1" />
- <h2 className="text-2xl font-bold mb-1">Create your first survey</h2>
- <p className="text-secondary text-sm mb-0">
- Tell AI what you want to learn from your users, or pick a template below.
- </p>
- </div>
-
- <MCPUseCaseCard surfaceKey="surveys.create" className="!mt-0 w-full mb-6" />
-
- <div className="rounded-xl border-2 border-[var(--color-ai)] mb-8">
- <label
- htmlFor="survey-ai-prompt"
- className="flex flex-col cursor-text"
- onClick={() => textAreaRef.current?.focus()}
- >
- <LemonTextArea
- id="survey-ai-prompt"
- ref={textAreaRef}
- value={prompt}
- onChange={setPrompt}
- onPressEnter={handleSubmit}
- placeholder="e.g., Create an NPS survey for users who completed onboarding, shown on the dashboard page"
- minRows={2}
- maxRows={5}
- className="!border-none !bg-transparent !shadow-none !rounded-none px-4 pt-4 pb-2 resize-none text-sm"
- hideFocus
- data-attr="survey-ai-prompt-input"
- />
- <div className="flex items-center justify-between px-4 pb-3">
- <div className="flex items-center gap-1.5 text-xs text-tertiary">
- <IconSparkles className="text-ai size-3.5" />
- <span>PostHog AI</span>
- </div>
- <LemonButton
- type="primary"
- size="small"
- icon={<IconArrowRight />}
- onClick={handleSubmit}
- disabledReason={!prompt.trim() ? 'Describe the survey you want' : undefined}
- data-attr="survey-ai-prompt-submit"
- >
- Create with AI
- </LemonButton>
- </div>
- </label>
- </div>
-
- <div className="flex items-center gap-4 mb-6">
- <div className="flex-1 border-t border-primary" />
- <span className="text-xs text-tertiary uppercase tracking-wide">or start with a template</span>
- <div className="flex-1 border-t border-primary" />
- </div>
-
- <div className="grid grid-cols-1 sm:grid-cols-3 gap-3 mb-6">
- {templates.map((template, idx) => (
- <TemplateCard
- key={template.templateType}
- template={template}
- idx={idx + 1}
- reportSurveyTemplateClicked={() => {}}
- surveyAppearance={template.appearance ?? defaultSurveyAppearance}
- handleTemplateClick={handleTemplateClick}
- hideTag={true}
- />
- ))}
- </div>
-
- <div className="flex items-center justify-center text-center">
- <LemonButton type="secondary" size="small" onClick={() => router.actions.push(urls.surveyWizard())}>
- See more templates
- </LemonButton>
- </div>
- </div>
- )
-}
-
-export function SurveysEmptyState(): JSX.Element {
- const { featureFlags } = useValues(featureFlagLogic)
- const { reportSurveyEmptyStateViewed } = useActions(eventUsageLogic)
-
- useEffect(() => {
- reportSurveyEmptyStateViewed()
- }, [reportSurveyEmptyStateViewed])
-
- if (featureFlags[FEATURE_FLAGS.SURVEYS_AI_FIRST_EMPTY_STATE] === 'test') {
- return <SurveysEmptyStateAIContent />
- }
-
- return <SurveysEmptyStateContent />
-}
diff --git a/frontend/src/styles/base.scss b/frontend/src/styles/base.scss
index 3d1999c33e80..4a9a8880b9d9 100644
--- a/frontend/src/styles/base.scss
+++ b/frontend/src/styles/base.scss
@@ -331,6 +331,7 @@
--color-product-error-tracking-light: rgb(211 148 24);
--color-product-error-tracking-dark: rgb(247 165 1);
--color-product-surveys-light: rgb(243 84 84);
+ --color-product-surveys-dark: rgb(248 121 121);
--color-product-product-tours-light: rgb(243 84 84);
--color-product-product-tours-dark: rgb(248 121 121);
--color-product-data-warehouse-light: rgb(133 103 255);
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 76e98f8e23d1..5fe8019926d5 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -513,7 +513,7 @@ importers:
version: 5.3.0
jest-image-snapshot:
specifier: ^6.4.0
mockdate:
specifier: ^3.0.5
version: 3.0.5
@@ -1955,7 +1955,7 @@ importers:
version: 3.6.0
jest-image-snapshot:
specifier: ^6.4.0
storybook:
specifier: 'catalog:'
@@ -4525,6 +4525,9 @@ importers:
products/surveys:
dependencies:
+ '@posthog/brand':
+ specifier: 'catalog:'
+ version: 0.10.0([email protected])
'@posthog/icons':
specifier: 'catalog:'
@@ -4553,6 +4556,9 @@ importers:
'@storybook/react':
specifier: 'catalog:'
+ kea-test-utils:
+ specifier: 'catalog:'
+ version: 0.2.4([email protected](patch_hash=139b8d1f1304f9d9da452a9a1244c94ea679dbcb85687d8999563146879fb6f5)([email protected]))
products/tasks:
dependencies:
diff --git a/products/surveys/frontend/e2e/settings.spec.ts b/products/surveys/frontend/e2e/settings.spec.ts
index 4388213013d3..a20d88918174 100644
--- a/products/surveys/frontend/e2e/settings.spec.ts
+++ b/products/surveys/frontend/e2e/settings.spec.ts
@@ -10,9 +10,27 @@ test.describe('Survey Settings', () => {
test.beforeEach(async ({ page, playwrightSetup }) => {
await playwrightSetup.loginAndNavigateToTeam(page, workspace!)
+ // The scene shows its setup empty state, tab bar included, until the project
+ // holds a survey. Seed one over the API so the Settings tab is reachable.
+ await seedSurvey(page, workspace!)
await page.goToMenuItem('surveys')
})
+ async function seedSurvey(page: Page, workspace: PlaywrightWorkspaceSetupResult): Promise<void> {
+ const response = await page.request.post(`/api/projects/${workspace.team_id}/surveys/`, {
+ headers: {
+ Authorization: `Bearer ${workspace.personal_api_key}`,
+ 'Content-Type': 'application/json',
+ },
+ data: {
+ name: 'Settings fixture survey',
+ type: 'popover',
+ questions: [{ type: 'open', question: 'How is it going?' }],
+ },
+ })
+ expect(response.ok()).toBe(true)
+ }
+
async function toggleSurveysSettingsAndWaitResponse(page: Page): Promise<void> {
const responsePromise = page.waitForResponse(
(resp) => resp.url().includes('/api/environments/') && resp.request().method() === 'PATCH'
diff --git a/products/surveys/frontend/emptyState/NewSurveyActions.tsx b/products/surveys/frontend/emptyState/NewSurveyActions.tsx
new file mode 100644
index 000000000000..ebbb57764dd0
--- /dev/null
+++ b/products/surveys/frontend/emptyState/NewSurveyActions.tsx
@@ -0,0 +1,75 @@
+import { useValues } from 'kea'
+
+import { IconSparkles } from '@posthog/icons'
+import { LemonButton } from '@posthog/lemon-ui'
+
+import { AccessControlAction } from 'lib/components/AccessControlAction'
+import { maxGlobalLogic } from 'scenes/max/maxGlobalLogic'
+import { useMaxTool } from 'scenes/max/useMaxTool'
+import { SURVEY_CREATED_SOURCE } from 'scenes/surveys/constants'
+import { surveysLogic } from 'scenes/surveys/surveysLogic'
+import { teamLogic } from 'scenes/teamLogic'
+import { urls } from 'scenes/urls'
+
+import { ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'
+import { AccessControlLevel, AccessControlResourceType } from '~/types'
+
+/**
+ * The surveys empty state's actions: the same survey wizard the scene's "New
+ * survey" button opens, plus the Max-driven creation flow the old empty state
+ * offered.
+ */
+export function NewSurveyActions(): JSX.Element {
+ const { isMaxAvailable } = useValues(maxGlobalLogic)
+ const { openMax } = useMaxTool({
+ identifier: 'create_survey',
+ initialMaxPrompt: 'Create a survey to collect ',
+ callback: (toolOutput) => {
+ surveysLogic
+ .findMounted()
+ ?.actions.handleMaxSurveyCreated(toolOutput, SURVEY_CREATED_SOURCE.SURVEY_EMPTY_STATE)
+ },
+ // `openMax` is null only when the tool is inactive, so without this the button stays
+ // enabled on an instance without PostHog AI and opens a panel saying it isn't set up.
+ active: isMaxAvailable,
+ })
+
+ return (
+ <div className="flex items-center gap-2">
+ <AccessControlAction
+ resourceType={AccessControlResourceType.Survey}
+ minAccessLevel={AccessControlLevel.Editor}
+ >
+ <LemonButton
+ type="primary"
+ to={urls.surveyWizard()}
+ data-attr="new-survey"
+ onClick={() => {
+ teamLogic.findMounted()?.actions.addProductIntent({
+ product_type: ProductKey.SURVEYS,
+ intent_context: ProductIntentContext.SURVEY_ADD_NEW,
+ })
+ }}
+ >
+ Create your first survey
+ </LemonButton>
+ </AccessControlAction>
+ {isMaxAvailable ? (
+ <AccessControlAction
+ resourceType={AccessControlResourceType.Survey}
+ minAccessLevel={AccessControlLevel.Editor}
+ >
+ <LemonButton
+ type="secondary"
+ icon={<IconSparkles />}
+ data-attr="surveys-empty-state-create-with-ai"
+ onClick={() => openMax?.()}
+ disabledReason={openMax ? undefined : 'PostHog AI is unavailable here'}
+ >
+ Create with AI
+ </LemonButton>
+ </AccessControlAction>
+ ) : null}
+ </div>
+ )
+}
diff --git a/products/surveys/frontend/emptyState/SurveysPreview.scss b/products/surveys/frontend/emptyState/SurveysPreview.scss
new file mode 100644
index 000000000000..c66b23bd0dad
--- /dev/null
+++ b/products/surveys/frontend/emptyState/SurveysPreview.scss
@@ -0,0 +1,324 @@
+@import '../../../../frontend/src/lib/components/ProductEmptyState/previewMixins';
+
+.SurveysPreview {
+ --surveys-preview-accent: var(--empty-state-accent, var(--color-primary-500));
+
+ display: flex;
+ flex-direction: column;
+ gap: 0.75rem;
+
+ // Hidden answered state. A direct child of .SurveysPreview so `:checked ~` reaches both cards.
+ &__checkbox {
+ position: absolute;
+ width: 0;
+ height: 0;
+ pointer-events: none;
+ opacity: 0;
+ }
+
+ &__app,
+ &__results {
+ overflow: hidden;
+ background: var(--color-bg-surface-primary);
+ border: 1px solid var(--color-border-primary);
+ border-radius: var(--radius);
+ }
+
+ // Answered/unanswered pairs are stacked on one grid cell and crossfaded, so
+ // answering never changes any element's size (no layout shift).
+ &__swap {
+ display: grid;
+ }
+
+ &__swap > * {
+ grid-area: 1 / 1;
+ min-width: 0;
+ }
+
+ &__when-answered {
+ @include preview-swap-hidden;
+ }
+
+ &__when-unanswered {
+ @include preview-swap-visible;
+ }
+
+ // Mini app with the survey popover
+
+ &__chrome {
+ display: flex;
+ gap: 0.375rem;
+ align-items: center;
+ padding: 0.4375rem 0.75rem;
+ border-bottom: 1px solid var(--color-border-primary);
+ }
+
+ &__url {
+ margin-left: 0.375rem;
+ font-family: var(--font-mono);
+ font-size: 0.625rem;
+ color: var(--color-text-secondary);
+ }
+
+ &__screen {
+ display: flex;
+ flex-direction: column;
+ gap: 0.5rem;
+ padding: 0.75rem;
+ }
+
+ &__page {
+ display: flex;
+ flex-direction: column;
+ gap: 0.375rem;
+ }
+
+ &__page-line {
+ height: 0.5rem;
+ background: var(--color-bg-fill-tertiary);
+ border-radius: 999px;
+ }
+
+ &__page-line--short {
+ width: 55%;
+ }
+
+ // The in-app survey popover, bottom-right like the real widget.
+ &__popover {
+ align-self: flex-end;
+ width: 88%;
+ padding: 0.625rem 0.75rem;
+ background: var(--color-bg-surface-primary);
+ border: 1px solid var(--color-border-primary);
+ border-radius: var(--radius);
+ box-shadow: 0 2px 8px rgb(0 0 0 / 8%);
+ }
+
+ &__question {
+ display: flex;
+ flex-direction: column;
+ gap: 0.5rem;
+ }
+
+ &__question-text {
+ font-size: 0.75rem;
+ font-weight: 600;
+ }
+
+ &__scale {
+ display: grid;
+ grid-template-columns: repeat(11, 1fr);
+ gap: 0.1875rem;
+ }
+
+ &__score {
+ padding: 0.25rem 0;
+ font-size: 0.625rem;
+ font-variant-numeric: tabular-nums;
+ text-align: center;
+ border: 1px solid var(--color-border-primary);
+ border-radius: var(--radius);
+ }
+
+ &__score--hero {
+ cursor: pointer;
+ user-select: none;
+ transition:
+ background-color 150ms ease,
+ color 150ms ease;
+ }
+
+ &__score--hero:hover {
+ background: var(--color-bg-fill-highlight-50);
+ }
+
+ &__scale-labels {
+ display: flex;
+ justify-content: space-between;
+ font-size: 0.5625rem;
+ color: var(--color-text-tertiary);
+ }
+
+ &__thanks {
+ align-self: center;
+ font-size: 0.75rem;
+ font-weight: 600;
+ text-align: center;
+
+ @include preview-accent-text(var(--surveys-preview-accent));
+ }
+
+ &__hint {
+ font-size: 0.625rem;
+ color: var(--color-text-tertiary);
+ text-align: center;
+ }
+
+ // Results card
+
+ &__head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 0.5rem 0.75rem;
+ border-bottom: 1px solid var(--color-border-primary);
+ }
+
+ &__title {
+ display: flex;
+ gap: 0.375rem;
+ align-items: center;
+ font-size: 0.75rem;
+ font-weight: 600;
+ }
+
+ &__live-dot {
+ width: 7px;
+ height: 7px;
+ background: var(--surveys-preview-accent);
+ border-radius: 50%;
+ animation: SurveysPreview__pulse 2s ease-in-out infinite;
+ }
+
+ &__stats {
+ display: flex;
+ gap: 2rem;
+ padding: 0.625rem 0.75rem 0.25rem;
+ }
+
+ &__stat {
+ display: flex;
+ flex-direction: column;
+ }
+
+ &__stat-label {
+ font-size: 0.625rem;
+ font-weight: 600;
+ color: var(--color-text-secondary);
+ }
+
+ &__stat-value {
+ font-size: 1.25rem;
+ font-weight: 700;
+ font-variant-numeric: tabular-nums;
+ line-height: 1.2;
+ }
+
+ &__stat-value--bumped {
+ @include preview-accent-text(var(--surveys-preview-accent));
+ }
+
+ // Detractors/passives/promoters distribution. The promoter share grows on answer.
+ &__bar {
+ display: flex;
+ gap: 2px;
+ height: 8px;
+ margin: 0.375rem 0.75rem 0.25rem;
+ overflow: hidden;
+ border-radius: 999px;
+ }
+
+ &__bar-detractors {
+ width: 18%;
+ background: color-mix(in oklab, var(--danger) 55%, transparent);
+ transition: width 400ms ease;
+ }
+
+ &__bar-passives {
+ width: 30%;
+ background: var(--color-bg-fill-tertiary);
+ transition: width 400ms ease;
+ }
+
+ &__bar-promoters {
+ flex: 1;
+ background: var(--surveys-preview-accent);
+ }
+
+ &__legend {
+ display: flex;
+ gap: 0.75rem;
+ padding: 0 0.75rem;
+ font-size: 0.5625rem;
+ color: var(--color-text-tertiary);
+ }
+
+ &__quote {
+ padding: 0.5rem 0.75rem 0.625rem;
+ font-size: 0.6875rem;
+ color: var(--color-text-secondary);
+ }
+
+ &__quote--fresh {
+ font-weight: 600;
+
+ @include preview-accent-text(var(--surveys-preview-accent));
+ }
+
+ @include preview-chrome-dot;
+}
+
+// Answered state (user clicked a score)
+
+.SurveysPreview__checkbox:checked ~ * .SurveysPreview__when-answered {
+ @include preview-swap-visible;
+}
+
+.SurveysPreview__checkbox:checked ~ * .SurveysPreview__when-unanswered {
+ @include preview-swap-hidden;
+}
+
+.SurveysPreview__checkbox:checked ~ .SurveysPreview__app .SurveysPreview__score--hero {
+ color: var(--color-bg-surface-primary);
+ background: var(--surveys-preview-accent);
+}
+
+// One more promoter shifts the distribution.
+.SurveysPreview__checkbox:checked ~ .SurveysPreview__results .SurveysPreview__bar-detractors {
+ width: 16%;
+}
+
+.SurveysPreview__checkbox:checked ~ .SurveysPreview__results .SurveysPreview__bar-passives {
+ width: 28%;
+}
+
+// The checkbox stays keyboard-focusable while visually hidden, so the score it labels
+// needs a visible focus indicator (WCAG 2.4.7).
+.SurveysPreview__checkbox:focus-visible ~ .SurveysPreview__app .SurveysPreview__score--hero {
+ outline: 2px solid var(--surveys-preview-accent);
+ outline-offset: 1px;
+}
+
+// Nudge attention at the hero score until it's clicked.
+.SurveysPreview:not(.SurveysPreview--static)
+ .SurveysPreview__checkbox:not(:checked)
+ ~ .SurveysPreview__app
+ .SurveysPreview__score--hero {
+ animation: SurveysPreview__nudge 2.4s ease-in-out infinite;
+}
+
+@keyframes SurveysPreview__nudge {
+ 0%,
+ 100% {
+ box-shadow: 0 0 0 0 color-mix(in oklab, var(--surveys-preview-accent) 45%, transparent);
+ }
+
+ 50% {
+ box-shadow: 0 0 0 4px color-mix(in oklab, var(--surveys-preview-accent) 20%, transparent);
+ }
+}
+
+@keyframes SurveysPreview__pulse {
+ 0%,
+ 100% {
+ opacity: 1;
+ }
+
+ 50% {
+ opacity: 0.35;
+ }
+}
+
+// Storybook snapshots and reduced motion drop all ambient motion; clicking the
+// score still flips the state (transitions only).
+@include preview-motion-guards('SurveysPreview');
diff --git a/products/surveys/frontend/emptyState/SurveysPreview.tsx b/products/surveys/frontend/emptyState/SurveysPreview.tsx
new file mode 100644
index 000000000000..7356ff5cc030
--- /dev/null
+++ b/products/surveys/frontend/emptyState/SurveysPreview.tsx
@@ -0,0 +1,130 @@
+import './SurveysPreview.scss'
+
+import { LemonTag } from 'lib/lemon-ui/LemonTag'
+import { cn } from 'lib/utils/css-classes'
+import { inStorybook, inStorybookTestRunner } from 'lib/utils/dom'
+
+const NPS_SCORES = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
+
+/**
+ * Example-data preview for the surveys empty state: the NPS popover a user sees
+ * in-app, and the results it feeds. Clicking a score answers the survey - the
+ * popover thanks the respondent, the response count ticks up, and the promoter
+ * bar grows. One hidden checkbox drives it via `:checked ~` styles - no timers
+ * or state, per the preview rules in the `building-product-empty-states` skill.
+ * Answered/unanswered pairs are stacked in `__swap` grids, so nothing shifts.
+ */
+export function SurveysPreview(): JSX.Element {
+ const isStatic = inStorybook() || inStorybookTestRunner()
+
+ return (
+ <div className={cn('SurveysPreview', isStatic && 'SurveysPreview--static')}>
+ {/* Answered state, before both cards so `:checked ~` can style them. */}
+ <input type="checkbox" id="surveys-preview-answer" className="SurveysPreview__checkbox" />
+
+ <div className="SurveysPreview__app">
+ <div className="SurveysPreview__chrome">
+ <span className="SurveysPreview__chrome-dot" />
+ <span className="SurveysPreview__chrome-dot" />
+ <span className="SurveysPreview__chrome-dot" />
+ <span className="SurveysPreview__url">yourapp.com/dashboard</span>
+ </div>
+ <div className="SurveysPreview__screen">
+ <div className="SurveysPreview__page" aria-hidden="true">
+ <span className="SurveysPreview__page-line" />
+ <span className="SurveysPreview__page-line SurveysPreview__page-line--short" />
+ </div>
+ <div className="SurveysPreview__popover">
+ <div className="SurveysPreview__popover-body SurveysPreview__swap">
+ <div className="SurveysPreview__question SurveysPreview__when-unanswered">
+ <span className="SurveysPreview__question-text">
+ How likely are you to recommend us to a friend?
+ </span>
+ <span className="SurveysPreview__scale">
+ {NPS_SCORES.map((score) =>
+ score === 9 ? (
+ <label
+ key={score}
+ htmlFor="surveys-preview-answer"
+ className="SurveysPreview__score SurveysPreview__score--hero"
+ >
+ {score}
+ </label>
+ ) : (
+ <span key={score} className="SurveysPreview__score">
+ {score}
+ </span>
+ )
+ )}
+ </span>
+ <span className="SurveysPreview__scale-labels">
+ <span>Not likely</span>
+ <span>Very likely</span>
+ </span>
+ </div>
+ <div className="SurveysPreview__thanks SurveysPreview__when-answered">
+ Thanks for your feedback!
+ </div>
+ </div>
+ </div>
+ <div className="SurveysPreview__hint SurveysPreview__swap">
+ <span className="SurveysPreview__when-unanswered">Answer the survey to see it land below.</span>
+ <span className="SurveysPreview__when-answered">
+ Counted, no code changes needed. Click 9 again to undo.
+ </span>
+ </div>
+ </div>
+ </div>
+
+ <div className="SurveysPreview__results">
+ <div className="SurveysPreview__head">
+ <span className="SurveysPreview__title">
+ <span className="SurveysPreview__live-dot" aria-hidden="true" />
+ NPS survey · results
+ </span>
+ <LemonTag size="small">example data</LemonTag>
+ </div>
+ <div className="SurveysPreview__stats">
+ <div className="SurveysPreview__stat">
+ <span className="SurveysPreview__stat-label">Responses</span>
+ <span className="SurveysPreview__stat-value SurveysPreview__swap">
+ <span className="SurveysPreview__when-unanswered">184</span>
+ <span className="SurveysPreview__when-answered SurveysPreview__stat-value--bumped">
+ 185
+ </span>
+ </span>
+ </div>
+ <div className="SurveysPreview__stat">
+ <span className="SurveysPreview__stat-label">NPS score</span>
+ <span className="SurveysPreview__stat-value SurveysPreview__swap">
+ <span className="SurveysPreview__when-unanswered">42</span>
+ <span className="SurveysPreview__when-answered SurveysPreview__stat-value--bumped">43</span>
+ </span>
+ </div>
+ </div>
+ <div className="SurveysPreview__bar" aria-hidden="true">
+ <span className="SurveysPreview__bar-detractors" />
+ <span className="SurveysPreview__bar-passives" />
+ <span className="SurveysPreview__bar-promoters" />
+ </div>
+ <div className="SurveysPreview__legend">
+ <span className="SurveysPreview__legend-item SurveysPreview__legend-item--detractors">
+ Detractors
+ </span>
+ <span className="SurveysPreview__legend-item SurveysPreview__legend-item--passives">Passives</span>
+ <span className="SurveysPreview__legend-item SurveysPreview__legend-item--promoters">
+ Promoters
+ </span>
+ </div>
+ <div className="SurveysPreview__quote SurveysPreview__swap">
+ <span className="SurveysPreview__when-unanswered">
+ "Love the product, wish exports were faster."
+ </span>
+ <span className="SurveysPreview__when-answered SurveysPreview__quote--fresh">
+ Your response, just now: 9 · promoter
+ </span>
+ </div>
+ </div>
+ </div>
+ )
+}
diff --git a/products/surveys/frontend/emptyState/surveysEmptyState.tsx b/products/surveys/frontend/emptyState/surveysEmptyState.tsx
new file mode 100644
index 000000000000..8f3dcfe0c075
--- /dev/null
+++ b/products/surveys/frontend/emptyState/surveysEmptyState.tsx
@@ -0,0 +1,37 @@
+import * as reporterPng from '@posthog/brand/hoggies/png/reporter'
+import { IconMessage } from '@posthog/icons'
+
+import { pngHoggie } from 'lib/brand/hoggies'
+import type { SceneProductEmptyState } from 'lib/components/ProductEmptyState/types'
+
+import { ProductKey } from '~/queries/schema/schema-general'
+
+import { NewSurveyActions } from './NewSurveyActions'
+import { SurveysPreview } from './SurveysPreview'
+import { surveysSetupLogic } from './surveysSetupLogic'
+
+const HedgehogReporter = pngHoggie(reporterPng)
+
+export const surveysEmptyState: SceneProductEmptyState = {
+ statusLogic: surveysSetupLogic,
+ config: {
+ productKey: ProductKey.SURVEYS,
+ productName: 'Surveys',
+ icon: <IconMessage />,
+ accentColor: 'var(--color-product-surveys-light)',
+ accentColorDark: 'var(--color-product-surveys-dark)',
+ hedgehog: HedgehogReporter,
+ text: {
+ 'needs-setup': {
+ headline: 'Ask your users, right in the product',
+ lead: 'Launch NPS, CSAT, or fully custom surveys with no code. Target them by cohort, feature flag, or URL, and analyze responses next to the rest of your product data.',
+ },
+ },
+ PrimaryAction: NewSurveyActions,
+ docsUrl: 'https://posthog.com/docs/surveys',
+ previewLabel: 'Responses, once your survey is live',
+ Preview: SurveysPreview,
+ // Skipping would reveal a bare empty list; creating a survey is the only next step.
+ skippable: false,
+ },
+}
diff --git a/products/surveys/frontend/emptyState/surveysSetupLogic.test.ts b/products/surveys/frontend/emptyState/surveysSetupLogic.test.ts
new file mode 100644
index 000000000000..1766a7b12102
--- /dev/null
+++ b/products/surveys/frontend/emptyState/surveysSetupLogic.test.ts
@@ -0,0 +1,33 @@
+import { expectLogic } from 'kea-test-utils'
+
+import { productSetupStatusLogic } from 'lib/components/ProductEmptyState/productSetupStatusLogic'
+
+import { ProductKey } from '~/queries/schema/schema-general'
+import { initKeaTests } from '~/test/init'
+
+import { surveysList } from '../generated/api'
+import { surveysSetupLogic } from './surveysSetupLogic'
+
+jest.mock('../generated/api', () => ({ surveysList: jest.fn() }))
+
+describe('surveysSetupLogic', () => {
+ beforeEach(() => {
+ initKeaTests()
+ })
+
+ // Guards the count mapping the scene gate hangs off. The archived case matters:
+ // the list excludes archived surveys unless asked, so collapsing to one query
+ // would gate a project that archived all of its surveys.
+ it.each([
+ [0, 0, 'needs-setup'],
+ [2, 0, 'has-data'],
+ [0, 1, 'has-data'],
+ ])('live=%s, archived=%s maps to %s', async (live, archived, expected) => {
+ ;(surveysList as jest.Mock).mockImplementation((_projectId: string, params?: { archived?: boolean }) =>
+ Promise.resolve({ count: params?.archived ? archived : live, results: [] })
+ )
+ surveysSetupLogic.mount()
+ await expectLogic(surveysSetupLogic).toFinishAllListeners()
+ expect(productSetupStatusLogic({ productKey: ProductKey.SURVEYS }).values.status).toBe(expected)
+ })
+})
diff --git a/products/surveys/frontend/emptyState/surveysSetupLogic.ts b/products/surveys/frontend/emptyState/surveysSetupLogic.ts
new file mode 100644
index 000000000000..e10ae8c1bc0e
--- /dev/null
+++ b/products/surveys/frontend/emptyState/surveysSetupLogic.ts
@@ -0,0 +1,27 @@
+import { createSetupDetectionLogic } from 'lib/components/ProductEmptyState/setupDetectionLogic'
+import { projectLogic } from 'scenes/projectLogic'
+
+import { ProductKey } from '~/queries/schema/schema-general'
+
+import { surveysList } from '../generated/api'
+
+/**
+ * Setup detection for the surveys empty state. Surveys are a creation-first
+ * product, so "set up" simply means the project has at least one survey - no
+ * event or traffic signal involved.
+ */
+export const surveysSetupLogic = createSetupDetectionLogic({
+ productKey: ProductKey.SURVEYS,
+ path: ['products', 'surveys', 'frontend', 'emptyState', 'surveysSetupLogic'],
+ detect: async () => {
+ const projectId = String(projectLogic.findMounted()?.values.currentProjectId)
+ // The list excludes archived surveys unless asked for them, and no value of
+ // `archived` returns both, so a project that archived all of its surveys
+ // would count zero and lose the scene it unarchives them from.
+ const [live, archived] = await Promise.all([
+ surveysList(projectId, { limit: 1 }),
+ surveysList(projectId, { limit: 1, archived: true }),
+ ])
+ return live.count + archived.count > 0 ? 'has-data' : 'needs-setup'
+ },
+})
diff --git a/products/surveys/package.json b/products/surveys/package.json
index a29d7e89278a..cac595a96c04 100644
--- a/products/surveys/package.json
+++ b/products/surveys/package.json
@@ -9,9 +9,11 @@
"kea-router": "catalog:"
},
"devDependencies": {
- "@storybook/react": "catalog:"
+ "@storybook/react": "catalog:",
+ "kea-test-utils": "catalog:"
},
"peerDependencies": {
+ "@posthog/brand": "catalog:",
"@posthog/icons": "catalog:",
"@types/react": "*",
"clsx": "*",