evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a real-time user activity monitoring system that processes a streaming JSON API endpoint containing user events. The system should progressively parse and filter the event stream, tracking active users and responding to specific patterns.
The system should fetch JSON data from a streaming endpoint and:
The streaming API returns JSON in this format:
{
"stream_id": "abc123",
"events": [
{
"type": "login",
"username": "alice",
"timestamp": "2024-01-15T10:30:00Z"
},
{
"type": "logout",
"username": "bob",
"timestamp": "2024-01-15T10:35:00Z"
},
{
"type": "admin_action",
"username": "admin",
"action": "user_ban",
"timestamp": "2024-01-15T10:40:00Z"
}
]
}/**
* Start monitoring user activity from a streaming endpoint
* @param {string} url - The streaming API endpoint URL
* @returns {object} Monitor instance with methods to access collected data
*/
function monitorUserActivity(url) {
// Returns an object with:
// - activeUsers: Set of currently logged-in usernames
// - adminEvents: Array of admin actions
// - startTime: Timestamp when monitoring began
// - complete: Boolean indicating if stream has completed
}
module.exports = { monitorUserActivity };Provides streaming JSON parsing for progressively handling HTTP responses.