-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Use NavigatorUAData and navigator.webdriver to improve bot detection #1359
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Size Change: +1.18 kB (+0.1%) Total Size: 1.17 MB
ℹ️ View Unchanged
|
ca1dab7
to
8cb7d1e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks sound to me 💪
/// <reference types="cypress" /> | ||
import { start } from '../support/setup' | ||
|
||
describe('User Agent Blocking', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️ this is lovely
if (navigator) { | ||
return isLikelyBot(navigator, this.config.custom_blocked_useragents) | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the only thing that gives me pause - and i've helpfully not thought about this at all - is the change from userAgent being required to navigator being required.
my assumption is this is ok because if we're in an environment with no navigator then we also have no userAgent...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah - I can see why there would be situations where people might want to pass a userAgent, but we currently get the userAgent by doing navigator.userAgent
so any environment without a navigator
won't have a userAgent
, so this is no change.
…ction (#1359) * Use NavigatorUAData and navigator.webdriver to improve bot detection * Use real values of brands from headless and regular chrome in tests * Reduce bundle size slightly * Remove global * Fix test setup * Opt out of bot filtering in cypress * Make _is_likely_bot an instance function on posthog, use it in cypress tests * Fix cypress imports * Code golf * More code golf * Fix testcafe tests * Treat cypress as a bot * Fix cypress chaining logic
Changes
We weren't detecting some headless browsers in our bot detection, so I've added headless chrome to the list of blocked UAs. See this zendesk ticket https://posthoghelp.zendesk.com/agent/tickets/16802
We weren't using the
navigator.webdriver
field, so I've added that to the check as well.I've also added some support for NavigatorUAData, so that we detect headless chrome where the --useragent argument is changed to something else
Checklist