Hi all,
We’re building a custom agent desktop using the embeddable framework - v3.5.0, and the client app SDK - v1.43.0. It’s… not updating the real-time stats properly when an agent changes state. Specifically, when an agent goes from ‘Available’ to ‘Not Ready’, the stats component freezes. The data was updating before the state change, then… nothing.
The component uses sdk.agentDesktop.getRealtimeStats() to pull the stats. We’re polling every 5 seconds, which seems reasonable? The UI shows the correct state transition - the agent’s status badge updates fine - but the stats panel shows old values. It doesn’t error, it just…stops updating. It’s weird.
I’ve been looking at the event stream - the AGENT_STATE_CHANGE event fires as expected. I’m subscribing to the event, logging the new state, and then calling sdk.agentDesktop.getRealtimeStats(). The console logs show the state change, but the getRealtimeStats() call after seems to return cached data. Or no data. Hard to say.
const handleAgentStateChange = (event: AgentStateChangeEventArgs) => {
console.log("Agent state changed to:", event.agentState);
getStats();
};
const getStats = async () => {
try {
const stats = await sdk.agentDesktop.getRealtimeStats();
setStatsData(stats); // This is a React state update
} catch (error) {
console.error("Error getting stats:", error);
}
};
The error is… not an error, exactly. It’s just stale data. I thought maybe there was some caching issue within the embeddable framework, but I can’t find anything about that in the docs. I tried clearing the browser cache, didn’t help. I’ve checked the permissions - the agent role has all the necessary permissions for real-time stats. We are on Genesys Cloud, of course.
Also, I’m not sure if it’s connected, but sometimes I see this in the browser console around the same time: [genesys-cloud-sdk-client-app] WebSocket connection closed - code: 1006, reason:. Is that normal? Or is it…a disconnect? It reconnects quickly, but still. I think it might be a race condition.
The stats are not updating at all. It’s just… stuck. I’m thinking the AGENT_STATE_CHANGE event might be causing some kind of internal re-initialization, but I can’t find any documentation about that.