@devries-cameron20 / composio-1 / commits / 2931dacd5
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

docs: emit docs_sidebar_click with sidebar group and depth (#4139)

Evaluating #4099 meant inferring every navigation conclusion from `$pageview` ordering, because the docs app has exactly one `posthog.capture` call and nothing captures sidebar clicks. (`$referring_domain` doesn't help: pageviews are captured manually on client-side route change, so `document.referrer` never updates on internal navigation.) **What the event carries:** `docs_sidebar_click` with `href`, `group` (separator heading), `folder`, `depth`, `position`, and `from_path`. `position` is the row index among visible siblings — a collapsed folder counts as one row, and its children get their own `1..n` sequence — so "clicks land in the top N rows" reads as written. **Why the index comes from the page tree, not the DOM:** separators currently render as `<p>` and folder triggers as `<button>` — fumadocs internals that break on upgrade. `lib/sidebar-nav-index.ts` walks the tree at build time (mirroring `app/llms.txt/route.ts`) and the client does a single delegated listener plus an href lookup. An href that isn't in the index emits nothing rather than a guessed group. `click` and `auxclick` (middle button) are both captured so links opened in a new tab aren't silently dropped. Mounted on the docs, examples, and both reference sidebars. `/toolkits` has no `DocsLayout` sidebar, so there's nothing to instrument there. **Folder-toggle tracking: deferred.** Folder triggers are `<button>`s with no href, so identifying which folder was toggled means matching on text content, and the open/closed state means reading a Radix `data-state` — exactly the DOM guessing this PR avoids. Worth doing if fumadocs gives us a stable hook. **Verification** (from `docs/`): `lint:links`, `test` (219 pass, 10 new), `types:check`, `build` all green; `lint` output matches the `next` baseline exactly. Runtime check against a production build with PostHog pointed at a local sink: - `/docs/triggers` → `group: "Core concepts"`, `folder: null`, `depth: 1`, `position: 4` (its visible row) - `/docs/authentication` (folder row) → `folder: "Authentication"`, `depth: 1`, `position: 3` - `/docs/authentication/manually-authenticating` → `depth: 2`, `position: 1` - middle-click on `/docs/cli` fired; right-click on a sidebar link did not - reference sidebar → `group: null` (that tree has no separators) - clicking an in-body docs link fired a `$pageview` and no `docs_sidebar_click` - built keyless, `process.env.NEXT_PUBLIC_POSTHOG_KEY` is inlined into the effect's guard so no listener is attached; confirmed in the emitted chunk and by the absence of any "You must initialize PostHog before calling posthog.capture" warning after clicking sidebar links 🤖 Generated with [Claude Code](https://claude.com/claude-code)

Kshitij Jhunjhunwala committed Aug 17, 2026 at 14:59 UTC 2931dacd5b4a01f2aae909ccf455d33fc8c61be1

No changes.