11import { use , useCallback , useMemo } from 'react' ;
22import isString from 'lodash/isString' ;
33import pickBy from 'lodash/pickBy' ;
4- import { SourceKind , TSource } from '@hyperdx/common-utils/dist/types' ;
4+ import {
5+ isLogSource ,
6+ SourceKind ,
7+ TSource ,
8+ } from '@hyperdx/common-utils/dist/types' ;
59import { Accordion , Box , Flex , Text } from '@mantine/core' ;
610
711import { WithClause } from '@/hooks/useRowWhere' ;
812import { getEventBody } from '@/source' ;
13+ import { getBrowserEventKind , isBrowserEventRow } from '@/utils/browserEvents' ;
914import { getHighlightedAttributesFromData } from '@/utils/highlightedAttributes' ;
1015import { resolveRowTimestampAnchor } from '@/utils/rowTimestamps' ;
1116import { getRequestPanelTitle } from '@/utils/rpcSpanAttributes' ;
1217import { isSet } from '@/utils/spanAttributeReaders' ;
1318
19+ import { BrowserEventSubpanel } from './BrowserEventSubpanel' ;
1420import {
1521 getJSONColumnNames ,
1622 getMapColumnNames ,
@@ -147,6 +153,24 @@ export function RowOverviewPanel({
147153 [ flattenedEventAttributes ] ,
148154 ) ;
149155
156+ // Only log sources select the event name, and gating here keeps every trace
157+ // row out whatever attributes it carries.
158+ const { browserEventKind, isBrowserRow } = useMemo ( ( ) => {
159+ if ( ! isLogSource ( source ) ) {
160+ return { browserEventKind : undefined , isBrowserRow : false } ;
161+ }
162+
163+ const row = {
164+ eventName : firstRow ?. __hdx_event_name ,
165+ attributes : flattenedEventAttributes ,
166+ } ;
167+
168+ return {
169+ browserEventKind : getBrowserEventKind ( row ) ,
170+ isBrowserRow : isBrowserEventRow ( row ) ,
171+ } ;
172+ } , [ source , firstRow ?. __hdx_event_name , flattenedEventAttributes ] ) ;
173+
150174 const exceptionAttributes = useMemo ( ( ) => {
151175 const spanEventAttributes = firstRow ?. __hdx_events_exception_attributes ;
152176 if (
@@ -249,6 +273,7 @@ export function RowOverviewPanel({
249273 // In that case suppress the body paper entirely instead of
250274 // rendering an "[Empty]" placeholder.
251275 bodyConfigured = { mainContentColumn !== undefined }
276+ hideEmptyBody = { isBrowserRow }
252277 severityText = { firstRow ?. __hdx_severity_text }
253278 rowData = { firstRow }
254279 />
@@ -258,6 +283,7 @@ export function RowOverviewPanel({
258283 mt = "sm"
259284 defaultValue = { [
260285 'exception' ,
286+ 'browserEvent' ,
261287 'spanEvents' ,
262288 'spanLinks' ,
263289 'linkedFrom' ,
@@ -289,7 +315,29 @@ export function RowOverviewPanel({
289315 </ Accordion . Item >
290316 ) }
291317
292- { requestPanelTitle != null && (
318+ { browserEventKind != null && (
319+ < Accordion . Item
320+ value = "browserEvent"
321+ data-testid = "browser-event-section"
322+ >
323+ < Accordion . Control >
324+ < Text size = "sm" ps = { contentPx } >
325+ Browser event
326+ </ Text >
327+ </ Accordion . Control >
328+ < Accordion . Panel >
329+ < Box px = { contentPx } >
330+ < BrowserEventSubpanel
331+ kind = { browserEventKind }
332+ attributes = { flattenedEventAttributes }
333+ body = { mainContent }
334+ />
335+ </ Box >
336+ </ Accordion . Panel >
337+ </ Accordion . Item >
338+ ) }
339+
340+ { requestPanelTitle != null && browserEventKind == null && (
293341 < Accordion . Item value = "network" >
294342 < Accordion . Control >
295343 < Text size = "sm" ps = { contentPx } >
0 commit comments