Skip to content

fix(analytics): no PostHog in a browser a program drives - #2441

Merged
gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:fix/analytics-automated-browsers
Nov 16, 2026
Merged

gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:fix/analytics-automated-browsers

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

The owner saw about 30 sign-up page views in a few hours that never signed up. They followed the marketing site's sign-up buttons one by one: the same glossary or blog page arrived through two or three different buttons (ref=glossary-hero, glossary-nudge, glossary-nav…), hours apart, at a steady pace. That is how a crawler or an AI agent walks a site, not how people click. Those views count as people in the sign-up funnel and make it look worse than it is.

PostHog now doesn't start in a browser a program drives, so its page views, replays and heatmaps never reach the funnels.

Changes

  • web/src/lib/automated-browser.ts (new): isAutomatedBrowser(). Only clear signs count, so no person is left out:
    • navigator.webdriver (set by WebDriver, Playwright and Puppeteer);
    • a HeadlessChrome or Chrome-Lighthouse user agent;
    • a crawler's own name as crawlers write it (Googlebot/2.1, GPTBot/1.0, bingbot/2.0: a word ending in "bot" followed by a version), or the words crawler or spider. A phone brand such as "CUBOT X70" doesn't match.
  • web/src/components/providers/posthog-provider.tsx: no posthog.init when it returns true. The analytics wrapper already handles PostHog being absent, as it does without a key.
  • Tests: the detector on bot, headless and Lighthouse user agents and on ordinary Chrome, iPhone Safari and a "Cubot" phone; the provider starts nothing with navigator.webdriver or a crawler's user agent.

robots.txt: no change. web/src/app/robots.ts already disallows the whole app domain (Disallow: /), so these visitors ignore it. A robots rule can't stop them.

What this can't catch: an agent that drives an ordinary browser and hides every sign (no webdriver, a normal Chrome user agent). Filter those in PostHog by what their events show (city, screen size, browser), once the owner has checked a few of them.

How to test

  1. cd web && yarn vitest run src/lib/automated-browser.test.ts src/components/providers/posthog-provider.test.tsx
  2. Open the app in a normal browser: PostHog events arrive as before.
  3. Open it with Playwright (navigator.webdriver is true): no request goes to PostHog.

Checks

  • Web typecheck: clean.
  • Vitest: the detector, the PostHog provider and src/lib/analytics*, 18 tests passed.
  • ESLint and Prettier on the changed files: clean.
  • No Help change: this changes no screen. No lockfile changes and no new dependencies.

Generated by Claude Code

Sign-up page views that followed every sign-up button of the marketing
site's pages, one by one, and never signed up, made the sign-up funnel
look worse than it is. PostHog now doesn't start in a browser a program
drives: navigator.webdriver, a headless Chrome or Lighthouse user agent,
or a crawler's own name. Only clear signs count, so no person is left
out. robots.txt already disallows the whole app domain.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9

@gkhngyk gkhngyk left a comment

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.

LGTM.

@gkhngyk
gkhngyk merged commit 57d25f6 into ansvisor:main Nov 16, 2026
22 of 23 checks passed
cihan-gyk pushed a commit to cihan-gyk/ansvisor that referenced this pull request Nov 16, 2026
Brings in ansvisor#2446 (no row counts), ansvisor#2442, ansvisor#2447, ansvisor#2441 and ansvisor#2377.

Conflicts:
- approved-articles.json: regenerated (yarn vitest run -u src/lib/help).

help/chat/chat.md merged cleanly: main's "Watch the work" text (no row
counts) and this branch's action-title line are both kept (132 words);
updated stays 2026-11-16, last_checked 2026-11-15.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
cihan-gyk pushed a commit to cihan-gyk/ansvisor that referenced this pull request Nov 16, 2026
Takes the updated ansvisor#2420, which now includes upstream main (ansvisor#2446 no row
counts, ansvisor#2442, ansvisor#2447, ansvisor#2441, ansvisor#2377).

Conflicts:
- approved-articles.json: regenerated (yarn vitest run -u src/lib/help).

help/chat/chat.md merged cleanly: updated 2026-11-16, last_checked
2026-11-15.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
cihan-gyk pushed a commit to cihan-gyk/ansvisor that referenced this pull request Nov 16, 2026
Takes the updated ansvisor#2422, which now includes ansvisor#2420 and upstream main
(ansvisor#2446 no row counts, ansvisor#2442, ansvisor#2447, ansvisor#2441, ansvisor#2377). No conflicts;
approved-articles.json checked with yarn vitest run -u src/lib/help
(no change).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
cihan-gyk pushed a commit to cihan-gyk/ansvisor that referenced this pull request Nov 16, 2026
Takes the updated ansvisor#2423, which now includes ansvisor#2422, ansvisor#2420 and upstream
main (ansvisor#2446 no row counts, ansvisor#2442, ansvisor#2447, ansvisor#2441, ansvisor#2377).

Conflicts:
- help/chat/chat.md: front matter only; took the later last_checked
  (2026-11-16). Both sides' text is kept: main's "Watch the work" (no
  row counts, 148 words) and this branch's look-up-by-code paragraph in
  "Ask about your actions" (146 words).
- approved-articles.json: regenerated (yarn vitest run -u src/lib/help).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
cihan-gyk pushed a commit to cihan-gyk/ansvisor that referenced this pull request Nov 16, 2026
Brings in ansvisor#2446 (no row counts), ansvisor#2442, ansvisor#2447, ansvisor#2441 and ansvisor#2377.

Conflicts:
- help/chat/chat.md: front matter only; took the later last_checked
  (2026-11-16), updated stays 2026-11-16. Both sides' sections are kept:
  main's "Watch the work" (no row counts) and this branch's "Open and
  close Settings in the chat menu" (98 words).

approved-articles.json merged cleanly and is current (yarn vitest run -u
src/lib/help: no change).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
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.

3 participants