ahoy.js
ahoy.js copied to clipboard
Improve generation of UUIDs
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).