How to use the analytics-utils.getBrowserLocale 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-core / src / modules / context.js View on Github external
// 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,
  },