Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(experiments): Add note for 'hide' setting on an empty list (#96938)

Marcel Poelkerb94e015eaf88
diff --git a/frontend/src/scenes/experiments/ExperimentView/ExperimentRecordingsListEmptyState.test.tsx b/frontend/src/scenes/experiments/ExperimentView/ExperimentRecordingsListEmptyState.test.tsx
index d76b32abae1d..05756d258362 100644
--- a/frontend/src/scenes/experiments/ExperimentView/ExperimentRecordingsListEmptyState.test.tsx
+++ b/frontend/src/scenes/experiments/ExperimentView/ExperimentRecordingsListEmptyState.test.tsx
@@ -8,7 +8,7 @@ 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 { HideViewedRecordingsOptions, playerSettingsLogic } from 'scenes/session-recordings/player/playerSettingsLogic'
import {
DEFAULT_RECORDING_FILTERS,
SessionRecordingPlaylistLogicProps,
@@ -303,6 +303,38 @@ describe('ExperimentRecordingsListEmptyState', () => {
logic.unmount()
})
+ // The server removes the recordings this setting hides before it answers, so they never reach
+ // the browser, `hiddenRecordingsCount` stays zero, and the reason reads as if nothing were
+ // hidden. The note is the only thing that tells the viewer otherwise. 'any-user' hides what the
+ // whole project watched, so copy about this viewer's own watching would be false there.
+ it.each([
+ ['current-user', 214, 'Recordings you have already watched are hidden'],
+ ['any-user', 215, 'Recordings anyone on your team has already watched are hidden'],
+ ] as [HideViewedRecordingsOptions, number, string][])(
+ 'notes the %s setting next to the reason it could account for',
+ async (mode, experimentId, copy) => {
+ teamLogic.actions.loadCurrentTeamSuccess(MOCK_DEFAULT_TEAM)
+ playerSettingsLogic.actions.setHideViewedRecordings(mode)
+ const experiment = {
+ ...EXPERIMENT,
+ id: experimentId,
+ start_date: daysAgo(10),
+ end_date: daysAgo(2),
+ } as Experiment
+ const logic = experimentReplayTabLogic({ experiment })
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+
+ renderEmptyState(experiment)
+
+ const emptyState = screen.getByTestId('experiment-recordings-empty-state')
+ expect(emptyState).toHaveTextContent('A session can be missing for a few reasons')
+ expect(emptyState).toHaveTextContent(copy)
+
+ 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')
diff --git a/frontend/src/scenes/experiments/ExperimentView/ExperimentRecordingsListEmptyState.tsx b/frontend/src/scenes/experiments/ExperimentView/ExperimentRecordingsListEmptyState.tsx
index c37cf11604e1..9e683b1dc830 100644
--- a/frontend/src/scenes/experiments/ExperimentView/ExperimentRecordingsListEmptyState.tsx
+++ b/frontend/src/scenes/experiments/ExperimentView/ExperimentRecordingsListEmptyState.tsx
@@ -236,7 +236,21 @@ export function ExperimentRecordingsListEmptyState({ experiment }: { experiment:
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} />
+ <>
+ <ReasonBanner reason={listEmptyReason} context={listEmptyContext} onAction={runAction} />
+ {/* The reason above is a guess from an empty list, and this setting can empty the
+ list on its own. The server removes the recordings it hides before it answers,
+ so they never reach the browser and the count above stays zero for them.
+ 'any-user' hides what the whole project watched, so the copy has to say whose
+ watching emptied the list. */}
+ {recordingsAreHidden && (
+ <p className="text-secondary text-xs">
+ {hideViewedRecordings === 'any-user'
+ ? 'Recordings anyone on your team has already watched are hidden, so this list can be empty for that reason alone.'
+ : 'Recordings you have already watched are hidden, so this list can be empty for that reason alone.'}
+ </p>
+ )}
+ </>
)}
</div>
)