fix(cli): make telemetry opt-out durable (#2852)

* fix(cli): make telemetry opt-out durable

* fix(cli): make telemetry status trustworthy
This commit is contained in:
Miguel Ángel
2026-07-28 20:35:54 +02:00
committed by GitHub
parent c691869e22
commit 880021411d
13 changed files with 491 additions and 52 deletions
+12 -3
View File
@@ -56,10 +56,19 @@ describe("studio client shouldTrack", () => {
expect(shouldTrack()).toBe(false);
});
it("returns false when VITE_HYPERFRAMES_NO_TELEMETRY='true'", async () => {
setNoTelemetry("true");
it.each(["true", "TRUE", " yes ", "on"])(
"returns false when VITE_HYPERFRAMES_NO_TELEMETRY=%j",
async (value) => {
setNoTelemetry(value);
const shouldTrack = await loadShouldTrack();
expect(shouldTrack()).toBe(false);
},
);
it("does not opt out for an explicit false value", async () => {
setNoTelemetry("false");
const shouldTrack = await loadShouldTrack();
expect(shouldTrack()).toBe(false);
expect(shouldTrack()).toBe(true);
});
it("returns false in vite dev mode", async () => {
+3 -2
View File
@@ -34,12 +34,13 @@ function isApiKeyConfigured(): boolean {
// VITE_HYPERFRAMES_NO_TELEMETRY mirrors the CLI's HYPERFRAMES_NO_TELEMETRY=1
// opt-out so HeyGen's own dev/CI builds can suppress telemetry from the studio
// bundle the same way. Vite injects it at build time. Accepts "1" or "true".
// bundle the same way. Vite injects it at build time. Match the CLI's
// affirmative privacy-control spellings.
// `import.meta.env` may be undefined in non-Vite bundlers (Next.js Turbopack).
function isBuildTimeOptOut(): boolean {
try {
const v = import.meta.env.VITE_HYPERFRAMES_NO_TELEMETRY as string | undefined;
return v === "1" || v === "true";
return v !== undefined && ["1", "true", "yes", "on"].includes(v.trim().toLowerCase());
} catch {
return false;
}