Use getRandomValues for wider browser support

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-04-15 18:22:33 +04:00
parent c887e3497f
commit 266446be9c

View File

@@ -26,7 +26,9 @@ export function getOrCreateVisitorId(bannerId: string): string {
// localStorage unavailable
}
const id = crypto.randomUUID();
const array = new Uint8Array(16);
crypto.getRandomValues(array);
const id = Array.from(array, (b) => b.toString(16).padStart(2, "0")).join("");
try {
localStorage.setItem(key, id);