* Update index to make it clear what has hasn't updated to Next/React yet * Typescriptify events and experiments * Typescript the old JS for easier integration * Update release-notes.ts * Lint * Run npm i * Fix a few lint issues * Update airgap-links.ts * Update airgap-links.ts * Update set-next-env to ts * Update airgap-links.ts * Update package-lock.json * Update set-next-env.ts * Update package-lock.json * Revert "Update package-lock.json" This reverts commit b45e8250beeb700719d3b44e1092b0bbd093baba. * readd fsevents * Revert "readd fsevents" This reverts commit 419f3c35080ac4a9072f0b4e8e291e1712ce3639. * Update openapi-schema-check.yml * Revert "Update openapi-schema-check.yml" This reverts commit 5e9f4a29ea11ee343ca17291a40a751920c5b923. * Update package-lock.json * Update package-lock.json
31 lines
949 B
TypeScript
31 lines
949 B
TypeScript
// A tiny user agent checking RegExp for analytics purposes
|
|
|
|
// The order matters with these
|
|
const OS_REGEXPS = [
|
|
/(iphone os|ipad os) ([^);]+)/i,
|
|
/(mac) os x ([^);]+)/i,
|
|
/(windows) ([^);]+)/i,
|
|
/(android) ([^);]+)/i,
|
|
/(cros) ([^);]+)/i,
|
|
/(linux) ([^);]+)/i,
|
|
]
|
|
|
|
// The order matters with these
|
|
const BROWSER_REGEXPS = [
|
|
/(firefox)\/([^\s)]+)/i,
|
|
/(edge)\/([^\s)]+)/i,
|
|
/(chrome)\/([^\s)]+)/i,
|
|
/(safari)\/([^\s)]+)/i,
|
|
/ms(ie)\/([^\s)]+)/i,
|
|
]
|
|
|
|
export default function parseUserAgent(ua = navigator.userAgent) {
|
|
ua = ua.toLowerCase()
|
|
const osRe = OS_REGEXPS.find((re) => re.test(ua))
|
|
let [, os = 'other', os_version = '0'] = (osRe && ua.match(osRe)) || []
|
|
if (os === 'iphone os' || os === 'ipad os') os = 'ios'
|
|
const browserRe = BROWSER_REGEXPS.find((re) => re.test(ua))
|
|
const [, browser = 'other', browser_version = '0'] = (browserRe && ua.match(browserRe)) || []
|
|
return { os, os_version, browser, browser_version }
|
|
}
|