Implement real-time presence tracking with PubNub
Does it follow best practices?
Evaluation — 100%
↑ 1.32xAgent success when using this tile
Validation for skill structure
A document collaboration platform (similar to Google Docs) needs to show who is currently viewing or editing a shared document. When a user opens a document, they should appear in the "active viewers" sidebar. When they close the tab or lose connection, they should be removed. The sidebar also shows a total count of viewers.
The platform uses PubNub for real-time features. Each document has a dedicated channel (e.g., doc-{documentId}). The team needs a JavaScript module that manages the list of active users for a given document channel. It must correctly handle all the ways users can appear and disappear, including network interruptions and high-traffic documents where hundreds of people might be viewing simultaneously.
Write the implementation for this presence-powered user list manager.
Produce a file called presence-manager.js containing a JavaScript class (or module) that:
The code should handle edge cases around network disruptions and be ready for channels of varying sizes.