Skip to content

Commit e8c9192

Browse files
authored
chore: add usage statistics CLI flag (#757)
This PR initiates the implementation of clearcut telemetry. It introduces the CLI configuration required to opt-out of usage statistics, along with the necessary transparency disclaimers for the user. It's hidden by default during development & while we get the launch approvals. **Implementation Roadmap:** This is the first in a series of PRs designed to implement the telemetry system: 1. **CLI & Opt-out Mechanism (This PR):** * Adds the `--usage-statistics` flag (hidden, default `false` for now). * Adds transparency logging to specify data collection when enabled. 2. **Logger Scaffolding & Integration:** * Implement `ClearcutLogger` and integrate it into `main.ts`. * Add hooks for `logServerStart` and `logToolInvocation`. * Introduce `ClearcutSender` as an abstraction layer for transport logic. 3. **Persistence Layer:** * Implement local state management to reliably track "First Time Installation" and "Daily Active" metrics. * Implement sending the daily active and first time installation event based on this local state. 4. **Watchdog Process Architecture:** * Move `ClearcutSender` execution to a dedicated watchdog process to ensure reliable event transmission even during abrupt server shutdowns. 5. **Transport, Batching & Retries:** * Finalize `ClearcutSender` with actual HTTP transport logic, including event batching, respecting `next_request_wait_millis` and retries.
1 parent 3fcca02 commit e8c9192

3 files changed

Lines changed: 39 additions & 0 deletions

File tree

src/cli.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,13 @@ export const cliOptions = {
193193
default: true,
194194
describe: 'Set to false to exclude tools related to network.',
195195
},
196+
usageStatistics: {
197+
type: 'boolean',
198+
// Marked as `false` until the feature is ready to be enabled by default.
199+
default: false,
200+
hidden: true,
201+
describe: 'Set to false to opt-out of usage statistics collection.',
202+
},
196203
} satisfies Record<string, YargsOptions>;
197204

198205
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
@@ -102,6 +102,14 @@ const logDisclaimers = () => {
102102
debug, and modify any data in the browser or DevTools.
103103
Avoid sharing sensitive or personal information that you do not want to share with MCP clients.`,
104104
);
105+
106+
if (args.usageStatistics) {
107+
console.error(
108+
`
109+
Google collects usage statistics to improve Chrome DevTools MCP. To opt-out, run with --no-usage-statistics.
110+
For more details, visit: https://github.com/ChromeDevTools/chrome-devtools-mcp#usage-statistics`,
111+
);
112+
}
105113
};
106114

107115
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 () => {
@@ -246,4 +248,26 @@ describe('cli args parsing', () => {
246248
autoConnect: true,
247249
});
248250
});
251+
252+
it('parses usage statistics flag', async () => {
253+
// Test default (should be false)
254+
const defaultArgs = parseArguments('1.0.0', ['node', 'main.js']);
255+
assert.strictEqual(defaultArgs.usageStatistics, false);
256+
257+
// Test enabling it
258+
const enabledArgs = parseArguments('1.0.0', [
259+
'node',
260+
'main.js',
261+
'--usage-statistics',
262+
]);
263+
assert.strictEqual(enabledArgs.usageStatistics, true);
264+
265+
// Test disabling it
266+
const disabledArgs = parseArguments('1.0.0', [
267+
'node',
268+
'main.js',
269+
'--no-usage-statistics',
270+
]);
271+
assert.strictEqual(disabledArgs.usageStatistics, false);
272+
});
249273
});

0 commit comments

Comments
 (0)