Skip to content

Commit

Permalink
feat: allow switching timing view (#18647)
Browse files Browse the repository at this point in the history
* feat: allow switching timing view

* sentence case

* Update UI snapshots for `chromium` (2)

* reverse of the sanitize props processing

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
pauldambra and github-actions[bot] authored Nov 15, 2023
1 parent f77b981 commit 3332f86
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 7 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ export function ItemPerformanceEvent({
tabs={[
{
key: 'timings',
label: 'timings',
label: 'Timings',
content: (
<>
<SimpleKeyValueList item={sanitizedProps} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import { PerformanceEvent } from '~/types'
import { getSeriesColor } from 'lib/colors'
import { humanFriendlyMilliseconds } from 'lib/utils'
import { Tooltip } from 'lib/lemon-ui/Tooltip'
import { useState } from 'react'
import { LemonBanner } from 'lib/lemon-ui/LemonBanner'
import { LemonDivider } from 'lib/lemon-ui/LemonDivider'
import { SimpleKeyValueList } from 'scenes/session-recordings/player/inspector/components/SimpleKeyValueList'
import { LemonButton } from 'lib/lemon-ui/LemonButton'

function colorForEntry(entryType: string | undefined): string {
switch (entryType) {
Expand Down Expand Up @@ -217,11 +222,7 @@ function percentagesWithinEventRange({
return { startPercentage: `${partStartPercentage}%`, widthPercentage: `${partPercentage}%` }
}

export const NetworkRequestTiming = ({
performanceEvent,
}: {
performanceEvent: PerformanceEvent
}): JSX.Element | null => {
const TimeLineView = ({ performanceEvent }: { performanceEvent: PerformanceEvent }): JSX.Element => {
const rangeStart = performanceEvent.start_time
const rangeEnd = performanceEvent.response_end
if (typeof rangeStart === 'number' && typeof rangeEnd === 'number') {
Expand Down Expand Up @@ -276,5 +277,44 @@ export const NetworkRequestTiming = ({
</div>
)
}
return null
return <LemonBanner type={'warning'}>Cannot render performance timeline for this request</LemonBanner>
}

const TableView = ({ performanceEvent }: { performanceEvent: PerformanceEvent }): JSX.Element => {
const timingProperties = Object.entries(performanceEvent).reduce((acc, [key, val]) => {
if (key.includes('time') || key.includes('end') || key.includes('start')) {
acc[key] = val
}
return acc
}, {})
return <SimpleKeyValueList item={timingProperties} />
}

export const NetworkRequestTiming = ({
performanceEvent,
}: {
performanceEvent: PerformanceEvent
}): JSX.Element | null => {
const [timelineMode, setTimelineMode] = useState<boolean>(true)

return (
<div className={'flex flex-col space-y-2'}>
<div className={'flex flex-row justify-end'}>
<LemonButton
type={'secondary'}
status={'stealth'}
onClick={() => setTimelineMode(!timelineMode)}
data-attr={`switch-timing-to-${timelineMode ? 'table' : 'timeline'}-view`}
>
{timelineMode ? 'Table view' : 'Timeline view'}
</LemonButton>
</div>
<LemonDivider dashed={true} />
{timelineMode ? (
<TimeLineView performanceEvent={performanceEvent} />
) : (
<TableView performanceEvent={performanceEvent} />
)}
</div>
)
}

0 comments on commit 3332f86

Please sign in to comment.