File tree Expand file tree Collapse file tree 3 files changed +16
-17
lines changed
Expand file tree Collapse file tree 3 files changed +16
-17
lines changed Original file line number Diff line number Diff line change @@ -121,12 +121,17 @@ export const stopTrace = defineTool({
121121export const analyzeInsight = defineTool ( {
122122 name : 'performance_analyze_insight' ,
123123 description :
124- 'Provides more detailed information on a specific Performance Insight that was highlighted in the results of a trace recording.' ,
124+ 'Provides more detailed information on a specific Performance Insight of an insight set that was highlighted in the results of a trace recording.' ,
125125 annotations : {
126126 category : ToolCategory . PERFORMANCE ,
127127 readOnlyHint : true ,
128128 } ,
129129 schema : {
130+ insightSetId : zod
131+ . string ( )
132+ . describe (
133+ 'The id for the specific insight set. Only use the ids given in the "Available insight sets" list.' ,
134+ ) ,
130135 insightName : zod
131136 . string ( )
132137 . describe (
@@ -144,6 +149,7 @@ export const analyzeInsight = defineTool({
144149
145150 const insightOutput = getInsightOutput (
146151 lastRecording ,
152+ request . params . insightSetId ,
147153 request . params . insightName as InsightName ,
148154 ) ;
149155 if ( 'error' in insightOutput ) {
Original file line number Diff line number Diff line change @@ -97,6 +97,7 @@ export type InsightOutput = {output: string} | {error: string};
9797
9898export function getInsightOutput (
9999 result : TraceResult ,
100+ insightSetId : string ,
100101 insightName : InsightName ,
101102) : InsightOutput {
102103 if ( ! result . insights ) {
@@ -105,27 +106,16 @@ export function getInsightOutput(
105106 } ;
106107 }
107108
108- // Currently, we do not support inspecting traces with multiple navigations. We either:
109- // 1. Find Insights from the first navigation (common case: user records a trace with a page reload to test load performance)
110- // 2. Fall back to finding Insights not associated with a navigation (common case: user tests an interaction without a page load).
111- const mainNavigationId =
112- result . parsedTrace . data . Meta . mainFrameNavigations . at ( 0 ) ?. args . data
113- ?. navigationId ;
114-
115- const insightsForNav = result . insights . get (
116- mainNavigationId ?? TraceEngine . Types . Events . NO_NAVIGATION ,
117- ) ;
118-
119- if ( ! insightsForNav ) {
109+ const insightSet = result . insights . get ( insightSetId ) ;
110+ if ( ! insightSet ) {
120111 return {
121- error : 'No Performance Insights for this trace.' ,
112+ error :
113+ 'No Performance Insights for the given insight set id. Only use ids given in the "Available insight sets" list.' ,
122114 } ;
123115 }
124116
125117 const matchingInsight =
126- insightName in insightsForNav . model
127- ? insightsForNav . model [ insightName ]
128- : null ;
118+ insightName in insightSet . model ? insightSet . model [ insightName ] : null ;
129119 if ( ! matchingInsight ) {
130120 return {
131121 error : `No Insight with the name ${ insightName } found. Double check the name you provided is accurate and try again.` ,
Original file line number Diff line number Diff line change @@ -158,6 +158,7 @@ describe('performance', () => {
158158 await analyzeInsight . handler (
159159 {
160160 params : {
161+ insightSetId : '8463DF94CD61B265B664E7F768183DE3' ,
161162 insightName : 'LCPBreakdown' ,
162163 } ,
163164 } ,
@@ -178,6 +179,7 @@ describe('performance', () => {
178179 await analyzeInsight . handler (
179180 {
180181 params : {
182+ insightSetId : '8463DF94CD61B265B664E7F768183DE3' ,
181183 insightName : 'MadeUpInsightName' ,
182184 } ,
183185 } ,
@@ -197,6 +199,7 @@ describe('performance', () => {
197199 await analyzeInsight . handler (
198200 {
199201 params : {
202+ insightSetId : '8463DF94CD61B265B664E7F768183DE3' ,
200203 insightName : 'LCPBreakdown' ,
201204 } ,
202205 } ,
You can’t perform that action at this time.
0 commit comments