: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
chore(surveys): delete unused survey overview and preview prop (#117909)
Lucas Faria43b1692d782b
diff --git a/frontend/src/scenes/surveys/SurveyEdit.tsx b/frontend/src/scenes/surveys/SurveyEdit.tsxindex 1c3d07bf4266..dd94c840d41f 100644--- a/frontend/src/scenes/surveys/SurveyEdit.tsx+++ b/frontend/src/scenes/surveys/SurveyEdit.tsx@@ -280,7 +280,6 @@ export default function SurveyEdit({ id }: { id: string }): JSX.Element {hasTargetingSet,selectedPageIndex,selectedSection,- isEditingSurvey,targetingFlagFilters,hasBranchingLogic,deviceTypesMatchTypeValidationError,@@ -1949,7 +1948,6 @@ export default function SurveyEdit({ id }: { id: string }): JSX.Element {previewPageIndex={selectedPageIndex || 0}survey={previewSurvey}handleSetSelectedPageIndex={(pageIndex) => setSelectedPageIndex(pageIndex)}- isEditingSurvey={isEditingSurvey}/></div></div>diff --git a/frontend/src/scenes/surveys/SurveyFormAppearance.tsx b/frontend/src/scenes/surveys/SurveyFormAppearance.tsxindex ef7f6a31157a..146c9e2141f9 100644--- a/frontend/src/scenes/surveys/SurveyFormAppearance.tsx+++ b/frontend/src/scenes/surveys/SurveyFormAppearance.tsx@@ -17,7 +17,6 @@ interface SurveyFormAppearanceProps {previewPageIndex: numbersurvey: NewSurvey | SurveyhandleSetSelectedPageIndex: (activePreview: number) => void- isEditingSurvey?: boolean}export function SurveyFormAppearance({diff --git a/frontend/src/scenes/surveys/SurveyOverview.tsx b/frontend/src/scenes/surveys/SurveyOverview.tsxdeleted file mode 100644index 9ccee19d8183..000000000000--- a/frontend/src/scenes/surveys/SurveyOverview.tsx+++ /dev/null@@ -1,225 +0,0 @@-import { useActions, useValues } from 'kea'-import { useState } from 'react'--import { IconComment, IconGitBranch } from '@posthog/icons'-import { LemonButton, LemonDivider, Link } from '@posthog/lemon-ui'--import { TZLabel } from 'lib/components/TZLabel'-import { dayjs } from 'lib/dayjs'-import { IconAreaChart, IconGridView, IconLink, IconListView } from 'lib/lemon-ui/icons'-import { pluralize } from 'lib/utils/strings'-import { FirstSurveyHelper } from 'scenes/surveys/components/empty-state/FirstSurveyHelper'-import { SURVEY_TYPE_LABEL_MAP, SurveyQuestionLabel } from 'scenes/surveys/constants'-import { CopySurveyLink } from 'scenes/surveys/CopySurveyLink'-import { SurveyDisplaySummary } from 'scenes/surveys/Survey'-import { SurveyAPIEditor } from 'scenes/surveys/SurveyAPIEditor'-import { SurveyFormAppearance } from 'scenes/surveys/SurveyFormAppearance'-import { surveyLogic } from 'scenes/surveys/surveyLogic'-import { getRecurringSurveyScheduleInfo } from 'scenes/surveys/utils'--import { SurveyQuestionType, SurveySchedule as SurveyScheduleEnum, SurveyType } from '~/types'--import { SurveyBranchingFlowModal } from './branching-flow/SurveyBranchingFlowModal'--function SurveySchedule(): JSX.Element {- const { survey } = useValues(surveyLogic)- if (survey.schedule === SurveyScheduleEnum.Recurring && survey.iteration_count && survey.iteration_frequency_days) {- const scheduleInfo = getRecurringSurveyScheduleInfo(survey)- return (- <span className="flex flex-col">- <span>- Repeats every {survey.iteration_frequency_days}{' '}- {pluralize(survey.iteration_frequency_days, 'day', 'days', false)}, {survey.iteration_count}{' '}- {pluralize(survey.iteration_count, 'time', 'times', false)}- </span>- {scheduleInfo &&- (!scheduleInfo.autoCloseDate ? (- <span className="text-xs text-muted">- Runs for {pluralize(scheduleInfo.totalDurationDays, 'day')} once launched- </span>- ) : scheduleInfo.autoCloseDate.isBefore(dayjs()) ? (- <span className="text-xs text-muted">- Schedule ended {scheduleInfo.autoCloseDate.format('MMMM D, YYYY')}; closing soon- </span>- ) : (- <span className="text-xs text-muted">- Automatically closes on {scheduleInfo.autoCloseDate.format('MMMM D, YYYY')}- </span>- ))}- </span>- )- }-- if (survey.schedule === SurveyScheduleEnum.Always) {- return <span>Always</span>- }-- // Default case: survey is scheduled to run once- return <span>Once</span>-}--function SurveyOption({ label, children }: { label: string; children: React.ReactNode }): JSX.Element {- return (- <div className="flex flex-col">- <dt className="card-secondary">{label}</dt>- <dd>{children}</dd>- </div>- )-}--const QuestionIconMap = {- [SurveyQuestionType.Open]: <IconComment className="text-muted" />,- [SurveyQuestionType.Link]: <IconLink className="text-muted" />,- [SurveyQuestionType.Rating]: <IconAreaChart className="text-muted" />,- [SurveyQuestionType.SingleChoice]: <IconListView className="text-muted" />,- [SurveyQuestionType.MultipleChoice]: <IconGridView className="text-muted" />,-}--export function SurveyOverview({ onTabChange }: { onTabChange?: (tab: string) => void }): JSX.Element {- const {- survey,- selectedPageIndex,- targetingFlagFilters,- surveyUsesLimit,- surveyUsesAdaptiveLimit,- hasBranchingLogic,- } = useValues(surveyLogic)- const { setSelectedPageIndex } = useActions(surveyLogic)- const [showFlowModal, setShowFlowModal] = useState(false)-- const isExternalSurvey = survey.type === SurveyType.ExternalSurvey-- return (- <div className="flex flex-col gap-8">- <FirstSurveyHelper onTabChange={onTabChange} />-- <div className="flex flex-col xl:grid xl:grid-cols-[1fr_400px] gap-x-4">- <dl className="flex flex-col gap-4 flex-1 overflow-hidden">- <SurveyOption label="Display mode">- <div className="flex flex-col">- <div className="flex flex-row items-center gap-2">- {SURVEY_TYPE_LABEL_MAP[survey.type]}- {isExternalSurvey && (- <CopySurveyLink- surveyId={survey.id}- enableIframeEmbedding={survey.enable_iframe_embedding ?? false}- />- )}- </div>- {isExternalSurvey && (- <span>- Responses are anonymous by default. To identify respondents, add the{' '}- <code className="bg-surface-tertiary px-1 rounded">?distinct_id=user123</code> to- the URL.{' '}- <Link- to="https://posthog.com/docs/surveys/creating-surveys#identifying-respondents-on-hosted-surveys"- target="_blank"- >- Check more details in the documentation- </Link>- .- </span>- )}- </div>- </SurveyOption>- <SurveyOption label={pluralize(survey.questions.length, 'Question', 'Questions', false)}>- <div className="flex flex-col gap-2">- {survey.questions.map((q, idx) => {- return (- <div- key={q.id ?? idx}- className="flex flex-col lg:gap-4 lg:flex-row justify-between"- >- <span className="flex-1 truncate">- {idx + 1}. {q.question}- </span>- <span className="flex items-center gap-1 text-xs text-muted">- {QuestionIconMap[q.type]}- {SurveyQuestionLabel[q.type]}- </span>- </div>- )- })}- {hasBranchingLogic && (- <div>- <LemonButton- type="secondary"- size="small"- icon={<IconGitBranch />}- onClick={() => setShowFlowModal(true)}- >- View branching flow- </LemonButton>- </div>- )}- </div>- </SurveyOption>- {(survey.start_date || survey.end_date) && (- <div className="flex gap-16">- {survey.start_date && (- <SurveyOption label="Start date">- <TZLabel time={survey.start_date} />- </SurveyOption>- )}- {survey.end_date && (- <SurveyOption label="End date">- <TZLabel time={survey.end_date} />- </SurveyOption>- )}- </div>- )}- <SurveyOption label="Schedule">- <SurveySchedule />- </SurveyOption>- {surveyUsesLimit && (- <SurveyOption label="Completion conditions">- The survey will be stopped once <b>{survey.responses_limit}</b> responses are received.- </SurveyOption>- )}- {surveyUsesAdaptiveLimit && (- <SurveyOption label="Completion conditions">- <span>- Survey response collection is limited to receive <b>{survey.response_sampling_limit}</b>{' '}- responses every {survey.response_sampling_interval}{' '}- {survey.response_sampling_interval_type}- (s).- </span>- </SurveyOption>- )}- <SurveyOption label="Partial responses">- {survey.enable_partial_responses ? 'Enabled' : 'Disabled'}- </SurveyOption>- <LemonDivider />- <SurveyDisplaySummary id={survey.id} survey={survey} targetingFlagFilters={targetingFlagFilters} />- </dl>- {survey.type !== SurveyType.API ? (- <SurveyFormAppearance- previewPageIndex={selectedPageIndex || 0}- survey={survey}- handleSetSelectedPageIndex={(preview) => setSelectedPageIndex(preview)}- />- ) : (- <div className="mt-2 space-y-2">- <div className="p-4 border rounded">- <div className="flex flex-row items-center w-full gap-1">- Learn how to set up API surveys{' '}- <Link- data-attr="survey-doc-link"- target="_blank"- to="https://posthog.com/docs/surveys/implementing-custom-surveys"- targetBlankIcon- >- in the docs- </Link>- </div>- </div>-- <SurveyAPIEditor survey={survey} />- </div>- )}- </div>-- <SurveyBranchingFlowModal survey={survey} isOpen={showFlowModal} onClose={() => setShowFlowModal(false)} />- </div>- )-}diff --git a/frontend/src/scenes/surveys/components/empty-state/FirstSurveyHelper.tsx b/frontend/src/scenes/surveys/components/empty-state/FirstSurveyHelper.tsxdeleted file mode 100644index 0945fcc86207..000000000000--- a/frontend/src/scenes/surveys/components/empty-state/FirstSurveyHelper.tsx+++ /dev/null@@ -1,166 +0,0 @@-import { useActions, useValues } from 'kea'--import * as einsteinPng from '@posthog/brand/hoggies/png/einstein'-import { IconBell, IconGraph, IconRocket, IconTarget } from '@posthog/icons'-import { LemonButton, Link } from '@posthog/lemon-ui'--import { pngHoggie } from 'lib/brand/hoggies'-import { LaunchSurveyButton } from 'scenes/surveys/components/LaunchSurveyButton'-import { SurveyEditSection, surveyLogic } from 'scenes/surveys/surveyLogic'-import { surveysLogic } from 'scenes/surveys/surveysLogic'--const HedgehogEinstein = pngHoggie(einsteinPng)--interface FirstSurveyHelperProps {- onTabChange?: (tab: string) => void-}--export function FirstSurveyHelper({ onTabChange }: FirstSurveyHelperProps): JSX.Element | null {- const { survey } = useValues(surveyLogic)- const { editingSurvey, setSelectedSection, setSurveyValue } = useActions(surveyLogic)- const { data, dataLoading } = useValues(surveysLogic)-- const hasOnlyOneSurvey = data.surveys.length <= 1-- if (dataLoading) {- return null- }-- // Only show for first-time users with unstarted surveys- if (!hasOnlyOneSurvey || survey.start_date) {- return null- }-- return (- <div className="bg-bg-light border border-border rounded-lg p-6">- <div className="flex items-center gap-6">- <div className="hidden sm:block flex-shrink-0">- <HedgehogEinstein width={180} height={180} className="scale-x-[-1]" />- </div>- <div className="flex-1 min-w-0">- <div className="mb-6">- <h3 className="text-xl font-semibold mb-2 text-default">Ready to launch your survey?</h3>- <p className="text-sm text-muted">- Your survey is set up! Here's what you can do next to maximize your results.- </p>- </div>-- {/* Primary Action - Most Important */}- <div className="bg-primary-3000/5 border border-primary-3000/20 rounded-lg p-4 mb-4">- <div className="flex items-center gap-3">- <div className="flex items-center justify-center w-8 h-8 bg-primary-3000 rounded-lg flex-shrink-0">- <IconRocket className="w-4 h-4 text-white" />- </div>- <div className="flex-1 min-w-0">- <h4 className="font-semibold text-default mb-0">Launch your survey</h4>- <p className="text-sm text-muted mb-0">- Start collecting feedback from your users right away.- </p>- </div>- <div className="flex-shrink-0">- <LaunchSurveyButton>Launch survey</LaunchSurveyButton>- </div>- </div>- </div>-- {/* Secondary Actions - Grouped */}- <div className="space-y-3">- <h5 className="text-sm font-medium text-muted uppercase tracking-wide">- Optional improvements- </h5>-- <div className="grid gap-3 sm:grid-cols-3">- <div className="border border-border rounded-lg p-3 hover:border-border-bold transition-colors">- <div className="flex items-start gap-3">- <IconTarget className="w-4 h-4 text-muted mt-1 flex-shrink-0" />- <div className="min-w-0 flex-1">- <h4 className="font-medium text-default text-sm mb-1">- Add display conditions- </h4>- <p className="text-xs text-muted mb-2 leading-relaxed">- Show to specific users.{' '}- <Link- to="https://posthog.com/docs/surveys/creating-surveys#display-conditions"- target="_blank"- className="text-primary-3000"- >- Docs- </Link>- </p>- <LemonButton- type="tertiary"- size="xsmall"- onClick={() => {- editingSurvey(true)- setSelectedSection(SurveyEditSection.DisplayConditions)- setTimeout(() => {- setSurveyValue('conditions', { url: '' })- }, 100)- }}- >- Configure- </LemonButton>- </div>- </div>- </div>-- <div className="border border-border rounded-lg p-3 hover:border-border-bold transition-colors">- <div className="flex items-start gap-3">- <IconGraph className="w-4 h-4 text-muted mt-1 flex-shrink-0" />- <div className="min-w-0 flex-1">- <h4 className="font-medium text-default text-sm mb-1">Preview results</h4>- <p className="text-xs text-muted mb-2 leading-relaxed">- See sample analytics.{' '}- <Link- to="https://posthog.com/docs/surveys/viewing-results#1-on-the-survey-page"- target="_blank"- className="text-primary-3000"- >- Docs- </Link>- </p>- <LemonButton- type="tertiary"- size="xsmall"- onClick={() => onTabChange?.('results')}- >- View demo- </LemonButton>- </div>- </div>- </div>-- <div className="border border-border rounded-lg p-3 hover:border-border-bold transition-colors">- <div className="flex items-start gap-3">- <IconBell className="w-4 h-4 text-muted mt-1 flex-shrink-0" />- <div className="min-w-0 flex-1">- <h4 className="font-medium text-default text-sm mb-1">- Get notified on responses- </h4>- <p className="text-xs text-muted mb-2 leading-relaxed">- Slack notifications.{' '}- <Link- to="https://posthog.com/tutorials/slack-surveys"- target="_blank"- className="text-primary-3000"- >- Tutorial- </Link>- </p>- <LemonButton- type="tertiary"- size="xsmall"- onClick={() => onTabChange?.('notifications')}- >- Set up- </LemonButton>- </div>- </div>- </div>- </div>- </div>- </div>- </div>- </div>- )-}