ahoy.js icon indicating copy to clipboard operation
ahoy.js copied to clipboard

Improve generation of UUIDs

Open cover opened this issue 2 years ago • 0 comments

Hey Andrew (thank you for Ahoy!), I was going through the code and noticed that it uses Math.random to generate the UUID, which is not recommended anymore even by the linked StackOverflow answer.

Here a quick update to use the crypto.randomUUID (if supported by the browser), otherwise falling back to the current recommended SO linked answer in the comment that now uses crypto.getRandomValues

On non-https pages the randomUUID won't be present, so it'll also fallback (getRandomValues works on http).

cover avatar Nov 21 '23 22:11 cover