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

Commit 4e0faa8

Browse files
committed
chore: add usage statistics CLI flag
1 parent a23c6ba commit 4e0faa8

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

src/cli.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,14 @@ export const cliOptions = {
178178
default: true,
179179
describe: 'Set to false to exclude tools related to network.',
180180
},
181+
usageStatistics: {
182+
type: 'boolean',
183+
// Marked as `false` until the feature is ready to be enabled by default.
184+
default: false,
185+
hidden: true,
186+
describe:
187+
'Set to false to opt-out of usage statistics collection.',
188+
},
181189
} satisfies Record<string, YargsOptions>;
182190

183191
export function parseArguments(version: string, argv = process.argv) {

src/main.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ const logDisclaimers = () => {
9898
debug, and modify any data in the browser or DevTools.
9999
Avoid sharing sensitive or personal information that you do not want to share with MCP clients.`,
100100
);
101+
102+
if (args.usageStatistics) {
103+
console.error(
104+
`
105+
Google collects usage statistics to improve Chrome DevTools MCP. To opt-out, run with --no-usage-statistics.
106+
For more details, visit: https://github.com/ChromeDevTools/chrome-devtools-mcp#usage-statistics`,
107+
);
108+
}
101109
};
102110

103111
const toolMutex = new Mutex();

tests/cli.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ describe('cli args parsing', () => {
1919
categoryNetwork: true,
2020
'auto-connect': undefined,
2121
autoConnect: undefined,
22+
'usage-statistics': false,
23+
usageStatistics: false,
2224
};
2325

2426
it('parses with default args', async () => {
@@ -222,4 +224,26 @@ describe('cli args parsing', () => {
222224
autoConnect: true,
223225
});
224226
});
227+
228+
it('parses usage statistics flag', async () => {
229+
// Test default (should be false)
230+
const defaultArgs = parseArguments('1.0.0', ['node', 'main.js']);
231+
assert.strictEqual(defaultArgs.usageStatistics, false);
232+
233+
// Test enabling it
234+
const enabledArgs = parseArguments('1.0.0', [
235+
'node',
236+
'main.js',
237+
'--usage-statistics',
238+
]);
239+
assert.strictEqual(enabledArgs.usageStatistics, true);
240+
241+
// Test disabling it
242+
const disabledArgs = parseArguments('1.0.0', [
243+
'node',
244+
'main.js',
245+
'--no-usage-statistics',
246+
]);
247+
assert.strictEqual(disabledArgs.usageStatistics, false);
248+
});
225249
});

0 commit comments

Comments
 (0)