mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-06 08:18:08 +00:00

Co-authored-by: Harshal Sheth <harshal@acryl.io> Co-authored-by: Dexter Lee <dexter@acryl.io> Co-authored-by: Gabe Lyons <itsgabelyons@gmail.com>
17 lines
433 B
TypeScript
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;
|
|
}
|