JBL JS - Getting Started
Installation Information
To use this product, you need to apply for the following files and authorization key from our company:
jbl.jsjbl.es.jsauthorizationKey
Parameters
| Name | Type |
|---|---|
| authorizationKey | String |
Usage Instructions
Using jbl.js
Global Object:
jbl.jsis a globally used script file. Once imported, it will automatically add theJBLWebSocketobject to thewindow.- Note: The
JBLWebSocketobject name is fixed and cannot be changed.
Steps:
- Place
jbl.jsin the same folder as yourindex.htmlfile. - Import
jbl.jsin yourhtmlfile by adding a<script>tag in the<head>section. - Execute the
connectmethod, and the data will automatically be sent back to the data center.
- Place
Example Code
html
<script type="text/javascript" src="https://cdn.example.com/jbl.js"></script>
<script>
const authorizationKey = ${Product authorization key};
// Monitor website information using the global object
JBLWebSocket.connect(authorizationKey);
</script>Using jbl.es.js
Modular Design:
jbl.es.jssupports modular imports, allowing you to customize the package name when importing, making it more flexible for your project.
Steps:
- Place
jbl.es.jsin a designated folder. In this example, we store it in the/assets/jsfolder. - Import
jbl.es.jsin the requiredjavascriptfile. - Use the custom name to initialize and start monitoring.
- Execute the
connectmethod, and the data will automatically be sent back to the data center.
- Place
Example Code
javascript
// Import jbl.es.js with a custom name
import CustomJBL from '@/assets/js/jbl.es.js';
const authorizationKey = ${Product authorization key};
// Monitor website information using the custom object
CustomJBL.connect(authorizationKey);Notes
- If you are using
jbl.js, ensure the global object nameJBLWebSocketis correct. This name is system-defined and cannot be changed. - If you are using
jbl.es.js, you can customize the object name during the import process to increase project flexibility. - Always execute the
connectmethod before calling other methods to ensure the monitoring functionality works properly.