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 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
}
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)
}
}
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 }
})
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
function setOriginalSource(data, config) {
storage.setItem(config.originalSourceKey, formatPipeString(data), {
storage: config.storage
})
}