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.

fix(surveys): stop the launch flow from enabling surveys project-wide (#99391)

Phillf7b9ef862507
diff --git a/frontend/src/scenes/surveys/SurveySettings.tsx b/frontend/src/scenes/surveys/SurveySettings.tsx
index c3128518c0c1..c0b6b73846cb 100644
--- a/frontend/src/scenes/surveys/SurveySettings.tsx
+++ b/frontend/src/scenes/surveys/SurveySettings.tsx
@@ -150,7 +150,7 @@ export function SurveySettings({ isModal = false }: { isModal?: boolean }): JSX.
)
}
-function openSurveysSettingsDialog(): void {
+export function openSurveysSettingsDialog(): void {
LemonDialog.open({
title: 'Surveys settings',
content: <SurveySettings isModal />,
diff --git a/frontend/src/scenes/surveys/components/LaunchSurveyButton.tsx b/frontend/src/scenes/surveys/components/LaunchSurveyButton.tsx
index 1a1c3e803aae..a09fcdb0db41 100644
--- a/frontend/src/scenes/surveys/components/LaunchSurveyButton.tsx
+++ b/frontend/src/scenes/surveys/components/LaunchSurveyButton.tsx
@@ -8,20 +8,17 @@ import { copyToClipboard } from 'lib/utils/copyToClipboard'
import { HostedSurveyRespondentHint } from 'scenes/surveys/components/HostedSurveyRespondentHint'
import { SdkVersionWarnings } from 'scenes/surveys/components/SdkVersionWarnings'
import { SurveyConditionsList } from 'scenes/surveys/components/SurveyConditions'
+import { SurveysDisabledLaunchWarning } from 'scenes/surveys/components/SurveysDisabledLaunchWarning'
import { getSurveyUrl } from 'scenes/surveys/CopySurveyLink'
import { surveyLogic } from 'scenes/surveys/surveyLogic'
import { getSurveyDisplayConditionsSummary } from 'scenes/surveys/utils'
-import { teamLogic } from 'scenes/teamLogic'
import { AccessControlLevel, AccessControlResourceType, SurveyType } from '~/types'
export function LaunchSurveyButton({ children = 'Launch' }: { children?: ReactNode }): JSX.Element {
const { survey, surveyWarnings } = useValues(surveyLogic)
const { launchSurvey } = useActions(surveyLogic)
- const { currentTeam } = useValues(teamLogic)
- const { updateCurrentTeam } = useActions(teamLogic)
- const needsOptIn = !currentTeam?.surveys_opt_in
const isHostedSurvey = survey.type === SurveyType.ExternalSurvey
const conditionsSummary = isHostedSurvey ? [] : getSurveyDisplayConditionsSummary(survey)
@@ -61,18 +58,13 @@ export function LaunchSurveyButton({ children = 'Launch' }: { children?: ReactNo
This survey will be shown to all users.
</div>
)}
- {needsOptIn && (
- <div className="text-xs text-muted">This will enable surveys for your project.</div>
- )}
+ <SurveysDisabledLaunchWarning surveyType={survey.type} />
</div>
),
primaryButton: {
children: isHostedSurvey ? 'Launch and copy link' : 'Launch',
type: 'primary',
onClick: () => {
- if (needsOptIn) {
- updateCurrentTeam({ surveys_opt_in: true })
- }
if (isHostedSurvey) {
void copyToClipboard(getSurveyUrl(survey.id), 'survey link')
}
diff --git a/frontend/src/scenes/surveys/components/SurveysDisabledLaunchWarning.tsx b/frontend/src/scenes/surveys/components/SurveysDisabledLaunchWarning.tsx
new file mode 100644
index 000000000000..d51449b4cfb6
--- /dev/null
+++ b/frontend/src/scenes/surveys/components/SurveysDisabledLaunchWarning.tsx
@@ -0,0 +1,35 @@
+import { useValues } from 'kea'
+
+import { IconGear } from '@posthog/icons'
+import { LemonBanner } from '@posthog/lemon-ui'
+
+import { openSurveysSettingsDialog } from 'scenes/surveys/SurveySettings'
+import { teamLogic } from 'scenes/teamLogic'
+
+import { SurveyType } from '~/types'
+
+// The launch dialogs snapshot their content, so this component reads the setting live. The
+// Configure button turns surveys on in a dialog above, and the warning must clear when it does.
+export function SurveysDisabledLaunchWarning({ surveyType }: { surveyType: SurveyType }): JSX.Element | null {
+ const { currentTeam } = useValues(teamLogic)
+
+ // PostHog hosts and renders these surveys, so they do not depend on the project's surveys_opt_in setting.
+ if (surveyType === SurveyType.ExternalSurvey || currentTeam?.surveys_opt_in) {
+ return null
+ }
+
+ return (
+ <LemonBanner
+ type="warning"
+ action={{
+ type: 'secondary',
+ icon: <IconGear />,
+ onClick: () => openSurveysSettingsDialog(),
+ children: 'Configure',
+ }}
+ >
+ Surveys are off for this project, so your app will not show this survey automatically. Launching does not
+ change the setting.
+ </LemonBanner>
+ )
+}
diff --git a/frontend/src/scenes/surveys/wizard/SurveyWizard.tsx b/frontend/src/scenes/surveys/wizard/SurveyWizard.tsx
index bc2fd65a5113..fd13ceb6f73c 100644
--- a/frontend/src/scenes/surveys/wizard/SurveyWizard.tsx
+++ b/frontend/src/scenes/surveys/wizard/SurveyWizard.tsx
@@ -14,7 +14,6 @@ import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'
import { featureFlagLogic as enabledFeaturesLogic } from 'lib/logic/featureFlagLogic'
import { useMaxTool } from 'scenes/max/useMaxTool'
import { SceneExport } from 'scenes/sceneTypes'
-import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
import { themeLogic } from '~/layout/navigation-3000/themeLogic'
@@ -23,6 +22,7 @@ import { SurveyMatchType, SurveyQuestionBranchingType, SurveyType } from '~/type
import { HostedSurveyRespondentHint } from '../components/HostedSurveyRespondentHint'
import { SdkVersionWarnings } from '../components/SdkVersionWarnings'
import { SurveyPublicContentNotice } from '../components/SurveyPublicContentNotice'
+import { SurveysDisabledLaunchWarning } from '../components/SurveysDisabledLaunchWarning'
import { NewSurvey } from '../constants'
import { SurveyAppearancePreview } from '../SurveyAppearancePreview'
import { getEventPropertyFilterCount } from '../SurveyEventTrigger'
@@ -109,8 +109,6 @@ function SurveyWizard({ id }: SurveyWizardLogicProps): JSX.Element {
},
})
- const { currentTeam } = useValues(teamLogic)
- const { updateCurrentTeam } = useActions(teamLogic)
const { isDarkModeOn } = useValues(themeLogic)
const [previewPageIndex, setPreviewPageIndex] = useState(0)
@@ -261,6 +259,7 @@ function SurveyWizard({ id }: SurveyWizardLogicProps): JSX.Element {
content: (
<div className="space-y-2">
<SdkVersionWarnings warnings={surveyWarnings} />
+ <SurveysDisabledLaunchWarning surveyType={survey.type} />
{isHostedSurvey ? (
<div className="flex flex-col gap-3">
<p className="text-secondary m-0">
@@ -298,31 +297,7 @@ function SurveyWizard({ id }: SurveyWizardLogicProps): JSX.Element {
}
const handleLaunchClick = (): void => {
- if (!currentTeam?.surveys_opt_in) {
- LemonDialog.open({
- title: 'Enable surveys?',
- content: (
- <p className="text-secondary">
- Surveys are currently disabled for this project. Would you like to enable them and launch your
- survey?
- </p>
- ),
- primaryButton: {
- children: 'Enable & continue',
- type: 'primary',
- onClick: () => {
- updateCurrentTeam({ surveys_opt_in: true })
- showLaunchConfirmation(launchSurvey)
- },
- },
- secondaryButton: {
- children: 'Cancel',
- type: 'tertiary',
- },
- })
- } else {
- showLaunchConfirmation(launchSurvey)
- }
+ showLaunchConfirmation(launchSurvey)
}
const handleSaveClick = (): void => {