@mihadd opened this Issue on February 7th 2017

The referrer type report shows only keywords like search engines, websites, ... for the entries. It should show detailed titles.

@sgiehl commented on March 19th 2017 Member

This is a general bug that occurs when showing the report "flat"

@sgiehl commented on March 19th 2017 Member

Thinking a bit about this actually points out, that flattening this report doesn't really make sense, as it would show the same as the report displaying all referrers. I'll try to disable flattening for this report.

@sgiehl commented on March 20th 2017 Member

That won't be as easy as I thought. We currently set the flat parameter for all reports rendered for scheduled reports. This triggers the flattener to flatten the report, even if the report isn't able to handle that in any way.

I guess we need to find a way to define if a report can/should be shown flat in scheduled reports, but I'm not sure right now how to solve this best.

@mattab @tsteur any suggestions?

@tsteur commented on March 20th 2017 Owner

The only way I can think of is to change the API method and remove flatten parameter or to keep API always set it to false in the API method if possible?

Problem is that scheduled reports doesn't consult viewDataTable about which features are enabled etc

@sgiehl commented on March 21st 2017 Member

@tsteur The API method doesn't have any flat param.
The DataTablePostProcessor handles this using the request parameter: https://github.com/piwik/piwik/blob/3.x-dev/core/API/DataTablePostProcessor.php#L172
And I didn't find a way to manipulate the request from within the API.

@tsteur commented on March 21st 2017 Owner

I just had a look and it is tricky indeed.

I did make it work with this logic:

        if (Common::getRequestVar('flat', 0, 'int') && $idSubtable === false) {
            $dataTable->queueFilter('GroupBy', array('label'));

but not sure about any side effects. To boost performance it would also need to set expanded=1 when flat is loaded.

Another workaround, and probably better and faster solution is to add a new method to report class like function supportsFlatten() {return true}. I think in the post processor we have the report already anyway and could call this method. Ideally, we would then also in ViewDataTable configure the config property $view->config->show_flatten_table automatically but not sure if that would work or if we'd break something as we would maybe suddenly enable flatten table somewhere where it was disabled before (I don't think so since it is configured after config creation in ViewDataTable).

@tsteur commented on March 22nd 2017 Owner

I haven't tested it but there should be an easier solution like

     if (Common::getRequestVar('flat', 0, 'int') && $idSubtable === false) {

and then we only need to make sure to put logic of postprocessor into a filter like this:

            $flattener = new Flattener($this->apiModule, $this->apiMethod, $this->request);
            if ($this->includeAggregateRows) {

            $recursiveLabelSeparator = ' - ';
            if ($this->report) {
                $recursiveLabelSeparator = $this->report->getRecursiveLabelSeparator();

            $dataTable = $flattener->flatten($dataTable, $recursiveLabelSeparator);

We are also doing this for other things where we need to disable sort etc and I think this may be the best solution, if we can decide in the API method itself when to disable filter "flatten"

@sgiehl commented on March 22nd 2017 Member

sounds good. Will give it a try.

@sgiehl commented on March 26th 2017 Member

It's not as easy as it seemed to be. The filter method of a DataTable filter gets the datatable as parameter, so it can be used to manipulate it using the objects methods. But it can't be easily replace. But that's what the flattener currently does: creating an empty clone and creating a new table. So we might need to manipulate it in another way. Will check that next week

@mattab commented on March 29th 2017 Owner

Referrer type is now not flattened:

referrer type

This Issue was closed on March 29th 2017
Powered by GitHub Issue Mirror