Description
In detectBot(), when a User-Agent is not matched by literal/regex patterns in ua-patterns.ts or by isAIBot(), it falls back to isBot() from ua-parser-js.
Currently, this generic fallback branch hardcodes action: BotAction.BLOCK instead of routing through getAction(BotCategory.UNKNOWN_BOT, config):
if (isBot(userAgent)) {
return {
isBot: true,
category: BotCategory.UNKNOWN_BOT,
name,
action: BotAction.BLOCK, // ignores config.trackOnlyCategories
confidence: 70,
reason: "general_bot_pattern",
};
}
As a result, configuring trackOnlyCategories: [BotCategory.UNKNOWN_BOT] does not apply to traffic detected via this fallback, and action: "block" is returned instead of "track_only".
Example:
A User-Agent like PowerShell/7.1.0 (which is recognized as a CLI tool by ua-parser-js's isBot() but is not present in ua-patterns.ts or isAIBot()):
detectBot("PowerShell/7.1.0", {
trackOnlyCategories: [BotCategory.UNKNOWN_BOT],
});
Expected: action: "track_only"
Actual: action: "block"
Proposed Fix
Route the generic isBot() fallback through getAction():
action: getAction(BotCategory.UNKNOWN_BOT, config),
I have verified the fix and tests locally and can open a PR once this issue is accepted.
Description
In
detectBot(), when a User-Agent is not matched by literal/regex patterns inua-patterns.tsor byisAIBot(), it falls back toisBot()fromua-parser-js.Currently, this generic fallback branch hardcodes
action: BotAction.BLOCKinstead of routing throughgetAction(BotCategory.UNKNOWN_BOT, config):As a result, configuring trackOnlyCategories: [BotCategory.UNKNOWN_BOT] does not apply to traffic detected via this fallback, and action: "block" is returned instead of "track_only".
Example:
A User-Agent like PowerShell/7.1.0 (which is recognized as a CLI tool by ua-parser-js's isBot() but is not present in ua-patterns.ts or isAIBot()):
I have verified the fix and tests locally and can open a PR once this issue is accepted.