as-event-tracker
Version:
Logs events in the browser based on client interactions.
65 lines • 2.76 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDevicePlatform = exports.getDeviceScreenHeight = exports.getDeviceScreenWidth = exports.getDeviceOS = exports.getDeviceType = void 0;
var ChannelMeta_1 = require("../consts/ChannelMeta");
function getDeviceType() {
var device_type = globalThis.CaptureState.clientChannelMeta.device_type;
if (device_type)
return device_type;
if (!globalThis.navigator)
return null;
var userAgent = globalThis.navigator.userAgent;
if (/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(userAgent))
return ChannelMeta_1.DeviceType.Tablet;
if (/Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(userAgent))
return ChannelMeta_1.DeviceType.Mobile;
return ChannelMeta_1.DeviceType.Desktop;
}
exports.getDeviceType = getDeviceType;
;
function getDeviceOS() {
var os = globalThis.CaptureState.clientChannelMeta.os;
if (os)
return os;
if (!globalThis.navigator)
return ChannelMeta_1.OsType.Unknown;
var userAgent = globalThis.navigator.userAgent;
if (userAgent.indexOf("Win") != -1)
return ChannelMeta_1.OsType.Windows;
if (userAgent.indexOf("Mac") != -1)
return ChannelMeta_1.OsType.Macintosh;
if (userAgent.indexOf("Linux") != -1)
return ChannelMeta_1.OsType.Linux;
if (userAgent.indexOf("Android") != -1)
return ChannelMeta_1.OsType.Android;
if (userAgent.indexOf("like Mac") != -1)
return ChannelMeta_1.OsType.iOS;
return ChannelMeta_1.OsType.Unknown;
}
exports.getDeviceOS = getDeviceOS;
;
function getDeviceScreenWidth() {
var _a;
var screen_width = globalThis.CaptureState.clientChannelMeta.screen_width;
if (screen_width)
return screen_width;
return ((_a = globalThis.screen) === null || _a === void 0 ? void 0 : _a.width) || null;
}
exports.getDeviceScreenWidth = getDeviceScreenWidth;
function getDeviceScreenHeight() {
var _a;
var screen_height = globalThis.CaptureState.clientChannelMeta.screen_height;
if (screen_height)
return screen_height;
return ((_a = globalThis.screen) === null || _a === void 0 ? void 0 : _a.height) || null;
}
exports.getDeviceScreenHeight = getDeviceScreenHeight;
function getDevicePlatform() {
var _a;
var device_platform = globalThis.CaptureState.clientChannelMeta.device_platform;
if (device_platform)
return device_platform;
return ((_a = globalThis.navigator) === null || _a === void 0 ? void 0 : _a.platform) || null;
}
exports.getDevicePlatform = getDevicePlatform;
//# sourceMappingURL=device.js.map
;