Generates a UUIDv7: a 48-bit millisecond timestamp followed by 74 random
bits (with the version and variant bits overlaid per RFC 9562). Unlike
crypto.randomUUID() (always v4, fully random), a v7 id's leading bytes
sort chronologically and embed its creation time — required for PostHog's
$session_id property, which PostHog validates against captured events'
timestamps.
RFC 9562 UUIDv7 generation. Ported by hand rather than adding a dependency — the format is small and fully specified, matching this project's existing preference for hand-rolling well-specified primitives over pulling in a package for one function (see
src/helpers/analytics.ts's module doc for the same reasoning applied to not loadingposthog-js).Source