: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(replay-vision): capture watch picks empty-state impressions (#125153)
Hayne Ryu196947c519cf
diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchPicksEmptyState.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchPicksEmptyState.tsxindex ef764e8088b2..8748d56358d0 100644--- a/products/replay_vision/frontend/replay_scanners/components/WatchPicksEmptyState.tsx+++ b/products/replay_vision/frontend/replay_scanners/components/WatchPicksEmptyState.tsx@@ -1,4 +1,5 @@-import { useValues } from 'kea'+import { useActions, useMountedLogic, useValues } from 'kea'+import { useEffect } from 'react'import { LemonSkeleton } from '@posthog/lemon-ui'@@ -8,6 +9,7 @@ import { teamLogic } from 'scenes/teamLogic'import { visionQuotaLogic } from '../../logics/visionQuotaLogic'import { visionScannersListLogic } from '../../logics/visionScannersListLogic'import { resolveWatchFeedEmptyReason } from '../watchFeedEmptyState'+import { watchPicksLogic } from '../watchPicksLogic'import { WatchPicksBlockedState } from './WatchPicksBlockedState'import { WatchPicksQuietState } from './WatchPicksQuietState'import { WatchPicksReplayOffState } from './WatchPicksReplayOffState'@@ -17,18 +19,29 @@ export function WatchPicksEmptyState({ size }: { size: 'small' | 'large' }): JSXconst { scanners, scannersLoading } = useValues(visionScannersListLogic)const { quota, quotaLoading } = useValues(visionQuotaLogic)const { currentTeam } = useValues(teamLogic)+ const picksLogic = useMountedLogic(watchPicksLogic)+ const { emptyStateShown } = useActions(picksLogic)const large = size === 'large'+ const loading = scannersLoading || quotaLoading- if (scannersLoading || quotaLoading) {+ const reason = loading+ ? null+ : resolveWatchFeedEmptyReason({+ scanners,+ quota,+ sessionRecordingOptIn: currentTeam?.session_recording_opt_in ?? null,+ hasFeedFilters: false,+ })++ useEffect(() => {+ if (reason) {+ emptyStateShown(reason)+ }+ }, [reason, emptyStateShown])++ if (!reason) {return <LemonSkeleton className={cn('w-full rounded', large ? 'h-64' : 'h-40')} />}-- const reason = resolveWatchFeedEmptyReason({- scanners,- quota,- sessionRecordingOptIn: currentTeam?.session_recording_opt_in ?? null,- hasFeedFilters: false,- })if (reason === 'replay-off') {return <WatchPicksReplayOffState size={size} />}diff --git a/products/replay_vision/frontend/replay_scanners/watchPicksLogic.ts b/products/replay_vision/frontend/replay_scanners/watchPicksLogic.tsindex 22b5800d6894..448809614cae 100644--- a/products/replay_vision/frontend/replay_scanners/watchPicksLogic.ts+++ b/products/replay_vision/frontend/replay_scanners/watchPicksLogic.ts@@ -32,6 +32,7 @@ import { SessionRecordingSidebarTab } from '~/types'import { visionObservationsViewedCreate, visionScannersWatchFeedRetrieve } from '../generated/api'import type { WatchFeedItemApi } from '../generated/api.schemas'import { observationKeyMomentMs, watchStartSeconds } from './components/WatchFeedCard'+import type { WatchFeedEmptyReason } from './watchFeedEmptyState'import { recordFeedImpressions } from './watchFeedImpressionCounts'import {type WatchFeedLoad,@@ -91,6 +92,9 @@ export interface watchPicksLogicActions {item: WatchFeedItemApiposition: number}+ emptyStateShown: (reason: WatchFeedEmptyReason) => {+ reason: WatchFeedEmptyReason+ }loadPicks: () => {value: true}@@ -172,6 +176,7 @@ export const watchPicksLogic: LogicWrapper<watchPicksLogicType> = kea<watchPicksmarkPickViewed: (observationId: string) => ({ observationId }),setPicksLoad: (load: WatchFeedLoad) => ({ load }),cardSeen: (item: WatchFeedItemApi, position: number) => ({ item, position }),+ emptyStateShown: (reason: WatchFeedEmptyReason) => ({ reason }),}),loaders(({ values, actions }) => ({@@ -291,6 +296,13 @@ export const watchPicksLogic: LogicWrapper<watchPicksLogicType> = kea<watchPickssetPicksLoad: ({ load }) => {cache.impressions.start(load)},+ emptyStateShown: ({ reason }) => {+ if (cache.emptyStateShownReason === reason) {+ return+ }+ cache.emptyStateShownReason = reason+ posthog.capture('replay_vision_watch_picks_empty_shown', { reason })+ },cardSeen: ({ item, position }) => {// Fallback rows below the picks were not served by the ranker, so they are not impressions of this load.if (values.picksLoad?.positions[item.observation.id] !== undefined) {