feat(analytics): enhance DotAnalyticsService#35549
Conversation
…tching logic - Introduced `getTotalEvents` method in `DotAnalyticsService` to fetch total events from the new analytics event API, supporting both predefined ranges and custom date ranges. - Updated service methods to handle optional parameters like `granularity`, `eventType`, and `siteId`. - Refactored related store logic in `with-pageview.feature.ts` to utilize the new service methods, ensuring accurate state management. - Added comprehensive unit tests for the new functionality, ensuring robust coverage and reliability. This update modernizes the analytics data access layer and prepares for future enhancements.
|
Claude finished @nicobytes's task in 2m 14s —— View job PR Review
5 issues worth a second look: 1. catchError(() => of(HealthStatusTypes.AVAILABLE))If the health endpoint is unreachable or returns a 5xx, this silently reports the service as available. It should return 2. Double
3. No store-level tests for The new tests only cover 4. Dual type system without a migration path — Store state uses 5. The comment acknowledges this: Otherwise the param-builder decomposition is clean, the overload signatures for |
- Introduced new methods in `DotAnalyticsService` for fetching unique visitors, top content, and page views by device/browser, utilizing the new analytics event API. - Updated the service to handle optional parameters and improved the request handling logic. - Enhanced unit tests for the new methods, ensuring comprehensive coverage and error handling. - Refactored related types and store logic to align with the new API structure. This update modernizes the analytics service and improves data retrieval capabilities.
…ling - Updated `DotAnalyticsService` to support new methods for fetching total events and unique visitors with improved granularity handling. - Refactored types to better represent API parameters and responses, including new types for total events and unique visitors. - Enhanced unit tests to cover error propagation for total events, top content, and pageviews by device/browser, ensuring robust error handling. - Cleaned up unused code in `with-pageview.feature.ts` to streamline the implementation. This update improves the analytics service's functionality and reliability in handling API responses.
…roved granularity handling - Updated `DotAnalyticsService` to replace deprecated methods with new ones for fetching total events and unique visitors, now supporting enhanced granularity options. - Refactored types in `analytics-api.types.ts` to remove obsolete granularity parameters and align with the new API structure. - Improved data handling in `fillMissingApiDates` utility to accommodate monthly granularity. - Cleaned up unused code and ensured consistency in type definitions for better maintainability. This update enhances the analytics service's functionality and prepares it for future improvements.
This pull request refactors the DotAnalyticsService API and its consumers to use unified parameter objects for analytics queries, improving flexibility and maintainability. The service methods now accept a single options object (including optional fields like
granularity,eventType, andsiteId), and the store feature is updated accordingly. Additional tests are added for new query combinations, and utility functions are introduced to build query parameters consistently.DotAnalyticsService API refactor and enhancements:
Refactored all analytics service methods (
getTotalEvents,getUniqueVisitors,getTopContent,getPageviewsByDeviceBrowser) to accept a single parameter object with optional fields (granularity,eventType,siteId), replacing multiple parameters and overloads. Added private utility methods to build HTTP query parameters for each API call. [1] [2] [3]Updated the store feature (
withPageview) to use the new parameter object format for all analytics queries, ensuring correct passing ofeventTypeandsiteId, and added type guards for array vs. object responses. [1] [2] [3] [4] [5] [6] [7]Testing improvements:
getTotalEventsindot-analytics.service.spec.ts, covering various combinations of query parameters and validating request construction. Introduced a helper function to match requests by URL and method. [1] [2]Minor improvements:
This PR fixes: #34849
This PR fixes: #34849