Skip to content

sendWebSiteLog( code, time, size )

Description

The sendWebSiteLog method is used to send custom event logs to the data center for analysis. It tracks specific events on the website, including their type, duration, and resource usage.

Syntax

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

JBLWebSocket.connect(authorizationKey);
JBLWebSocket.sendWebSiteLog(code, time, size);

Parameters

ParameterTypeDescription
codeStringRequired.Custom event name. Specify the type of event being logged.
timeNumberRequired.The amount of time (in milliseconds) that the event took to complete.
sizeNumberRequired.The amount of resources (e.g., bandwidth or memory) consumed by the event.

Example

javascript
// Example usage of sendWebSiteLog
const code = "imageLoad";
const time = 200; // 200ms
const size = 500; // 500KB

JBLWebSocket.sendWebSiteLog(code, time, size);

Use Cases

  • Event Tracking: Monitor how long specific events (e.g., API calls, media loading) take to execute.
  • Resource Usage Analysis: Measure the memory or bandwidth consumed by particular events to optimize performance.
  • Custom Monitoring: Send logs for user-defined events to gain detailed insights into website behavior.