matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.89k stars 2.65k forks source link

ScheduledReports plugin does not support adding report parameters #11330

Open bkbeckman opened 7 years ago

bkbeckman commented 7 years ago

I'm building a plugin that integrates with ScheduledReports and I need the ability to pass in parameters.

I noticed there are callbacks for 'ScheduledReports.getReportParameters' and 'ScheduledReports.validateReportParameters'. However, it looks like the front-end does not take the results of a 'ScheduledReports.getReportParameters' into consideration when submitting the form field. Thus, the field is never populated when the user submits the form.

I added a handler with debug statements to each of these events and here are some results:

Piwik\Plugins\MyPlugin\MyPlugin::getScheduledReportParameters :: parameters :: Array ( [emailMe] => [evolutionGraph] => [additionalEmails] => [displayFormat] => 1 [myCustomParameter] => 0 // here is the custom parameter that I added to the array ) Piwik\Plugins\MyPlugin\MyPlugin::validateScheduledReportParameters :: parameters :: Array ( [displayFormat] => 1 [emailMe] => 1 [evolutionGraph] => // custom parameter was not submitted )

And form submission data from Chrome:

idReport:0 description:description idSegment: reportType:email reportFormat:html reports[]:MyCustomReport1 reports[]:MyCustomReport2 parameters[displayFormat]:1 parameters[emailMe]:true parameters[evolutionGraph]:false token_auth:

I believe the problem can be traced to the reportParametersScheduledReports.twig file. As you can see, the parameters to submit are hard-coded in the javascript instead of being pulled dynamically from the $availableParameters variable.

mattab commented 7 years ago

Thanks for the feedback @bkbeckman - we would welcome a pull request implementing this change and allowing you to build your plugin with custom parameters. So hopefully you have a chance to create and submit this PR for our review? :+1: