: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(signals): show report product suggestions in the web inbox (#112706)
Rafael Audibertad313168450e
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 5bec6ef61381..1bfa2ad859d2 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -11046,6 +11046,10 @@ snapshots:hash: v1.k794b7964.4a72fd69c80a076b8f6040c0473d1a42aa0e574e51cd9ac16c16ce74f5434d4b.UJFgWCDdVPiMssuUXnf6Px4wj9tZljS4fKvI_6WmIqIscenes-app-inbox-report-metrics--wide--light:hash: v1.k794b7964.3465b8cd1a9bf286b7ae698d78dba847138201548b8a3c56978fae74b431da53.2bz4A6FW49b2OIDhumSwnnmW8eVEaLSHMmBLZx_eFOg+ scenes-app-inbox-reportsourcesuggestion--logs--dark:+ hash: v1.k794b7964.7a1690934454b93121e9bf56db6e5b731bae66bb941e705ef3d27855458e01d9.p0wpMpu1OEWo_e2f7WnYoNgV9Pmy9PFaXsx8wFZg-aA+ scenes-app-inbox-reportsourcesuggestion--logs--light:+ hash: v1.k794b7964.d5d1040cc778c947be775229c9b6158b5f836a533ed705da42df816071be1cdb.BhUT6qPcyyC9BegwxP3rKg3OcahAzfe1WffSJEOcd-sscenes-app-inbox-scene--empty--dark:hash: v1.k794b7964.d1f94cecb2a36f2308212dc28ef1e83d8153b45578c4f390c4596dc308d5eb93.Cxai09kW1P5oCqveaca9r04fxOsysv7d9ggUQDV7hB4scenes-app-inbox-scene--empty--light:diff --git a/products/signals/frontend/inbox/components/detail/ReportDetail.tsx b/products/signals/frontend/inbox/components/detail/ReportDetail.tsxindex d8b10c220d29..77adfc83c407 100644--- a/products/signals/frontend/inbox/components/detail/ReportDetail.tsx+++ b/products/signals/frontend/inbox/components/detail/ReportDetail.tsx@@ -56,6 +56,7 @@ import { ReportExpectedImpact } from './ReportExpectedImpact'import { ReportFeedbackFooter } from './ReportFeedbackFooter'import { ReportImpactMetrics } from './ReportImpactMetrics'import { ReportPrimaryMetric } from './ReportPrimaryMetric'+import { ReportSourceSuggestion } from './ReportSourceSuggestion'import { ReportStatusSection } from './ReportStatusSection'import { ReportSummaryBody } from './ReportSummaryBody'import { ReportTasksSection } from './ReportTasksSection'@@ -463,6 +464,12 @@ export function InboxDetailFrame({{evidenceExpanded ? 'Show less' : 'Show more'}</LemonButton>)}+ {report.source_suggestion && (+ <ReportSourceSuggestion+ report={report}+ suggestion={report.source_suggestion}+ />+ )}</div>)}</DetailSection>diff --git a/products/signals/frontend/inbox/components/detail/ReportDetailLegacy.tsx b/products/signals/frontend/inbox/components/detail/ReportDetailLegacy.tsxindex 427c4bf494d7..3b3794521993 100644--- a/products/signals/frontend/inbox/components/detail/ReportDetailLegacy.tsx+++ b/products/signals/frontend/inbox/components/detail/ReportDetailLegacy.tsx@@ -56,6 +56,7 @@ import { ReportChart } from './ReportChart'import { ReportChartsContext } from './reportChartsContext'import { useReportDetailActions } from './ReportDetailActions'import { ReportFeedbackFooter } from './ReportFeedbackFooter'+import { ReportSourceSuggestion } from './ReportSourceSuggestion'import { ReportTasksSection } from './ReportTasksSection'import { SuggestedReviewersSection } from './SuggestedReviewersSection'import { TrackerIssueNote } from './TrackerIssueNote'@@ -406,6 +407,9 @@ function InboxDetailFrameLegacy({{evidenceExpanded ? 'Show less' : 'Show more'}</LemonButton>)}+ {report.source_suggestion && (+ <ReportSourceSuggestion report={report} suggestion={report.source_suggestion} />+ )}</div>)}</DetailSection>diff --git a/products/signals/frontend/inbox/components/detail/ReportSourceSuggestion.stories.tsx b/products/signals/frontend/inbox/components/detail/ReportSourceSuggestion.stories.tsxnew file mode 100644index 000000000000..a2dc429479ad--- /dev/null+++ b/products/signals/frontend/inbox/components/detail/ReportSourceSuggestion.stories.tsx@@ -0,0 +1,29 @@+import type { Meta, StoryObj } from '@storybook/react'++import { makeReport } from '../../__mocks__/inboxMocks'+import { ReportSourceSuggestion } from './ReportSourceSuggestion'++const meta: Meta<typeof ReportSourceSuggestion> = {+ title: 'Scenes-App/Inbox/ReportSourceSuggestion',+ component: ReportSourceSuggestion,+ parameters: { layout: 'centered' },+ decorators: [+ (Story): JSX.Element => (+ <div className="w-96 max-w-full">+ <Story />+ </div>+ ),+ ],+ args: {+ report: makeReport({ title: 'Checkout requests time out' }),+ suggestion: {+ product: 'logs',+ reason: 'Logs from the checkout service could show whether the timeout starts at the payment provider.',+ },+ },+}+export default meta++type Story = StoryObj<typeof ReportSourceSuggestion>++export const Logs: Story = {}diff --git a/products/signals/frontend/inbox/components/detail/ReportSourceSuggestion.tsx b/products/signals/frontend/inbox/components/detail/ReportSourceSuggestion.tsxnew file mode 100644index 000000000000..f49b7fd27571--- /dev/null+++ b/products/signals/frontend/inbox/components/detail/ReportSourceSuggestion.tsx@@ -0,0 +1,68 @@+import { IconArrowRight } from '@posthog/icons'+import { LemonButton } from '@posthog/lemon-ui'++import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'+import { LemonCard } from 'lib/lemon-ui/LemonCard'++import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'+import type { FileSystemIconType } from '~/queries/schema/schema-general'++import type { ReportSourceSuggestionApi } from 'products/signals/frontend/generated/api.schemas'++import {+ captureInboxReportSourceSuggestionClicked,+ captureInboxReportSourceSuggestionShown,+} from '../../inboxAnalytics'+import type { SignalReport } from '../../types'+import { sourceSuggestionTarget } from '../../utils/sourceSuggestion'+import { getSourceProductMeta } from '../badges/sourceProductIcons'++/** A product the team doesn't use that would have given this report better evidence, shown after the evidence. */+export function ReportSourceSuggestion({+ report,+ suggestion,+}: {+ report: SignalReport+ suggestion: ReportSourceSuggestionApi+}): JSX.Element | null {+ const target = sourceSuggestionTarget(suggestion.product)++ useOnMountEffect(() => {+ if (target) {+ captureInboxReportSourceSuggestionShown({ report, product: suggestion.product })+ }+ })++ if (!target) {+ return null+ }++ return (+ <LemonCard hoverEffect={false} className="p-3 shadow-none border-dashed">+ <div className="flex items-center gap-2 mb-2">+ <span+ className="flex shrink-0 text-base group/colorful-product-icons colorful-product-icons-true"+ aria-hidden+ >+ {iconForType(suggestion.product as FileSystemIconType)}+ </span>+ <span className="truncate text-xs font-medium text-tertiary">+ {getSourceProductMeta(suggestion.product)?.label} · Not set up in this project+ </span>+ </div>+ <p className="m-0 mb-2 text-sm">{suggestion.reason}</p>+ <div className="flex">+ <LemonButton+ type="secondary"+ size="small"+ to={target.url()}+ sideIcon={<IconArrowRight />}+ onClick={() => captureInboxReportSourceSuggestionClicked({ report, product: suggestion.product })}+ data-attr="inbox-report-source-suggestion"+ >+ {target.actionLabel}+ </LemonButton>+ </div>+ </LemonCard>+ )+}diff --git a/products/signals/frontend/inbox/components/detail/artefactTypes.ts b/products/signals/frontend/inbox/components/detail/artefactTypes.tsindex 21326e3800ae..af01be98010d 100644--- a/products/signals/frontend/inbox/components/detail/artefactTypes.ts+++ b/products/signals/frontend/inbox/components/detail/artefactTypes.ts@@ -313,6 +313,8 @@ export function selectVisibleReportActivity(artefacts: SignalReportArtefact[]):(artefact) =>artefact.type !== 'implementation_dispatch' &&artefact.type !== 'impact_measurement_plan' &&+ // The report shows its product suggestion under the evidence, so the log would only repeat it.+ artefact.type !== 'source_suggestion' &&(artefact.type !== 'implementation_handover' ||(artefact.content as ImplementationHandoverContent).status !== 'processing'))diff --git a/products/signals/frontend/inbox/inboxAnalytics.ts b/products/signals/frontend/inbox/inboxAnalytics.tsindex 696811102b59..8c7168bc5242 100644--- a/products/signals/frontend/inbox/inboxAnalytics.ts+++ b/products/signals/frontend/inbox/inboxAnalytics.ts@@ -43,6 +43,8 @@ export const INBOX_EVENTS = {SELECTION_MODE_ENTERED: 'Inbox selection mode entered',REPORT_ACTION_COMPLETED: 'Inbox report action completed',REPORT_FEEDBACK: 'Inbox report feedback',+ REPORT_SOURCE_SUGGESTION_SHOWN: 'Inbox report source suggestion shown',+ REPORT_SOURCE_SUGGESTION_CLICKED: 'Inbox report source suggestion clicked',REPORT_FEEDBACK_NOTE: 'Inbox report feedback note',SETTINGS_CHANGED: 'Inbox settings changed',SOURCE_CONNECTED: 'Signal source connected',@@ -545,6 +547,22 @@ export function captureInboxReportFeedback(params: {})}+/** A report's product suggestion rendered under its evidence. */+export function captureInboxReportSourceSuggestionShown(params: { report: SignalReport; product: string }): void {+ captureInboxEvent(INBOX_EVENTS.REPORT_SOURCE_SUGGESTION_SHOWN, {+ ...baseReportProperties(params.report),+ product: params.product,+ })+}++/** The suggestion's link to the product was followed. */+export function captureInboxReportSourceSuggestionClicked(params: { report: SignalReport; product: string }): void {+ captureInboxEvent(INBOX_EVENTS.REPORT_SOURCE_SUGGESTION_CLICKED, {+ ...baseReportProperties(params.report),+ product: params.product,+ })+}+/*** Optional free-text note, offered only once a rating is already recorded. It rides on its own* event rather than re-firing {@link captureInboxReportFeedback} so sentiment stays exactly onediff --git a/products/signals/frontend/inbox/types.ts b/products/signals/frontend/inbox/types.tsindex fc5501d0dfb3..da30391bb056 100644--- a/products/signals/frontend/inbox/types.ts+++ b/products/signals/frontend/inbox/types.ts@@ -4,6 +4,7 @@ import {type ReportChartApi,type ReportMetricApi,type ReportRankingApi,+ type ReportSourceSuggestionApi,type SignalReportPullRequestApi,type SignalReportAssigneeApi,type SignalReportAssignmentPrStateEnumApi,@@ -103,6 +104,8 @@ export interface SignalReport {metrics?: ReportMetricApi[]/** Prompts the report's author suggests sending about it (questions or next-step actions), offered above the "Ask AI" box. */suggested_prompts?: string[]+ /** A product the team doesn't use that would have given this report better evidence. Detail responses only. */+ source_suggestion?: ReportSourceSuggestionApi | null/** Count of signals at the time the latest research run kicked off. */signals_at_run?: number/** Scout notes the work log dropped because they restate earlier ones. 0 when nothing was dropped. */diff --git a/products/signals/frontend/inbox/utils/sourceSuggestion.ts b/products/signals/frontend/inbox/utils/sourceSuggestion.tsnew file mode 100644index 000000000000..5a411cc77e08--- /dev/null+++ b/products/signals/frontend/inbox/utils/sourceSuggestion.ts@@ -0,0 +1,23 @@+import { urls } from 'scenes/urls'++import type { SuggestedSourceProductEnumApi } from 'products/signals/frontend/generated/api.schemas'++export interface SourceSuggestionTarget {+ url: () => string+ actionLabel: string+}++/** The landing page a report's product suggestion sends the reader to, and the button that opens it. */+const SOURCE_SUGGESTION_TARGETS: Record<SuggestedSourceProductEnumApi, SourceSuggestionTarget> = {+ logs: { url: () => urls.logs(), actionLabel: 'Set up logs' },+ session_replay: { url: () => urls.replay(), actionLabel: 'Set up session replay' },+ error_tracking: { url: () => urls.errorTracking(), actionLabel: 'Set up error tracking' },+ llm_analytics: { url: () => urls.aiObservabilityDashboard(), actionLabel: 'Set up AI observability' },+}++/** Null for a product this build does not know yet, which a newer backend can send to a cached frontend. */+export function sourceSuggestionTarget(product: string): SourceSuggestionTarget | null {+ return Object.hasOwn(SOURCE_SUGGESTION_TARGETS, product)+ ? SOURCE_SUGGESTION_TARGETS[product as SuggestedSourceProductEnumApi]+ : null+}