mirror of
https://github.com/ComposioHQ/composio.git
synced 2026-09-22 11:46:35 +08:00
fe623da434
The docs app had exactly one posthog.capture call ($pageview), so any question about how people move through the sidebar had to be answered by reverse-engineering pageview ordering within a session. $referring_domain is no help either: pageviews are captured manually on client-side route change, so document.referrer never updates on internal navigation. Adds a docs_sidebar_click event carrying href, group, folder, depth, position and from_path. Group/folder/depth are derived from the fumadocs page tree at build time and the click handler only does an href lookup — reading them off the rendered sidebar would mean depending on separators being <p> and folder triggers being <button>, which is fumadocs-internal and breaks on upgrade. Mounted on the docs, examples and both reference sidebars. Nothing fires when PostHog is unconfigured, for non-sidebar links, or for an href that is not in the index. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
26 lines
821 B
TypeScript
26 lines
821 B
TypeScript
import { DocsLayout } from 'fumadocs-ui/layouts/docs';
|
|
import type { ReactNode } from 'react';
|
|
import { buildSidebarNavIndex } from './sidebar-nav-index';
|
|
import { SidebarAnalytics } from '@/components/sidebar-analytics';
|
|
|
|
type Source = typeof import('./source').examplesSource;
|
|
|
|
export function createDocsLayout(source: Source) {
|
|
const navIndex = buildSidebarNavIndex(source.pageTree);
|
|
|
|
return function Layout({ children }: { children: ReactNode }) {
|
|
return (
|
|
<DocsLayout
|
|
tree={source.pageTree}
|
|
nav={{ enabled: true, title: null }}
|
|
searchToggle={{ enabled: false }}
|
|
sidebar={{ collapsible: false, footer: null, tabs: false }}
|
|
themeSwitch={{ enabled: false }}
|
|
>
|
|
<SidebarAnalytics index={navIndex} />
|
|
{children}
|
|
</DocsLayout>
|
|
);
|
|
};
|
|
}
|