Sign in Get 3 free credits

Try a job or a niche: tiktok captions, study notes, excel formulas. Press Esc to close.

PostHog ad blocker fix

Keeps PostHog session replay and dead click capture working on a Next.js site when visitors block ads.

Claude's review

8/10 Specific, well-scoped fix with code, prerequisites, verification and pitfalls.

We asked Claude the question you would ask: would I be glad I installed this? We only sell skills it rates 7 or higher.

In detail

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.

How you use it

  1. Add it to your pack, then download your pack (1 credit).
  2. In Claude, open Customize > Skills and upload the zip. Code execution needs to be on under Settings > Capabilities.
  3. Ask Claude for the job in your own words. It uses the skill when your request matches what it does. Step by step guide

Safety check

Nothing risky found: no hidden instructions, no download and run, no reading of saved passwords or keys.

An automated scan lowers risk but cannot promise zero risk. How we check skills

Preview

The first lines of SKILL.md
---
name: posthog-adblock-bypass
description: 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

1. The project is **Next.js** (App Router or Pages Router both fine) with `posthog-js` from npm.
2. Server-side: `curl -I https://<api_host>/static/dead-clicks-autocapture.js?v=1.x` returns 200. If it returns 404, the upstream proxy is misconfigured — **fix that first**, this skill won't help.
3. Identify the **PostHog cloud region**: US (`us-assets.i.posthog.com`) or EU (`eu-assets.i.posthog.com`). Default to US if unclear, but ask.
4. Locate the existing `posthog.init(...)` call (commonly `src/lib/posthog.ts`, a provider component, or `app/layout.tsx`). Note the file so you can hook the rewriter before init.
5. **Session replay must be enabled in the PostHog project dashboard** (Settings → Project → Session replay → "Record user sessions"). If it's off, posthog-js never even tries to load the recorder, so this skill produces no visible effect. Surface this check to the user.

## Implementation — three changes

### 1. Add rewrites to `next.config.{ts,js,mjs}`

Insert a `rewrites()` block. Use `/_p/` as the alias prefix (or any path that doesn't contain words like `recorder`, `analytics`, `tracking`, `posthog`).

```ts
import type { NextConfig } from "next";

const PH_ASSETS = "https://us-assets.i.posthog.com"; // EU: "https://eu-assets.i.posthog.com"

const nextConfig: NextConfig = {
  // ...existing config...
...

From Leanmcp's repository, MIT licence.

Related skills

  • Checked

    TinyBase app builder

    Scaffolds and extends local first JavaScript apps with TinyBase, including schemas, persistence and sync.

    by tinyplex 5.2k
    7/101 credit
  • Checked

    ComfyUI custom node UI

    Adds widgets, sidebar tabs, commands and dialogs to ComfyUI custom nodes, so your node feels built in.

    by jtydhr88 325
    8/101 credit
  • Checked

    Scrolling menu upgrade

    Finds outdated react-horizontal-scrolling-menu code and rewrites it for version 8 so the menu works again.

    by asmyshlyaev177 789
    7/101 credit
  • Checked

    Screenshot to React code

    Rebuilds a screenshot or mockup as React, TypeScript and Tailwind code that closely matches the design.

    by buildfastwithai 792
    7/101 credit
  • Checked

    Map location picker

    Adds a map pin picker to a web form, so users can choose and submit one exact spot like a delivery address.

    by cyphercodes 84
    7/101 credit
  • Checked

    Port code to Rust

    Ports C, C++, Python, Go or JavaScript code into idiomatic Rust, with tests that prove it behaves the same.

    by morganlinton 2.2k
    9/101 credit

Secure checkout

Credits

AUD

  1. 1Choose
  2. 2Pay on Square
  3. 3Credits added