Callback in sendRequest() / trackPageView() is not always executed #19862
Labels
Bug
For errors / faults / flaws.
c: Tracking
Issues related to getting data into Matomo
not-in-changelog
For issues or pull requests that should not be included in our release changelog on matomo.org.
Milestone
Expected Behavior
The callback in a
trackPageView()
call (and others) should always be executed, once the tracking Request is sent.Current Behavior
In some circumstances, this is not happening. While testing, I noticed it's working in Firefox, but not in Chrome (v 106.0.5249.119 ).
I tried to debug this issue and found this line to be different in execution. In FF
clientHintsResolved
istrue
and in Chrome it isn't. I went down the rabbit hole a bit deeper and found thatdetectBrowserFeatures()
is called,detectClientHints(callback)
is also called, but the givencallback
of the latter is not called in Chrome but is mandatory forclientHintsResolved
to betrue
. A bit deeper, I found thatnavigator.userAgentData.getHighEntropyValues()
behaves different in Firefox and Chrome.Nevertheless... What happens then, is that in
sendRequest(request, delay, callback)
, therequest
is put into a queue but - and that's the issue, IMO -delay
andcallback
are ignored and lost at this moment. The Request in the Queue is executed (sent) later on, but my originally provided callback is not. :(Possible Solution
delay
andcallback
along withrequest
into the clientHintsRequestQueue and execute it from there.Steps to Reproduce
Context
I've some pages that perform an immediate redirect (via window.location) but need to be tracked via Matomo. Therefore I need to know when Matomo has finished the tracking call so I securely can leave the page. ( Maybe there is a better way? )
Your Environment
Chrome (v 106.0.5249.119 )
Windows 11
Matomo version: 4.12.0
The text was updated successfully, but these errors were encountered: