: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(experiments): explain why the recordings tab list is empty (#96196)
Marcel Poelkerc3b76ba0a693
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 586db1f84852..17f0c082d615 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -6996,30 +6996,58 @@ snapshots:hash: v1.k794b7964.a4753ab565ca3f44ae93f0bf19bb4bd25b2544c1bb796cebbd3a16b6aa146db5.k7wPrw7XnQ4KdxWMRQ9gVWew1fhgPOLCUVIuC24Kp1cscenes-app-experiments--experiment-frequentist-two-variants--light:hash: v1.k794b7964.c3d7500050335234dac2b12a58ae26fe68611d4f4fb040ab162a0b22aa2816c4.yZkCSjTEKndRt6r5t2hSlLwgfIwnnDg5or8MZX0tAz0+ scenes-app-experiments--experiment-recordings-empty-ended-past-retention--dark:+ hash: v1.k794b7964.557c37efd8493be197bc3abf9814f8e3cbc9436cea359aa6f0e2c4a476a017b9.qLJQ9vTIuxXylC9XI8GS2Jbqjcl8XDfW5dnyVMEbM9E+ scenes-app-experiments--experiment-recordings-empty-ended-past-retention--light:+ hash: v1.k794b7964.a4d9fac8514518ee888d7cc5c45aebbb5c990cb6958841d70dd882aad31e137c.LObzOkyk1zK5TzXl2RkvPQ8dRRDBBHNEbleI_FktK1I+ scenes-app-experiments--experiment-recordings-empty-in-session-has-none--dark:+ hash: v1.k794b7964.8e0fae0206a2c6a689489769c4f4c54afcb5e2e7dff7f3e691093d52d40f2b66.gGmGSdURcQqQYiaRAMoU9e0QLqZ60iBgu5Y3TXSAYIE+ scenes-app-experiments--experiment-recordings-empty-in-session-has-none--light:+ hash: v1.k794b7964.17ae28c96ffb6e5f325c1d6472a3d0daf74ebc5f587e71c6e1e519c3ae90cfde.gxIuB-JGrgOu019Z-fO3qd5xJdDjYnakTZFb8ifWRd4+ scenes-app-experiments--experiment-recordings-empty-metric-filter-failed--dark:+ hash: v1.k794b7964.5bcdedce15abcde17d42fb48cbb10113bcb4a5d13b1fc77b33004f4489bb28f7.RErYd5Fhw_0HL83KG4-o2P3E0010HXhf7zGyTjPysyE+ scenes-app-experiments--experiment-recordings-empty-metric-filter-failed--light:+ hash: v1.k794b7964.122650d92376c8deb66d05818fd951ee6c3ef9547e36cc4cb90319283d4e5b91.UPiCTjRgAuc_xzEnxre4KeFY-7Gi2z8M-LGfZBztRzQ+ scenes-app-experiments--experiment-recordings-empty-metric-filter-matched-nothing--dark:+ hash: v1.k794b7964.2abb549c5ccab18a46aaba2c29495c1522cec73f66f19dd9ede59e08ba7b0472.m8YY2HCJZBIPbrKEy7LIJKaG07qR_AjZATroyJPg7x0+ scenes-app-experiments--experiment-recordings-empty-metric-filter-matched-nothing--light:+ hash: v1.k794b7964.1fc5dafbe824292161867932af884a6a9065e4e6876e8a02d2bc70f8f9f94288.q5oxrAyeYGEoeVe2d-8KK0UlyQwJdPaieJP6vSnAGd4+ scenes-app-experiments--experiment-recordings-empty-too-early--dark:+ hash: v1.k794b7964.461cc90ab6b2e52b99111e0631d253e47347647f994b2500ceb87eeb77c6b771.3taB8yr84NutLTUwM3FMvtp-Z9R0KSmjXY1j9hUx5R0+ scenes-app-experiments--experiment-recordings-empty-too-early--light:+ hash: v1.k794b7964.5cf3abd3f3e537339d3ed11cbc1dc3458c815dc86d604dbf8b10706f15e4256b.xrmpvVhU_I1uoQfXcreRrNEetOw5r37Uf3xQuow99nI+ scenes-app-experiments--experiment-recordings-empty-unknown-in-window--dark:+ hash: v1.k794b7964.8cc424769dc71c1d102074ed089a9762c5c0b26328cc41d038a66020f6a9d3ac.wVEIH7FEp0NL6rq-dldcLPVuPLtX4C_h75c1OITmY2Y+ scenes-app-experiments--experiment-recordings-empty-unknown-in-window--light:+ hash: v1.k794b7964.dafbf32bb4f6e62e25354b53b5b3d138cf188dafee4178bc84bd7d5cfa813480.Pq8vXEFRWfV6bIeiHnX_CQR3sHA82yZ3F7tVlrLVR20+ scenes-app-experiments--experiment-recordings-empty-variant-has-none--dark:+ hash: v1.k794b7964.530d0f67567386042f51c3c7103cf35569830e1fcca930c98c87f19f0e78a0cb.xCXIqElOyZHwKcW8AMioDp7Ms6i0FyHKZMyu_edJ6yk+ scenes-app-experiments--experiment-recordings-empty-variant-has-none--light:+ hash: v1.k794b7964.c34b90d09956ebfa2b8e214e6ff72ee83bd52b4373f095001182130074edf77f.BfVbJEalysyFVC_DscyNMfF0di9x2kD1J4GmWS44__Escenes-app-experiments--experiment-replay-scanner-backlink--dark:- hash: v1.k794b7964.a664d49360b53c7b5d9688b274653ab9f8ce2c5d4fbd9c88c074501079e58a80.4xrkavfqRBFfrvK6NUJx7i5vUpdlvsoIwYhPPvpeOBI+ hash: v1.k794b7964.ebc31572406f9a52425ac28a209784b99a852c92116fe1ed90df19fc3d73b899.-MGnNAnX0zGAKvPu8HLxqQph4wxAX97lMphrQZdYQBoscenes-app-experiments--experiment-replay-scanner-backlink--light:- hash: v1.k794b7964.2ac397a742be0c9a40665935c2c3564ff25253117f5dae171b2ff5bc2e7c0fc4.sK7WzwkpIAHDXzJC2TZPAzndt-xZ7SSY5hJJIh-RK9s+ hash: v1.k794b7964.19d61ab9fd6ce3e4db819e93ba3b246b9b3b7618cb8d0a4d3dfcd5c888a20f32.mDpS1PbH6T6TkXxoijLxGHh6OC3nR3A02jmkJGbzH10scenes-app-experiments--experiment-stopped-with-conclusion--dark:hash: v1.k794b7964.e347bbe9e217d7cbd915b09b362a9d995285c1f6492229235ce3dcef74e49f30.5xV99CaEDXp-xFACHoS4M9vQ6zFGOjestb-iW79F5Q4scenes-app-experiments--experiment-stopped-with-conclusion--light:hash: v1.k794b7964.793a4b6109b2c0ab65b07d9eaefd1c8862f12bfc7f33b2f452ad20044396b2a7.6B0Meq7yO75vBEoBmuP2dNl2oKTugzzr_IKTcJHhEi0scenes-app-experiments--experiment-watch-shelf-no-recordings--dark:- hash: v1.k794b7964.2ac26f9773399f7c2a0897fe7bf079342e196d96e005d5398c90cab279f00ef0.XeWSLYIaWO0-9S0Gu37FahYgZRooHWJbZuQo1CV-gK8+ hash: v1.k794b7964.bb5665d2af43df90803e28b9b6e4a1fc6dcfefd250a5d205956d6f5d53ec9dd1.Nc8TAC5gk9jVejy1uNyXDQLDxcH7RrM9AwCocsNthHgscenes-app-experiments--experiment-watch-shelf-no-recordings--light:- hash: v1.k794b7964.e55c98187c7b3fd9fa55401c0baa5f56e29cd831b89c2fbe79754cf3c9da9fcf.uSX-AvXhBvhKYjXYKPnPio1Uunf851HG-S-6TatD2fA+ hash: v1.k794b7964.54f19c9492044a0d7d0145cf500475d2f1585c9cdf6c1135450c8a976ed1b0ea.Zm6VQaKhf94w8x6FkHYke0FkDsehbV-sdFeKWsXmSGUscenes-app-experiments--experiment-watch-shelf-no-separation--dark:- hash: v1.k794b7964.67610e0b1840bf8fa6bb23ca5790864acfac146e2aa7af7533bb29795b1087e0.LQx2eb_qo4CPMlIlmlqiBuFj-Nutb0xfsfr9ls_b5_w+ hash: v1.k794b7964.1e46e9f215749793c1c1f888ae5b04c0ec907238bcdbafffbf03749784f1eabd.fPcQwDzHNnMQ1Vgekt0dOx9KFdh2f0BmwTD6jZxAlh8scenes-app-experiments--experiment-watch-shelf-no-separation--light:- hash: v1.k794b7964.9905e631412d75f05a9c1ccd7d450ef543bb3707b88512f22a74b9e2d8740750.QY7_c_0BnayEhoKEkIwbOUy_lXhGSo_z6qHBAFXSy54+ hash: v1.k794b7964.418661e125da6f8bb635cce82971886e971a0e49009b045d24ce2cb41db71f61.ABRYFTNA8OWeQSO_4JEX0pRCsvin6Ivc4n8nx6JEBjoscenes-app-experiments--experiment-watch-shelf-no-session-linked-exposures--dark:- hash: v1.k794b7964.efed1414511ba693b62e9ef699eb46eebc974f71b04ff3ab196acee3d41bf8ff.vW1xzGD58MKp9kOF62u82jA4goSpqGzI4aN9JMudCDI+ hash: v1.k794b7964.4f868db97e62b87b802b5ce9c5d998497bfc2067c8ee5d52950cb6c0c6ff4be3.eI2pqmLkw4JRLEMYcZ6RhlO_o0oTbsr7fvz5p_uKqnIscenes-app-experiments--experiment-watch-shelf-no-session-linked-exposures--light:- hash: v1.k794b7964.d13537ae58ffc2d03e58fd792394e4d7726b5d6bc466931048b5d47226105422.XU1jTNjk6MlyoUqFEcfptrbZAD_MMF7Gjiu_Mj1lEr4+ hash: v1.k794b7964.fab54a048b400849ce84abed89fa05b10a591b2fb54e467e393cbe235a337444.ar6gDjV8vY2-bM4mfDqSRl95vb1clFMYjdlOJVt9AMYscenes-app-experiments--experiment-watch-shelf-too-early--dark:- hash: v1.k794b7964.1b88cc8cd64ba1bccfcaed317ac501bf200ba341e92116db27f90d82ae49c73a.SMrxC03vvYcGHvkNeohFps_ewZMmt62ym-wvgn_M6DE+ hash: v1.k794b7964.3e5f919fc0ee8641df2561640122f1e8579266b1b3c39a1b79702a79023a2cdb.0YEvFMCCv1VnUboUz8fkK1q5w7TDKFH4wzR_3aUo6EUscenes-app-experiments--experiment-watch-shelf-too-early--light:- hash: v1.k794b7964.e058db803b56cf08ca5ee991f4fbb027c0356403bdd65d7dc48e005c949ace33.dmKGtzopSbXAZbJNQ9wkZKko6X2RRDtvbS3Bk-FPkUk+ hash: v1.k794b7964.8b9cf6e2c3db721a8654bbeec17dfa29d7cd02ff76ee76dcc5b2a9422396eef6.eG8RjYgxtBcEe4TZrvO2QXrwgPs2u6M7VqAlDQzSLcUscenes-app-experiments--experiment-with-funnel-metric--dark:hash: v1.k794b7964.fd0d0ad7569f50079a322a8901513f854823ce694796a2a24a1e6714ac9c5902.fBtAQkm1LZ7xYp6DTXoQSDqDFjsUkxMCP-aNAZJ1Fmcscenes-app-experiments--experiment-with-funnel-metric--light:diff --git a/frontend/src/lib/utils/eventUsageLogic.ts b/frontend/src/lib/utils/eventUsageLogic.tsindex 57b7eb80b397..986bbdbd3671 100644--- a/frontend/src/lib/utils/eventUsageLogic.ts+++ b/frontend/src/lib/utils/eventUsageLogic.ts@@ -246,6 +246,17 @@ export interface ExperimentWatchEmptyActionContext {action: string}+/**+ * An action on the empty recordings list was taken. Joined to `empty_reason` on+ * `experiment recordings list rendered`, this says which explanations people act on.+ */+export interface ExperimentRecordingsEmptyActionContext {+ /** One of the tab's `ExperimentReplayListEmptyReason` values. */+ empty_reason: string | null+ /** One of the tab's `ExperimentRecordingsEmptyAction` values. */+ action: string+}+/*** The card, without its event name: an event name is the customer's own taxonomy, which this* telemetry must not carry.@@ -1401,6 +1412,13 @@ export interface eventUsageLogicActions {context: ExperimentRecordingsBucketLoadedContextexperimentId: ExperimentIdType}+ reportExperimentRecordingsEmptyActionClicked: (+ experimentId: ExperimentIdType,+ context: ExperimentRecordingsEmptyActionContext+ ) => {+ context: ExperimentRecordingsEmptyActionContext+ experimentId: ExperimentIdType+ }reportExperimentRecordingsListRendered: (experimentId: ExperimentIdType,context: ExperimentRecordingsListRenderedContext@@ -2883,6 +2901,10 @@ export const eventUsageLogic = kea<eventUsageLogicType>([experimentId: ExperimentIdType,context: ExperimentRecordingsListRenderedContext) => ({ experimentId, context }),+ reportExperimentRecordingsEmptyActionClicked: (+ experimentId: ExperimentIdType,+ context: ExperimentRecordingsEmptyActionContext+ ) => ({ experimentId, context }),reportExperimentRecordingOpened: (experimentId: ExperimentIdType,context: ExperimentRecordingsFilterContext@@ -4137,6 +4159,12 @@ export const eventUsageLogic = kea<eventUsageLogicType>([...context,})},+ reportExperimentRecordingsEmptyActionClicked: ({ experimentId, context }) => {+ posthog.capture('experiment recordings empty state action clicked', {+ experiment_id: experimentId,+ ...context,+ })+ },reportExperimentRecordingOpened: ({ experimentId, context }) => {posthog.capture('experiment recording opened', {experiment_id: experimentId,diff --git a/frontend/src/scenes/experiments/ExperimentView/ExperimentRecordingsListEmptyState.test.tsx b/frontend/src/scenes/experiments/ExperimentView/ExperimentRecordingsListEmptyState.test.tsxnew file mode 100644index 000000000000..d76b32abae1d--- /dev/null+++ b/frontend/src/scenes/experiments/ExperimentView/ExperimentRecordingsListEmptyState.test.tsx@@ -0,0 +1,333 @@+import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'++import '@testing-library/jest-dom'++import { cleanup, render, screen, waitFor } from '@testing-library/react'+import { BindLogic, Provider } from 'kea'+import { expectLogic } from 'kea-test-utils'++import api from 'lib/api'+import { dayjs } from 'lib/dayjs'+import { playerSettingsLogic } from 'scenes/session-recordings/player/playerSettingsLogic'+import {+ DEFAULT_RECORDING_FILTERS,+ SessionRecordingPlaylistLogicProps,+ sessionRecordingsPlaylistLogic,+} from 'scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic'+import { teamLogic } from 'scenes/teamLogic'++import { useMocks } from '~/mocks/jest'+import { initKeaTests } from '~/test/init'+import { Experiment, FilterLogicalOperator, TeamType } from '~/types'++import {+ experimentsInSessionExposureRetrieve,+ experimentsSessionBucketsCreate,+} from 'products/experiments/frontend/generated/api'++import { ExperimentRecordingsListEmptyState } from './ExperimentRecordingsListEmptyState'+import { ExperimentReplayListEmptyReason, experimentReplayTabLogic } from './experimentReplayTabLogic'++jest.mock('lib/utils/product-intents', () => ({+ addProductIntentForCrossSell: jest.fn().mockResolvedValue(null),+}))++jest.mock('products/experiments/frontend/generated/api', () => ({+ experimentsInSessionExposureRetrieve: jest.fn(),+ experimentsSessionContextsCreate: jest.fn().mockResolvedValue({ results: [] }),+ experimentsSessionBucketsCreate: jest.fn(),+ experimentsSessionEventDeltasCreate: jest.fn().mockResolvedValue(null),+}))++jest.mock('products/replay_vision/frontend/generated/api', () => ({+ visionScannersList: jest.fn().mockResolvedValue({ results: [] }),+}))++// Run windows are read against today, so a fixed date would start naming a different reason as it+// aged. Counted in hours so a run in a zone with daylight saving still lands a whole number of days.+const daysAgo = (days: number): string =>+ dayjs()+ .subtract(days * 24, 'hour')+ .toISOString()++const EXPERIMENT = {+ id: 42,+ feature_flag_key: 'my-flag',+ start_date: daysAgo(10),+ end_date: null,+ metrics: [],+ metrics_secondary: [],+ feature_flag: {+ filters: {+ multivariate: {+ variants: [+ { key: 'control', rollout_percentage: 50 },+ { key: 'test', rollout_percentage: 50 },+ ],+ },+ },+ },+} as unknown as Experiment++// Every action the empty state can offer, so a case can state its whole set and an extra one fails.+// A LemonBanner action renders twice, once per width, so presence is counted rather than queried.+const ACTION_ATTRS = [+ 'experiment-recordings-empty-replay-settings',+ 'experiment-recordings-empty-retention-docs',+ 'experiment-recordings-empty-ad-blocker-docs',+ 'experiment-recordings-empty-retry-metric-filter',+ 'experiment-recordings-empty-clear-filters',+ 'experiment-recordings-empty-show-all-variants',+ 'experiment-recordings-empty-all-sessions',+]++interface ReasonCase {+ reason: ExperimentReplayListEmptyReason+ /** One per case: the tab logic is keyed per experiment, and each case mounts its own. */+ experimentId: number+ experiment: Partial<Experiment>+ team?: Partial<TeamType>+ setup?: (logic: ReturnType<typeof experimentReplayTabLogic.build>) => void+ /** The part of the copy that only this reason says. */+ copy: string+ /** In `ACTION_ATTRS` order. */+ actions: string[]+}++// The team's retention period is the mock default of 30 days, which the run windows are set against.+const REASON_CASES: ReasonCase[] = [+ {+ reason: ExperimentReplayListEmptyReason.ReplayDisabled,+ experimentId: 201,+ experiment: {},+ team: { session_recording_opt_in: false },+ copy: 'Session replay is off for this project',+ actions: ['experiment-recordings-empty-replay-settings'],+ },+ {+ reason: ExperimentReplayListEmptyReason.NotLaunched,+ experimentId: 202,+ experiment: { start_date: null, end_date: null },+ copy: 'Launch the experiment to see recordings of participants.',+ actions: [],+ },+ {+ reason: ExperimentReplayListEmptyReason.TooEarly,+ experimentId: 203,+ experiment: { start_date: daysAgo(1), end_date: null },+ copy: 'The experiment started 1 day ago',+ actions: [],+ },+ {+ reason: ExperimentReplayListEmptyReason.EndedPastRetention,+ experimentId: 204,+ experiment: { start_date: daysAgo(200), end_date: daysAgo(60) },+ copy: 'This project keeps recordings for 30 days',+ actions: ['experiment-recordings-empty-retention-docs'],+ },+ {+ reason: ExperimentReplayListEmptyReason.MetricFilterMatchedNothing,+ experimentId: 205,+ experiment: { start_date: daysAgo(10), end_date: null },+ setup: (logic) => {+ ;(experimentsSessionBucketsCreate as jest.Mock).mockResolvedValue({+ session_ids: [],+ truncated: false,+ considered_metrics: [],+ excluded_metrics: [],+ filter_test_accounts: true,+ })+ logic.actions.setMetricFilterMode('no_metric_activity')+ },+ copy: 'No recordings matched the metric filter.',+ actions: [],+ },+ {+ reason: ExperimentReplayListEmptyReason.MetricFilterFailed,+ experimentId: 206,+ experiment: { start_date: daysAgo(10), end_date: null },+ setup: (logic) => {+ ;(experimentsSessionBucketsCreate as jest.Mock).mockRejectedValue({ detail: 'refused' })+ logic.actions.setMetricFilterMode('no_metric_activity')+ },+ copy: 'The metric filter could not be loaded',+ actions: ['experiment-recordings-empty-retry-metric-filter'],+ },+ {+ reason: ExperimentReplayListEmptyReason.FiltersNarrowed,+ experimentId: 212,+ 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 }],+ },+ ],+ },+ }),+ copy: 'No recordings match the filters added above',+ actions: ['experiment-recordings-empty-clear-filters'],+ },+ {+ reason: ExperimentReplayListEmptyReason.UnknownInWindow,+ experimentId: 207,+ experiment: { start_date: daysAgo(10), end_date: daysAgo(2) },+ copy: 'A session can be missing for a few reasons',+ actions: ['experiment-recordings-empty-retention-docs', 'experiment-recordings-empty-ad-blocker-docs'],+ },+ {+ reason: ExperimentReplayListEmptyReason.VariantHasNone,+ experimentId: 210,+ experiment: { start_date: daysAgo(10), end_date: daysAgo(2) },+ setup: (logic) => logic.actions.setSelectedVariantKey('test'),+ copy: 'No recordings for the test variant',+ actions: ['experiment-recordings-empty-show-all-variants'],+ },+ {+ reason: ExperimentReplayListEmptyReason.InSessionHasNone,+ experimentId: 211,+ experiment: { start_date: daysAgo(10), end_date: daysAgo(2) },+ setup: (logic) => logic.actions.setExposureScope('in_session'),+ copy: 'No recordings of the sessions the exposure happened in',+ actions: ['experiment-recordings-empty-all-sessions'],+ },+]++describe('ExperimentRecordingsListEmptyState', () => {+ // The tab always scopes its playlist, so the empty state always renders under a scoped logic.+ const playlistProps: SessionRecordingPlaylistLogicProps = {+ logicKey: 'experiment-empty-state-test',+ updateSearchParams: false,+ filters: { ...DEFAULT_RECORDING_FILTERS, date_from: '-30d' },+ }+ let playlistLogic: ReturnType<typeof sessionRecordingsPlaylistLogic.build>++ beforeEach(() => {+ useMocks({+ get: {+ '/api/environments/:team_id/session_recordings': { results: [], has_next: false },+ '/api/environments/:team_id/session_recordings/properties': { results: [] },+ },+ })+ localStorage.clear()+ initKeaTests()+ ;(experimentsInSessionExposureRetrieve as jest.Mock).mockResolvedValue({+ available: true,+ unavailable_reason: null,+ uses_stamped_fallback: false,+ })+ ;(experimentsSessionBucketsCreate as jest.Mock).mockReset()+ jest.spyOn(api.propertyDefinitions, 'seenTogether').mockResolvedValue({})+ playlistLogic = sessionRecordingsPlaylistLogic(playlistProps)+ playlistLogic.mount()+ playerSettingsLogic.mount()+ })++ afterEach(() => {+ cleanup()+ playerSettingsLogic.actions.setHideViewedRecordings(false)+ playerSettingsLogic.unmount()+ playlistLogic.unmount()+ jest.restoreAllMocks()+ localStorage.clear()+ })++ function renderEmptyState(experiment: Experiment): void {+ render(+ <Provider>+ <BindLogic logic={sessionRecordingsPlaylistLogic} props={playlistProps}>+ <ExperimentRecordingsListEmptyState experiment={experiment} />+ </BindLogic>+ </Provider>+ )+ }++ it.each(REASON_CASES)(+ 'explains $reason and offers only the actions that fix it',+ async ({ experimentId, experiment, team, setup, copy, actions }) => {+ teamLogic.actions.loadCurrentTeamSuccess({ ...MOCK_DEFAULT_TEAM, ...team })+ const logic = experimentReplayTabLogic({+ experiment: { ...EXPERIMENT, id: experimentId, ...experiment } as Experiment,+ })+ logic.mount()+ setup?.(logic)+ await expectLogic(logic).toFinishAllListeners()+ renderEmptyState({ ...EXPERIMENT, id: experimentId, ...experiment } as Experiment)++ expect(screen.getByTestId('experiment-recordings-empty-state')).toHaveTextContent(copy)+ expect(ACTION_ATTRS.filter((attr) => screen.queryAllByTestId(attr).length > 0)).toEqual(actions)++ logic.unmount()+ }+ )++ it('names no reason while the metric filter is still being resolved', async () => {+ // An unanswered bucket has the same empty session set as one that matched nothing, so the+ // banner used to claim "matched nothing" and drop "Try again" for the length of the request.+ // A retry after a failure shows it worst: the list never reloads, so only the banner moves.+ teamLogic.actions.loadCurrentTeamSuccess(MOCK_DEFAULT_TEAM)+ let resolveBucket: (response: unknown) => void = () => {}+ ;(experimentsSessionBucketsCreate as jest.Mock).mockReturnValue(+ new Promise((resolve) => {+ resolveBucket = resolve+ })+ )+ const logic = experimentReplayTabLogic({+ experiment: { ...EXPERIMENT, id: 213 } as Experiment,+ })+ logic.mount()+ logic.actions.setMetricFilterMode('no_metric_activity')+ await waitFor(() => expect(logic.values.sessionBucketLoading).toBe(true))++ renderEmptyState({ ...EXPERIMENT, id: 213 } as Experiment)+ expect(screen.getByTestId('experiment-recordings-empty-state')).toBeEmptyDOMElement()++ resolveBucket({+ session_ids: [],+ truncated: false,+ considered_metrics: [],+ excluded_metrics: [],+ filter_test_accounts: true,+ })+ await waitFor(() =>+ expect(screen.getByTestId('experiment-recordings-empty-state')).toHaveTextContent(+ 'No recordings matched the metric filter.'+ )+ )++ logic.unmount()+ })++ it('answers with the hidden recordings instead of a reason when the list only looks empty', async () => {+ teamLogic.actions.loadCurrentTeamSuccess(MOCK_DEFAULT_TEAM)+ playerSettingsLogic.actions.setHideViewedRecordings('current-user')+ const logic = experimentReplayTabLogic({ experiment: EXPERIMENT })+ logic.mount()+ await expectLogic(logic).toFinishAllListeners()+ // After the playlist's own first load, which resets the list as it starts.+ await waitFor(() => expect(playlistLogic.values.sessionRecordingsResponseLoading).toBe(false))+ // Rows the API returned, hidden in the browser because this viewer has watched them.+ playlistLogic.actions.loadSessionRecordingsSuccess({+ results: [+ { id: 's1', viewed: true },+ { id: 's2', viewed: true },+ ],+ has_next: false,+ } as any)++ renderEmptyState(EXPERIMENT)++ expect(playlistLogic.values.hiddenRecordingsCount).toBe(2)+ expect(screen.getByTestId('experiment-recordings-empty-show-hidden')).toHaveTextContent(+ 'Show 2 hidden recordings'+ )+ expect(screen.queryByTestId('experiment-recordings-empty-state')).not.toHaveTextContent('A session can be')++ logic.unmount()+ })+})diff --git a/frontend/src/scenes/experiments/ExperimentView/ExperimentRecordingsListEmptyState.tsx b/frontend/src/scenes/experiments/ExperimentView/ExperimentRecordingsListEmptyState.tsxnew file mode 100644index 000000000000..c37cf11604e1--- /dev/null+++ b/frontend/src/scenes/experiments/ExperimentView/ExperimentRecordingsListEmptyState.tsx@@ -0,0 +1,243 @@+import { useActions, useValues } from 'kea'++import { LemonBanner, LemonButton, Link } from '@posthog/lemon-ui'++import { dayjs } from 'lib/dayjs'+import { pluralize } from 'lib/utils/strings'+import { playerSettingsLogic } from 'scenes/session-recordings/player/playerSettingsLogic'+import { sessionRecordingsPlaylistLogic } from 'scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic'+import { urls } from 'scenes/urls'++import { Experiment } from '~/types'++import {+ ExperimentRecordingsEmptyAction,+ ExperimentRecordingsListEmptyContext,+ ExperimentReplayListEmptyReason,+ experimentReplayTabLogic,+} from './experimentReplayTabLogic'++// The two hints the shared replay panel offers, kept at the same URLs so a viewer who knows one+// surface lands on the same page from the other.+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'++/** 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) {+ return 'today'+ }+ return `${pluralize(daysSinceStart, 'day')} ago`+}++/**+ * One banner per reason, each naming what happened and what to do about it. Modeled on the+ * behavior-comparison shelf's empty states.+ */+function ReasonBanner({+ reason,+ context,+ onAction,+}: {+ reason: ExperimentReplayListEmptyReason+ context: ExperimentRecordingsListEmptyContext+ onAction: (action: ExperimentRecordingsEmptyAction) => void+}): JSX.Element {+ if (reason === ExperimentReplayListEmptyReason.ReplayDisabled) {+ return (+ <LemonBanner+ type="info"+ action={{+ children: 'Replay settings',+ to: urls.settings('environment-replay'),+ onClick: () => onAction('replay_settings'),+ 'data-attr': 'experiment-recordings-empty-replay-settings',+ }}+ >+ Session replay is off for this project, so none of the sessions in this experiment were recorded. Turn+ it on to record new sessions.+ </LemonBanner>+ )+ }+ if (reason === ExperimentReplayListEmptyReason.NotLaunched) {+ return <LemonBanner type="info">Launch the experiment to see recordings of participants.</LemonBanner>+ }+ if (reason === ExperimentReplayListEmptyReason.TooEarly) {+ return (+ <LemonBanner type="info">+ No recordings yet. The experiment started {startedWhen(context.daysSinceStart)}, and a recording appears+ here once an exposed person's session has been captured.+ </LemonBanner>+ )+ }+ if (reason === ExperimentReplayListEmptyReason.EndedPastRetention) {+ return (+ <LemonBanner+ type="info"+ action={{+ children: 'How retention works',+ to: RETENTION_DOCS,+ targetBlank: true,+ onClick: () => onAction('retention_docs'),+ 'data-attr': 'experiment-recordings-empty-retention-docs',+ }}+ >+ This experiment ended on {dayjs(context.endDate).format('MMM D, YYYY')}. This project keeps recordings+ for {pluralize(context.retentionWindowDays, 'day')}, so the recordings from its run are no longer+ stored.+ </LemonBanner>+ )+ }+ if (reason === ExperimentReplayListEmptyReason.MetricFilterMatchedNothing) {+ return (+ <LemonBanner type="info">+ No recordings matched the metric filter. Change or clear the filter above to widen the list.+ </LemonBanner>+ )+ }+ if (reason === ExperimentReplayListEmptyReason.MetricFilterFailed) {+ return (+ <LemonBanner+ type="info"+ action={{+ children: 'Try again',+ onClick: () => onAction('retry_metric_filter'),+ 'data-attr': 'experiment-recordings-empty-retry-metric-filter',+ }}+ >+ The metric filter could not be loaded, so the list has nothing to show.+ </LemonBanner>+ )+ }+ if (reason === ExperimentReplayListEmptyReason.FiltersNarrowed) {+ return (+ <LemonBanner+ type="info"+ action={{+ children: 'Clear filters',+ onClick: () => onAction('clear_filters'),+ 'data-attr': 'experiment-recordings-empty-clear-filters',+ }}+ >+ 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',+ }}+ >+ 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',+ }}+ >+ No recordings of the sessions the exposure happened in. The same people can still have recordings of+ their other sessions.+ </LemonBanner>+ )+ }+ return (+ <LemonBanner type="info">+ <div className="flex flex-col gap-1">+ <span>+ No recordings found for the people exposed to this experiment. A session can be missing for a few+ reasons:+ </span>+ <Link+ to={RETENTION_DOCS}+ target="_blank"+ data-attr="experiment-recordings-empty-retention-docs"+ onClick={() => onAction('retention_docs')}+ >+ Recordings might be outside the retention period+ </Link>+ <Link+ to={AD_BLOCKER_DOCS}+ target="_blank"+ data-attr="experiment-recordings-empty-ad-blocker-docs"+ onClick={() => onAction('ad_blocker_docs')}+ >+ An ad blocker might be preventing recordings+ </Link>+ </div>+ </LemonBanner>+ )+}++/**+ * Why this experiment's recordings list came back empty. Replaces the shared replay troubleshooting+ * panel on the tab, which can only offer the generic hints and whose "Search over the last 30 days"+ * button would overwrite the experiment's own run window.+ */+export function ExperimentRecordingsListEmptyState({ experiment }: { experiment: Experiment }): JSX.Element {+ const logic = experimentReplayTabLogic({ experiment })+ const { listEmptyReason, listEmptyContext, recordingsFilters, sessionBucketLoading } = useValues(logic)+ const { listEmptyActionClicked, loadSessionBucket, setSelectedVariantKey, setExposureScope } = useActions(logic)+ const { hiddenRecordingsCount } = useValues(sessionRecordingsPlaylistLogic)+ const { setShowSettings, setFilters } = useActions(sessionRecordingsPlaylistLogic)+ const { hideViewedRecordings } = useValues(playerSettingsLogic)+ const { setHideViewedRecordings } = useActions(playerSettingsLogic)++ const recordingsAreHidden = hideViewedRecordings !== false++ const runAction = (action: ExperimentRecordingsEmptyAction): void => {+ listEmptyActionClicked(action)+ if (action === 'retry_metric_filter') {+ loadSessionBucket()+ } else if (action === 'show_all_variants') {+ setSelectedVariantKey(null)+ } else if (action === 'all_sessions') {+ setExposureScope('all_exposed')+ } else if (action === 'clear_filters') {+ // The playlist's own reset would drop the tab's scoping too, so the tab's filters go+ // back in whole rather than the playlist defaults.+ setFilters(recordingsFilters)+ }+ }++ return (+ <div className="flex flex-col gap-2" data-attr="experiment-recordings-empty-state">+ {recordingsAreHidden && (+ <LemonButton+ type="secondary"+ fullWidth={true}+ size="xsmall"+ data-attr="experiment-recordings-empty-show-hidden"+ onClick={() => {+ listEmptyActionClicked('show_hidden')+ setShowSettings(true)+ setHideViewedRecordings(false)+ }}+ >+ {hiddenRecordingsCount > 0+ ? `Show ${pluralize(hiddenRecordingsCount, 'hidden recording')}`+ : 'Show hidden recordings'}+ </LemonButton>+ )}+ {/* The client-side backstop hid rows the server let through, so the list is empty only+ because of the setting. A reason names a cause of emptiness, and there is none here.+ An in-flight bucket has the same shape as one that matched nothing, so a reason there+ would claim an answer the request has not given yet. The caption above the playlist+ carries the wait. */}+ {hiddenRecordingsCount === 0 && !sessionBucketLoading && (+ <ReasonBanner reason={listEmptyReason} context={listEmptyContext} onAction={runAction} />+ )}+ </div>+ )+}diff --git a/frontend/src/scenes/experiments/ExperimentView/ExperimentReplayTab.tsx b/frontend/src/scenes/experiments/ExperimentView/ExperimentReplayTab.tsxindex b4a27129eabc..39ea65712010 100644--- a/frontend/src/scenes/experiments/ExperimentView/ExperimentReplayTab.tsx+++ b/frontend/src/scenes/experiments/ExperimentView/ExperimentReplayTab.tsx@@ -32,6 +32,7 @@ import { scannerTypeLabel } from 'products/replay_vision/frontend/replay_scannerimport { NOT_A_FUNNEL_REASON } from '../utils'import { ExperimentBehaviorComparison, ExperimentBehaviorComparisonToggle } from './ExperimentBehaviorComparison'+import { ExperimentRecordingsListEmptyState } from './ExperimentRecordingsListEmptyState'import {ExperimentReplayMetricFilterMode,ExperimentReplayMetricOption,@@ -515,6 +516,7 @@ export function ExperimentReplayTab({ experiment }: { experiment: Experiment }):onFiltersChange={(filters) => playlistFiltersChanged(filters)}onRecordingsLoaded={(recordings, isFirstPage) => recordingsLoaded(recordings, isFirstPage)}onRecordingSelected={(recordingId) => recordingOpened(recordingId)}+ listEmptyState={<ExperimentRecordingsListEmptyState experiment={experiment} />}/>)}</div>diff --git a/frontend/src/scenes/experiments/ExperimentView/experimentReplayTabLogic.test.ts b/frontend/src/scenes/experiments/ExperimentView/experimentReplayTabLogic.test.tsindex 4fef2f8761e1..fa1b7f17d9c1 100644--- a/frontend/src/scenes/experiments/ExperimentView/experimentReplayTabLogic.test.ts+++ b/frontend/src/scenes/experiments/ExperimentView/experimentReplayTabLogic.test.ts@@ -210,6 +210,37 @@ const EMPTY_REASON_CASES: EmptyReasonCase[] = [logic.actions.setMetricFilterMode('no_metric_activity')},},+ {+ // Sessions matched the metric, none of them has a recording.+ reason: ExperimentReplayListEmptyReason.MetricFilterMatchedNothing,+ experimentId: 146,+ experiment: { start_date: daysAgo(10), end_date: null },+ setup: (logic) => {+ ;(experimentsSessionBucketsCreate as jest.Mock).mockResolvedValue({+ ...BUCKET_RESPONSE,+ session_ids: ['bucket-session'],+ })+ logic.actions.setMetricFilterMode('no_metric_activity')+ },+ },+ {+ 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 }],+ },+ ],+ },+ }),+ },{reason: ExperimentReplayListEmptyReason.EndedPastRetention,experimentId: 124,@@ -220,6 +251,18 @@ const EMPTY_REASON_CASES: EmptyReasonCase[] = [experimentId: 125,experiment: { start_date: daysAgo(1), end_date: null },},+ {+ reason: ExperimentReplayListEmptyReason.VariantHasNone,+ experimentId: 141,+ experiment: { start_date: daysAgo(10), end_date: daysAgo(2) },+ setup: (logic) => logic.actions.setSelectedVariantKey('test'),+ },+ {+ reason: ExperimentReplayListEmptyReason.InSessionHasNone,+ experimentId: 142,+ experiment: { start_date: daysAgo(10), end_date: daysAgo(2) },+ setup: (logic) => logic.actions.setExposureScope('in_session'),+ },{reason: ExperimentReplayListEmptyReason.UnknownInWindow,experimentId: 127,@@ -792,6 +835,35 @@ describe('experimentReplayTabLogic', () => {})+ 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+ // recordings, and every reason's click-through rate would be measured against it.+ const captureSpy = jest.spyOn(posthog, 'capture').mockReturnValue(undefined as any)+ teamLogic.actions.loadCurrentTeamSuccess(MOCK_DEFAULT_TEAM)+ const empty = experimentReplayTabLogic({+ experiment: { ...EXPERIMENT, id: 143, start_date: daysAgo(1), end_date: null } as Experiment,+ })+ empty.mount()+ await expectLogic(empty).toFinishAllListeners()++ empty.actions.listEmptyActionClicked('show_hidden')+ empty.actions.listEmptyActionClicked('replay_settings')+ await expectLogic(empty).toFinishAllListeners()++ const clicks = captureSpy.mock.calls.filter(+ ([event, properties]) =>+ 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,+ ])++ empty.unmount()+ })+it('reports a list with rows, with no reason and the facets it was narrowed by', async () => {// The empty reason names a plausible cause of emptiness, so on a list with rows it would// read as a fault the tab found. The facets match `experiment recording opened`, so andiff --git a/frontend/src/scenes/experiments/ExperimentView/experimentReplayTabLogic.ts b/frontend/src/scenes/experiments/ExperimentView/experimentReplayTabLogic.tsindex 19de850ae808..c0e0118f740d 100644--- a/frontend/src/scenes/experiments/ExperimentView/experimentReplayTabLogic.ts+++ b/frontend/src/scenes/experiments/ExperimentView/experimentReplayTabLogic.ts@@ -29,12 +29,14 @@ import {ExperimentWatchShelfContext,eventUsageLogic,} from 'lib/utils/eventUsageLogic'+import { objectsEqual } from 'lib/utils/objects'import { addProductIntentForCrossSell } from 'lib/utils/product-intents'import { playerSidebarLogic } from 'scenes/session-recordings/player/sidebar/playerSidebarLogic'import {DEFAULT_RECORDING_FILTERS,defaultRecordingDurationFilter,} from 'scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic'+import { filtersFromUniversalFilterGroups } from 'scenes/session-recordings/utils'import { teamLogic } from 'scenes/teamLogic'import {@@ -157,15 +159,40 @@ export type ExperimentReplayRecording = Pick<SessionRecordingType, 'id' | 'recor/** The link an empty "what to watch" state offers, as reported to telemetry. */export type ExperimentWatchEmptyAction = 'exposure_docs' | 'replay_settings'+/** The action an empty recordings list offers for its reason, as reported to telemetry. */+export type ExperimentRecordingsEmptyAction =+ | 'replay_settings'+ | 'retention_docs'+ | 'ad_blocker_docs'+ | 'retry_metric_filter'+ | 'clear_filters'+ | 'show_hidden'+ | 'show_all_variants'+ | 'all_sessions'+/**- * Why the recordings list came back with nothing, from what the client already holds. Reported, not- * shown: the tab has no way today to tell a project with replay switched off from an experiment- * launched an hour ago, and both look like "this feature is broken" to whoever opened the tab.+ * 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.+ */+export interface ExperimentRecordingsListEmptyContext {+ /** Null until the experiment launches. */+ daysSinceStart: number | null+ /** Null while the experiment runs. */+ endDate: string | null+ /** The project's replay retention window, which `ended_past_retention` is decided against. */+ retentionWindowDays: number+ /** Null when the list holds every variant. */+ variantKey: string | null+}++/**+ * Why the recordings list came back with nothing, from what the client already holds. Both shown to+ * the viewer, as the banner the empty list carries, and reported alongside the render.*- * `unknown_in_window` is the residue — replay is on, the run window is inside retention, and the- * filters still matched nothing. Exposure linkage and the duration floor both live in there, which- * is why the event carries `exposure_linkable` and the `duration_filter_*` properties alongside- * the reason.+ * `unknown_in_window` is the residue: replay is on, the run window is inside retention, nothing+ * narrowed the list, and it still matched nothing. Exposure linkage and the duration floor both+ * live in there, which is why the event carries `exposure_linkable` and the `duration_filter_*`+ * properties alongside the reason.*/export enum ExperimentReplayListEmptyReason {/** The project does not record sessions, so no experiment on it can have any. */@@ -173,8 +200,16 @@ export enum ExperimentReplayListEmptyReason {NotLaunched = 'not_launched',/** The request behind the metric filter was refused, so the list has no session set to show. */MetricFilterFailed = 'metric_filter_failed',- /** The selected metrics resolved to an empty session set, so the list can only be empty. */+ /**+ * A metric filter narrowed the list and nothing survived it: the selected metrics resolved to+ * an empty session set, or to sessions none of which has a recording.+ */MetricFilterMatchedNothing = 'metric_filter_matched_nothing',+ /**+ * A filter added through the filter bar narrowed the list past the tab's own scoping, and+ * nothing survived it.+ */+ FiltersNarrowed = 'filters_narrowed',/*** The whole run window predates retention: every recording it had has since expired. Measured* against the project's current retention setting, while a recording expires on the period it@@ -184,6 +219,13 @@ export enum ExperimentReplayListEmptyReason {EndedPastRetention = 'ended_past_retention',/** Launched within the last few days, so recordings may not have been captured yet. */TooEarly = 'too_early',+ /** The list is narrowed to one variant, and that variant has nothing. */+ VariantHasNone = 'variant_has_none',+ /**+ * The list is narrowed to the sessions the exposure happened in, and that narrower set has+ * nothing. The same people can still own recordings of their other sessions.+ */+ InSessionHasNone = 'in_session_has_none',UnknownInWindow = 'unknown_in_window',}@@ -264,10 +306,12 @@ export interface experimentReplayTabLogicValues {exposureLinkable: boolean | nullexposureScope: ExperimentReplayExposureScopefilterContext: ExperimentRecordingsFilterContext+ filtersCustomized: booleaninSessionExposure: ExperimentInSessionExposureApi | nullinSessionExposureLoading: booleanlinkedScanners: LinkedScanner[]linkedScannersLoading: boolean+ listEmptyContext: ExperimentRecordingsListEmptyContextlistEmptyReason: ExperimentReplayListEmptyReasonloadedRecordings: ExperimentReplayRecording[]loadedRecordingsById: Map<string, ExperimentReplayRecording>@@ -334,6 +378,13 @@ export interface experimentReplayTabLogicActions {context: ExperimentRecordingsBucketLoadedContextexperimentId: ExperimentIdType} // eventUsageLogic+ reportExperimentRecordingsEmptyActionClicked: (+ experimentId: ExperimentIdType,+ context: import('lib/utils/eventUsageLogic').ExperimentRecordingsEmptyActionContext+ ) => {+ context: import('lib/utils/eventUsageLogic').ExperimentRecordingsEmptyActionContext+ experimentId: ExperimentIdType+ } // eventUsageLogicreportExperimentRecordingsListRendered: (experimentId: ExperimentIdType,context: ExperimentRecordingsListRenderedContext@@ -386,6 +437,9 @@ export interface experimentReplayTabLogicActions {payload?: anyseenTogetherMap: Record<string, boolean>} // viewRecordingsLinkabilityLogic+ listEmptyActionClicked: (action: ExperimentRecordingsEmptyAction) => {+ action: ExperimentRecordingsEmptyAction+ }loadInSessionExposure: (_?: unknown) => unknownloadInSessionExposureFailure: (error: string,@@ -554,12 +608,25 @@ export interface experimentReplayTabLogicMeta {appliedDurationFilterCount: number,appliedDurationFilter: RecordingDurationFilter | null) => boolean+ filtersCustomized: (+ playlistFilters: RecordingUniversalFilters | null,+ recordingsFilters: RecordingUniversalFilters+ ) => booleanlistEmptyReason: (currentTeam: TeamPublicType | TeamType | null,bucketSessionIds: string[] | undefined,sessionBucketError: string | null,+ filtersCustomized: boolean,+ recordingsFilters: RecordingUniversalFilters,+ effectiveVariantKey: string | null,+ effectiveExposureScope: ExperimentReplayExposureScope,arg: any) => ExperimentReplayListEmptyReason+ listEmptyContext: (+ currentTeam: TeamPublicType | TeamType | null,+ effectiveVariantKey: string | null,+ arg: any+ ) => ExperimentRecordingsListEmptyContextfilterContext: (effectiveVariantKey: string | null,effectiveExposureScope: ExperimentReplayExposureScope,@@ -657,6 +724,7 @@ export const experimentReplayTabLogic = kea<experimentReplayTabLogicType>(['reportExperimentWatchCardSelected','reportExperimentWatchHighlightOpened','reportExperimentWatchEmptyActionClicked',+ 'reportExperimentRecordingsEmptyActionClicked',],],})),@@ -675,6 +743,7 @@ export const experimentReplayTabLogic = kea<experimentReplayTabLogicType>([selectWatchCard: (card: ExperimentWatchCardApi | null) => ({ card }),watchHighlightOpened: (card: ExperimentWatchCardApi, position: number) => ({ card, position }),watchEmptyActionClicked: (action: ExperimentWatchEmptyAction) => ({ action }),+ listEmptyActionClicked: (action: ExperimentRecordingsEmptyAction) => ({ action }),prefetchSessionContexts: (sessionIds: string[]) => ({ sessionIds }),reportTabViewed: true,scannerCrossSellClicked: true,@@ -1063,8 +1132,28 @@ export const experimentReplayTabLogic = kea<experimentReplayTabLogicType>([appliedDurationFilter.value !== defaultRecordingDurationFilter.value ||appliedDurationFilter.operator !== defaultRecordingDurationFilter.operator,],+ // Whether the viewer narrowed the list past the tab's own scoping through the filter bar.+ // Only the parts a filter can change are compared: the rest of the playlist's filters are+ // the tab's own and travel back unchanged through `onFiltersChange`. Null before the+ // playlist has reported any change, which reads as not customized.+ filtersCustomized: [+ (s) => [s.playlistFilters, s.recordingsFilters],+ (+ playlistFilters: RecordingUniversalFilters | null,+ recordingsFilters: RecordingUniversalFilters+ ): boolean =>+ playlistFilters !== null &&+ (!objectsEqual(+ filtersFromUniversalFilterGroups(playlistFilters),+ filtersFromUniversalFilterGroups(recordingsFilters)+ ) ||+ !objectsEqual(playlistFilters.duration, recordingsFilters.duration) ||+ (playlistFilters.date_from ?? null) !== (recordingsFilters.date_from ?? null) ||+ (playlistFilters.date_to ?? null) !== (recordingsFilters.date_to ?? null) ||+ !!playlistFilters.filter_test_accounts !== !!recordingsFilters.filter_test_accounts),+ ],/**- * The cause to report when the list comes back with nothing, first match wins. The order is+ * The cause to name when the list comes back with nothing, first match wins. The order is* cheapest-and-most-certain first: a project with replay off can have no recordings at all,* while the window and retention reasons only say that the recordings the window would have* shown no longer exist.@@ -1073,11 +1162,24 @@ export const experimentReplayTabLogic = kea<experimentReplayTabLogicType>([* tab, so on a list with rows it is meaningless rather than wrong.*/listEmptyReason: [- (s) => [s.currentTeam, s.bucketSessionIds, s.sessionBucketError, (_, props) => props.experiment],+ (s) => [+ s.currentTeam,+ s.bucketSessionIds,+ s.sessionBucketError,+ s.filtersCustomized,+ s.recordingsFilters,+ s.effectiveVariantKey,+ s.effectiveExposureScope,+ (_, props) => props.experiment,+ ],(currentTeam: TeamPublicType | TeamType | null,bucketSessionIds: string[] | undefined,sessionBucketError: string | null,+ filtersCustomized: boolean,+ recordingsFilters: RecordingUniversalFilters,+ effectiveVariantKey: string | null,+ effectiveExposureScope: ExperimentReplayExposureScope,experiment: Experiment): ExperimentReplayListEmptyReason => {if (!currentTeam?.session_recording_opt_in) {@@ -1104,6 +1206,20 @@ export const experimentReplayTabLogic = kea<experimentReplayTabLogicType>([if (daysSinceStart < TOO_EARLY_DAYS) {return ExperimentReplayListEmptyReason.TooEarly}+ // Tightest narrowing first, so the way back out is one step.+ if (filtersCustomized) {+ return ExperimentReplayListEmptyReason.FiltersNarrowed+ }+ // A non-empty bucket, or the metric event filters the tab puts on the list itself.+ if (bucketSessionIds !== undefined || filtersFromUniversalFilterGroups(recordingsFilters).length > 0) {+ return ExperimentReplayListEmptyReason.MetricFilterMatchedNothing+ }+ if (effectiveVariantKey !== null) {+ return ExperimentReplayListEmptyReason.VariantHasNone+ }+ if (effectiveExposureScope === 'in_session') {+ return ExperimentReplayListEmptyReason.InSessionHasNone+ }// A window that expired only in part gets no reason of its own, whether the// experiment ended or still runs: its retained days are inside retention, so an// empty list there is unexplained. `days_since_start` and `retention_period` ride@@ -1111,6 +1227,19 @@ export const experimentReplayTabLogic = kea<experimentReplayTabLogicType>([return ExperimentReplayListEmptyReason.UnknownInWindow},],+ listEmptyContext: [+ (s) => [s.currentTeam, s.effectiveVariantKey, (_, props) => props.experiment],+ (+ currentTeam: TeamPublicType | TeamType | null,+ effectiveVariantKey: string | null,+ experiment: Experiment+ ): ExperimentRecordingsListEmptyContext => ({+ daysSinceStart: daysSince(experiment.start_date),+ endDate: experiment.end_date ?? null,+ retentionWindowDays: retentionDays(currentTeam?.session_recording_retention_period),+ variantKey: effectiveVariantKey,+ }),+ ],// What the list was narrowed by, shared by the opened-recording and list-rendered reports so// an empty list and an opened recording are comparable facet for facet.filterContext: [@@ -1492,6 +1621,15 @@ export const experimentReplayTabLogic = kea<experimentReplayTabLogicType>([action,})},+ listEmptyActionClicked: ({ action }) => {+ actions.reportExperimentRecordingsEmptyActionClicked(props.experiment.id, {+ // `show_hidden` is offered whenever the viewer hides watched recordings, which the+ // API applies to the query. No reason explains that emptiness, and `listEmptyReason`+ // would name one, so the report carries the action on its own.+ empty_reason: action === 'show_hidden' ? null : values.listEmptyReason,+ action,+ })+ },watchHighlightOpened: ({ card, position }) => {actions.reportExperimentWatchHighlightOpened(props.experiment.id, {card_kind: card.kind,diff --git a/frontend/src/scenes/experiments/stories/ExperimentRecordingsListEmpty.stories.tsx b/frontend/src/scenes/experiments/stories/ExperimentRecordingsListEmpty.stories.tsxnew file mode 100644index 000000000000..c34dec1ebde6--- /dev/null+++ b/frontend/src/scenes/experiments/stories/ExperimentRecordingsListEmpty.stories.tsx@@ -0,0 +1,150 @@+import { Meta, StoryObj } from '@storybook/react'+import { screen, waitFor, within } from '@testing-library/dom'+import userEvent from '@testing-library/user-event'++import { App } from 'scenes/App'+import { urls } from 'scenes/urls'++import { mswDecorator } from '~/mocks/browser'+import EXPERIMENT_WITH_FUNNEL_METRIC from '~/mocks/fixtures/api/experiments/experiment_with_funnel_metric.json'++// One story per empty reason: the copy is the feature, and a screenshot is the only way to check+// that each reason reads as its own answer. The default session_recordings handler returns an empty+// page, so every story here lands on the empty state.+//+// `replay_disabled` is the exception and has no story. `teamLogic` takes the team from the app+// context, and it holds on to the value replay is on whatever a story does to the context or to the+// endpoint, so the scene cannot be put in that state here. The unit test asserts that copy instead.+const EXPERIMENT_PATH = `/api/projects/:team_id/experiments/${EXPERIMENT_WITH_FUNNEL_METRIC.id}/`+const SESSION_BUCKETS_PATH = `/api/projects/:team_id/experiments/${EXPERIMENT_WITH_FUNNEL_METRIC.id}/session_buckets/`++// `mockDate` below is 2025-06-01, and the mock team keeps recordings for 30 days. Each story sets+// the run window against those two so the tab resolves the reason the story is named for.+const experimentRun = (startDate: string | null, endDate: string | null): Record<string, unknown> => ({+ ...EXPERIMENT_WITH_FUNNEL_METRIC,+ start_date: startDate,+ end_date: endDate,+})++const meta: Meta = {+ component: App,+ title: 'Scenes-App/Experiments',+ parameters: {+ layout: 'fullscreen',+ viewMode: 'story',+ mockDate: '2025-06-01',+ pageUrl: urls.experiment(EXPERIMENT_WITH_FUNNEL_METRIC.id) + '?tab=recordings',+ testOptions: { waitForSelector: '[data-attr="experiment-recordings-empty-state"] .LemonBanner' },+ },+ decorators: [+ mswDecorator({+ get: {+ [EXPERIMENT_PATH]: EXPERIMENT_WITH_FUNNEL_METRIC,+ '/api/environments/:team_id/experiments_config/': {},+ '/api/projects/:team_id/experiment_holdouts': { count: 0, results: [] },+ '/api/projects/:team_id/experiment_saved_metrics/': { count: 0, results: [] },+ [`/api/projects/:team_id/feature_flags/${EXPERIMENT_WITH_FUNNEL_METRIC.feature_flag.id}/`]:+ EXPERIMENT_WITH_FUNNEL_METRIC.feature_flag,+ [`/api/projects/:team_id/feature_flags/${EXPERIMENT_WITH_FUNNEL_METRIC.feature_flag.id}/status/`]: {},+ '/api/environments/:team_id/default_release_conditions/': [],+ '/api/projects/:team_id/property_definitions/seen_together': {},+ '/api/projects/:team_id/vision/scanners/': { count: 0, results: [] },+ },+ post: {+ '/api/environments/:team_id/query/:kind': [200, { results: [] }],+ },+ }),+ ],+}+export default meta++type Story = StoryObj<{}>++/** Replay is on, the window is inside retention, nothing narrowed the list, and it is still empty. */+export const ExperimentRecordingsEmptyUnknownInWindow: Story = {}++export const ExperimentRecordingsEmptyTooEarly: Story = {+ decorators: [mswDecorator({ get: { [EXPERIMENT_PATH]: experimentRun('2025-05-30T09:00:00Z', null) } })],+}++export const ExperimentRecordingsEmptyEndedPastRetention: Story = {+ decorators: [+ mswDecorator({+ get: { [EXPERIMENT_PATH]: experimentRun('2025-01-10T09:00:00Z', '2025-04-01T09:00:00Z') },+ }),+ ],+}++/**+ * Waits for a control the scene renders once the experiment has loaded, then clicks it. Storybook+ * leaves testing-library's test id attribute at its default, unlike jest and Playwright, so a+ * `data-attr` has to be matched as a plain attribute.+ */+async function clickWhenRendered(canvasElement: HTMLElement, dataAttr: string): Promise<void> {+ const control = await waitFor(() => {+ const button = canvasElement.querySelector<HTMLElement>(`[data-attr="${dataAttr}"]`)+ if (!button) {+ throw new Error(`${dataAttr} not yet rendered`)+ }+ return button+ })+ await userEvent.click(control)+}++/** Narrowed to one variant, so the reason is the facet rather than anything about the project. */+export const ExperimentRecordingsEmptyVariantHasNone: Story = {+ 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.+ */+export const ExperimentRecordingsEmptyInSessionHasNone: Story = {+ decorators: [+ mswDecorator({+ get: {+ [`/api/projects/:team_id/experiments/${EXPERIMENT_WITH_FUNNEL_METRIC.id}/in_session_exposure/`]: {+ available: true,+ unavailable_reason: null,+ uses_stamped_fallback: false,+ },+ },+ }),+ ],+ play: async ({ canvasElement }) => {+ await clickWhenRendered(canvasElement, 'experiment-recordings-exposure-scope-in-session')+ },+}++/** The two metric-filter reasons need the filter switched on, which only the menu can do. */+const pickFiredNone: Story['play'] = async ({ canvasElement }) => {+ await clickWhenRendered(canvasElement, 'experiment-recordings-metric-filter')+ // The menu content is a portal outside the canvas, so this searches the whole document.+ await userEvent.click(await screen.findByText('Fired none'))+}++export const ExperimentRecordingsEmptyMetricFilterMatchedNothing: Story = {+ decorators: [+ mswDecorator({+ post: {+ [SESSION_BUCKETS_PATH]: {+ session_ids: [],+ truncated: false,+ considered_metrics: [{ metric_uuid: 'funnel', metric_name: 'Checkout funnel' }],+ excluded_metrics: [],+ filter_test_accounts: true,+ },+ },+ }),+ ],+ play: pickFiredNone,+}++export const ExperimentRecordingsEmptyMetricFilterFailed: Story = {+ decorators: [mswDecorator({ post: { [SESSION_BUCKETS_PATH]: [400, { detail: 'Could not resolve the filter' }] } })],+ play: pickFiredNone,+}diff --git a/frontend/src/scenes/session-recordings/playlist/Playlist.test.tsx b/frontend/src/scenes/session-recordings/playlist/Playlist.test.tsxindex b3f83717d1fa..8704a12d8802 100644--- a/frontend/src/scenes/session-recordings/playlist/Playlist.test.tsx+++ b/frontend/src/scenes/session-recordings/playlist/Playlist.test.tsx@@ -7,7 +7,7 @@ import { BindLogic, Provider } from 'kea'import { useMocks } from '~/mocks/jest'import { initKeaTests } from '~/test/init'-import { Playlist } from './Playlist'+import { Playlist, PlaylistProps } from './Playlist'import { sessionRecordingsPlaylistLogic } from './sessionRecordingsPlaylistLogic'jest.mock('scenes/session-recordings/filters/RecordingsUniversalFiltersEmbed', () => ({@@ -53,11 +53,11 @@ describe('Playlist', () => {localStorage.clear()})- function renderPlaylist(): ReturnType<typeof render> {+ function renderPlaylist(props: PlaylistProps = {}): ReturnType<typeof render> {return render(<Provider><BindLogic logic={sessionRecordingsPlaylistLogic} props={logicProps}>- <Playlist />+ <Playlist {...props} /></BindLogic></Provider>)@@ -70,6 +70,17 @@ describe('Playlist', () => {expect(screen.queryByText('Show all')).not.toBeInTheDocument()})+ it('lets the caller replace the troubleshooting panel for an empty list', async () => {+ renderPlaylist({ listEmptyState: <div data-attr="caller-empty-state" /> })++ await waitFor(() => {+ expect(logic.values.sessionRecordingsResponseLoading).toBe(false)+ })++ expect(screen.getByTestId('caller-empty-state')).toBeInTheDocument()+ expect(screen.queryByTestId('mock-troubleshooting')).not.toBeInTheDocument()+ })+it('shows the selected sessions notice and clears session_ids via "Show all"', async () => {logic.actions.setFilters({ session_ids: ['s1', 's2'] })diff --git a/frontend/src/scenes/session-recordings/playlist/Playlist.tsx b/frontend/src/scenes/session-recordings/playlist/Playlist.tsxindex 4c0302b3d420..fe95e8db652f 100644--- a/frontend/src/scenes/session-recordings/playlist/Playlist.tsx+++ b/frontend/src/scenes/session-recordings/playlist/Playlist.tsx@@ -64,6 +64,12 @@ export type PlaylistProps = {isSynthetic?: booleandescription?: stringselectInitialItem?: boolean+ /**+ * Replaces the shared replay troubleshooting panel when a filters list comes back empty. Set it+ * on a surface that already knows why its list is empty, because the shared panel can only+ * offer the generic replay hints. Collections keep their own empty state.+ */+ listEmptyState?: JSX.Element}export function Playlist({@@ -73,6 +79,7 @@ export function Playlist({isSynthetic,description,selectInitialItem,+ listEmptyState,}: PlaylistProps): JSX.Element {const { isPlaylistCollapsed } = useValues(playerSettingsLogic)const { setPlaylistCollapsed } = useActions(playerSettingsLogic)@@ -224,11 +231,11 @@ export function Playlist({const activeItemId = activeSessionRecordingId === undefined ? controlledActiveItemId : activeSessionRecordingId- const listEmptyState =+ const emptyState =type === 'collection' ? (<CollectionEmptyState isSynthetic={isSynthetic} description={description} />) : (- <ListEmptyState />+ <ListEmptyState listEmptyState={listEmptyState} />)// Show collapsed view@@ -343,7 +350,7 @@ export function Playlist({loading={!!sessionRecordingsResponseLoading}setActiveItemId={onChangeActiveItem}activeItemId={activeItemId}- emptyState={listEmptyState}+ emptyState={emptyState}scrollEl={scrollEl}/>),@@ -361,13 +368,13 @@ export function Playlist({loading={!!sessionRecordingsResponseLoading}setActiveItemId={onChangeActiveItem}activeItemId={activeItemId}- emptyState={listEmptyState}+ emptyState={emptyState}scrollEl={scrollEl}/>) : sessionRecordingsResponseLoading ? (<LoadingState />) : (- listEmptyState+ emptyState)}</div></div>@@ -404,7 +411,7 @@ const TitleWithCount = ({ title, count }: { title?: string; count: number }): JS)}-const ListEmptyState = (): JSX.Element => {+const ListEmptyState = ({ listEmptyState }: Pick<PlaylistProps, 'listEmptyState'>): JSX.Element => {const { sessionRecordingsAPIErrored, unusableEventsInFilter } = useValues(sessionRecordingsPlaylistLogic)return (@@ -415,7 +422,7 @@ const ListEmptyState = (): JSX.Element => {<UnusableEventsWarning unusableEventsInFilter={unusableEventsInFilter} />) : (<div className="flex flex-col gap-2">- <SessionRecordingsPlaylistTroubleshooting />+ {listEmptyState ?? <SessionRecordingsPlaylistTroubleshooting />}</div>)}</div>diff --git a/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylist.tsx b/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylist.tsxindex 2990fd8816c9..43a593b2b164 100644--- a/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylist.tsx+++ b/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylist.tsx@@ -23,13 +23,15 @@ import { SessionRecordingPlaylistLogicProps, sessionRecordingsPlaylistLogic } frconst HedgehogDirector = pngHoggie(directorPng)-export function SessionRecordingsPlaylist({- ...props-}: SessionRecordingPlaylistLogicProps & {+type SessionRecordingsPlaylistProps = SessionRecordingPlaylistLogicProps & {showContent?: booleanisSynthetic?: booleandescription?: string-}): JSX.Element {+ /** Replaces the shared replay troubleshooting panel when the list comes back empty. */+ listEmptyState?: JSX.Element+}++export function SessionRecordingsPlaylist({ ...props }: SessionRecordingsPlaylistProps): JSX.Element {const logicProps: SessionRecordingPlaylistLogicProps = {...props,autoPlay: props.autoPlay ?? true,@@ -56,13 +58,7 @@ export function SessionRecordingsPlaylist({)}-function HorizontalLayout({- ...props-}: SessionRecordingPlaylistLogicProps & {- showContent?: boolean- isSynthetic?: boolean- description?: string-}): JSX.Element {+function HorizontalLayout({ ...props }: SessionRecordingsPlaylistProps): JSX.Element {const playlistRef = useRef<HTMLDivElement>(null)const { isPlaylistCollapsed } = useValues(playerSettingsLogic)@@ -107,13 +103,7 @@ function HorizontalLayout({)}-function VerticalLayout({- ...props-}: SessionRecordingPlaylistLogicProps & {- showContent?: boolean- isSynthetic?: boolean- description?: string-}): JSX.Element {+function VerticalLayout({ ...props }: SessionRecordingsPlaylistProps): JSX.Element {const playerRef = useRef<HTMLDivElement>(null)const { isPlaylistCollapsed } = useValues(playerSettingsLogic)