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.

fix(replay-vision): drill from scanner charts into observations instead of the persons modal (#75799)

Arno Hillenb8bfa4c1ae00
diff --git a/products/product_analytics/frontend/insights/trends/shared/handleTrendsChartClick.test.tsx b/products/product_analytics/frontend/insights/trends/shared/handleTrendsChartClick.test.tsx
index 5f2181586a04..e39f4869d3ab 100644
--- a/products/product_analytics/frontend/insights/trends/shared/handleTrendsChartClick.test.tsx
+++ b/products/product_analytics/frontend/insights/trends/shared/handleTrendsChartClick.test.tsx
@@ -108,6 +108,30 @@ describe('handleTrendsChartClick', () => {
}
)
+ it('forwards a formula-series click (action: null) to context.onDataPointClick instead of the modal', () => {
+ // Formula results carry no `action`, so the generic drill-down can't attribute them to a series
+ // (it silently falls back to series 0). Products embedding formula charts rely on their
+ // onDataPointClick handler winning here, with the day read from the top-level `days`.
+ const openPersonsModal = jest.fn()
+ const onDataPointClick = jest.fn()
+ const trendResult = makeTrendResult({
+ action: null,
+ label: 'Yes rate',
+ days: ['2024-06-10', '2024-06-11', '2024-06-12'],
+ })
+ const deps = makeDeps({
+ openPersonsModal,
+ indexedResults: [trendResult],
+ context: { onDataPointClick },
+ })
+
+ handleTrendsChartClick(keyFor(trendResult), 1, deps)
+
+ expect(openPersonsModal).not.toHaveBeenCalled()
+ expect(onDataPointClick).toHaveBeenCalledTimes(1)
+ expect(onDataPointClick).toHaveBeenCalledWith(expect.objectContaining({ day: '2024-06-11' }), expect.anything())
+ })
+
it('passes indexedResults[0] (not the clicked dataset) as the second arg to onDataPointClick', () => {
// Legacy parity with ActionsLineGraph — the second arg is always the first
// result, regardless of which series was clicked. Locking this in so a refactor
diff --git a/products/replay_vision/backend/api/observations.py b/products/replay_vision/backend/api/observations.py
index d947b87ad762..58204ce316d3 100644
--- a/products/replay_vision/backend/api/observations.py
+++ b/products/replay_vision/backend/api/observations.py
@@ -32,6 +32,7 @@ from posthog.api.routing import TeamAndOrgViewSetMixin
from posthog.api.shared import UserBasicSerializer
from posthog.api.streaming import sse_streaming_response
from posthog.event_usage import report_user_action
+from posthog.models.team import Team
from posthog.models.user import User
from posthog.renderers import ServerSentEventRenderer
from posthog.utils import relative_date_parse
@@ -500,6 +501,13 @@ class _ObservationOrderByFilter(OrderByFilter):
return self._order_nulls_last(qs, "_order_verdict", descending)
+class _TeamAwareFilterBackend(DjangoFilterBackend):
+ """Passes the viewset's team into the filterset so date bounds can use the project timezone."""
+
+ def get_filterset_kwargs(self, request: Request, queryset: QuerySet, view: Any) -> dict[str, Any]:
+ return {**super().get_filterset_kwargs(request, queryset, view), "team": getattr(view, "team", None)}
+
+
class ReplayObservationFilter(django_filters.FilterSet):
status = MultiChoiceFilter(
field_name="status",
@@ -535,13 +543,16 @@ class ReplayObservationFilter(django_filters.FilterSet):
)
date_from = django_filters.CharFilter(
method="_filter_date_from",
- help_text="Only observations created at or after this time. Accepts ISO 8601 or a relative date like `-7d`.",
+ help_text=(
+ "Only observations created at or after this time. Accepts ISO 8601 or a relative date like `-7d`; "
+ "values without an explicit offset are interpreted in the project's timezone."
+ ),
)
date_to = django_filters.CharFilter(
method="_filter_date_to",
help_text=(
"Only observations created at or before this time. Accepts ISO 8601 or a relative date like `-1d`; "
- "date-only values include the whole day."
+ "date-only values include the whole day, interpreted in the project's timezone."
),
)
labeled = django_filters.BooleanFilter(
@@ -564,6 +575,15 @@ class ReplayObservationFilter(django_filters.FilterSet):
model = ReplayObservation
fields = ["status", "triggered_by", "session_id"]
+ def __init__(self, *args: Any, team: Team | None = None, **kwargs: Any) -> None:
+ self._team = team
+ super().__init__(*args, **kwargs)
+
+ @property
+ def _timezone_info(self) -> ZoneInfo:
+ # Date bounds come from UI date pickers, so users mean them in the project timezone, not UTC.
+ return self._team.timezone_info if self._team else ZoneInfo("UTC")
+
@classmethod
def schema_parameters(cls) -> list[OpenApiParameter]:
"""Mirror declared filters as `OpenApiParameter`s for `@action` methods drf-spectacular can't auto-discover."""
@@ -587,12 +607,12 @@ class ReplayObservationFilter(django_filters.FilterSet):
def _filter_date_from(
self, queryset: QuerySet[ReplayObservation], _name: str, value: str
) -> QuerySet[ReplayObservation]:
- return queryset.filter(created_at__gte=relative_date_parse(value, ZoneInfo("UTC")))
+ return queryset.filter(created_at__gte=relative_date_parse(value, self._timezone_info))
def _filter_date_to(
self, queryset: QuerySet[ReplayObservation], _name: str, value: str
) -> QuerySet[ReplayObservation]:
- parsed = relative_date_parse(value, ZoneInfo("UTC"))
+ parsed = relative_date_parse(value, self._timezone_info)
# Date-only values include the whole day; relative values stay exact.
if not value.startswith(("-", "+")) and "T" not in value and ":" not in value:
parsed = parsed.replace(hour=23, minute=59, second=59, microsecond=999999)
@@ -693,7 +713,7 @@ class ReplayObservationViewSet(
permission_classes = [ReplayVisionEnabledPermission]
serializer_class = ReplayObservationSerializer
queryset = ReplayObservation.objects.all()
- filter_backends = [DjangoFilterBackend]
+ filter_backends = [_TeamAwareFilterBackend]
filterset_class = ReplayObservationFilter
def _scanner_for_url(self) -> ReplayScanner:
@@ -758,7 +778,9 @@ class ReplayObservationViewSet(
# Empty values (`?status=`) are no-ops in the filterset, so they must not opt out of the fast path.
if not any(self.request.query_params.get(key) for key in ReplayObservationFilter.base_filters):
return self._unfiltered_neighbors(observation, siblings)
- filterset = ReplayObservationFilter(self.request.query_params, queryset=siblings, request=self.request)
+ filterset = ReplayObservationFilter(
+ self.request.query_params, queryset=siblings, request=self.request, team=self.team
+ )
if not filterset.is_valid():
# Same 400 the list endpoint gives for the identical bad query string.
raise ValidationError(filterset.errors)
diff --git a/products/replay_vision/backend/tests/test_api.py b/products/replay_vision/backend/tests/test_api.py
index 816e01919c71..205df48a5ed2 100644
--- a/products/replay_vision/backend/tests/test_api.py
+++ b/products/replay_vision/backend/tests/test_api.py
@@ -964,6 +964,24 @@ class TestReplayObservationViewSet(_VisionAPITestCase):
self.assertEqual(resp.status_code, 200, resp.json())
self.assertEqual([r["session_id"] for r in resp.json()["results"]], ["old"])
+ def test_list_date_range_bounds_use_project_timezone(self) -> None:
+ self.team.timezone = "US/Pacific"
+ self.team.save()
+ # 05:00 UTC is 21:00 the previous day in Pacific; 20:00 UTC is 12:00 the same day.
+ previous_day = self._create_observation(session_id="pacific-previous-day")
+ ReplayObservation.objects.filter(pk=previous_day.pk).update(created_at=datetime(2026, 3, 3, 5, 0, tzinfo=UTC))
+ same_day = self._create_observation(session_id="pacific-same-day")
+ ReplayObservation.objects.filter(pk=same_day.pk).update(created_at=datetime(2026, 3, 3, 20, 0, tzinfo=UTC))
+
+ base_url = self.observations_url(str(self.scanner.id))
+ resp = self.client.get(f"{base_url}?date_from=2026-03-03&date_to=2026-03-03")
+ self.assertEqual(resp.status_code, 200, resp.json())
+ self.assertEqual([r["session_id"] for r in resp.json()["results"]], ["pacific-same-day"])
+
+ resp = self.client.get(f"{base_url}?date_from=2026-03-02&date_to=2026-03-02")
+ self.assertEqual(resp.status_code, 200, resp.json())
+ self.assertEqual([r["session_id"] for r in resp.json()["results"]], ["pacific-previous-day"])
+
def test_retrieve_with_filters_resolves_object_and_scopes_neighbors_only(self) -> None:
observation = self._create_observation(session_id="s-pending")
self._create_observation(session_id="s-other")
diff --git a/products/replay_vision/frontend/generated/api.schemas.ts b/products/replay_vision/frontend/generated/api.schemas.ts
index e08306914b14..162603a0ffaa 100644
--- a/products/replay_vision/frontend/generated/api.schemas.ts
+++ b/products/replay_vision/frontend/generated/api.schemas.ts
@@ -1591,11 +1591,11 @@ export type VisionObservationsListParams = {
export type VisionObservationsRetrieveParams = {
/**
- * Only observations created at or after this time. Accepts ISO 8601 or a relative date like `-7d`.
+ * Only observations created at or after this time. Accepts ISO 8601 or a relative date like `-7d`; values without an explicit offset are interpreted in the project's timezone.
*/
date_from?: string
/**
- * Only observations created at or before this time. Accepts ISO 8601 or a relative date like `-1d`; date-only values include the whole day.
+ * Only observations created at or before this time. Accepts ISO 8601 or a relative date like `-1d`; date-only values include the whole day, interpreted in the project's timezone.
*/
date_to?: string
/**
@@ -1694,11 +1694,11 @@ export type VisionScannersImpactRetrieveParams = {
export type VisionScannersObservationsListParams = {
/**
- * Only observations created at or after this time. Accepts ISO 8601 or a relative date like `-7d`.
+ * Only observations created at or after this time. Accepts ISO 8601 or a relative date like `-7d`; values without an explicit offset are interpreted in the project's timezone.
*/
date_from?: string
/**
- * Only observations created at or before this time. Accepts ISO 8601 or a relative date like `-1d`; date-only values include the whole day.
+ * Only observations created at or before this time. Accepts ISO 8601 or a relative date like `-1d`; date-only values include the whole day, interpreted in the project's timezone.
*/
date_to?: string
/**
@@ -1745,11 +1745,11 @@ export type VisionScannersObservationsListParams = {
export type VisionScannersObservationsRetrieveParams = {
/**
- * Only observations created at or after this time. Accepts ISO 8601 or a relative date like `-7d`.
+ * Only observations created at or after this time. Accepts ISO 8601 or a relative date like `-7d`; values without an explicit offset are interpreted in the project's timezone.
*/
date_from?: string
/**
- * Only observations created at or before this time. Accepts ISO 8601 or a relative date like `-1d`; date-only values include the whole day.
+ * Only observations created at or before this time. Accepts ISO 8601 or a relative date like `-1d`; date-only values include the whole day, interpreted in the project's timezone.
*/
date_to?: string
/**
@@ -1788,11 +1788,11 @@ export type VisionScannersObservationsRetrieveParams = {
export type VisionScannersObservationsStatsRetrieveParams = {
/**
- * Only observations created at or after this time. Accepts ISO 8601 or a relative date like `-7d`.
+ * Only observations created at or after this time. Accepts ISO 8601 or a relative date like `-7d`; values without an explicit offset are interpreted in the project's timezone.
*/
date_from?: string
/**
- * Only observations created at or before this time. Accepts ISO 8601 or a relative date like `-1d`; date-only values include the whole day.
+ * Only observations created at or before this time. Accepts ISO 8601 or a relative date like `-1d`; date-only values include the whole day, interpreted in the project's timezone.
*/
date_to?: string
/**
diff --git a/products/replay_vision/frontend/replay_scanners/components/ScannerInsightsChart.tsx b/products/replay_vision/frontend/replay_scanners/components/ScannerInsightsChart.tsx
index d9d40b5211c2..675f538800bf 100644
--- a/products/replay_vision/frontend/replay_scanners/components/ScannerInsightsChart.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/ScannerInsightsChart.tsx
@@ -1,9 +1,10 @@
-import { useValues } from 'kea'
-import { useMemo } from 'react'
+import { useActions, useValues } from 'kea'
+import { useCallback, useMemo } from 'react'
import { Spinner } from '@posthog/lemon-ui'
import { InsightVizNode, NodeKind, ProductKey, TrendsQuery } from '~/queries/schema/schema-general'
+import { QueryContext } from '~/queries/types'
import {
AnyPropertyFilter,
BaseMathType,
@@ -15,7 +16,7 @@ import {
} from '~/types'
import { getReplayVisionRecordingViewDisabledReason } from '../../utils/accessControl'
-import { scannerOverviewLogic } from '../scannerOverviewLogic'
+import { OVERVIEW_CHART_INTERVAL, scannerOverviewLogic } from '../scannerOverviewLogic'
import { ScannerType } from '../types'
import { VisionInsightChart } from './VisionInsightChart'
@@ -71,7 +72,7 @@ function buildQuery(
formulaNodes: [{ formula: 'A / B * 100', custom_name: 'Yes rate' }],
},
dateRange,
- interval: 'day',
+ interval: OVERVIEW_CHART_INTERVAL,
}
}
if (scannerType === 'classifier') {
@@ -94,7 +95,7 @@ function buildQuery(
},
trendsFilter: { display: ChartDisplayType.ActionsAreaGraph },
dateRange,
- interval: 'day',
+ interval: OVERVIEW_CHART_INTERVAL,
}
}
if (scannerType === 'scorer') {
@@ -114,7 +115,7 @@ function buildQuery(
],
trendsFilter: { display: ChartDisplayType.ActionsLineGraph },
dateRange,
- interval: 'day',
+ interval: OVERVIEW_CHART_INTERVAL,
}
}
return {
@@ -130,7 +131,7 @@ function buildQuery(
],
trendsFilter: { display: ChartDisplayType.ActionsLineGraph },
dateRange,
- interval: 'day',
+ interval: OVERVIEW_CHART_INTERVAL,
}
}
@@ -178,9 +179,13 @@ 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()
+ const { drillIntoObservations } = useActions(scannerOverviewLogic({ scannerId }))
+ const onDataPointClick = useCallback<NonNullable<QueryContext['onDataPointClick']>>(
+ (series) => drillIntoObservations(series.day, series.breakdown),
+ [drillIntoObservations]
+ )
+ // The Observations tab requires session_recording read access; without it the chart stays static.
+ const canDrillIntoObservations = !getReplayVisionRecordingViewDisabledReason()
return (
<div className="border rounded p-4 bg-surface-primary space-y-3">
<div className="flex items-baseline justify-between gap-2">
@@ -205,7 +210,7 @@ export function ScannerInsightsChart({
query={chartQuery}
insightProps={chartInsightProps}
className="InsightCard h-80"
- drillable={canDrillIntoRecordings}
+ onDataPointClick={canDrillIntoObservations ? onDataPointClick : undefined}
/>
</div>
)
diff --git a/products/replay_vision/frontend/replay_scanners/components/VisionInsightChart.test.ts b/products/replay_vision/frontend/replay_scanners/components/VisionInsightChart.test.ts
index 06f75ffdd1c9..14a97ad2de99 100644
--- a/products/replay_vision/frontend/replay_scanners/components/VisionInsightChart.test.ts
+++ b/products/replay_vision/frontend/replay_scanners/components/VisionInsightChart.test.ts
@@ -1,18 +1,64 @@
-import { ChartOverlayState, chartOverlayState } from './VisionInsightChart'
-
-describe('chartOverlayState', () => {
- // `insightData` is always a truthy object from the selector, so the decision must hinge on `result`, not the object.
- const cases: [string, { result?: unknown } | null | undefined, boolean, ChartOverlayState][] = [
- ['null insightData while loading', null, true, 'loading'],
- ['null insightData settled (cancelled/never-loaded)', null, false, 'error'],
- ['truthy object with no result while loading', { result: undefined }, true, 'loading'],
- ['truthy object with no result settled', { result: undefined }, false, 'error'],
- ['loaded with rows', { result: [{ x: 1 }] }, false, 'none'],
- ['loaded but empty result', { result: [] }, false, 'none'],
- ['loaded, ignores a stale loading flag during refresh', { result: [{ x: 1 }] }, true, 'none'],
- ]
-
- it.each(cases)('%s', (_label, insightData, loading, expected) => {
- expect(chartOverlayState(insightData, loading)).toEqual(expected)
+jest.mock('~/queries/query', () => ({
+ __esModule: true,
+ ...jest.requireActual('~/queries/query'),
+ performQuery: jest.fn().mockResolvedValue({ result: [] }),
+}))
+
+import { insightDataLogic } from 'scenes/insights/insightDataLogic'
+import { insightLogic } from 'scenes/insights/insightLogic'
+
+import { InsightVizNode, NodeKind, TrendsQuery } from '~/queries/schema/schema-general'
+import { initKeaTests } from '~/test/init'
+
+import { ChartOverlayState, adHocInsightProps, chartOverlayState, embeddedVisionChartQuery } from './VisionInsightChart'
+
+const TRENDS_VIZ: InsightVizNode = {
+ kind: NodeKind.InsightVizNode,
+ source: {
+ kind: NodeKind.TrendsQuery,
+ series: [{ kind: NodeKind.EventsNode, event: '$recording_observed' }],
+ } as TrendsQuery,
+}
+
+describe('VisionInsightChart', () => {
+ describe('chartOverlayState', () => {
+ // `insightData` is always a truthy object from the selector, so the decision must hinge on `result`, not the object.
+ const cases: [string, { result?: unknown } | null | undefined, boolean, ChartOverlayState][] = [
+ ['null insightData while loading', null, true, 'loading'],
+ ['null insightData settled (cancelled/never-loaded)', null, false, 'error'],
+ ['truthy object with no result while loading', { result: undefined }, true, 'loading'],
+ ['truthy object with no result settled', { result: undefined }, false, 'error'],
+ ['loaded with rows', { result: [{ x: 1 }] }, false, 'none'],
+ ['loaded but empty result', { result: [] }, false, 'none'],
+ ['loaded, ignores a stale loading flag during refresh', { result: [{ x: 1 }] }, true, 'none'],
+ ]
+
+ it.each(cases)('%s', (_label, insightData, loading, expected) => {
+ expect(chartOverlayState(insightData, loading)).toEqual(expected)
+ })
+ })
+
+ describe('persons modal opt-out', () => {
+ // hidePersonsModal only reaches the modal gate via `new-AdHoc.`-keyed props (insightDataLogic's propsQuery),
+ // so this guards the exact wiring that once silently regressed to a live modal.
+ it('showPersonsModal is false for the props the chart builds', async () => {
+ initKeaTests()
+ const props = adHocInsightProps(
+ { dashboardItemId: 'new-replay-vision-test-chart' },
+ embeddedVisionChartQuery(TRENDS_VIZ)
+ )
+ expect(props.dashboardItemId).toBe('new-AdHoc.new-replay-vision-test-chart')
+
+ const dataLogic = insightDataLogic(props)
+ dataLogic.mount()
+ const logic = insightLogic(props)
+ logic.mount()
+
+ expect(dataLogic.values.query).toMatchObject({ hidePersonsModal: true })
+ expect(logic.values.showPersonsModal).toBe(false)
+
+ logic.unmount()
+ dataLogic.unmount()
+ })
})
})
diff --git a/products/replay_vision/frontend/replay_scanners/components/VisionInsightChart.tsx b/products/replay_vision/frontend/replay_scanners/components/VisionInsightChart.tsx
index 754400d17f3e..579e53a1253e 100644
--- a/products/replay_vision/frontend/replay_scanners/components/VisionInsightChart.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/VisionInsightChart.tsx
@@ -1,5 +1,6 @@
import clsx from 'clsx'
import { useActions, useValues } from 'kea'
+import { useMemo } from 'react'
import { LemonButton, Spinner } from '@posthog/lemon-ui'
@@ -7,6 +8,7 @@ import { insightVizDataLogic } from 'scenes/insights/insightVizDataLogic'
import { Query } from '~/queries/Query/Query'
import { InsightVizNode } from '~/queries/schema/schema-general'
+import { QueryContext } from '~/queries/types'
import { InsightLogicProps } from '~/types'
interface VisionInsightChartProps {
@@ -15,8 +17,23 @@ 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
+ /** Custom handler for data point clicks (must be stable/memoized). Without one, charts stay static. */
+ onDataPointClick?: QueryContext['onDataPointClick']
+}
+
+/** Vision events all belong to one synthetic person, so the generic persons modal would only list meaningless actors. */
+export function embeddedVisionChartQuery(query: InsightVizNode): InsightVizNode {
+ return { ...query, hidePersonsModal: true }
+}
+
+/** Only `new-AdHoc.`-keyed props push `query` into insightDataLogic (its `propsQuery` selector), which is what lets `hidePersonsModal` stick. */
+export function adHocInsightProps(insightProps: InsightLogicProps, query: InsightVizNode): InsightLogicProps {
+ const id = insightProps.dashboardItemId ?? 'vision-chart'
+ return {
+ ...insightProps,
+ dashboardItemId: id.startsWith('new-AdHoc.') ? (id as `new-${string}`) : `new-AdHoc.${id}`,
+ query,
+ }
}
export type ChartOverlayState = 'none' | 'loading' | 'error'
@@ -45,9 +62,15 @@ export function VisionInsightChart({
query,
insightProps,
className,
- drillable = false,
+ onDataPointClick,
}: VisionInsightChartProps): JSX.Element {
- const logic = insightVizDataLogic(insightProps)
+ const chartQuery = useMemo(() => embeddedVisionChartQuery(query), [query])
+ const chartProps = useMemo(() => adHocInsightProps(insightProps, chartQuery), [insightProps, chartQuery])
+ const context = useMemo<QueryContext>(
+ () => ({ insightProps: chartProps, onDataPointClick }),
+ [chartProps, onDataPointClick]
+ )
+ const logic = insightVizDataLogic(chartProps)
const { insightData, insightDataLoading } = useValues(logic)
const { loadData } = useActions(logic)
@@ -55,7 +78,7 @@ export function VisionInsightChart({
return (
<div className={clsx('relative', className)}>
- <Query query={query} readOnly embedded inSharedMode={!drillable} context={{ insightProps }} />
+ <Query query={chartQuery} readOnly embedded inSharedMode context={context} />
{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/replay_scanners/replayScannerLogic.test.ts b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.test.ts
index 00a459f07ed9..d2304b9c3caa 100644
--- a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.test.ts
+++ b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.test.ts
@@ -15,6 +15,7 @@ import {
replayScannerLogic,
shouldGuardScannerNavigation,
} from './replayScannerLogic'
+import { observationsDrilldownSearchParams } from './scannerOverviewLogic'
import { defaultScannerTemplates } from './scannerTemplates'
import { ClassifierScanner, ReplayScanner, ScorerScanner } from './types'
@@ -34,6 +35,11 @@ describe('replayScannerLogic', () => {
get: {
'/api/projects/:team/vision/scanners/:id/': () => [404, {}],
'/api/projects/:team/vision/scanners/:id/observations/': { results: [] },
+ '/api/projects/:team/vision/scanners/:id/observations/stats/': {
+ status_counts: { total: 0, succeeded: 0, failed: 0, ineligible: 0, in_flight: 0 },
+ coverage: { recent_sessions: 0, total_sessions: 0, recent_days: 14 },
+ available_tags: [],
+ },
},
post: {
'/api/projects/:team/vision/scanners/': createSpy,
@@ -698,4 +704,27 @@ describe('replayScannerLogic', () => {
}
})
})
+
+ describe('observations drill-down round-trip', () => {
+ // Guards the URL contract between the Overview chart drill-down and this logic's urlToAction:
+ // a param rename on either side breaks the drill-down silently.
+ it('restores the drill-down search params into the observations table filters', async () => {
+ const sidLogic = replayScannerLogic({ id: 'sid' })
+ sidLogic.mount()
+ try {
+ const params = observationsDrilldownSearchParams({
+ day: '2026-05-04',
+ interval: 'day',
+ scannerType: 'monitor',
+ })
+ router.actions.push(urls.replayVision('sid'), params!)
+ await expectLogic(sidLogic).toFinishAllListeners()
+ expect(sidLogic.values.observationDateFrom).toBe('2026-05-04')
+ expect(sidLogic.values.observationDateTo).toBe('2026-05-04')
+ expect(sidLogic.values.observationVerdictFilter).toEqual(['yes'])
+ } finally {
+ sidLogic.unmount()
+ }
+ })
+ })
})
diff --git a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts
index ecfd67ed824d..a01d6f1863f8 100644
--- a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts
+++ b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts
@@ -1571,6 +1571,9 @@ const TABLE_URL_PARAM_KEYS = [
'date_to',
] as const
+/** Observation-filter params the scanner page reads from the URL; links into the Observations tab build from these keys. */
+export type ObservationsUrlParams = Partial<Record<(typeof TABLE_URL_PARAM_KEYS)[number], string>>
+
/** The three step URLs of a scanner's editor wizard. */
function scannerEditorPaths(scannerId: string): string[] {
return [
diff --git a/products/replay_vision/frontend/replay_scanners/scannerOverviewLogic.test.ts b/products/replay_vision/frontend/replay_scanners/scannerOverviewLogic.test.ts
index 572eae0a925e..65f3fc914b6c 100644
--- a/products/replay_vision/frontend/replay_scanners/scannerOverviewLogic.test.ts
+++ b/products/replay_vision/frontend/replay_scanners/scannerOverviewLogic.test.ts
@@ -1,9 +1,12 @@
+import { router } from 'kea-router'
import { expectLogic } from 'kea-test-utils'
+import { urls } from 'scenes/urls'
+
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
-import { scannerOverviewLogic } from './scannerOverviewLogic'
+import { observationsDrilldownSearchParams, scannerOverviewLogic } from './scannerOverviewLogic'
const STATS = {
status_counts: { total: 0, succeeded: 0, failed: 0, ineligible: 0, in_flight: 0, success_rate: null },
@@ -106,4 +109,74 @@ describe('scannerOverviewLogic', () => {
expect(logic.values.overviewVerdictFilter).toEqual([])
expect(logic.values.hasActiveOverviewFilters).toBe(false)
})
+
+ describe('observationsDrilldownSearchParams', () => {
+ const day = (overrides: object = {}): Parameters<typeof observationsDrilldownSearchParams>[0] => ({
+ day: '2026-05-04',
+ interval: 'day',
+ ...overrides,
+ })
+
+ it('maps a clicked day to an inclusive single-day observations filter', () => {
+ expect(observationsDrilldownSearchParams(day())).toEqual({
+ tab: 'observations',
+ date_from: '2026-05-04',
+ date_to: '2026-05-04',
+ })
+ })
+
+ it('adds verdict=yes for monitor scanners, whose chart plots the yes rate', () => {
+ expect(observationsDrilldownSearchParams(day({ scannerType: 'monitor' }))?.verdict).toBe('yes')
+ expect(observationsDrilldownSearchParams(day({ scannerType: 'classifier' }))?.verdict).toBeUndefined()
+ })
+
+ const tagCases: [string, unknown, string | undefined][] = [
+ ['plain tag', 'rageclick', 'rageclick'],
+ ['single-value breakdown array', ['rageclick'], 'rageclick'],
+ ['other bucket', '$$_posthog_breakdown_other_$$', undefined],
+ ['null bucket', '$$_posthog_breakdown_null_$$', undefined],
+ ['numeric breakdown', 42, undefined],
+ ['empty string', '', undefined],
+ ]
+
+ it.each(tagCases)('breakdown handling: %s', (_label, breakdown, expected) => {
+ expect(observationsDrilldownSearchParams(day({ breakdown }))?.tags).toEqual(expected)
+ })
+
+ it('slices datetime buckets to their date', () => {
+ expect(observationsDrilldownSearchParams(day({ day: '2026-05-04 14:00:00' }))?.date_from).toBe('2026-05-04')
+ })
+
+ // Buckets without a single-day meaning have no Observations-tab equivalent, so the click is a no-op.
+ const noOpCases: [string, object][] = [
+ ['undefined day', { day: undefined }],
+ ['numeric day', { day: 1753747200 }],
+ ['non-date label', { day: 'previous' }],
+ ['week interval', { interval: 'week' }],
+ ]
+
+ it.each(noOpCases)('returns null for %s', (_label, overrides) => {
+ expect(observationsDrilldownSearchParams(day(overrides))).toBeNull()
+ })
+ })
+
+ describe('drillIntoObservations', () => {
+ it('navigates to the observations tab filtered to the clicked day, with the monitor verdict', async () => {
+ // The mocked scanner is a monitor, so the drill-down should carry verdict=yes.
+ await expectLogic(logic, () => logic.actions.drillIntoObservations('2026-05-04')).toFinishAllListeners()
+ expect(router.values.location.pathname).toContain(urls.replayVision('sid'))
+ expect(router.values.searchParams).toMatchObject({
+ tab: 'observations',
+ date_from: '2026-05-04',
+ date_to: '2026-05-04',
+ verdict: 'yes',
+ })
+ })
+
+ it('ignores clicks on buckets that cannot map to a day filter', async () => {
+ const before = router.values.location.pathname
+ await expectLogic(logic, () => logic.actions.drillIntoObservations(undefined)).toFinishAllListeners()
+ expect(router.values.location.pathname).toBe(before)
+ })
+ })
})
diff --git a/products/replay_vision/frontend/replay_scanners/scannerOverviewLogic.ts b/products/replay_vision/frontend/replay_scanners/scannerOverviewLogic.ts
index 70a31bd5822c..0bf2b6050525 100644
--- a/products/replay_vision/frontend/replay_scanners/scannerOverviewLogic.ts
+++ b/products/replay_vision/frontend/replay_scanners/scannerOverviewLogic.ts
@@ -13,14 +13,19 @@ import {
selectors,
} from 'kea'
import { loaders } from 'kea-loaders'
+import { router } from 'kea-router'
import { lemonToast } from 'lib/lemon-ui/LemonToast'
+import { isNullBreakdown, isOtherBreakdown } from 'scenes/insights/utils'
import { teamLogic } from 'scenes/teamLogic'
+import { urls } from 'scenes/urls'
+
+import { IntervalType } from '~/types'
import { visionScannersImpactRetrieve, visionScannersObservationsStatsRetrieve } from '../generated/api'
import type { ObservationStatsApi, ScannerImpactApi } from '../generated/api.schemas'
import { replayScannerLogic } from './replayScannerLogic'
-import type { ObservationVerdictValue } from './replayScannerLogic'
+import type { ObservationVerdictValue, ObservationsUrlParams } from './replayScannerLogic'
import type {
ClassifierTagStats,
CoverageStats,
@@ -39,7 +44,7 @@ import {
deriveScorerSummary,
deriveSummarizerFacetStats,
} from './scannerStats'
-import type { ReplayScanner } from './types'
+import type { ReplayScanner, ScannerType } from './types'
export interface ScannerOverviewLogicProps {
scannerId: string
@@ -47,6 +52,38 @@ export interface ScannerOverviewLogicProps {
const DEFAULT_DATE_FROM = '-14d'
+/** The bucket size of the Overview charts; the drill-down only knows how to map day buckets onto the Observations tab. */
+export const OVERVIEW_CHART_INTERVAL: IntervalType = 'day'
+
+/** Observations-tab search params for a clicked Overview chart point, or null when the bucket can't map to a day filter. */
+export function observationsDrilldownSearchParams(options: {
+ day: string | number | undefined
+ breakdown?: unknown
+ interval: IntervalType
+ scannerType?: ScannerType
+}): ({ tab: 'observations' } & ObservationsUrlParams) | null {
+ const { day, breakdown, interval, scannerType } = options
+ if (interval !== 'day' || typeof day !== 'string' || !/^\d{4}-\d{2}-\d{2}/.test(day)) {
+ return null
+ }
+ const date = day.slice(0, 10)
+ const params: { tab: 'observations' } & ObservationsUrlParams = {
+ tab: 'observations',
+ date_from: date,
+ date_to: date,
+ }
+ // The monitor chart plots the yes rate, so land on the sessions behind the numerator.
+ if (scannerType === 'monitor') {
+ params.verdict = 'yes'
+ }
+ const tag = Array.isArray(breakdown) ? breakdown[0] : breakdown
+ // The "Other"/"None" breakdown buckets aren't real tags, so they can't narrow the tab.
+ if (typeof tag === 'string' && tag && !isOtherBreakdown(tag) && !isNullBreakdown(tag)) {
+ params.tags = tag
+ }
+ return params
+}
+
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface scannerOverviewLogicValues {
scanner: ReplayScanner // replayScannerLogic
@@ -76,6 +113,13 @@ export interface scannerOverviewLogicActions {
clearOverviewFilters: () => {
value: true
}
+ drillIntoObservations: (
+ day: number | string | undefined,
+ breakdown?: unknown
+ ) => {
+ breakdown: unknown
+ day: number | string | undefined
+ }
loadOverviewImpact: () => any
loadOverviewImpactFailure: (
error: string,
@@ -170,6 +214,7 @@ export const scannerOverviewLogic = kea<scannerOverviewLogicType>([
setOverviewVerdictFilter: (values: ObservationVerdictValue[]) => ({ values }),
setOverviewTagFilter: (values: string[]) => ({ values }),
clearOverviewFilters: true,
+ drillIntoObservations: (day: string | number | undefined, breakdown?: unknown) => ({ day, breakdown }),
}),
reducers({
@@ -298,6 +343,19 @@ export const scannerOverviewLogic = kea<scannerOverviewLogicType>([
// Impact needs the scanner type; refire once the scanner (and its type) resolves.
loadScannerSuccess: () => actions.loadOverviewImpact(),
+ drillIntoObservations: ({ day, breakdown }) => {
+ const searchParams = observationsDrilldownSearchParams({
+ day,
+ breakdown,
+ interval: OVERVIEW_CHART_INTERVAL,
+ scannerType: values.scanner?.scanner_type,
+ })
+ if (searchParams) {
+ // Replaces any existing observation filters: the drill-down defines the slice being inspected.
+ router.actions.push(urls.replayVision(props.scannerId), searchParams)
+ }
+ },
+
loadOverviewStats: async (_, breakpoint) => {
const teamId = teamLogic.values.currentTeamId
if (!teamId || props.scannerId === 'new') {
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 48c26571e26e..c4f3f06b8b4b 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -83781,11 +83781,11 @@ export namespace Schemas {
export type VisionObservationsRetrieveParams = {
/**
- * Only observations created at or after this time. Accepts ISO 8601 or a relative date like `-7d`.
+ * Only observations created at or after this time. Accepts ISO 8601 or a relative date like `-7d`; values without an explicit offset are interpreted in the project's timezone.
*/
date_from?: string;
/**
- * Only observations created at or before this time. Accepts ISO 8601 or a relative date like `-1d`; date-only values include the whole day.
+ * Only observations created at or before this time. Accepts ISO 8601 or a relative date like `-1d`; date-only values include the whole day, interpreted in the project's timezone.
*/
date_to?: string;
/**
@@ -83884,11 +83884,11 @@ export namespace Schemas {
export type VisionScannersObservationsListParams = {
/**
- * Only observations created at or after this time. Accepts ISO 8601 or a relative date like `-7d`.
+ * Only observations created at or after this time. Accepts ISO 8601 or a relative date like `-7d`; values without an explicit offset are interpreted in the project's timezone.
*/
date_from?: string;
/**
- * Only observations created at or before this time. Accepts ISO 8601 or a relative date like `-1d`; date-only values include the whole day.
+ * Only observations created at or before this time. Accepts ISO 8601 or a relative date like `-1d`; date-only values include the whole day, interpreted in the project's timezone.
*/
date_to?: string;
/**
@@ -83935,11 +83935,11 @@ export namespace Schemas {
export type VisionScannersObservationsRetrieveParams = {
/**
- * Only observations created at or after this time. Accepts ISO 8601 or a relative date like `-7d`.
+ * Only observations created at or after this time. Accepts ISO 8601 or a relative date like `-7d`; values without an explicit offset are interpreted in the project's timezone.
*/
date_from?: string;
/**
- * Only observations created at or before this time. Accepts ISO 8601 or a relative date like `-1d`; date-only values include the whole day.
+ * Only observations created at or before this time. Accepts ISO 8601 or a relative date like `-1d`; date-only values include the whole day, interpreted in the project's timezone.
*/
date_to?: string;
/**
@@ -83978,11 +83978,11 @@ export namespace Schemas {
export type VisionScannersObservationsStatsRetrieveParams = {
/**
- * Only observations created at or after this time. Accepts ISO 8601 or a relative date like `-7d`.
+ * Only observations created at or after this time. Accepts ISO 8601 or a relative date like `-7d`; values without an explicit offset are interpreted in the project's timezone.
*/
date_from?: string;
/**
- * Only observations created at or before this time. Accepts ISO 8601 or a relative date like `-1d`; date-only values include the whole day.
+ * Only observations created at or before this time. Accepts ISO 8601 or a relative date like `-1d`; date-only values include the whole day, interpreted in the project's timezone.
*/
date_to?: string;
/**
diff --git a/services/mcp/src/generated/replay_vision/api.ts b/services/mcp/src/generated/replay_vision/api.ts
index 6cdc274665f6..2b20b8145bad 100644
--- a/services/mcp/src/generated/replay_vision/api.ts
+++ b/services/mcp/src/generated/replay_vision/api.ts
@@ -495,12 +495,14 @@ export const VisionObservationsRetrieveQueryParams = /* @__PURE__ */ zod.object(
date_from: zod
.string()
.optional()
- .describe('Only observations created at or after this time. Accepts ISO 8601 or a relative date like `-7d`.'),
+ .describe(
+ "Only observations created at or after this time. Accepts ISO 8601 or a relative date like `-7d`; values without an explicit offset are interpreted in the project's timezone."
+ ),
date_to: zod
.string()
.optional()
.describe(
- 'Only observations created at or before this time. Accepts ISO 8601 or a relative date like `-1d`; date-only values include the whole day.'
+ "Only observations created at or before this time. Accepts ISO 8601 or a relative date like `-1d`; date-only values include the whole day, interpreted in the project's timezone."
),
labeled: zod
.string()
@@ -958,12 +960,14 @@ export const VisionScannersObservationsListQueryParams = /* @__PURE__ */ zod.obj
date_from: zod
.string()
.optional()
- .describe('Only observations created at or after this time. Accepts ISO 8601 or a relative date like `-7d`.'),
+ .describe(
+ "Only observations created at or after this time. Accepts ISO 8601 or a relative date like `-7d`; values without an explicit offset are interpreted in the project's timezone."
+ ),
date_to: zod
.string()
.optional()
.describe(
- 'Only observations created at or before this time. Accepts ISO 8601 or a relative date like `-1d`; date-only values include the whole day.'
+ "Only observations created at or before this time. Accepts ISO 8601 or a relative date like `-1d`; date-only values include the whole day, interpreted in the project's timezone."
),
labeled: zod
.boolean()
@@ -1021,12 +1025,14 @@ export const VisionScannersObservationsRetrieveQueryParams = /* @__PURE__ */ zod
date_from: zod
.string()
.optional()
- .describe('Only observations created at or after this time. Accepts ISO 8601 or a relative date like `-7d`.'),
+ .describe(
+ "Only observations created at or after this time. Accepts ISO 8601 or a relative date like `-7d`; values without an explicit offset are interpreted in the project's timezone."
+ ),
date_to: zod
.string()
.optional()
.describe(
- 'Only observations created at or before this time. Accepts ISO 8601 or a relative date like `-1d`; date-only values include the whole day.'
+ "Only observations created at or before this time. Accepts ISO 8601 or a relative date like `-1d`; date-only values include the whole day, interpreted in the project's timezone."
),
labeled: zod
.string()
@@ -1081,12 +1087,14 @@ export const VisionScannersObservationsStatsRetrieveQueryParams = /* @__PURE__ *
date_from: zod
.string()
.optional()
- .describe('Only observations created at or after this time. Accepts ISO 8601 or a relative date like `-7d`.'),
+ .describe(
+ "Only observations created at or after this time. Accepts ISO 8601 or a relative date like `-7d`; values without an explicit offset are interpreted in the project's timezone."
+ ),
date_to: zod
.string()
.optional()
.describe(
- 'Only observations created at or before this time. Accepts ISO 8601 or a relative date like `-1d`; date-only values include the whole day.'
+ "Only observations created at or before this time. Accepts ISO 8601 or a relative date like `-1d`; date-only values include the whole day, interpreted in the project's timezone."
),
labeled: zod
.string()