: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): emit cloud Inbox report scrolled for the engagement metric (#81395)
posthog[bot]21405c93693c
diff --git a/products/signals/frontend/inbox/InboxScene.tsx b/products/signals/frontend/inbox/InboxScene.tsxindex cfe33ce1469b..ec51ff9d4293 100644--- a/products/signals/frontend/inbox/InboxScene.tsx+++ b/products/signals/frontend/inbox/InboxScene.tsx@@ -205,9 +205,21 @@ function InboxListView(): JSX.Element {*/function InboxDetailView({ report }: { report: SignalReport }): JSX.Element {const { activeTab } = useValues(inboxSceneLogic)+ const { reportDetailScrolled } = useActions(inboxSceneLogic)+ // Report only the first scroll per report to the logic (which fires `Inbox report scrolled` once),+ // so a fast native scroll doesn't dispatch an action on every frame.+ const scrolledReportRef = useRef<string | null>(null)return (- <div className="flex flex-col min-h-0 flex-1 overflow-auto">+ <div+ className="flex flex-col min-h-0 flex-1 overflow-auto"+ onScroll={() => {+ if (scrolledReportRef.current !== report.id) {+ scrolledReportRef.current = report.id+ reportDetailScrolled()+ }+ }}+ >{/* Key on the report so per-report detail state (e.g. the active diff tab) resets on navigation. */}<ReportDetail key={report.id} report={report} tab={activeTab} /></div>diff --git a/products/signals/frontend/inbox/inboxAnalytics.test.ts b/products/signals/frontend/inbox/inboxAnalytics.test.tsindex 8195f05c8631..22601be1383e 100644--- a/products/signals/frontend/inbox/inboxAnalytics.test.ts+++ b/products/signals/frontend/inbox/inboxAnalytics.test.ts@@ -4,6 +4,7 @@ import {captureInboxQueryChanged,captureInboxReportAction,captureInboxReportClosed,+ captureInboxReportScrolled,captureInboxReportsImpressed,captureInboxSettingsChanged,captureInboxViewed,@@ -158,6 +159,24 @@ describe('inboxAnalytics', () => {})})+ it('carries the dwell before a detail-pane scroll, without the report title', () => {+ captureInboxReportScrolled({+ report: makeReport({ id: 'r9' }),+ rank: 3,+ listSize: 20,+ timeSinceOpenMs: 6200,+ })+ const props = lastCapture(INBOX_EVENTS.REPORT_SCROLLED)+ expect(props).toMatchObject({+ report_id: 'r9',+ rank: 3,+ list_size: 20,+ time_since_open_ms: 6200,+ })+ expect(props?.report_title).toBeUndefined()+ expect(JSON.stringify(props)).not.toContain('Something broke')+ })+it('records how the query moved without shipping what was typed into the search box', () => {captureInboxQueryChanged({change: 'search',diff --git a/products/signals/frontend/inbox/inboxAnalytics.ts b/products/signals/frontend/inbox/inboxAnalytics.tsindex 3221b15d6148..a4806264d07b 100644--- a/products/signals/frontend/inbox/inboxAnalytics.ts+++ b/products/signals/frontend/inbox/inboxAnalytics.ts@@ -22,6 +22,7 @@ export const INBOX_EVENTS = {REPORTS_IMPRESSED: 'Inbox reports impressed',REPORT_OPENED: 'Inbox report opened',REPORT_CLOSED: 'Inbox report closed',+ REPORT_SCROLLED: 'Inbox report scrolled',REPORT_ACTION: 'Inbox report action',REPORT_ACTION_COMPLETED: 'Inbox report action completed',REPORT_FEEDBACK: 'Inbox report feedback',@@ -319,6 +320,26 @@ export function captureInboxReportClosed()}+/**+ * The report detail pane was scrolled, fired once per open on the first scroll. It feeds the dwell+ * half of the "Inbox engagement" metric, whose second step reads a scroll after at least 5 seconds.+ * Only the desktop `Inbox report scrolled` event fed that step before, so it was dead for cloud.+ * `time_since_open_ms` is the dwell before the scroll. Mirrors the desktop event's shape.+ */+export function captureInboxReportScrolled(params: {+ report: SignalReport+ rank: number | null+ listSize: number | null+ timeSinceOpenMs: number+}): void {+ captureInboxEvent(INBOX_EVENTS.REPORT_SCROLLED, {+ ...baseReportProperties(params.report),+ rank: params.rank,+ list_size: params.listSize,+ time_since_open_ms: params.timeSinceOpenMs,+ })+}+export function captureInboxReportAction(params: {/** Omitted for bulk actions, which act on a selection rather than a single report. */report?: SignalReport | nulldiff --git a/products/signals/frontend/inbox/inboxSceneLogic.ts b/products/signals/frontend/inbox/inboxSceneLogic.tsindex 91883d315fe1..dd34e0955abb 100644--- a/products/signals/frontend/inbox/inboxSceneLogic.ts+++ b/products/signals/frontend/inbox/inboxSceneLogic.ts@@ -22,6 +22,7 @@ import { signalsReportsViewedCreate } from 'products/signals/frontend/generated/import {captureInboxReportClosed,captureInboxReportOpened,+ captureInboxReportScrolled,InboxReportCloseMethod,InboxReportOpenMethod,} from './inboxAnalytics'@@ -211,6 +212,8 @@ function inboxSurfaceUrl(values: {interface InboxOpenTracking {report: SignalReportopenedAt: number+ /** Set once the first detail-pane scroll has fired `Inbox report scrolled` for this open. */+ scrolled: boolean}/**@@ -294,6 +297,9 @@ export interface inboxSceneLogicActions {id: string}}+ reportDetailScrolled: () => {+ value: true+ }runSessionAnalysis: () => {value: true}@@ -393,6 +399,9 @@ export const inboxSceneLogic = kea<inboxSceneLogicType>([runSessionAnalysis: true,runSessionAnalysisSuccess: true,runSessionAnalysisFailure: (error: string) => ({ error }),+ // The detail pane was scrolled. The logic fires `Inbox report scrolled` once per open; the+ // component reports the raw scroll.+ reportDetailScrolled: true,// A decoded `#createScout=` payload, prefilling the create modal. The user still submits it.setScoutTemplateDraft: (draft: ScoutCreateInitialValues | null) => ({ draft }),}),@@ -627,13 +636,29 @@ export const inboxSceneLogic = kea<inboxSceneLogicType>([rank,listSize,})- cache.openTracking = { report, openedAt: Date.now() }+ cache.openTracking = { report, openedAt: Date.now(), scrolled: false }cache.pendingOpenMethod = undefined// Best-effort server-side view record: consumption evidence that keeps the authoring// scout from being auto-paused as ignored. The analytics event above stays the rich// record (rank, open method, dwell), so a failure here is swallowed.void signalsReportsViewedCreate(String(teamLogic.values.currentTeamId), report.id).catch(() => {})},+ reportDetailScrolled: () => {+ // Fire the dwell signal once per open, on the first scroll. The metric's dwell branch+ // filters `time_since_open_ms >= 5000`, so an immediate scroll is carried but won't qualify.+ const open: InboxOpenTracking | undefined = cache.openTracking+ if (!open || open.scrolled) {+ return+ }+ open.scrolled = true+ const { rank, listSize } = findReportRank(open.report.id)+ captureInboxReportScrolled({+ report: open.report,+ rank,+ listSize,+ timeSinceOpenMs: Date.now() - open.openedAt,+ })+ },setSelectedScoutSkillName: ({ skillName }) => {if (skillName !== null) {// Opening a scout detail closes the scratchpad (reducer) — clear its transient search.