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: 

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 

}); 

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 

 

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 

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 

 

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. 

Additional Resources

See All Integration Steps