@adityasharma7 opened this Issue on November 1st 2018

First of all, Kudos to Matomo community for the amazing analytics tools.

I am using Matomo for tracking page view. I have a requirement where on completion of XHR request of track page view I need to perform some operation which involves accessing xhr ( XmlHttpRequest ) object. Basically, I need some of the data extracted by Piwik to be sent to another server too which is not a Matomo server. I figured out that with the trackPageView() method we can pass customTitle, customData, callback. I was able to pass a callback function as a parameter but I am not able to access xhr in the callback.
I did some exploration towards the flow of Piwik.js.
In sendXmlHttpRequest() function,
if(this.readyState===4&&(typeof callback ==='function')){callback()}
can be changed to
if(this.readyState===4&&(typeof callback ==='function')){callback(xhr)}
When the library is providing a callback for xhr, it should also provide access to the xhr object.

@tsteur commented on November 1st 2018 Member

That might be possible. In the future this behaviour may change though as we maybe group couple requests into one bulk request for example. I guess it depends why and what you need from the XHR object?

@adityasharma7 commented on November 2nd 2018

@tsteur Thanks for your response. I have added a comment for the same on the pr #13665
Thanks!

Powered by GitHub Issue Mirror