docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a traffic analyzer utility that identifies and categorizes automated bots and crawlers from website traffic logs.
Your utility should process User-Agent strings from HTTP requests and distinguish between human users and automated traffic. The system needs to:
Create a module that exports the following functions:
/**
* Analyzes a User-Agent string to determine if it represents a bot or crawler.
*
* @param {string} userAgent - The User-Agent string to analyze
* @returns {boolean} true if the User-Agent represents a bot, false otherwise
*/
function isBot(userAgent) {
// IMPLEMENTATION HERE
}
/**
* Extracts bot vendor information from a User-Agent string.
* Returns null if the User-Agent is not from a bot.
*
* @param {string} userAgent - The User-Agent string to analyze
* @returns {string|null} The bot vendor name, or null if not a bot
*/
function getBotVendor(userAgent) {
// IMPLEMENTATION HERE
}
/**
* Analyzes an array of User-Agent strings and returns statistics
* about bot vs human traffic.
*
* @param {string[]} userAgents - Array of User-Agent strings
* @returns {Object} Statistics with botCount, humanCount, and totalCount
*/
function analyzeTraffic(userAgents) {
// IMPLEMENTATION HERE
}
module.exports = {
isBot,
getBotVendor,
analyzeTraffic,
};Provides browser and bot detection capabilities from User-Agent strings.