: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): move home page metrics to the Usage tab behind experiment (#97967)
Kim Svatos Duganc4b4e4013a13
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex d2c6b8f6890e..a2899cb597e4 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -482,6 +482,7 @@ export const FEATURE_FLAGS = {REPLAY_VISION_CALIBRATION_ENTRY_POINT: 'replay-vision-calibration-entry-point', // owner: #team-replay multivariate=control,test, links from a rated observation into the scanner's Calibration tabREPLAY_VISION_CALIBRATION_FEEDBACK_PROMPT: 'replay-vision-calibration-feedback-prompt', // owner: #team-replay multivariate=control,test, asks what the scanner should have concluded on a thumbs downREPLAY_VISION_CALIBRATION_TEST_NUDGE: 'replay-vision-calibration-test-nudge', // owner: #team-replay multivariate=control,test, prompts the user to test a recommendation before applying it+ REPLAY_VISION_HOME_REDESIGN_EXPERIMENT: 'replay-vision-home-redesign-experiment', // owner: #team-replay multivariate=control,test — gate on === 'test'; a truthy check turns on for control tooREPLAY_VISION_MODEL_TIER_NAMING_EXPERIMENT: 'replay-vision-model-tier-naming-experiment', // owner: #team-replay multivariate=control,test,lite-standard-proREVAMPED_PY_NOTEBOOKS: 'revamped-py-notebooks', // owner: #team-data-toolsREVENUE_FIELDS_IN_POWER_USERS_TABLE: 'revenue-fields-in-power-users-table', // owner: @arthurdedeus #team-customer-analyticsdiff --git a/products/replay_vision/frontend/components/ScanningPausedBanner.tsx b/products/replay_vision/frontend/components/ScanningPausedBanner.tsxnew file mode 100644index 000000000000..d17030e7bf3d--- /dev/null+++ b/products/replay_vision/frontend/components/ScanningPausedBanner.tsx@@ -0,0 +1,37 @@+import { useValues } from 'kea'++import { LemonBanner, Link } from '@posthog/lemon-ui'++import { urls } from 'scenes/urls'++import { ProductKey } from '~/queries/schema/schema-general'++import { visionQuotaLogic } from '../logics/visionQuotaLogic'++/** Shown on the scanners list when the org's credits are used up, since the spend card that+ * carried this warning lives on the Usage tab under the home-redesign experiment. */+export function ScanningPausedBanner(): JSX.Element | null {+ const { displayQuota: quota, onFreePlan } = useValues(visionQuotaLogic)++ if (!quota?.exhausted) {+ return null+ }+ return (+ <LemonBanner type="warning" data-attr="vision-scanning-paused-banner">+ {onFreePlan ? (+ <>+ Scanning is paused because your organization's free credits are used up.{' '}+ <Link to={urls.organizationBilling([ProductKey.REPLAY_VISION])}>Add billing</Link> to keep scanning,+ or check the <Link to={`${urls.replayVision()}?tab=usage`}>Usage tab</Link> for details.+ </>+ ) : (+ <>+ Scanning is paused because your organization reached its monthly spend limit.{' '}+ <Link to={urls.organizationBilling([ProductKey.REPLAY_VISION])}>Raise your billing limit</Link> to+ resume scanning, or check the <Link to={`${urls.replayVision()}?tab=usage`}>Usage tab</Link> for+ details.+ </>+ )}+ </LemonBanner>+ )+}diff --git a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.tsx b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.tsxindex 7bb3e804667d..96642feea92f 100644--- a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.tsx+++ b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.tsx@@ -17,10 +17,12 @@ import {} from '@posthog/lemon-ui'import { ObjectTags } from 'lib/components/ObjectTags/ObjectTags'+import { FEATURE_FLAGS } from 'lib/constants'import { More } from 'lib/lemon-ui/LemonButton/More'import { LemonDialog } from 'lib/lemon-ui/LemonDialog'import { LemonTableColumns } from 'lib/lemon-ui/LemonTable'import { ProfilePicture } from 'lib/lemon-ui/ProfilePicture'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { SceneExport } from 'scenes/sceneTypes'import { urls } from 'scenes/urls'@@ -33,6 +35,7 @@ import { FilterPill } from '../components/FilterPill'import { IngestionLimitBanner } from '../components/IngestionLimitBanner'import { ReplayVisionFeedbackButton } from '../components/ReplayVisionFeedbackButton'import { ScannerTypeBadge } from '../components/ScannerTypeBadge'+import { ScanningPausedBanner } from '../components/ScanningPausedBanner'import { replayVisionEmptyState } from '../emptyState/replayVisionEmptyState'import { visionQuotaLogic } from '../logics/visionQuotaLogic'import { ObservationSearchTab } from '../search/ObservationSearchTab'@@ -44,7 +47,14 @@ import { VisionUsageTab } from './components/VisionUsageTab'import { ReplayScannerTab } from './replayScannerSceneLogic'import { type ScannersSorting, SCANNERS_PAGE_SIZE, replayScannersLogic } from './replayScannersLogic'import { LIMIT_REACHED_TOOLTIP } from './scannerCopy'-import { ENABLED_OPTIONS, EnabledFilter, SCANNER_TYPE_OPTIONS, ScannerType, ReplayScanner } from './types'+import {+ ENABLED_OPTIONS,+ EnabledFilter,+ SCANNER_TYPE_OPTIONS,+ ScannerType,+ ReplayScanner,+ homeRedesignVariant,+} from './types'const TYPE_OPTIONS: { value: ScannerType; label: string }[] = SCANNER_TYPE_OPTIONS.map(({ value, label }) => ({value,@@ -143,6 +153,13 @@ export function ReplayScannersScene(): JSX.Element {const { push } = useActions(router)const { searchParams } = useValues(router)const { showUsd } = useValues(visionQuotaLogic)+ const { featureFlags } = useValues(featureFlagLogic)+ const onScannersTab = ![ReplayScannerTab.Search, 'usage'].includes(searchParams.tab)+ // Reading the flags proxy reports exposure; guard the read so it fires only where the+ // experiment arms actually diverge (the scanners tab; the Usage tab reads it itself).+ const isRedesign =+ onScannersTab &&+ homeRedesignVariant(featureFlags[FEATURE_FLAGS.REPLAY_VISION_HOME_REDESIGN_EXPERIMENT]) === 'test'const columns: LemonTableColumns<ReplayScanner> = [{@@ -293,7 +310,9 @@ export function ReplayScannersScene(): JSX.Element {<VisionUsageTab />) : (<>- {(scannerStats?.total ?? 0) > 0 ? (+ {isRedesign ? (+ <ScanningPausedBanner />+ ) : (scannerStats?.total ?? 0) > 0 ? (<VisionMetrics />) : scannerStatsLoading ? (<div className="flex items-center justify-center h-72 bg-bg-light rounded">diff --git a/products/replay_vision/frontend/replay_scanners/components/EnabledScannersCard.tsx b/products/replay_vision/frontend/replay_scanners/components/EnabledScannersCard.tsxnew file mode 100644index 000000000000..fb3a620fa000--- /dev/null+++ b/products/replay_vision/frontend/replay_scanners/components/EnabledScannersCard.tsx@@ -0,0 +1,37 @@+import { useValues } from 'kea'++import { cn } from 'lib/utils/css-classes'++import { ScannerTypeBadge } from '../../components/ScannerTypeBadge'+import { replayScannersLogic } from '../replayScannersLogic'+import { SCANNER_TYPE_OPTIONS } from '../types'++export function EnabledScannersCard({ className }: { className?: string }): JSX.Element {+ const { scannerStats } = useValues(replayScannersLogic)++ return (+ <div className={cn('bg-bg-light border rounded p-4 flex flex-col', className)}>+ <div className="text-muted text-xs font-medium uppercase mb-2">Enabled scanners</div>+ <div className="text-3xl font-semibold">+ {scannerStats?.enabled ?? 0}+ <span className="text-muted text-lg font-normal">+ {' / '}+ {scannerStats?.total ?? 0}+ </span>+ </div>+ <div className="flex flex-wrap gap-1.5 mt-3">+ {SCANNER_TYPE_OPTIONS.map(({ value }) => {+ const { enabled = 0, total = 0 } = scannerStats?.by_type?.[value] ?? {}+ return (+ <ScannerTypeBadge+ key={value}+ scannerType={value}+ variant={total > 0 ? 'default' : 'muted'}+ suffix={`${enabled}/${total}`}+ />+ )+ })}+ </div>+ </div>+ )+}diff --git a/products/replay_vision/frontend/replay_scanners/components/ObservationsOverTimeCard.tsx b/products/replay_vision/frontend/replay_scanners/components/ObservationsOverTimeCard.tsxnew file mode 100644index 000000000000..00ee626850b6--- /dev/null+++ b/products/replay_vision/frontend/replay_scanners/components/ObservationsOverTimeCard.tsx@@ -0,0 +1,73 @@+import { useMemo } from 'react'++import { DateFilter } from 'lib/components/DateFilter/DateFilter'+import { cn } from 'lib/utils/css-classes'++import { InsightVizNode, NodeKind, ProductKey } from '~/queries/schema/schema-general'+import { BaseMathType, ChartDisplayType, InsightLogicProps } from '~/types'++import { VisionInsightChart } from './VisionInsightChart'++const RECORDING_OBSERVED_EVENT = '$recording_observed'+const COLLECTION_ID = 'replay-vision-list-observations'++interface ObservationsOverTimeCardProps {+ dateFrom: string | null+ dateTo: string | null+ onDateChange: (dateFrom: string | null, dateTo: string | null) => void+ className?: string+}++export function ObservationsOverTimeCard({+ dateFrom,+ dateTo,+ onDateChange,+ className,+}: ObservationsOverTimeCardProps): JSX.Element {+ // Memoized so a re-render (e.g. stats/quota arriving) can't churn the query and abort an in-flight load.+ // `tags.productKey` is required for ClickHouse query tagging; without it the runner aborts.+ const chartQuery = useMemo<InsightVizNode>(+ () => ({+ kind: NodeKind.InsightVizNode,+ source: {+ kind: NodeKind.TrendsQuery,+ series: [+ {+ kind: NodeKind.EventsNode,+ event: RECORDING_OBSERVED_EVENT,+ math: BaseMathType.TotalCount,+ name: 'Observations',+ },+ ],+ trendsFilter: { display: ChartDisplayType.ActionsLineGraph },+ dateRange: { date_from: dateFrom, date_to: dateTo },+ interval: 'day',+ tags: { productKey: ProductKey.REPLAY_VISION },+ },+ }),+ [dateFrom, dateTo]+ )+ const chartInsightProps = useMemo<InsightLogicProps>(+ () => ({ dashboardItemId: 'new-replay-vision-list-observations-chart', dataNodeCollectionId: COLLECTION_ID }),+ []+ )++ return (+ <div className={cn('bg-bg-light rounded p-4 flex flex-col InsightCard', className)}>+ <div className="flex flex-wrap items-start justify-between gap-2 mb-1">+ <h3 className="text-base font-semibold m-0">Observations over time</h3>+ <DateFilter+ dateFrom={dateFrom}+ dateTo={dateTo}+ onChange={(from, to) => onDateChange(from ?? null, to ?? null)}+ />+ </div>+ <p className="text-muted text-xs mb-3">Across all scanners</p>+ <VisionInsightChart+ query={chartQuery}+ insightProps={chartInsightProps}+ className="flex-1 flex flex-col min-h-0"+ />+ </div>+ )+}diff --git a/products/replay_vision/frontend/replay_scanners/components/VisionMetrics.tsx b/products/replay_vision/frontend/replay_scanners/components/VisionMetrics.tsxindex b64878c92384..fb0dd2b3faad 100644--- a/products/replay_vision/frontend/replay_scanners/components/VisionMetrics.tsx+++ b/products/replay_vision/frontend/replay_scanners/components/VisionMetrics.tsx@@ -1,33 +1,24 @@import { useActions, useValues } from 'kea'-import { useMemo } from 'react'import { Link, Spinner, Tooltip } from '@posthog/lemon-ui'-import { DateFilter } from 'lib/components/DateFilter/DateFilter'import { urls } from 'scenes/urls'-import { InsightVizNode, NodeKind, ProductKey } from '~/queries/schema/schema-general'-import { BaseMathType, ChartDisplayType, InsightLogicProps } from '~/types'-import { NoBillingLimitNote } from '../../components/NoBillingLimitNote'import { QuotaExhaustedNote } from '../../components/QuotaExhaustedNote'-import { ScannerTypeBadge } from '../../components/ScannerTypeBadge'import { visionQuotaLogic } from '../../logics/visionQuotaLogic'import { creditsToUsd, formatCreditCount } from '../../utils/credits'import { buildQuotaMeter, fleetContributions } from '../../utils/quotaContributions'import { QUOTA_STATUS_STYLES } from '../../utils/quotaProjection'import { STARTUP_CAP_EXPLANATION } from '../../utils/startupCap'import { replayScannersLogic } from '../replayScannersLogic'-import { SCANNER_TYPE_OPTIONS } from '../types'+import { EnabledScannersCard } from './EnabledScannersCard'+import { ObservationsOverTimeCard } from './ObservationsOverTimeCard'import { QuotaMeter } from './QuotaMeterBar'import { QuotaStatusLine } from './QuotaStatusLine'-import { VisionInsightChart } from './VisionInsightChart'--const RECORDING_OBSERVED_EVENT = '$recording_observed'-const COLLECTION_ID = 'replay-vision-list-observations'export function VisionMetrics(): JSX.Element {- const { scannerStats, chartDateFrom, chartDateTo } = useValues(replayScannersLogic)+ const { chartDateFrom, chartDateTo } = useValues(replayScannersLogic)const { setChartDateRange } = useActions(replayScannersLogic)const {displayQuota: quota,@@ -47,77 +38,17 @@ export function VisionMetrics(): JSX.Element {const styles = QUOTA_STATUS_STYLES[status]const { resetsOn } = projection- // Memoized so a re-render (e.g. stats/quota arriving) can't churn the query and abort an in-flight load.- // `tags.productKey` is required for ClickHouse query tagging; without it the runner aborts.- const chartQuery = useMemo<InsightVizNode>(- () => ({- kind: NodeKind.InsightVizNode,- source: {- kind: NodeKind.TrendsQuery,- series: [- {- kind: NodeKind.EventsNode,- event: RECORDING_OBSERVED_EVENT,- math: BaseMathType.TotalCount,- name: 'Observations',- },- ],- trendsFilter: { display: ChartDisplayType.ActionsLineGraph },- dateRange: { date_from: chartDateFrom, date_to: chartDateTo },- interval: 'day',- tags: { productKey: ProductKey.REPLAY_VISION },- },- }),- [chartDateFrom, chartDateTo]- )- const chartInsightProps = useMemo<InsightLogicProps>(- () => ({ dashboardItemId: 'new-replay-vision-list-observations-chart', dataNodeCollectionId: COLLECTION_ID }),- []- )-return (<div className="flex flex-col lg:flex-row gap-4 lg:h-96">- <div className="flex-1 bg-bg-light rounded p-4 flex flex-col InsightCard h-full min-h-80 lg:min-h-0">- <div className="flex flex-wrap items-start justify-between gap-2 mb-1">- <h3 className="text-base font-semibold m-0">Observations over time</h3>- <DateFilter- dateFrom={chartDateFrom}- dateTo={chartDateTo}- onChange={(from, to) => setChartDateRange(from ?? null, to ?? null)}- />- </div>- <p className="text-muted text-xs mb-3">Across all scanners</p>- <VisionInsightChart- query={chartQuery}- insightProps={chartInsightProps}- className="flex-1 flex flex-col min-h-0"- />- </div>+ <ObservationsOverTimeCard+ dateFrom={chartDateFrom}+ dateTo={chartDateTo}+ onDateChange={setChartDateRange}+ className="flex-1 h-full min-h-80 lg:min-h-0"+ /><div className="flex flex-1 flex-col gap-4">- <div className="flex-1 bg-bg-light border rounded p-4 flex flex-col">- <div className="text-muted text-xs font-medium uppercase mb-2">Enabled scanners</div>- <div className="text-3xl font-semibold">- {scannerStats?.enabled ?? 0}- <span className="text-muted text-lg font-normal">- {' / '}- {scannerStats?.total ?? 0}- </span>- </div>- <div className="flex flex-wrap gap-1.5 mt-3">- {SCANNER_TYPE_OPTIONS.map(({ value }) => {- const { enabled = 0, total = 0 } = scannerStats?.by_type?.[value] ?? {}- return (- <ScannerTypeBadge- key={value}- scannerType={value}- variant={total > 0 ? 'default' : 'muted'}- suffix={`${enabled}/${total}`}- />- )- })}- </div>- </div>+ <EnabledScannersCard className="flex-1" /><div className="flex-1 bg-bg-light border rounded p-4 flex flex-col"><div className="flex items-baseline justify-between gap-3 mb-2"><div className="text-muted text-xs font-medium uppercase">Spend this billing period</div>diff --git a/products/replay_vision/frontend/replay_scanners/components/VisionUsageTab.tsx b/products/replay_vision/frontend/replay_scanners/components/VisionUsageTab.tsxindex 5ad8dd15c816..02b9c48d5c0a 100644--- a/products/replay_vision/frontend/replay_scanners/components/VisionUsageTab.tsx+++ b/products/replay_vision/frontend/replay_scanners/components/VisionUsageTab.tsx@@ -2,9 +2,11 @@ import { useActions, useValues } from 'kea'import { LemonButton, LemonCard, LemonSwitch, Link, Spinner, Tooltip } from '@posthog/lemon-ui'+import { FEATURE_FLAGS } from 'lib/constants'import { LemonProgress } from 'lib/lemon-ui/LemonProgress'import { LemonTableColumns } from 'lib/lemon-ui/LemonTable'import { LemonTable } from 'lib/lemon-ui/LemonTable'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { pluralize } from 'lib/utils/strings'import { urls } from 'scenes/urls'@@ -23,8 +25,11 @@ import {} from '../../utils/credits'import { verdictColorVar, verdictTextClass } from '../../utils/spendVerdict'import { STARTUP_CAP_EXPLANATION } from '../../utils/startupCap'-import { ReplayScanner } from '../types'+import { replayScannersLogic } from '../replayScannersLogic'+import { ReplayScanner, homeRedesignVariant } from '../types'import { visionUsageLogic } from '../visionUsageLogic'+import { EnabledScannersCard } from './EnabledScannersCard'+import { ObservationsOverTimeCard } from './ObservationsOverTimeCard'import { SpendTrajectoryChart } from './SpendTrajectoryChart'const ORG_WIDE_NOTE = 'Spend and limits are shared by every project in the organization.'@@ -59,6 +64,13 @@ export function VisionUsageTab(): JSX.Element {billedLimitCredits,showStartupCap,} = useValues(visionQuotaLogic)+ const { chartDateFrom, chartDateTo } = useValues(replayScannersLogic)+ const { setChartDateRange } = useActions(replayScannersLogic)+ const { featureFlags } = useValues(featureFlagLogic)+ // Reading the flags proxy reports exposure; this component only renders once the Usage tab is+ // open, so exposure covers exactly the users who saw either arm of this tab.+ const isRedesign =+ homeRedesignVariant(featureFlags[FEATURE_FLAGS.REPLAY_VISION_HOME_REDESIGN_EXPERIMENT]) === 'test'const statusText = verdictTextClass(verdict.kind)const hasCap = verdict.hasCap@@ -263,6 +275,18 @@ export function VisionUsageTab(): JSX.Element {</LemonCard></div>+ {isRedesign && (+ <div className="grid grid-cols-1 @xl:grid-cols-2 gap-4">+ <ObservationsOverTimeCard+ dateFrom={chartDateFrom}+ dateTo={chartDateTo}+ onDateChange={setChartDateRange}+ className="border min-h-80"+ />+ <EnabledScannersCard />+ </div>+ )}+<LemonCard hoverEffect={false} className="p-4 flex flex-col gap-2"><div className="flex flex-wrap items-baseline justify-between gap-2"><h3 className="text-base font-semibold m-0">Spend this period</h3>diff --git a/products/replay_vision/frontend/replay_scanners/types.ts b/products/replay_vision/frontend/replay_scanners/types.tsindex 4ccdc1854297..0957f56020bc 100644--- a/products/replay_vision/frontend/replay_scanners/types.ts+++ b/products/replay_vision/frontend/replay_scanners/types.ts@@ -284,6 +284,15 @@ const RETIRED_MODEL_NAMES: Record<string, string> = {'gemini-3.6-flash': 'Gemini 3.6 Flash',}+// Arms of the replay-vision-home-redesign-experiment flag. Narrows a raw flag value so control,+// booleans, and unknown variants all degrade to the control experience instead of half-applying+// the redesigned layout.+export type HomeRedesignVariant = 'control' | 'test'++export function homeRedesignVariant(flagValue: unknown): HomeRedesignVariant | null {+ return flagValue === 'control' || flagValue === 'test' ? flagValue : null+}+// Tier-name arms of the replay-vision-model-tier-naming-experiment flag: capability tiers instead// of provider model names, keyed by the flag's variant key. Every surface that shows a model must// resolve the variant the same way so a user never sees mixed naming schemes for one scanner.