1- import { useEffect , useState } from " react" ;
2- import { useParams } from " react-router" ;
3- import { apiRoute } from " ./util" ;
4- import { ApiEventsPage , EventData , convertApiEventToEventData } from " ./types" ;
5- import { Box , Alert } from " @launchpad-ui/core" ;
6- import { Heading , Text , ProgressBar , Button } from " @launchpad-ui/components" ;
7- import { Icon } from " @launchpad-ui/icons" ;
8- import EventsTable from " ./EventsTable" ;
9- import { TextField , Label , Input } from " @launchpad-ui/components" ;
10- import { Fragment } from " react" ;
1+ import { useEffect , useState } from ' react' ;
2+ import { useParams } from ' react-router' ;
3+ import { apiRoute } from ' ./util' ;
4+ import { ApiEventsPage , EventData , convertApiEventToEventData } from ' ./types' ;
5+ import { Box , Alert } from ' @launchpad-ui/core' ;
6+ import { Heading , Text , ProgressBar , Button } from ' @launchpad-ui/components' ;
7+ import { Icon } from ' @launchpad-ui/icons' ;
8+ import EventsTable from ' ./EventsTable' ;
9+ import { TextField , Label , Input } from ' @launchpad-ui/components' ;
10+ import { Fragment } from ' react' ;
1111
1212const DebugSessionEventsPage = ( ) => {
1313 const { debugSessionKey } = useParams < { debugSessionKey : string } > ( ) ;
@@ -18,27 +18,36 @@ const DebugSessionEventsPage = () => {
1818
1919 const fetchEvents = async ( ) => {
2020 if ( ! debugSessionKey ) {
21- setError ( " Debug session key is required" ) ;
21+ setError ( ' Debug session key is required' ) ;
2222 setLoading ( false ) ;
2323 return ;
2424 }
2525
2626 try {
2727 setLoading ( true ) ;
2828 setError ( null ) ;
29-
30- const response = await fetch ( apiRoute ( `/dev/debug-sessions/${ encodeURIComponent ( debugSessionKey ) } /events?limit=1000` ) ) ;
31-
29+
30+ const response = await fetch (
31+ apiRoute (
32+ `/dev/debug-sessions/${ encodeURIComponent ( debugSessionKey ) } /events?limit=1000` ,
33+ ) ,
34+ ) ;
35+
3236 if ( ! response . ok ) {
33- throw new Error ( `Failed to fetch events: ${ response . status } ${ response . statusText } ` ) ;
37+ throw new Error (
38+ `Failed to fetch events: ${ response . status } ${ response . statusText } ` ,
39+ ) ;
3440 }
35-
41+
3642 const data : ApiEventsPage = await response . json ( ) ;
37- const convertedEvents = data . events ?. map ( convertApiEventToEventData ) || [ ] ;
43+ const convertedEvents =
44+ data . events ?. map ( convertApiEventToEventData ) || [ ] ;
3845 setEvents ( convertedEvents ) ;
3946 setDisplayedEvents ( convertedEvents ) ;
4047 } catch ( err ) {
41- setError ( err instanceof Error ? err . message : "An unknown error occurred" ) ;
48+ setError (
49+ err instanceof Error ? err . message : 'An unknown error occurred' ,
50+ ) ;
4251 } finally {
4352 setLoading ( false ) ;
4453 }
@@ -49,26 +58,32 @@ const DebugSessionEventsPage = () => {
4958 } , [ debugSessionKey ] ) ;
5059
5160 const handleSearchChange = ( value : string ) => {
52- setDisplayedEvents ( events . filter ( event => {
53- let search = '' ;
54-
55- const extractValues = ( obj : unknown ) : string [ ] => {
56- if ( obj === null || obj === undefined ) return [ ] ;
57- if ( typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' ) {
58- return [ String ( obj ) ] ;
59- }
60- if ( Array . isArray ( obj ) ) {
61- return obj . flatMap ( item => extractValues ( item ) ) ;
62- }
63- if ( typeof obj === 'object' ) {
64- return Object . values ( obj ) . flatMap ( value => extractValues ( value ) ) ;
65- }
66- return [ ] ;
67- } ;
68- search = extractValues ( event ) . join ( ' ' ) ;
69-
70- return search . toLowerCase ( ) . includes ( value . toLowerCase ( ) ) ;
71- } ) )
61+ setDisplayedEvents (
62+ events . filter ( ( event ) => {
63+ let search = '' ;
64+
65+ const extractValues = ( obj : unknown ) : string [ ] => {
66+ if ( obj === null || obj === undefined ) return [ ] ;
67+ if (
68+ typeof obj === 'string' ||
69+ typeof obj === 'number' ||
70+ typeof obj === 'boolean'
71+ ) {
72+ return [ String ( obj ) ] ;
73+ }
74+ if ( Array . isArray ( obj ) ) {
75+ return obj . flatMap ( ( item ) => extractValues ( item ) ) ;
76+ }
77+ if ( typeof obj === 'object' ) {
78+ return Object . values ( obj ) . flatMap ( ( value ) => extractValues ( value ) ) ;
79+ }
80+ return [ ] ;
81+ } ;
82+ search = extractValues ( event ) . join ( ' ' ) ;
83+
84+ return search . toLowerCase ( ) . includes ( value . toLowerCase ( ) ) ;
85+ } ) ,
86+ ) ;
7287 } ;
7388
7489 if ( loading ) {
@@ -113,12 +128,19 @@ const DebugSessionEventsPage = () => {
113128
114129 return (
115130 < Box padding = "2rem" width = "100%" >
116-
117- < Box display = "flex" justifyContent = "space-between" alignItems = "center" marginBottom = "1rem" >
131+ < Box
132+ display = "flex"
133+ justifyContent = "space-between"
134+ alignItems = "center"
135+ marginBottom = "1rem"
136+ >
118137 < Box >
119138 < Heading > Debug Session Events</ Heading >
120139 < Box marginTop = "0.5rem" >
121- < Text color = "var(--lp-color-text-ui-secondary)" style = { { fontFamily : "monospace" } } >
140+ < Text
141+ color = "var(--lp-color-text-ui-secondary)"
142+ style = { { fontFamily : 'monospace' } }
143+ >
122144 Session: { debugSessionKey }
123145 </ Text >
124146 </ Box >
@@ -127,9 +149,7 @@ const DebugSessionEventsPage = () => {
127149
128150 < TextField onChange = { handleSearchChange } name = "debug-session-search" >
129151 < Fragment key = ".0" >
130- < Label >
131- Search
132- </ Label >
152+ < Label > Search</ Label >
133153 < Input placeholder = "Try a type like 'summary', or an email address, or similar" />
134154 </ Fragment >
135155 </ TextField >
0 commit comments