John Joyce 29832e5385
feat(Product Analytics): Introducing In-App Analytics Beta (#2499)
Co-authored-by: Harshal Sheth <harshal@acryl.io>
Co-authored-by: Dexter Lee <dexter@acryl.io>
Co-authored-by: Gabe Lyons <itsgabelyons@gmail.com>
2021-05-11 15:41:42 -07:00

17 lines
433 B
TypeScript

import Cookies from 'js-cookie';
import { v4 as uuidv4 } from 'uuid';
import { BROWSER_ID_COOKIE } from '../conf/Global';
function generateBrowserId(): string {
return uuidv4();
}
export function getBrowserId() {
let browserId = Cookies.get(BROWSER_ID_COOKIE);
if (!browserId) {
browserId = generateBrowserId();
Cookies.set(BROWSER_ID_COOKIE, browserId, { expires: 365 });
}
return browserId;
}