UNPKG

visitory-sdk

Version:

Feature flags and analytics SDK for Visitory

22 lines (21 loc) 845 B
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime"; import { useEffect } from 'react'; import { useSessionTracker } from '../hooks/use-session-tracker'; export function SessionTrackerProvider({ children, apiKey, }) { useEffect(() => { if (!apiKey) { console.error('[SessionTrackerProvider] No API key provided'); return; } console.log('[SessionTrackerProvider] Initialized with API key:', apiKey ? 'present' : 'missing'); }, [apiKey]); const { stop } = useSessionTracker(apiKey); // Stop tracking when the component unmounts useEffect(() => { return () => { console.log('[SessionTrackerProvider] Unmounting, stopping session tracker'); stop(); }; }, [stop]); return _jsx(_Fragment, { children: children }); }