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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user