mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
21 lines
441 B
TypeScript
21 lines
441 B
TypeScript
import * as cookies from 'lib/cookies';
|
|
import * as growthBook from 'lib/growthbook/consts';
|
|
import isBrowser from 'lib/isBrowser';
|
|
|
|
export default function getUuid() {
|
|
const cookie = cookies.get(cookies.NAMES.UUID);
|
|
|
|
if (cookie) {
|
|
return cookie;
|
|
}
|
|
|
|
const uuid = crypto.randomUUID();
|
|
cookies.set(cookies.NAMES.UUID, uuid);
|
|
|
|
if (isBrowser()) {
|
|
window.localStorage.removeItem(growthBook.STORAGE_KEY);
|
|
}
|
|
|
|
return uuid;
|
|
}
|