From 3260f782964033f4dec5efc891c5921b44a097b9 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Wed, 18 Dec 2024 13:54:02 +0000 Subject: [PATCH] fix --- .../player/SessionRecordingPlayer.tsx | 12 +++--------- .../player/sessionRecordingDataLogic.ts | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/frontend/src/scenes/session-recordings/player/SessionRecordingPlayer.tsx b/frontend/src/scenes/session-recordings/player/SessionRecordingPlayer.tsx index 6b28feca120ae..d70a3267a2532 100644 --- a/frontend/src/scenes/session-recordings/player/SessionRecordingPlayer.tsx +++ b/frontend/src/scenes/session-recordings/player/SessionRecordingPlayer.tsx @@ -4,7 +4,6 @@ import { LemonButton } from '@posthog/lemon-ui' import clsx from 'clsx' import { BindLogic, useActions, useValues } from 'kea' import { BuilderHog2 } from 'lib/components/hedgehogs' -import { dayjs } from 'lib/dayjs' import { FloatingContainerContext } from 'lib/hooks/useFloatingContainerContext' import { HotkeysInterface, useKeyboardHotkeys } from 'lib/hooks/useKeyboardHotkeys' import { usePageVisibility } from 'lib/hooks/usePageVisibility' @@ -87,11 +86,9 @@ export function SessionRecordingPlayer(props: SessionRecordingPlayerProps): JSX. setSpeed, closeExplorer, } = useActions(sessionRecordingPlayerLogic(logicProps)) - const { isNotFound, snapshotsInvalid, start } = useValues(sessionRecordingDataLogic(logicProps)) + const { isNotFound, isRecentAndInvalid } = useValues(sessionRecordingDataLogic(logicProps)) const { loadSnapshots } = useActions(sessionRecordingDataLogic(logicProps)) - const { isFullScreen, explorerMode, isBuffering, messageTooLargeWarnings } = useValues( - sessionRecordingPlayerLogic(logicProps) - ) + const { isFullScreen, explorerMode, isBuffering } = useValues(sessionRecordingPlayerLogic(logicProps)) const { setPlayNextAnimationInterrupted } = useActions(sessionRecordingPlayerLogic(logicProps)) const speedHotkeys = useMemo(() => createPlaybackSpeedKey(setSpeed), [setSpeed]) const { isVerticallyStacked, sidebarOpen, playbackMode } = useValues(playerSettingsLogic) @@ -158,9 +155,6 @@ export function SessionRecordingPlayer(props: SessionRecordingPlayerProps): JSX. } ) - const lessThanFiveMinutesOld = dayjs().diff(start, 'minute') <= 5 - const cannotPlayback = snapshotsInvalid && lessThanFiveMinutesOld && !messageTooLargeWarnings - const { draggable, elementProps } = useNotebookDrag({ href: urls.replaySingle(sessionRecordingId) }) if (isNotFound) { @@ -198,7 +192,7 @@ export function SessionRecordingPlayer(props: SessionRecordingPlayerProps): JSX. className="SessionRecordingPlayer__main flex flex-col h-full w-full" ref={playerMainRef} > - {cannotPlayback ? ( + {isRecentAndInvalid ? (

We're still working on it

diff --git a/frontend/src/scenes/session-recordings/player/sessionRecordingDataLogic.ts b/frontend/src/scenes/session-recordings/player/sessionRecordingDataLogic.ts index 10118ce5defdc..ff63bd4b1f397 100644 --- a/frontend/src/scenes/session-recordings/player/sessionRecordingDataLogic.ts +++ b/frontend/src/scenes/session-recordings/player/sessionRecordingDataLogic.ts @@ -1087,13 +1087,13 @@ export const sessionRecordingDataLogic = kea([ if (everyWindowMissingFullSnapshot) { // video is definitely unplayable posthog.capture('recording_has_no_full_snapshot', { - sessionId: sessionRecordingId, + watchedSession: sessionRecordingId, teamId: currentTeam?.id, teamName: currentTeam?.name, }) } else if (anyWindowMissingFullSnapshot) { posthog.capture('recording_window_missing_full_snapshot', { - sessionId: sessionRecordingId, + watchedSession: sessionRecordingId, teamID: currentTeam?.id, teamName: currentTeam?.name, }) @@ -1103,6 +1103,14 @@ export const sessionRecordingDataLogic = kea([ }, ], + isRecentAndInvalid: [ + (s) => [s.start, s.snapshotsInvalid], + (start, snapshotsInvalid) => { + const lessThanFiveMinutesOld = dayjs().diff(start, 'minute') <= 5 + return snapshotsInvalid && lessThanFiveMinutesOld + }, + ], + bufferedToTime: [ (s) => [s.segments], (segments): number | null => { @@ -1160,6 +1168,13 @@ export const sessionRecordingDataLogic = kea([ actions.loadFullEventData(value) } }, + isRecentAndInvalid: (prev: boolean, next: boolean) => { + if (!prev && next) { + posthog.capture('recording cannot playback yet', { + watchedSession: values.sessionPlayerData.sessionRecordingId, + }) + } + }, })), afterMount(({ cache }) => { resetTimingsCache(cache)