UNPKG

@newrelic/gatsby-theme-newrelic

Version:

[![Community Project header](https://github.com/newrelic/opensource-website/raw/master/src/images/categories/Community_Project.png)](https://opensource.newrelic.com/oss-category/#community-project)

16 lines (13 loc) 410 B
import { useLocalStorageState } from 'use-local-storage-state'; import generateUUID from '../utils/generateUUID'; import { STORAGE_KEYS } from '../utils/constants'; const useUserId = () => { const [userId, setValue] = useLocalStorageState(STORAGE_KEYS.USER_ID); if (userId == null) { const uuid = generateUUID(); setValue(uuid); return uuid; } return userId; }; export default useUserId;