Opened 4 years ago

Closed 3 years ago

Last modified 3 years ago

#1598 closed Bug (fixed)

API.getMetaData includes unique visitors in year period

Reported by: greg Owned by: matt
Priority: low Milestone: Piwik 1.1
Component: Core Keywords: metadata, api
Cc: Sensitive: no

Description

The API call

?module=API&method=API.getMetadata&format=XML&apiModule=UserCountry&apiAction=getCountry&period=year

includes the metric "unique visitors" which is not included in the corresponding getProcessedReport call

?module=API&method=API.getProcessedReport&format=XML&apiModule=UserCountry&apiAction=getCountry&period=year

Change History (7)

comment:1 Changed 4 years ago by greg (gka)

I'm not quite sure about the expected behaviour. Maybe the bug is not that API.getMetaData includes the unique visitor metric, but that API.getProcessedReport does not include it. However, I think both functions should return the same metrics.

The bug appears only in time periods other than day. I found this bug because the new map plugin calls API.getMetaData to build the HTML Select and the flash map calls API.getProcessedReport to load the data. If you change the time to anything but day, you'll find the metric "unique visitors" in the Select but the map does not display it, because it is missing in the getProcessedReport result.

Hope the bug is clearer now. I'll try to locate the bug in the API plugin.

comment:2 Changed 4 years ago by greg (gka)

I found the code which removes the unique visitors from the processed metrics in line 308 and 309 in plugins/API/API.php.

if($period != 'day')
{
    unset($columns['nb_uniq_visitors']);
    unset($reportMetadata['metrics']['nb_uniq_visitors']);
}

It looks like the API.getMetaData results are independent of the selected time period and thus always include the unique visitor metrics. Since I don't want to touch the code I'll rather add a workaround to the map plugin which removes the unique visitors manually.

comment:3 Changed 4 years ago by greg (gka)

You may change the ticket priority to minor and move it to a later milestone.

comment:4 Changed 4 years ago by vipsoft (robocoder)

  • Milestone changed from 4 - Piwik 1.0 - Stable release to 5 - Piwik 1.1
  • Priority changed from major to low

matt: why is it unsetting for period != 'day'? Shouldn't this be period != 'year' given #842 r1301?

comment:5 Changed 4 years ago by matt (mattab)

  • Owner set to matt

oops, my mistake, it should be period == year. Thanks for investigating greg & vipsoft

comment:6 Changed 3 years ago by matt (mattab)

  • Resolution set to fixed
  • Status changed from new to closed

(In [3329]) Fixes #1598
Unique Visitors now out of the API resultset, the UI, and the Api metadata response, when period=year. Adding API metadata test for period=year.

comment:7 Changed 3 years ago by matt (mattab)

(In [3330]) Refs #1598
Fixing notice in sparkline widgets

Note: See TracTickets for help on using tickets.