Skip to content

connect( key, channel )

Description

The connect method initializes the connection between your application and the data center. It is a required step for enabling the monitoring process, as it ensures that all the collected data is sent back to the data center. Think of this method as the foundational setup (similar to init) for the entire system.

⚠️ Notes

  1. The key parameter is mandatory. Without a valid authorizationKey, the connection will not be established.
  2. The channel parameter is optional. If not provided, the system will use a default configuration for data streams.
  3. Ensure that you call this method before any other methods, as it sets up the foundational connection for monitoring.

Syntax

javascript
import JBLWebSocket from '@/assets/js/jbl.es.js';
const authorizationKey = ${Product authorization key};

JBLWebSocket.connect(authorizationKey);

Parameters

ParameterTypeDescription
keyStringRequired,The authorizationKey provided for authentication. This is a mandatory parameter.
channelStringOptional,The Channel Name for grouping or categorizing data streams. This is an optional parameter.

Usage

Basic Example

Use the connect method to authenticate and start monitoring data for your application:

javascript
const authorizationKey = 'your-auth-key';
JBLWebSocket.connect(authorizationKey);

Example with Channel

If you want to define a specific channel for data categorization:

javascript
const authorizationKey = 'your-auth-key';
const channelName = 'MyChannel';
JBLWebSocket.connect(authorizationKey, channelName);