Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function getOriginalSource(opts = {}) {
const config = Object.assign({}, CONFIG, opts)
const { referrer, originalSourceKey } = config
// 1. try first source browser storage
const originalSrc = storage.getItem(originalSourceKey, { storage: config.storage })
if (originalSrc) {
return parsePipeString(originalSrc)
}
// 2. then try __utmz cookie
const utmzCookie = getCookie('__utmz')
if (utmzCookie) {
const parsedCookie = parsePipeString(utmzCookie)
if (parsedCookie) {
setOriginalSource(parsedCookie, config)
return parsedCookie
}
}
// 3. Then try referrer url and utm params
const ref = (inBrowser) ? (referrer || document.referrer) : ''
const refData = parseReferrer(ref)
setOriginalSource(refData, config)
export function getOriginalLandingPage(opts = {}) {
const config = Object.assign({}, CONFIG, opts)
const key = config.originalLandingPageKey
const storageConfig = { storage: config.storage }
// 1. try first source browser storage
const originalLandingPage = storage.getItem(key, storageConfig)
if (originalLandingPage) {
return originalLandingPage
}
const url = (inBrowser) ? window.location.href : ''
storage.setItem(key, url, storageConfig)
return url
}
export const getItem = (key, opts) => {
return storage.getItem(key, opts)
}
export function getPersistedUserData(params) {
return {
userId: storage.getItem(USER_ID) || params.an_uid,
anonymousId: storage.getItem(ANON_ID) || params.an_aid || uuid(),
traits: storage.getItem(USER_TRAITS) || {}
}
}
export function getPersistedUserData(params) {
return {
userId: storage.getItem(USER_ID) || params.an_uid,
anonymousId: storage.getItem(ANON_ID) || params.an_aid || uuid(),
traits: storage.getItem(USER_TRAITS) || {}
}
}