Repository navigation
fix(desktop): capture inbox feedback notes #103900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| import { ANALYTICS_EVENTS } from "@posthog/shared"; | ||
| import type { SignalReport } from "@posthog/shared/types"; | ||
| import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; | ||
| import { act, renderHook } from "@testing-library/react"; | ||
| import type { ReactNode } from "react"; | ||
| import { beforeEach, describe, expect, it, vi } from "vitest"; | ||
|
|
||
| const mocks = vi.hoisted(() => ({ | ||
| refundSignalReport: vi.fn(), | ||
| track: vi.fn(), | ||
| success: vi.fn(), | ||
| error: vi.fn(), | ||
| })); | ||
|
|
||
| vi.mock("@posthog/ui/features/auth/authClient", () => ({ | ||
| useAuthenticatedClient: () => ({ | ||
| refundSignalReport: mocks.refundSignalReport, | ||
| }), | ||
| })); | ||
|
|
||
| vi.mock("@posthog/ui/features/feature-flags/useFeatureFlag", () => ({ | ||
| useFeatureFlag: () => true, | ||
| })); | ||
|
|
||
| vi.mock("@posthog/ui/shell/analytics", () => ({ track: mocks.track })); | ||
|
|
||
| vi.mock("@posthog/ui/primitives/toast", () => ({ | ||
| toast: { success: mocks.success, error: mocks.error }, | ||
| })); | ||
|
|
||
| import { useRefundReport } from "./useRefundReport"; | ||
|
|
||
| const report: SignalReport = { | ||
| id: "report-1", | ||
| title: "Report one", | ||
| summary: "Summary", | ||
| status: "ready", | ||
| total_weight: 1, | ||
| signal_count: 1, | ||
| artefact_count: 0, | ||
| created_at: "2026-08-20T09:00:00Z", | ||
| updated_at: "2026-08-20T09:00:00Z", | ||
| implementation_pr_url: "https://github.com/PostHog/posthog/pull/1", | ||
| }; | ||
|
|
||
| function createWrapper() { | ||
| const queryClient = new QueryClient({ | ||
| defaultOptions: { mutations: { retry: false } }, | ||
| }); | ||
| return function Wrapper({ children }: { children: ReactNode }) { | ||
| return ( | ||
| <QueryClientProvider client={queryClient}>{children}</QueryClientProvider> | ||
| ); | ||
| }; | ||
| } | ||
|
|
||
| describe("useRefundReport", () => { | ||
| beforeEach(() => { | ||
| vi.clearAllMocks(); | ||
| mocks.refundSignalReport.mockResolvedValue({ | ||
| ...report, | ||
| status: "suppressed", | ||
| }); | ||
| }); | ||
|
|
||
| it("tracks the refund reason and note after a successful refund", async () => { | ||
| const { result } = renderHook(() => useRefundReport(report), { | ||
| wrapper: createWrapper(), | ||
| }); | ||
|
|
||
| await act(async () => { | ||
| await result.current.mutation.mutateAsync({ | ||
| reason: "pr_incorrect", | ||
| note: "The proposed change did not fix the issue", | ||
| }); | ||
| }); | ||
|
|
||
| expect(mocks.track).toHaveBeenCalledWith( | ||
| ANALYTICS_EVENTS.INBOX_REPORT_ACTION, | ||
| expect.objectContaining({ | ||
| report_id: report.id, | ||
| action_type: "refund", | ||
| refund_reason: "pr_incorrect", | ||
| refund_note: "The proposed change did not fix the issue", | ||
| }), | ||
| ); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,6 @@ import type { SignalReport } from "@posthog/shared/types"; | |
| import { track } from "@posthog/ui/shell/analytics"; | ||
| import { useCallback, useMemo } from "react"; | ||
|
|
||
| /** Input bound; analytics captures only the note length, never its contents. */ | ||
| export const FEEDBACK_NOTE_MAX_LENGTH = 4000; | ||
|
|
||
| /** | ||
|
|
@@ -46,7 +45,7 @@ export function useReportFeedbackTracker( | |
| track(ANALYTICS_EVENTS.INBOX_REPORT_FEEDBACK_NOTE, { | ||
| ...base, | ||
| sentiment, | ||
| note_length: text.length, | ||
| note: text, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Medium: Sensitive note contents enter telemetry A user can now send arbitrary sensitive text into the shared analytics project by entering it in a feedback note. The same raw-text sink is added for dismissal notes in |
||
| }); | ||
| }, | ||
| [base], | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change replaces a privacy-preserving
note_length: numberfield with the rawnote: textcontent in theINBOX_REPORT_FEEDBACK_NOTEevent, and addsdismissal_note/refund_notefree-text fields toINBOX_REPORT_ACTION. These notes are free-form text typed by desktop reviewers about customer reports (support/PR review context) and up to 4000 characters (FEEDBACK_NOTE_MAX_LENGTH), so they can contain customer PII, account details, or other sensitive business data. The removed comment atproducts/desktop/packages/ui/src/features/inbox/hooks/useReportFeedbackTracker.tspreviously stated explicitly: "analytics captures only the note length, never its contents" — that safeguard is now gone with no redaction, scrubbing, or consent gate before the text is forwarded to the analytics pipeline (track(...)→ PostHog capture, which may be replicated to data warehouses/third parties and viewed by a much broader audience than the original reviewer note).Concretely:
products/desktop/packages/ui/src/features/inbox/hooks/useReportFeedbackTracker.ts:46-50sendsnote: textverbatim;products/desktop/packages/ui/src/features/inbox/hooks/useRefundReport.ts:34-37sendsrefund_note: input.note;products/desktop/packages/core/src/inbox/engagement.ts:105-107propagatesdismissal_note. None of these paths apply any sanitization/redaction before the text leaves the client into the analytics event stream. Recommend either reverting to length/hash-only capture, or explicitly classifying these fields as free-text/PII in the analytics pipeline and gating their storage/visibility (e.g., excluding from broadly-replicated warehouses, redacting known PII patterns) before shipping this contract change.Severity: medium | Confidence: 55% | React with 👍 if useful or 👎 if not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was by design
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood — since capturing the full note text is the intentional purpose of this PR (per the description: "Desktop feedback events now capture the full reviewer note"), I'll treat this as accepted/by design rather than a defect to fix in this PR. I'd still flag for the team, outside of this review, that these notes are free text potentially containing customer PII or sensitive business details, so it's worth confirming the analytics pipeline's data handling/retention policy accounts for that (e.g., PII scrubbing rules, warehouse replication scope) rather than treating it as opaque length-only telemetry going forward. No further action needed from me here.