Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Dec 18, 2024
1 parent f470b61 commit 3260f78
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -198,7 +192,7 @@ export function SessionRecordingPlayer(props: SessionRecordingPlayerProps): JSX.
className="SessionRecordingPlayer__main flex flex-col h-full w-full"
ref={playerMainRef}
>
{cannotPlayback ? (
{isRecentAndInvalid ? (
<div className="flex flex-1 flex-col items-center justify-center">
<BuilderHog2 height={200} />
<h1>We're still working on it</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1087,13 +1087,13 @@ export const sessionRecordingDataLogic = kea<sessionRecordingDataLogicType>([
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,
})
Expand All @@ -1103,6 +1103,14 @@ export const sessionRecordingDataLogic = kea<sessionRecordingDataLogicType>([
},
],

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 => {
Expand Down Expand Up @@ -1160,6 +1168,13 @@ export const sessionRecordingDataLogic = kea<sessionRecordingDataLogicType>([
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)
Expand Down

0 comments on commit 3260f78

Please sign in to comment.