Live Stats
The doc covers how the live user count is maintained and sent to the dashboard home page.
- Scheduler :
- To enable the live User count on the Dashboard home page, this field should be be added in the env of the respective scheduler and redeployed.
"enableLiveChatStats" = true - The function getLiveChatStatsSeconds is scheduled to call the api /getLiveUserStats very second.
- The function getLiveChatStatsSeconds is scheduled to call the api /getLiveUserStats every minute.
- Both the apis are hit on the OCS from where the data is formatted and sent to dashboard using socket events.
- To enable the live User count on the Dashboard home page, this field should be be added in the env of the respective scheduler and redeployed.
- OCS
- The api route is defined in index.js, where it checks for the query parameters and calls the function to send Live stats per second or per minute.
- The room on which the socket data is emitted is liveChatsStatsAdmin, which is the room that a user joins by default when Logs in.
- The stats per second are emitted using the event : perSecondStats
- The stats per minute are emitted using the event : perMinuteStats
- Redis Data
- The data for this feature is maintained in a seperate hash in Redis i.e. liveChatsStats
- The hash contains the key value pair, where key is the platform name and value is the user count. For eg:
total: 5
website: 2
android: 0
ios: 0
whatsapp: 1
gbm: 2 - The count of total and the respective platform of the customer increases when the customer initiates the chat.
- The count of total and the respective platform of the customer decreases when the chat ends due to any reason.
- Note:
- If the field in scheduler env is set as false or is not set, the data will still be captured but will not be sent to Dashboard.