Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Context Reducer. Follows ducks pattern http://bit.ly/2DnERMc
import { getBrowserLocale, getTimeZone, uuid } from 'analytics-utils'
import EVENTS from '../events'
import inBrowser from '../utils/inBrowser'
import getOSNameNode from '../utils/getOSName/node'
import getOSNameBrowser from '../utils/getOSName/browser'
let osName
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,
},