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(replay-vision): chart scorer scores as a distribution bar histogram (#61039)

Kim Svatos Dugan153f1b8d3a42
diff --git a/products/replay_vision/frontend/replay_scanners/components/ScannerOverview.tsx b/products/replay_vision/frontend/replay_scanners/components/ScannerOverview.tsx
index f3f5d3554497..5c372779c37b 100644
--- a/products/replay_vision/frontend/replay_scanners/components/ScannerOverview.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/ScannerOverview.tsx
@@ -4,7 +4,7 @@ import { useMemo } from 'react'
import { LemonTag } from '@posthog/lemon-ui'
import { buildTheme } from 'lib/charts/utils/theme'
-import { BoxPlot } from 'lib/hog-charts'
+import { BarChart } from 'lib/hog-charts'
import { LemonProgress } from 'lib/lemon-ui/LemonProgress'
import { replayScannerLogic } from '../replayScannerLogic'
@@ -102,17 +102,17 @@ function ClassifierOverview({ scannerId, tabId }: { scannerId: string; tabId: st
}
function ScorerOverview({ scannerId, tabId }: { scannerId: string; tabId: string }): JSX.Element | null {
- const { scorerScores, scorerSummary } = useValues(replayScannerLogic({ id: scannerId, tabId }))
+ const { scorerScores, scorerSummary, scorerHistogram } = useValues(replayScannerLogic({ id: scannerId, tabId }))
const theme = useMemo(() => buildTheme(), [])
- if (!scorerSummary) {
+ if (!scorerSummary || !scorerHistogram) {
return null
}
return (
<OverviewPanel title="Score distribution" subtitle={`${scorerScores.length} scored`}>
<div className="h-40 flex flex-col">
- <BoxPlot
- labels={['Scores']}
- series={[{ key: 'scores', label: 'Scores', color: theme.colors[0], data: [scorerSummary] }]}
+ <BarChart
+ labels={scorerHistogram.labels}
+ series={[{ key: 'count', label: 'Sessions', color: theme.colors[0], data: scorerHistogram.counts }]}
config={{ showGrid: false }}
theme={theme}
/>
diff --git a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts
index ec3cf6943f55..f50ed48a58d9 100644
--- a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts
+++ b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts
@@ -449,6 +449,36 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
}
},
],
+ // Score histogram: count of observations per score bucket across the configured scale.
+ scorerHistogram: [
+ (s) => [s.scorerScores, s.scanner],
+ (scores: number[], scanner: ReplayScanner | null): { labels: string[]; counts: number[] } | null => {
+ if (scores.length === 0) {
+ return null
+ }
+ // Span the configured scale (falling back to the observed range) so the axis shows the full
+ // possible range even when scores cluster. Widen the bucket for large scales to cap the bar count.
+ const scale = scanner?.scanner_type === 'scorer' ? scanner.scanner_config.scale : undefined
+ const lo = Math.floor(scale?.min ?? scores[0])
+ const hi = Math.ceil(scale?.max ?? scores[scores.length - 1])
+ const span = Math.max(0, hi - lo)
+ const bucketWidth = Math.max(1, Math.ceil((span + 1) / 21))
+ const bucketCount = Math.floor(span / bucketWidth) + 1
+ const counts = new Array(bucketCount).fill(0)
+ for (const score of scores) {
+ const idx = Math.min(
+ bucketCount - 1,
+ Math.max(0, Math.floor((Math.round(score) - lo) / bucketWidth))
+ )
+ counts[idx] += 1
+ }
+ const labels = counts.map((_, i) => {
+ const start = lo + i * bucketWidth
+ return bucketWidth === 1 ? String(start) : `${start}–${Math.min(start + bucketWidth - 1, hi)}`
+ })
+ return { labels, counts }
+ },
+ ],
// Distinct sessions scanned: last 14 days and total. Surfaces sweep-job coverage.
coverageStats: [
(s) => [s.observations],