Implement real-time presence tracking with PubNub
79
Quality
67%
Does it follow best practices?
Impact
98%
1.07xAverage score across 5 eval scenarios
{
"context": "A chat application needs a robust presence tracking system that maintains an accurate list of online users, handles initial state loading, processes all types of presence events including high-occupancy scenarios, and exposes hooks for UI integration.",
"type": "weighted_checklist",
"checklist": [
{
"name": "Map-based user tracking",
"description": "Uses a Map (or equivalent dictionary) to store online users keyed by UUID, supporting add, remove, and lookup operations",
"max_score": 10
},
{
"name": "hereNow initialization",
"description": "Has an initialize method that calls pubnub.hereNow() with includeUUIDs: true and includeState: true to populate the initial user list before relying on events",
"max_score": 15
},
{
"name": "Join handling",
"description": "Handles 'join' events by adding the user to the map with their UUID and optional state",
"max_score": 10
},
{
"name": "Leave and timeout handling",
"description": "Handles both 'leave' and 'timeout' events by removing the user from the map",
"max_score": 10
},
{
"name": "State-change handling",
"description": "Handles 'state-change' events by updating the existing user's state in the map without removing them",
"max_score": 10
},
{
"name": "Interval event handling",
"description": "Handles 'interval' events by processing batch arrays of join, leave, and timeout UUIDs from the event object",
"max_score": 15
},
{
"name": "Occupancy tracking",
"description": "Tracks the occupancy count from each presence event's occupancy field and exposes it via a getter method",
"max_score": 10
},
{
"name": "Callback hooks exposed",
"description": "Exposes overridable callback methods (e.g., onUserJoined, onUserLeft, onOccupancyChanged) that external code can set to react to presence changes",
"max_score": 10
},
{
"name": "withPresence subscription",
"description": "Subscribes to the channel with withPresence: true (or receivePresenceEvents: true) to receive presence events",
"max_score": 10
}
]
}