Include segment codes, where applicable, in all API results


#1

Currently in calls to UserCountry methods, the results include codes that can be used if you wanted to call another report using a segment of a country/region/city.

For example ->
Calls to UserCountry.getCountry include us for the United States data row.
Calls to UserCountry.getRegion include FL us for the Florida data row.

This is extremely useful if one wants to display a list of countries, and allow the user to select a country and get further data based on that segment. This is possible because the original results contains the codes needed to make subsequent segmented calls.

I propose that inclusion of these codes be a standard practice for all relevant API results.

While I’ve not reviewed data results from all API methods, a few that I can point out being in need of such a feature addition include ->

DevicesDetection.getOsVersions -> include operatingSystemCode
DevicesDetection.getBrowserFamilies -> include browserCode
DevicesDetection.getBrowserVersions -> include browserCode, browserVersion
UserSettings.getOS -> include operatingSystemCode
UserSettings.getBrowserVersion -> include browserCode, browserVersion
UserSettings.getBrowser -> include browserCode

Basically, it would be great if anywhere results are given where the label cannot be used as a segment value and a code must be used instead, that code would be included in the results.


(Matthieu Aubry) #2

That’s a reasonnable request indeed! could you maybe create a ticket at dev.piwik.org with the request?