: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(desktop): show report product suggestions in the inbox (#112707)
Rafael Audibert174a4e0a34b7
diff --git a/packages/agent/packages/agent-contracts/src/domain-types.ts b/packages/agent/packages/agent-contracts/src/domain-types.tsindex 77600765c50d..761678cd8476 100644--- a/packages/agent/packages/agent-contracts/src/domain-types.ts+++ b/packages/agent/packages/agent-contracts/src/domain-types.ts@@ -808,6 +808,21 @@ export interface SignalReport {refund_ineligibility_reason?: string | null;/** The space (task channel) this report is assigned to, or null when unassigned. The general view lists every report regardless of this value. */channel_id?: string | null;+ /** A product the team doesn't use that would have given this report better evidence. Set on the detail response only; null in list responses. */+ source_suggestion?: SignalReportSourceSuggestion | null;+}++/** Products a report can suggest turning on. Mirrors `SuggestedSourceProduct` in the signals backend. */+export type SuggestedSourceProduct =+ | "logs"+ | "session_replay"+ | "error_tracking"+ | "llm_analytics";++export interface SignalReportSourceSuggestion {+ product: SuggestedSourceProduct;+ /** One sentence on what the product would have shown for this report. */+ reason: string;}export type SignalReportRefundReason =diff --git a/packages/agent/packages/agent-contracts/src/inbox-types.ts b/packages/agent/packages/agent-contracts/src/inbox-types.tsindex a3b8663e0e78..e87e9f2ed12a 100644--- a/packages/agent/packages/agent-contracts/src/inbox-types.ts+++ b/packages/agent/packages/agent-contracts/src/inbox-types.ts@@ -419,6 +419,7 @@ export type SourceProduct =| "error_tracking"| "health_checks"| "llm_analytics"+ | "logs"| "replay_vision"| "session_replay"| "signals_scout"@@ -430,11 +431,12 @@ export type SourceProduct =* `signals_scout` appears only as a signal origin and is always on. `replay_vision` authorizes* itself through each scanner's own `emits_signals` flag, so there is no config row to toggle.* `session_replay` is retired: the session summarization behind it is gone, and it survives here- * only so reports emitted before that still render their source.+ * only so reports emitted before that still render their source. `logs` signals come from logs+ * alerts, which are configured in the logs product rather than toggled here.*/export type ToggleableSourceProduct = Exclude<SourceProduct,- "signals_scout" | "replay_vision" | "session_replay"+ "signals_scout" | "replay_vision" | "session_replay" | "logs">;/**diff --git a/products/desktop/packages/core/src/inbox/sourceSuggestion.ts b/products/desktop/packages/core/src/inbox/sourceSuggestion.tsnew file mode 100644index 000000000000..135d03434196--- /dev/null+++ b/products/desktop/packages/core/src/inbox/sourceSuggestion.ts@@ -0,0 +1,30 @@+import type { SuggestedSourceProduct } from "@posthog/shared/types";++const SOURCE_SUGGESTION_PRODUCTS: Record<+ SuggestedSourceProduct,+ { path: string; actionLabel: string }+> = {+ logs: { path: "logs", actionLabel: "Set up logs" },+ session_replay: { path: "replay/home", actionLabel: "Set up session replay" },+ error_tracking: {+ path: "error_tracking",+ actionLabel: "Set up error tracking",+ },+ llm_analytics: {+ path: "ai-observability/dashboard",+ actionLabel: "Set up AI observability",+ },+};++/**+ * The project path of the landing page a report's product suggestion links to,+ * and its button label. Null for a product this client doesn't know yet, so a+ * backend that adds one ships before the desktop app learns about it.+ */+export function sourceSuggestionTarget(+ product: string,+): { path: string; actionLabel: string } | null {+ return Object.hasOwn(SOURCE_SUGGESTION_PRODUCTS, product)+ ? SOURCE_SUGGESTION_PRODUCTS[product as SuggestedSourceProduct]+ : null;+}diff --git a/products/desktop/packages/shared/src/analytics-events.ts b/products/desktop/packages/shared/src/analytics-events.tsindex 615891f49fa2..3e40bb1128cc 100644--- a/products/desktop/packages/shared/src/analytics-events.ts+++ b/products/desktop/packages/shared/src/analytics-events.ts@@ -996,6 +996,22 @@ export interface InboxReportActionResultProperties {failure_code?: InboxReportActionFailureCode;}+/**+ * A report's product suggestion was rendered under its evidence, or its link+ * to the product was followed. Mirrors cloud's `Inbox report source+ * suggestion shown` / `clicked`, so the clients are comparable in one PostHog+ * project.+ */+export interface InboxReportSourceSuggestionProperties {+ report_id: string;+ report_age_hours: number;+ priority: string | null;+ actionability: string | null;+ /** Whether the report already has an implementation PR. */+ has_pr: boolean;+ product: string;+}+/*** Thumbs-up/down verdict on a report's usefulness, fired from the feedback* footer at the end of the report body. Feedback-only: unlike a dismiss, the@@ -1823,6 +1839,9 @@ export const ANALYTICS_EVENTS = {INBOX_REPORT_SCROLLED: "Inbox report scrolled",INBOX_REPORT_FEEDBACK: "Inbox report feedback",INBOX_REPORT_FEEDBACK_NOTE: "Inbox report feedback note",+ INBOX_REPORT_SOURCE_SUGGESTION_SHOWN: "Inbox report source suggestion shown",+ INBOX_REPORT_SOURCE_SUGGESTION_CLICKED:+ "Inbox report source suggestion clicked",INBOX_TRIAGE_STARTED: "Inbox triage started",INBOX_TRIAGE_ENDED: "Inbox triage ended",SIGNAL_SOURCE_CONNECTED: "Signal source connected",@@ -2048,6 +2067,8 @@ export type EventPropertyMap = {[ANALYTICS_EVENTS.INBOX_REPORT_SCROLLED]: InboxReportScrolledProperties;[ANALYTICS_EVENTS.INBOX_REPORT_FEEDBACK]: InboxReportFeedbackProperties;[ANALYTICS_EVENTS.INBOX_REPORT_FEEDBACK_NOTE]: InboxReportFeedbackNoteProperties;+ [ANALYTICS_EVENTS.INBOX_REPORT_SOURCE_SUGGESTION_SHOWN]: InboxReportSourceSuggestionProperties;+ [ANALYTICS_EVENTS.INBOX_REPORT_SOURCE_SUGGESTION_CLICKED]: InboxReportSourceSuggestionProperties;[ANALYTICS_EVENTS.INBOX_TRIAGE_STARTED]: InboxTriageStartedProperties;[ANALYTICS_EVENTS.INBOX_TRIAGE_ENDED]: InboxTriageEndedProperties;[ANALYTICS_EVENTS.SIGNAL_SOURCE_CONNECTED]: SignalSourceConnectedProperties;@@ -2141,6 +2162,8 @@ const INBOX_ANALYTICS_EVENT_NAMES: ReadonlySet<string> = new Set([ANALYTICS_EVENTS.INBOX_REPORT_SCROLLED,ANALYTICS_EVENTS.INBOX_REPORT_FEEDBACK,ANALYTICS_EVENTS.INBOX_REPORT_FEEDBACK_NOTE,+ ANALYTICS_EVENTS.INBOX_REPORT_SOURCE_SUGGESTION_SHOWN,+ ANALYTICS_EVENTS.INBOX_REPORT_SOURCE_SUGGESTION_CLICKED,ANALYTICS_EVENTS.INBOX_TRIAGE_STARTED,ANALYTICS_EVENTS.INBOX_TRIAGE_ENDED,ANALYTICS_EVENTS.SIGNAL_SOURCE_CONNECTED,diff --git a/products/desktop/packages/ui/src/features/inbox/components/InboxDetailFrame.tsx b/products/desktop/packages/ui/src/features/inbox/components/InboxDetailFrame.tsxindex f5dd65ba7bab..bba49236464c 100644--- a/products/desktop/packages/ui/src/features/inbox/components/InboxDetailFrame.tsx+++ b/products/desktop/packages/ui/src/features/inbox/components/InboxDetailFrame.tsx@@ -1,5 +1,6 @@import type { IconProps } from "@phosphor-icons/react";import type { SignalReport } from "@posthog/shared/types";+import { ReportSourceSuggestion } from "@posthog/ui/features/inbox/components/detail/ReportSourceSuggestion";import { InboxDetailFrameView } from "@posthog/ui/features/inbox/components/InboxDetailFrameView";import {SignalsList,@@ -77,7 +78,15 @@ export function InboxDetailFrame({again.</p>) : signals.length > 0 ? (- <SignalsList signals={signals} />+ <div className="flex flex-col gap-2">+ <SignalsList signals={signals} />+ {report.source_suggestion && (+ <ReportSourceSuggestion+ report={report}+ suggestion={report.source_suggestion}+ />+ )}+ </div>) : (<SignalsListSkeleton count={evidenceCount} />);diff --git a/products/desktop/packages/ui/src/features/inbox/components/detail/ReportSourceSuggestion.stories.tsx b/products/desktop/packages/ui/src/features/inbox/components/detail/ReportSourceSuggestion.stories.tsxnew file mode 100644index 000000000000..3dbee85c0c0f--- /dev/null+++ b/products/desktop/packages/ui/src/features/inbox/components/detail/ReportSourceSuggestion.stories.tsx@@ -0,0 +1,27 @@+import type { Meta, StoryObj } from "@storybook/react-vite";+import { ReportSourceSuggestionView } from "./ReportSourceSuggestion";++const meta: Meta<typeof ReportSourceSuggestionView> = {+ title: "Inbox/ReportSourceSuggestion",+ component: ReportSourceSuggestionView,+ decorators: [+ (Story) => (+ <div className="max-w-sm p-4">+ <Story />+ </div>+ ),+ ],+ args: {+ product: "logs",+ reason:+ "Logs from the checkout service could show whether the timeout starts at the payment provider.",+ actionLabel: "Set up logs",+ url: "https://us.posthog.com/project/1/logs",+ onOpen: () => {},+ },+};+export default meta;++type Story = StoryObj<typeof ReportSourceSuggestionView>;++export const Logs: Story = {};diff --git a/products/desktop/packages/ui/src/features/inbox/components/detail/ReportSourceSuggestion.tsx b/products/desktop/packages/ui/src/features/inbox/components/detail/ReportSourceSuggestion.tsxnew file mode 100644index 000000000000..93a9763d3dc5--- /dev/null+++ b/products/desktop/packages/ui/src/features/inbox/components/detail/ReportSourceSuggestion.tsx@@ -0,0 +1,122 @@+import { ArrowSquareOutIcon } from "@phosphor-icons/react";+import { reportAgeHours } from "@posthog/core/inbox/engagement";+import { sourceSuggestionTarget } from "@posthog/core/inbox/sourceSuggestion";+import { Button } from "@posthog/quill";+import { ANALYTICS_EVENTS } from "@posthog/shared";+import type {+ SignalReport,+ SignalReportSourceSuggestion,+} from "@posthog/shared/types";+import { getSourceProductMeta } from "@posthog/ui/features/inbox/components/utils/source-product-icons";+import { track } from "@posthog/ui/shell/analytics";+import { openExternalUrl } from "@posthog/ui/shell/openExternal";+import { projectPathUrl } from "@posthog/ui/utils/posthogLinks";+import { useEffect, useEffectEvent } from "react";++function suggestionEventProperties(report: SignalReport, product: string) {+ return {+ report_id: report.id,+ report_age_hours: reportAgeHours(report.created_at),+ priority: report.priority ?? null,+ actionability: report.actionability ?? null,+ has_pr: !!report.implementation_pr_url,+ product,+ };+}++/**+ * A product the team doesn't use that would have given this report better+ * evidence, shown after the evidence with a link to the product in PostHog.+ */+export function ReportSourceSuggestion({+ report,+ suggestion,+}: {+ report: SignalReport;+ suggestion: SignalReportSourceSuggestion;+}) {+ const target = sourceSuggestionTarget(suggestion.product);+ const url = target ? projectPathUrl(target.path) : null;+ const shown = url !== null;++ const trackShown = useEffectEvent(() => {+ track(+ ANALYTICS_EVENTS.INBOX_REPORT_SOURCE_SUGGESTION_SHOWN,+ suggestionEventProperties(report, suggestion.product),+ );+ });++ // biome-ignore lint/correctness/useExhaustiveDependencies: once per report and product, not on every report refetch.+ useEffect(() => {+ if (shown) {+ trackShown();+ }+ }, [shown, report.id, suggestion.product]);++ if (!target || !url) return null;++ return (+ <ReportSourceSuggestionView+ product={suggestion.product}+ reason={suggestion.reason}+ actionLabel={target.actionLabel}+ url={url}+ onOpen={() => {+ track(+ ANALYTICS_EVENTS.INBOX_REPORT_SOURCE_SUGGESTION_CLICKED,+ suggestionEventProperties(report, suggestion.product),+ );+ openExternalUrl(url);+ }}+ />+ );+}++export function ReportSourceSuggestionView({+ product,+ reason,+ actionLabel,+ url,+ onOpen,+}: {+ product: string;+ reason: string;+ actionLabel: string;+ url: string;+ onOpen: () => void;+}) {+ const meta = getSourceProductMeta(product);++ return (+ <div className="flex flex-col gap-2 rounded-md border border-border border-dashed p-3">+ <div className="flex items-center gap-1.5 text-muted-foreground text-xs">+ {meta && (+ <meta.Icon+ size={13}+ className="shrink-0"+ style={{ color: meta.color }}+ />+ )}+ <span className="font-medium">{meta?.label ?? product}</span>+ <span>· Not set up in this project</span>+ </div>+ <p className="m-0 text-foreground text-xs">{reason}</p>+ <Button+ // biome-ignore lint/a11y/useAnchorContent: Button renders its children inside the anchor.+ render={<a href={url} target="_blank" rel="noreferrer" />}+ nativeButton={false}+ variant="outline"+ size="sm"+ className="self-start"+ onClick={(event) => {+ // The host opens external URLs, so the anchor's own navigation must not run too.+ event.preventDefault();+ onOpen();+ }}+ >+ <ArrowSquareOutIcon size={12} />+ {actionLabel}+ </Button>+ </div>+ );+}diff --git a/products/desktop/packages/ui/src/features/inbox/components/detail/reportActivity.ts b/products/desktop/packages/ui/src/features/inbox/components/detail/reportActivity.tsindex 76ce8dbfe610..ac06638aeb84 100644--- a/products/desktop/packages/ui/src/features/inbox/components/detail/reportActivity.ts+++ b/products/desktop/packages/ui/src/features/inbox/components/detail/reportActivity.ts@@ -6,6 +6,8 @@ const ROUTINE_PIPELINE_ARTEFACTS = new Set(["repo_selection","safety_judgment","signal_finding",+ // Rendered under the report's evidence instead.+ "source_suggestion","suggested_reviewers","task_run",]);diff --git a/products/desktop/packages/ui/src/features/inbox/components/utils/source-product-icons.tsx b/products/desktop/packages/ui/src/features/inbox/components/utils/source-product-icons.tsxindex 455b58ba82b7..692e154ed83f 100644--- a/products/desktop/packages/ui/src/features/inbox/components/utils/source-product-icons.tsx+++ b/products/desktop/packages/ui/src/features/inbox/components/utils/source-product-icons.tsx@@ -10,6 +10,7 @@ import {KanbanIcon,LifebuoyIcon,LightbulbIcon,+ ListBulletsIcon,MagnifyingGlassIcon,MegaphoneIcon,ShieldIcon,@@ -57,6 +58,11 @@ export function hasKnownSourceProduct(}const SOURCE_PRODUCT_META: Partial<Record<SourceProduct, SourceProductMeta>> = {+ logs: {+ Icon: ListBulletsIcon,+ color: "var(--pink-9)",+ label: "Logs",+ },replay_vision: {Icon: VideoIcon,color: "var(--amber-9)",diff --git a/products/desktop/packages/ui/src/utils/posthogLinks.ts b/products/desktop/packages/ui/src/utils/posthogLinks.tsindex cf3e97b99b20..06290a4e1fbb 100644--- a/products/desktop/packages/ui/src/utils/posthogLinks.ts+++ b/products/desktop/packages/ui/src/utils/posthogLinks.ts@@ -29,6 +29,14 @@ function withProjectId(return getPostHogUrl(path(projectId), overrides?.cloudRegion);}+/** A page inside the current project, given its path after `/project/<id>/`. */+export function projectPathUrl(+ path: string,+ overrides?: LinkOverrides,+): string | null {+ return withProjectId((pid) => `/project/${pid}/${path}`, overrides);+}+export function flagUrl(flagId: number,overrides?: LinkOverrides,