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): default overview range to scanner age when under a week (#112646)

Kim Svatos Dugan6c78091b5d62
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 5a4c6d235e64..faffb567772b 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -13079,9 +13079,9 @@ snapshots:
scenes-app-replay-vision--classifier-observations--light:
hash: v1.k794b7964.6fcacc536adc9752bdbb5f599db6e3f06594fa4debc7a4540b6b525bb11e793c.NI3Vj1WWags8OLGTQopF6STboc11xrZ0b16N9jIYOIM
scenes-app-replay-vision--classifier-overview--dark:
- hash: v1.k794b7964.b1f7357f9a6076f86d189fd22d033515a5dfaffdc153848343e8d5584280d78b.cQu30e3nNVxIifwcxe8DF3BuWKB6wTW4JQHKEhyVpRY
+ hash: v1.k794b7964.5b5e1b2351b8751b237e9395498394c8c38066bde74c8bc2fcc24be157b533f8.bfui9VR408mO2dqavb84bmjznqttxLLzm7CoAUbJVFI
scenes-app-replay-vision--classifier-overview--light:
- hash: v1.k794b7964.d783f97810e725be92a984582c6b85339167bdeacf4dbdfe05c47212aa9c9c75.RMVo1BoCfKz55txBT9FgJ2pldYxWqQlqT-zmXPop2KE
+ hash: v1.k794b7964.194ca4c49d68460e06f361407a05e0629cbaae418dcb9ff5acfbb469ebbcd3b0.DaGPf-7jP1nkfUL2TJAXzpk3CEoIDyHTNOfPMiOA_jI
scenes-app-replay-vision--experiment-variants--dark:
hash: v1.k794b7964.fdd4adf30d177da572195bd1b9e9d0c14e352c6673851f25f8a020270c50e08f.6WesLWYfxfVHjS8EmBHUzdkoSYACQdRj1VauuiONc6o
scenes-app-replay-vision--experiment-variants--light:
@@ -13131,17 +13131,17 @@ snapshots:
scenes-app-replay-vision--monitor-observations--light:
hash: v1.k794b7964.432b542fcb0acbebc5abd9deb9428d4aa1337b128305383161d5a161f4d01df1.UZF1mz1jxDx4rm1QMuy79xQDwcoWze3_ZFs0RLAVQCM
scenes-app-replay-vision--monitor-overview--dark:
- hash: v1.k794b7964.f11305a2e709e7e0108c7fb03cd480ba75752f6c2d884ae1cd270fe318b6b68b.whpy_xgBs8nvtiwyPkYWT6ovNKFhwmwHR0VNGAkYGl0
+ hash: v1.k794b7964.79627bbcaf1345596a4230711f90d9eba24f1573be64c223b3c05fb85642b05f.0imokLmvnCGRhNwGiL6uxRaz3DayL3voUkn-lGl3TMg
scenes-app-replay-vision--monitor-overview--light:
- hash: v1.k794b7964.423f41d1f11920873e7f657aa56fd2c7bb9fd758c656f94edd4fa04728dea5bb.PWqdJEE1QvQAaIqg7ZHsZnpyu5eBa8mUOlvA_hIYWqw
+ hash: v1.k794b7964.78c674851e796673dbc50f43f862493f25b646aa72f0e45170dd66b737e4d8d7.3KYDsrwG2gMYKec4kttVDHpZr5J7WnNCbtj-sXFDrLc
scenes-app-replay-vision--monitor-overview-with-root-cause--dark:
- hash: v1.k794b7964.01b26567fdcf4d429d65ee57ed7064873038342528430c4380ec8f8a5933d78a.zZ4_9dl5f2qPUprcfGL-SyfyaIy3gzl0xComtoV7Ksg
+ hash: v1.k794b7964.95eb50d69e46376f28de8821b0d1dfa356c08db91249e14f900cb54e7d58c278.oCAAFUd8iCTVgaeYB6ogtIxzaALytcTJ7tuCFgqEED8
scenes-app-replay-vision--monitor-overview-with-root-cause--light:
- hash: v1.k794b7964.318d3703de117fffe975a1c77c494b05918565f7ec0b5c2d96a2631d6fb21991.jKSetvdRTd5dg-gC7kRbzbaVOKbDTmBPsPvp3vLqNX8
+ hash: v1.k794b7964.073eab68ce364fe54825e75de13b55b6ba8311f3847ac3d9587b13a92535b1a5.nUn1DOo5NrJydsJ5f6DcBI9-1ekBAIBckrHF_hZGb2Q
scenes-app-replay-vision--monitor-overview-with-scout-report--dark:
- hash: v1.k794b7964.d91977fcbcd3742c55b1c1986dc0f882bd9ad2734ec33bdd1e0107ea5b3573a9.J9EJx4e07WFUd5bTKG1S0r2IXJp17Pf-n7qcM-APn6Q
+ hash: v1.k794b7964.014ed4f3a48e4a8278a97cb0649d3374b2f38104e7690550d88ff148cf475674.bA-EbiStJZ_opUpEa66H9_N3Y9gE3P-EN_P35ol1cf0
scenes-app-replay-vision--monitor-overview-with-scout-report--light:
- hash: v1.k794b7964.749b1631705f7977ec0548c84aa7c8502baa8b302c9449de0ed8aaaa817cc8fd.CFEBUveBJNQWFaxmzj85wauSeb8AfPHuTGQV5xMe4Q4
+ hash: v1.k794b7964.2b333b7d2f03a600120fdcc91a82ce1f68a39a8e8da3457ded692f576958e4a9.5PJRfXJPruTNmlASj1DjGgGiPPE1FtDZ_ZE127jZO2c
scenes-app-replay-vision--monitor-root-cause-scout-form--dark:
hash: v1.k794b7964.d5ed2f853f5e78bf2a5a4700e100a0a0fec171c7dd35b170d6d82c4c4d789c10.IU35Y8TiBpc0HN88ZA64xAT7Suw8-pWtefUjE5lj8Dw
scenes-app-replay-vision--monitor-root-cause-scout-form--light:
@@ -13253,7 +13253,7 @@ snapshots:
scenes-app-replay-vision--scanner-scan-drought--dark:
hash: v1.k794b7964.5c09744ba06f15580bfd640c2a809591bb56086af17814fe74274f0acaf11d33.OZTilyTCRycOtXM67McARvKkGn8D3KKAdw5-XaD1zO4
scenes-app-replay-vision--scanner-scan-drought--light:
- hash: v1.k794b7964.1d32ee6ac5611df1025dce903ffaa8159d0d681b617002e98b1d6e86cb260ad5.S3hqhlec6jYgTFED9P2Kzo3ohLklHSsmCRVKtmQ9G4k
+ hash: v1.k794b7964.6a5ab1a3452c76cb23e89db3eb1c109361b1a2d1c3301512efff010eb476a0f2.i6TqWeh0WalzF2nrzlw6fFwKQJceWOJeA5Z-M1o1-RY
scenes-app-replay-vision--scanner-scouts--dark:
hash: v1.k794b7964.f2ec81ed8ea5bb2bac407771a1048892005f99fa1c8f5f2a28a142cb634a6463.xxFctKJq59z32tHbG0qxE4ej9rs08md6SuEDCc9oIGU
scenes-app-replay-vision--scanner-scouts--light:
diff --git a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx
index 536f30b5b7f8..f800826a3246 100644
--- a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx
+++ b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx
@@ -71,7 +71,8 @@ const scanner = (overrides: Partial<ReplayScannerApi> = {}): ReplayScannerApi =>
emits_signals: false,
scanner_version: 1,
last_swept_at: '2026-05-12T00:00:00Z',
- created_at: '2026-05-12T00:00:00Z',
+ // Older than the Overview's 14-day default, so its range matches the 14 days in the trend mock.
+ created_at: '2026-04-01T00:00:00Z',
updated_at: '2026-05-12T00:00:00Z',
created_by: null,
credits_this_month: 0,
diff --git a/products/replay_vision/frontend/replay_scanners/scannerOverviewLogic.test.ts b/products/replay_vision/frontend/replay_scanners/scannerOverviewLogic.test.ts
index ef4e68fd43cc..07ae04416c6e 100644
--- a/products/replay_vision/frontend/replay_scanners/scannerOverviewLogic.test.ts
+++ b/products/replay_vision/frontend/replay_scanners/scannerOverviewLogic.test.ts
@@ -8,7 +8,11 @@ import { urls } from 'scenes/urls'
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
-import { observationsDrilldownSearchParams, scannerOverviewLogic } from './scannerOverviewLogic'
+import {
+ observationsDrilldownSearchParams,
+ overviewDefaultDateFrom,
+ scannerOverviewLogic,
+} from './scannerOverviewLogic'
const STATS = {
status_counts: { total: 0, succeeded: 0, failed: 0, ineligible: 0, in_flight: 0, success_rate: null },
@@ -35,6 +39,8 @@ describe('scannerOverviewLogic', () => {
scanner_config: { prompt: 'p' },
sampling_rate: 1,
enabled: true,
+ // Old enough that the Overview keeps its standard 14-day default.
+ created_at: dayjs().subtract(30, 'day').toISOString(),
},
'/api/projects/:team/vision/scanners/:id/observations/': { results: [], count: 0 },
'/api/projects/:team/vision/scanners/:id/observations/stats/': ({ request }) => {
@@ -162,6 +168,20 @@ describe('scannerOverviewLogic', () => {
})
})
+ describe('overviewDefaultDateFrom', () => {
+ const now = dayjs('2026-03-10T15:00:00Z')
+
+ it.each([
+ ['an unsaved scanner', undefined, '-14d'],
+ ['a scanner created today', '2026-03-10T09:00:00Z', '-1d'],
+ ['a scanner created yesterday', '2026-03-09T23:00:00Z', '-1d'],
+ ['a scanner created six days ago', '2026-03-04T09:00:00Z', '-6d'],
+ ['a scanner created a week ago', '2026-03-03T09:00:00Z', '-14d'],
+ ])('defaults %s to %s', (_name, createdAt, expected) => {
+ expect(overviewDefaultDateFrom(createdAt, now)).toBe(expected)
+ })
+ })
+
describe('observationsDrilldownSearchParams', () => {
const day = (overrides: object = {}): Parameters<typeof observationsDrilldownSearchParams>[0] => ({
day: '2026-05-04',
@@ -270,6 +290,22 @@ describe('scannerOverviewLogic', () => {
expect(freshLogic.values.firstScanPending).toBe(true)
})
+ it('defaults the date range to the days since a young scanner was created', async () => {
+ freshLogic.mount()
+ await expectLogic(freshLogic).toFinishAllListeners()
+
+ // The scanner loads after the first stats request, so the newest request must use its age.
+ expect(freshLogic.values.overviewDateFrom).toBe('-1d')
+ expect(new URL(statsRequests[statsRequests.length - 1]).searchParams.get('date_from')).toBe('-1d')
+ expect(freshLogic.values.hasActiveOverviewFilters).toBe(false)
+
+ await expectLogic(freshLogic, () =>
+ freshLogic.actions.setOverviewDateRange('-30d', null)
+ ).toFinishAllListeners()
+ expect(freshLogic.values.overviewDateFrom).toBe('-30d')
+ expect(freshLogic.values.hasActiveOverviewFilters).toBe(true)
+ })
+
it('polls stats in the background while pending and stops once observations settle', async () => {
// toFinishAllListeners hangs under fake timers (msw resolves responses on the clock),
// so the whole test advances fake time instead, which also flushes microtasks.
diff --git a/products/replay_vision/frontend/replay_scanners/scannerOverviewLogic.ts b/products/replay_vision/frontend/replay_scanners/scannerOverviewLogic.ts
index 67db86f2dcd6..35a727e3c376 100644
--- a/products/replay_vision/frontend/replay_scanners/scannerOverviewLogic.ts
+++ b/products/replay_vision/frontend/replay_scanners/scannerOverviewLogic.ts
@@ -14,7 +14,7 @@ import {
} from 'kea'
import { router } from 'kea-router'
-import { dayjs } from 'lib/dayjs'
+import { Dayjs, dayjs } from 'lib/dayjs'
import { lemonToast } from 'lib/lemon-ui/LemonToast'
import { dateStringToDayJs } from 'lib/utils/dateFilters'
import { isNullBreakdown, isOtherBreakdown } from 'scenes/insights/utils'
@@ -53,6 +53,9 @@ export interface ScannerOverviewLogicProps {
const DEFAULT_DATE_FROM = '-14d'
+// A scanner emits no events before it was created, so for a young scanner the 14-day default is mostly empty days.
+const NEW_SCANNER_MAX_AGE_DAYS = 7
+
// Calmer than the 3s in-flight default: first scheduled results take minutes, not seconds.
const FIRST_SCAN_POLL_INTERVAL_MS = 15_000
@@ -60,6 +63,15 @@ const FIRST_SCAN_POLL_INTERVAL_MS = 15_000
// checks it has to admit the failure itself instead of spinning on a promise it can't verify.
const FIRST_SCAN_CHECK_FAILING_AFTER = 3
+/** The Overview's default date range: the days since a young scanner was created, else the last 14 days. */
+export function overviewDefaultDateFrom(createdAt: string | null | undefined, now: Dayjs = dayjs()): string {
+ if (!createdAt) {
+ return DEFAULT_DATE_FROM
+ }
+ const ageDays = now.startOf('day').diff(dayjs(createdAt).startOf('day'), 'day')
+ return ageDays < NEW_SCANNER_MAX_AGE_DAYS ? `-${Math.max(1, ageDays)}d` : DEFAULT_DATE_FROM
+}
+
/** 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'
@@ -100,12 +112,14 @@ export interface scannerOverviewLogicValues {
cohortDisabledReason: string | null
cohortWindowDays: number
coverageStats: CoverageStats
+ defaultOverviewDateFrom: string
firstScanCheckFailing: boolean
firstScanPending: boolean
firstScanSettled: boolean
hasActiveOverviewFilters: boolean
monitorStats: MonitorStats
overviewDateFrom: string | null
+ overviewDateSelection: { dateFrom: string | null } | null
overviewDateTo: string | null
overviewStatsApi: ObservationStatsApi | null
overviewStatsApiLoading: boolean
@@ -176,11 +190,17 @@ export interface scannerOverviewLogicActions {
export interface scannerOverviewLogicMeta {
key: string
__keaTypeGenInternalSelectorTypes: {
+ defaultOverviewDateFrom: (scanner: ScannerFormValues) => string
+ overviewDateFrom: (
+ overviewDateSelection: { dateFrom: string | null } | null,
+ defaultOverviewDateFrom: string
+ ) => string | null
hasActiveOverviewFilters: (
overviewVerdictFilter: ObservationVerdictValue[],
overviewTagFilter: string[],
overviewDateFrom: string | null,
- overviewDateTo: string | null
+ overviewDateTo: string | null,
+ defaultOverviewDateFrom: string
) => boolean
availableTags: (overviewStatsApi: ObservationStatsApi | null) => string[]
monitorStats: (overviewStatsApi: ObservationStatsApi | null) => MonitorStats
@@ -246,11 +266,12 @@ export const scannerOverviewLogic = kea<scannerOverviewLogicType>([
}),
reducers({
- overviewDateFrom: [
- DEFAULT_DATE_FROM as string | null,
+ // Null until the user picks a range, so the default can follow the scanner's age once it loads.
+ overviewDateSelection: [
+ null as { dateFrom: string | null } | null,
{
- setOverviewDateRange: (_, { dateFrom }) => dateFrom,
- clearOverviewFilters: () => DEFAULT_DATE_FROM,
+ setOverviewDateRange: (_, { dateFrom }) => ({ dateFrom }),
+ clearOverviewFilters: () => null,
},
],
overviewDateTo: [
@@ -315,16 +336,32 @@ export const scannerOverviewLogic = kea<scannerOverviewLogicType>([
}),
selectors({
+ defaultOverviewDateFrom: [
+ (s) => [s.scanner],
+ (scanner: ReplayScanner | null): string => overviewDefaultDateFrom(scanner?.created_at),
+ ],
+ overviewDateFrom: [
+ (s) => [s.overviewDateSelection, s.defaultOverviewDateFrom],
+ (selection: { dateFrom: string | null } | null, defaultDateFrom: string): string | null =>
+ selection ? selection.dateFrom : defaultDateFrom,
+ ],
// The date default alone isn't an "active" filter; only the pills (and a non-default date) are.
hasActiveOverviewFilters: [
- (s) => [s.overviewVerdictFilter, s.overviewTagFilter, s.overviewDateFrom, s.overviewDateTo],
+ (s) => [
+ s.overviewVerdictFilter,
+ s.overviewTagFilter,
+ s.overviewDateFrom,
+ s.overviewDateTo,
+ s.defaultOverviewDateFrom,
+ ],
(
verdictFilter: ObservationVerdictValue[],
tagFilter: string[],
dateFrom: string | null,
- dateTo: string | null
+ dateTo: string | null,
+ defaultDateFrom: string
): boolean =>
- verdictFilter.length > 0 || tagFilter.length > 0 || dateFrom !== DEFAULT_DATE_FROM || dateTo !== null,
+ verdictFilter.length > 0 || tagFilter.length > 0 || dateFrom !== defaultDateFrom || dateTo !== null,
],
// Wrap the shared derivations in inline arrows with explicit return types so kea-typegen
// can infer them (it can't resolve return types from bare imported-function references).
@@ -469,8 +506,14 @@ export const scannerOverviewLogic = kea<scannerOverviewLogicType>([
loadOverviewStatsSuccess: syncFirstScanPoll,
loadOverviewStatsFailure: syncFirstScanPoll,
scannerWatermarkRefreshed: syncFirstScanPoll,
- // Pending depends on the sweep watermark, which may resolve after the first stats response.
- loadScannerSuccess: syncFirstScanPoll,
+ loadScannerSuccess: () => {
+ // The default range depends on the scanner's age, which may load after the first stats request.
+ if (values.overviewDateFrom !== cache.statsDateFrom) {
+ reloadStats()
+ }
+ // Pending depends on the sweep watermark, which may resolve after the first stats response.
+ syncFirstScanPoll()
+ },
saveCohort: ({ qualifier }) => actions.saveAffectedCohort(values.cohortWindowDays, qualifier),
@@ -488,6 +531,7 @@ export const scannerOverviewLogic = kea<scannerOverviewLogicType>([
},
loadOverviewStats: async (_, breakpoint) => {
+ cache.statsDateFrom = values.overviewDateFrom
const teamId = teamLogic.values.currentTeamId
if (!teamId || props.scannerId === 'new') {
actions.loadOverviewStatsFailure()