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.

feat(today): send inbox ranking open and action labels from every report path (#117881)

posthog[bot]48fc42105997
diff --git a/frontend/src/scenes/project-homepage/today/TodayReportNextStep.tsx b/frontend/src/scenes/project-homepage/today/TodayReportNextStep.tsx
index b2f4eaa60903..5718e128e8be 100644
--- a/frontend/src/scenes/project-homepage/today/TodayReportNextStep.tsx
+++ b/frontend/src/scenes/project-homepage/today/TodayReportNextStep.tsx
@@ -7,6 +7,7 @@ import { Button, Text } from '@posthog/quill'
import { LinkPrimitive } from 'lib/lemon-ui/Link'
import { Composer } from 'products/posthog_ai/frontend/api/composer'
+import { captureInboxReportAction } from 'products/signals/frontend/inbox/inboxAnalytics'
import { inboxTaskKickoffLogic } from 'products/signals/frontend/inbox/inboxTaskKickoffLogic'
import type {
ImplementationSlotClaim,
@@ -39,6 +40,7 @@ function PrimaryAction({
variant="primary"
className="me-1"
render={<LinkPrimitive to={primary.url} target="_blank" />}
+ onClick={() => captureInboxReportAction({ report, actionType: 'open_pr', surface: 'today' })}
disabledReason={isSample ? SAMPLE_REPORT_REASON : null}
data-attr="today-report-review-pr"
>
diff --git a/frontend/src/scenes/project-homepage/today/TodayReportPage.tsx b/frontend/src/scenes/project-homepage/today/TodayReportPage.tsx
index e42496a04035..1f4e73f25daa 100644
--- a/frontend/src/scenes/project-homepage/today/TodayReportPage.tsx
+++ b/frontend/src/scenes/project-homepage/today/TodayReportPage.tsx
@@ -96,11 +96,19 @@ function ReportSkeleton({ header }: { header: JSX.Element | null }): JSX.Element
}
export function TodayReportPage({ reportId }: { reportId: string }): JSX.Element {
- const { currentReport, page, reportFailed, isSample } = useValues(todayReportLogic({ reportId }))
+ const logic = todayReportLogic({ reportId })
+ const { currentReport, page, reportFailed, isSample } = useValues(logic)
+ const { reportVisited } = useActions(logic)
const { setTodayReportTitle } = useActions(projectHomepageLogic)
const title = currentReport ? reportTitle(currentReport) : null
const rootRef = useRef<HTMLDivElement>(null)
+ // The page mounts once per visit (`TodayHome` keys it by report). Prefetched neighbors mount the logic but not
+ // the page, so they send no open.
+ useEffect(() => {
+ reportVisited()
+ }, [reportVisited])
+
useLayoutEffect(() => {
rootRef.current?.closest('main')?.scrollTo({ top: 0 })
}, [reportId])
diff --git a/frontend/src/scenes/project-homepage/today/todayAskPrompt.ts b/frontend/src/scenes/project-homepage/today/todayAskPrompt.ts
index 42e53ab4f458..17190e0a814f 100644
--- a/frontend/src/scenes/project-homepage/today/todayAskPrompt.ts
+++ b/frontend/src/scenes/project-homepage/today/todayAskPrompt.ts
@@ -17,16 +17,21 @@ function markdownLink(text: string, href: string): string {
return `[${text.replace(/[[\]]/g, '\\$&')}](${urls.absolute(urls.currentProject(href))})`
}
+// `link_source` tells the report page that a PostHog AI answer wrote the link.
+function todayReportHref(reportId: string): string {
+ return `${urls.todayReport(reportId)}?link_source=today`
+}
+
function reportsContext(reports: SignalReport[]): string[] {
return [
'- The page shows these reports, most urgent first:',
...reports.map(
(report, index) =>
- ` ${index + 1}. ${markdownLink(report.title ?? 'Untitled report', urls.todayReport(report.id))}` +
+ ` ${index + 1}. ${markdownLink(report.title ?? 'Untitled report', todayReportHref(report.id))}` +
(report.priority ? ` (${report.priority})` : '')
),
'',
- 'Each link ends with the report id. Use it with `inbox-reports-retrieve` to read the report in full before you ' +
+ 'The last part of each link path is the report id. Use it with `inbox-reports-retrieve` to read the report in full before you ' +
'follow up on it.',
]
}
diff --git a/frontend/src/scenes/project-homepage/today/todayLogic.test.ts b/frontend/src/scenes/project-homepage/today/todayLogic.test.ts
index 79f08c05dc50..746c0947f658 100644
--- a/frontend/src/scenes/project-homepage/today/todayLogic.test.ts
+++ b/frontend/src/scenes/project-homepage/today/todayLogic.test.ts
@@ -56,7 +56,10 @@ describe('todayLogic', () => {
it.each([
{
shown: 'the report list',
- expected: ['the page shows these reports', '](http://localhost/project/997/home/reports/r-1)'],
+ expected: [
+ 'the page shows these reports',
+ '](http://localhost/project/997/home/reports/r-1?link_source=today)',
+ ],
},
{
shown: 'the open report',
@@ -166,7 +169,12 @@ describe('todayLogic', () => {
logic.actions.loadTopReports()
await expectLogic(logic).toFinishAllListeners()
+ reportResponse = [200, report]
logic.actions.reportOpened(report, 'list')
+ const reportLogic = todayReportLogic({ reportId: 'a' })
+ reportLogic.mount()
+ reportLogic.actions.reportVisited()
+ await expectLogic(reportLogic).toDispatchActions(['loadFullReportSuccess'])
todayVerdictLogic.actions.setReportVerdict(
{ reportId: 'a', title: 'Signup form rejects emails', hasOpenPullRequest: false },
'dismiss',
@@ -189,7 +197,13 @@ describe('todayLogic', () => {
],
[
'Inbox report opened',
- expect.objectContaining({ report_id: 'a', surface: 'today', list: 'briefing', rank: 1 }),
+ expect.objectContaining({
+ report_id: 'a',
+ surface: 'today',
+ open_method: 'click',
+ list: 'briefing',
+ rank: 1,
+ }),
undefined,
],
[
@@ -209,7 +223,12 @@ describe('todayLogic', () => {
logic.mount()
await expectLogic(logic).toFinishAllListeners()
+ reportResponse = [200, b]
logic.actions.reportOpened(b, 'list')
+ const reportLogic = todayReportLogic({ reportId: 'b' })
+ reportLogic.mount()
+ reportLogic.actions.reportVisited()
+ await expectLogic(reportLogic).toDispatchActions(['loadFullReportSuccess'])
const events = capture.mock.calls.filter(([event]) => event.startsWith('Inbox '))
expect(events).toEqual([
@@ -242,6 +261,19 @@ describe('todayLogic', () => {
expect(capture.mock.calls.filter(([event]) => event === 'today report previewed')).toEqual([
['today report previewed', expect.objectContaining({ list: 'team', report_id: 'a', surface: 'list' })],
])
+ expect(capture.mock.calls.filter(([event]) => event === 'Inbox report action')).toEqual([
+ [
+ 'Inbox report action',
+ expect.objectContaining({
+ report_id: 'a',
+ action_type: 'expand_preview',
+ surface: 'today',
+ list: 'briefing',
+ rank: 1,
+ }),
+ undefined,
+ ],
+ ])
})
it.each([
diff --git a/frontend/src/scenes/project-homepage/today/todayLogic.ts b/frontend/src/scenes/project-homepage/today/todayLogic.ts
index 35ab413089b4..3394fdfcb8ea 100644
--- a/frontend/src/scenes/project-homepage/today/todayLogic.ts
+++ b/frontend/src/scenes/project-homepage/today/todayLogic.ts
@@ -21,7 +21,7 @@ import { signalsReportsList, signalsReportsRetrieve } from 'products/signals/fro
import {
TodayReportList,
TodayReportSnapshot,
- captureTodayReportOpened,
+ captureTodayReportAction,
captureTodayReportsImpressed,
} from 'products/signals/frontend/inbox/inboxAnalytics'
import { isActionCapableReport } from 'products/signals/frontend/inbox/inboxTaskKickoffLogic'
@@ -56,6 +56,18 @@ const CLOCK_MS = 30_000
/** Where a report was opened from, sent with the `today report opened` event. */
export type TodayReportOpenSource = 'list' | 'more'
+/**
+ * The list position of a report the person opened from Today. The report page reads it once, and sends the
+ * `Inbox report opened` event with it. `step` is the previous / next control on a report page.
+ */
+export interface TodayReportOpenContext {
+ reportId: string
+ list: TodayReportList | null
+ rank: number | null
+ listSize: number | null
+ source: TodayReportOpenSource | 'step'
+}
+
/** Where a question to PostHog AI came from, sent with the `today ai asked` event. */
export type TodayAskSource = 'walk_through' | 'report_page'
@@ -119,7 +131,7 @@ async function currentReportContext(
return { report: current ?? report, canAct: !!current && isActionCapableReport(current) }
}
-function signalReportSnapshot(report: SignalReport): TodayReportSnapshot {
+export function signalReportSnapshot(report: SignalReport): TodayReportSnapshot {
return {
reportId: report.id,
priority: report.priority ?? null,
@@ -174,6 +186,7 @@ export interface todayLogicValues {
now: number
recentObjects: FileSystemEntry[]
reportId: string | null
+ reportOpenContext: TodayReportOpenContext | null
reportPreviews: Record<string, TodayReportPreview>
reports: SignalReport[]
reportsBroken: boolean
@@ -278,6 +291,9 @@ export interface todayLogicActions {
expanded: boolean
list: TodayList
}
+ setReportOpenContext: (context: TodayReportOpenContext | null) => {
+ context: TodayReportOpenContext | null
+ }
setReturnFocusReportId: (reportId: string | null) => {
reportId: string | null
}
@@ -390,6 +406,7 @@ export const todayLogic = kea<todayLogicType>([
exploreOpened: (product: string, position: number) => ({ product, position }),
setHomeScrollTop: (top: number | null) => ({ top }),
setReturnFocusReportId: (reportId: string | null) => ({ reportId }),
+ setReportOpenContext: (context: TodayReportOpenContext | null) => ({ context }),
setListExpanded: (list: TodayList, expanded: boolean) => ({ list, expanded }),
showMoreForYou: true,
retryFailedLoads: true,
@@ -474,6 +491,10 @@ export const todayLogic = kea<todayLogicType>([
locationChanged: (top, { pathname }) => (isTodayPath(pathname) ? top : null),
},
],
+ reportOpenContext: [
+ null as TodayReportOpenContext | null,
+ { setReportOpenContext: (_, { context }) => context },
+ ],
returnFocusReportId: [
null as string | null,
{
@@ -686,6 +707,14 @@ export const todayLogic = kea<todayLogicType>([
moreRows.length
)
}
+ const capturePreview = (reportId: string, list: TodayReportList, rank: number): void => {
+ captureTodayReportAction({
+ reportId,
+ actionType: 'expand_preview',
+ todaySurface: 'list',
+ extra: { list, rank },
+ })
+ }
return {
askAi: async ({ prompt, source, report }, breakpoint) => {
let context: TodayAskContext
@@ -725,9 +754,9 @@ export const todayLogic = kea<todayLogicType>([
return
}
const { rows } = values.forYouRows
- for (const [list, source] of [
- ['team', 'list'],
- ['more', 'more'],
+ for (const [list, source, reportList] of [
+ ['team', 'list', 'briefing'],
+ ['more', 'more', 'sidebar_more'],
] as const) {
const listRows = reportRows(rows, source)
const index = listRows.findIndex((row) => row.report.id === reportId)
@@ -739,6 +768,7 @@ export const todayLogic = kea<todayLogicType>([
has_metric: !!listRows[index].report.metrics?.length,
surface: 'list',
})
+ capturePreview(reportId, reportList, index + 1)
return
}
}
@@ -797,6 +827,15 @@ export const todayLogic = kea<todayLogicType>([
lemonToast.error('Couldn’t load more reports. Try again in a minute.')
},
reportOpened: ({ report, source }) => {
+ const listRows = reportRows(values.forYouRows.rows, source)
+ const rank = listRows.findIndex((row) => row.report.id === report.id) + 1
+ actions.setReportOpenContext({
+ reportId: report.id,
+ list: source === 'more' ? 'sidebar_more' : 'briefing',
+ rank: rank || null,
+ listSize: listRows.length,
+ source,
+ })
if (values.useSampleData) {
return
}
@@ -807,15 +846,6 @@ export const todayLogic = kea<todayLogicType>([
has_pr: !!report.implementation_pr_url,
source,
})
- const listRows = reportRows(values.forYouRows.rows, source)
- const rank = listRows.findIndex((row) => row.report.id === report.id) + 1
- captureTodayReportOpened({
- report: signalReportSnapshot(report),
- list: source === 'more' ? 'sidebar_more' : 'briefing',
- rank: rank || null,
- listSize: listRows.length,
- source,
- })
},
}
}),
diff --git a/frontend/src/scenes/project-homepage/today/todayReportLogic.test.ts b/frontend/src/scenes/project-homepage/today/todayReportLogic.test.ts
index b935d3c64c62..9ffbe9aa60dc 100644
--- a/frontend/src/scenes/project-homepage/today/todayReportLogic.test.ts
+++ b/frontend/src/scenes/project-homepage/today/todayReportLogic.test.ts
@@ -1,4 +1,6 @@
+import { router } from 'kea-router'
import { expectLogic } from 'kea-test-utils'
+import posthog from 'posthog-js'
import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
@@ -12,6 +14,7 @@ import { SignalReport, SignalReportStatus } from 'products/signals/frontend/inbo
import type { ReportPageApi } from 'products/today/frontend/generated/api.schemas'
import { todayReportLogic } from './todayReportLogic'
+import { todayReportQueueLogic } from './todayReportQueueLogic'
const PAGE: ReportPageApi = {
lead: 'Checkout fails for Safari users.',
@@ -26,6 +29,115 @@ const PAGE: ReportPageApi = {
}
describe('todayReportLogic', () => {
+ afterEach(() => {
+ jest.restoreAllMocks()
+ })
+
+ test.each([
+ [
+ 'a direct page load as a deep-link with its link source',
+ '/project/997/home/reports/b?link_source=today',
+ false,
+ false,
+ 'b',
+ 1,
+ [
+ expect.objectContaining({
+ report_id: 'b',
+ surface: 'today',
+ open_method: 'deeplink',
+ link_source: 'today',
+ list: null,
+ rank: null,
+ list_size: null,
+ }),
+ ],
+ ],
+ [
+ 'a step onto the prefetched next report with its queue position',
+ '/project/997/home/reports/a',
+ true,
+ true,
+ 'b',
+ 1,
+ [
+ expect.objectContaining({
+ report_id: 'b',
+ surface: 'today',
+ open_method: 'click',
+ source: 'step',
+ rank: 2,
+ list_size: 2,
+ }),
+ ],
+ ],
+ [
+ 'one open for each visit before the report loads',
+ '/project/997/home/reports/b?link_source=today',
+ false,
+ false,
+ 'b',
+ 2,
+ [
+ expect.objectContaining({
+ report_id: 'b',
+ open_method: 'deeplink',
+ link_source: 'today',
+ }),
+ expect.objectContaining({
+ report_id: 'b',
+ open_method: 'deeplink',
+ link_source: null,
+ }),
+ ],
+ ],
+ ['no open for a sample report', '/project/997/home/reports/sample-pr', false, false, 'sample-pr', 1, []],
+ ])('sends %s', async (_, path, step, prefetched, reportId, visits, opens) => {
+ useMocks({
+ get: {
+ '/api/projects/:team_id/signals/reports/': {
+ results: [makeReport({ id: 'a' }), makeReport({ id: 'b' })],
+ count: 2,
+ },
+ '/api/projects/:team_id/signals/reports/:id/': ({ params }) => [
+ 200,
+ makeReport({ id: params.id as string }),
+ ],
+ '/api/projects/:team_id/today/reports/:id/page/': () => [200, PAGE],
+ '/api/projects/:team_id/today/briefing/': () => [404, {}],
+ },
+ })
+ initKeaTests()
+ const capture = jest.spyOn(posthog, 'capture')
+ const sentOpens = (): unknown[] =>
+ capture.mock.calls.filter(([event]) => event === 'Inbox report opened').map(([, props]) => props)
+ const queueLogic = todayReportQueueLogic()
+ queueLogic.mount()
+ router.actions.push(path)
+ await expectLogic(queueLogic).toFinishAllListeners()
+
+ const logic = todayReportLogic({ reportId })
+ logic.mount()
+ if (prefetched) {
+ await expectLogic(logic).toDispatchActions(['loadFullReportSuccess']).toFinishAllListeners()
+ }
+ // The report page prefetches its neighbors, and a prefetch is not a visit.
+ expect(sentOpens()).toEqual([])
+ if (step) {
+ queueLogic.actions.openAdjacentReport(1)
+ }
+ for (let visit = 0; visit < visits; visit++) {
+ logic.actions.reportVisited()
+ }
+ await expectLogic(logic)
+ .toDispatchActions(prefetched ? [] : ['loadFullReportSuccess'])
+ .toFinishAllListeners()
+
+ expect(sentOpens()).toEqual(opens)
+ // A copied address bar must not carry the link source to the next reader.
+ expect(router.values.searchParams.link_source).toBeUndefined()
+ })
+
test.each([
[
'implements a report that is ready to act on',
diff --git a/frontend/src/scenes/project-homepage/today/todayReportLogic.ts b/frontend/src/scenes/project-homepage/today/todayReportLogic.ts
index 1c993b52e23a..10bed5a447e3 100644
--- a/frontend/src/scenes/project-homepage/today/todayReportLogic.ts
+++ b/frontend/src/scenes/project-homepage/today/todayReportLogic.ts
@@ -1,5 +1,6 @@
import { MakeLogicType, actions, afterMount, connect, kea, key, listeners, path, props, reducers, selectors } from 'kea'
import { loaders } from 'kea-loaders'
+import { router } from 'kea-router'
import posthog from 'posthog-js'
import api from 'lib/api'
@@ -11,7 +12,13 @@ import { urls } from 'scenes/urls'
import { businessKnowledgeRepositoriesFileRetrieve } from 'products/business_knowledge/frontend/generated/api'
import type { RepositoryFileApi } from 'products/business_knowledge/frontend/generated/api.schemas'
-import { captureInboxReportAction, discussQuestionProperties } from 'products/signals/frontend/inbox/inboxAnalytics'
+import {
+ type InboxReportLinkSource,
+ captureInboxReportAction,
+ captureTodayReportOpened,
+ discussQuestionProperties,
+ parseInboxReportLinkSource,
+} from 'products/signals/frontend/inbox/inboxAnalytics'
import { inboxTaskKickoffLogic } from 'products/signals/frontend/inbox/inboxTaskKickoffLogic'
import { SignalReport } from 'products/signals/frontend/inbox/types'
import {
@@ -37,7 +44,13 @@ import {
import { type TodaySignalDestination } from './todayEvidence'
import { type TodayMarkedFigure, markedFigures, staleEvidenceDate } from './todayFigureSources'
import { TodayImpactNumber, impactNumbers } from './todayImpact'
-import { type TodayAskSource, todayLogic } from './todayLogic'
+import {
+ type TodayAskSource,
+ type TodayReportOpenContext,
+ reportIdFromPath,
+ signalReportSnapshot,
+ todayLogic,
+} from './todayLogic'
import { reportWorkKind, reportWorkPrompt } from './todayNextStep'
import { TodayCodeQuote, codeIdentifiers, findCodeQuote } from './todayQuotedCode'
import { type TodayReportState, reportState } from './todayReportState'
@@ -57,12 +70,19 @@ export interface TodayReportLogicProps {
reportId: string
}
+/** A visit whose `Inbox report opened` event waits for the report to load. */
+interface TodayPendingOpen {
+ context: TodayReportOpenContext | null
+ linkSource: InboxReportLinkSource | null
+}
+
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface todayReportLogicValues {
featureFlags: FeatureFlagsSet // featureFlagLogic
currentProjectId: number | string // teamLogic
currentTeamId: number | null // teamLogic
askingAi: boolean // todayLogic
+ reportOpenContext: TodayReportOpenContext | null // todayLogic
reports: SignalReport[] // todayLogic
reportStateOverrides: Record<string, TodayReportState> // todayVerdictLogic
asksJev: boolean
@@ -139,6 +159,9 @@ export interface todayReportLogicActions {
report: SignalReport | undefined
source: TodayAskSource
} // todayLogic
+ setReportOpenContext: (context: TodayReportOpenContext | null) => {
+ context: TodayReportOpenContext | null
+ } // todayLogic
askAboutReport: (question: string) => {
question: string
}
@@ -241,6 +264,9 @@ export interface todayReportLogicActions {
files: CodeFileApi[]
signal: SignalViewApi
}
+ reportVisited: () => {
+ value: true
+ }
setDraft: (draft: string) => {
draft: string
}
@@ -296,7 +322,7 @@ export const todayReportLogic = kea<todayReportLogicType>([
teamLogic,
['currentTeamId', 'currentProjectId'],
todayLogic,
- ['reports', 'askingAi'],
+ ['reports', 'askingAi', 'reportOpenContext'],
todayVerdictLogic,
['reportStateOverrides'],
featureFlagLogic,
@@ -304,7 +330,7 @@ export const todayReportLogic = kea<todayReportLogicType>([
],
actions: [
todayLogic,
- ['askAi'],
+ ['askAi', 'setReportOpenContext'],
inboxTaskKickoffLogic,
['createPrFromReport', 'discussReport', 'openReportDiscussion'],
],
@@ -325,6 +351,7 @@ export const todayReportLogic = kea<todayReportLogicType>([
setDraft: (draft: string) => ({ draft }),
startWithPostHog: true,
markOpened: (kind: TodayMarkKind) => ({ kind }),
+ reportVisited: true,
}),
loaders(({ props, values, cache }) => ({
fullReport: [
@@ -524,8 +551,53 @@ export const todayReportLogic = kea<todayReportLogicType>([
}
return cache.fileReads.get(key)
}
+ const captureOpen = ({ context, linkSource }: TodayPendingOpen, report: SignalReport): void => {
+ if (values.isSample) {
+ return
+ }
+ captureTodayReportOpened({
+ report: signalReportSnapshot(report),
+ openMethod: context ? 'click' : 'deeplink',
+ linkSource,
+ list: context?.list ?? null,
+ rank: context?.rank ?? null,
+ listSize: context?.listSize ?? null,
+ source: context?.source ?? null,
+ })
+ }
return {
- loadFullReportSuccess: () => actions.loadKeyClauses(),
+ reportVisited: () => {
+ // A visit with no click on Today is a deep-link: a shared URL, a PostHog AI link, a refresh,
+ // or back / forward.
+ const context = values.reportOpenContext
+ const { pathname } = router.values.location
+ const { link_source: linkSource, ...searchParams } = router.values.searchParams
+ const onReportPage = reportIdFromPath(pathname) === props.reportId
+ const open: TodayPendingOpen = {
+ context: context?.reportId === props.reportId ? context : null,
+ linkSource: onReportPage ? parseInboxReportLinkSource(linkSource) : null,
+ }
+ if (context) {
+ actions.setReportOpenContext(null)
+ }
+ if (onReportPage && linkSource !== undefined) {
+ // A copied address bar must not pass the original `link_source` on to the next reader.
+ router.actions.replace(pathname, searchParams, router.values.hashParams)
+ }
+ // A prefetched neighbor already has its report, so its open goes out now.
+ if (values.fullReport && !values.fullReportLoading) {
+ captureOpen(open, values.fullReport)
+ } else {
+ // A step away and back before the fetch ends is two visits, so each one keeps its own open.
+ cache.pendingOpens = [...(cache.pendingOpens ?? []), open]
+ }
+ },
+ loadFullReportSuccess: ({ fullReport }) => {
+ actions.loadKeyClauses()
+ const opens: TodayPendingOpen[] = cache.pendingOpens ?? []
+ cache.pendingOpens = []
+ opens.forEach((open) => captureOpen(open, fullReport))
+ },
loadPageSuccess: () => {
actions.loadKeyClauses()
actions.loadFigureMarks()
diff --git a/frontend/src/scenes/project-homepage/today/todayReportQueueLogic.ts b/frontend/src/scenes/project-homepage/today/todayReportQueueLogic.ts
index d67136b4b07d..ecfae1741dac 100644
--- a/frontend/src/scenes/project-homepage/today/todayReportQueueLogic.ts
+++ b/frontend/src/scenes/project-homepage/today/todayReportQueueLogic.ts
@@ -6,7 +6,7 @@ import posthog from 'posthog-js'
import { urls } from 'scenes/urls'
import { forYouReportIds, type TodayForYouRows } from './todayForYouRows'
-import { type TodayMoreReports, todayLogic } from './todayLogic'
+import { type TodayMoreReports, type TodayReportOpenContext, todayLogic } from './todayLogic'
import { navigateWithCrossfade } from './todayViewTransition'
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -62,6 +62,9 @@ export interface todayReportQueueLogicActions {
moreReports: TodayMoreReports | null
payload?: any
} // todayLogic
+ setReportOpenContext: (context: TodayReportOpenContext | null) => {
+ context: TodayReportOpenContext | null
+ } // todayLogic
leaveReport: () => {
value: true
}
@@ -102,7 +105,7 @@ export const todayReportQueueLogic = kea<todayReportQueueLogicType>([
router,
['locationChanged'],
todayLogic,
- ['loadMoreReports', 'loadMoreReportsSuccess', 'loadMoreReportsFailure'],
+ ['loadMoreReports', 'loadMoreReportsSuccess', 'loadMoreReportsFailure', 'setReportOpenContext'],
],
})),
actions({
@@ -164,6 +167,13 @@ export const todayReportQueueLogic = kea<todayReportQueueLogicType>([
position: reportPosition,
total: reportQueueIds.length,
})
+ actions.setReportOpenContext({
+ reportId: target,
+ list: null,
+ rank: reportPosition + step,
+ listSize: reportQueueIds.length,
+ source: 'step',
+ })
router.actions.push(urls.todayReport(target))
} else if (step === 1 && canLoadMoreReports) {
cache.openNextAfterLoad = values.reportId
diff --git a/products/signals/dags/inbox_ranking/README.md b/products/signals/dags/inbox_ranking/README.md
index ca9a047ed19d..c13ef44aed63 100644
--- a/products/signals/dags/inbox_ranking/README.md
+++ b/products/signals/dags/inbox_ranking/README.md
@@ -286,6 +286,14 @@ It counts as fixed only when the window closed before the snapshot and no not-fi
The label is dated from the resolve, and a reason after the window cannot take it back, so the label only grows.
The Today home sends the same client events as the Inbox, with `surface: 'today'` and a `list` property (`briefing` or `sidebar_more`) on impressions and opens.
+The Today report page sends `Inbox report opened` once per visit, when the report loads.
+A click on a list row sends `open_method: 'click'` with the row's `list`, `rank` and `list_size`, and `source` (`list` or `more`).
+The previous / next control sends `source: 'step'`, with the position in the report queue as `rank` and the queue length as `list_size`, and no `list`.
+Every other visit (a shared URL, a PostHog AI link, a refresh, back / forward) sends `open_method: 'deeplink'` with a null `list`, `rank` and `list_size`.
+`link_source` comes from the URL, and PostHog AI writes `link_source=today` on the Today report links it shows.
+A list row opened in place sends `Inbox report action` with `action_type: 'expand_preview'`, `list` and `rank`.
+No head reads `expand_preview`, and it is not in `ACTION_TYPES`.
+Sample reports send no `Inbox` events.
Filter on `surface` where a metric must stay Inbox-only.
Today sets a verdict first and sends its optional reason in a second state call, which does not change the status.
For that call the server emits `signal_report_status_changed` with `previous_status` equal to `status` and `reason_added: true`, so the reason reaches the status-stream heads.
diff --git a/products/signals/frontend/inbox/inboxAnalytics.ts b/products/signals/frontend/inbox/inboxAnalytics.ts
index 132eb3033ff8..f8939bc46489 100644
--- a/products/signals/frontend/inbox/inboxAnalytics.ts
+++ b/products/signals/frontend/inbox/inboxAnalytics.ts
@@ -162,7 +162,7 @@ export type InboxReportFeedbackSentiment = 'positive' | 'negative'
* section), `resolve` (marking a report done without an inbox PR), `resume_discussion` (reopening the
* last Ask AI run from the report composer), `view_diff`, `show_more` (a list
* section widening its window), and the section expand/collapse pair (desktop splits those per
- * section instead).
+ * section instead). `expand_preview` is a Today list row opened in place, which no ranking head reads yet.
* Desktop-only variants we don't fire yet are intentionally omitted.
*/
export type InboxReportActionType =
@@ -184,6 +184,7 @@ export type InboxReportActionType =
| 'remove_suggested_reviewer'
| 'claim'
| 'unclaim'
+ | 'expand_preview'
/**
* Where the text of an "Ask AI" question came from. `suggested` is a scout-authored question sent as
@@ -670,18 +671,24 @@ export function captureTodayReportsImpressed(params: {
})
}
-/** The Today home version of {@link captureInboxReportOpened}. `source` is the control the person clicked. */
+/**
+ * The Today home version of {@link captureInboxReportOpened}. `source` is the control the person clicked. A deep-link
+ * has no `list`, `rank`, `list_size` or `source`.
+ */
export function captureTodayReportOpened(params: {
report: TodayReportSnapshot
- list: TodayReportList
+ openMethod: InboxReportOpenMethod
+ linkSource: InboxReportLinkSource | null
+ list: TodayReportList | null
rank: number | null
listSize: number | null
- source: string
+ source: string | null
}): void {
captureInboxEvent(INBOX_EVENTS.REPORT_OPENED, {
...todayReportProperties(params.report),
surface: 'today' satisfies InboxReportActionSurface,
- open_method: 'click' satisfies InboxReportOpenMethod,
+ open_method: params.openMethod,
+ link_source: params.linkSource,
list: params.list,
rank: params.rank,
list_size: params.listSize,