Move Top Stats to new internal stats endpoint#6035
Conversation
|
329200e to
1fcedf4
Compare
6732692 to
6c0a88d
Compare
6c0a88d to
eb2b22c
Compare
|
@RobertJoonas I have rebased this branch against the (pending) e2e test suite and I have stumbled on one issue:
When switching to realtime, it appears that top stats metrics IDs for current visitors and visitors from the last 30 minutes have the same ID ("visitors"). Before the change, "Current visitors" metrics has a distinct ID of "current_visitors". |
@zoldar, I have addressed this with a hotfix for now. abcdabc. Planning to drop the separation of topStatsQuery and currentVisitorsQuery in a follow-up. The current visitors could just be an integer value in the formatted Top Stats structure. E.g: |
|
@RobertJoonas nice SHA :D |

Changes
This PR introduces a new
POST /api/stats/:domain/queryendpoint and makes the Top Stats use it. The endpoint will eventually replace all the Api.StatsController actions such asmain_graph,sources,pages, etc.statsfunction inapi.ts. It takes aStatsQueryobject which aims to mimic the query params required to construct%ParsedQueryParams{}on the backend.StatsQueryobject, there's also a new function calledcreateStatsQuerywhich takesDashboardStateandReportParamsobjects as arguments. ReportParams contains the information about a specific report, e.g.: dimensions and metrics.While this PR does not intend to change any behaviour, there are some functional changes with this move:
bounce_rateis now shown in page-filtered Top Stats, even when imports are included in the view. Since bounce rate from imported data is unavailable in this view, there's an appropriate warning, like with scroll depth. (This was actually already handled by Include bounce rate in top stats with page filter and imported data + fix 500 #6073, but listing it here for better visibility as well)time_on_pageis now shown in page-filtered Top Stats, even when imports are included in the view. There's a specific exception where the metric is dropped on the backend though -- when legacy time on page is queried in aggregate from imported data. That's because the functionality in theLegacy.TimeOnPagemodule does not exist. This was likely the reason why time on page was simply cut out of page-filtered Top Stats when imports are included.Before:
After:
Tests
Changelog
Documentation
Dark mode