Log editor switches to visualeditorfeatureuse

Depends lightly on a patch to WikiEditor, which will hook up the logging there
for the case where the switch is happening from WikiEditor to VisualEditor on
the same pageload.

Bug: T221191
Change-Id: Ibafec77b2eabd3b3b3767472b7b5a40e3312bf18
This commit is contained in:
David Lynch 2019-06-27 16:44:20 -05:00
parent 10de6f2c2f
commit 38e3c3fbdb
3 changed files with 38 additions and 1 deletions

View file

@ -1182,6 +1182,7 @@
switchToolbar.on( 'switchEditor', function ( mode ) {
if ( mode === 'visual' ) {
init.activateVe( 'visual' );
$( '#wpTextbox1' ).trigger( 'wikiEditor-switching-visualeditor' );
}
} );

View file

@ -1519,6 +1519,40 @@ ve.init.mw.DesktopArticleTarget.prototype.onUnload = function () {
}
};
/**
* @inheritdoc
*/
ve.init.mw.DesktopArticleTarget.prototype.switchToVisualEditor = function () {
// Parent method
ve.init.mw.DesktopArticleTarget.super.prototype.switchToVisualEditor.apply( this, arguments );
if ( ve.init.target.isModeAvailable( 'visual' ) ) {
ve.track( 'activity.editor-switch', { action: 'visual-desktop' } );
}
};
/**
* @inheritdoc
*/
ve.init.mw.DesktopArticleTarget.prototype.switchToWikitextEditor = function () {
// Parent method
ve.init.mw.DesktopArticleTarget.super.prototype.switchToWikitextEditor.apply( this, arguments );
if ( ve.init.target.isModeAvailable( 'source' ) ) {
ve.track( 'activity.editor-switch', { action: 'source-nwe-desktop' } );
}
};
/**
* @inheritdoc
*/
ve.init.mw.DesktopArticleTarget.prototype.switchToWikitextSection = function () {
// Parent method
ve.init.mw.DesktopArticleTarget.super.prototype.switchToWikitextSection.apply( this, arguments );
ve.track( 'activity.editor-switch', { action: 'source-nwe-desktop' } );
};
/**
* @inheritdoc
*/
@ -1533,6 +1567,7 @@ ve.init.mw.DesktopArticleTarget.prototype.switchToFallbackWikitextEditor = funct
prefPromise = mw.libs.ve.setEditorPreference( 'wikitext' );
if ( !modified ) {
ve.track( 'activity.editor-switch', { action: 'source-desktop' } );
ve.track( 'mwedit.abort', { type: 'switchnochange', mechanism: 'navigate', mode: 'visual' } );
this.submitting = true;
prefPromise.done( function () {
@ -1551,6 +1586,7 @@ ve.init.mw.DesktopArticleTarget.prototype.switchToFallbackWikitextEditor = funct
this.serialize(
this.getDocToSave(),
function ( wikitext ) {
ve.track( 'activity.editor-switch', { action: 'source-desktop' } );
ve.track( 'mwedit.abort', { type: 'switchwith', mechanism: 'navigate', mode: 'visual' } );
target.submitWithSaveFields( { wpDiff: true, wpAutoSummary: '' }, wikitext );
}

View file

@ -213,7 +213,7 @@
return;
}
if ( ve.init.target.constructor.static.platformType === 'phone' ) {
if ( ve.init.target && ve.init.target.constructor.static.platformType === 'phone' ) {
// handled in MobileFrontend for session-identification reasons
return;
}