ext.uls.eventlogger: Remove more obsolete deferred complexity

Follows-up c578db02 and ea671b1f, which I thought removed
all code relating to the old async EventLogging method.
I didn't notice this UI code at the time, because I only took a
single pass over the code to find dead code. Now that that code
is gone, it is clear that the UI code is also redundant.

The mw.track() and logEvent() methods don't track the Beacon API's
async fetches, which also isn't needed, since the loss of browser
context upon navigation doesn't abort background beacons.

The loading of the EL library itself is already ensured via a
dependency so we already know there won't be an async fetch for
that.

What that leaves is some portion of older browsers in which a
EventLogging falls back to 'new Image'. This is basically just
IE 11 per <https://caniuse.com/beacon>, and for those some portion
of events will have been lost since EventLogging removed support
two+ years ago for tracking those fallback fetches via a Promise
(because of the perf issues caused by what the removed code here
was able to do).

Change-Id: Idf4378f983b6ba0e755ebadb97aa6d87cf95f7a5
This commit is contained in:
Timo Tijhof
2020-10-23 00:27:24 +01:00
committed by Krinkle
parent f8fde38197
commit 09862cffec
4 changed files with 55 additions and 97 deletions

View File

@@ -207,30 +207,14 @@
new mw.Api().parse( $.i18n( 'ext-uls-display-settings-anon-log-in-cta' ) )
.done( function ( parsedCta ) {
var deferred = new $.Deferred();
$loginCta.html( parsedCta ); // The parsed CTA is HTML
$loginCta.find( 'a' ).on( 'click', function ( event ) {
event.preventDefault();
// Because browsers navigate away when clicking a link,
// we are overriding the normal click behavior to allow
// the event be logged first - currently there is no
// local queue for events. Since the hook system does not
// allow returning values, we have this ugly hack
// for event logging to delay the page loading if event logging
// is enabled. The promise is passed to the hook, so that
// if event logging is enabled, in can resole the promise
// immediately to avoid extra delays.
deferred.done( function () {
location.href = event.target.href;
} );
mw.hook( 'mw.uls.login.click' ).fire( deferred );
// Delay is zero if event logging is not enabled
setTimeout( function () {
deferred.resolve();
}, mw.config.get( 'wgULSEventLogging' ) * 500 );
// The parsed CTA is HTML
$loginCta.html( parsedCta );
$loginCta.find( 'a' ).on( 'click', function () {
// If EventLogging is installed and enabled for ULS, give it a
// chance to log this event. There is no promise provided and in
// most browsers this will use the Beacon API in the background.
// In older browsers, this event will likely get lost.
mw.hook( 'mw.uls.login.click' );
} );
} );