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(signals): close the inbox and scout instrumentation gaps (#75714)

Andrew Maguiredc1977f08ea5
diff --git a/frontend/src/scenes/inbox/InboxScene.tsx b/frontend/src/scenes/inbox/InboxScene.tsx
index e3a1882323d2..6e1d0a67c073 100644
--- a/frontend/src/scenes/inbox/InboxScene.tsx
+++ b/frontend/src/scenes/inbox/InboxScene.tsx
@@ -1,4 +1,5 @@
import { useActions, useValues } from 'kea'
+import { useEffect, useRef } from 'react'
import { IconArrowLeft, IconBug } from '@posthog/icons'
import { LemonButton, Tooltip } from '@posthog/lemon-ui'
@@ -23,6 +24,7 @@ import { NotActionableTab } from './components/tabs/NotActionableTab'
import { PullRequestsTab } from './components/tabs/PullRequestsTab'
import { ReportsTab } from './components/tabs/ReportsTab'
import { RunsTab } from './components/tabs/RunsTab'
+import { captureInboxPanelViewed } from './inboxAnalytics'
import { inboxSceneLogic } from './inboxSceneLogic'
import { inboxOnboardingLogic } from './logics/inboxOnboardingLogic'
import { INBOX_TAB_DESCRIPTION, InboxTabKey, SignalReport, SignalRun } from './types'
@@ -90,6 +92,27 @@ function InboxListView(): JSX.Element {
// (e.g. via a deep link) while the rail shows, or the rail and a config body would both appear.
const effectiveTab = showRail && activeTab === 'config' ? 'pulls' : activeTab
+ // Runs and Configuration don't render `InboxReportList`, so `Inbox viewed` never fires for them.
+ // Same once-per-visit guard as the report list: hold Runs until its load settles so the count is real.
+ const panelViewFiredRef = useRef<string | null>(null)
+ useEffect(() => {
+ if (effectiveTab !== 'runs' && effectiveTab !== 'config') {
+ panelViewFiredRef.current = null
+ return
+ }
+ if (effectiveTab === 'runs' && signalRunsLoading) {
+ return
+ }
+ if (panelViewFiredRef.current === effectiveTab) {
+ return
+ }
+ panelViewFiredRef.current = effectiveTab
+ captureInboxPanelViewed({
+ panel: effectiveTab,
+ itemCount: effectiveTab === 'runs' ? signalRuns.length : null,
+ })
+ }, [effectiveTab, signalRunsLoading, signalRuns.length])
+
return (
<div ref={widthRef} className="flex min-h-0 flex-1">
<div className="flex flex-col min-h-0 flex-1 min-w-0">
@@ -184,6 +207,19 @@ export function InboxScene(): JSX.Element {
// instead of remounting and resetting to the first page at the top.
const showDetail = !!selectedReportId || !!selectedScoutSkillName || isScratchpadOpen || isFindingsOpen
+ // The two scout panels replace the list without going through any tab, so they'd otherwise leave
+ // no trace at all. The scout detail reports itself (it has the config to describe).
+ useEffect(() => {
+ if (isFindingsOpen) {
+ captureInboxPanelViewed({ panel: 'findings' })
+ }
+ }, [isFindingsOpen])
+ useEffect(() => {
+ if (isScratchpadOpen) {
+ captureInboxPanelViewed({ panel: 'scratchpad' })
+ }
+ }, [isScratchpadOpen])
+
return (
<SceneContent className="gap-y-0 border-b-0 flex-1 min-h-0">
<div className={showDetail ? 'hidden' : 'flex flex-col gap-y-4 flex-1 min-h-0'}>
diff --git a/frontend/src/scenes/inbox/components/config/scouts/ScoutCreateButton.tsx b/frontend/src/scenes/inbox/components/config/scouts/ScoutCreateButton.tsx
index 54b14cf1ce7f..df761553c5ad 100644
--- a/frontend/src/scenes/inbox/components/config/scouts/ScoutCreateButton.tsx
+++ b/frontend/src/scenes/inbox/components/config/scouts/ScoutCreateButton.tsx
@@ -9,6 +9,7 @@ import { AccessControlLevel, AccessControlResourceType } from '~/types'
import type { SignalScoutCreateResponseApi } from 'products/signals/frontend/generated/api.schemas'
+import { captureScoutAction } from '../../../inboxAnalytics'
import type { ScoutCreateInitialValues } from '../../../logics/scoutCreateModalLogic'
const LazyScoutCreateModal = React.lazy(async () => {
@@ -60,7 +61,14 @@ export function ScoutCreateButton({
<LazyScoutCreateModal
isOpen
initialValues={initialValues}
- onCreated={onCreated}
+ onCreated={(scout) => {
+ captureScoutAction({
+ actionType: 'create_scout',
+ surface: 'fleet_list',
+ skillName: scout.config.skill_name,
+ })
+ onCreated?.(scout)
+ }}
onClose={() => setIsModalOpen(false)}
/>
</React.Suspense>
diff --git a/frontend/src/scenes/inbox/components/config/scouts/ScoutDetailView.tsx b/frontend/src/scenes/inbox/components/config/scouts/ScoutDetailView.tsx
index f80aa7a40e8a..cdb48370ba50 100644
--- a/frontend/src/scenes/inbox/components/config/scouts/ScoutDetailView.tsx
+++ b/frontend/src/scenes/inbox/components/config/scouts/ScoutDetailView.tsx
@@ -1,11 +1,12 @@
import { useActions, useValues } from 'kea'
-import { useEffect } from 'react'
+import { useEffect, useRef } from 'react'
import { IconArrowLeft } from '@posthog/icons'
import { LemonButton, LemonSkeleton } from '@posthog/lemon-ui'
import { pluralize } from 'lib/utils/strings'
+import { captureScoutDetailViewed } from '../../../inboxAnalytics'
import { inboxSceneLogic } from '../../../inboxSceneLogic'
import { scoutDetailLogic } from '../../../logics/scoutDetailLogic'
import { scoutFleetLogic } from '../../../logics/scoutFleetLogic'
@@ -36,6 +37,26 @@ export function ScoutDetailView({ skillName }: { skillName: string }): JSX.Eleme
const config = scoutConfigs?.find((c) => c.skill_name === skillName) ?? null
const rollup = rollups.get(skillName)
+ // Once per scout opened, as soon as its config resolves — the run rollup fills in a beat later
+ // off the polled window, so the counts are whatever had loaded by then.
+ const detailViewedForRef = useRef<string | null>(null)
+ useEffect(() => {
+ if (!config || detailViewedForRef.current === skillName) {
+ return
+ }
+ detailViewedForRef.current = skillName
+ captureScoutDetailViewed({
+ skillName,
+ scoutOrigin: config.scout_origin,
+ enabled: config.enabled,
+ emit: config.emit,
+ runIntervalMinutes: config.run_interval_minutes,
+ runCount: rollup?.runCount ?? 0,
+ failedRunCount: rollup?.failedCount ?? 0,
+ emittedSignalCount: rollup?.emittedCount ?? 0,
+ })
+ }, [skillName, config, rollup])
+
return (
<div className="flex flex-col min-h-0 flex-1 overflow-auto gap-4 px-4 py-3">
<LemonButton
diff --git a/frontend/src/scenes/inbox/components/config/scouts/ScoutEmissionCard.tsx b/frontend/src/scenes/inbox/components/config/scouts/ScoutEmissionCard.tsx
index e16301e30106..b9c7d043abed 100644
--- a/frontend/src/scenes/inbox/components/config/scouts/ScoutEmissionCard.tsx
+++ b/frontend/src/scenes/inbox/components/config/scouts/ScoutEmissionCard.tsx
@@ -9,6 +9,7 @@ import { copyToClipboard } from 'lib/utils/copyToClipboard'
import { addProjectIdIfMissing } from 'lib/utils/kea-router'
import { urls } from 'scenes/urls'
+import { captureScoutAction } from '../../../inboxAnalytics'
import { LinkedSignalReport, SignalScoutEmission, SignalScoutRunSummary } from '../../../types'
import { prettifyScoutSkillName } from '../../../utils/scoutRunsWindow'
import { SignalReportPriorityBadge } from '../../badges/SignalReportPriorityBadge'
@@ -70,12 +71,28 @@ export const ScoutEmissionCard = memo(function ScoutEmissionCard({
}, [isDeepLinked, emission.finding_id])
const copyFindingLink = (): void => {
+ captureScoutAction({
+ actionType: 'copy_finding_link',
+ surface: 'scout_detail',
+ skillName,
+ extra: { severity: emission.severity },
+ })
void copyToClipboard(
`${window.location.origin}${addProjectIdIfMissing(urls.inboxScout(skillName, emission.finding_id))}`,
'finding link'
)
}
+ const toggleExpanded = (): void => {
+ captureScoutAction({
+ actionType: expanded ? 'collapse_emission' : 'expand_emission',
+ surface: 'scout_detail',
+ skillName,
+ extra: { severity: emission.severity, run_id: run.run_id, signal_report_id: report?.id ?? null },
+ })
+ setExpanded((value) => !value)
+ }
+
return (
<div
ref={cardRef}
@@ -86,7 +103,7 @@ export const ScoutEmissionCard = memo(function ScoutEmissionCard({
<div className="flex items-center">
<button
type="button"
- onClick={() => setExpanded((value) => !value)}
+ onClick={toggleExpanded}
className="flex flex-1 items-center gap-2 px-3 py-2 text-left"
aria-expanded={expanded}
>
@@ -136,6 +153,14 @@ export const ScoutEmissionCard = memo(function ScoutEmissionCard({
<Link
to={urls.inboxReport('reports', report.id)}
className="mt-2 inline-flex max-w-full items-center gap-1 rounded bg-primary-highlight px-2 py-0.5 text-xs font-medium text-primary"
+ onClick={() =>
+ captureScoutAction({
+ actionType: 'open_linked_report',
+ surface: 'scout_detail',
+ skillName,
+ extra: { signal_report_id: report.id, severity: emission.severity },
+ })
+ }
>
<span className="shrink-0 text-muted">In report:</span>
<span className="truncate">{report.title || 'Untitled report'}</span>
@@ -157,7 +182,18 @@ export const ScoutEmissionCard = memo(function ScoutEmissionCard({
{run.task_url && (
<>
<span className="flex-1" />
- <Link to={run.task_url} className="flex items-center gap-1 font-medium shrink-0">
+ <Link
+ to={run.task_url}
+ className="flex items-center gap-1 font-medium shrink-0"
+ onClick={() =>
+ captureScoutAction({
+ actionType: 'open_task_run',
+ surface: 'scout_detail',
+ skillName,
+ extra: { run_id: run.run_id },
+ })
+ }
+ >
Open task run <IconExternal className="size-3" />
</Link>
</>
diff --git a/frontend/src/scenes/inbox/components/config/scouts/ScoutHelperSkillLinks.tsx b/frontend/src/scenes/inbox/components/config/scouts/ScoutHelperSkillLinks.tsx
index f13b22914add..3a9afd0c03ae 100644
--- a/frontend/src/scenes/inbox/components/config/scouts/ScoutHelperSkillLinks.tsx
+++ b/frontend/src/scenes/inbox/components/config/scouts/ScoutHelperSkillLinks.tsx
@@ -1,5 +1,7 @@
import { Link } from '@posthog/lemon-ui'
+import { captureScoutAction } from '../../../inboxAnalytics'
+
// General "learn more" entry point for scouts.
const SCOUTS_DOCS_URL = 'https://posthog.com/docs/self-driving/scouts'
@@ -27,7 +29,17 @@ export function ScoutHelperSkillLinks(): JSX.Element {
{HELPER_SKILLS.map((skill, index) => (
<span key={skill.label}>
{index > 0 ? ' · ' : null}
- <Link to={skill.url} target="_blank">
+ <Link
+ to={skill.url}
+ target="_blank"
+ onClick={() =>
+ captureScoutAction({
+ actionType: 'open_helper_skill',
+ surface: 'fleet_list',
+ extra: { helper_skill: skill.label },
+ })
+ }
+ >
{skill.label}
</Link>
</span>
diff --git a/frontend/src/scenes/inbox/components/config/scouts/ScoutRowCard.tsx b/frontend/src/scenes/inbox/components/config/scouts/ScoutRowCard.tsx
index 64ea9bcf8273..b30a160c461f 100644
--- a/frontend/src/scenes/inbox/components/config/scouts/ScoutRowCard.tsx
+++ b/frontend/src/scenes/inbox/components/config/scouts/ScoutRowCard.tsx
@@ -13,6 +13,7 @@ import type {
SignalScoutConfigApi as SignalScoutConfig,
} from 'products/signals/frontend/generated/api.schemas'
+import { captureScoutAction } from '../../../inboxAnalytics'
import {
dailyCronToTime,
formatRunIntervalShort,
@@ -53,6 +54,8 @@ export function ScoutRowCard({
const [settingsOpen, setSettingsOpen] = useState(false)
const { closeSetupModal } = useActions(agentSetupModalLogic)
const displayName = prettifyScoutSkillName(config.skill_name)
+ // The same card is both a fleet row and the detail page header, and the two read very differently.
+ const surface = asHeader ? 'scout_detail' : 'fleet_list'
// What the scout investigates, from the skill frontmatter — surfaced on hover over the name.
const description = config.description?.trim()
@@ -114,6 +117,13 @@ export function ScoutRowCard({
subtle
className="text-muted"
aria-label={`Open the ${config.skill_name} skill`}
+ onClick={() =>
+ captureScoutAction({
+ actionType: 'open_skill_in_posthog',
+ surface,
+ skillName: config.skill_name,
+ })
+ }
>
<IconArrowUpRight className="size-3.5" />
</Link>
@@ -152,7 +162,14 @@ export function ScoutRowCard({
size="small"
icon={<IconGear />}
active={settingsOpen}
- onClick={() => setSettingsOpen((value) => !value)}
+ onClick={() => {
+ captureScoutAction({
+ actionType: settingsOpen ? 'close_settings' : 'open_settings',
+ surface,
+ skillName: config.skill_name,
+ })
+ setSettingsOpen((value) => !value)
+ }}
aria-label={`${config.skill_name} settings`}
/>
</Tooltip>
diff --git a/frontend/src/scenes/inbox/components/config/scouts/ScoutRunHistorySection.tsx b/frontend/src/scenes/inbox/components/config/scouts/ScoutRunHistorySection.tsx
index 365112c32067..e769e8bcd084 100644
--- a/frontend/src/scenes/inbox/components/config/scouts/ScoutRunHistorySection.tsx
+++ b/frontend/src/scenes/inbox/components/config/scouts/ScoutRunHistorySection.tsx
@@ -8,6 +8,7 @@ import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'
import { pluralize } from 'lib/utils/strings'
import { urls } from 'scenes/urls'
+import { captureScoutAction } from '../../../inboxAnalytics'
import { scoutFleetLogic } from '../../../logics/scoutFleetLogic'
import { SignalScoutRunSummary } from '../../../types'
import {
@@ -31,6 +32,15 @@ const FILTERS: { value: ScoutRunFilter; label: string }[] = [
{ value: 'failed', label: 'Failed' },
]
+function captureOpenLinkedReport(skillName: string, reportId: string, relationship: 'authored' | 'edited'): void {
+ captureScoutAction({
+ actionType: 'open_linked_report',
+ surface: 'scout_detail',
+ skillName,
+ extra: { signal_report_id: reportId, report_relationship: relationship },
+ })
+}
+
/** Truncated mono id (run ids are long ULIDs; only the leading chunk earns a row footer). */
function truncateId(value: string): string {
return value.length > 12 ? `${value.slice(0, 12)}…` : value
@@ -60,7 +70,13 @@ function RunGlyph({ run }: { run: SignalScoutRunSummary }): JSX.Element {
* Memoized because the 60s runs-window poll re-renders the whole history list; `loadRunsWindow`
* reconciles run identity (see `reconcileById`) so unchanged runs keep their reference and skip here.
*/
-const ScoutRunRow = memo(function ScoutRunRow({ run }: { run: SignalScoutRunSummary }): JSX.Element {
+const ScoutRunRow = memo(function ScoutRunRow({
+ run,
+ skillName,
+}: {
+ run: SignalScoutRunSummary
+ skillName: string
+}): JSX.Element {
const [expanded, setExpanded] = useState(false)
const now = new Date()
const status = normalizeRunStatus(run.status)
@@ -75,7 +91,15 @@ const ScoutRunRow = memo(function ScoutRunRow({ run }: { run: SignalScoutRunSumm
<div className="flex flex-col rounded border border-primary bg-bg-light">
<button
type="button"
- onClick={() => setExpanded((value) => !value)}
+ onClick={() => {
+ captureScoutAction({
+ actionType: expanded ? 'collapse_run' : 'expand_run',
+ surface: 'scout_detail',
+ skillName,
+ extra: { run_id: run.run_id, run_status: status, emitted_count: emitted },
+ })
+ setExpanded((value) => !value)
+ }}
className="flex items-center gap-2 px-3 py-2 text-left"
aria-expanded={expanded}
>
@@ -128,6 +152,7 @@ const ScoutRunRow = memo(function ScoutRunRow({ run }: { run: SignalScoutRunSumm
key={reportId}
to={urls.inboxReport('reports', reportId)}
className="flex items-center gap-1 font-medium shrink-0"
+ onClick={() => captureOpenLinkedReport(skillName, reportId, 'authored')}
>
Authored report <IconArrowRight className="size-3" />
</Link>
@@ -137,6 +162,7 @@ const ScoutRunRow = memo(function ScoutRunRow({ run }: { run: SignalScoutRunSumm
key={reportId}
to={urls.inboxReport('reports', reportId)}
className="flex items-center gap-1 font-medium shrink-0"
+ onClick={() => captureOpenLinkedReport(skillName, reportId, 'edited')}
>
Edited report <IconArrowRight className="size-3" />
</Link>
@@ -144,7 +170,18 @@ const ScoutRunRow = memo(function ScoutRunRow({ run }: { run: SignalScoutRunSumm
{run.task_url && (
<>
<span className="flex-1" />
- <Link to={run.task_url} className="flex items-center gap-1 font-medium shrink-0">
+ <Link
+ to={run.task_url}
+ className="flex items-center gap-1 font-medium shrink-0"
+ onClick={() =>
+ captureScoutAction({
+ actionType: 'open_task_run',
+ surface: 'scout_detail',
+ skillName,
+ extra: { run_id: run.run_id, run_status: status },
+ })
+ }
+ >
Open task run <IconExternal className="size-3" />
</Link>
</>
@@ -198,7 +235,18 @@ export function ScoutRunHistorySection({ skillName }: { skillName: string }): JS
size="xsmall"
type="tertiary"
active={filter === entry.value}
- onClick={() => setFilter(entry.value)}
+ onClick={() => {
+ captureScoutAction({
+ actionType: 'filter_runs',
+ surface: 'scout_detail',
+ skillName,
+ extra: {
+ filter: entry.value,
+ filter_match_count: filterCounts.get(entry.value) ?? 0,
+ },
+ })
+ setFilter(entry.value)
+ }}
>
{entry.label} {filterCounts.get(entry.value) ?? 0}
</LemonButton>
@@ -218,7 +266,7 @@ export function ScoutRunHistorySection({ skillName }: { skillName: string }): JS
) : (
<>
{filteredRuns.map((run) => (
- <ScoutRunRow key={run.run_id} run={run} />
+ <ScoutRunRow key={run.run_id} run={run} skillName={skillName} />
))}
{!runsWindowComplete && (
<span className="text-xs text-muted">
diff --git a/frontend/src/scenes/inbox/components/config/scouts/ScoutsFleetSection.tsx b/frontend/src/scenes/inbox/components/config/scouts/ScoutsFleetSection.tsx
index 15b1e44a47b6..bd45d0bd7d8f 100644
--- a/frontend/src/scenes/inbox/components/config/scouts/ScoutsFleetSection.tsx
+++ b/frontend/src/scenes/inbox/components/config/scouts/ScoutsFleetSection.tsx
@@ -1,5 +1,5 @@
import { useActions, useValues } from 'kea'
-import { useEffect } from 'react'
+import { useEffect, useRef } from 'react'
import { IconCompass, IconSparkles } from '@posthog/icons'
import { LemonBanner, LemonButton, LemonSkeleton } from '@posthog/lemon-ui'
@@ -10,6 +10,7 @@ import { pluralize } from 'lib/utils/strings'
import type { SignalScoutConfigApi as SignalScoutConfig } from 'products/signals/frontend/generated/api.schemas'
+import { captureScoutAction, captureScoutFleetViewed } from '../../../inboxAnalytics'
import { inboxSceneLogic } from '../../../inboxSceneLogic'
import { scoutFleetLogic } from '../../../logics/scoutFleetLogic'
import {
@@ -34,7 +35,7 @@ import { ScoutSuggestButton } from './ScoutSuggestButton'
* Cloud port of desktop's `ScoutsFleetSection`.
*/
export function ScoutsFleetSection(): JSX.Element {
- const { scoutConfigs, scoutConfigsLoading } = useValues(scoutFleetLogic)
+ const { scoutConfigs, scoutConfigsLoading, enabledCount, customScoutCount } = useValues(scoutFleetLogic)
const { loadScoutConfigs, startRunsPolling, stopRunsPolling } = useActions(scoutFleetLogic)
const { setScratchpadOpen, setFindingsOpen } = useActions(inboxSceneLogic)
const { closeSetupModal } = useActions(agentSetupModalLogic)
@@ -46,6 +47,22 @@ export function ScoutsFleetSection(): JSX.Element {
return () => stopRunsPolling()
}, [startRunsPolling, stopRunsPolling])
+ // Roster shape once per opening, the first time the fleet resolves. A failed load stays `null`
+ // and reports nothing — an unreachable scout API isn't an empty troop.
+ const fleetViewedFiredRef = useRef(false)
+ useEffect(() => {
+ if (scoutConfigs === null || fleetViewedFiredRef.current) {
+ return
+ }
+ fleetViewedFiredRef.current = true
+ captureScoutFleetViewed({
+ scoutCount: scoutConfigs.length,
+ enabledCount,
+ customCount: customScoutCount,
+ dryRunCount: scoutConfigs.filter((config) => !config.emit).length,
+ })
+ }, [scoutConfigs, enabledCount, customScoutCount])
+
if (scoutConfigsLoading && scoutConfigs === null) {
return <LemonSkeleton className="h-12 w-full rounded" />
}
@@ -81,6 +98,7 @@ export function ScoutsFleetSection(): JSX.Element {
<FleetStatsHeader />
<FleetFindingsCallout
onOpen={() => {
+ captureScoutAction({ actionType: 'open_findings', surface: 'fleet_list' })
// This section can render inside the scout-troop setup modal; dismiss it so the
// findings view isn't left hidden behind the portal'd modal. No-op outside a modal.
closeSetupModal()
@@ -89,6 +107,7 @@ export function ScoutsFleetSection(): JSX.Element {
/>
<FleetMemoryCallout
onOpen={() => {
+ captureScoutAction({ actionType: 'open_memory', surface: 'fleet_list' })
// This section can render inside the scout-troop setup modal; dismiss it so the
// memory view isn't left hidden behind the portal'd modal. No-op outside a modal.
closeSetupModal()
@@ -185,7 +204,18 @@ function ScoutsFleetList(): JSX.Element {
<ScoutChatCta label="How is my scout troop performing?" prompt={SCOUT_FLEET_OVERVIEW_PROMPT} />
<ScoutChatCta label="What signals were emitted recently?" prompt={SCOUT_RECENT_SIGNALS_PROMPT} />
<span className="flex-1" />
- <LemonButton size="xsmall" type="tertiary" onClick={() => setHideDisabled(!hideDisabled)}>
+ <LemonButton
+ size="xsmall"
+ type="tertiary"
+ onClick={() => {
+ captureScoutAction({
+ actionType: 'toggle_hide_disabled',
+ surface: 'fleet_list',
+ extra: { hide_disabled: !hideDisabled },
+ })
+ setHideDisabled(!hideDisabled)
+ }}
+ >
{hideDisabled ? 'Show disabled' : 'Hide disabled'}
</LemonButton>
</div>
diff --git a/frontend/src/scenes/inbox/components/detail/DetailSection.tsx b/frontend/src/scenes/inbox/components/detail/DetailSection.tsx
index 4ed5c0d36608..5582f570bd12 100644
--- a/frontend/src/scenes/inbox/components/detail/DetailSection.tsx
+++ b/frontend/src/scenes/inbox/components/detail/DetailSection.tsx
@@ -21,6 +21,8 @@ interface DetailSectionProps {
collapsible?: boolean
/** Start collapsed (only honoured when `collapsible`). */
defaultCollapsed?: boolean
+ /** Called with the new collapsed state whenever the header toggle is pressed. */
+ onToggleCollapsed?: (collapsed: boolean) => void
}
/**
@@ -39,10 +41,17 @@ export function DetailSection({
children,
collapsible = false,
defaultCollapsed = false,
+ onToggleCollapsed,
}: DetailSectionProps): JSX.Element {
const [collapsed, setCollapsed] = useState(defaultCollapsed)
const open = !collapsible || !collapsed
+ const toggle = (): void => {
+ const next = !collapsed
+ setCollapsed(next)
+ onToggleCollapsed?.(next)
+ }
+
const headerRow = (
<div className="flex flex-1 items-center gap-3 min-w-0">
<div className="flex items-center gap-2 min-w-0">
@@ -67,7 +76,7 @@ export function DetailSection({
type="tertiary"
size="small"
fullWidth
- onClick={() => setCollapsed((c) => !c)}
+ onClick={toggle}
aria-expanded={open}
sideIcon={open ? <IconCollapse /> : <IconExpand />}
// `-my-px` trims the small button's extra height so its baseline matches the
diff --git a/frontend/src/scenes/inbox/components/detail/ReportDetail.tsx b/frontend/src/scenes/inbox/components/detail/ReportDetail.tsx
index c196466b4fe1..cc13430d183b 100644
--- a/frontend/src/scenes/inbox/components/detail/ReportDetail.tsx
+++ b/frontend/src/scenes/inbox/components/detail/ReportDetail.tsx
@@ -13,6 +13,7 @@ import { addProjectIdIfMissing } from 'lib/utils/kea-router'
import { SignalNode } from 'scenes/debug/signals/types'
import { urls } from 'scenes/urls'
+import { captureInboxReportAction } from '../../inboxAnalytics'
import { inboxReportDetailLogic } from '../../logics/inboxReportDetailLogic'
import { SignalCard } from '../../SignalCard'
import { InboxTabKey, INBOX_TAB_LABEL, SignalReport, SignalReportStatus, SignalSourceProduct } from '../../types'
@@ -326,6 +327,15 @@ export function InboxDetailFrame({
[chartPlacements]
)
+ // Reading depth on the report body: which supporting sections a reader actually opened.
+ const captureSectionToggle = (section: string) => (collapsed: boolean) =>
+ captureInboxReportAction({
+ report,
+ actionType: collapsed ? 'collapse_section' : 'expand_section',
+ surface: 'detail_pane',
+ extra: { section },
+ })
+
const conventionalTitle = parseConventionalCommitTitle(report.title)
const displayTitle = displayConventionalCommitTitle(report.title, 'Untitled report')
// Absolute URL to this report – seeded into the Discuss prompt so the agent can open and read
@@ -349,7 +359,12 @@ export function InboxDetailFrame({
<BindLogic logic={inboxReportDetailLogic} props={logicProps}>
<div className="grid grid-cols-1 @5xl:grid-cols-[minmax(0,80ch)_minmax(22rem,1fr)] gap-5">
<div className="min-w-0 flex flex-col gap-5">
- <DetailSection icon={summary.icon} title={summary.title} collapsible>
+ <DetailSection
+ icon={summary.icon}
+ title={summary.title}
+ collapsible
+ onToggleCollapsed={captureSectionToggle('summary')}
+ >
{report.summary ? (
<LemonMarkdown
className="text-sm text-secondary leading-relaxed break-words [&>*+*]:mt-3 [&_[data-attr=report-chart]]:my-5 [&_li]:my-1 [&_ul]:my-2 [&_ol]:my-2 [&_h1]:mt-5 [&_h2]:mt-5 [&_h3]:mt-4"
@@ -386,6 +401,7 @@ export function InboxDetailFrame({
icon={<IconSearch />}
title="Evidence"
collapsible
+ onToggleCollapsed={captureSectionToggle('evidence')}
rightSlot={
<Tooltip title={FINDINGS_TOOLTIP}>
<span className="text-[0.6875rem] text-tertiary tabular-nums cursor-help">
@@ -495,7 +511,14 @@ export function InboxDetailFrame({
{hasDiff ? (
<LemonTabs
activeKey={activeDetailTab}
- onChange={setActiveDetailTab}
+ onChange={(key) => {
+ setActiveDetailTab(key)
+ // Reviewing the diff is the deepest engagement a report gets short of acting
+ // on it, and it's the one desktop can't see either.
+ if (key === 'files') {
+ captureInboxReportAction({ report, actionType: 'view_diff', surface: 'detail_pane' })
+ }
+ }}
tabs={[
{ key: 'overview', label: 'Overview', content: overviewBody },
{
@@ -568,6 +591,9 @@ export function ReportDetail({ report, tab }: { report: SignalReport; tab: Inbox
to={prFilesUrl(prUrl)}
targetBlank
tooltip={`${prRef.repoSlug}#${prRef.number}`}
+ onClick={() =>
+ captureInboxReportAction({ report, actionType: 'open_pr', surface: 'detail_pane' })
+ }
>
Open in GitHub
</LemonButton>
diff --git a/frontend/src/scenes/inbox/inboxAnalytics.test.ts b/frontend/src/scenes/inbox/inboxAnalytics.test.ts
index 022aa585ff67..2d61b06ce1c3 100644
--- a/frontend/src/scenes/inbox/inboxAnalytics.test.ts
+++ b/frontend/src/scenes/inbox/inboxAnalytics.test.ts
@@ -1,9 +1,12 @@
import posthog from 'posthog-js'
import {
+ captureInboxQueryChanged,
captureInboxReportAction,
captureInboxReportsImpressed,
+ captureInboxSettingsChanged,
captureInboxViewed,
+ captureScoutConfigChanged,
captureSignalSourceConnected,
INBOX_EVENTS,
} from './inboxAnalytics'
@@ -154,6 +157,68 @@ describe('inboxAnalytics', () => {
})
})
+ it('records how the query moved without shipping what was typed into the search box', () => {
+ captureInboxQueryChanged({
+ change: 'search',
+ tab: 'reports',
+ scope: 'entire-project',
+ sortField: 'created_at',
+ sortDirection: 'desc',
+ sourceProductFilter: ['error_tracking'],
+ scoutFilter: [],
+ priorityFilter: ['P0'],
+ searchQuery: ' acme checkout crash ',
+ hasActiveFilters: true,
+ })
+ const props = lastCapture(INBOX_EVENTS.QUERY_CHANGED)
+ expect(props).toMatchObject({
+ change: 'search',
+ tab: 'reports',
+ scope: 'entire-project',
+ sort_field: 'created_at',
+ source_product_filter: ['error_tracking'],
+ has_search: true,
+ search_length: 'acme checkout crash'.length,
+ })
+ expect(JSON.stringify(props)).not.toContain('acme')
+ })
+
+ // A settings value can be a collection of the customer's own names — the base-branch overrides
+ // map their repositories, a Slack destination names their channel. Only its size may leave.
+ it.each<[string, unknown, unknown, number | null]>([
+ ['a scalar', false, false, null],
+ ['a repo map', { 'acme/web': 'release', 'acme/api': 'main' }, null, 2],
+ ['an empty map', {}, null, 0],
+ ])('sends %s as a settings value', (_name, newValue, expectedValue, expectedSize) => {
+ captureInboxSettingsChanged({ setting: 'autostart_base_branches', newValue, success: true, scope: 'team' })
+ const props = lastCapture(INBOX_EVENTS.SETTINGS_CHANGED)
+ expect(props).toMatchObject({ new_value: expectedValue, new_value_size: expectedSize })
+ expect(JSON.stringify(props)).not.toContain('acme')
+ })
+
+ it('reduces a structured scout setting to its size on both sides of the change', () => {
+ captureScoutConfigChanged({
+ skillName: 'signals-scout-general',
+ scoutOrigin: 'canonical',
+ setting: 'output_destinations',
+ oldValue: {},
+ newValue: { slack: { integration_id: 3, channel: 'acme-alerts' } },
+ success: true,
+ })
+ const props = lastCapture(INBOX_EVENTS.SCOUT_CONFIG_CHANGED)
+ expect(props).toMatchObject({
+ skill_name: 'signals-scout-general',
+ scout_origin: 'canonical',
+ setting: 'output_destinations',
+ old_value: null,
+ old_value_size: 0,
+ new_value: null,
+ new_value_size: 1,
+ success: true,
+ })
+ expect(JSON.stringify(props)).not.toContain('acme-alerts')
+ })
+
it('records a connected source with first-connection and wizard flags', () => {
captureSignalSourceConnected({
sourceProduct: 'github',
diff --git a/frontend/src/scenes/inbox/inboxAnalytics.ts b/frontend/src/scenes/inbox/inboxAnalytics.ts
index 3dd22e6d9976..994dabac120c 100644
--- a/frontend/src/scenes/inbox/inboxAnalytics.ts
+++ b/frontend/src/scenes/inbox/inboxAnalytics.ts
@@ -14,14 +14,26 @@ export const INBOX_CLIENT = 'cloud' as const
export const INBOX_EVENTS = {
VIEWED: 'Inbox viewed',
+ PANEL_VIEWED: 'Inbox panel viewed',
+ QUERY_CHANGED: 'Inbox query changed',
REPORTS_IMPRESSED: 'Inbox reports impressed',
REPORT_OPENED: 'Inbox report opened',
REPORT_CLOSED: 'Inbox report closed',
REPORT_ACTION: 'Inbox report action',
+ REPORT_ACTION_COMPLETED: 'Inbox report action completed',
REPORT_FEEDBACK: 'Inbox report feedback',
REPORT_FEEDBACK_NOTE: 'Inbox report feedback note',
+ SETTINGS_CHANGED: 'Inbox settings changed',
SOURCE_CONNECTED: 'Signal source connected',
+ SOURCE_DISABLED: 'Signal source disabled',
SOURCE_INTEREST: 'signals source interest',
+ // Scout-troop management. Names and property shapes match the desktop app one-for-one so both
+ // clients union in one project; desktop sends no `inbox_client`, so its rows read as null.
+ SCOUT_FLEET_VIEWED: 'Scout fleet viewed',
+ SCOUT_DETAIL_VIEWED: 'Scout detail viewed',
+ SCOUT_CONFIG_CHANGED: 'Scout config changed',
+ SCOUT_ACTION: 'Scout action',
+ SCOUT_CHAT_STARTED: 'Scout chat started',
} as const
type InboxEvent = (typeof INBOX_EVENTS)[keyof typeof INBOX_EVENTS]
@@ -40,8 +52,9 @@ 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
- * Archive tab. Desktop-only variants we don't fire yet are intentionally omitted.
+ * `action_type` breakdown reads the same across clients), plus cloud-only `restore` (Archive tab),
+ * `view_diff`, and the section expand/collapse pair (desktop splits those per section instead).
+ * Desktop-only variants we don't fire yet are intentionally omitted.
*/
export type InboxReportActionType =
| 'dismiss'
@@ -49,9 +62,56 @@ export type InboxReportActionType =
| 'restore'
| 'create_pr'
| 'refund'
+ | 'open_pr'
+ | 'view_diff'
+ | 'expand_section'
+ | 'collapse_section'
| 'add_suggested_reviewer'
| 'remove_suggested_reviewer'
+/**
+ * Whether a task-kickoff action (`discuss` / `create_pr`) actually produced a task. The press itself
+ * is already an {@link captureInboxReportAction} event; without the outcome the two are
+ * indistinguishable, so an attempted PR counts the same as a created one.
+ */
+export type InboxReportActionOutcome = 'success' | 'failure' | 'blocked'
+
+/** Panels that replace the report list and so never fire `Inbox viewed`. */
+export type InboxPanelName = 'runs' | 'config' | 'scratchpad' | 'findings'
+
+/** Which control moved the report list to a new query. `url` is a shared/deep link being applied. */
+export type InboxQueryChange = 'scope' | 'sort' | 'source_product' | 'scout' | 'priority' | 'search' | 'clear' | 'url'
+
+/** Surface a scout-management event fired from. Matches the desktop values. */
+export type ScoutSurface = 'fleet_list' | 'scout_detail' | 'empty_state'
+
+/**
+ * Scout-management actions. The first block matches desktop's enum; the trailing three are
+ * cloud-only, covering affordances desktop doesn't have (creating and deleting scouts, and the
+ * scratchpad callout).
+ */
+export type ScoutActionType =
+ | 'open_settings'
+ | 'close_settings'
+ | 'open_skill_in_posthog'
+ | 'open_helper_skill'
+ | 'open_findings'
+ | 'toggle_hide_disabled'
+ | 'expand_run'
+ | 'collapse_run'
+ | 'filter_runs'
+ | 'expand_emission'
+ | 'collapse_emission'
+ | 'copy_finding_link'
+ | 'open_task_run'
+ | 'open_linked_report'
+ | 'create_scout'
+ | 'delete_scout'
+ | 'open_memory'
+
+/** What a scout chat CTA was asking for. Matches the desktop values. */
+export type ScoutChatType = 'author_scout' | 'fleet_overview' | 'recent_signals'
+
function captureInboxEvent(event: InboxEvent, properties: Record<string, unknown>): void {
posthog.capture(event, { inbox_client: INBOX_CLIENT, ...properties })
}
@@ -287,6 +347,211 @@ export function captureSignalSourceConnected(params: {
})
}
+/**
+ * A source switched off. Its own event rather than an `enabled` flag on
+ * {@link captureSignalSourceConnected}, so existing connection counts keep meaning connections —
+ * turning a source off is the shape of churn, not a negative connection.
+ */
+export function captureSignalSourceDisabled(params: { sourceProduct: string; sourceType: string }): void {
+ captureInboxEvent(INBOX_EVENTS.SOURCE_DISABLED, {
+ source_product: params.sourceProduct,
+ source_type: params.sourceType,
+ })
+}
+
export function captureSignalSourceInterest(source: string): void {
captureInboxEvent(INBOX_EVENTS.SOURCE_INTEREST, { source })
}
+
+/**
+ * Outcome of a task-kickoff action, fired once the request settles. Pairs with the press event on
+ * `report_id` + `action_type`. `blocked` means we never issued the request (no AI consent), which is
+ * a product problem rather than a failure — hence its own bucket.
+ */
+export function captureInboxReportActionCompleted(params: {
+ report: SignalReport
+ actionType: InboxReportActionType
+ outcome: InboxReportActionOutcome
+ /** Only set for `blocked`, and only ever our own consent copy — never a server error body. */
+ blockedReason?: string | null
+}): void {
+ captureInboxEvent(INBOX_EVENTS.REPORT_ACTION_COMPLETED, {
+ ...baseReportProperties(params.report),
+ action_type: params.actionType,
+ outcome: params.outcome,
+ ...(params.blockedReason ? { blocked_reason: params.blockedReason } : {}),
+ })
+}
+
+/**
+ * A surface that replaces the report list (Runs, Configuration, and the two scout panels). None of
+ * them render `InboxReportList`, so without this they're invisible — `Inbox viewed` only ever fires
+ * for the flat report tabs.
+ */
+export function captureInboxPanelViewed(params: { panel: InboxPanelName; itemCount?: number | null }): void {
+ captureInboxEvent(INBOX_EVENTS.PANEL_VIEWED, {
+ panel: params.panel,
+ item_count: params.itemCount ?? null,
+ })
+}
+
+/**
+ * The list moved to a new query — a filter, sort, search, or scope change. `Inbox viewed` fires once
+ * per tab mount, so re-querying an already-open inbox left no trace at all: a user working a filtered
+ * list all day and one who arrived and sat still looked identical.
+ *
+ * The search *term* is deliberately not sent (only its length): unlike a dismissal reason, it's
+ * incidental typing that can name a customer's own entities. `change` says which control moved; the
+ * remaining properties are the resulting query, so any single event describes the full view.
+ */
+export function captureInboxQueryChanged(params: {
+ change: InboxQueryChange
+ tab: string | null
+ scope: string
+ sortField: string
+ sortDirection: string
+ sourceProductFilter: string[]
+ scoutFilter: string[]
+ priorityFilter: string[]
+ searchQuery: string
+ hasActiveFilters: boolean
+}): void {
+ const search = params.searchQuery.trim()
+ captureInboxEvent(INBOX_EVENTS.QUERY_CHANGED, {
+ change: params.change,
+ tab: params.tab,
+ scope: params.scope,
+ sort_field: params.sortField,
+ sort_direction: params.sortDirection,
+ source_product_filter: params.sourceProductFilter,
+ scout_filter: params.scoutFilter,
+ priority_filter: params.priorityFilter,
+ has_search: search.length > 0,
+ search_length: search.length,
+ has_active_filters: params.hasActiveFilters,
+ })
+}
+
+/**
+ * A team-level inbox setting was changed (self-driving autostart, Slack notifications, base-branch
+ * overrides). Fired once the request settles, so `success` distinguishes a saved change from a
+ * rejected one. `old_value` isn't carried: the patch is applied optimistically before the listener
+ * runs, so the prior value is no longer readable there — the previous event for the same `setting`
+ * is the transition.
+ */
+export function captureInboxSettingsChanged(params: {
+ setting: string
+ newValue: unknown
+ success: boolean
+ /** Whether the setting governs the whole team or just the person changing it. */
+ scope: 'team' | 'user'
+}): void {
+ captureInboxEvent(INBOX_EVENTS.SETTINGS_CHANGED, {
+ setting: params.setting,
+ ...settingValueProperties('new_value', params.newValue),
+ success: params.success,
+ setting_scope: params.scope,
+ })
+}
+
+/**
+ * A setting's value, safe to ship. Scalars go as-is; a structured value is reduced to how many
+ * entries it holds, because those carry the customer's own names — the base-branch overrides are a
+ * map of their repositories, a Slack destination names their channel.
+ */
+function settingValueProperties(key: string, value: unknown): Record<string, unknown> {
+ if (typeof value === 'object' && value !== null) {
+ return { [key]: null, [`${key}_size`]: Object.keys(value).length }
+ }
+ return { [key]: value ?? null, [`${key}_size`]: null }
+}
+
+/** Roster shape at the moment the scout troop list was opened. Mirrors desktop's `Scout fleet viewed`. */
+export function captureScoutFleetViewed(params: {
+ scoutCount: number
+ enabledCount: number
+ customCount: number
+ dryRunCount: number
+}): void {
+ captureInboxEvent(INBOX_EVENTS.SCOUT_FLEET_VIEWED, {
+ scout_count: params.scoutCount,
+ enabled_count: params.enabledCount,
+ custom_count: params.customCount,
+ dry_run_count: params.dryRunCount,
+ is_empty: params.scoutCount === 0,
+ })
+}
+
+/** One scout's detail page opened, with its config and recent-window run shape. */
+export function captureScoutDetailViewed(params: {
+ skillName: string
+ scoutOrigin: string | null
+ enabled: boolean
+ emit: boolean
+ runIntervalMinutes: number | null
+ runCount: number
+ failedRunCount: number
+ emittedSignalCount: number
+}): void {
+ captureInboxEvent(INBOX_EVENTS.SCOUT_DETAIL_VIEWED, {
+ skill_name: params.skillName,
+ scout_origin: params.scoutOrigin,
+ enabled: params.enabled,
+ emit: params.emit,
+ has_config: true,
+ run_interval_minutes: params.runIntervalMinutes,
+ run_count: params.runCount,
+ failed_run_count: params.failedRunCount,
+ emitted_signal_count: params.emittedSignalCount,
+ })
+}
+
+/**
+ * One scout setting saved. Fired per changed field — a schedule switch patches two fields at once,
+ * and rolling them into one event would make the `setting` breakdown lie about which control moved.
+ */
+export function captureScoutConfigChanged(params: {
+ skillName: string
+ scoutOrigin: string | null
+ setting: string
+ oldValue: unknown
+ newValue: unknown
+ success: boolean
+}): void {
+ captureInboxEvent(INBOX_EVENTS.SCOUT_CONFIG_CHANGED, {
+ skill_name: params.skillName,
+ scout_origin: params.scoutOrigin,
+ setting: params.setting,
+ ...settingValueProperties('old_value', params.oldValue),
+ ...settingValueProperties('new_value', params.newValue),
+ success: params.success,
+ })
+}
+
+/** Any non-config interaction on the scout surfaces — expanding a run, copying a link, opening a skill. */
+export function captureScoutAction(params: {
+ actionType: ScoutActionType
+ surface: ScoutSurface
+ skillName?: string | null
+ extra?: Record<string, unknown>
+}): void {
+ captureInboxEvent(INBOX_EVENTS.SCOUT_ACTION, {
+ action_type: params.actionType,
+ surface: params.surface,
+ skill_name: params.skillName ?? null,
+ ...params.extra,
+ })
+}
+
+/** A scout CTA kicked off a cloud task ("Suggest a scout", the fleet-overview chips). */
+export function captureScoutChatStarted(params: {
+ chatType: ScoutChatType
+ surface: ScoutSurface
+ skillName?: string | null
+}): void {
+ captureInboxEvent(INBOX_EVENTS.SCOUT_CHAT_STARTED, {
+ chat_type: params.chatType,
+ surface: params.surface,
+ skill_name: params.skillName ?? null,
+ })
+}
diff --git a/frontend/src/scenes/inbox/inboxTaskKickoffLogic.ts b/frontend/src/scenes/inbox/inboxTaskKickoffLogic.ts
index 76a5e676b155..7a2831d68835 100644
--- a/frontend/src/scenes/inbox/inboxTaskKickoffLogic.ts
+++ b/frontend/src/scenes/inbox/inboxTaskKickoffLogic.ts
@@ -16,6 +16,7 @@ import {
TaskExecutionModeEnumApi,
} from 'products/tasks/frontend/generated/api.schemas'
+import { captureInboxReportActionCompleted } from './inboxAnalytics'
import {
SIGNAL_REPORT_TASK_DISCUSSION_RELATIONSHIP,
SIGNAL_REPORT_TASK_IMPLEMENTATION_RELATIONSHIP,
@@ -207,6 +208,12 @@ export const inboxTaskKickoffLogic = kea<inboxTaskKickoffLogicType>([
// run endpoint enforces no consent of its own.
if (values.aiConsentDisabledReason) {
lemonToast.error(values.aiConsentDisabledReason)
+ captureInboxReportActionCompleted({
+ report,
+ actionType: 'discuss',
+ outcome: 'blocked',
+ blockedReason: values.aiConsentDisabledReason,
+ })
actions.discussReportFailure()
return
}
@@ -218,15 +225,23 @@ export const inboxTaskKickoffLogic = kea<inboxTaskKickoffLogicType>([
'Discuss report',
DISCUSS_RUNTIME
)
+ captureInboxReportActionCompleted({ report, actionType: 'discuss', outcome: 'success' })
actions.discussReportSuccess()
} catch (error: any) {
lemonToast.error(error?.detail || error?.message || 'Failed to start discussion')
+ captureInboxReportActionCompleted({ report, actionType: 'discuss', outcome: 'failure' })
actions.discussReportFailure()
}
},
createPrFromReport: async ({ report }) => {
if (values.aiConsentDisabledReason) {
lemonToast.error(values.aiConsentDisabledReason)
+ captureInboxReportActionCompleted({
+ report,
+ actionType: 'create_pr',
+ outcome: 'blocked',
+ blockedReason: values.aiConsentDisabledReason,
+ })
actions.createPrFailure()
return
}
@@ -238,9 +253,11 @@ export const inboxTaskKickoffLogic = kea<inboxTaskKickoffLogicType>([
'Implement report fix',
CREATE_PR_RUNTIME
)
+ captureInboxReportActionCompleted({ report, actionType: 'create_pr', outcome: 'success' })
actions.createPrSuccess()
} catch (error: any) {
lemonToast.error(error?.detail || error?.message || 'Failed to start PR task')
+ captureInboxReportActionCompleted({ report, actionType: 'create_pr', outcome: 'failure' })
actions.createPrFailure()
}
},
diff --git a/frontend/src/scenes/inbox/logics/inboxFiltersLogic.test.ts b/frontend/src/scenes/inbox/logics/inboxFiltersLogic.test.ts
index ecc3e95c7f48..9d48c4a69107 100644
--- a/frontend/src/scenes/inbox/logics/inboxFiltersLogic.test.ts
+++ b/frontend/src/scenes/inbox/logics/inboxFiltersLogic.test.ts
@@ -1,10 +1,21 @@
+/* oxlint-disable react-hooks/rules-of-hooks -- useMocks is a test helper, not a React hook */
+import { expectLogic } from 'kea-test-utils'
+import posthog from 'posthog-js'
+
+import { useMocks } from '~/mocks/jest'
+import { initKeaTests } from '~/test/init'
+
+import { INBOX_EVENTS } from '../inboxAnalytics'
import {
buildSignalReportListOrdering,
filterSearchParams,
+ inboxFiltersLogic,
InboxFilterState,
parseFilterSearchParams,
} from './inboxFiltersLogic'
+jest.mock('posthog-js')
+
const DEFAULT_STATE: InboxFilterState = {
scope: 'for-you',
sourceProductFilter: [],
@@ -93,4 +104,53 @@ describe('inboxFiltersLogic', () => {
})
})
})
+
+ describe('query-changed telemetry', () => {
+ let logic: ReturnType<typeof inboxFiltersLogic.build>
+
+ const queryChanges = (): Record<string, any>[] =>
+ (posthog.capture as jest.Mock).mock.calls
+ .filter(([name]) => name === INBOX_EVENTS.QUERY_CHANGED)
+ .map(([, props]) => props)
+
+ beforeEach(() => {
+ // Filter state persists to localStorage, which jsdom keeps between tests.
+ localStorage.clear()
+ initKeaTests()
+ useMocks({ get: { '/api/projects/:team_id/signals/reports/available_reviewers/': () => [200, {}] } })
+ ;(posthog.capture as jest.Mock).mockClear()
+ logic = inboxFiltersLogic()
+ logic.mount()
+ })
+
+ afterEach(() => {
+ logic.unmount()
+ })
+
+ it('reports a user-picked scope with the resulting query', async () => {
+ logic.actions.setScope('entire-project')
+ await expectLogic(logic).toFinishAllListeners()
+ expect(queryChanges()).toEqual([
+ expect.objectContaining({ change: 'scope', scope: 'entire-project', has_search: false }),
+ ])
+ })
+
+ // The empty-inbox auto-default picks a scope for the user. Counting it as engagement would
+ // fire this event for everyone who merely lands on an empty inbox — the exact inflation that
+ // makes `Inbox viewed` unusable as an activity signal.
+ it('stays silent when the scope is defaulted rather than chosen', async () => {
+ logic.actions.applyDefaultScope('entire-project')
+ await expectLogic(logic).toFinishAllListeners()
+ expect(queryChanges()).toEqual([])
+ })
+
+ it('collapses a typed search into one event once the box settles', async () => {
+ logic.actions.setSearchQuery('che')
+ logic.actions.setSearchQuery('checkout')
+ await expectLogic(logic).toFinishAllListeners()
+ expect(queryChanges()).toEqual([
+ expect.objectContaining({ change: 'search', has_search: true, search_length: 8 }),
+ ])
+ })
+ })
})
diff --git a/frontend/src/scenes/inbox/logics/inboxFiltersLogic.ts b/frontend/src/scenes/inbox/logics/inboxFiltersLogic.ts
index a6c097d2a0ec..ba910fc6c80b 100644
--- a/frontend/src/scenes/inbox/logics/inboxFiltersLogic.ts
+++ b/frontend/src/scenes/inbox/logics/inboxFiltersLogic.ts
@@ -7,7 +7,8 @@ import { isUUIDLike } from 'lib/utils/guards'
import { urls } from 'scenes/urls'
import { INBOX_PRIORITY_OPTIONS, INBOX_SORT_OPTIONS, INBOX_SOURCE_OPTIONS } from '../filterOptions'
-import { INBOX_SCOPE_FOR_YOU, InboxScope, SignalReportPriority } from '../types'
+import { captureInboxQueryChanged, InboxQueryChange } from '../inboxAnalytics'
+import { INBOX_SCOPE_FOR_YOU, INBOX_TAB_KEYS, InboxScope, SignalReportPriority } from '../types'
/** A teammate who can be scoped to / suggested as a reviewer. Matches the `available_reviewers` API row. */
export interface InboxReviewerOption {
@@ -95,6 +96,18 @@ export function parseFilterSearchParams(searchParams: Record<string, any>): Inbo
}
}
+/**
+ * The inbox tab in the current URL, or null off a tab route (the scout panels, or a bare `/inbox`).
+ * Read from the router rather than connected from `inboxSceneLogic`, which already connects this
+ * logic — the reverse edge would be a cycle.
+ */
+function currentInboxTab(): string | null {
+ const segments = router.values.location.pathname.split('/').filter(Boolean)
+ const inboxIndex = segments.indexOf('inbox')
+ const candidate = inboxIndex === -1 ? undefined : segments[inboxIndex + 1]
+ return candidate && (INBOX_TAB_KEYS as string[]).includes(candidate) ? candidate : null
+}
+
function sameSet(a: string[], b: string[]): boolean {
return a.length === b.length && [...a].sort().join(',') === [...b].sort().join(',')
}
@@ -310,12 +323,43 @@ export const inboxFiltersLogic = kea<inboxFiltersLogicType>([
],
}),
- listeners(({ actions }) => ({
- searchAvailableReviewers: async ({ query }, breakpoint) => {
- await breakpoint(300)
- actions.loadAvailableReviewers({ query: query.trim() || undefined })
- },
- })),
+ listeners(({ actions, values }) => {
+ // Listeners run after reducers, so `values` is already the query the user landed on.
+ const captureQueryChange = (change: InboxQueryChange): void =>
+ captureInboxQueryChanged({
+ change,
+ tab: currentInboxTab(),
+ scope: values.scope,
+ sortField: values.sortField,
+ sortDirection: values.sortDirection,
+ sourceProductFilter: values.sourceProductFilter,
+ scoutFilter: values.scoutFilter,
+ priorityFilter: values.priorityFilter,
+ searchQuery: values.searchQuery,
+ hasActiveFilters: values.hasActiveFilters,
+ })
+
+ return {
+ searchAvailableReviewers: async ({ query }, breakpoint) => {
+ await breakpoint(300)
+ actions.loadAvailableReviewers({ query: query.trim() || undefined })
+ },
+ // `applyDefaultScope` is deliberately absent — it's the empty-inbox auto-default, not a
+ // user choice, and counting it as engagement is exactly the inflation we're trying to avoid.
+ setScope: () => captureQueryChange('scope'),
+ setSort: () => captureQueryChange('sort'),
+ toggleSourceProduct: () => captureQueryChange('source_product'),
+ toggleScout: () => captureQueryChange('scout'),
+ togglePriority: () => captureQueryChange('priority'),
+ clearFilters: () => captureQueryChange('clear'),
+ setFilters: () => captureQueryChange('url'),
+ // The search box fires per keystroke; settle first so a typed phrase is one event.
+ setSearchQuery: async (_, breakpoint) => {
+ await breakpoint(600)
+ captureQueryChange('search')
+ },
+ }
+ }),
reducers({
scope: [
diff --git a/frontend/src/scenes/inbox/logics/scoutFleetLogic.ts b/frontend/src/scenes/inbox/logics/scoutFleetLogic.ts
index eb2970ecd8fe..29f21d9c2e20 100644
--- a/frontend/src/scenes/inbox/logics/scoutFleetLogic.ts
+++ b/frontend/src/scenes/inbox/logics/scoutFleetLogic.ts
@@ -28,6 +28,12 @@ import type {
import { llmSkillsNameArchiveCreate } from 'products/skills/frontend/generated/api'
import { RunSourceEnumApi, TaskExecutionModeEnumApi } from 'products/tasks/frontend/generated/api.schemas'
+import {
+ captureScoutAction,
+ captureScoutChatStarted,
+ captureScoutConfigChanged,
+ ScoutChatType,
+} from '../inboxAnalytics'
import { SignalScoutRunSummary } from '../types'
import { aiConsentDisabledReason } from '../utils/aiConsent'
import {
@@ -37,6 +43,9 @@ import {
isSettledRun,
prettifyScoutSkillName,
reconcileById,
+ SCOUT_AUTHOR_PROMPT,
+ SCOUT_FLEET_OVERVIEW_PROMPT,
+ SCOUT_RECENT_SIGNALS_PROMPT,
SCOUT_RUNS_WINDOW_HOURS,
ScoutRollup,
sortConfigsForDisplay,
@@ -45,6 +54,35 @@ import {
type SignalScoutConfig = SignalScoutConfigApi
type SignalScoutConfigUpdate = PatchedSignalScoutConfigUpdateApi
+// Which CTA a chat task came from, keyed off the templated prompt so the callers stay untouched.
+const SCOUT_CHAT_TYPES: Record<string, ScoutChatType> = {
+ [SCOUT_AUTHOR_PROMPT]: 'author_scout',
+ [SCOUT_FLEET_OVERVIEW_PROMPT]: 'fleet_overview',
+ [SCOUT_RECENT_SIGNALS_PROMPT]: 'recent_signals',
+}
+
+/**
+ * One `Scout config changed` per field the request carried. A schedule switch patches both
+ * `run_interval_minutes` and `run_cron_schedule` at once, and collapsing those into a single event
+ * would make the `setting` breakdown misreport which control the user actually moved.
+ */
+function captureScoutConfigUpdates(
+ config: SignalScoutConfig | undefined,
+ updates: SignalScoutConfigUpdate,
+ success: boolean
+): void {
+ for (const [setting, newValue] of Object.entries(updates)) {
+ captureScoutConfigChanged({
+ skillName: config?.skill_name ?? '',
+ scoutOrigin: config?.scout_origin ?? null,
+ setting,
+ oldValue: config ? (config as unknown as Record<string, unknown>)[setting] : null,
+ newValue,
+ success,
+ })
+ }
+}
+
// Fleet runs are refetched on a slow cadence so "running now" / recent emissions
// stay live without hammering the capped runs endpoint (desktop: 60s).
const RUNS_REFETCH_INTERVAL_MS = 60_000
@@ -575,7 +613,9 @@ export const scoutFleetLogic = kea<scoutFleetLogicType>([
try {
while (updatesToSend) {
const previousCronSchedule = confirmedConfig?.run_cron_schedule
+ const previousConfig = confirmedConfig
const updated = await signalsScoutConfigUpdate(String(teamId), configId, updatesToSend)
+ captureScoutConfigUpdates(previousConfig, updatesToSend, true)
confirmedConfig = updated
if (updatesToSend.run_cron_schedule === null && previousCronSchedule) {
@@ -596,6 +636,9 @@ export const scoutFleetLogic = kea<scoutFleetLogicType>([
}
} catch (error: any) {
queuedUpdatesAfterFailure = pendingUpdates.get(configId)
+ if (updatesToSend) {
+ captureScoutConfigUpdates(confirmedConfig, updatesToSend, false)
+ }
if (confirmedConfig) {
actions.patchScoutConfigLocally(configId, confirmedConfig)
}
@@ -661,8 +704,20 @@ export const scoutFleetLogic = kea<scoutFleetLogicType>([
// Remove only after the backend confirms — deletion is irreversible, so no optimistic
// drop that would have to be re-inserted (and re-sorted) on failure.
actions.removeScoutConfigLocally(configId)
+ captureScoutAction({
+ actionType: 'delete_scout',
+ surface: 'fleet_list',
+ skillName: config.skill_name,
+ extra: { scout_origin: config.scout_origin, success: true },
+ })
lemonToast.success(`Deleted ${displayName}`)
} catch (error: any) {
+ captureScoutAction({
+ actionType: 'delete_scout',
+ surface: 'fleet_list',
+ skillName: config.skill_name,
+ extra: { scout_origin: config.scout_origin, success: false },
+ })
lemonToast.error(error?.detail || error?.message || 'Failed to delete scout')
// A partial failure (skill archived but config delete failed) could desync the list
// from the backend — reload the truth so the row reflects reality.
@@ -683,6 +738,10 @@ export const scoutFleetLogic = kea<scoutFleetLogicType>([
actions.startScoutChatTaskFailure()
return
}
+ const chatType = SCOUT_CHAT_TYPES[prompt]
+ if (chatType) {
+ captureScoutChatStarted({ chatType, surface: 'fleet_list' })
+ }
try {
// Deliberately repo-less: these prompts read PostHog data over MCP and never touch
// code, while `tasks/repositories/` would hand back whichever repo sorts first across
diff --git a/frontend/src/scenes/inbox/logics/signalTeamConfigLogic.ts b/frontend/src/scenes/inbox/logics/signalTeamConfigLogic.ts
index 9c7ef94fa60d..6203c5f8931c 100644
--- a/frontend/src/scenes/inbox/logics/signalTeamConfigLogic.ts
+++ b/frontend/src/scenes/inbox/logics/signalTeamConfigLogic.ts
@@ -5,6 +5,7 @@ import { lemonToast } from '@posthog/lemon-ui'
import api from 'lib/api'
+import { captureInboxSettingsChanged } from '../inboxAnalytics'
import type { SignalReportPriority, SignalTeamConfig } from '../types'
export interface BaseBranchOverride {
@@ -249,8 +250,21 @@ export const signalTeamConfigLogic = kea<signalTeamConfigLogicType>([
},
],
}),
- listeners(({ actions, values }) => {
+ listeners(({ actions, values, cache }) => {
+ // The patch is applied optimistically before these listeners run, so the setting names are
+ // taken off the request rather than read back off state. A FIFO is enough to pair a
+ // success/failure with its patch: the loader serializes the requests, so they settle in send order.
+ const captureSettled = (success: boolean): void => {
+ const patch: Partial<SignalTeamConfig> | undefined = cache.pendingSettingPatches?.shift()
+ for (const [setting, newValue] of Object.entries(patch ?? {})) {
+ captureInboxSettingsChanged({ setting, newValue, success, scope: 'team' })
+ }
+ }
+
return {
+ patchTeamConfig: ({ patch }) => {
+ ;(cache.pendingSettingPatches ??= []).push(patch)
+ },
addBaseBranchOverride: () => {
if (values.addBaseBranchOverrideDisabledReason) {
return
@@ -280,11 +294,13 @@ export const signalTeamConfigLogic = kea<signalTeamConfigLogicType>([
actions.patchTeamConfig({ autostart_base_branches: next })
},
patchTeamConfigSuccess: ({ payload }) => {
+ captureSettled(true)
if (payload?.clearDraftOnSuccess) {
actions.clearDraftBaseBranch()
}
},
patchTeamConfigFailure: ({ error, errorObject }) => {
+ captureSettled(false)
lemonToast.error(errorObject?.detail ?? error ?? 'Failed to update team self-driving settings')
// The optimistic value is now a lie, and the server holds the truth about what stuck.
actions.loadTeamConfig()
diff --git a/frontend/src/scenes/inbox/logics/userAutonomyLogic.ts b/frontend/src/scenes/inbox/logics/userAutonomyLogic.ts
index 8e8be375dd43..cd2cac1c2208 100644
--- a/frontend/src/scenes/inbox/logics/userAutonomyLogic.ts
+++ b/frontend/src/scenes/inbox/logics/userAutonomyLogic.ts
@@ -5,6 +5,7 @@ import { lemonToast } from '@posthog/lemon-ui'
import api from 'lib/api'
+import { captureInboxSettingsChanged } from '../inboxAnalytics'
import type { SignalReportPriority, SignalUserAutonomyConfig } from '../types'
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -108,11 +109,19 @@ export const userAutonomyLogic = kea<userAutonomyLogicType>([
}),
listeners(({ actions }) => ({
setAutostartPriority: async ({ priority }) => {
+ let success = true
try {
await api.signalUserAutonomy.update({ autostart_priority: priority })
} catch (error: any) {
+ success = false
lemonToast.error(error?.detail ?? error?.message ?? 'Failed to update auto-start threshold')
} finally {
+ captureInboxSettingsChanged({
+ setting: 'autostart_priority',
+ newValue: priority,
+ success,
+ scope: 'user',
+ })
actions.loadAutonomyConfig()
}
},
@@ -128,11 +137,23 @@ export const userAutonomyLogic = kea<userAutonomyLogicType>([
if ('minPriority' in updates) {
body.slack_notification_min_priority = updates.minPriority ?? null
}
+ let success = true
try {
await api.signalUserAutonomy.update(body)
} catch (error: any) {
+ success = false
lemonToast.error(error?.detail ?? error?.message ?? 'Failed to update Slack notification setting')
} finally {
+ for (const [setting, newValue] of Object.entries(body)) {
+ // The channel name is the customer's own, so only whether one is now set travels.
+ const isChannel = setting === 'slack_notification_channel'
+ captureInboxSettingsChanged({
+ setting,
+ newValue: isChannel ? newValue !== null : newValue,
+ success,
+ scope: 'user',
+ })
+ }
actions.loadAutonomyConfig()
}
},
diff --git a/frontend/src/scenes/inbox/signalSourcesLogic.ts b/frontend/src/scenes/inbox/signalSourcesLogic.ts
index 4021c11b73bc..b127f1031cfb 100644
--- a/frontend/src/scenes/inbox/signalSourcesLogic.ts
+++ b/frontend/src/scenes/inbox/signalSourcesLogic.ts
@@ -21,7 +21,7 @@ import type { CISignalsConfigApi } from 'products/engineering_analytics/frontend
import type { PaginatedResponse } from '../../lib/api'
import type { FeatureFlagsSet } from '../../lib/logic/featureFlagLogic'
-import { captureSignalSourceConnected } from './inboxAnalytics'
+import { captureSignalSourceConnected, captureSignalSourceDisabled } from './inboxAnalytics'
import { SignalSourceConfig, SignalSourceConfigStatus, ToggleSignalSourceParams } from './types'
/** Matches Cymbal `EmitSignalRequest.source_type` + `products.signals.backend.api.emit_signal` checks. */
@@ -839,6 +839,8 @@ export const signalSourcesLogic = kea<signalSourcesLogicType>([
isFirstConnection: !(existing && !existing.id.startsWith('new_')),
viaSetupWizard: params.viaSetupWizard ?? false,
})
+ } else {
+ captureSignalSourceDisabled({ sourceProduct, sourceType })
}
actions.loadSourceConfigs()
} catch (error: any) {
@@ -882,6 +884,11 @@ export const signalSourcesLogic = kea<signalSourcesLogicType>([
isFirstConnection: !wasConnected,
viaSetupWizard: false,
})
+ } else {
+ captureSignalSourceDisabled({
+ sourceProduct: SignalSourceProduct.ErrorTracking,
+ sourceType: SignalSourceType.IssueCreated,
+ })
}
actions.loadSourceConfigs()
} catch (error: any) {
@@ -931,6 +938,11 @@ export const signalSourcesLogic = kea<signalSourcesLogicType>([
isFirstConnection: !wasConnected,
viaSetupWizard,
})
+ } else {
+ captureSignalSourceDisabled({
+ sourceProduct: SignalSourceProduct.EngineeringAnalytics,
+ sourceType: SignalSourceType.CiFlakyCheck,
+ })
}
actions.loadSourceConfigs()
} catch (error: any) {