Change generation of logging session ID

Same pattern as is now used in VisualEditor. Generate an initial session
ID when the file loads, so if any VisualEditorFeatureUse events trigger
before the init there'll be a session ID for them to use.

Bug: T275051
Change-Id: I4f25e9e1e195c11129044868eb67fcc2f4494ffd
This commit is contained in:
David Lynch 2021-02-23 15:12:12 -06:00
parent da72fb15c2
commit 6ec1f39147

View file

@ -29,7 +29,11 @@ mw.loader.using( 'ext.eventLogging' ).done( function () {
saveFailure: 'save_failure'
},
timing = {},
session = {},
session = {
// eslint-disable-next-line camelcase
editing_session_id: mw.user.generateRandomSessionId()
},
firstInitDone = false,
/**
* Edit schema
* https://meta.wikimedia.org/wiki/Schema:EditAttemptStep
@ -128,8 +132,11 @@ mw.loader.using( 'ext.eventLogging' ).done( function () {
// Update the rolling session properties
if ( data.action === 'init' ) {
// eslint-disable-next-line camelcase
session.editing_session_id = mw.user.generateRandomSessionId();
if ( firstInitDone ) {
// eslint-disable-next-line camelcase
session.editing_session_id = mw.user.generateRandomSessionId();
}
firstInitDone = true;
}
// eslint-disable-next-line camelcase
session.editor_interface = data.editor_interface || session.editor_interface;