Skip to content

Support returning an exact match of parameters in API.getMetadata and API.getProcessedReport #23211

@diosmosis

Description

@diosmosis

Summary

Currently the API.getMetadata and API.getProcessedReport methods, when determining which report metadata to use and return, allows extra, unneeded API parameters to be supplied. The first report whose <parameters>...</parameters> are included in the API parameters are returned. If there are extra API parameters at that point, they are ignored.

This creates a problem for reports that have multiple parameters or a varying number of parameters, as the best matching report may be ignored.

For example, given the following reports:

<module>MyPlugin</module>
<action>getMyReport</action>
<parameters>
    <idOneThing>1</idOneThing>
</parameters>
<module>MyPlugin</module>
<action>getMyReport</action>
<parameters>
    <idOneThing>1</idOneThing>
    <anotherParam>2</anotherParam>
</parameters>

Trying to do an API request like module=MyPlugin&action=getMyReport&apiParameters[idOneThing]=1&apiParameters[anotherParam]=2 will result in the first report being used, because Matomo will match idOneThing in the first report, and treat the anotherParam parameter in the API request as extra.

I think changing this may result in a BC break, so I'm hoping some feature can be added to allow specifically requesting an exact match on parameters.

An implementation of this can be seen in this PR: #23206 (it adds an exact_match parameter to the aforementioned API requests).

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementFor new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions