Page MenuHomePhabricator

Image link clicks might not get logged
Closed, ResolvedPublic

Description

This is a reminder to check whether the click logging works properly for image page links, which navigate the browser away. We use a 0.5 sec timeout to make sure the log request has enough time to lead before it would be aborted by the browser aborts it while unloading the page; this might be too little or unnecessarily much. See Mattflaschen's comment at https://gerrit.wikimedia.org/r/#/c/92445/ for more details.


Version: unspecified
Severity: trivial

Details

Reference
bz56426

Event Timeline

bzimport raised the priority of this task from to Normal.Nov 22 2014, 2:26 AM
bzimport added a project: MediaViewer.
bzimport set Reference to bz56426.
bzimport added a subscriber: Unknown Object (MLST).
Tgr created this task.Oct 31 2013, 8:06 PM

It's actually possible to make logging work on navigating away without a timeout by making a synchronous XHR call during the onbeforeunload. Browsers will abort an classic async one, but not a synchronous one. The drawback is that it freezes the page, but since the backend of event logging correctly aborts the request right away, it would be hardly felt. (I've already built something like that in production at dA).

This change would imply modifying (or overloading) mw.eventLog to make it do a synchronous XHR when needed instead of using an image object.

What do you think? Is the synchronous thing worth filing in Mingle?

I like this better than using timeouts that may not be enough. +1

Tgr added a comment.Feb 20 2014, 7:50 PM

Certainly a better solution as it does not take more time than necessary (I imagine on a fast connection way less than half sec is needed, so currently we are making the user wait for no reason). We can still set a timeout on the XHR object so this does not get too annoying for people with extremely slow connections.

I've just realized that we don't need onbeforeunload, since we capture a specific click. We just need a callback/deferred to tell us when the .log() call is done. Conveniently, ext.eventLogging already provides that.

The technique I've described would be useful if we want to track people navigating away altogether (including entering a new URL in their browser). Worth keeping in mind, but not necessary for "site-link-click".

https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/255

Gilles closed this task as Resolved.Dec 10 2014, 10:39 PM
Gilles claimed this task.
Restricted Application added a subscriber: Matanya. · View Herald TranscriptOct 31 2016, 2:52 PM