Repository navigation
Harden admin metrics cohorts/usage aggregation and enforce router-level admin guard - #167
Conversation
Agent-Logs-Url: https://github.com/geturbackend/urBackend/sessions/0a7698b2-c6e4-4cb8-9bed-bde65040ddbd Co-authored-by: yash-pouranik <172860064+yash-pouranik@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR hardens admin metrics endpoints by centralizing admin authorization and reduces feature-usage aggregation memory risk while clarifying reliability alert documentation.
Changes:
- Applies
authMiddlewareandrequireAdminat the admin metrics router level. - Converts feature-usage unique developer counting to a
$facetwith$count. - Updates the reliability alert comment to match the actual
>=5%threshold.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
apps/dashboard-api/src/routes/admin.metrics.js |
Adds router-level authentication and admin middleware for all metrics routes. |
apps/dashboard-api/src/controllers/admin.metrics.controller.js |
Exports requireAdmin as middleware and updates feature-usage aggregation. |
packages/common/src/queues/reliabilityAlertQueue.js |
Corrects the reliability threshold comment. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@coderabbitai |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 8918
✅ All Clear
|
The metrics follow-up identified cohort inflation, N+1 retention checks, and aggregation memory risk, plus a missing router-level admin guard and a misleading reliability alert comment.
Admin metrics authorization
requireAdminat the router level so all/api/admin/metrics/*endpoints are covered by default.Feature-usage aggregation safety
$addToSet-based unique developer tracking with a$facet+$countapproach to avoid aggregation memory pressure while preserving totals.Reliability alert clarity
>=20requests />=5%error rate logic.Example (feature-usage aggregation change):