How to use the analytics-utils.storage.getItem function in analytics-utils

To help you get started, we’ve selected a few analytics-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DavidWells / analytics / packages / analytics-plugin-original-source / src / index.js View on Github external
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)
github DavidWells / analytics / packages / analytics-plugin-original-source / src / index.js View on Github external
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
}
github DavidWells / analytics / packages / analytics-core / src / middleware / storage.js View on Github external
export const getItem = (key, opts) => {
  return storage.getItem(key, opts)
}
github DavidWells / analytics / packages / analytics-core / src / modules / user.js View on Github external
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) || {}
  }
}
github DavidWells / analytics / packages / analytics-core / src / modules / user.js View on Github external
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) || {}
  }
}