NOTE: work on this is blocked on T275894 having been completed first.
NOTE: Consider making the schema change for T275794 when making the schema change for this one.
Readers Web will be A/B testing the existing treatment of the language switcher and a new treatment being worked on as part of #desktop_improvements. The Universal Language Switcher (the ULS) is well-instrumented but is missing a few key data that will allow us to better understand the impact of the new treatment vs the existing one. Per T268504, those data are:
* The user's session ID (an psuedorandom identifier that persists between pageviews but not after the tab/window is closed)
* Whether the user is logged in or not
* The user's bucketised edit count
* The language that the user chose when they changed language using the ULS
== AC
* [] When I change language using the ULS, then I see an `UniversalLanguageSwitcher` event being logged
## The event's `sessionID` property is set to the user's session ID, i.e. `mw.user.sessionId()`
## The event's `isAnon` property is set to whether the user is logged in or not, i.e. `mw.user.isAnon()`
## The event's `userEditBucket` poperty is set to the user's bucketised edit count, i.e. `mw.wikimediaEvents.getEditCountBucket( mw.config.get( 'wgUserEditCount' ) );`
## The event's `interfaceLanguage` and `selectedLanguage` to the language code for the current language and the selected language, respectively
== Questions
* Should it be called `selectedInterfaceLanguage`?
== Developer Notes
* The `sessionID`, `isAnon`, and `userEditBucket` properties will have to be set in the instrument's `log()` function as they should be set for all events. The `selectedLanguage` property should only be set in the `interfaceLanguageChange()` function.
```lang=javascript,name=WikimediaEvents/modules/ext.wikimedaEvents/universalLanguageSelector.js
function log( event ) {
event = $.extend( {
// Adding four new fields is a major change.
version: 2,
token: mw.user.id(),
contentLanguage: mw.config.get( 'wgContentLanguage' ),
interfaceLanguage: mw.config.get( 'wgUserLanguage' )
sessionID: mw.user.sessionId(),
isAnon: mw.user.isAnon(),
userEditBucket: mw.wikimediaEvents.getEditCountBucket( mw.config.get( 'wgUserEditCount' ) )
}, event );
mw.track( 'event.UniversalLanguageSelector', event );
}
// ...
function interfaceLanguageChange( language ) {
log( {
action: 'language-change',
context: 'interface',
selectedLanguage: language
} );
}
```