GET /api/components/stats
Retrieves aggregated statistics about component usage and interactions. This endpoint provides insights into which components are most popular, what actions users perform, and the distribution between anonymous and registered users.Endpoint
Response Fields
Indicates if the statistics were retrieved successfully
Aggregated statistics data
Response Example
200 - Success
Example Request
Error Codes
| Code | Message | Cause |
|---|---|---|
500 | Error interno del servidor | Database error or aggregation failure |
Data Insights
Total Interactions
Provides a quick overview of overall component library usage. Useful for tracking growth and engagement over time.By Component (porComponente)
- Limited to top 10 components to focus on most popular items
- Sorted by count in descending order
- Helps identify which components are most valuable to users
- Can guide prioritization for component improvements and documentation
By Action (porAccion)
- Shows every unique component-action combination
- Sorted alphabetically by component name, then by count
- Reveals how users interact with each component
- Example insights:
- High “hover” counts may indicate users exploring functionality
- High “click” counts show active engagement
- Modal “open” vs “close” ratios can reveal UX issues
By User Type (porTipoUsuario)
- Compares anonymous vs registered user engagement
- Helps understand authentication impact on usage
- Can inform decisions about feature gating or user experience
Implementation Details
The statistics are calculated using MongoDB aggregation pipelines:- Total Interactions: Simple document count (tracking.service.ts:51)
- By Component: Groups by component name, limits to 10 results (tracking.service.ts:52-56)
- By Action: Groups by component and action combination (tracking.service.ts:57-60)
- By User Type: Groups by user type field (tracking.service.ts:61-63)
Use Cases
- Dashboard Visualization: Display real-time component usage metrics
- Product Analytics: Identify most/least popular components
- UX Research: Understand user interaction patterns
- Resource Allocation: Prioritize development based on usage data
- Marketing: Showcase popular components to potential users