Log login-click event

Our logEvent wrapper now returns jQuery.Promise too.

Added timeout out parameter to our logEvent wrapper. Unlike
GettingStarted, I didn't create separate logUnlessTimeout
function.

Chrome apparently emulates enter on links as a click, so
this catches enters, left and middle clicks, but not if
the link is opened via right click menu. Might not catch
enter in all browsers.

Change-Id: I4b0eb56e7c7d6e56f8fd99d536f9b60b94a2e09e
This commit is contained in:
Niklas Laxström
2013-07-16 10:46:36 +00:00
parent a1d7e391fb
commit 8e1726e745
2 changed files with 34 additions and 2 deletions

View File

@@ -159,6 +159,19 @@
new mw.Api().parse( $.i18n( 'ext-uls-display-settings-anon-log-in-cta' ) )
.done( function ( parsedCta ) {
$loginCta.html( parsedCta );
// Because browsers navigate away when clicking a link,
// we are are overriding the normal click behavior to
// allow the event be logged first - currently there is no
// local queue for events. The timeout is there to make sure
// the user gets to the new page even if event logging is slow
// or fails.
$loginCta.find( 'a' ).click( function ( event ) {
event.preventDefault();
mw.uls.logEvent( { action: 'login-click' }, 500 )
.always( function () {
window.location.href = event.target.href;
} );
} );
} );
return;