Attendance Tracking Feature¶
Overview¶
The Attendance feature (/attendance) provides comprehensive tracking of agent attendance, online status, and clock in/out times. This feature is essential for team management, ensuring proper coverage, and monitoring agent availability.
Access Level: Admin/Owner only Status: Production Ready Last Updated: January 2025
Features¶
1. Online Agents Panel¶
Real-Time Online Status: - Live tracking of all online agents in the organization - Online agent count badge - Real-time updates via WebSocket subscriptions - Automatic refresh every 60 seconds - Debounced updates to prevent excessive queries
Agent Information Display: - Agent name and email - Profile avatars with initials fallback - Green status indicators for online agents - Time-ago formatting for last seen timestamps - Visual online status indicators
Performance Optimizations: - Throttled fetching (max once per 5 seconds) - Debounced real-time updates (2 second delay) - Efficient database queries - Optimized for large teams
2. Attendance History Table¶
Comprehensive Attendance Records: - Complete clock in/out tracking - Hours worked calculation - Status indicators (ACTIVE/COMPLETED) - Agent information display - Timestamp formatting
Advanced Filtering: - Search by agent name or email - Filter by status (All, Active, Completed) - Date range filtering: - Today - Last 7 days - Last 30 days - Last 90 days - Real-time search functionality
History Layout: - Collapsible tree grouped by agent → day → session (expand to drill in) - No page-based navigation; the tree loads the filtered range
Bulk Delete: - "Clear Records" / "Delete Filtered" to remove attendance records (cannot be undone)
Data Display: - Formatted dates (MMM d, yyyy) - Formatted times (HH:mm) - Duration in hours and minutes - Status badges with color coding - Agent contact information
3. Automatic Tracking¶
Clock In/Out Automation: - Automatic clock in on user login - Automatic clock out on user logout - No manual intervention required - Duration calculation automatic - Status updates in real-time
Database Integration:
- Attendance logs stored in attendance_logs table
- Online status tracked in profiles table
- Last seen timestamp updates
- Automatic duration calculations
4. Access Control¶
Role-Based Access: - Only ADMIN and OWNER roles can access - Automatic redirect for unauthorized users - Role-based permission checking - Secure data isolation via RLS policies
Organization-Level Data: - Only shows attendance for organization members - Secure data isolation - Multi-tenant support - Privacy protection
Database Schema¶
attendance_logs Table¶
- id: UUID (primary key)
- user_id: UUID (foreign key to auth.users)
- organization_id: UUID (foreign key to organizations)
- clock_in_at: TIMESTAMP WITH TIME ZONE
- clock_out_at: TIMESTAMP WITH TIME ZONE (nullable)
- created_at: TIMESTAMP WITH TIME ZONE
- updated_at: TIMESTAMP WITH TIME ZONE
profiles Table (Extended)¶
attendance_summary View¶
Provides easy access to attendance data with calculated fields: - Hours worked calculation - Status determination (ACTIVE/COMPLETED) - Agent information join - Optimized for reporting
Usage¶
Viewing Attendance¶
- Navigate to Attendance in the sidebar (Admin/Owner only)
- View Online Agents Panel on the left:
- See all currently online agents
- Monitor real-time status
- View last seen timestamps
- View Attendance History Table on the right:
- Browse attendance records
- Filter by date range
- Search by agent name
- Filter by status
Filtering Attendance Records¶
- Search: Enter agent name or email in search box
- Status Filter: Select status (All, Active, Completed)
- Date Range: Select period (Today, Last 7/30/90 days)
- Refresh: Click refresh button to update data
Understanding Status¶
- ACTIVE: Agent is currently clocked in (no clock_out_at)
- COMPLETED: Agent has clocked out (clock_out_at exists)
Security¶
Row Level Security (RLS)¶
- Agents can view their own attendance logs
- Admins/Owners can view all attendance logs in organization
- Service role has full access for automation
- Secure data isolation per organization
Privacy¶
- Attendance data is organization-scoped
- No cross-organization data access
- Secure authentication required
- Audit trail maintained
Benefits¶
- Automatic Tracking: No manual entry required
- Real-Time Visibility: See who's online instantly
- Historical Reporting: Complete attendance history
- Manager Oversight: Track team attendance patterns
- Compliance: Maintain accurate attendance records
- Performance Insights: Analyze attendance patterns
Best Practices¶
- Regular Monitoring: Check attendance dashboard daily
- Filter Usage: Use date range filters for specific periods
- Status Checks: Monitor active sessions regularly
- Export Data: Use attendance data for payroll/HR systems
- Team Communication: Share attendance insights with team
Troubleshooting¶
"No attendance records showing" - Check date range filter - Verify user has clocked in - Ensure correct organization selected
"Online status not updating" - Check real-time subscription - Refresh the page - Verify user is logged in
"Can't access attendance page" - Verify user has ADMIN or OWNER role - Check organization permissions - Contact system administrator
Related Documentation¶
Last Updated: January 2025