Prepare ULS for EventLogging

This change introduces a new configuration variable, $wgULSEventLogging. When
set to true, ULS will register an EventLogging schema module for
<http://meta.wikimedia.org/wiki/Schema:UniversalLanguageSelector>,
making it possible to log events using `mw.uls.logEvent`. When false, the
schema module is not loaded, and `mw.uls.logEvent` is a no-op.

Change-Id: I7139e67cc2f830a6b4b3c8ff1fc72dfcdec9a699
This commit is contained in:
Niklas Laxström
2013-06-15 15:04:05 +00:00
parent 20033e4fbf
commit 4543d43dda
3 changed files with 62 additions and 3 deletions

View File

@@ -116,6 +116,33 @@
return !/MSIE [67]/i.test( navigator.userAgent );
};
/**
* Local wrapper for 'mw.eventLog.logEvent' which handles default params
* and ensures the correct schema is loaded.
*
* @param {Object} data Event action and optional fields
* @since 2013.07
* @see https://meta.wikimedia.org/wiki/Schema:UniversalLanguageSelector
*/
mw.uls.logEvent = $.noop;
// If EventLogging integration is enabled, set event defaults and make the
// the function call event logging with correct schema.
if ( mw.config.get( 'wgULSEventLogging' ) ) {
mw.loader.using( 'schema.UniversalLanguageSelector', function () {
mw.eventLog.setDefaults( 'UniversalLanguageSelector', {
version: 1,
token: mw.user.id(),
contentLanguage: mw.config.get( 'wgContentLanguage' ),
interfaceLanguage: currentLang
} );
mw.uls.logEvent = function ( event ) {
mw.eventLog.logEvent( 'UniversalLanguageSelector', event );
};
} );
}
/**
* i18n initialization
*/