: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): store desktop feedback type (#103911)
Dylan Martin62a71dd196e3
diff --git a/products/desktop/docs/FEEDBACK.md b/products/desktop/docs/FEEDBACK.mdindex 2303dd05b120..d5035d900ec4 100644--- a/products/desktop/docs/FEEDBACK.md+++ b/products/desktop/docs/FEEDBACK.md@@ -5,6 +5,8 @@ In the form, press `Cmd+Enter` or `Ctrl+Enter` to send feedback.The form sends one authenticated request to the Desktop feedback endpoint. The endpoint records the response in the Desktop feedback survey only after it accepts the full submission. Each response includes the current view, app version, session, and related task or folder ID when available.+The endpoint accepts an optional `feedback_type`: `bug`, `feature`, or `general`. The survey event stores this value. Older app versions can omit this field.+The app captures the current window before the form opens. The screenshot can be reviewed and stays off until selected. People can also attach up to two images. Recent app logs can be reviewed while they stay off, and are sent only when selected.Selected screenshots and images are stored in PostHog's internal media project, not the project selected in Desktop. The survey response contains authenticated image links instead of image data. Only people with access to the internal feedback project can open them, and the public media route returns `404`. Links stop working after 30 days, and a daily cleanup removes the stored media. If the response fails, the endpoint removes the new media. The feedback modal is excluded from Session Replay, so previews and logs do not enter the recording.diff --git a/products/surveys/backend/api/test/test_desktop_feedback.py b/products/surveys/backend/api/test/test_desktop_feedback.pyindex 4b225e1fcac7..f2ab88f79662 100644--- a/products/surveys/backend/api/test/test_desktop_feedback.py+++ b/products/surveys/backend/api/test/test_desktop_feedback.py@@ -9,6 +9,7 @@ from django.core.files.uploadedfile import SimpleUploadedFilefrom django.test import override_settingsfrom django.utils import timezone+from parameterized import parameterizedfrom PIL import Imagefrom rest_framework import status@@ -55,6 +56,7 @@ class TestDesktopFeedback(APIBaseTest):"response": "The page did not load","source": "Generic (Leave feedback button)","feedback_view": "task-detail",+ "feedback_type": "bug","feedback_task_id": "task-123","feedback_app_logs": "[info] Example log","app_version": "1.2.3",@@ -65,6 +67,7 @@ class TestDesktopFeedback(APIBaseTest):)assert response.status_code == status.HTTP_201_CREATED, response.json()+ assert client.capture.call_args.kwargs["properties"]["feedback_type"] == "bug"assert response.json() == {"accepted": True,"response_id": "00000000-0000-0000-0000-000000000001",@@ -212,9 +215,10 @@ class TestDesktopFeedback(APIBaseTest):assert denied_response.status_code == status.HTTP_403_FORBIDDENassert client.capture.call_count == 1+ @parameterized.expand([("bug",), ("feature",), ("general",), (None,)])@override_settings(CLOUD_DEPLOYMENT="EU")@patch("products.surveys.backend.desktop_feedback.get_client")- def test_captures_feedback_in_the_instance_region(self, get_client) -> None:+ def test_captures_feedback_in_the_instance_region(self, feedback_type: str | None, get_client) -> None:client = MagicMock()client.capture.return_value = "00000000-0000-0000-0000-000000000001"get_client.return_value = client@@ -225,11 +229,17 @@ class TestDesktopFeedback(APIBaseTest):"response": "The page did not load","source": "Generic (Leave feedback button)","feedback_view": "task-detail",+ **({"feedback_type": feedback_type} if feedback_type else {}),},format="multipart",)assert response.status_code == status.HTTP_201_CREATED, response.json()+ properties = client.capture.call_args.kwargs["properties"]+ if feedback_type:+ assert properties["feedback_type"] == feedback_type+ else:+ assert "feedback_type" not in propertiesget_client.assert_called_once_with("EU",sync_mode=True,@@ -238,6 +248,23 @@ class TestDesktopFeedback(APIBaseTest):max_retries=2,)+ @patch("products.surveys.backend.desktop_feedback.get_client")+ def test_rejects_unknown_feedback_type(self, get_client) -> None:+ response = self.client.post(+ f"/api/projects/{self.team.id}/desktop_feedback/",+ {+ "response": "Example feedback",+ "source": "Generic (Leave feedback button)",+ "feedback_view": "home",+ "feedback_type": "unknown",+ },+ format="multipart",+ )++ assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()+ assert response.json()["attr"] == "feedback_type"+ get_client.assert_not_called()+@patch("products.surveys.backend.desktop_feedback.object_storage.delete")@patch("posthog.models.uploaded_media.object_storage.write")@patch("products.surveys.backend.desktop_feedback.get_client")diff --git a/products/surveys/backend/desktop_feedback.py b/products/surveys/backend/desktop_feedback.pyindex 1c180b3be5f0..6a7ae32ddd9e 100644--- a/products/surveys/backend/desktop_feedback.py+++ b/products/surveys/backend/desktop_feedback.py@@ -198,6 +198,7 @@ def submit_desktop_feedback(**media_properties,}optional_properties = {+ "feedback_type": data.get("feedback_type"),"feedback_task_id": data.get("feedback_task_id"),"feedback_folder_id": data.get("feedback_folder_id"),"feedback_app_logs": data.get("feedback_app_logs"),diff --git a/products/surveys/backend/presentation/desktop_feedback.py b/products/surveys/backend/presentation/desktop_feedback.pyindex 0aaabf8a8f0e..b45b07db52e0 100644--- a/products/surveys/backend/presentation/desktop_feedback.py+++ b/products/surveys/backend/presentation/desktop_feedback.py@@ -38,6 +38,12 @@ class DesktopFeedbackSource(models.TextChoices):POSTHOG_WEB = "Visiting PostHog web"+class DesktopFeedbackType(models.TextChoices):+ BUG = "bug", "Bug"+ FEATURE = "feature", "Feature"+ GENERAL = "general", "General"++class DesktopFeedbackServiceUnavailable(APIException):status_code = status.HTTP_503_SERVICE_UNAVAILABLEdefault_detail = "Could not send feedback. Please try again."@@ -81,6 +87,11 @@ class DesktopFeedbackRequestSerializer(serializers.Serializer):max_length=100,help_text="Desktop view that was active when the feedback form opened.",)+ feedback_type = serializers.ChoiceField(+ choices=DesktopFeedbackType.choices,+ required=False,+ help_text="Feedback type selected by the user: bug, feature, or general.",+ )feedback_task_id = serializers.CharField(required=False,max_length=100,diff --git a/products/surveys/frontend/generated/api.schemas.ts b/products/surveys/frontend/generated/api.schemas.tsindex 76d779f99769..782e2390b5d5 100644--- a/products/surveys/frontend/generated/api.schemas.ts+++ b/products/surveys/frontend/generated/api.schemas.ts@@ -19,6 +19,19 @@ export const DesktopFeedbackSourceEnumApi = {VisitingPostHogWeb: 'Visiting PostHog web',} as const+/**+ * * `bug` - Bug+ * * `feature` - Feature+ * * `general` - General+ */+export type DesktopFeedbackTypeEnumApi = (typeof DesktopFeedbackTypeEnumApi)[keyof typeof DesktopFeedbackTypeEnumApi]++export const DesktopFeedbackTypeEnumApi = {+ Bug: 'bug',+ Feature: 'feature',+ General: 'general',+} as const+export interface DesktopFeedbackRequestApi {/*** Feedback text entered by the user.@@ -35,6 +48,12 @@ export interface DesktopFeedbackRequestApi {* @maxLength 100*/feedback_view: string+ /** Feedback type selected by the user: bug, feature, or general.+ *+ * * `bug` - Bug+ * * `feature` - Feature+ * * `general` - General */+ feedback_type?: DesktopFeedbackTypeEnumApi/*** Task that was active when the feedback form opened.* @maxLength 100diff --git a/products/surveys/frontend/generated/api.ts b/products/surveys/frontend/generated/api.tsindex 14bead08d68f..9631780b776c 100644--- a/products/surveys/frontend/generated/api.ts+++ b/products/surveys/frontend/generated/api.ts@@ -64,6 +64,9 @@ export const desktopFeedbackCreate = async (formData.append(`response`, desktopFeedbackRequestApi.response)formData.append(`source`, desktopFeedbackRequestApi.source)formData.append(`feedback_view`, desktopFeedbackRequestApi.feedback_view)+ if (desktopFeedbackRequestApi.feedback_type !== undefined) {+ formData.append(`feedback_type`, desktopFeedbackRequestApi.feedback_type)+ }if (desktopFeedbackRequestApi.feedback_task_id !== undefined) {formData.append(`feedback_task_id`, desktopFeedbackRequestApi.feedback_task_id)}diff --git a/products/surveys/frontend/generated/api.zod.ts b/products/surveys/frontend/generated/api.zod.tsindex 9bd0a3068e4f..37d510d92c9d 100644--- a/products/surveys/frontend/generated/api.zod.ts+++ b/products/surveys/frontend/generated/api.zod.ts@@ -37,6 +37,13 @@ export const DesktopFeedbackCreateBody = /* @__PURE__ */ zod.object({.string().max(desktopFeedbackCreateBodyFeedbackViewMax).describe('Desktop view that was active when the feedback form opened.'),+ feedback_type: zod+ .enum(['bug', 'feature', 'general'])+ .describe('\* `bug` - Bug\n\* `feature` - Feature\n\* `general` - General')+ .optional()+ .describe(+ 'Feedback type selected by the user: bug, feature, or general.\n\n\* `bug` - Bug\n\* `feature` - Feature\n\* `general` - General'+ ),feedback_task_id: zod.string().max(desktopFeedbackCreateBodyFeedbackTaskIdMax)diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 98e28f9f0275..44424be3ab4d 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -30386,6 +30386,20 @@ export namespace Schemas {VisitingPostHogWeb: 'Visiting PostHog web',} as const;+ /**+ * * `bug` - Bug+ * * `feature` - Feature+ * * `general` - General+ */+ export type DesktopFeedbackTypeEnum = typeof DesktopFeedbackTypeEnum[keyof typeof DesktopFeedbackTypeEnum];+++ export const DesktopFeedbackTypeEnum = {+ Bug: 'bug',+ Feature: 'feature',+ General: 'general',+ } as const;+export interface DesktopFeedbackRequest {/*** Feedback text entered by the user.@@ -30402,6 +30416,12 @@ export namespace Schemas {* @maxLength 100*/feedback_view: string;+ /** Feedback type selected by the user: bug, feature, or general.+ *+ * * `bug` - Bug+ * * `feature` - Feature+ * * `general` - General */+ feedback_type?: DesktopFeedbackTypeEnum;/*** Task that was active when the feedback form opened.* @maxLength 100