: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): stop double-scaling survey rates in MCP stats view (#69234)
Sam Pennington1f8a1e074751
diff --git a/products/surveys/mcp/apps/SurveyStatsView.tsx b/products/surveys/mcp/apps/SurveyStatsView.tsxindex 40dced9df2c2..e6051528880e 100644--- a/products/surveys/mcp/apps/SurveyStatsView.tsx+++ b/products/surveys/mcp/apps/SurveyStatsView.tsx@@ -12,6 +12,7 @@ export interface SurveyStatEntry {export interface SurveyStatsData {survey_id?: stringstats?: Record<string, { total_count: number; unique_persons: number }>+ // Rates come from the API already scaled to a percentage (0-100), e.g. 21.7 means 21.7%.rates?: { response_rate?: number; dismissal_rate?: number }_posthogUrl?: string}@@ -48,11 +49,9 @@ export function SurveyStatsView({ data }: SurveyStatsViewProps): ReactElement {<div><div className="flex justify-between text-sm mb-1"><span className="text-muted-foreground">Response rate</span>- <span className="tabular-nums">- {(data.rates.response_rate * 100).toFixed(1)}%- </span>+ <span className="tabular-nums">{data.rates.response_rate.toFixed(1)}%</span></div>- <Progress value={data.rates.response_rate * 100} variant="success" />+ <Progress value={data.rates.response_rate} variant="success" /></div>)}{data.rates.dismissal_rate != null && (@@ -60,10 +59,10 @@ export function SurveyStatsView({ data }: SurveyStatsViewProps): ReactElement {<div className="flex justify-between text-sm mb-1"><span className="text-muted-foreground">Dismissal rate</span><span className="tabular-nums">- {(data.rates.dismissal_rate * 100).toFixed(1)}%+ {data.rates.dismissal_rate.toFixed(1)}%</span></div>- <Progress value={data.rates.dismissal_rate * 100} variant="warning" />+ <Progress value={data.rates.dismissal_rate} variant="warning" /></div>)}</div>diff --git a/products/surveys/mcp/apps/Surveys.stories.tsx b/products/surveys/mcp/apps/Surveys.stories.tsxindex d2bda57ad81e..2a7cd6d3e66c 100644--- a/products/surveys/mcp/apps/Surveys.stories.tsx+++ b/products/surveys/mcp/apps/Surveys.stories.tsx@@ -126,8 +126,8 @@ const sampleStats: SurveyStatsData = {'survey dismissed': { total_count: 1830, unique_persons: 1700 },},rates: {- response_rate: 0.255,- dismissal_rate: 0.217,+ response_rate: 25.5,+ dismissal_rate: 21.7,},_posthogUrl: 'https://us.posthog.com/project/1/surveys/survey-1',}