Analytics Storage Utils
Storage utilities for analytics
Storage tries to use localStorage
then cookies
then defaults to global
window.
It's also possible to specify exactly where to set, get, and remove data from with the options
parameter.
getItem
import { getItem } from '@analytics/storage-utils'
const value = getItem('key')
const getLSValue = getItem('key', 'localStorage')
const getLSValue = getItem('key', 'cookie')
const getLSValue = getItem('key', 'global')
const valueObj = getItem('otherKey', 'all')
setItem
import { setItem } from '@analytics/storage-utils'
setItem('key', 'value')
setItem('key', 'otherValue', 'localStorage')
setItem('keyTwo', 'cookieVal', 'cookie')
setItem('keyThree', 'xyz', 'global')
removeItem
import { removeItem } from '@analytics/storage-utils'
setItem('key')
setItem('key', 'otherValue', 'localStorage')
setItem('keyTwo', 'cookieVal', 'cookie')
setItem('keyThree', 'xyz', 'global')