diff --git a/modules/dt.ui.ReplyWidget.js b/modules/dt.ui.ReplyWidget.js index c4cd8e817..37b52fa90 100644 --- a/modules/dt.ui.ReplyWidget.js +++ b/modules/dt.ui.ReplyWidget.js @@ -350,19 +350,20 @@ ReplyWidget.prototype.onModeTabSelectChoose = function ( option ) { // TODO: We rely on #setup to call #saveEditMode, so when we have 2017WTE // we will need to save the new preference here as switching will not // reload the editor. - promise.then( null, function () { + promise.then( function () { + // Switch succeeded + mw.track( 'dt.schemaVisualEditorFeatureUse', { + feature: 'editor-switch', + // TODO: Log as `source-nwe-desktop` when enable2017Wikitext is set + action: ( mode === 'visual' ? 'visual' : 'source' ) + '-desktop' + } ); + }, function () { // Switch failed, restore previous tab selection widget.modeTabSelect.selectItemByData( mode === 'source' ? 'visual' : 'source' ); } ).always( function () { widget.setPending( false ); widget.modeTabSelect.setDisabled( false ); } ); - - mw.track( 'dt.schemaVisualEditorFeatureUse', { - feature: 'editor-switch', - // TODO: Log as `source-nwe-desktop` when enable2017Wikitext is set - action: ( mode === 'visual' ? 'visual' : 'source' ) + '-desktop' - } ); }; /** diff --git a/modules/logger.js b/modules/logger.js index 5fde6f7c9..1c16a6ac4 100644 --- a/modules/logger.js +++ b/modules/logger.js @@ -224,7 +224,8 @@ mw.loader.using( 'ext.eventLogging' ).done( function () { ) ? 1 : sampleRate ); } - if ( data.feature === 'editor-switch' ) { + if ( data.feature === 'editor-switch' && data.action.indexOf( 'dialog-' ) === -1 ) { + // TODO: Account for `source-nwe-desktop` when enable2017Wikitext is set // eslint-disable-next-line camelcase session.editor_interface = session.editor_interface === 'visualeditor' ? 'wikitext' : 'visualeditor'; }