-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathupdate_flag_usage_metrics.ts
More file actions
36 lines (27 loc) · 976 Bytes
/
update_flag_usage_metrics.ts
File metadata and controls
36 lines (27 loc) · 976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* @license
* Copyright 2026 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import * as fs from 'node:fs';
import * as path from 'node:path';
import {cliOptions} from '../build/src/bin/chrome-devtools-mcp-cli-options.js';
import {
getPossibleFlagMetrics,
type FlagMetric,
} from '../build/src/telemetry/flagUtils.js';
function writeFlagUsageMetrics() {
const outputPath = path.resolve('src/telemetry/flag_usage_metrics.json');
const dir = path.dirname(outputPath);
if (!fs.existsSync(dir)) {
throw new Error(`Error: Directory ${dir} does not exist.`);
}
const metrics = getPossibleFlagMetrics(cliOptions);
// Sort metrics by name for deterministic output
metrics.sort((a: FlagMetric, b: FlagMetric) => a.name.localeCompare(b.name));
fs.writeFileSync(outputPath, JSON.stringify(metrics, null, 2) + '\n');
console.log(
`Successfully wrote ${metrics.length} flag usage metrics to ${outputPath}`,
);
}
writeFlagUsageMetrics();