: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(surveys): add an export shortcut to the summary tab (#98627)
Lucas Fariad7a79c7203df
diff --git a/docs/internal/survey-responses.md b/docs/internal/survey-responses.mdindex b2c89cfef690..c31db0610ad3 100644--- a/docs/internal/survey-responses.md+++ b/docs/internal/survey-responses.md@@ -18,3 +18,8 @@ It includes a compact row with counts and percentages for **Completed**, **DismiThese percentages use all responses matching the current filters as their denominator, including archived responses when selected.Each submission counts once in this breakdown, even when the performance summary counts unique people.The performance bar labels dismissals with no answers separately from responses.++Use **Export responses** on the Summary tab to download answers as CSV or Excel.+The export includes all responses matching the current filters, across all table pages.+The Responses tab has an export control in the table.+The same export remains available in the action sidebar.diff --git a/docs/published/docs/surveys/performance.md b/docs/published/docs/surveys/performance.mdindex be5410abb669..1e9c52db80bc 100644--- a/docs/published/docs/surveys/performance.md+++ b/docs/published/docs/surveys/performance.md@@ -8,6 +8,8 @@ The inline metrics show **Shown**, **Responses**, and **Response rate**. Turn onThe results toolbar contains the date range and **Filters**, which expands response filters, property filters, and **Show archived**. The Filters badge counts active response and property filters plus the archived toggle; the visible date range is separate. **Clear filters** appears when filters are active and resets the date range, response filters, property filters, and archived toggle. Find **View insights** in the toolbar's overflow menu. Configure survey notifications in the **Notifications** tab.+On the **Summary** tab, use **Export responses** on the right of the toolbar to download all answers matching the current filters as CSV or Excel, across all table pages. The **Responses** tab has an export control in the table.+The outcome bar shows responses, dismissals without answers, and unanswered surveys. Each label includes its count and percentage, so small segments remain readable. Hover over the bar to inspect the counts in the chart tooltip.**Response completion** describes the submissions that contain answers:diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex c5afc8bf2834..5c23bd1a3eef 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -9596,6 +9596,10 @@ snapshots:hash: v1.k794b7964.d24cf21331cc08695b112c71c74fbebad505f764b5724c887e1eae2b910a5add.F78vCNK-5jT9ibk8H5w3wLowjG6acy17BWbFyM9rmhMscenes-app-surveys--survey-results--light:hash: v1.k794b7964.a1e5aa8fb1e492e5336f984ec06b48c101295863c2ac0f3d6ce75a1c7325710e.94II2OjeSRNoA0vmcSCD4VYazwhbhLOQFTU1Yvwl4LY+ scenes-app-surveys--survey-summary-export--dark:+ hash: v1.k794b7964.7a29422b4cb020b79b9f9908dca482a988d85cc76f0ef933119ebfc234a26102.wHOJnD6FjoTozXXkXXko9W9sSQxIk0GApIqv4sojL-g+ scenes-app-surveys--survey-summary-export--light:+ hash: v1.k794b7964.4c1aba9c3175866b1cd56a938768604d0cfa12158dc6881d8051cf9b4dce01b9.7SX5XrAQDCKIdIawBOoVzZMKBaDtedRucnvsxb9HLMEscenes-app-surveys--surveys-global-settings--dark:hash: v1.k794b7964.476a85556bb374416ca1ae0cccfb23f8cc6f6a2e0e71d3f7d0e37a2ad3d463aa.lCKgctegJe2jQZ7Bf7sXK6YhuGh17KhGftYqoY3s5PMscenes-app-surveys--surveys-global-settings--light:diff --git a/frontend/src/scenes/surveys/SurveyViewRedesign/SurveyFilters.tsx b/frontend/src/scenes/surveys/SurveyViewRedesign/SurveyFilters.tsxindex ff240a831830..48e4cdbf2bb0 100644--- a/frontend/src/scenes/surveys/SurveyViewRedesign/SurveyFilters.tsx+++ b/frontend/src/scenes/surveys/SurveyViewRedesign/SurveyFilters.tsx@@ -42,7 +42,7 @@ function CopyResponseKeyButton({ questionId }: { questionId: string }): JSX.Elem)}-export function SurveyResultsFiltersBar(): JSX.Element {+export function SurveyResultsFiltersBar({ actions }: { actions?: React.ReactNode }): JSX.Element {const {survey,answerFilters,@@ -135,15 +135,18 @@ export function SurveyResultsFiltersBar(): JSX.Element {</LemonButton>)}</div>- <LemonMenu items={[{ label: 'View insights', icon: <IconGraph />, to: surveyAsInsightURL }]}>- <LemonButton- size="small"- icon={<IconEllipsis />}- aria-label="More result actions"- tooltip="More result actions"- data-attr="survey-results-more-actions"- />- </LemonMenu>+ <div className="flex flex-wrap items-center gap-2">+ {actions}+ <LemonMenu items={[{ label: 'View insights', icon: <IconGraph />, to: surveyAsInsightURL }]}>+ <LemonButton+ size="small"+ icon={<IconEllipsis />}+ aria-label="More result actions"+ tooltip="More result actions"+ data-attr="survey-results-more-actions"+ />+ </LemonMenu>+ </div></div>{resultsFiltersExpanded && (diff --git a/frontend/src/scenes/surveys/SurveyViewRedesign/SurveyViewRedesign.tsx b/frontend/src/scenes/surveys/SurveyViewRedesign/SurveyViewRedesign.tsxindex a542012d767c..bf247231773f 100644--- a/frontend/src/scenes/surveys/SurveyViewRedesign/SurveyViewRedesign.tsx+++ b/frontend/src/scenes/surveys/SurveyViewRedesign/SurveyViewRedesign.tsx@@ -2,11 +2,12 @@ import { useActions, useValues } from 'kea'import { router } from 'kea-router'import { useCallback, useEffect, useMemo, useRef, useState } from 'react'-import { IconArchive, IconCode, IconCopy, IconTrash } from '@posthog/icons'+import { IconArchive, IconCode, IconCopy, IconDownload, IconTrash } from '@posthog/icons'import { LemonButton, LemonDialog, LemonDivider, LemonTag, Tooltip } from '@posthog/lemon-ui'import { AccessControlAction } from 'lib/components/AccessControlAction'import { ActivityLog } from 'lib/components/ActivityLog/ActivityLog'+import { ExportButton } from 'lib/components/ExportButton/ExportButton'import { SceneDuplicate } from 'lib/components/Scenes/SceneDuplicate'import { SceneFile } from 'lib/components/Scenes/SceneFile'import { SceneMenuBarFileItems } from 'lib/components/Scenes/SceneMenuBarFileItems'@@ -63,6 +64,7 @@ import {AccessControlLevel,AccessControlResourceType,ActivityScope,+ ExporterFormat,ProgressStatus,SidePanelTab,Survey,@@ -600,6 +602,7 @@ function SurveyStatusAction(): JSX.Element | null {function SurveySummaryContent({ onViewResponses }: { onViewResponses: () => void }): JSX.Element {const {survey,+ dataTableQuery,isAnyResultsLoading,resultsRequeryInProgress,processedSurveyStats,@@ -614,11 +617,34 @@ function SurveySummaryContent({ onViewResponses }: { onViewResponses: () => voidconst atLeastOneResponse = !!processedSurveyStats?.[SurveyEventName.SENT].total_countconst isRefreshingResults = resultsRequeryInProgress || isAnyResultsLoading+ const exportButton = (+ <ExportButton+ id="survey-responses-export"+ type="secondary"+ size="small"+ icon={<IconDownload />}+ buttonCopy="Export responses"+ disabledReason={!dataTableQuery ? 'No responses to export yet.' : undefined}+ items={+ dataTableQuery+ ? [ExporterFormat.CSV, ExporterFormat.XLSX].map((format) => ({+ title: format === ExporterFormat.CSV ? 'Export as CSV' : 'Export as Excel',+ export_format: format,+ export_context: {+ source: dataTableQuery,+ filename: `survey-${survey.name}-responses`,+ },+ }))+ : []+ }+ />+ )+if (!isRefreshingResults && !atLeastOneResponse) {return (<div className="px-4 pb-4"><div className="mx-auto w-full max-w-[1200px] space-y-6">- <SurveyResultsFiltersBar />+ <SurveyResultsFiltersBar actions={exportButton} /><SurveyStatsSummary /><SurveyNoResponsesBannertype="survey"@@ -638,7 +664,7 @@ function SurveySummaryContent({ onViewResponses }: { onViewResponses: () => voidreturn (<div className="px-4 pb-4"><div className="mx-auto w-full max-w-[1200px] space-y-6">- <SurveyResultsFiltersBar />+ <SurveyResultsFiltersBar actions={exportButton} /><SurveyResultsRefreshStatus visible={isRefreshingResults} /><divaria-busy={isRefreshingResults}diff --git a/frontend/src/scenes/surveys/Surveys.stories.tsx b/frontend/src/scenes/surveys/Surveys.stories.tsxindex 71deb895533f..eced0161c40d 100644--- a/frontend/src/scenes/surveys/Surveys.stories.tsx+++ b/frontend/src/scenes/surveys/Surveys.stories.tsx@@ -583,6 +583,18 @@ export const SurveyResults: Story = {],}+export const SurveySummaryExport: Story = {+ ...SurveyResults,+ parameters: {+ ...SurveyResults.parameters,+ pageUrl: `${urls.survey(MOCK_SURVEY_WITH_RESULTS.id)}?tab=summary`,+ testOptions: {+ waitForSelector: '#survey-responses-export',+ viewport: { width: 560, height: 800 },+ },+ },+}+export const SurveyNotFound: Story = {tags: ['test-skip'],parameters: {