: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
fix(surveys): tailor resume UX for hosted surveys (#59319)
Lucas Fariaac13af7a6854
diff --git a/frontend/src/scenes/surveys/SurveyView.tsx b/frontend/src/scenes/surveys/SurveyView.tsxindex 3f146840cc97..f7e4a544dae4 100644--- a/frontend/src/scenes/surveys/SurveyView.tsx+++ b/frontend/src/scenes/surveys/SurveyView.tsx@@ -25,7 +25,12 @@ import { SurveyNotificationModal } from 'scenes/surveys/components/SurveyNotificimport { SurveyNotifications } from 'scenes/surveys/components/SurveyNotifications'import { SurveyNotificationsCallout } from 'scenes/surveys/components/SurveyNotificationsCallout'import { DuplicateToProjectModal } from 'scenes/surveys/DuplicateToProjectModal'-import { canDeleteSurvey, openArchiveSurveyDialog, openDeleteSurveyDialog } from 'scenes/surveys/surveyDialogs'+import {+ canDeleteSurvey,+ openArchiveSurveyDialog,+ openDeleteSurveyDialog,+ openResumeSurveyDialog,+} from 'scenes/surveys/surveyDialogs'import { surveyLogic } from 'scenes/surveys/surveyLogic'import { SurveyNoResponsesBanner } from 'scenes/surveys/SurveyNoResponsesBanner'import { SurveyOverview } from 'scenes/surveys/SurveyOverview'@@ -228,28 +233,7 @@ function SurveyViewLegacy({ id }: { id: string }): JSX.Element {<LemonButtontype="secondary"size="small"- onClick={() => {- LemonDialog.open({- title: 'Resume this survey?',- content: (- <div className="text-sm text-secondary">- Once resumed, the survey will be visible to your users- again.- </div>- ),- primaryButton: {- children: 'Resume',- type: 'primary',- onClick: () => resumeSurvey(),- size: 'small',- },- secondaryButton: {- children: 'Cancel',- type: 'tertiary',- size: 'small',- },- })- }}+ onClick={() => openResumeSurveyDialog(survey, () => resumeSurvey())}>Resume</LemonButton>diff --git a/frontend/src/scenes/surveys/SurveyViewRedesign/SurveyViewRedesign.tsx b/frontend/src/scenes/surveys/SurveyViewRedesign/SurveyViewRedesign.tsxindex 9ab401776b67..b545c3b8ac54 100644--- a/frontend/src/scenes/surveys/SurveyViewRedesign/SurveyViewRedesign.tsx+++ b/frontend/src/scenes/surveys/SurveyViewRedesign/SurveyViewRedesign.tsx@@ -26,7 +26,12 @@ import { SurveyNotifications } from 'scenes/surveys/components/SurveyNotificatioimport { SurveyNotificationsCallout } from 'scenes/surveys/components/SurveyNotificationsCallout'import { DuplicateToProjectModal } from 'scenes/surveys/DuplicateToProjectModal'import { useSurveyResponseColumns } from 'scenes/surveys/hooks/useSurveyResponseColumns'-import { canDeleteSurvey, openArchiveSurveyDialog, openDeleteSurveyDialog } from 'scenes/surveys/surveyDialogs'+import {+ canDeleteSurvey,+ openArchiveSurveyDialog,+ openDeleteSurveyDialog,+ openResumeSurveyDialog,+} from 'scenes/surveys/surveyDialogs'import { SurveyHeadline } from 'scenes/surveys/SurveyHeadline'import { SurveyTab, surveyLogic } from 'scenes/surveys/surveyLogic'import { SurveyNoResponsesBanner } from 'scenes/surveys/SurveyNoResponsesBanner'@@ -516,27 +521,7 @@ function SurveyStatusAction(): JSX.Element | null {<LemonButtontype="secondary"size="small"- onClick={() => {- LemonDialog.open({- title: 'Resume this survey?',- content: (- <div className="text-sm text-secondary">- Once resumed, the survey will be visible to your users again.- </div>- ),- primaryButton: {- children: 'Resume',- type: 'primary',- onClick: () => resumeSurvey(),- size: 'small',- },- secondaryButton: {- children: 'Cancel',- type: 'tertiary',- size: 'small',- },- })- }}+ onClick={() => openResumeSurveyDialog(survey, () => resumeSurvey())}>Resume</LemonButton>diff --git a/frontend/src/scenes/surveys/components/SurveysTable.tsx b/frontend/src/scenes/surveys/components/SurveysTable.tsxindex 1f08ef009b58..fb7e30b9ba56 100644--- a/frontend/src/scenes/surveys/components/SurveysTable.tsx+++ b/frontend/src/scenes/surveys/components/SurveysTable.tsx@@ -20,7 +20,12 @@ import { SurveysEmptyState } from 'scenes/surveys/components/empty-state/Surveysimport { SdkVersionWarnings } from 'scenes/surveys/components/SdkVersionWarnings'import { SurveyStatusTag } from 'scenes/surveys/components/SurveyStatusTag'import { SURVEY_TYPE_LABEL_MAP, SurveyQuestionLabel } from 'scenes/surveys/constants'-import { canDeleteSurvey, openArchiveSurveyDialog, openDeleteSurveyDialog } from 'scenes/surveys/surveyDialogs'+import {+ canDeleteSurvey,+ openArchiveSurveyDialog,+ openDeleteSurveyDialog,+ openResumeSurveyDialog,+} from 'scenes/surveys/surveyDialogs'import { SurveysTabs, surveysLogic } from 'scenes/surveys/surveysLogic'import { getSurveyWarnings } from 'scenes/surveys/surveyVersionRequirements'import { isSurveyRunning } from 'scenes/surveys/utils'@@ -348,37 +353,15 @@ export function SurveysTable(): JSX.Element {><LemonButtonfullWidth- onClick={() => {- LemonDialog.open({- title: 'Resume this survey?',- content: (- <div className="text-sm text-secondary">- Once resumed, the survey will be visible to your- users again.- </div>- ),- primaryButton: {- children: 'Resume',- type: 'primary',- onClick: () => {- updateSurvey({- id: survey.id,- updatePayload: {- end_date: null,- },- intentContext:- ProductIntentContext.SURVEY_RESUMED,- })- },- size: 'small',- },- secondaryButton: {- children: 'Cancel',- type: 'tertiary',- size: 'small',- },- })- }}+ onClick={() =>+ openResumeSurveyDialog(survey, () =>+ updateSurvey({+ id: survey.id,+ updatePayload: { end_date: null },+ intentContext: ProductIntentContext.SURVEY_RESUMED,+ })+ )+ }>Resume survey</LemonButton>diff --git a/frontend/src/scenes/surveys/surveyDialogs.tsx b/frontend/src/scenes/surveys/surveyDialogs.tsxindex be5fa4d358a8..f373b4aaadd5 100644--- a/frontend/src/scenes/surveys/surveyDialogs.tsx+++ b/frontend/src/scenes/surveys/surveyDialogs.tsx@@ -1,7 +1,11 @@import { LemonDialog } from '@posthog/lemon-ui'-import { Survey } from '~/types'+import { copyToClipboard } from 'lib/utils/copyToClipboard'+import { Survey, SurveyType } from '~/types'++import { HostedSurveyRespondentHint } from './components/HostedSurveyRespondentHint'+import { getSurveyUrl } from './CopySurveyLink'import { isSurveyRunning } from './utils'export function openDeleteSurveyDialog(survey: Pick<Survey, 'start_date'>, onConfirm: () => void): void {@@ -69,6 +73,41 @@ export function openArchiveSurveyDialog(survey: Pick<Survey, 'start_date' | 'end})}+export function openResumeSurveyDialog(survey: Pick<Survey, 'id' | 'type'>, onConfirm: () => void): void {+ const isHostedSurvey = survey.type === SurveyType.ExternalSurvey++ LemonDialog.open({+ title: 'Resume this survey?',+ content: isHostedSurvey ? (+ <div className="flex flex-col gap-3 text-sm">+ <p className="text-secondary m-0">+ Once resumed, anyone with the link can answer the survey again. We'll copy the link to your+ clipboard so you can share it right away.+ </p>+ <HostedSurveyRespondentHint />+ </div>+ ) : (+ <div className="text-sm text-secondary">Once resumed, the survey will be visible to your users again.</div>+ ),+ primaryButton: {+ children: isHostedSurvey ? 'Resume and copy link' : 'Resume',+ type: 'primary',+ onClick: () => {+ if (isHostedSurvey) {+ void copyToClipboard(getSurveyUrl(survey.id), 'survey link')+ }+ onConfirm()+ },+ size: 'small',+ },+ secondaryButton: {+ children: 'Cancel',+ type: 'tertiary',+ size: 'small',+ },+ })+}+export function canDeleteSurvey(survey: Pick<Survey, 'archived' | 'start_date'>): boolean {return survey.archived || !survey.start_date}