File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020 "@dnd-kit/sortable" : " ^10.0.0" ,
2121 "@dnd-kit/utilities" : " ^3.2.2" ,
2222 "@hookform/resolvers" : " ^3" ,
23+ "@microsoft/clarity" : " ^1.0.2" ,
2324 "@monaco-editor/react" : " ^4.7.0" ,
2425 "@peculiar/x509" : " ^2.0.0" ,
2526 "@radix-ui/react-accordion" : " ^1.2.12" ,
Original file line number Diff line number Diff line change 1+ "use client"
2+
3+ import { useEffect } from "react"
4+
5+ // Microsoft Clarity heatmaps + session replays. No-op unless
6+ // NEXT_PUBLIC_CLARITY_PROJECT_ID is set (so it stays off in local dev),
7+ // matching how Vercel Analytics only reports in production.
8+ // Data lives in clarity.microsoft.com — nothing touches our backend.
9+ let initialized = false // ponytail: module guard so StrictMode/remounts can't double-inject the script
10+
11+ export function ClarityAnalytics ( ) {
12+ useEffect ( ( ) => {
13+ const projectId = process . env . NEXT_PUBLIC_CLARITY_PROJECT_ID
14+ if ( ! projectId || initialized ) return
15+ initialized = true
16+ import ( "@microsoft/clarity" ) . then ( ( m ) => m . default . init ( projectId ) )
17+ } , [ ] )
18+
19+ return null
20+ }
Original file line number Diff line number Diff line change @@ -20,6 +20,10 @@ const ClientSpeedInsights = dynamic(
2020 ( ) => import ( '@vercel/speed-insights/next' ) . then ( ( m ) => m . SpeedInsights ) ,
2121 { ssr : false }
2222)
23+ const ClientClarity = dynamic (
24+ ( ) => import ( '@/components/clarity-analytics' ) . then ( ( m ) => m . ClarityAnalytics ) ,
25+ { ssr : false }
26+ )
2327const ClientToaster = dynamic (
2428 ( ) => import ( '@/components/branded-toaster' ) . then ( ( m ) => m . BrandedToaster ) ,
2529 { ssr : false }
@@ -47,6 +51,9 @@ export function ClientShell({ children }: Props) {
4751 < Suspense fallback = { null } >
4852 < ClientSpeedInsights />
4953 </ Suspense >
54+ < Suspense fallback = { null } >
55+ < ClientClarity />
56+ </ Suspense >
5057 < Suspense fallback = { null } >
5158 < ClientToaster />
5259 </ Suspense >
You can’t perform that action at this time.
0 commit comments