@grafana/faro-web-sdk
Version:
Faro instrumentations, metas, transports for web.
15 lines • 607 B
JavaScript
import { UAParser } from 'ua-parser-js';
let cachedUA;
let cachedResult;
// Browser and OS meta providers both need to parse navigator.userAgent.
// Cache keyed on the UA string so we parse at most once per unique UA
// (test mutations of navigator.userAgent invalidate naturally).
export function getUAResult() {
const currentUA = typeof navigator !== 'undefined' ? navigator.userAgent : '';
if (cachedUA !== currentUA || !cachedResult) {
cachedResult = new UAParser(currentUA).getResult();
cachedUA = currentUA;
}
return cachedResult;
}
//# sourceMappingURL=uaParser.js.map