MCPcopy Create free account
hub / github.com/ChromeDevTools/chrome-devtools-mcp / getInsightOutput

Function getInsightOutput

src/trace-processing/parse.ts:101–135  ·  view source on GitHub ↗
(
  result: TraceResult,
  insightSetId: string,
  insightName: InsightName,
  deviceScope?: DevTools.CrUXManager.DeviceScope | null,
)

Source from the content-addressed store, hash-verified

99export type InsightOutput = {output: string} | {error: string};
100
101export function getInsightOutput(
102 result: TraceResult,
103 insightSetId: string,
104 insightName: InsightName,
105 deviceScope?: DevTools.CrUXManager.DeviceScope | null,
106): InsightOutput {
107 if (!result.insights) {
108 return {
109 error: 'No Performance insights are available for this trace.',
110 };
111 }
112
113 const insightSet = result.insights.get(insightSetId);
114 if (!insightSet) {
115 return {
116 error:
117 'No Performance Insights for the given insight set id. Only use ids given in the "Available insight sets" list.',
118 };
119 }
120
121 const matchingInsight =
122 insightName in insightSet.model ? insightSet.model[insightName] : null;
123 if (!matchingInsight) {
124 return {
125 error: `No Insight with the name ${insightName} found. Double check the name you provided is accurate and try again.`,
126 };
127 }
128
129 const formatter = new DevTools.PerformanceInsightFormatter(
130 DevTools.AgentFocus.fromParsedTrace(result.parsedTrace),
131 matchingInsight,
132 deviceScope,
133 );
134 return {output: formatter.formatInsight()};
135}

Callers 1

formatMethod · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected