diff --git a/packages/shared/src/utils/bot-detection/__tests__/detector.test.ts b/packages/shared/src/utils/bot-detection/__tests__/detector.test.ts index 5fb2574b5..5bfec533c 100644 --- a/packages/shared/src/utils/bot-detection/__tests__/detector.test.ts +++ b/packages/shared/src/utils/bot-detection/__tests__/detector.test.ts @@ -262,6 +262,21 @@ describe("detectBot", () => { expect(custom.action).toBe(BotAction.BLOCK); }); }); + + describe("generic isBot() fallback", () => { + it("respects trackOnlyCategories for bots only caught by ua-parser-js's generic isBot()", () => { + const genericBotUA = "PowerShell/7.1.0"; + + const result = detectBot(genericBotUA, { + trackOnlyCategories: [BotCategory.UNKNOWN_BOT], + }); + + expect(result.isBot).toBe(true); + expect(result.category).toBe(BotCategory.UNKNOWN_BOT); + expect(result.reason).toBe("general_bot_pattern"); + expect(result.action).toBe(BotAction.TRACK_ONLY); + }); + }); }); describe("matchCategory", () => { diff --git a/packages/shared/src/utils/bot-detection/detector.ts b/packages/shared/src/utils/bot-detection/detector.ts index 5c32fd9c2..9b9eb5779 100644 --- a/packages/shared/src/utils/bot-detection/detector.ts +++ b/packages/shared/src/utils/bot-detection/detector.ts @@ -151,7 +151,7 @@ function detect( isBot: true, category: BotCategory.UNKNOWN_BOT, name, - action: BotAction.BLOCK, + action: getAction(BotCategory.UNKNOWN_BOT, config), confidence: 70, reason: "general_bot_pattern", };