Gayatri - Add backend for Job Analytics device-specific engagement metrics (Ticket #34) - #2332
Open
sawantgayatri19 wants to merge 1 commit into
Open
Conversation
…agement metrics (sessions, bounce rate, avg engagement time)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Description
Adds the missing backend endpoint for Ticket #34 (Job Analytics Page - Add Device-Specific Engagement Metrics). This is the companion backend for frontend PR #4998, which currently uses mock data.
New Endpoint
GET /api/applicant-analytics/device-breakdown?startDate=YYYY-MM-DD&endDate=YYYY-MM-DDReturns real, computed per-device engagement metrics from the existing
AnonymousInteractioncollection:Response shape matches exactly what the frontend's
generateMockAnalyticsData().deviceBreakdownalready expects, so wiring it in should be a drop-in replacement of the mock.Related PR
Frontend: #4998 (needs this backend, per its own description: "This frontend PR is not related to any backend PR")
How to test
npm installandnpm run devcurl -H "Authorization: <token>" "http://localhost:4500/api/applicant-analytics/device-breakdown?startDate=2025-08-01&endDate=2025-08-31"Testing
Added 7 new unit tests covering: permission checks, date validation, the core aggregation math (verified against hand-calculated expected values), no-data edge case, and error handling. All existing tests (150/151 suites) and lint pass — the one pre-existing failure (
reasonSchedulingController) is a local MongoDB timeout unrelated to this change.Also manually verified live against the dev database — confirmed real session/bounce-rate/engagement-time data is correctly aggregated and returned.