Skip to content

Conversation

@jjl014
Copy link
Contributor

@jjl014 jjl014 commented Oct 29, 2024

Updates:

  • Update bot check logic to always check user agent. This in turn will ensure that no events from bot-like "users" get put in the request queue
  • Add/update tests

Notes:

This PR was aiming to keep things mostly the same without changing too many things. There are a couple different ways we could go about updating the existing logic and here are a few (feel free to comment if you have other thoughts/ideas as well):

Current Solution:
The current state works well for the most part, but fails if the crawler/scraper is able to perform some "human-like" action due to the current logic we have in place. Once humanity is determined, it will always rely on the isHuman variable that's saved to storage and doesn't do any more checks. This makes it easy for crawlers/scrapers to bypass any additional checks.

Proposed Solution 1 (This PR):
Not a whole lot changed except for checking the User Agent every time before a request is queued in addition to making sure that the user has proven that they're human.

Proposed Solution 2:
Check the User Agent when the client is instantiated and set sendTrackingEvents to false if it's a bot-like User Agent. This would disable tracking events entirely and no events can be queued.

Proposed Solution 3:
The isHuman (__cnstrc_is_human) variable is currently set after a human-like action has been performed on the page (i.e. scroll, click, mouseover, etc). We could add another condition where we check the User Agent before the isHuman variable ets set, so even if the “user” performs a human-like action, they would be required to have a non-bot-like user agent for events to get queued.

@jjl014 jjl014 requested a review from a team October 29, 2024 23:18
Copy link
Contributor

@esezen esezen left a comment

Choose a reason for hiding this comment

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

LGTM!

isBot() {
if (this.getIsHumanFromSessionStorage()) {
return false;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@jjl014 jjl014 requested review from esezen and sblaurock November 6, 2024 01:08
const humanity = new HumanityCheck();

expect(humanity.isHuman()).to.equal(false);
expect(humanity.hasPerformedHumanEvent).to.equal(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for fixing the tests! Sorry I didn't do that earlier.

@esezen esezen merged commit 3fc9a7d into master Dec 19, 2024
@esezen esezen deleted the noci-update-bot-checking branch December 19, 2024 18:34
jjl014 added a commit that referenced this pull request Jan 8, 2025
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.

4 participants