From d3dc1439cc0ea372ca596eeb5f68d8a0ba1413cb Mon Sep 17 00:00:00 2001 From: Louis Knight-Webb Date: Sat, 10 Jan 2026 12:02:09 +0000 Subject: [PATCH] Add PostHog analytics event for new UI access (Vibe Kanban) (#1895) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Done. I've added PostHog analytics tracking to `NewDesignScope.tsx` that fires a `ui_new_accessed` event once per session when users visit any `/workspaces` route. The implementation: - Fires the event only once per session (using a `useRef` that resets on page refresh) - Respects the user's analytics opt-in/opt-out preferences (handled by PostHog SDK) - Located in `NewDesignScope` which wraps all new UI routes * Use sessionStorage for true once-per-session tracking The useRef approach only prevented duplicates within a single mount lifecycle. If the user navigated away from /workspaces and back, the component would remount and the ref would reset, firing the event again. sessionStorage persists for the entire browser tab lifetime, ensuring the event fires exactly once per session. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 * Revert to useRef for tracking 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --------- Co-authored-by: Claude Opus 4.5 --- .../src/components/ui-new/scope/NewDesignScope.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/ui-new/scope/NewDesignScope.tsx b/frontend/src/components/ui-new/scope/NewDesignScope.tsx index cd24ee16..ef3d387c 100644 --- a/frontend/src/components/ui-new/scope/NewDesignScope.tsx +++ b/frontend/src/components/ui-new/scope/NewDesignScope.tsx @@ -1,4 +1,5 @@ -import { ReactNode, useRef } from 'react'; +import { ReactNode, useRef, useEffect } from 'react'; +import { usePostHog } from 'posthog-js/react'; import { PortalContainerContext } from '@/contexts/PortalContainerContext'; import { WorkspaceProvider, @@ -29,6 +30,16 @@ function ExecutionProcessesProviderWrapper({ export function NewDesignScope({ children }: NewDesignScopeProps) { const ref = useRef(null); + const posthog = usePostHog(); + const hasTracked = useRef(false); + + useEffect(() => { + if (!hasTracked.current) { + posthog?.capture('ui_new_accessed'); + hasTracked.current = true; + } + }, [posthog]); + return (