Page MenuHomePhabricator

Log sessionID, isAnon, editBucketCount, and selectedLanguage properties in the UniversalLanguageSelector instrument
Closed, ResolvedPublic3 Estimated Story Points

Description

NOTE: work on this is blocked on T275894 having been completed first.

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

  • 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
    1. The event's sessionID property is set to the user's session ID, i.e. mw.user.sessionId()
    2. The event's isAnon property is set to whether the user is logged in or not, i.e. mw.user.isAnon()
    3. The event's userEditBucket poperty is set to the user's bucketised edit count, i.e. mw.wikimediaEvents.getEditCountBucket( mw.config.get( 'wgUserEditCount' ) );
    4. 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.
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
  } );
}

QA Steps

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

ACStatusDetails
1T275766#6994221
2T275766#6994221

QA Results - Prod

ACStatusDetails
1T275766#7001337
2T275766#7001337

Related Objects

StatusSubtypeAssignedTask
OpenMNeisler
Resolvedovasileva
OpenNone
Resolvedalexhollender
Resolvedalexhollender
Resolvedovasileva
Resolvedovasileva
Resolvedovasileva
ResolvedSpikeovasileva
OpenBUG REPORTNone
Resolvedovasileva
Resolvedalexhollender
DeclinedNone
OpenJdlrobson
ResolvedEdtadros
OpenJdlrobson
Declinedovasileva
OpenNone
Opennray
Opennray
Resolvedovasileva
OpenEdtadros
OpenNone
OpenEdtadros
ResolvedEdtadros
ResolvedEdtadros
Openovasileva
OpenNone
DuplicateNone
OpenNone
Resolvedovasileva
OpenNone
OpenMNeisler
Resolvedovasileva

Event Timeline

Does this task involve removing the instrumentation in UniversalLanguageSelector? Presumably, this change is inside WikimediaEvents only after copying across instrumentation from ULS?

I think once T275766#6862597 is clarified (via an addition to acceptance criteria) this should be moved into upcoming for estimation.

Should it be called selectedInterfaceLanguage?

Presumably an implementation detail that does not effect estimation.

Jdlrobson updated the task description. (Show Details)
Jdlrobson set the point value for this task to 3.
phuedx removed the point value for this task.
phuedx set the point value for this task to 3.

Change 668742 had a related patch set uploaded (by Phuedx; owner: Phuedx):
[mediawiki/extensions/WikimediaEvents@master] WIP: Add properties to UniversalLanguageSelector events

https://gerrit.wikimedia.org/r/668742

Change 668743 had a related patch set uploaded (by Phuedx; owner: Phuedx):
[schemas/event/secondary@master] WIP: Add properties to UniversalLanguageSelector schema

https://gerrit.wikimedia.org/r/668743

phuedx added a subscriber: Ottomata.

👆 I updated the associated patches after feedback from @Ottomata (thanks!).

Change 668743 merged by jenkins-bot:
[schemas/event/secondary@master] universalLanguageSelector: Add new properties

https://gerrit.wikimedia.org/r/668743

Change 668742 merged by jenkins-bot:
[mediawiki/extensions/WikimediaEvents@master] Add properties to UniversalLanguageSelector events

https://gerrit.wikimedia.org/r/668742

Test Result - Beta

Status: ✅ PASS
Environment: beta
OS: macOS Big Sur
Browser: Chrome
Device: MBP
Emulated Device: NA

Test Artifact(s):

QA Steps
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

✅ AC1:

{
  "version": 2,
  "token": "",
  "contentLanguage": "en",
  "interfaceLanguage": "en",
  "web_session_id": "385ca0790cc1c32792b8",
  "isAnon": false,
  "action": "settings-open",
  "context": "interlanguage",
  "userEditBucket": "5-99 edits"
}
  • Change your interface language
  • Observe that an action=change-language event has been logged with:
    • A selectedInterfaceLanguage property with a value

✅ AC2:

{
  "version": 2,
  "token": "",
  "contentLanguage": "en",
  "interfaceLanguage": "en",
  "web_session_id": "385ca0790cc1c32792b8",
  "isAnon": false,
  "action": "language-change",
  "context": "interface",
  "selectedInterfaceLanguage": "fr",
  "timeToChangeLanguage": 393020.3049316406,
  "userEditBucket": "5-99 edits"
}
Edtadros added a subscriber: Edtadros.

@ovasileva This passes, however before I move it to Ready for Signoff I wanted to be sure that you weren't intending it to be tested with the new language button. This was tested on the current one in production.

Test Result - Prod

Status: ✅ PASS
Environment: enwiki
OS: macOS Big Sur
Browser: Chrome
Device: MBP
Emulated Device: NA

Test Artifact(s):

QA Steps
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

✅ AC1:

{
  "version": 2,
  "token": "",
  "contentLanguage": "en",
  "interfaceLanguage": "en",
  "web_session_id": "a1f64e09ac54172e877d",
  "isAnon": false,
  "action": "settings-open",
  "context": "interlanguage",
  "userEditBucket": "1-4 edits"
}
  • Change your interface language
  • Observe that an action=change-language event has been logged with:
    • A selectedInterfaceLanguage property with a value

✅ AC2:

{
  "version": 2,
  "token": "",
  "contentLanguage": "en",
  "interfaceLanguage": "en",
  "web_session_id": "a1f64e09ac54172e877d",
  "isAnon": false,
  "action": "language-change",
  "context": "interface",
  "selectedInterfaceLanguage": "es",
  "timeToChangeLanguage": 14494.409912109375,
  "userEditBucket": "1-4 edits"
}