: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(inbox): swap report copy-link button for feedback (#72555)
Andrew Maguire1f6e8a60766f
diff --git a/frontend/src/scenes/inbox/components/detail/ReportDetail.tsx b/frontend/src/scenes/inbox/components/detail/ReportDetail.tsxindex 28767c833f3a..7b9dd1094761 100644--- a/frontend/src/scenes/inbox/components/detail/ReportDetail.tsx+++ b/frontend/src/scenes/inbox/components/detail/ReportDetail.tsx@@ -5,12 +5,10 @@ import { IconArrowLeft, IconDocument, IconEllipsis, IconExternal, IconPullRequesimport { LemonButton, LemonTabs, Tooltip } from '@posthog/lemon-ui'import { TZLabel } from 'lib/components/TZLabel'-import { IconLink } from 'lib/lemon-ui/icons'import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'import { LemonMenu, LemonMenuItem } from 'lib/lemon-ui/LemonMenu'import { ScoutLink } from 'lib/signals/ScoutLink'import { scoutDisplayName } from 'lib/signals/signalCardSourceLine'-import { copyToClipboard } from 'lib/utils/copyToClipboard'import { addProjectIdIfMissing } from 'lib/utils/kea-router'import { SignalNode } from 'scenes/debug/signals/types'import { urls } from 'scenes/urls'@@ -40,7 +38,7 @@ import { DetailSection } from './DetailSection'import { DiscussReportButton } from './DiscussReportButton'import { PullRequestBranchTag, PullRequestDiffPanel } from './PullRequestDiffPanel'import { ReportActivitySection } from './ReportActivitySection'-import { ReportDetailAction, useReportDetailActions } from './ReportDetailActions'+import { useReportDetailActions } from './ReportDetailActions'import { ReportTasksSection } from './ReportTasksSection'import { SuggestedReviewersSection } from './SuggestedReviewersSection'@@ -247,7 +245,7 @@ export function ReportDetailSkeleton(): JSX.Element {interface InboxDetailFrameProps {report: SignalReport- /** Active inbox tab — drives the copy-link target in the merged header. */+ /** Active inbox tab — drives the back link and the report URL seeded into Discuss. */tab: InboxTabKey/** Summary section heading icon + title. */summary: { icon: ReactNode; title: string }@@ -263,7 +261,7 @@ interface InboxDetailFrameProps {/*** Shared chrome for the Report and Pull request detail bodies. Owns the full page header- * (title, copy link) merged with the badges/meta/actions, then summary on the left+ * (title) merged with the badges/meta/actions, then summary on the left* and supporting sections (Evidence, Runs, Reviewers) on the right. Mirrors desktop* `InboxDetailFrame`. AgentRunDetail keeps its own layout + shell header.*/@@ -291,23 +289,13 @@ export function InboxDetailFrame({const conventionalTitle = parseConventionalCommitTitle(report.title)const displayTitle = displayConventionalCommitTitle(report.title, 'Untitled report')- // Absolute URL to this report – used for the copy-link action and seeded into the Discuss prompt- // so the agent can open and read the report directly.+ // Absolute URL to this report – seeded into the Discuss prompt so the agent can open and read+ // the report directly.const reportUrl = `${window.location.origin}${addProjectIdIfMissing(urls.inboxReport(tab, report.id))}`// Secondary actions as data so the same set renders inline as buttons on wide layouts and as a// standard `LemonMenu` on narrow ones; the primary action stays inline either way.- const detailActions = useReportDetailActions(report)- const reportActions: ReportDetailAction[] = [- {- key: 'copy-link',- label: 'Copy link',- icon: <IconLink />,- tooltip: 'Copy a link to this report',- onClick: () => void copyToClipboard(reportUrl, 'report link'),- },- ...detailActions,- ]+ const reportActions = useReportDetailActions(report)const overflowMenuItems: LemonMenuItem[] = reportActions.map((action) => ({label: action.label,icon: action.icon,diff --git a/frontend/src/scenes/inbox/components/detail/ReportDetailActions.tsx b/frontend/src/scenes/inbox/components/detail/ReportDetailActions.tsxindex bbd955615b57..d75e7d6df2bc 100644--- a/frontend/src/scenes/inbox/components/detail/ReportDetailActions.tsx+++ b/frontend/src/scenes/inbox/components/detail/ReportDetailActions.tsx@@ -2,13 +2,13 @@ import { useActions, useValues } from 'kea'import { router } from 'kea-router'import { type MouseEvent, useState } from 'react'-import { IconArchive, IconPullRequest, IconReceipt, IconUndo } from '@posthog/icons'+import { IconArchive, IconMessage, IconPullRequest, IconReceipt, IconUndo } from '@posthog/icons'import { lemonToast } from '@posthog/lemon-ui'import api from 'lib/api'import { urls } from 'scenes/urls'-import { captureInboxReportAction } from '../../inboxAnalytics'+import { captureInboxReportAction, captureInboxReportFeedback } from '../../inboxAnalytics'import { inboxSceneLogic } from '../../inboxSceneLogic'import { inboxTaskKickoffLogic } from '../../inboxTaskKickoffLogic'import { inboxBulkActionsLogic } from '../../logics/inboxBulkActionsLogic'@@ -16,6 +16,7 @@ import { INBOX_FLAT_TAB_LIST_PARAMS, reportListLogic } from '../../logics/reportimport { ACTIONABLE_ACTIONABILITY_VALUES, SignalReport, SignalReportStatus } from '../../types'import { useReportArchive } from '../cards/useReportArchive'import { useReportRefund } from '../cards/useReportRefund'+import { openFeedbackReportDialog } from '../shell/FeedbackReportDialog'/*** One detail-pane action, rendered either inline as a `LemonButton` (wide layouts) or as a@@ -54,10 +55,10 @@ function canCreateImplementationPr(report: SignalReport): boolean {}/**- * Detail-pane actions as data: Archive/Restore and Create PR. Discuss is rendered separately as a- * standalone dropdown button (`DiscussReportButton`) since it opens a question popover rather than- * firing on click. Task creation is owned by `inboxTaskKickoffLogic`; archiving reuses the shared- * `useReportArchive` dialog flow. Callers render these inline or inside a menu.+ * Detail-pane actions as data: Feedback (always), Archive/Restore, and Create PR. Discuss is+ * rendered separately as a standalone dropdown button (`DiscussReportButton`) since it opens a+ * question popover rather than firing on click. Task creation is owned by `inboxTaskKickoffLogic`;+ * archiving reuses the shared `useReportArchive` dialog flow. Callers render these inline or inside a menu.*/export function useReportDetailActions(report: SignalReport): ReportDetailAction[] {const { isCreatingPr } = useValues(inboxTaskKickoffLogic)@@ -143,11 +144,28 @@ export function useReportDetailActions(report: SignalReport): ReportDetailAction}}- // A resolved report is terminal – its PR already merged, so only Discuss (rendered separately)- // and Refund apply. The PR can still be refunded (auto-approved by design; the weekly review+ // Feedback is always available – it never changes the report's state, just records what the+ // user thinks of it (and its PR), so it stays even for resolved/archived reports.+ const feedback: ReportDetailAction = {+ key: 'feedback',+ label: 'Feedback',+ icon: <IconMessage />,+ tooltip: 'Tell us how useful this report was',+ onClick: () =>+ openFeedbackReportDialog({+ reportTitle: report.title ?? 'Untitled report',+ onConfirm: ({ sentiment, note }) => {+ captureInboxReportFeedback({ report, sentiment, note, surface: 'detail_pane' })+ lemonToast.success('Thanks for the feedback')+ },+ }),+ }++ // A resolved report is terminal – its PR already merged, so only feedback and Discuss (rendered+ // separately) apply. The PR can still be refunded (auto-approved by design; the weekly review// watches refunded-then-merged).if (isResolved) {- return canRefund ? [refund] : []+ return [feedback, ...(canRefund ? [refund] : [])]}// An already-archived report offers Restore instead of Archive (and no Create PR). A refunded@@ -155,6 +173,7 @@ export function useReportDetailActions(report: SignalReport): ReportDetailAction// archived-but-still-charged report can still be refunded.if (isArchived) {return [+ feedback,...(canRefund ? [refund] : []),...(report.refund? []@@ -172,6 +191,7 @@ export function useReportDetailActions(report: SignalReport): ReportDetailAction}const actions: ReportDetailAction[] = [+ feedback,{key: 'archive',label: 'Archive',diff --git a/frontend/src/scenes/inbox/components/shell/FeedbackReportDialog.tsx b/frontend/src/scenes/inbox/components/shell/FeedbackReportDialog.tsxnew file mode 100644index 000000000000..d342ff33d572--- /dev/null+++ b/frontend/src/scenes/inbox/components/shell/FeedbackReportDialog.tsx@@ -0,0 +1,89 @@+import { IconThumbsDown, IconThumbsUp } from '@posthog/icons'++import { LemonDialog } from 'lib/lemon-ui/LemonDialog'+import { LemonField } from 'lib/lemon-ui/LemonField'+import { LemonRadio, LemonRadioOption } from 'lib/lemon-ui/LemonRadio'+import { LemonTextArea } from 'lib/lemon-ui/LemonTextArea'++import { InboxReportFeedbackSentiment } from '../../inboxAnalytics'++// Matches the note cap on the sibling inbox dialogs (Dismiss, Refund, Discuss); the note rides+// along as an analytics property, so keep it under the client's per-property limit.+const FEEDBACK_NOTE_MAX_LENGTH = 4000++export interface FeedbackReportDialogResult {+ sentiment: InboxReportFeedbackSentiment+ note: string+}++interface OpenFeedbackReportDialogParams {+ /** Report title for the dialog copy. */+ reportTitle?: string | null+ /** Called with the chosen sentiment + note once the user submits. */+ onConfirm: (result: FeedbackReportDialogResult) => void | Promise<void>+}++const SENTIMENT_RADIO_OPTIONS: LemonRadioOption<InboxReportFeedbackSentiment>[] = [+ {+ value: 'positive',+ label: (+ <span className="inline-flex items-center gap-1.5">+ <IconThumbsUp className="shrink-0 text-success" />+ Helpful+ </span>+ ),+ },+ {+ value: 'negative',+ label: (+ <span className="inline-flex items-center gap-1.5">+ <IconThumbsDown className="shrink-0 text-danger" />+ Not helpful+ </span>+ ),+ },+]++/**+ * Opens the report feedback dialog: pick a thumbs sentiment plus an optional note, then submit.+ * Feedback-only — the report stays in the inbox (unlike {@link openDismissReportDialog}). The+ * caller wires `onConfirm` to fire the `Inbox report feedback` analytics event.+ */+export function openFeedbackReportDialog({ reportTitle, onConfirm }: OpenFeedbackReportDialogParams): void {+ LemonDialog.openForm({+ title: `Feedback on "${reportTitle?.trim() ? reportTitle : 'Untitled report'}"`,+ description:+ 'Tell us how useful this report was. Your feedback helps the agent improve – it does not archive the report.',+ maxWidth: '30rem',+ initialValues: { sentiment: null as InboxReportFeedbackSentiment | null, note: '' },+ content: (+ <div className="flex flex-col gap-3">+ <LemonField name="sentiment" label="How useful was this?">+ {({ value, onChange }) => (+ <LemonRadio value={value} onChange={onChange} options={SENTIMENT_RADIO_OPTIONS} />+ )}+ </LemonField>+ <LemonField name="note" label="Anything to add?" info="Optional – helps the agent learn">+ <LemonTextArea+ placeholder="Optional: what was useful or off?"+ maxLength={FEEDBACK_NOTE_MAX_LENGTH}+ rows={4}+ // Keep Enter for newlines – without this it bubbles to the dialog's submit-on-Enter handler.+ stopPropagation+ />+ </LemonField>+ </div>+ ),+ errors: {+ sentiment: (sentiment) => (!sentiment ? "You haven't picked a rating" : undefined),+ },+ primaryButtonProps: { children: 'Send feedback' },+ shouldAwaitSubmit: true,+ onSubmit: async ({ sentiment, note }) => {+ if (!sentiment) {+ return+ }+ await onConfirm({ sentiment, note: (note ?? '').trim() })+ },+ })+}diff --git a/frontend/src/scenes/inbox/inboxAnalytics.ts b/frontend/src/scenes/inbox/inboxAnalytics.tsindex 3189f0c76163..6e77f52bde4d 100644--- a/frontend/src/scenes/inbox/inboxAnalytics.ts+++ b/frontend/src/scenes/inbox/inboxAnalytics.ts@@ -18,6 +18,7 @@ export const INBOX_EVENTS = {REPORT_OPENED: 'Inbox report opened',REPORT_CLOSED: 'Inbox report closed',REPORT_ACTION: 'Inbox report action',+ REPORT_FEEDBACK: 'Inbox report feedback',SOURCE_CONNECTED: 'Signal source connected',SOURCE_INTEREST: 'signals source interest',} as const@@ -33,6 +34,9 @@ export type InboxReportOpenMethod = 'click' | 'deeplink' | 'unknown'/** How a report detail was closed. */export type InboxReportCloseMethod = 'next_report' | 'deselected' | 'unmount'+/** Sentiment captured by the report feedback button. */+export type InboxReportFeedbackSentiment = 'positive' | 'negative'+/*** Report actions cloud actually emits. Names match the desktop enum one-for-one (so the* `action_type` breakdown reads the same across clients), plus a cloud-only `restore` for the@@ -70,8 +74,8 @@ interface BaseReportProperties {/*** Identity + classification for a report. Kept to opaque ids, enums, ages, and counts — it never* includes the agent-generated report title, which can echo proprietary detail from a customer's- * own data. A user-authored dismissal reason note is a different case: it is the actionable signal- * we want, so the relevant capture call attaches it explicitly.+ * own data. User-authored notes (a dismissal reason note, feedback note) are a different case: they+ * are the actionable signal we want, so the relevant capture calls attach them explicitly.*/function baseReportProperties(report: SignalReport): BaseReportProperties {return {@@ -226,6 +230,26 @@ export function captureInboxReportAction(params: {})}+/**+ * Free-form feedback on a single report, fired from the detail pane's feedback button. Unlike a+ * dismiss, this is feedback-only: the report stays in the inbox. Carries the thumbs sentiment plus+ * the optional note text so we can read what people actually think of a report (and its PR).+ */+export function captureInboxReportFeedback(params: {+ report: SignalReport+ sentiment: InboxReportFeedbackSentiment+ note: string+ surface: InboxReportActionSurface+}): void {+ captureInboxEvent(INBOX_EVENTS.REPORT_FEEDBACK, {+ ...baseReportProperties(params.report),+ sentiment: params.sentiment,+ has_pr: !!params.report.implementation_pr_url,+ ...(params.note ? { note: params.note } : {}),+ surface: params.surface,+ })+}+export function captureSignalSourceConnected(params: {sourceProduct: stringsourceType: string