@tsteur opened this Issue on March 25th 2020 Member

We can also do this as part of 3.13.6 if needed.

We're getting the feedback around slow segment suggested values a lot and it can potentially even take down Matomo when it needs to look at a lot of data over 60 days. I'm meaning the API.getSuggestedValuesForSegment method.

We would like the ability that for some segments to optionally define an API method (eg Events.getAction).

  • should browser archiving be disabled, then we would get the suggested values by looking at the most common labels instead of issuing the live query
  • should browser archiving be enabled, then this can be slow to start archiving so we would prefer the live visitor log query instead to avoid slow archiving

We'll need to make sure to have tests for both ways for this API method. Initially we would probably not set this for visitor segments but action segments were possible (page urls, page titles, events, ...). Could set it for some visitor segments though as well.

Ideally, we would not need to do range archives eg period=range&date=last2months. Looking at one full month be fine. However, we can't really look at previous month since then recent values would be missing and we can't look at the current month because we might be only a few days into the month.

  • I suggest looking at this year's data be fine when browser archiving is disabled.
  • When the current month is January, then we would maybe need to look at last 2 months (this and previous month) and accept there will be a range archive. We wouldn't want to use last 2 years as it would be slower to aggregate since year archives usually have a lot more data.

From a technical point of view:
The idea is, that a Dimension class would be able to define an API method eg protected $segmentSuggestedValuesApi = 'Actions.getPageUrls'. This would be automatically passed on to the segment class and in the API.getSuggestedValuesForSegment we can then check if browser archiving is disabled and if there is an API defined, then we issue the API request instead of a live query.

We would also specify all needed parameters like the filter_limit=X, filter_offset=0, segment = '' in Request::processRequest.

As a side effect, should range period be disabled, this would make the suggested values still work for the months from Feb-Dec. Jan wouldn't work. We need to make sure to have a check for this like

        if (!Period\Factory::isPeriodEnabledForAPI('range')) {
            return array();
        }

to prevent any exception.

Powered by GitHub Issue Mirror