fix(studio): correct save failure telemetry (#3499)

This commit is contained in:
Miguel Ángel
2026-08-30 00:24:46 -04:00
committed by GitHub
parent 0fd70b1d21
commit 28be8dddfa
8 changed files with 248 additions and 31 deletions
+12 -2
View File
@@ -48,8 +48,18 @@ export async function studioExpectedFileVersion(
return versions.get(path);
}
function createStudioWriteToken(): string {
return globalThis.crypto.randomUUID();
export function createStudioWriteToken(): string {
const webCrypto = globalThis.crypto;
if (typeof webCrypto?.randomUUID === "function") return webCrypto.randomUUID();
if (typeof webCrypto?.getRandomValues !== "function") {
throw new Error("Web Crypto getRandomValues is required for Studio write identity");
}
const bytes = webCrypto.getRandomValues(new Uint8Array(16));
bytes[6] = (bytes[6] & 0x0f) | 0x40;
bytes[8] = (bytes[8] & 0x3f) | 0x80;
const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
}
/**