Node.js WebSocket consumer dropping Genesys analytics events

Trying to stream analytics notification events to Kafka using a basic Node.js consumer. The WebSocket connection to wss://api.mypurecloud.com/v2/analytics/events seems to hold, but the onmessage callback only fires for login/logout, never for queue metrics. The JSON payload I’m expecting has type: 'queue' but it’s just not arriving. Here’s the handler:

ws.on('message', (data) => { 
 console.log(JSON.parse(data)); 
 kafkaProduce(data); 
});

Why is the stream silent for analytics?

Are you passing the correct auth_token in the initial WebSocket handshake? The connection might be establishing but filtering out metrics due to insufficient scope. Try logging the raw socket open event to see if there’s a 403 hidden in the headers. Also, check if your user role actually has analytics:view permissions.

is spot on about the scopes, but you might still hit a wall if you’re not explicitly subscribing to the queue entity in the handshake. The Genesys WebSocket API doesn’t push everything by default. You have to tell it what you want.

Check your initial message payload right after the connection opens. It usually looks something like this:

ws.send(JSON.stringify({
 type: 'subscribe',
 entity: 'queue',
 id: 'your-queue-id-here', // or omit for all queues if perms allow
 fields: ['nWaiting', 'nTalking', 'nCallback']
}));

If you just connect and wait, the server assumes you only want presence updates. Also, make sure your token has analytics:report:view. Without that, the subscription silently fails or just doesn’t send the data. I’ve seen this trip people up a few times. Debug the raw JSON you’re sending on open.