You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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`, and `siteId`), 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]](diffhunk://#diff-c0a594cb6bf35693b60035c742263700865b55e180715509ac6b9377ddaeb95bL13-R19)
[[2]](diffhunk://#diff-c0a594cb6bf35693b60035c742263700865b55e180715509ac6b9377ddaeb95bL92-R160)
[[3]](diffhunk://#diff-c0a594cb6bf35693b60035c742263700865b55e180715509ac6b9377ddaeb95bR176-R220)
* Updated the store feature (`withPageview`) to use the new parameter
object format for all analytics queries, ensuring correct passing of
`eventType` and `siteId`, and added type guards for array vs. object
responses.
[[1]](diffhunk://#diff-989f33d2983ed4588112a6b12fa172e230e6e75dcc308948fcc4bc7e73161d59L10-R10)
[[2]](diffhunk://#diff-989f33d2983ed4588112a6b12fa172e230e6e75dcc308948fcc4bc7e73161d59L95-R105)
[[3]](diffhunk://#diff-989f33d2983ed4588112a6b12fa172e230e6e75dcc308948fcc4bc7e73161d59L146-R158)
[[4]](diffhunk://#diff-989f33d2983ed4588112a6b12fa172e230e6e75dcc308948fcc4bc7e73161d59L200-R218)
[[5]](diffhunk://#diff-989f33d2983ed4588112a6b12fa172e230e6e75dcc308948fcc4bc7e73161d59L216-R231)
[[6]](diffhunk://#diff-989f33d2983ed4588112a6b12fa172e230e6e75dcc308948fcc4bc7e73161d59L262-R290)
[[7]](diffhunk://#diff-989f33d2983ed4588112a6b12fa172e230e6e75dcc308948fcc4bc7e73161d59L316-R354)
**Testing improvements:**
* Added comprehensive tests for `getTotalEvents` in
`dot-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]](diffhunk://#diff-99331c74e1a5318c227da2286205a09c838813f9e2e732e45c6734cdde4b1793R3-R21)
[[2]](diffhunk://#diff-99331c74e1a5318c227da2286205a09c838813f9e2e732e45c6734cdde4b1793R136-R232)
**Minor improvements:**
* Fixed strict typing for test variables in the service spec file.
[[1]](diffhunk://#diff-99331c74e1a5318c227da2286205a09c838813f9e2e732e45c6734cdde4b1793L53-R67)
[[2]](diffhunk://#diff-99331c74e1a5318c227da2286205a09c838813f9e2e732e45c6734cdde4b1793L77-R91)
This PR fixes: #34849
0 commit comments