Skip to content

Commit 2504a6f

Browse files
committed
feat(frontend): show user defined attrs in session timeline
closes #1546
1 parent 0dccac0 commit 2504a6f

File tree

1 file changed

+39
-19
lines changed

1 file changed

+39
-19
lines changed

frontend/dashboard/app/components/session_replay_event_details.tsx

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client'
22

33
import { ReactNode } from 'react'
4-
import Image from 'next/image';
4+
import Image from 'next/image'
55
import Link from 'next/link'
66

77
type SessionReplayEventDetailsProps = {
@@ -19,27 +19,47 @@ export default function SessionReplayEventDetails({
1919
}: SessionReplayEventDetailsProps) {
2020

2121
function getBodyFromEventDetails(eventDetails: any): ReactNode {
22-
const entries = Object.entries(eventDetails);
22+
const entries = Object.entries(eventDetails).filter(([key]) => key !== "user_defined_attribute")
23+
const userDefinedAttribute = Object.entries(eventDetails).find(([key]) => key === "user_defined_attribute")
2324
const keyStyle = "text-gray-400 w-1/3"
2425
const valueStyle = "w-2/3 pl-2"
25-
return <div className='flex flex-col p-4 text-white w-full gap-1 text-sm'>
26-
{entries.map(([key, value]): ReactNode => {
27-
if (typeof value === 'object') {
28-
return null
29-
} else if (value === '' || value === null) {
30-
return null
31-
} else if (key === 'stacktrace') {
32-
return <div className='flex flex-col' key={key}>
33-
<p className={keyStyle}>{key}:</p>
34-
<p className='w-full p-1 text-xs rounded-md'>{(value as string).replace(/\n/g, '\n\t')}</p></div>
35-
} else {
36-
return <div className='flex flex-row' key={key}>
37-
<p className={keyStyle}>{key}</p>
38-
<p className={valueStyle}> {value!.toString()}</p>
26+
27+
return (
28+
<div className="flex flex-col p-4 text-white w-full gap-1 text-sm">
29+
{entries.map(([key, value]) => {
30+
if (key === "stacktrace" && typeof value === "string") {
31+
return (
32+
<div className="flex flex-col" key={key}>
33+
<p className={keyStyle}>{key}:</p>
34+
<p className="w-full p-1 text-xs rounded-md">
35+
{value.replace(/\n/g, "\n\t")}
36+
</p>
37+
</div>
38+
)
39+
} else if (value === "" || value === null || typeof value === "object") {
40+
return null // Skip empty or invalid values
41+
} else {
42+
return (
43+
<div className="flex flex-row" key={key}>
44+
<p className={keyStyle}>{key}</p>
45+
<p className={valueStyle}>{value?.toString()}</p>
46+
</div>
47+
)
48+
}
49+
})}
50+
51+
{userDefinedAttribute && (
52+
<div key="user_defined_attribute">
53+
{Object.entries(userDefinedAttribute[1]!).map(([attrKey, attrValue]) => (
54+
<div className="flex flex-row" key={attrKey}>
55+
<p className={keyStyle}>{attrKey}</p>
56+
<p className={valueStyle}>{attrValue?.toString()}</p>
57+
</div>
58+
))}
3959
</div>
40-
}
41-
})}
42-
</div>
60+
)}
61+
</div>
62+
)
4363
}
4464

4565
function getAttachmentsFromEventDetails(): ReactNode {

0 commit comments

Comments
 (0)