@@ -454,6 +454,45 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
454454 this . #setActiveInsight( { name, navigationId, createOverlayFn} ) ;
455455 } ) ;
456456
457+ // Make a proper event for this afterwards.
458+ // Custom event to show third-party scripts as overlay. Extracted from ThirdParties.ts
459+ // @ts -ignore
460+ document . getElementById ( '-blink-dev-tools' ) ?. addEventListener ( 'showthirdparty' , ( event : CustomEvent ) => {
461+ const { navigationId} = event . detail ;
462+ this . #setActiveInsight( {
463+ name : 'third-parties' ,
464+ navigationId,
465+ createOverlayFn : ( ) => {
466+ // We should have the current active trace index on the model loaded
467+ const traceInsightsData = this . #traceEngineModel. traceInsights ( this . #activeTraceIndex( ) || 0 ) ;
468+ const insight = TimelineInsights . ThirdParties . getThirdPartiesInsight ( traceInsightsData , navigationId ) ;
469+ if ( ! insight ) {
470+ return [ ] ;
471+ }
472+
473+ const overlays : Overlays . Overlays . TimelineOverlay [ ] = [ ] ;
474+ for ( const [ entity , requests ] of insight . requestsByEntity ) {
475+ if ( entity === insight . firstPartyEntity ) {
476+ continue ;
477+ }
478+
479+ for ( const request of requests ) {
480+ // The overlay entry can be used to highlight any trace entry, including network track entries.
481+ // This function is extracted from the ThirdParties overlay component, since it is not accessible
482+ // from outside the component.
483+ overlays . push ( {
484+ type : 'ENTRY_OUTLINE' ,
485+ entry : request ,
486+ outlineReason : 'INFO' ,
487+ } ) ;
488+ }
489+ }
490+
491+ return overlays ;
492+ } ,
493+ } ) ;
494+ } ) ;
495+
457496 this . #sideBar. contentElement . addEventListener ( TimelineComponents . Sidebar . EventReferenceClick . eventName , event => {
458497 const { metricEvent} = event ;
459498 this . flameChart . setSelectionAndReveal ( TimelineSelection . fromTraceEvent ( metricEvent ) ) ;
0 commit comments