Repository navigation
Build the line analytics dashboard (W7-09) - #169
Merged
Merged
Conversation
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.
Coordinators need numbers for grant reports and for deciding on hours (TDD 4.6.9). The line analytics API and CSV export landed in #167 (for #142), but
/portal/admin/analyticswas still a placeholder. This replaces it with a dashboard built on those endpoints.Changes:
AnalyticsDashboard(components/admin/AnalyticsDashboard.tsx) and used it on the Analytics page, inside<Suspense>because it reads the URL withuseSearchParams.?range=,start/endfor custom only,channel=) and updated withrouter.replace. No params means last 30 days, which matches the API default. A custom range that's over 366 days, or has the start after the end, shows an inline error and sends no request.formatDurationhelper (lib/dates.ts), e.g. "2m 30s", "1h 5m", and "—" for null.aria-hidden, with a visually hidden table that carries the same data for screen readers.suppression_threshold. The API drops those groups without listing them, so the note can't be shown only when something was actually dropped. A null confidence average gets its own note./api/admin/analytics/line.csvwith the currentstart/end. The CSV endpoint doesn't takechannel, so the export always covers all channels, and the page says so when a channel is selected.NEXT_PUBLIC_WEBSITE_ANALYTICS_URLis set. It's documented in.env.exampleso Add privacy-safe website analytics (W7-11) #164 can set it.LineAnalyticstype and auseLineAnalyticshook tolib/portal/queries.ts. The type is written by hand, like the others there, becauseapi-types.tspredates the analytics DTO.Charts: this adds Recharts (
npm install recharts), confirming TDD open question 15.Tests, with a mocked response: the tiles show formatted durations; the range and channel controls change both the request and the URL; a custom range is read from the URL, and one over 366 days is rejected without a request; the small-group and confidence notes appear; the CSV link carries the current range; the website analytics link stays hidden when it isn't configured. There are also unit tests for the new date helpers. Frontend lint, typecheck, format check, the full Vitest suite and
next buildpass. There are no backend changes.Follow-up:
channelto the CSV endpoint if coordinators want per-channel exports.Screenshots (also committed under
docs/screenshots/analytics-dashboard/), using fixture data and a synthetic coordinator session:The last one shows the small-group notes, the suppressed confidence average, and the note that the CSV covers all channels. The header says "Reconnecting…" only because the portal socket was blocked during capture.
Closes #162