posthog-js
Version:
Posthog-js allows you to automatically capture usage and send events to PostHog.
27 lines (26 loc) • 1.01 kB
TypeScript
/**
* Opt-in heuristic that flags user agents whose Chrome token appears without
* the usual AppleWebKit / Safari tokens that real Chrome always emits. Legit
* mobile WebViews and custom WebView apps CAN omit these, so this is a
* client-side-only signal — intended for callers who want to filter or tag
* events in `before_send`, not a universal blocklist entry.
*
* This is deliberately a standalone utility (not wired into the default
* blocklist) so default SDK behavior is unchanged. Server-side rules remain
* the primary bot-detection surface — see posthog/posthog#109617 and #109620.
*
* @example
* ```ts
* import { isLikelyWebViewBot } from 'posthog-js/customizations'
*
* posthog.init('PROJECT_TOKEN', {
* before_send: (event) => {
* if (event && isLikelyWebViewBot(navigator.userAgent)) {
* event.properties.$suspected_webview_bot = true
* }
* return event
* },
* })
* ```
*/
export declare function isLikelyWebViewBot(ua: string | undefined): boolean;