Skip to content

Commit 40fb09c

Browse files
committed
feat(shell-docs): instrument framework selector with PostHog event
Fires framework_selected when a user picks a framework so the docs funnel can attribute drop-off to specific frameworks. Net-new event (no upstream equivalent in docs/).
1 parent 5f7974a commit 40fb09c

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

showcase/shell-docs/src/components/framework-selector.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import React, { useEffect, useRef, useState } from "react";
1111
import { usePathname, useRouter } from "next/navigation";
12+
import posthog from "posthog-js";
1213
import { useFramework } from "./framework-provider";
1314
import { FrameworkLogo } from "./icons/framework-icons";
1415

@@ -150,6 +151,21 @@ export function FrameworkSelector({
150151

151152
function selectFramework(slug: string) {
152153
setStoredFramework(slug);
154+
// Fire a PostHog event so analytics dashboards can see which
155+
// backend readers pick. Wrapped in try/catch — PostHog can be
156+
// blocked by ad blockers or fail to initialize, and a broken
157+
// analytics call must never break navigation.
158+
try {
159+
const opt = options.find((o) => o.slug === slug);
160+
posthog.capture("framework_selected", {
161+
framework: slug,
162+
framework_name: opt?.name ?? slug,
163+
category: opt?.category,
164+
from_path: pathname,
165+
});
166+
} catch {
167+
// Swallow — analytics is fire-and-forget.
168+
}
153169
// replace vs push: picking a backend is a pivot on the same logical
154170
// page, not a forward navigation. Using `push` clutters the back
155171
// stack with every framework the user clicked through, which makes

0 commit comments

Comments
 (0)