Activity and Productivity Tracking
Relevant source files
The following files were used as context for generating this wiki page: - [README.md](https://github.com/ever-co/ever-teams/blob/HEAD/README.md) - [apps/web/app/[locale]/(main)/dashboard/app-url/[teamId]/page.tsx](https://github.com/ever-co/ever-teams/blob/HEAD/apps/web/app/%5Blocale%5D/(main)/dashboard/app-url/[teamId]/page.tsx) - [apps/web/core/components/pages/dashboard/app-url/productivity-pdf.tsx](https://github.com/ever-co/ever-teams/blob/HEAD/apps/web/core/components/pages/dashboard/app-url/productivity-pdf.tsx) - [apps/web/core/components/pages/dashboard/pdf/index.tsx](https://github.com/ever-co/ever-teams/blob/HEAD/apps/web/core/components/pages/dashboard/pdf/index.tsx) - [apps/web/core/components/pages/time-and-activity/export/time-activity-export-menu.tsx](https://github.com/ever-co/ever-teams/blob/HEAD/apps/web/core/components/pages/time-and-activity/export/time-activity-export-menu.tsx) - [apps/web/core/components/pages/time-and-activity/export/time-activity-pdf.tsx](https://github.com/ever-co/ever-teams/blob/HEAD/apps/web/core/components/pages/time-and-activity/export/time-activity-pdf.tsx) - [apps/web/core/services/client/api/timesheets/time-log.service.ts](https://github.com/ever-co/ever-teams/blob/HEAD/apps/web/core/services/client/api/timesheets/time-log.service.ts) - [apps/web/core/hooks/activities/use-report-activity.ts](https://github.com/ever-co/ever-teams/blob/HEAD/apps/web/core/hooks/activities/use-report-activity.ts) - [apps/web/app/api/timesheet/activity/report/route.ts](https://github.com/ever-co/ever-teams/blob/HEAD/apps/web/app/api/timesheet/activity/report/route.ts) - [apps/web/core/components/pages/dashboard/app-url/productivity-application/productivity-application-pdf.tsx](https://github.com/ever-co/ever-teams/blob/HEAD/apps/web/core/components/pages/dashboard/app-url/productivity-application/productivity-application-pdf.tsx)The Activity and Productivity Tracking system is a core feature of the Ever Teams platform, designed to provide insights into workforce performance. It encompasses time tracking, activity monitoring (including apps and URLs), and the generation of detailed productivity metrics. This system allows managers and employees to view and analyze work patterns, understand time allocation across different projects and tasks, and export this data for reporting purposes.
The functionality is primarily accessed through the "Time & Activity" and "Apps & URLs" dashboards, which present data in various formats, including tables, charts, and downloadable PDF reports. The system is built to be flexible, allowing data to be grouped by date, project, employee, or application.
Sources: README.md, apps/web/app/[locale]/(main)/dashboard/app-url/[teamId]/page.tsx
System Architecture
The tracking system follows a client-server architecture. The frontend, built with Next.js and React, is responsible for user interaction, state management, and rendering data. The backend provides API endpoints to fetch processed activity and time log data.
Data Flow
The following diagram illustrates the typical data flow when a user requests an activity report from the dashboard.
This sequence shows how user actions on the frontend trigger a chain of calls through a custom hook, a client-side service, and a Next.js API route to finally fetch data from the main backend.
Sources: apps/web/app/[locale]/(main)/dashboard/app-url/[teamId]/page.tsx:60-63, apps/web/core/hooks/activities/use-report-activity.ts:31-43, apps/web/core/services/client/api/timesheets/time-log.service.ts:180-221, apps/web/app/api/timesheet/activity/report/route.ts:18-29
Data Fetching and State Management
Client-side data fetching and state management for activity reports are centralized in the useReportActivity custom hook.
Sources: apps/web/core/hooks/activities/use-report-activity.ts
useReportActivity Hook
This hook is the primary interface for UI components to interact with the activity reporting data. It encapsulates the logic for fetching data, managing filters, and handling loading states.
Key Properties and Functions:
| Name | Type | Description |
|---|---|---|
activityReport | IActivityReportGroupByDate[] | The fetched and structured report data. |
loading | boolean | Indicates if a data fetch is in progress. |
currentFilters | FilterState | Holds the current state of filters (dates, projects, employees, etc.). |
fetchActivityReport() | function | Triggers a refetch of the activity report using the currentFilters. |
handleGroupByChange() | function | Updates the grouping type (e.g., 'date', 'project') and refetches data. |
updateDateRange() | function | Updates the start and end dates in the filter state. |
updateFilters() | function | Updates other filter criteria like project or employee IDs. |
The hook is initialized with a types parameter, such as 'APPS-URLS', which specifies the kind of activity to be fetched.
Sources: apps/web/core/hooks/activities/use-report-activity.ts:20-80, apps/web/app/[locale]/(main)/dashboard/app-url/[teamId]/page.tsx:58-66
TimeLogService
The TimeLogService acts as the client-side layer for making API requests related to time logs and reports. The useReportActivity hook utilizes this service to fetch data.
Key Methods:
getTimerLogsDailyReport(params): Fetches a daily report of time logs. It constructs a query string with parameters liketenantId,organizationId,employeeIds, date range, and activity levels. The response is validated against a Zod schema (timeLogReportDailySchema).getTimeLogReportDaily(params): A similar method that fetches a daily report, but with more grouping and filtering capabilities. It is used for generating detailed, grouped reports.addManualTime(request): Allows for the manual submission of time logs.
Sources: apps/web/core/services/client/api/timesheets/time-log.service.ts:51-95, 180-221
API Endpoint
The primary API endpoint for fetching activity data is a Next.js API route.
GET /api/timesheet/activity/report
This endpoint serves as a proxy or wrapper around the main Gauzy backend API. It receives filter parameters from the client, forwards them to the backend service, and returns the data.
Query Parameters:
| Parameter | Type | Description |
|---|---|---|
startDate | string | The start date for the report period. |
endDate | string | The end date for the report period. |
projectIds[] | string[] | Array of project IDs to filter by. |
employeeIds[] | string[] | Array of employee IDs to filter by. |
teamIds[] | string[] | Array of team IDs to filter by. |
organizationId | string | The ID of the organization. |
tenantId | string | The ID of the tenant. |
types | string | The type of activity to report (e.g., 'APPS-URLS'). |
groupBy | string | The field to group the results by (e.g., 'date', 'project'). |
Sources: apps/web/app/api/timesheet/activity/report/route.ts:10-17
Data Models
The activity and productivity data is structured using a set of nested interfaces. The diagram below shows the relationships between the main data entities used in the reports.
This ER diagram shows that a daily report (IActivityReportGroupByDate) contains multiple employees, each with a list of projects they worked on, and each project contains a list of specific activities.
Sources: apps/web/core/components/pages/dashboard/app-url/productivity-pdf.tsx:4-7, apps/web/core/components/pages/dashboard/app-url/productivity-application/productivity-application-pdf.tsx:6-10
UI and Visualization
The "Apps & URLs" dashboard is the main interface for viewing productivity data. It is composed of several key components that allow for filtering, grouping, and visualizing the information.
Sources: apps/web/app/[locale]/(main)/dashboard/app-url/[teamId]/page.tsx
Dashboard Page
The page at apps/web/app/[locale]/(main)/dashboard/app-url/[teamId]/page.tsx orchestrates the display of the productivity dashboard. It uses the useReportActivity hook to fetch data and dynamically renders different table views based on the selected groupByType.
Grouped Data Tables
Depending on the groupByType state, one of the following table components is rendered to display the activity report:
| Component | groupByType Value | Description |
|---|---|---|
ProductivityTable | date | Displays activity data grouped by date. |
ProductivityProjectTable | project | Displays activity data grouped by project. |
ProductivityEmployeeTable | employee, member | Displays activity data grouped by employee. |
ProductivityApplicationTable | application | Displays activity data grouped by application. |
Sources: apps/web/app/[locale]/(main)/dashboard/app-url/[teamId]/page.tsx:216-235
Charts and Statistics
The dashboard also includes visual elements to summarize productivity at a glance:
LazyProductivityHeader: Displays the current month and year for the report.LazyProductivityStats: Shows a breakdown of productive, neutral, and unproductive time as percentages.LazyProductivityChart: A chart that visualizes productivity data over the selected period.
Sources: apps/web/app/[locale]/(main)/dashboard/app-url/[teamId]/page.tsx:201-211
Reporting and Exporting
A key feature of the activity tracking system is the ability to export reports as PDF files. This is handled by dedicated React components that use the @react-pdf/renderer library.
Export Menu
The TimeActivityExportMenu component provides a dropdown menu with options to export data. Currently, it supports PDF export, with disabled options for CSV and XLSX.
The menu generates a filename for the export dynamically using the report type and date range.
Sources: apps/web/core/components/pages/time-and-activity/export/time-activity-export-menu.tsx:215-217
PDF Generation
Several components are responsible for rendering different types of PDF reports:
ProductivityPDF: Creates a detailed activity report. It groups data by date and includes a comprehensive "Performance Summary" section with statistics like total working hours, total activities, top performer, and most active project.ProductivityApplicationPDF: Generates a report grouped by application/activity title. For each application, it lists the date, project, member, time spent, and percentage of time used.TimeActivityPDF: A general-purpose PDF component for time and activity. It displays a flat table of activities with columns for date, member, project, task, hours, earnings, and activity level. It also includes summary statistics and a list of applied filters.TeamStatsPDF: Creates a PDF report for team statistics, showing metrics like total time, tracked time, manual time, and activity levels for each member, grouped by date.
This diagram shows the flow for generating a PDF report.
Sources: apps/web/core/components/pages/dashboard/app-url/productivity-pdf.tsx, apps/web/core/components/pages/dashboard/app-url/productivity-application/productivity-application-pdf.tsx, apps/web/core/components/pages/time-and-activity/export/time-activity-pdf.tsx, apps/web/core/components/pages/dashboard/pdf/index.tsx
Conclusion
The Activity and Productivity Tracking system is a comprehensive module within Ever Teams that provides powerful tools for monitoring and analyzing work. It integrates client-side state management with backend data services to deliver responsive dashboards with flexible grouping and filtering. The inclusion of robust PDF exporting capabilities makes it a vital tool for performance reviews, client billing, and project management reporting.