-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: show recording button if set #26565
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { LemonButton, LemonButtonProps } from '@posthog/lemon-ui' | ||
import { useActions } from 'kea' | ||
import { Dayjs, dayjs } from 'lib/dayjs' | ||
import { IconPlayCircle } from 'lib/lemon-ui/icons' | ||
import { sessionPlayerModalLogic } from 'scenes/session-recordings/player/modal/sessionPlayerModalLogic' | ||
import { urls } from 'scenes/urls' | ||
|
||
import { EventType } from '~/types' | ||
|
||
export default function ViewRecordingButton({ | ||
sessionId, | ||
timestamp, | ||
...props | ||
}: Pick<LemonButtonProps, 'size' | 'type' | 'data-attr' | 'fullWidth' | 'className'> & { | ||
sessionId: string | ||
timestamp?: string | Dayjs | ||
}): JSX.Element { | ||
const { openSessionPlayer } = useActions(sessionPlayerModalLogic) | ||
|
||
return ( | ||
<LemonButton | ||
to={urls.replaySingle(sessionId)} | ||
onClick={() => { | ||
const fiveSecondsBeforeEvent = dayjs(timestamp).valueOf() - 5000 | ||
openSessionPlayer({ id: sessionId }, Math.max(fiveSecondsBeforeEvent, 0)) | ||
}} | ||
sideIcon={<IconPlayCircle />} | ||
{...props} | ||
> | ||
View recording | ||
</LemonButton> | ||
) | ||
} | ||
|
||
export const mightHaveRecording = (properties: EventType['properties']): boolean => { | ||
return properties.$session_id | ||
? properties.$recording_status | ||
? properties.$recording_status === 'active' | ||
: true | ||
: false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
import { PersonDisplay, TZLabel } from '@posthog/apps-common' | ||
import { LemonButton } from '@posthog/lemon-ui' | ||
import clsx from 'clsx' | ||
import { useActions, useValues } from 'kea' | ||
import { EmptyMessage } from 'lib/components/EmptyMessage/EmptyMessage' | ||
import { ErrorDisplay } from 'lib/components/Errors/ErrorDisplay' | ||
import { Playlist } from 'lib/components/Playlist/Playlist' | ||
import { dayjs } from 'lib/dayjs' | ||
import { sessionPlayerModalLogic } from 'scenes/session-recordings/player/modal/sessionPlayerModalLogic' | ||
import ViewRecordingButton, { mightHaveRecording } from 'lib/components/ViewRecordingButton' | ||
import { PropertyIcons } from 'scenes/session-recordings/playlist/SessionRecordingPreview' | ||
|
||
import { ErrorTrackingEvent, errorTrackingIssueSceneLogic } from '../errorTrackingIssueSceneLogic' | ||
|
@@ -38,7 +36,13 @@ export const OverviewTab = (): JSX.Element => { | |
event ? ( | ||
<div className="h-full overflow-auto"> | ||
<div className="bg-bg-light p-1 flex justify-end border-b min-h-[42px]"> | ||
<ViewSessionButton event={event} /> | ||
{mightHaveRecording(event.properties) && ( | ||
<ViewRecordingButton | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe nicer to do this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't want to pass the |
||
size="small" | ||
sessionId={event.properties.$session_id} | ||
timestamp={event.timestamp} | ||
/> | ||
)} | ||
</div> | ||
<div className="pl-2"> | ||
<ErrorDisplay eventProperties={event.properties} /> | ||
|
@@ -62,25 +66,6 @@ export const OverviewTab = (): JSX.Element => { | |
) | ||
} | ||
|
||
const ViewSessionButton = ({ event }: { event: ErrorTrackingEvent }): JSX.Element | null => { | ||
const { openSessionPlayer } = useActions(sessionPlayerModalLogic) | ||
|
||
const sessionId = event.properties.$session_id | ||
|
||
return ( | ||
<LemonButton | ||
size="small" | ||
onClick={() => { | ||
const fiveSecondsBeforeEvent = dayjs(event.timestamp).valueOf() - 5000 | ||
openSessionPlayer({ id: sessionId }, Math.max(fiveSecondsBeforeEvent, 0)) | ||
}} | ||
disabledReason={!sessionId ? 'There was no Session ID associated with this exception' : undefined} | ||
> | ||
View recording | ||
</LemonButton> | ||
) | ||
} | ||
|
||
const ListItemException = ({ | ||
item: { timestamp, properties, person }, | ||
isActive, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so.... we need to consider library version here, no?
something like that - with a made up method I don't think exists 🙈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we not get away without it? I was working off the assumption that
properties.$recording_status
will be undefined for older versions of the SDK. That will fail the second check in the function and hence resolve totrue
(eg. for all events in a time before we captured$recording_status
we assume there might be a recordingThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ugh... yeah, ok... too many question marks and colons 🫠
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too many for my brain