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 (Vector 2022). 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
- The UniversalLanguageSelector schema is updated to v1.1.0 and has the following additional properties:
- sessionID
- isAnon
- userEditBucket
- interfaceLanguage
- 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.
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 } ); }
QA Steps
- Navigate to https://en.wikipedia.beta.wmflabs.org
- Run the following in your browser's console:
mw.trackSubscribe('event.UniversalLanguageSelector', (_, event) => console.log(JSON.stringify(event, null, 2)));
- Open the Universal Language Selector
- Observe that an action=settings-open event has been logged with:
- A version property set to 2
- A token property set to ''
- A web_session_id property with a value;
- An isAnon property, set to false;
- A userEditBucket property with a value
- Change your interface language
- Observe that an action=change-language event has been logged with:
- A selectedInterfaceLanguage property with a value
QA Results - Beta
AC | Status | Details |
---|---|---|
1 | ✅ | T275766#6994221 |
2 | ✅ | T275766#6994221 |
QA Results - Prod
AC | Status | Details |
---|---|---|
1 | ✅ | T275766#7001337 |
2 | ✅ | T275766#7001337 |