Skills

Posthog Adblock Bypass

Configure a Next.js app using posthog-js so session recording and dead-click capture...

Install

npx skills add Leanmcp/gateway-skills --skill posthog-adblock-bypass -g -a claude-code -y
Category
Engineering
Updated
28d ago
License
MIT
Context cost
Mediumabout 2,196 tokens
Runs scripts
No, instructions only

What it does

Configure a Next.js app using posthog-js so session recording and dead-click capture survive browser ad blockers. Aliases the three blocker-flagged JS chunks (dead-clicks-autocapture.js, recorder.js, posthog-recorder.js) to bland same-origin paths via Next.js rewrites, and monkey-patches HTMLScriptElement so posthog-js requests the aliases. TRIGGER when posthog-js session replay or dead-click capture is failing in production with ERR_BLOCKED_BY_CLIENT or 404s on /static/dead-clicks-autocapture.js / /static/recorder.js / /static/posthog-recorder.js, or when the user wants to bypass ad blockers for these specific assets. Works alongside an existing PostHog reverse proxy (managed or otherwise), only the three blocked files divert through Next.js, all other PostHog traffic stays on the original api_host. SKIP for unrelated PostHog setup, non-Next.js apps, or when capture/decide endpoints (/e/, /decide/, /array/*/config.js) are the ones being blocked, those need a different treatment.

PostHog ad-blocker bypass for Next.js

When to use this

The user has posthog-js working mostly, events, feature flags, decide, config all reach PostHog fine, but session recording and/or dead-click capture aren't working, and DevTools shows:

  • /static/dead-clicks-autocapture.js failing
  • /static/recorder.js or /static/posthog-recorder.js failing
  • ERR_BLOCKED_BY_CLIENT or a synthesized 404 (the file actually returns 200 via curl)

Root cause: ad blockers (uBlock Origin / Brave Shields / AdBlock Plus / EasyPrivacy) match on filename patterns (recorder, autocapture, dead-clicks) regardless of host. A reverse proxy alone doesn't help, renaming on a different host still trips the same filter. Confirmation step: ask the user to disable their ad blocker on the page; if the requests succeed, this skill applies.

This skill applies the surgical fix: only those three files divert through the Next.js app under bland filenames. All other PostHog traffic (events, decide, config, recording uploads) keeps using the existing api_host.

Prerequisites to confirm before implementing

Read the whole SKILL.md on GitHub

More in Engineering