Skip to content

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)

- is_online: BOOLEAN (default: false)
- last_seen_at: TIMESTAMP WITH TIME ZONE

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

  1. Navigate to Attendance in the sidebar (Admin/Owner only)
  2. View Online Agents Panel on the left:
  3. See all currently online agents
  4. Monitor real-time status
  5. View last seen timestamps
  6. View Attendance History Table on the right:
  7. Browse attendance records
  8. Filter by date range
  9. Search by agent name
  10. Filter by status

Filtering Attendance Records

  1. Search: Enter agent name or email in search box
  2. Status Filter: Select status (All, Active, Completed)
  3. Date Range: Select period (Today, Last 7/30/90 days)
  4. 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

  1. Automatic Tracking: No manual entry required
  2. Real-Time Visibility: See who's online instantly
  3. Historical Reporting: Complete attendance history
  4. Manager Oversight: Track team attendance patterns
  5. Compliance: Maintain accurate attendance records
  6. Performance Insights: Analyze attendance patterns

Best Practices

  1. Regular Monitoring: Check attendance dashboard daily
  2. Filter Usage: Use date range filters for specific periods
  3. Status Checks: Monitor active sessions regularly
  4. Export Data: Use attendance data for payroll/HR systems
  5. 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



Last Updated: January 2025