MCPcopy Create free account
hub / github.com/ChromeDevTools/chrome-devtools-mcp / writeToolCallMetricsConfig

Function writeToolCallMetricsConfig

scripts/update_metrics.ts:31–68  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29}
30
31function writeToolCallMetricsConfig() {
32 const outputPath = path.resolve('src/telemetry/tool_call_metrics.json');
33
34 const dir = path.dirname(outputPath);
35 if (!fs.existsSync(dir)) {
36 throw new Error(`Error: Directory ${dir} does not exist.`);
37 }
38
39 const allTools = createTools(
40 ServerConfig.applyDefaults({}, {suppressUsageStatisticsNotice: true}),
41 );
42
43 if (!haveUniqueNames(allTools)) {
44 throw new Error('Error: Duplicate tool names found.');
45 }
46
47 let existingMetrics: ToolMetric[] = [];
48 if (fs.existsSync(outputPath)) {
49 try {
50 existingMetrics = JSON.parse(
51 fs.readFileSync(outputPath, 'utf8'),
52 ) as ToolMetric[];
53 } catch {
54 console.warn(
55 `Warning: Failed to parse existing metrics from ${outputPath}. Starting fresh.`,
56 );
57 }
58 }
59
60 const newMetrics = generateToolMetrics(allTools);
61 const mergedMetrics = applyToExistingMetrics(existingMetrics, newMetrics);
62
63 fs.writeFileSync(outputPath, JSON.stringify(mergedMetrics, null, 2) + '\n');
64
65 console.log(
66 `Successfully wrote ${mergedMetrics.length} total tool metrics (including deprecated ones) to ${outputPath}`,
67 );
68}
69
70function writeFlagUsageMetrics() {
71 const outputPath = path.resolve('src/telemetry/flag_usage_metrics.json');

Callers 1

mainFunction · 0.85

Calls 7

createToolsFunction · 0.85
haveUniqueNamesFunction · 0.85
generateToolMetricsFunction · 0.85
applyToExistingMetricsFunction · 0.85
resolveMethod · 0.80
applyDefaultsMethod · 0.80
parseMethod · 0.80

Tested by

no test coverage detected