import { useEffect, useState } from 'react';
import { getAnalytics } from '../core/AnalyticsManager';
import type { SessionInfo } from '../types';
/**
* Returns live session info — refreshes whenever the component renders.
*
* ```tsx
* function DebugScreen() {
* const session = useSession();
* return Session: {session?.sessionId};
* }
* ```
*/
export function useSession(): SessionInfo | null {
const [session, setSession] = useState(null);
useEffect(() => {
try {
setSession(getAnalytics().getSession());
} catch {
// Analytics not initialized yet
}
}, []);
return session;
}