Skip to content

Commit c939456

Browse files
authored
fix: define tracing categories (#21)
Drive-by: we do not need to download latest anymore. Drive-by: report success if no insights were found (examples: example.com)
1 parent a76b23d commit c939456

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
"generate-docs": "npm run build && node --experimental-strip-types scripts/generate-docs.ts",
1515
"start": "npm run build && node build/src/index.js",
1616
"start-debug": "DEBUG=mcp:* DEBUG_COLORS=false npm run build && node build/src/index.js",
17-
"test": "npm run build && npx puppeteer browsers install chrome@latest && node --test-reporter spec --test-force-exit --test 'build/tests/**/*.test.js'",
18-
"test:only": "npm run build && npx puppeteer browsers install chrome@latest && node --test-reporter spec --test-force-exit --test --test-only 'build/tests/**/*.test.js'",
19-
"test:only:no-build": "npx puppeteer browsers install chrome@latest && node --test-reporter spec --test-force-exit --test --test-only 'build/tests/**/*.test.js'",
17+
"test": "npm run build && node --test-reporter spec --test-force-exit --test 'build/tests/**/*.test.js'",
18+
"test:only": "npm run build && node --test-reporter spec --test-force-exit --test --test-only 'build/tests/**/*.test.js'",
19+
"test:only:no-build": "node --test-reporter spec --test-force-exit --test --test-only 'build/tests/**/*.test.js'",
2020
"prepare": "node --experimental-strip-types scripts/prepare.ts"
2121
},
2222
"files": [

src/tools/performance.ts

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,31 @@ export const startTrace = defineTool({
4949
});
5050
}
5151

52-
// TODO(jacktfranklin): determine the exact list of categories and
53-
// align with DevTools
54-
await page.tracing.start();
52+
// This panel may be opened with trace data recorded in other tools.
53+
// Keep in sync with the categories arrays in:
54+
// https://source.chromium.org/chromium/chromium/src/+/main:third_party/devtools-frontend/src/front_end/panels/timeline/TimelineController.ts
55+
// https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/gather/gatherers/trace.js
56+
const categories = [
57+
'-*',
58+
'blink.console',
59+
'blink.user_timing',
60+
'devtools.timeline',
61+
'disabled-by-default-devtools.screenshot',
62+
'disabled-by-default-devtools.timeline',
63+
'disabled-by-default-devtools.timeline.invalidationTracking',
64+
'disabled-by-default-devtools.timeline.frame',
65+
'disabled-by-default-devtools.timeline.stack',
66+
'disabled-by-default-v8.cpu_profiler',
67+
'disabled-by-default-v8.cpu_profiler.hires',
68+
'latencyInfo',
69+
'loading',
70+
'disabled-by-default-lighthouse',
71+
'v8.execute',
72+
'v8',
73+
];
74+
await page.tracing.start({
75+
categories,
76+
});
5577

5678
if (request.params.reload) {
5779
await page.goto(pageUrlForTracing, {
@@ -98,8 +120,14 @@ async function stopTracingAndAppendOutput(
98120
response.appendResponseLine('The performance trace has been stopped.');
99121
if (result) {
100122
const insightText = insightOutput(result);
101-
response.appendResponseLine('Insights with performance opportunities:');
102-
response.appendResponseLine(insightText);
123+
if (insightText) {
124+
response.appendResponseLine('Insights with performance opportunities:');
125+
response.appendResponseLine(insightText);
126+
} else {
127+
response.appendResponseLine(
128+
'No insights has been found. The performance looks good!',
129+
);
130+
}
103131
}
104132
} catch (e) {
105133
logger(

0 commit comments

Comments
 (0)