: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): make scanner analysis chart drillable (#73242)
Arno Hillen2bf286bb8191
diff --git a/products/replay_vision/frontend/replay_scanners/components/ScannerInsightsChart.tsx b/products/replay_vision/frontend/replay_scanners/components/ScannerInsightsChart.tsxindex e416345d1bc5..92fc0bd89dc2 100644--- a/products/replay_vision/frontend/replay_scanners/components/ScannerInsightsChart.tsx+++ b/products/replay_vision/frontend/replay_scanners/components/ScannerInsightsChart.tsx@@ -16,6 +16,7 @@ import {PropertyOperator,} from '~/types'+import { getReplayVisionRecordingViewDisabledReason } from '../../utils/accessControl'import { replayScannerLogic } from '../replayScannerLogic'import { ScannerType } from '../types'import { VisionInsightChart } from './VisionInsightChart'@@ -178,6 +179,9 @@ export function ScannerInsightsChart({}),[scannerId])+ // Drill-down opens the actors modal, which surfaces the recordings behind a data point. Only enable it for+ // users who can view recordings, so a scanner-only viewer denied session_recording access can't enumerate them.+ const canDrillIntoRecordings = !getReplayVisionRecordingViewDisabledReason()return (<div className="border rounded p-4 bg-surface-primary space-y-3"><div className="flex items-baseline justify-between gap-2">@@ -203,7 +207,12 @@ export function ScannerInsightsChart({onChange={(from, to) => setChartDateRange(from ?? null, to ?? null)}/></div>- <VisionInsightChart query={chartQuery} insightProps={chartInsightProps} className="InsightCard h-80" />+ <VisionInsightChart+ query={chartQuery}+ insightProps={chartInsightProps}+ className="InsightCard h-80"+ drillable={canDrillIntoRecordings}+ /></div>)}diff --git a/products/replay_vision/frontend/replay_scanners/components/VisionInsightChart.tsx b/products/replay_vision/frontend/replay_scanners/components/VisionInsightChart.tsxindex 6336b2eb36d8..754400d17f3e 100644--- a/products/replay_vision/frontend/replay_scanners/components/VisionInsightChart.tsx+++ b/products/replay_vision/frontend/replay_scanners/components/VisionInsightChart.tsx@@ -15,6 +15,8 @@ interface VisionInsightChartProps {insightProps: InsightLogicProps/** Sizing classes for the chart container — pass the same layout the chart sat in before, the chart sizes against it. */className?: string+ /** When true, clicking a data point opens the persons/recordings modal. Off by default so summary charts stay static. */+ drillable?: boolean}export type ChartOverlayState = 'none' | 'loading' | 'error'@@ -39,7 +41,12 @@ export function chartOverlayState(* blank box when a query is cancelled or hasn't resolved (its empty/refresh fallbacks are dashboard-only), so we* overlay our own spinner/retry whenever there's no response to render.*/-export function VisionInsightChart({ query, insightProps, className }: VisionInsightChartProps): JSX.Element {+export function VisionInsightChart({+ query,+ insightProps,+ className,+ drillable = false,+}: VisionInsightChartProps): JSX.Element {const logic = insightVizDataLogic(insightProps)const { insightData, insightDataLoading } = useValues(logic)const { loadData } = useActions(logic)@@ -48,7 +55,7 @@ export function VisionInsightChart({ query, insightProps, className }: VisionInsreturn (<div className={clsx('relative', className)}>- <Query query={query} readOnly embedded inSharedMode context={{ insightProps }} />+ <Query query={query} readOnly embedded inSharedMode={!drillable} context={{ insightProps }} />{overlay !== 'none' && (<div className="absolute inset-0 flex flex-col items-center justify-center gap-2 bg-bg-light">{overlay === 'loading' ? (diff --git a/products/replay_vision/frontend/utils/accessControl.ts b/products/replay_vision/frontend/utils/accessControl.tsindex 674a9a225dab..58446b40910e 100644--- a/products/replay_vision/frontend/utils/accessControl.ts+++ b/products/replay_vision/frontend/utils/accessControl.ts@@ -21,6 +21,15 @@ export function getReplayVisionEditDisabledReason(scannerUserAccessLevel?: Acces)}+/**+ * Reading recording-derived content (e.g. drilling from a scanner chart into the sessions behind a data+ * point) requires session_recording viewer access, independent of scanner access. A scanner-only viewer+ * denied recordings must not be able to enumerate them, so gate any recording-surfacing affordance on this.+ */+export function getReplayVisionRecordingViewDisabledReason(): string | null {+ return getAccessControlDisabledReason(AccessControlResourceType.SessionRecording, AccessControlLevel.Viewer) ?? null+}+/*** Deleting a scanner or vision action is the one write that skips the session_recording check —* destroy doesn't expose or process recording content (see `_CONFIG_ACTIONS`, which omits "destroy",