: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
fix(experiments): offer buttons in empty "too-early" state on recordings tab (#101644)
Marcel Poelker424228673e3a
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 99d879de38f4..03b510aad110 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -7820,6 +7820,10 @@ snapshots:hash: v1.k794b7964.461cc90ab6b2e52b99111e0631d253e47347647f994b2500ceb87eeb77c6b771.3taB8yr84NutLTUwM3FMvtp-Z9R0KSmjXY1j9hUx5R0scenes-app-experiments--experiment-recordings-empty-too-early--light:hash: v1.k794b7964.5cf3abd3f3e537339d3ed11cbc1dc3458c815dc86d604dbf8b10706f15e4256b.xrmpvVhU_I1uoQfXcreRrNEetOw5r37Uf3xQuow99nI+ scenes-app-experiments--experiment-recordings-empty-too-early-with-variant-selected--dark:+ hash: v1.k794b7964.5f4d54b0bbe64c6a906e4a290405648ce7c80c97c86f19d281ff9829fd19e05b.5YPMxoq0_-4wYzjQ7CiyCWqvPi6la0L9pRYSgTVAvJI+ scenes-app-experiments--experiment-recordings-empty-too-early-with-variant-selected--light:+ hash: v1.k794b7964.93da1e924fa384a4145cab3dda5debd9d1bb8cb4cce8c966e3c549fef7c3132f.VgpPDGtm07ehdQcnqCMd7YS-DdZqFpewcfqparhhwA4scenes-app-experiments--experiment-recordings-empty-unknown-in-window--dark:hash: v1.k794b7964.8cc424769dc71c1d102074ed089a9762c5c0b26328cc41d038a66020f6a9d3ac.wVEIH7FEp0NL6rq-dldcLPVuPLtX4C_h75c1OITmY2Yscenes-app-experiments--experiment-recordings-empty-unknown-in-window--light:diff --git a/frontend/src/lib/utils/eventUsageLogic.ts b/frontend/src/lib/utils/eventUsageLogic.tsindex 003252192d0c..b88bf92c3ad3 100644--- a/frontend/src/lib/utils/eventUsageLogic.ts+++ b/frontend/src/lib/utils/eventUsageLogic.ts@@ -184,6 +184,16 @@ export interface ExperimentRecordingsListRenderedContext extends ExperimentRecorresult_count: number/** Null when the list has rows. One of the tab's `ExperimentReplayListEmptyReason` values. */empty_reason: string | null+ /**+ * The way out the empty state offered, null when its banner offered none. This follows+ * `empty_reason` rather than the state of the tab: four reasons carry a way out of a narrowing,+ * and the rest carry a link or nothing, so a variant that still narrows the list is not+ * reported here when replay is off or the window expired. Null on a list with rows too, for the+ * same reason `empty_reason` is. The values match `action` on `experiment recordings empty+ * state action clicked`, so the two together size how often a viewer takes the way out against+ * how often it is offered.+ */+ narrowing_action: string | null/** Null when the experiment has not launched. */days_since_start: number | null/** Null while the experiment runs. */@@ -218,6 +228,18 @@ export interface ExperimentRecordingsListRenderedContext extends ExperimentRecor* filter as a difference. The three properties above are null when the viewer removed it.*/duration_filter_customized: boolean+ /**+ * Whether the viewer narrowed the list past the tab's own scoping through the filter bar. This+ * is the input that decides `filters_narrowed`, and the only filter-bar signal the rest of this+ * event lacks.+ */+ filters_customized: boolean+ /**+ * Whose already-watched recordings the viewer hides, and `off` when the viewer hides none. The+ * server removes the recordings this setting hides before it answers, so the setting can empty+ * a list on its own, and no `empty_reason` names it.+ */+ hide_viewed_recordings: 'off' | 'current-user' | 'any-user'/** Whether the exposure event is ever seen with a session id. Null while the check is out. */exposure_linkable: boolean | null}@@ -294,6 +316,12 @@ export interface ExperimentRecordingsEmptyActionContext {empty_reason: string | null/** One of the tab's `ExperimentRecordingsEmptyAction` values. */action: string+ /**+ * Whole days from the launch to the click, null when the experiment has not launched. The same+ * count `experiment recordings list rendered` carries, so an action on a young experiment reads+ * apart from one on a run that has had time to collect recordings.+ */+ days_since_start: number | null}/**diff --git a/frontend/src/scenes/experiments/ExperimentView/ExperimentRecordingsListEmptyState.test.tsx b/frontend/src/scenes/experiments/ExperimentView/ExperimentRecordingsListEmptyState.test.tsxindex 00e4978f069a..5241504dfae3 100644--- a/frontend/src/scenes/experiments/ExperimentView/ExperimentRecordingsListEmptyState.test.tsx+++ b/frontend/src/scenes/experiments/ExperimentView/ExperimentRecordingsListEmptyState.test.tsx@@ -129,6 +129,17 @@ const REASON_CASES: ReasonCase[] = [copy: 'The experiment started 1 day ago',actions: [],},+ {+ // The same young run, narrowed to one variant. A list this young is usually empty for every+ // variant, so the copy stays the age of the run, and the banner carries the way out of the+ // variant. Without it the viewer is told to wait and given nothing to widen the list with.+ reason: ExperimentReplayListEmptyReason.TooEarly,+ experimentId: 216,+ experiment: { start_date: daysAgo(1), end_date: null },+ setup: (logic) => logic.actions.setSelectedVariantKey('test'),+ copy: 'No recordings yet',+ actions: ['experiment-recordings-empty-show-all-variants'],+ },{reason: ExperimentReplayListEmptyReason.EndedPastRetention,experimentId: 204,diff --git a/frontend/src/scenes/experiments/ExperimentView/ExperimentRecordingsListEmptyState.tsx b/frontend/src/scenes/experiments/ExperimentView/ExperimentRecordingsListEmptyState.tsxindex 21d0b9ae862b..9263257ca26a 100644--- a/frontend/src/scenes/experiments/ExperimentView/ExperimentRecordingsListEmptyState.tsx+++ b/frontend/src/scenes/experiments/ExperimentView/ExperimentRecordingsListEmptyState.tsx@@ -3,6 +3,7 @@ import { useActions, useValues } from 'kea'import { LemonBanner, LemonButton, Link } from '@posthog/lemon-ui'import { dayjs } from 'lib/dayjs'+import { LemonBannerAction } from 'lib/lemon-ui/LemonBanner/LemonBanner'import { pluralize } from 'lib/utils/strings'import { playerSettingsLogic } from 'scenes/session-recordings/player/playerSettingsLogic'import { sessionRecordingsPlaylistLogic } from 'scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic'@@ -13,8 +14,10 @@ import { Experiment } from '~/types'import {ExperimentRecordingsEmptyAction,ExperimentRecordingsListEmptyContext,+ ExperimentRecordingsNarrowingAction,ExperimentReplayListEmptyReason,experimentReplayTabLogic,+ offeredNarrowingAction,} from './experimentReplayTabLogic'// The two hints the shared replay panel offers, kept at the same URLs so a viewer who knows one@@ -22,6 +25,28 @@ import {const RETENTION_DOCS = 'https://posthog.com/docs/session-replay/data-retention'const AD_BLOCKER_DOCS = 'https://posthog.com/docs/session-replay/troubleshooting#4-adtracking-blockers'+/**+ * What each way out of a narrowing is labeled. Two banners offer these: the narrowing's own, and+ * the too-early banner on a run too young for the narrowing to be named. One map, so the same+ * action cannot read as two different buttons.+ */+const NARROWING_ACTION_LABELS: Record<+ ExperimentRecordingsNarrowingAction,+ Pick<LemonBannerAction, 'children' | 'data-attr'>+> = {+ clear_filters: { children: 'Clear filters', 'data-attr': 'experiment-recordings-empty-clear-filters' },+ show_all_variants: { children: 'Show all variants', 'data-attr': 'experiment-recordings-empty-show-all-variants' },+ all_sessions: { children: 'All sessions', 'data-attr': 'experiment-recordings-empty-all-sessions' },+}++/** The banner action for one way out of a narrowing. */+function narrowingActionProps(+ action: ExperimentRecordingsNarrowingAction,+ onAction: (action: ExperimentRecordingsEmptyAction) => void+): LemonBannerAction {+ return { ...NARROWING_ACTION_LABELS[action], onClick: () => onAction(action) }+}+/** How long ago the run started, as the copy says it. Day zero has no count that reads right. */function startedWhen(daysSinceStart: number | null): string {if (daysSinceStart === null || daysSinceStart <= 0) {@@ -43,6 +68,9 @@ function ReasonBanner({context: ExperimentRecordingsListEmptyContextonAction: (action: ExperimentRecordingsEmptyAction) => void}): JSX.Element {+ const offered = offeredNarrowingAction(reason, context.narrowingAction)+ const offeredAction = offered ? narrowingActionProps(offered, onAction) : undefined+if (reason === ExperimentReplayListEmptyReason.ReplayDisabled) {return (<LemonBanner@@ -64,7 +92,10 @@ function ReasonBanner({}if (reason === ExperimentReplayListEmptyReason.TooEarly) {return (- <LemonBanner type="info">+ // The age of the run is the reason on a list this young, whatever the viewer narrowed+ // it by. A viewer who did narrow it still gets that narrowing's way out, rather than a+ // banner that only tells them to wait.+ <LemonBanner type="info" action={offeredAction}>No recordings yet. The experiment started {startedWhen(context.daysSinceStart)}, and a recording appearshere once an exposed person's session has been captured.</LemonBanner>@@ -113,42 +144,21 @@ function ReasonBanner({}if (reason === ExperimentReplayListEmptyReason.FiltersNarrowed) {return (- <LemonBanner- type="info"- action={{- children: 'Clear filters',- onClick: () => onAction('clear_filters'),- 'data-attr': 'experiment-recordings-empty-clear-filters',- }}- >+ <LemonBanner type="info" action={offeredAction}>No recordings match the filters added above. Clear them to widen the list back to everyone exposed.</LemonBanner>)}if (reason === ExperimentReplayListEmptyReason.VariantHasNone) {return (- <LemonBanner- type="info"- action={{- children: 'Show all variants',- onClick: () => onAction('show_all_variants'),- 'data-attr': 'experiment-recordings-empty-show-all-variants',- }}- >+ <LemonBanner type="info" action={offeredAction}>No recordings for the {context.variantKey} variant. The other variants can still have some.</LemonBanner>)}if (reason === ExperimentReplayListEmptyReason.InSessionHasNone) {return (- <LemonBanner- type="info"- action={{- children: 'All sessions',- onClick: () => onAction('all_sessions'),- 'data-attr': 'experiment-recordings-empty-all-sessions',- }}- >+ <LemonBanner type="info" action={offeredAction}>No recordings of the sessions the exposure happened in. The same people can still have recordings oftheir other sessions.</LemonBanner>diff --git a/frontend/src/scenes/experiments/ExperimentView/experimentReplayTabLogic.test.ts b/frontend/src/scenes/experiments/ExperimentView/experimentReplayTabLogic.test.tsindex 447eba128c96..2019c31e3acb 100644--- a/frontend/src/scenes/experiments/ExperimentView/experimentReplayTabLogic.test.ts+++ b/frontend/src/scenes/experiments/ExperimentView/experimentReplayTabLogic.test.ts@@ -38,6 +38,7 @@ import {} from '../utils'import { viewRecordingsLinkabilityLogic } from '../viewRecordingsLinkabilityLogic'import {+ type ExperimentRecordingsNarrowingAction,type ExperimentReplayRecording,ExperimentReplayListEmptyReason,experimentReplayTabLogic,@@ -201,13 +202,35 @@ const listsRendered = (captureSpy: jest.SpyInstance, experimentId: number): any[event === 'experiment recordings list rendered' && (properties as any)?.experiment_id === experimentId)+type TabLogic = ReturnType<typeof experimentReplayTabLogic.build>++// The three narrowings the viewer controls, shared by the cases below and by the narrowing-action+// cases under them, so the two tables cannot end up describing different tabs.+const selectTestVariant = (logic: TabLogic): void => logic.actions.setSelectedVariantKey('test')++const narrowToInSession = (logic: TabLogic): void => logic.actions.setExposureScope('in_session')++const addFilterBarFilter = (logic: TabLogic): void =>+ logic.actions.playlistFiltersChanged({+ ...logic.values.recordingsFilters,+ filter_group: {+ type: FilterLogicalOperator.And,+ values: [+ {+ type: FilterLogicalOperator.And,+ values: [{ id: '$pageview', name: '$pageview', type: 'events', order: 0 }],+ },+ ],+ },+ })+interface EmptyReasonCase {reason: ExperimentReplayListEmptyReason/** One per case: the logic is keyed per experiment, and each case mounts its own. */experimentId: numberexperiment: Partial<Experiment>team?: Partial<TeamType>- setup?: (logic: ReturnType<typeof experimentReplayTabLogic.build>) => void+ setup?: (logic: TabLogic) => void}// The team's retention period is the mock default of 30 days, which the run windows are set against.@@ -267,19 +290,7 @@ const EMPTY_REASON_CASES: EmptyReasonCase[] = [reason: ExperimentReplayListEmptyReason.FiltersNarrowed,experimentId: 147,experiment: { start_date: daysAgo(10), end_date: null },- setup: (logic) =>- logic.actions.playlistFiltersChanged({- ...logic.values.recordingsFilters,- filter_group: {- type: FilterLogicalOperator.And,- values: [- {- type: FilterLogicalOperator.And,- values: [{ id: '$pageview', name: '$pageview', type: 'events', order: 0 }],- },- ],- },- }),+ setup: addFilterBarFilter,},{reason: ExperimentReplayListEmptyReason.EndedPastRetention,@@ -291,17 +302,39 @@ const EMPTY_REASON_CASES: EmptyReasonCase[] = [experimentId: 125,experiment: { start_date: daysAgo(1), end_date: null },},+ // The same young run, narrowed by the viewer. A list this young is usually empty for every+ // variant, every scope and every filter, so the age of the run stays the reason and the+ // narrowing is not named on a guess. The banner hands back the narrowing's way out instead,+ // which the narrowing-action cases below cover.+ {+ reason: ExperimentReplayListEmptyReason.TooEarly,+ experimentId: 149,+ experiment: { start_date: daysAgo(1), end_date: null },+ setup: selectTestVariant,+ },+ {+ reason: ExperimentReplayListEmptyReason.TooEarly,+ experimentId: 150,+ experiment: { start_date: daysAgo(1), end_date: null },+ setup: narrowToInSession,+ },+ {+ reason: ExperimentReplayListEmptyReason.TooEarly,+ experimentId: 151,+ experiment: { start_date: daysAgo(1), end_date: null },+ setup: addFilterBarFilter,+ },{reason: ExperimentReplayListEmptyReason.VariantHasNone,experimentId: 141,experiment: { start_date: daysAgo(10), end_date: daysAgo(2) },- setup: (logic) => logic.actions.setSelectedVariantKey('test'),+ setup: selectTestVariant,},{reason: ExperimentReplayListEmptyReason.InSessionHasNone,experimentId: 142,experiment: { start_date: daysAgo(10), end_date: daysAgo(2) },- setup: (logic) => logic.actions.setExposureScope('in_session'),+ setup: narrowToInSession,},{reason: ExperimentReplayListEmptyReason.UnknownInWindow,@@ -317,6 +350,53 @@ const EMPTY_REASON_CASES: EmptyReasonCase[] = [},]+// The way out the banner has to offer for each narrowing. Read on a young run, where the reason is+// the age of the run rather than the narrowing, so this is the only thing that gets a viewer who+// narrowed the list back out of it.+const NARROWING_ACTION_CASES: {+ narrowing: string+ experimentId: number+ team?: Partial<TeamType>+ setup?: (logic: TabLogic) => void+ reason: ExperimentReplayListEmptyReason+ action: ExperimentRecordingsNarrowingAction | null+}[] = [+ {+ narrowing: 'a filter added above',+ experimentId: 152,+ setup: addFilterBarFilter,+ reason: ExperimentReplayListEmptyReason.TooEarly,+ action: 'clear_filters',+ },+ {+ narrowing: 'a selected variant',+ experimentId: 153,+ setup: selectTestVariant,+ reason: ExperimentReplayListEmptyReason.TooEarly,+ action: 'show_all_variants',+ },+ {+ narrowing: 'the in-session scope',+ experimentId: 154,+ setup: narrowToInSession,+ reason: ExperimentReplayListEmptyReason.TooEarly,+ action: 'all_sessions',+ },+ { narrowing: 'nothing', experimentId: 155, reason: ExperimentReplayListEmptyReason.TooEarly, action: null },+ {+ // Replay off names its own cause, and its banner offers the settings link alone. The+ // variant still narrows the tab, so reading the narrowing rather than the reason would+ // report a button this viewer was never given, and every reason's click-through rate would+ // be measured against renders that offered nothing.+ narrowing: 'a selected variant under replay off',+ experimentId: 156,+ team: { session_recording_opt_in: false },+ setup: selectTestVariant,+ reason: ExperimentReplayListEmptyReason.ReplayDisabled,+ action: null,+ },+]+describe('experimentReplayTabLogic', () => {let logic: ReturnType<typeof experimentReplayTabLogic.build>let seenTogetherSpy: jest.SpyInstance@@ -878,6 +958,31 @@ describe('experimentReplayTabLogic', () => {})+ it.each(NARROWING_ACTION_CASES)(+ 'reports $action as the way out of a young run narrowed by $narrowing',+ async ({ experimentId, team, setup, reason, action }) => {+ const captureSpy = jest.spyOn(posthog, 'capture').mockReturnValue(undefined as any)+ teamLogic.actions.loadCurrentTeamSuccess({ ...MOCK_DEFAULT_TEAM, ...team })+ const young = experimentReplayTabLogic({+ experiment: { ...EXPERIMENT, id: experimentId, start_date: daysAgo(1), end_date: null } as Experiment,+ })+ young.mount()+ setup?.(young)+ await expectLogic(young).toFinishAllListeners()++ young.actions.recordingsLoaded([])+ await expectLogic(young).toFinishAllListeners()++ // The banner and the report both resolve the action from the reason, so a viewer who+ // was handed a way out and a render counted as offering one cannot come apart.+ expect(listsRendered(captureSpy, experimentId)[0][1]).toMatchObject({+ empty_reason: reason,+ narrowing_action: action,+ })+ young.unmount()+ }+ )+it('reports no reason for the hidden-recordings action, and the reason for the others', async () => {// `show_hidden` is offered when rows came back and the browser hid them, so the list is not// empty. Sending the reason there would count a cause of emptiness against a list that had@@ -899,9 +1004,13 @@ describe('experimentReplayTabLogic', () => {event === 'experiment recordings empty state action clicked' &&(properties as any)?.experiment_id === 143)- expect(clicks.map(([, properties]) => (properties as any).empty_reason)).toEqual([- null,- ExperimentReplayListEmptyReason.TooEarly,+ expect(clicks.map(([, properties]) => properties as any)).toMatchObject([+ { action: 'show_hidden', empty_reason: null, days_since_start: 1 },+ {+ action: 'replay_settings',+ empty_reason: ExperimentReplayListEmptyReason.TooEarly,+ days_since_start: 1,+ },])empty.unmount()@@ -928,6 +1037,7 @@ describe('experimentReplayTabLogic', () => {experiment_id: 111,result_count: 2,empty_reason: null,+ narrowing_action: null,days_since_start: 10,days_since_end: 2,retention_period: '90d',@@ -938,6 +1048,8 @@ describe('experimentReplayTabLogic', () => {duration_filter_operator: 'gt',duration_filter_count: 1,duration_filter_customized: false,+ filters_customized: false,+ hide_viewed_recordings: 'off',exposure_linkable: true,variant: 'test',exposure_scope: 'all_exposed',diff --git a/frontend/src/scenes/experiments/ExperimentView/experimentReplayTabLogic.ts b/frontend/src/scenes/experiments/ExperimentView/experimentReplayTabLogic.tsindex d8d2ec63e971..83f79b593d4d 100644--- a/frontend/src/scenes/experiments/ExperimentView/experimentReplayTabLogic.ts+++ b/frontend/src/scenes/experiments/ExperimentView/experimentReplayTabLogic.ts@@ -32,6 +32,7 @@ import {} from 'lib/utils/eventUsageLogic'import { objectsEqual } from 'lib/utils/objects'import { addProductIntentForCrossSell } from 'lib/utils/product-intents'+import { HideViewedRecordingsOptions, playerSettingsLogic } from 'scenes/session-recordings/player/playerSettingsLogic'import { playerSidebarLogic } from 'scenes/session-recordings/player/sidebar/playerSidebarLogic'import {DEFAULT_RECORDING_FILTERS,@@ -168,6 +169,13 @@ export type ExperimentRecordingsEmptyAction =| 'show_all_variants'| 'all_sessions'+/**+ * The actions that widen a list the viewer narrowed. Named apart from the rest so that the map of+ * their labels in the empty state can be exhaustive, and so that a reason's action and the one the+ * too-early banner borrows cannot be different sets.+ */+export type ExperimentRecordingsNarrowingAction = 'clear_filters' | 'show_all_variants' | 'all_sessions'+/*** The dates and settings the empty-state copy names. The component reads them from here so that it* does not measure the run window a second time against a clock this logic has already read.@@ -183,6 +191,12 @@ export interface ExperimentRecordingsListEmptyContext {variantKey: string | null/** End of the window the applied metric filter scanned. Null when no filter is applied. */scannedWindowEnd: string | null+ /**+ * The way out of the tightest narrowing the viewer controls, null when nothing narrows the+ * list. The too-early banner carries it, so a viewer on a young run is never left with a reason+ * that only waiting fixes and no way to widen the list themselves.+ */+ narrowingAction: ExperimentRecordingsNarrowingAction | null}/**@@ -252,6 +266,75 @@ function daysSince(date: string | null | undefined): number | null {return date ? dayjs().diff(dayjs(date), 'day') : null}+/**+ * The way out of the tightest narrowing the viewer controls, null when nothing narrows the list.+ * Tightest first, in the same order `listEmptyReason` names the narrowings, so the action offered+ * is the one the reason would have named had the run been old enough to reach it.+ *+ * The tab's own metric event filters are left out. The reason they raise carries no action either,+ * so there is nothing for this to offer.+ */+function narrowingAction(+ filtersCustomized: boolean,+ effectiveVariantKey: string | null,+ effectiveExposureScope: ExperimentReplayExposureScope+): ExperimentRecordingsNarrowingAction | null {+ if (filtersCustomized) {+ return 'clear_filters'+ }+ if (effectiveVariantKey !== null) {+ return 'show_all_variants'+ }+ if (effectiveExposureScope === 'in_session') {+ return 'all_sessions'+ }+ return null+}++/**+ * The way out the empty state offers for a reason, null when that reason's banner offers none. The+ * banner and the render report both read this, so a viewer who is handed a way out and a render+ * counted as offering one cannot come apart.+ *+ * Too early borrows whatever narrows the list, because on a run that young the age of the run is+ * the cause however the viewer narrowed it. The three narrowing reasons name their own way out,+ * which is the one `narrowingAction` resolves, since the reasons and the narrowings are read in one+ * order. Every other reason has nothing a narrowing can fix: replay is off, the window expired, the+ * metric filter matched nothing or failed. A variant that still narrows the tab widens none of+ * those, so none of them offers it.+ */+export function offeredNarrowingAction(+ reason: ExperimentReplayListEmptyReason,+ narrowing: ExperimentRecordingsNarrowingAction | null+): ExperimentRecordingsNarrowingAction | null {+ switch (reason) {+ case ExperimentReplayListEmptyReason.TooEarly:+ return narrowing+ case ExperimentReplayListEmptyReason.FiltersNarrowed:+ return 'clear_filters'+ case ExperimentReplayListEmptyReason.VariantHasNone:+ return 'show_all_variants'+ case ExperimentReplayListEmptyReason.InSessionHasNone:+ return 'all_sessions'+ default:+ return null+ }+}++/**+ * The hide-viewed setting as the report names it. The setting is persisted, and a value stored+ * before it named whose recordings to hide is a plain `true`, which is why the option is read off+ * truthiness rather than matched value for value. `playerSettingsLogic` upgrades that `true` to+ * 'current-user', and this normalizes it the same way, so one setting cannot report under two+ * names.+ */+function hideViewedOption(hideViewedRecordings: HideViewedRecordingsOptions): 'off' | 'current-user' | 'any-user' {+ if (hideViewedRecordings === 'any-user') {+ return 'any-user'+ }+ return hideViewedRecordings ? 'current-user' : 'off'+}+/*** Sort metrics the way the experiment's metrics page lists them. The ordering arrays are that* page's display order, and every metric uuid is meant to be in one of them — but only sorting@@ -275,6 +358,7 @@ function metricDisplayOrder(experiment: Experiment): (a: { uuid: string }, b: {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface experimentReplayTabLogicValues {featureFlags: FeatureFlagsSet // featureFlagLogic+ hideViewedRecordings: HideViewedRecordingsOptions // playerSettingsLogiccurrentProjectId: number | string // teamLogiccurrentTeam: TeamPublicType | TeamType | null // teamLogiclinkabilityLoaded: boolean // viewRecordingsLinkabilityLogic@@ -625,7 +709,9 @@ export interface experimentReplayTabLogicMeta {) => ExperimentReplayListEmptyReasonlistEmptyContext: (currentTeam: TeamPublicType | TeamType | null,+ filtersCustomized: boolean,effectiveVariantKey: string | null,+ effectiveExposureScope: ExperimentReplayExposureScope,scannedWindowEnd: string | null,arg: any) => ExperimentRecordingsListEmptyContext@@ -709,6 +795,10 @@ export const experimentReplayTabLogic = kea<experimentReplayTabLogicType>([teamLogic,// The replay settings that decide whether this experiment can have recordings at all.['currentProjectId', 'currentTeam'],+ playerSettingsLogic,+ // Read for the report only. The playlist sends the setting to the endpoint itself, so+ // the tab must not apply it a second time.+ ['hideViewedRecordings'],],// Mounts the sidebar singleton for this tab's lifetime, so the default below outlives the// player remounting as the viewer moves between recordings in the playlist.@@ -1239,6 +1329,12 @@ export const experimentReplayTabLogic = kea<experimentReplayTabLogicType>([* while the window and retention reasons only say that the recordings the window would have* shown no longer exist.*+ * Too early comes before the narrowings the viewer controls. On a run this young an empty+ * list is most often empty for every variant, every scope and every filter, so the age of+ * the run is the honest cause and a narrowing would be named on a guess. The viewer still+ * gets one click back out, because the banner carries the active narrowing's action from+ * `listEmptyContext`.+ ** Read only for an empty list. It names a plausible cause of emptiness, not the state of the* tab, so on a list with rows it is meaningless rather than wrong.*/@@ -1315,10 +1411,19 @@ export const experimentReplayTabLogic = kea<experimentReplayTabLogicType>([},],listEmptyContext: [- (s) => [s.currentTeam, s.effectiveVariantKey, s.scannedWindowEnd, (_, props) => props.experiment],+ (s) => [+ s.currentTeam,+ s.filtersCustomized,+ s.effectiveVariantKey,+ s.effectiveExposureScope,+ s.scannedWindowEnd,+ (_, props) => props.experiment,+ ],(currentTeam: TeamPublicType | TeamType | null,+ filtersCustomized: boolean,effectiveVariantKey: string | null,+ effectiveExposureScope: ExperimentReplayExposureScope,scannedWindowEnd: string | null,experiment: Experiment): ExperimentRecordingsListEmptyContext => ({@@ -1327,6 +1432,7 @@ export const experimentReplayTabLogic = kea<experimentReplayTabLogicType>([retentionWindowDays: retentionDays(currentTeam?.session_recording_retention_period),variantKey: effectiveVariantKey,scannedWindowEnd,+ narrowingAction: narrowingAction(filtersCustomized, effectiveVariantKey, effectiveExposureScope),}),],// What the list was narrowed by, shared by the opened-recording and list-rendered reports so@@ -1759,6 +1865,7 @@ export const experimentReplayTabLogic = kea<experimentReplayTabLogicType>([// would name one, so the report carries the action on its own.empty_reason: action === 'show_hidden' ? null : values.listEmptyReason,action,+ days_since_start: daysSince(props.experiment.start_date),})},watchHighlightOpened: ({ card, position }) => {@@ -1791,6 +1898,10 @@ export const experimentReplayTabLogic = kea<experimentReplayTabLogicType>([...values.filterContext,result_count: recordings.length,empty_reason: recordings.length === 0 ? values.listEmptyReason : null,+ narrowing_action:+ recordings.length === 0+ ? offeredNarrowingAction(values.listEmptyReason, values.listEmptyContext.narrowingAction)+ : null,days_since_start: daysSince(props.experiment.start_date),days_since_end: daysSince(props.experiment.end_date),retention_period: values.currentTeam?.session_recording_retention_period ?? null,@@ -1801,6 +1912,8 @@ export const experimentReplayTabLogic = kea<experimentReplayTabLogicType>([duration_filter_operator: values.appliedDurationFilter?.operator ?? null,duration_filter_count: values.appliedDurationFilterCount,duration_filter_customized: values.durationFilterCustomized,+ filters_customized: values.filtersCustomized,+ hide_viewed_recordings: hideViewedOption(values.hideViewedRecordings),exposure_linkable: values.exposureLinkable,})},diff --git a/frontend/src/scenes/experiments/stories/ExperimentRecordingsListEmpty.stories.tsx b/frontend/src/scenes/experiments/stories/ExperimentRecordingsListEmpty.stories.tsxindex 0573792780ee..0ff152da9dd5 100644--- a/frontend/src/scenes/experiments/stories/ExperimentRecordingsListEmpty.stories.tsx+++ b/frontend/src/scenes/experiments/stories/ExperimentRecordingsListEmpty.stories.tsx@@ -99,6 +99,19 @@ export const ExperimentRecordingsEmptyVariantHasNone: Story = {},}+/**+ * Narrowed to one variant on a run too young to have recordings either way. The copy stays the+ * too-early one, because the list is most likely empty for every variant, and the banner carries+ * the way out of the variant so the viewer is not left with nothing to click.+ */+export const ExperimentRecordingsEmptyTooEarlyWithVariantSelected: Story = {+ decorators: [mswDecorator({ get: { [EXPERIMENT_PATH]: experimentRun('2025-05-30T09:00:00Z', null) } })],+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement)+ await userEvent.click(await canvas.findByText('test-1'))+ },+}+/*** Narrowed to the sessions the exposure happened in. The scope is offered only once the server* confirms this experiment can be asked for it, so the story answers that check first.