豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit c0435a2

Browse files
authored
fix: disable usage statistics when CI or CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS env is set (#862)
When CI or CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS env variables are set, we override the set cli args and disable the usage statistics.
1 parent 3e816ae commit c0435a2

File tree

6 files changed

+21
-3
lines changed

6 files changed

+21
-3
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ Google handles this data in accordance with the [Google Privacy Policy](https://
4141

4242
Google's collection of usage statistics for Chrome DevTools MCP is independent from the Chrome browser's usage statistics. Opting out of Chrome metrics does not automatically opt you out of this tool, and vice-versa.
4343

44+
Collection is disabled if CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS or CI env variables are set.
45+
4446
## Requirements
4547

4648
- [Node.js](https://nodejs.org/) v20.19 or a newer [latest maintenance LTS](https://github.com/nodejs/Release#release-schedule) version.
@@ -465,7 +467,7 @@ The Chrome DevTools MCP server supports the following configuration option:
465467
- **Default:** `true`
466468

467469
- **`--usageStatistics`/ `--usage-statistics`**
468-
Set to false to opt-out of usage statistics collection. Google collects usage data to improve the tool, handled under the Google Privacy Policy (https://policies.google.com/privacy). This is independent from Chrome browser metrics.
470+
Set to false to opt-out of usage statistics collection. Google collects usage data to improve the tool, handled under the Google Privacy Policy (https://policies.google.com/privacy). This is independent from Chrome browser metrics. Disabled if CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS or CI env variables are set.
469471
- **Type:** boolean
470472
- **Default:** `true`
471473

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"test:update-snapshots": "npm run build && node scripts/test.mjs --test-update-snapshots",
2323
"prepare": "node --experimental-strip-types scripts/prepare.ts",
2424
"verify-server-json-version": "node --experimental-strip-types scripts/verify-server-json-version.ts",
25-
"eval": "npm run build && node --experimental-strip-types scripts/eval_gemini.ts",
25+
"eval": "npm run build && CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS=true node --experimental-strip-types scripts/eval_gemini.ts",
2626
"count-tokens": "node --experimental-strip-types scripts/count_tokens.ts"
2727
},
2828
"files": [

scripts/test.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ async function runTests(attempt) {
6565
return new Promise(resolve => {
6666
const child = spawn('node', nodeArgs, {
6767
stdio: 'inherit',
68+
env: {
69+
...process.env,
70+
CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS: true,
71+
},
6872
});
6973

7074
child.on('close', code => {

src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ export const cliOptions = {
208208
type: 'boolean',
209209
default: true,
210210
describe:
211-
'Set to false to opt-out of usage statistics collection. Google collects usage data to improve the tool, handled under the Google Privacy Policy (https://policies.google.com/privacy). This is independent from Chrome browser metrics.',
211+
'Set to false to opt-out of usage statistics collection. Google collects usage data to improve the tool, handled under the Google Privacy Policy (https://policies.google.com/privacy). This is independent from Chrome browser metrics. Disabled if CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS or CI env variables are set.',
212212
},
213213
clearcutEndpoint: {
214214
type: 'string',

src/main.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ const VERSION = '0.15.0';
3737
export const args = parseArguments(VERSION);
3838

3939
const logFile = args.logFile ? saveLogsToFile(args.logFile) : undefined;
40+
if (
41+
process.env['CI'] ||
42+
process.env['CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS']
43+
) {
44+
console.error(
45+
"turning off usage statistics. process.env['CI'] || process.env['CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS'] is set.",
46+
);
47+
args.usageStatistics = false;
48+
}
49+
4050
let clearcutLogger: ClearcutLogger | undefined;
4151
if (args.usageStatistics) {
4252
clearcutLogger = new ClearcutLogger({

tests/e2e/telemetry.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ describe('Telemetry E2E', () => {
182182
stdio: ['pipe', 'pipe', 'pipe'],
183183
env: {
184184
...process.env,
185+
CI: undefined,
186+
CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS: undefined,
185187
},
186188
...spawnOptions,
187189
},

0 commit comments

Comments
 (0)