t3-code-android-nightly/packages/shared/src/telemetryId.ts
Theo Browne e287582182
feat(server): analytics records a stable install id and who owns each install (#21506)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 00:14:03 -07:00

12 lines
554 B
TypeScript

import { sha256 } from "@noble/hashes/sha2";
import * as Hex from "effect/encoding/Hex";
/**
* Hashes an identifier before it reaches analytics. Clients and the server both
* use it, so one Connect account gives the same owner id on every surface.
*/
export const hashTelemetryId = (value: string): string =>
Hex.encode(sha256(new TextEncoder().encode(value)));
/** True for a `hashTelemetryId` result. The server accepts only this shape from clients. */
export const isTelemetryIdHash = (value: string): boolean => /^[0-9a-f]{64}$/u.test(value);