build: Add telemetry compiled output
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
30
dist/telemetry.js
vendored
Normal file
30
dist/telemetry.js
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Telemetry for compressed tools usage tracking
|
||||
* Logs to ~/.local/share/mcp/compressed-tools.jsonl
|
||||
*/
|
||||
import { appendFileSync, mkdirSync, existsSync } from "fs";
|
||||
import { homedir } from "os";
|
||||
import { join } from "path";
|
||||
const LOG_DIR = join(homedir(), ".local", "share", "mcp");
|
||||
const LOG_FILE = join(LOG_DIR, "compressed-tools.jsonl");
|
||||
// Ensure log directory exists
|
||||
if (!existsSync(LOG_DIR)) {
|
||||
mkdirSync(LOG_DIR, { recursive: true });
|
||||
}
|
||||
export function logTelemetry(event) {
|
||||
const entry = {
|
||||
timestamp: new Date().toISOString(),
|
||||
...event,
|
||||
};
|
||||
try {
|
||||
appendFileSync(LOG_FILE, JSON.stringify(entry) + "\n");
|
||||
}
|
||||
catch {
|
||||
// Silently fail - telemetry should never break the tool
|
||||
}
|
||||
}
|
||||
export function calculateCompressionRatio(original, compressed) {
|
||||
if (original === 0)
|
||||
return 0;
|
||||
return Math.round((1 - compressed / original) * 100 * 10) / 10;
|
||||
}
|
||||
Reference in New Issue
Block a user