@grafana/faro-web-sdk
Version:
Faro instrumentations, metas, transports for web.
18 lines • 734 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getUAResult = getUAResult;
const ua_parser_js_1 = require("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).
function getUAResult() {
const currentUA = typeof navigator !== 'undefined' ? navigator.userAgent : '';
if (cachedUA !== currentUA || !cachedResult) {
cachedResult = new ua_parser_js_1.UAParser(currentUA).getResult();
cachedUA = currentUA;
}
return cachedResult;
}
//# sourceMappingURL=uaParser.js.map