Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to access XHR object in the callback of trackPageView #13662

Closed
adityasharma7 opened this issue Nov 1, 2018 · 3 comments
Closed
Labels
not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.

Comments

@adityasharma7
Copy link

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
Copy link
Member

tsteur commented Nov 1, 2018

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
Copy link
Author

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

@Findus23
Copy link
Member

This was fixed a long time ago with #13855

@mattab mattab added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

No branches or pull requests

4 participants