This directory contains custom React hooks that encapsulate stateful logic and side effects.
Handles authentication and authorization logic.
Returns: UseAuthReturn
userEmail
- Current user's email from window dataisAuthorized(pageProperties)
- Function to check if user can access a pageUsage:
const { userEmail, isAuthorized } = useAuth();
const canView = isAuthorized(pageProperties);
Manages glimpse data fetching and state.
Parameters:
glimpseId
- ID of the glimpse to fetchinitialData
- Optional initial data to avoid refetchingReturns: UseGlimpseDataReturn
data
- Current glimpse dataloading
- Loading stateerror
- Error staterefetch
- Function to manually refetch dataUsage:
const { data, loading, error, refetch } = useGlimpseData(glimpseId, initialData);
Manages agent data fetching with automatic polling.
Parameters:
glimpseId
- ID of the glimpseisAuthorized
- Whether user is authorized (controls polling)Returns: UseAgentDataReturn
agentData
- Current agent datahasAgents
- Boolean indicating if agents existUsage:
const { agentData, hasAgents } = useAgentData(glimpseId, isAuthorized);
Handles viewing status tracking with automatic updates and reliable session ending.
Parameters:
glimpseId
- ID of the glimpse being viewedisAuthorized
- Whether user is authorized (controls tracking)Side Effects:
Session Tracking:
sendBeacon
API for reliable session ending during page unloadUsage:
useViewingTracking(glimpseId, isAuthorized);