Add ability to access XHR object in the callback of trackPageView #13662
Labels
not-in-changelog
For issues or pull requests that should not be included in our release changelog on matomo.org.
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 thetrackPageView()
method we can passcustomTitle, 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.
The text was updated successfully, but these errors were encountered: