Skip to content

Label bot traffic for analytics#649

Merged
petebachant merged 2 commits into
mainfrom
block-bots
Jul 17, 2026
Merged

Label bot traffic for analytics#649
petebachant merged 2 commits into
mainfrom
block-bots

Conversation

@petebachant

Copy link
Copy Markdown
Member

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR reduces inflated Mixpanel page-view counts by disabling Mixpanel’s automatic pageview tracking and replacing it with a custom tracker that delays pageview emission until a first “human” interaction and skips automated browsers (via navigator.webdriver).

Changes:

  • Disable Mixpanel auto pageview tracking in main.tsx and initialize custom pageview tracking with the TanStack Router instance.
  • Add initPageViewTracking helper to gate pageview tracking behind first interaction and de-dupe by URL.
  • Add Vitest/JSDOM coverage for the new tracking behavior (interaction gating, de-dupe, webdriver exclusion).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
frontend/src/main.tsx Disables Mixpanel auto pageviews and initializes the new router-aware pageview tracking.
frontend/src/lib/analytics.ts Implements interaction-gated, webdriver-filtered, de-duplicated pageview tracking.
frontend/src/lib/analytics.test.ts Adds tests validating the new tracking behavior and bot filtering.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread frontend/src/lib/analytics.ts Outdated
Comment on lines +52 to +64
export function initPageViewTracking(router: AnyRouter): void {
if (navigator.webdriver) return
INTERACTION_EVENTS.forEach((event) =>
window.addEventListener(event, confirmHuman, {
capture: true,
passive: true,
}),
)
requestPageView()
router.subscribe("onResolved", ({ hrefChanged }) => {
if (hrefChanged) requestPageView()
})
}
@petebachant petebachant changed the title Filter more bot traffic from analytics Label bot traffic from analytics Jul 17, 2026
@petebachant petebachant changed the title Label bot traffic from analytics Label bot traffic for analytics Jul 17, 2026
@petebachant
petebachant merged commit a64ad7c into main Jul 17, 2026
6 of 7 checks passed
@petebachant
petebachant deleted the block-bots branch July 17, 2026 08:48
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.

2 participants