: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(replay): explain empty recordings list by its real cause (#88955)
posthog[bot]b796e9331fd1
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex e49f2a492fe9..159745e6bd97 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -6849,9 +6849,9 @@ snapshots:scenes-app-experiments--experiment-frequentist-two-variants--light:hash: v1.k794b7964.c3d7500050335234dac2b12a58ae26fe68611d4f4fb040ab162a0b22aa2816c4.yZkCSjTEKndRt6r5t2hSlLwgfIwnnDg5or8MZX0tAz0scenes-app-experiments--experiment-replay-scanner-backlink--dark:- hash: v1.k794b7964.e04ec522e5f690078c89c21f4e160d067f13c755e65988852d89dbc624e4c74b.DbWktEPnIBX15xGlIGLocMuFHo7CzbH-yVTgowQMnck+ hash: v1.k794b7964.7efe310d3bf7b9c4d5462d30ae611e6248804e02857e97bb5a112c76fd1b66fe.aDk-Mc3Vtc8YcmQ4tpT7MpVrYARzKCdcwiKj4PFlxicscenes-app-experiments--experiment-replay-scanner-backlink--light:- hash: v1.k794b7964.c6573bba587cbabd798e942c29bd722fea308624f4cffda71303fb2b110dd7e0.j-wHlxQDewiAsZ_lDoIuGozhNEb_FEGu0tT0I_UXkMY+ hash: v1.k794b7964.2dc5ae6c50622395d0e6faebae14181a3a26b304acaafcff67a9b9fcc4307bda.lxOQLxGPUK14YY86vol2qQN_x4w0Uy6zERaXaSDAnVQscenes-app-experiments--experiment-stopped-with-conclusion--dark:hash: v1.k794b7964.e347bbe9e217d7cbd915b09b362a9d995285c1f6492229235ce3dcef74e49f30.5xV99CaEDXp-xFACHoS4M9vQ6zFGOjestb-iW79F5Q4scenes-app-experiments--experiment-stopped-with-conclusion--light:diff --git a/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylistTroubleshooting.test.tsx b/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylistTroubleshooting.test.tsxnew file mode 100644index 000000000000..a447a6902cb9--- /dev/null+++ b/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylistTroubleshooting.test.tsx@@ -0,0 +1,111 @@+import '@testing-library/jest-dom'++import { cleanup, render, screen } from '@testing-library/react'+import { BindLogic, Provider } from 'kea'++import { useMocks } from '~/mocks/jest'+import { initKeaTests } from '~/test/init'++import { playerSettingsLogic } from '../player/playerSettingsLogic'+import {+ DEFAULT_RECORDING_FILTERS,+ SessionRecordingPlaylistLogicProps,+ sessionRecordingsPlaylistLogic,+} from './sessionRecordingsPlaylistLogic'+import { SessionRecordingsPlaylistTroubleshooting } from './SessionRecordingsPlaylistTroubleshooting'++describe('SessionRecordingsPlaylistTroubleshooting', () => {+ let logic: ReturnType<typeof sessionRecordingsPlaylistLogic.build>++ const logicProps: SessionRecordingPlaylistLogicProps = {+ logicKey: 'troubleshooting-test',+ updateSearchParams: false,+ }++ beforeEach(() => {+ useMocks({+ get: {+ '/api/environments/:team_id/session_recordings': { results: [], has_next: false },+ '/api/environments/:team_id/session_recordings/properties': { results: [] },+ },+ })+ initKeaTests()+ logic = sessionRecordingsPlaylistLogic(logicProps)+ logic.mount()+ playerSettingsLogic.mount()+ })++ afterEach(() => {+ cleanup()+ playerSettingsLogic.actions.setHideViewedRecordings(false)+ playerSettingsLogic.unmount()+ logic.unmount()+ localStorage.clear()+ })++ function renderTroubleshooting(props: SessionRecordingPlaylistLogicProps = logicProps): ReturnType<typeof render> {+ return render(+ <Provider>+ <BindLogic logic={sessionRecordingsPlaylistLogic} props={props}>+ <SessionRecordingsPlaylistTroubleshooting />+ </BindLogic>+ </Provider>+ )+ }++ it.each([+ ['no filters are applied', false, 'No recordings found'],+ ['filters are applied', true, 'No recordings match your filters'],+ ])('names the cause in the heading when %s, and always keeps the capture hints', (_, withFilters, heading) => {+ if (withFilters) {+ logic.actions.setFilters({ date_from: '-30d' })+ }++ renderTroubleshooting()++ expect(screen.getByText(heading)).toBeInTheDocument()+ // Filters being the likely cause does not rule out capture problems, so the hints stay.+ expect(screen.getByText('An ad blocker might be preventing recordings')).toBeInTheDocument()+ expect(screen.getByText('Recordings might be outside the retention period')).toBeInTheDocument()+ })++ it('offers to clear filters only when the user applied them', () => {+ renderTroubleshooting()+ expect(screen.queryByTestId('replay-empty-state-troubleshooting-clear-filters')).not.toBeInTheDocument()++ cleanup()+ logic.actions.setFilters({ date_from: '-30d' })+ renderTroubleshooting()++ expect(screen.getByText('Clear filters')).toBeInTheDocument()+ })++ it('does not offer to clear filters the caller owns, which resetFilters would drop', () => {+ const scopedProps: SessionRecordingPlaylistLogicProps = {+ logicKey: 'troubleshooting-scoped-test',+ updateSearchParams: false,+ filters: { ...DEFAULT_RECORDING_FILTERS, date_from: '-30d' },+ }+ const scopedLogic = sessionRecordingsPlaylistLogic(scopedProps)+ scopedLogic.mount()++ renderTroubleshooting(scopedProps)++ expect(scopedLogic.values.totalFiltersCount).toBeGreaterThan(0)+ expect(screen.queryByTestId('replay-empty-state-troubleshooting-clear-filters')).not.toBeInTheDocument()++ scopedLogic.unmount()+ })++ it('offers to show hidden recordings when the setting is on, even with a zero client count', () => {+ playerSettingsLogic.actions.setHideViewedRecordings('current-user')++ renderTroubleshooting()++ // Hiding is server-side, so the count is 0: the countless label proves the setting drives it.+ expect(logic.values.hiddenRecordingsCount).toBe(0)+ expect(screen.getByTestId('replay-empty-state-troubleshooting-show-hidden-recordings')).toHaveTextContent(+ /^Show hidden recordings$/+ )+ })+})diff --git a/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylistTroubleshooting.tsx b/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylistTroubleshooting.tsxindex 29d58de19c25..d008ed78f2df 100644--- a/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylistTroubleshooting.tsx+++ b/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylistTroubleshooting.tsx@@ -6,16 +6,24 @@ import { playerSettingsLogic } from '../player/playerSettingsLogic'import { sessionRecordingsPlaylistLogic } from './sessionRecordingsPlaylistLogic'export const SessionRecordingsPlaylistTroubleshooting = (): JSX.Element => {+ const { hideViewedRecordings } = useValues(playerSettingsLogic)const { setHideViewedRecordings } = useActions(playerSettingsLogic)- const { hiddenRecordingsCount } = useValues(sessionRecordingsPlaylistLogic)- const { setShowSettings, setFilters } = useActions(sessionRecordingsPlaylistLogic)+ const { hiddenRecordingsCount, totalFiltersCount, isScopedByCaller } = useValues(sessionRecordingsPlaylistLogic)+ const { setShowSettings, setFilters, resetFilters } = useActions(sessionRecordingsPlaylistLogic)++ const recordingsAreHidden = hideViewedRecordings !== false+ const hasFilters = totalFiltersCount > 0+ // Clearing would drop the caller's scoping, leaving a list that no longer matches the surface.+ const canClearFilters = hasFilters && !isScopedByCallerreturn (<>- <h3 className="title text-secondary mb-0">No matching recordings</h3>+ <h3 className="title text-secondary mb-0">+ {hasFilters ? 'No recordings match your filters' : 'No recordings found'}+ </h3><div className="flex flex-col deprecated-space-y-2"><ul className="deprecated-space-y-1">- {hiddenRecordingsCount > 0 && (+ {recordingsAreHidden && (<li><LemonButtontype="secondary"@@ -27,7 +35,22 @@ export const SessionRecordingsPlaylistTroubleshooting = (): JSX.Element => {setHideViewedRecordings(false)}}>- Show {hiddenRecordingsCount} hidden recordings+ {hiddenRecordingsCount > 0+ ? `Show ${hiddenRecordingsCount} hidden recordings`+ : 'Show hidden recordings'}+ </LemonButton>+ </li>+ )}+ {canClearFilters && (+ <li>+ <LemonButton+ type="secondary"+ fullWidth={true}+ size="xsmall"+ data-attr="replay-empty-state-troubleshooting-clear-filters"+ onClick={() => resetFilters()}+ >+ Clear filters</LemonButton></li>)}diff --git a/frontend/src/scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic.ts b/frontend/src/scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic.tsindex c33cd1efba6d..b00f03bf2c28 100644--- a/frontend/src/scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic.ts+++ b/frontend/src/scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic.ts@@ -501,6 +501,7 @@ export interface sessionRecordingsPlaylistLogicValues {isCreatingNewCollectionInModal: booleanisDeleteSelectedRecordingsDialogOpen: booleanisDeletingSelectedRecordings: boolean+ isScopedByCaller: booleanlogicProps: SessionRecordingPlaylistLogicPropsmatchingEventsMatchType: MatchingEventsMatchTypenewCollectionName: string@@ -796,6 +797,7 @@ export interface sessionRecordingsPlaylistLogicMeta {}) => booleanpinnedFilters: (arg: any) => UniversalFiltersGroup | undefined+ isScopedByCaller: (arg: any) => booleantotalFiltersCount: (filters: RecordingUniversalFilters, arg: any, arg2: any) => numberhiddenRecordings: (sessionRecordings: SessionRecordingType[],@@ -1845,6 +1847,12 @@ export const sessionRecordingsPlaylistLogic = kea<sessionRecordingsPlaylistLogic(pinnedFilters): UniversalFiltersGroup | undefined => pinnedFilters,],+ // props.filters scopes embedded playlists (experiment tab, group page, notebook node).+ isScopedByCaller: [+ () => [(_, props) => props.filters],+ (filters: RecordingUniversalFilters | undefined): boolean => !!filters,+ ],+totalFiltersCount: [(s) => [s.filters, (_, props) => props.personUUID, (_, props) => props.pinnedFilters],(filters: RecordingUniversalFilters, personUUID, pinnedFilters) => {