feat: emit sampled mcp telemetry

This commit is contained in:
Andrey Avtomonov 2026-05-22 16:01:13 +02:00
parent 9956ce398f
commit c6f3634fb3
6 changed files with 126 additions and 2 deletions

View file

@ -26,6 +26,17 @@ type TelemetryEventFields<Name extends TelemetryEventName> = Omit<
>;
const emittedProjectSnapshots = new Set<string>();
const MCP_SAMPLE_RATE = 0.1 as const;
let mcpSampled: boolean | undefined;
export function shouldEmitMcpTelemetry(): boolean {
mcpSampled ??= Math.random() < MCP_SAMPLE_RATE;
return mcpSampled;
}
export function mcpTelemetrySampleRate(): 0.1 {
return MCP_SAMPLE_RATE;
}
async function emitInstallFirstRunIfNeeded(input: {
identity: Awaited<ReturnType<typeof loadTelemetryIdentity>>;