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.

fix(desktop): capture inbox feedback notes (#103900)

Dylan Martin85b30fd7e688
diff --git a/products/desktop/packages/core/src/inbox/engagement.test.ts b/products/desktop/packages/core/src/inbox/engagement.test.ts
index d6a31aaea218..9be0716d252c 100644
--- a/products/desktop/packages/core/src/inbox/engagement.test.ts
+++ b/products/desktop/packages/core/src/inbox/engagement.test.ts
@@ -83,23 +83,26 @@ describe("buildBulkActionEvents", () => {
expect(events.every((e) => e.dismissal_reason === undefined)).toBe(true);
});
- it("attaches only the dismissal category for dismiss", () => {
+ it("attaches dismissal feedback only to dismiss actions", () => {
const [dismissed] = buildBulkActionEvents({
reports: [fakeReport({ id: "a" })],
actionType: "dismiss",
surface: "toolbar",
dismissalReason: "not_relevant",
+ dismissalNote: "Wrong project",
});
expect(dismissed.dismissal_reason).toBe("not_relevant");
- expect(dismissed).not.toHaveProperty("dismissal_note");
+ expect(dismissed.dismissal_note).toBe("Wrong project");
const [snoozed] = buildBulkActionEvents({
reports: [fakeReport({ id: "a" })],
actionType: "snooze",
surface: "toolbar",
dismissalReason: "not_relevant",
+ dismissalNote: "Wrong project",
});
expect(snoozed.dismissal_reason).toBeUndefined();
+ expect(snoozed.dismissal_note).toBeUndefined();
});
});
diff --git a/products/desktop/packages/core/src/inbox/engagement.ts b/products/desktop/packages/core/src/inbox/engagement.ts
index 0c8ef96f2caa..74c92897f95d 100644
--- a/products/desktop/packages/core/src/inbox/engagement.ts
+++ b/products/desktop/packages/core/src/inbox/engagement.ts
@@ -62,6 +62,7 @@ export interface BuildBulkActionEventsInput {
bulkSize?: number;
/** Dismissal category, only meaningful for `dismiss`. */
dismissalReason?: string;
+ dismissalNote?: string;
}
/**
@@ -76,7 +77,14 @@ export interface BuildBulkActionEventsInput {
export function buildBulkActionEvents(
input: BuildBulkActionEventsInput,
): InboxReportActionProperties[] {
- const { reports, actionType, surface, triageId, dismissalReason } = input;
+ const {
+ reports,
+ actionType,
+ surface,
+ triageId,
+ dismissalReason,
+ dismissalNote,
+ } = input;
const bulkSize = input.bulkSize ?? reports.length;
const isBulk = bulkSize > 1;
return reports.map((report) => ({
@@ -94,6 +102,9 @@ export function buildBulkActionEvents(
...(actionType === "dismiss" && dismissalReason
? { dismissal_reason: dismissalReason }
: {}),
+ ...(actionType === "dismiss" && dismissalNote
+ ? { dismissal_note: dismissalNote }
+ : {}),
}));
}
diff --git a/products/desktop/packages/shared/src/analytics-events.ts b/products/desktop/packages/shared/src/analytics-events.ts
index ef039ea5e163..0017660dbae2 100644
--- a/products/desktop/packages/shared/src/analytics-events.ts
+++ b/products/desktop/packages/shared/src/analytics-events.ts
@@ -778,6 +778,7 @@ export type InboxReportActionType =
| "reingest"
| "implement"
| "create_pr"
+ | "refund"
| "open_pr"
| "open_task"
| "copy_link"
@@ -937,6 +938,9 @@ export interface InboxReportActionProperties {
list_size: number;
triage_id?: string;
dismissal_reason?: string;
+ dismissal_note?: string;
+ refund_reason?: string;
+ refund_note?: string;
signal_id?: string;
signal_source_product?: string;
signal_source_type?: string;
@@ -984,7 +988,7 @@ export interface InboxReportFeedbackProperties {
}
/**
- * Optional note metadata, offered only once a rating is already recorded. It
+ * Optional note, offered only once a rating is already recorded. It
* rides on its own event rather than re-firing {@link InboxReportFeedbackProperties}
* so sentiment stays exactly one event per rating; join back to the rating on
* `report_id`. Carries `sentiment` too so a note can be read without that join.
@@ -997,7 +1001,7 @@ export interface InboxReportFeedbackNoteProperties {
sentiment: InboxReportFeedbackSentiment;
has_pr: boolean;
surface: InboxReportActionSurface;
- note_length: number;
+ note: string;
}
// Scout events
diff --git a/products/desktop/packages/ui/src/features/inbox/components/detail/ReportFeedbackFooter.test.tsx b/products/desktop/packages/ui/src/features/inbox/components/detail/ReportFeedbackFooter.test.tsx
index a8639af6cac5..f1d15eaaff83 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/detail/ReportFeedbackFooter.test.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/detail/ReportFeedbackFooter.test.tsx
@@ -96,7 +96,7 @@ describe("ReportFeedbackFooter", () => {
sentiment: "negative",
has_pr: false,
surface: "detail_footer",
- note_length: 11,
+ note: "some detail",
},
);
expect(screen.getByText("Note added")).toBeInTheDocument();
diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxBulkActions.ts b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxBulkActions.ts
index 3dc864a738d2..e654182c406f 100644
--- a/products/desktop/packages/ui/src/features/inbox/hooks/useInboxBulkActions.ts
+++ b/products/desktop/packages/ui/src/features/inbox/hooks/useInboxBulkActions.ts
@@ -289,6 +289,7 @@ export function useInboxBulkActions(
triageId,
bulkSize: result.totalCount,
dismissalReason: dismissal?.reason,
+ dismissalNote: dismissal?.note,
});
for (const event of events) {
track(ANALYTICS_EVENTS.INBOX_REPORT_ACTION, event);
diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/useRefundReport.test.tsx b/products/desktop/packages/ui/src/features/inbox/hooks/useRefundReport.test.tsx
new file mode 100644
index 000000000000..ac3c7be8dd37
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/inbox/hooks/useRefundReport.test.tsx
@@ -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",
+ }),
+ );
+ });
+});
diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/useRefundReport.ts b/products/desktop/packages/ui/src/features/inbox/hooks/useRefundReport.ts
index 2e281a9238eb..5baa51a8852f 100644
--- a/products/desktop/packages/ui/src/features/inbox/hooks/useRefundReport.ts
+++ b/products/desktop/packages/ui/src/features/inbox/hooks/useRefundReport.ts
@@ -7,6 +7,7 @@ import type {
} from "@posthog/shared/types";
import { useAuthenticatedClient } from "@posthog/ui/features/auth/authClient";
import { useFeatureFlag } from "@posthog/ui/features/feature-flags/useFeatureFlag";
+import { useReportActionTracker } from "@posthog/ui/features/inbox/hooks/useReportActionTracker";
import { toast } from "@posthog/ui/primitives/toast";
import { useMutation, useQueryClient } from "@tanstack/react-query";
@@ -20,6 +21,7 @@ export function useRefundReport(report: SignalReport) {
const client = useAuthenticatedClient();
const queryClient = useQueryClient();
const flagEnabled = useFeatureFlag(SIGNALS_PR_REFUNDS_FLAG);
+ const trackAction = useReportActionTracker(report);
const { canRefund, disabledReason } = computeRefundEligibility(
report,
@@ -29,7 +31,11 @@ export function useRefundReport(report: SignalReport) {
const mutation = useMutation({
mutationFn: (input: { reason: SignalReportRefundReason; note?: string }) =>
client.refundSignalReport(report.id, input),
- onSuccess: () => {
+ onSuccess: (_updatedReport, input) => {
+ trackAction("refund", {
+ refund_reason: input.reason,
+ ...(input.note ? { refund_note: input.note } : {}),
+ });
toast.success("PR refunded. The report has been archived.");
queryClient.invalidateQueries({ queryKey: inboxReportKeys.all });
},
diff --git a/products/desktop/packages/ui/src/features/inbox/hooks/useReportFeedbackTracker.ts b/products/desktop/packages/ui/src/features/inbox/hooks/useReportFeedbackTracker.ts
index ee6ce2b94372..8bf78c3fc071 100644
--- a/products/desktop/packages/ui/src/features/inbox/hooks/useReportFeedbackTracker.ts
+++ b/products/desktop/packages/ui/src/features/inbox/hooks/useReportFeedbackTracker.ts
@@ -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,
});
},
[base],