Add active hours metric #45
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request adds support for tracking and displaying "active hours"—the sum of actual user interaction time (excluding idle time) as reported by the Coder Insights API—across workspace, team, and template analytics. The backend collection script is updated to fetch and enrich workspaces with active hours, and the frontend is updated to show and sort by this new metric in relevant tables. These changes provide a more accurate view of user engagement beyond simple connection time.
Backend: Collection and Data Enrichment
fetch_user_activity_insightsfunction toscripts/collect_coder_analytics.pyto retrieve active hours per user from the Coder Insights API and integrated this data into workspace enrichment. [1] [2] [3]metrics.tsto includeactive_hoursin workspace, team, and template metrics. [1] [2] [3] [4] [5] [6] [7]Data Types and Interfaces
active_hoursfield toCoderWorkspace,WorkspaceMetrics,TeamMetrics, andTemplateMetricsinterfaces intypes.tsto support the new metric throughout the codebase. [1] [2] [3] [4]Frontend: Display and Sorting
Documentation and Messaging
These changes collectively enable a more meaningful analysis of workspace usage by distinguishing actual user engagement from mere connection time.