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.

feat(mcp-analytics): add feedback survey button (#91121)

Lucas Faria6aec1a4828ff
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index f52f7d2a613b..a387ba98adc9 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -7353,7 +7353,7 @@ snapshots:
scenes-app-max-ai-replay-vision-scan-widget--with-skipped--light:
hash: v1.k794b7964.c543228b0f31abb2aae3b274819abdee4ba6a89fb3324fc6aaa2b18aefee5815.S9etTEY8oT2JhOgLO5hdc6VqvbvYhD-nU4P1WKh24yg
scenes-app-mcp-analytics--activity--dark:
- hash: v1.k794b7964.8260dddad89625bb262d04be928f4e417d5b82195adcd475563dea59ae8f380e.CtzjnY-sch0rG7R9hkAD6Ai5SDP40LNsBsW5hQhJJys
+ hash: v1.k794b7964.bca0d74d1b2639c6b1f979e341f71f07760a64f741ae2c8a52911b60dc1199c7.qXE1qgq9_TENwX5GUO2YnUiP4QcGqZlCPpGbL8cS_H4
scenes-app-mcp-analytics--activity--light:
hash: v1.k794b7964.473eea859bb71b592d4192301ff6b6f80d0b31bc60d992537d1f4c72ef5a54fa.TYyn1fQMICc0v0oJjArYuI8WHq9LrVDDeu8ECeEAFac
scenes-app-mcp-analytics--dashboard--dark:
diff --git a/frontend/src/lib/components/FeedbackSurveyButton/FeedbackSurveyButton.test.tsx b/frontend/src/lib/components/FeedbackSurveyButton/FeedbackSurveyButton.test.tsx
index 15e30bb02150..765f860e29eb 100644
--- a/frontend/src/lib/components/FeedbackSurveyButton/FeedbackSurveyButton.test.tsx
+++ b/frontend/src/lib/components/FeedbackSurveyButton/FeedbackSurveyButton.test.tsx
@@ -1,5 +1,5 @@
import { cleanup, fireEvent, render } from '@testing-library/react'
-import posthog, { DisplaySurveyType } from 'posthog-js'
+import posthog, { DisplaySurveyType, type Properties } from 'posthog-js'
import { FeedbackSurveyButton } from './FeedbackSurveyButton'
@@ -16,8 +16,8 @@ function mockSurveysLoaded(context: { isLoaded: boolean } | null): void {
}) as typeof posthog.onSurveysLoaded)
}
-function renderButton(): HTMLElement {
- const { getByRole } = render(<FeedbackSurveyButton surveyId={SURVEY_ID} />)
+function renderButton(properties?: Properties): HTMLElement {
+ const { getByRole } = render(<FeedbackSurveyButton surveyId={SURVEY_ID} properties={properties} />)
return getByRole('button')
}
@@ -39,7 +39,8 @@ describe('FeedbackSurveyButton', () => {
it('displays the survey with condition bypass once surveys load', () => {
mockSurveysLoaded({ isLoaded: true })
- const button = renderButton()
+ const properties = { feedback_surface: 'mcp_analytics', mcp_analytics_tab: 'activity' }
+ const button = renderButton(properties)
expect(button.getAttribute('aria-disabled')).not.toBe('true')
fireEvent.click(button)
@@ -47,6 +48,7 @@ describe('FeedbackSurveyButton', () => {
displayType: DisplaySurveyType.Popover,
ignoreConditions: true,
ignoreDelay: true,
+ properties,
})
})
diff --git a/frontend/src/lib/components/FeedbackSurveyButton/FeedbackSurveyButton.tsx b/frontend/src/lib/components/FeedbackSurveyButton/FeedbackSurveyButton.tsx
index adae0b1837f4..393b0f71860a 100644
--- a/frontend/src/lib/components/FeedbackSurveyButton/FeedbackSurveyButton.tsx
+++ b/frontend/src/lib/components/FeedbackSurveyButton/FeedbackSurveyButton.tsx
@@ -1,10 +1,11 @@
-import posthog, { DisplaySurveyType } from 'posthog-js'
+import posthog, { DisplaySurveyType, type Properties } from 'posthog-js'
import { useEffect, useState } from 'react'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
export interface FeedbackSurveyButtonProps {
surveyId: string
+ properties?: Properties
'data-attr'?: string
}
@@ -13,7 +14,11 @@ export interface FeedbackSurveyButtonProps {
* The plain, iconless styling is the intended standard for in-app feedback buttons — new ones
* should use this component rather than adding another variant.
*/
-export function FeedbackSurveyButton({ surveyId, 'data-attr': dataAttr }: FeedbackSurveyButtonProps): JSX.Element {
+export function FeedbackSurveyButton({
+ surveyId,
+ properties,
+ 'data-attr': dataAttr,
+}: FeedbackSurveyButtonProps): JSX.Element {
const [surveysLoaded, setSurveysLoaded] = useState(false)
useEffect(
@@ -39,6 +44,7 @@ export function FeedbackSurveyButton({ surveyId, 'data-attr': dataAttr }: Feedba
displayType: DisplaySurveyType.Popover,
ignoreConditions: true,
ignoreDelay: true,
+ properties,
})
}
>
diff --git a/products/mcp_analytics/frontend/MCPAnalyticsScene.tsx b/products/mcp_analytics/frontend/MCPAnalyticsScene.tsx
index 881ed6293bdb..c456848e1cd5 100644
--- a/products/mcp_analytics/frontend/MCPAnalyticsScene.tsx
+++ b/products/mcp_analytics/frontend/MCPAnalyticsScene.tsx
@@ -4,6 +4,7 @@ import { router, combineUrl } from 'kea-router'
import { IconSparkles } from '@posthog/icons'
import { LemonButton, LemonTab, LemonTabs, LemonTag } from '@posthog/lemon-ui'
+import { FeedbackSurveyButton } from 'lib/components/FeedbackSurveyButton/FeedbackSurveyButton'
import { NotFound } from 'lib/components/NotFound'
import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
@@ -37,6 +38,7 @@ export const scene: SceneExport = {
}
const MCP_DOCS_URL = 'https://posthog.com/docs/mcp-analytics/installation'
+const MCP_ANALYTICS_FEEDBACK_SURVEY_ID = '01a04991-bc80-0000-70c5-beeea0553cd0'
export function MCPAnalyticsScene(): JSX.Element {
return (
@@ -133,6 +135,14 @@ function MCPAnalyticsSceneContent(): JSX.Element {
resourceType={{ type: 'mcp_analytics' }}
actions={
<>
+ <FeedbackSurveyButton
+ surveyId={MCP_ANALYTICS_FEEDBACK_SURVEY_ID}
+ properties={{
+ feedback_surface: 'mcp_analytics',
+ mcp_analytics_tab: activeTab,
+ }}
+ data-attr="mcp-analytics-feedback-button"
+ />
{onboardingState === 'onboarded' && (
<LemonButton
type="secondary"