Skip to content

fix(shared): respect trackOnlyCategories in generic isBot() fallback - #667

Open
aditya3799 wants to merge 1 commit into
databuddy-analytics:stagingfrom
aditya3799:fix/bot-detection-track-only-fallback
Open

fix(shared): respect trackOnlyCategories in generic isBot() fallback#667
aditya3799 wants to merge 1 commit into
databuddy-analytics:stagingfrom
aditya3799:fix/bot-detection-track-only-fallback

Conversation

@aditya3799

@aditya3799 aditya3799 commented Aug 22, 2026

Copy link
Copy Markdown

Fixes #<PUT_YOUR_ISSUE_NUMBER_HERE>

Summary of Changes

Routes the generic isBot() fallback in detectBot() through getAction(BotCategory.UNKNOWN_BOT, config) so that config.trackOnlyCategories is properly respected.

Reproduction & Verification

  • Tested with PowerShell/7.1.0 and trackOnlyCategories: [BotCategory.UNKNOWN_BOT].
  • Added unit test in packages/shared/src/utils/bot-detection/__tests__/detector.test.ts.
  • Ran full test suite (109 tests pass), type checks, and policy linter with zero errors.

AI Usage Disclosure

Assisted by AI (Antigravity) for draftingt eh message of issue and pull request and finding a new user-agent alis for testing the fix. Implementation and tests were verified locally using bun test and bun run lint.

Fixes #666


Summary by cubic

Respect trackOnlyCategories in the generic isBot() fallback. Previously, unknown bots caught by ua-parser-js’s generic isBot() always BLOCKed; now we derive the action via getAction so UNKNOWN_BOT can be TRACK_ONLY when configured.

  • Route the generic fallback through getAction(BotCategory.UNKNOWN_BOT, config) to align with other categories.
  • Add a unit test covering user agent "PowerShell/7.1.0" with trackOnlyCategories: [UNKNOWN_BOT].
  • Default behavior remains BLOCK unless config.trackOnlyCategories includes UNKNOWN_BOT.

Written for commit ab30155. Summary will update on new commits.

Review in cubic

@vercel

vercel Bot commented Aug 22, 2026

Copy link
Copy Markdown

@aditya3799 is attempting to deploy a commit to the Databuddy OSS Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 51e9ef5c-8df8-4412-b79d-da07d0129588

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR makes the generic isBot() fallback apply the configured action for UNKNOWN_BOT rather than always blocking it.

  • Routes fallback action selection through getAction.
  • Adds coverage for trackOnlyCategories: [BotCategory.UNKNOWN_BOT].

Confidence Score: 4/5

The PR appears safe to merge, with only a non-blocking indentation issue in the added test.

The production change preserves the default blocking behavior and applies TRACK_ONLY only when explicitly configured; the sole accepted concern is misleading test indentation.

Files Needing Attention: packages/shared/src/utils/bot-detection/tests/detector.test.ts

Important Files Changed

Filename Overview
packages/shared/src/utils/bot-detection/detector.ts Correctly applies existing category-action semantics to the generic bot fallback without changing default behavior.
packages/shared/src/utils/bot-detection/tests/detector.test.ts Adds focused regression coverage, but the new describe and it declarations have inverted indentation.

Reviews (1): Last reviewed commit: "fix(shared): respect trackOnlyCategories..." | Re-trigger Greptile

Comment on lines +266 to +267
describe("Generic isBot() fallback — config should still apply", () => {
it("respects trackOnlyCategories for bots only caught by ua-parser-js's generic isBot()", () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Correct inverted test indentation

The new describe is indented more deeply than its child it, which visually misrepresents the test hierarchy and makes the structure harder to follow.

Suggested change
describe("Generic isBot() fallback — config should still apply", () => {
it("respects trackOnlyCategories for bots only caught by ua-parser-js's generic isBot()", () => {
describe("Generic isBot() fallback — config should still apply", () => {
it("respects trackOnlyCategories for bots only caught by ua-parser-js's generic isBot()", () => {

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant