Live Chat Messenger Events & Logger

Updated 

The Live Chat Logger in the Live Chat SDK provides a structured mechanism for capturing and managing real-time SDK events and system logs. It enables developers to monitor chat interactions, track user actions, and diagnose issues efficiently by logging critical events and system statuses. 

Add Events Logger to SDK Events 

To track and manage various events efficiently, the SDK provides a logging system that can be configured according to your requirements. The logging system supports different log levels to help debug issues effectively. 

Configure the Logger 

Use the following snippet to enable logging and define custom log transports: 

Note: It is recommended to call setLoggerConfig before takeOff to avoid missing logs emitted during initialization.

import MessengerClient from '@sprinklrjs/chat-native-client'; 

 

MessengerClient.setLoggerConfig({ 

  enableLogs: true, // Required to enable logs 

  logLevel: 4, // Optional, default is INFO (4) 

  transports: [ 

    { 

      write(level, ...logs) { 

        // Implement your custom logger transport here 

      }, 

    }, 

  ], // Optional, default transport is console 

}); 

setLoggerConfig Parameters 

Parameter 

Required/Optional 

 

Value 

Description 

 

enableLogs 

Required 

Boolean (true/false) 

This parameter is required to enable or disable logging. When set to true, logging is enabled, allowing the application to record log messages. If set to false, logging is disabled. 

logLevel 

Optional 

Integer (0 to 7) 

This parameter sets the level of logging detail. The default value is 4, which corresponds to the INFO level. Refer to the table below for more details on Log Level 

transports

Optional

List of objects with a write method.

write(level, …logs){}

  • level: Level of the log

  • …logs: List of logs as strings

This parameter allows defining multiple transporters that get called parallelly.

 

Available Log Levels 

The SDK supports the following log levels: 

Log Level 

Value  

Description 

OFF 

Disables all logging. No log messages will be recorded. 

FATAL 

Logs only the most severe error events that will presumably lead the application to abort. 

ERROR 

Logs things that went wrong so that either something failed or the system had to resort to a fallback that the user may have noticed. 

WARN 

Logs things that went wrong, but were recoverable so that a user should not have noticed. 

INFO 

Logs primarily large business-logic steps as the SDK connects, sends, and receives messages. 

DEBUG 

Logs details of the inner workings of the SDK logic and network stack. 

TRACE 

Logs high-traffic logs; tracks many objects as they move through the SDK. 

ALL 

Enables all logging levels, capturing every log message. 

 
As is standard with most logging systems, each of these settings also includes all levels below it. Setting the SDK Logging Level to OFF disables SDK logging entirely. 

Add Messenger Events Listener to SDK Events 

To track various SDK-related events, register an event listener using the registerEventsListener method. 

Register an Events Listener 

Note: It is recommended to call registerEventsListener before takeOff to avoid missing events during initialization.

import MessengerClient from '@sprinklrjs/chat-native-client'; 

 

MessengerClient.registerEventsListener(this.eventsListener); 

 

eventsListener = (eventGroup, eventType, payload) => { 

  // Handle events here 

}; 

Supported Events  

The SDK emits events under different event groups. Below is the list of supported event groups and their event types: 

MESSENGER Events 

Event Type  

Description  

SDK Method 

BOOT_FAILED  

Messenger boot process failed.  

 takeOff 

BOOT_STARTING  

Messenger boot process started.  

 takeOff 

BOOT_COMPLETE  

Messenger boot process completed successfully.  

takeOff 

USER_LOGOUT  

User logged out.  

cleanup 

UPDATE_USER_STARTING  

Updating user information started.  

updateUser/ updateCustomUser  

UPDATE_USER_FAILED  

Updating user information failed.  

updateUser/ updateCustomUser  

UPDATE_USER_SUCCESS  

User information updated successfully.  

updateUser/ updateCustomUser  

UPDATE_USER_CONTEXT_FAILED  

Updating user context failed.  

updateUserContext  

UPDATE_CLIENT_CONTEXT_FAILED  

Updating client context failed.  

updateClientContext  

ANONYMOUS_SESSION_CREATION_STARTING  

Anonymous session creation started.  

cleanup  

ANONYMOUS_SESSION_CREATION_SUCCESS  

Anonymous session created successfully.  

cleanup  

ANONYMOUS_SESSION_CREATION_FAILED  

Anonymous session creation failed.  

cleanup 

AUTH_SESSION_STATUS 

Authentication session status changed 

getAuthSessionStatus/any Authenticated API Call 

ANONYMOUS_SESSION_CLEARED 

Anonymous session cleared successfully 

cleanup 

ANONYMOUS_SESSION_CLEAR_FAILED 

Anonymous session clear failed 

cleanup 

 

NETWORK Events 

Event Type 

Description 

INTERNET_CONNECTION_STATUS_CHANGED 

Internet connection status changed. 

PUSH_NOTIFICATION Events 

Event Type 

Description 

SDK Method 

PUSH_NOTIFICATION_REGISTRATION_EXISTS 

Push notification registration already exists. 

updatePushToken 

PUSH_NOTIFICATION_REGISTRATION_SUCCESS 

Push notification registration successful. 

updatePushToken 

PUSH_NOTIFICATION_REGISTRATION_FAILED 

Push notification registration failed. 

updatePushToken 

PUSH_NOTIFICATION_UNREGISTRATION_SUCCESS 

Push notification unregistered successfully. 

updatePushToken 

PUSH_NOTIFICATION_UNREGISTRATION_FAILED 

Push notification unregistration failed. 

updatePushToken 

CONVERSATION Events 

Event Type  

Description  

NEW_CONVERSATION_INITIATION_FAILED  

Failed to initiate a new conversation.  

CONVERSATION_CLOSED  

Conversation closed.  

CONVERSATION_DELETED  

Conversation deleted.  

CONVERSATION_CLOSE_FAILED  

Failed to close the conversation.  

CONVERSATION_DELETE_FAILED  

Failed to delete the conversation.  

CONVERSATION_CLOSED_BY_AGENT  

Conversation was closed by an agent. 

ALL_CONVERSATIONS_DELETED 

All conversations deleted successfully.   

ALL_CONVERSATIONS_CLOSED   

All conversations closed successfully.   

ALL_CONVERSATIONS_CLOSE_FAILED 

Failed to close all conversations.   

 

ALL_CONVERSATIONS_DELETE_FAILED 

Failed to delete all conversation. 

VIDEO CALL Events

Event Type 

Description 

VIDEO_CALL_ENDED 

Video call session ended 

VIDEO_CALL_FAILED 

Video call connection failed 

VIDEO_CALL_STARTED 

Video call session started successfully 

VIDEO_CALL_INITIATED 

Video call initiated by user 

MQTT CLIENT Events

Event Type 

Description 

MQTT_CLIENT_ERROR 

MQTT client connection error occurred 

MQTT_CLIENT_CLOSED 

MQTT client connection closed 

MQTT_CLIENT_OFFLINE 

MQTT client went offline 

MQTT_CLIENT_RECONNECT 

MQTT client attempting to reconnect 

MQTT_CLIENT_CONNECTED 

MQTT client connected successfully 

MQTT_CLIENT_DISCONNECTED 

MQTT client disconnected 

VoIP Events

Event Type

Description

ANSWER_CALL_INITIATED 

VoIP call answer action initiated

Co-browse Events

Event Type

Description

COBROWSE_SESSION_STARTED 

Co-browse session started with agent 

COBROWSE_SESSION_ENDED 

Co-browse session ended

Additional Resources

See All Integration Steps