How to use the analytics-utils.storage.setItem 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 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
return store => next => action => {
    const { type, key, value, options } = action
    if (type === EVENTS.setItem || type === EVENTS.removeItem) {
      if (action.abort) {
        return next(action)
      }
      // Run storage set or remove
      if (type === EVENTS.setItem) {
        storage.setItem(key, value, options)
      } else {
        storage.removeItem(key, options)
      }
    }
    return next(action)
  }
}
github DavidWells / analytics / packages / analytics-core / middleware / identify / index.js View on Github external
return store => next => action => {
    const { type, userId, traits, options, callback } = action
    if (type === EVENTS.IDENTIFY_INIT) {
      const identifyCalls = getIntegrationsWithMethod(getIntegrations(), 'identify')
      const cb = getCallbackFromArgs(traits, options, callback)

      // TODO add aborting
      // if (action.abort) {
      //
      // }

      storage.setItem(USER_ID, userId)

      if (traits) {
        storage.setItem(USER_TRAITS, traits)
      }
      // No identify middleware attached
      if (!identifyCalls.length) {
        store.dispatch({
          type: EVENTS.IDENTIFY,
          userId: userId,
          traits: traits,
          options: options,
          // callback: callback
        })
        return store.dispatch({
          ...{ type: EVENTS.IDENTIFY_COMPLETE }
        })
github DavidWells / analytics / packages / analytics-core / middleware / identify / index.js View on Github external
return store => next => action => {
    const { type, userId, traits, options, callback } = action
    if (type === EVENTS.IDENTIFY_INIT) {
      const identifyCalls = getIntegrationsWithMethod(getIntegrations(), 'identify')
      const cb = getCallbackFromArgs(traits, options, callback)

      // TODO add aborting
      // if (action.abort) {
      //
      // }

      storage.setItem(USER_ID, userId)

      if (traits) {
        storage.setItem(USER_TRAITS, traits)
      }
      // No identify middleware attached
      if (!identifyCalls.length) {
        store.dispatch({
          type: EVENTS.IDENTIFY,
          userId: userId,
          traits: traits,
          options: options,
          // callback: callback
        })
        return store.dispatch({
          ...{ type: EVENTS.IDENTIFY_COMPLETE }
        })
      }

      // TODO SAVE ID TO LOCALSTORAGE
github DavidWells / analytics / packages / analytics-plugin-original-source / src / index.js View on Github external
function setOriginalSource(data, config) {
  storage.setItem(config.originalSourceKey, formatPipeString(data), {
    storage: config.storage
  })
}