-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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: error clustering UI #20958
Merged
Merged
feat: error clustering UI #20958
Changes from 13 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
56c68ca
add viewed count to result
daibhin b18d233
convert to table
daibhin dbc2fc3
view percentage
daibhin b2d2d0e
open example in modal
daibhin 52a2c20
better json parsing of errors
daibhin 193351c
remove playlist creation
daibhin d97d4d9
tweaks to API for better UI
daibhin 458f096
per user views
daibhin d0d090c
fix sorting
daibhin 29389b8
move session player modal to the bottom
daibhin 01fe452
Merge branch 'master' into dn-feat/error-clustering-ui
daibhin b26e52a
fix queryset typing
daibhin 2142c82
add title parsing
daibhin f364293
Update frontend/src/scenes/session-recordings/errors/SessionRecording…
daibhin 058b012
title parsing
daibhin 45e724d
Update UI snapshots for `chromium` (2)
github-actions[bot] e602f68
Update UI snapshots for `chromium` (2)
github-actions[bot] fb929e9
Merge branch 'master' into dn-feat/error-clustering-ui
daibhin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
import { IconFeatures } from '@posthog/icons' | ||
import { LemonButton, LemonCollapse, Spinner } from '@posthog/lemon-ui' | ||
import { LemonButton, LemonTable, LemonTabs, Spinner } from '@posthog/lemon-ui' | ||
import { useActions, useValues } from 'kea' | ||
import { JSONViewer } from 'lib/components/JSONViewer' | ||
import { useState } from 'react' | ||
import { urls } from 'scenes/urls' | ||
|
||
import { ErrorClusterSample } from '~/types' | ||
|
||
import { SessionPlayerModal } from '../player/modal/SessionPlayerModal' | ||
import { sessionPlayerModalLogic } from '../player/modal/sessionPlayerModalLogic' | ||
import { sessionRecordingErrorsLogic } from './sessionRecordingErrorsLogic' | ||
|
||
export function SessionRecordingErrors(): JSX.Element { | ||
const { openSessionPlayer } = useActions(sessionPlayerModalLogic) | ||
const { errors, errorsLoading } = useValues(sessionRecordingErrorsLogic) | ||
const { loadErrorClusters } = useActions(sessionRecordingErrorsLogic) | ||
|
||
|
@@ -24,57 +27,109 @@ export function SessionRecordingErrors(): JSX.Element { | |
} | ||
|
||
return ( | ||
<LemonCollapse | ||
panels={errors.map((error) => ({ | ||
key: error.cluster, | ||
header: ( | ||
<ErrorPanelHeader | ||
occurrenceCount={error.occurrences} | ||
sessionCount={error.unique_sessions} | ||
example={error.samples[0]} | ||
/> | ||
), | ||
content: <ErrorPanelContent samples={error.samples} />, | ||
}))} | ||
/> | ||
<> | ||
<LemonTable | ||
columns={[ | ||
{ | ||
title: 'Error', | ||
dataIndex: 'cluster', | ||
render: (_, cluster) => { | ||
const displayTitle = parseTitle(cluster.sample.error) | ||
return ( | ||
<div title={displayTitle} className="font-semibold text-sm text-default line-clamp-1"> | ||
{displayTitle} | ||
</div> | ||
) | ||
}, | ||
width: '50%', | ||
}, | ||
{ | ||
title: 'Occurrences', | ||
dataIndex: 'occurrences', | ||
sorter: (a, b) => a.occurrences - b.occurrences, | ||
}, | ||
{ | ||
title: 'Sessions', | ||
dataIndex: 'unique_sessions', | ||
sorter: (a, b) => a.unique_sessions - b.unique_sessions, | ||
}, | ||
{ | ||
title: 'Viewed', | ||
tooltip: "Percentage of the issue you've already seen in other watched recordings", | ||
daibhin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
dataIndex: 'viewed', | ||
render: function Render(_, cluster) { | ||
return `${((cluster.viewed / cluster.unique_sessions) * 100).toFixed(0)}%` | ||
}, | ||
sorter: (a, b) => a.viewed / a.unique_sessions - b.viewed / b.unique_sessions, | ||
}, | ||
{ | ||
title: 'Actions', | ||
render: function Render(_, cluster) { | ||
return ( | ||
<LemonButton | ||
to={urls.replaySingle(cluster.sample.session_id)} | ||
onClick={(e) => { | ||
e.preventDefault() | ||
openSessionPlayer({ id: cluster.sample.session_id }) | ||
}} | ||
className="p-2 whitespace-nowrap" | ||
type="primary" | ||
> | ||
Watch example | ||
</LemonButton> | ||
) | ||
}, | ||
}, | ||
]} | ||
dataSource={errors} | ||
expandable={{ expandedRowRender: (cluster) => <ExpandedError error={cluster.sample.error} /> }} | ||
/> | ||
<SessionPlayerModal /> | ||
</> | ||
) | ||
} | ||
|
||
const ErrorPanelHeader = ({ | ||
occurrenceCount, | ||
sessionCount, | ||
example, | ||
}: { | ||
occurrenceCount: number | ||
sessionCount: number | ||
example: ErrorClusterSample | ||
}): JSX.Element => { | ||
return ( | ||
<div className="w-full flex justify-between items-center gap-2"> | ||
<span className="truncate">{example.input}</span> | ||
<div className="flex items-center gap-2"> | ||
<span className="text-muted"> | ||
{occurrenceCount} occurrences / {sessionCount} sessions | ||
</span> | ||
<LemonButton type="secondary" to={urls.replaySingle(example.session_id)}> | ||
Watch recording | ||
</LemonButton> | ||
</div> | ||
const ExpandedError = ({ error }: { error: string }): JSX.Element => { | ||
const hasJson = isJSON(error) | ||
const [activeTab, setActiveTab] = useState(hasJson ? 'json' : 'raw') | ||
|
||
return hasJson ? ( | ||
<div className="pb-3"> | ||
<LemonTabs | ||
activeKey={activeTab} | ||
onChange={setActiveTab} | ||
tabs={[ | ||
hasJson && { | ||
key: 'json', | ||
label: 'JSON', | ||
content: <JSONViewer src={JSON.parse(error)} style={{ whiteSpace: 'pre-wrap' }} />, | ||
}, | ||
{ key: 'raw', label: 'Raw', content: <span className="whitespace-pre-line">{error}</span> }, | ||
]} | ||
/> | ||
</div> | ||
) : ( | ||
<div className="py-3 space-y-1"> | ||
<h3>Example error</h3> | ||
<div className="whitespace-pre-line">{error}</div> | ||
</div> | ||
) | ||
} | ||
|
||
const ErrorPanelContent = ({ samples }: { samples: ErrorClusterSample[] }): JSX.Element => { | ||
return ( | ||
<div className="flex flex-col space-y-2"> | ||
{samples.map((error) => ( | ||
<div key={error.session_id} className="flex justify-between items-center"> | ||
<span>{error.input}</span> | ||
<LemonButton type="secondary" to={urls.replaySingle(error.session_id)}> | ||
Watch recording | ||
</LemonButton> | ||
</div> | ||
))} | ||
</div> | ||
) | ||
function isJSON(str: string): boolean { | ||
try { | ||
JSON.parse(str) | ||
return true | ||
} catch { | ||
return false | ||
} | ||
} | ||
|
||
function parseTitle(error: string): string { | ||
try { | ||
const parsedError = JSON.parse(error) | ||
return parsedError.error || error | ||
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'd still just get the 1st line here since the error is always a stack trace. |
||
} catch { | ||
return error | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could this list be potentially too long to be passed to Postgres?
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.
I think because we're scoping it to team and individual user we should be ok...
Could write a test to see how many session ids before we get an error but it's still not generally released so we should be ok