Skip to content

feat(analytics): add dotAnalyticsCount pipe and bar chart accessibility#35744

Queued
nicobytes wants to merge 9 commits into
mainfrom
34849-dashboard-details
Queued

feat(analytics): add dotAnalyticsCount pipe and bar chart accessibility#35744
nicobytes wants to merge 9 commits into
mainfrom
34849-dashboard-details

Conversation

@nicobytes
Copy link
Copy Markdown
Member

@nicobytes nicobytes commented May 19, 2026

This pull request introduces a reusable formatting utility and pipe for displaying analytics count values in both compact (e.g., 1.1K) and full (e.g., 1,128) formats across the analytics dashboard. It refactors existing components to use this new pipe, improving consistency and simplifying code. It also updates tests and adds new ones to ensure correct formatting. Additionally, there are minor UI adjustments to paginator controls in detail dialogs.

Analytics count formatting improvements:

  • Added formatAnalyticsCount utility and DotAnalyticsCountPipe to provide consistent compact and full formatting for analytics counts (sessions, views, tooltips), with comprehensive unit tests.
  • Refactored dot-analytics-bar-engagement-chart, dot-analytics-stacked-bar, and detail-table dialogs to use the new pipe, removing redundant formatting methods.
  • Updated and added component tests to validate compact notation usage in the UI.

Bar chart accessibility:

  • Added tooltips and improved aria-labels on pageview bar chart rows for clearer hover context and screen reader support.

UI/UX adjustments:

  • Simplified paginator controls in engagement and pageview detail dialogs by hiding page report and jump-to-page dropdowns.

Paginator UX: Page report and jump-to-page controls are intentionally hidden in detail dialogs to reduce visual clutter. Row-per-page selector remains available.

Code cleanup:

  • Minor import ordering fix in constants file.

This PR fixes: #34849

…ormatting

This update introduces the `DotAnalyticsCountPipe`, which formats session counts in both compact and full notation. The pipe is integrated into the `dot-analytics-bar-engagement-chart` and `dot-analytics-stacked-bar` components, replacing the previous formatting methods. Additionally, unit tests for the new pipe and related utility functions have been added to ensure correct functionality.

Changes include:
- Replaced `formatSessionsCount` with `dotAnalyticsCount` pipe in relevant components.
- Added tests for the `DotAnalyticsCountPipe` to validate formatting behavior.
- Updated HTML templates to utilize the new pipe for session count display.

This enhancement improves the clarity and consistency of session count representations across the analytics dashboard.
…cessibility improvements

This update introduces tooltips for the bar chart rows in the DotAnalyticsBarChartComponent, providing users with additional context on view counts. The aria-labels for each row have also been improved for better accessibility.

Changes include:
- Added `viewsTooltip` method to format view counts for tooltips.
- Implemented `rowAriaLabel` method to create accessible labels for each bar row.
- Enhanced mouse enter/leave events to activate/deactivate tooltips on hover.
- Updated HTML template to include aria-labels and tooltip attributes.
- Expanded unit tests to cover new tooltip functionality and accessibility features.

These enhancements improve user experience by providing clearer information and ensuring compliance with accessibility standards.
@github-actions github-actions Bot added the Area : Frontend PR changes Angular/TypeScript frontend code label May 19, 2026
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 19, 2026

Claude finished @nicobytes's task in 2m 26s —— View job


Claude PR Review

  • Read the new utility + pipe and their tests
  • Review refactored chart components
  • Check accessibility/template changes (bar chart, stacked bar)
  • Check dialog paginator changes
  • Spot-check existing review comment from @oidacra
  • Post final review

The PR is clean — small, well-tested, mostly mechanical. The four removed i18n keys (legend.engaged, legend.not-engaged, sessions-label, session-label) have no remaining references in core-web, so the deletion is safe. The new pipe/util pair is sensibly scoped and null/undefined/non-finite/negative inputs all coerce to '0'. @oidacra's first comment (use triggerEventHandler instead of calling onRowMouseEnter directly) is already addressed by dot-analytics-bar-chart.component.spec.ts:90.

A few things worth a second look — none blocking:

1. Locale coupling in testsIntl.NumberFormat(undefined, { notation: 'compact' }) emits localized suffixes (K, Mio., , etc.). Tests assert toMatch(/K/i) and toMatch(/M/i), which only hold under en-ish locales. Jest defaults to en-US so this passes today, but if CI ever changes the locale these will silently regress. Consider passing an explicit locale (e.g. 'en-US') inside formatAnalyticsCount, or asserting on the formatted string returned by Intl itself rather than a hard-coded /K/. Same concern applies to the thousand-separator assumption (toContain('128') survives both '1,128' and '1.128', so that one is fine).

2. Soft negative assertions — a couple of tests only check what the output isn't: dot-analytics-bar-engagement-chart.component.spec.ts:230-232 (not.toContain('1,128'), not.toContain('1128'), not.toContain('sess.')) and :251-252 (not.toBe('320000'), length-only). If the formatter ever returns '' or 'NaN', these tests still pass. A positive assertion like expect(visibleText).toMatch(/\d+(\.\d+)?\s*[KM]/i) would actually pin the behavior. Fix this →

3. Mixed locale + hardcoded English in tooltipsanalytics.engagement.charts.multi-sessions-tooltip={0} sessions is fixed English while {0} is locale-formatted by Intl.NumberFormat. Under a German UI you'd get "1.128 sessions" — a small i18n inconsistency. This matches existing dotCMS i18n patterns, so not a regression; just calling it out.

4. Redundant roundingformatAnalyticsCount does Math.round(value) and then passes maximumFractionDigits: 0 to Intl.NumberFormat. The second is unnecessary once you've already rounded. Harmless.

5. progressAriaLabel(row) invoked from template in dot-analytics-pageview-detail-table-dialog.component.html:51 — re-runs every change detection. Fine at 10 rows/page; not worth restructuring.

Nothing risky. LGTM.
· Branch

@github-actions github-actions Bot added the Area : Backend PR changes Java/Maven backend code label May 19, 2026
@nicobytes nicobytes changed the title feat(analytics): implement dotAnalyticsCount pipe for session count feat(analytics): add dotAnalyticsCount pipe and bar chart accessibility May 19, 2026
nicobytes added 2 commits May 19, 2026 12:29
…t formatting

This update enhances the analytics components by integrating the `DotAnalyticsCountPipe` for formatting session and view counts across various components. The pipe replaces previous formatting methods, ensuring a unified display of counts in both compact and full notation.

Changes include:
- Updated `dot-analytics-bar-engagement-chart`, `dot-analytics-stacked-bar`, and detail table dialogs to utilize the new pipe for count formatting.
- Removed redundant formatting methods from components and templates.
- Enhanced unit tests for the `DotAnalyticsCountPipe` to validate formatting behavior, including edge cases for zero and negative values.

These improvements streamline the presentation of analytics data, ensuring clarity and consistency throughout the dashboard.
nicobytes added 2 commits May 19, 2026 16:38
…ar-engagement-chart for improved data handling and UI

This update enhances the `DotAnalyticsBarChartComponent` and `DotAnalyticsBarEngagementChartComponent` by refactoring data handling and improving the user interface. Key changes include:
- Renamed and restructured data handling methods to use `displayRows` for better clarity and consistency.
- Introduced a new view model for bar chart rows, encapsulating properties like `viewsTooltip` and `ariaLabel`.
- Updated HTML templates to reflect the new data structure and improve accessibility with better aria-labels.
- Enhanced the engagement chart to include a subtitle for clarity and adjusted layout styles for better visual presentation.
- Removed deprecated session labels from the language properties to streamline the codebase.

These improvements aim to provide a more intuitive user experience and maintain consistency across analytics components.
…mproved accessibility and data handling

This update refines the `DotAnalyticsBarEngagementChartComponent` by improving the accessibility of engagement rows through better aria-labels and tooltips. Key changes include:
- Updated the HTML template to use precomputed aria-labels and session titles directly from the data model.
- Refactored the component's TypeScript code to encapsulate aria-label and session title logic within the view model.
- Added unit tests to validate the new aria-label and tooltip behaviors for engagement rows.

These enhancements aim to provide a more accessible user experience and ensure accurate representation of session data in the analytics dashboard.
@nicobytes nicobytes enabled auto-merge May 19, 2026 20:52
@nicobytes nicobytes added this pull request to the merge queue May 20, 2026
Any commits made after this event will not be merged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI: Safe To Rollback Area : Backend PR changes Java/Maven backend code Area : Frontend PR changes Angular/TypeScript frontend code

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Add dotCMS Analytics Proxy Endpoint for /v1/analytics/** to dot-ca-event-manager

3 participants