From a1f36c9fc82f38de98608fc579f8d3f8eb68e292 Mon Sep 17 00:00:00 2001 From: kleap-admin Date: Thu, 15 Jan 2026 14:29:09 +0000 Subject: [PATCH] Update components/kleap-analytics.tsx --- components/kleap-analytics.tsx | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 components/kleap-analytics.tsx diff --git a/components/kleap-analytics.tsx b/components/kleap-analytics.tsx new file mode 100644 index 0000000..21fa0e6 --- /dev/null +++ b/components/kleap-analytics.tsx @@ -0,0 +1,28 @@ +'use client' + +import { useEffect } from 'react' + +/** + * Kleap Analytics Component + * Loads analytics when configured + * Note: In production, analytics ID will be injected via Vercel deployment + */ +export function KleapAnalytics() { + useEffect(() => { + // Only load analytics when inside an iframe (Kleap environment) + if (typeof window !== 'undefined' && window.parent !== window) { + // In preview mode, we don't have real analytics + // This is just a placeholder for the structure + // Real analytics will be injected during Vercel deployment + + // Add window.kleap.track function for compatibility + (window as any).kleap = (window as any).kleap || {}; + (window as any).kleap.track = function(name: string, data?: any) { + console.debug('[Kleap Analytics]', name, data); + // In production, this will call umami.track + }; + } + }, []); + + return null; +} \ No newline at end of file