-
Notifications
You must be signed in to change notification settings - Fork 0
this.info_browser
Marcelo de Souza Lima edited this page Jan 17, 2025
·
1 revision
The this.info_browser property provides detailed information about the user's browser, operating system, and device. This is powered by the my-ua-parser library and includes data such as the browser engine, OS, CPU architecture, and more. It is ideal for advanced browser detection and analytics.
{
"ua": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36",
"browser": {
"name": "Chrome",
"version": "130.0.0.0",
"major": "130"
},
"engine": {
"name": "Blink",
"version": "130.0.0.0"
},
"os": {
"name": "Linux",
"version": "x86_64"
},
"device": {},
"cpu": {
"architecture": "amd64"
}
}- ua: The full user agent string.
- browser: Information about the browser (name, version, major version).
- engine: Information about the browser engine (e.g., Blink, WebKit).
- os: Information about the operating system (name, version).
- device: Information about the device (usually empty for desktops).
- cpu: Information about the CPU architecture (e.g., amd64).
To access detailed browser and system information, use this.info_browser in your class:
class MyApp extends JsBaseClass {
async handle() {
// Log detailed browser information
this.console.log('User Agent:', this.info_browser.ua);
this.console.log('Browser Name:', this.info_browser.browser.name);
this.console.log('Browser Version:', this.info_browser.browser.version);
this.console.log('Browser Engine:', this.info_browser.engine.name);
this.console.log('Operating System:', this.info_browser.os.name);
this.console.log('CPU Architecture:', this.info_browser.cpu.architecture);
// Example: Apply OS-specific logic
if (this.info_browser.os.name === 'Linux') {
this.console.log('Running on a Linux system.');
} else {
this.console.log('Running on a different OS.');
}
}
}
// Initialize the app
const app = new MyApp();
app.init();