feat: implement app-side telemetry sender

Add the shared telemetry sender, wire the CLI/server emit points,
and cover the config and completion behavior with tests.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
dotta 2026-03-31 08:08:18 -05:00
parent ca5659f734
commit 34044cdfce
29 changed files with 670 additions and 5 deletions

View file

@ -0,0 +1,25 @@
import type { TelemetryConfig } from "./types.js";
const CI_ENV_VARS = ["CI", "CONTINUOUS_INTEGRATION", "BUILD_NUMBER", "GITHUB_ACTIONS", "GITLAB_CI"];
function isCI(): boolean {
return CI_ENV_VARS.some((key) => process.env[key] === "true" || process.env[key] === "1");
}
export function resolveTelemetryConfig(fileConfig?: { enabled?: boolean }): TelemetryConfig {
if (process.env.PAPERCLIP_TELEMETRY_DISABLED === "1") {
return { enabled: false };
}
if (process.env.DO_NOT_TRACK === "1") {
return { enabled: false };
}
if (isCI()) {
return { enabled: false };
}
if (fileConfig?.enabled === false) {
return { enabled: false };
}
const endpoint = process.env.PAPERCLIP_TELEMETRY_ENDPOINT || undefined;
return { enabled: true, endpoint };
}