Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let referrer
let locale
let timeZone
if (process.browser) {
osName = getOSNameBrowser()
referrer = document.referrer
locale = getBrowserLocale()
timeZone = getTimeZone()
} else {
osName = getOSNameNode()
referrer = {}
}
const initialState = {
initialized: false,
sessionId: uuid(),
app: null,
version: null,
debug: false,
offline: (inBrowser) ? !navigator.onLine : false, // use node network is-online
os: {
name: osName,
},
userAgent: (inBrowser) ? navigator.userAgent : 'node', // https://github.com/bestiejs/platform.js
library: {
name: 'analytics',
// TODO fix version number. npm run publish:patch has wrong version
version: process.env.VERSION
},
timezone: timeZone,
locale: locale,
campaign: {},
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) || {}
}
}