Santhosh has uploaded a new change for review. https://gerrit.wikimedia.org/r/197512
Change subject: Eventlogging for various actions on translation ...................................................................... Eventlogging for various actions on translation Schema: https://meta.wikimedia.org/wiki/Schema:ContentTranslation Bug: T90529, T88569 Change-Id: I81cab64c07a4d9f474165f96c4686918e08491f0 --- M ContentTranslation.hooks.php M modules/dashboard/ext.cx.translationlist.js M modules/draft/ext.cx.draft.js M modules/eventlogging/ext.cx.eventlogging.js 4 files changed, 71 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation refs/changes/12/197512/1 diff --git a/ContentTranslation.hooks.php b/ContentTranslation.hooks.php index 1fbe673..42d3e11 100644 --- a/ContentTranslation.hooks.php +++ b/ContentTranslation.hooks.php @@ -105,7 +105,7 @@ * Hook: EventLoggingRegisterSchemas */ public static function addEventLogging( array &$schemas ) { - $schemas['ContentTranslation'] = 7146627; + $schemas['ContentTranslation'] = 11618043; $schemas['ContentTranslationCTA'] = 11616099; } diff --git a/modules/dashboard/ext.cx.translationlist.js b/modules/dashboard/ext.cx.translationlist.js index cf639d2..2e8f1c7 100644 --- a/modules/dashboard/ext.cx.translationlist.js +++ b/modules/dashboard/ext.cx.translationlist.js @@ -161,7 +161,9 @@ .addClass( 'image' ); $progressbar = $( '<div>' ) .addClass( 'progressbar' ) - .cxProgressBar( { weights: progress } ); + .cxProgressBar( { + weights: progress + } ); $imageBlock.append( $image, $progressbar ); this.showTitleImage( translation ); @@ -313,6 +315,7 @@ .then( function ( response ) { if ( response.cxdelete.result === 'success' ) { translationList.markTranslationAsDeleted( translation ); + mw.hook( 'mw.cx.translation.deleted' ).fire(); } } ); } ); diff --git a/modules/draft/ext.cx.draft.js b/modules/draft/ext.cx.draft.js index f2c54d3..4f8cc6c 100644 --- a/modules/draft/ext.cx.draft.js +++ b/modules/draft/ext.cx.draft.js @@ -153,6 +153,7 @@ $section.attr( 'data-cx-draft', true ); mw.hook( 'mw.cx.translation.postMT' ).fire( $section ); } + mw.hook( 'mw.cx.translation.restored' ).fire(); }; /** diff --git a/modules/eventlogging/ext.cx.eventlogging.js b/modules/eventlogging/ext.cx.eventlogging.js index 1bec68f..13e7b30 100644 --- a/modules/eventlogging/ext.cx.eventlogging.js +++ b/modules/eventlogging/ext.cx.eventlogging.js @@ -23,7 +23,8 @@ */ listen: function () { // Register handlers for event logging triggers - mw.hook( 'mw.cx.translation.published' ).add( $.proxy( this.translatedPageCreated, this ) ); + mw.hook( 'mw.cx.translation.published' ).add( $.proxy( this.published, this ) ); + mw.hook( 'mw.cx.translation.saved' ).add( $.proxy( this.saved, this ) ); mw.hook( 'mw.cx.cta.shown' ).add( $.proxy( this.ctaShown, this ) ); mw.hook( 'mw.cx.cta.accept' ).add( $.proxy( this.ctaAccept, this ) ); mw.hook( 'mw.cx.cta.reject' ).add( $.proxy( this.ctaReject, this ) ); @@ -34,16 +35,75 @@ * @param {string} contentLanguage source language * @param {string} targetLanguage Target language code */ - translatedPageCreated: function ( contentLanguage, targetLanguage ) { + translated: function ( action, sourceLanguage, targetLanguage, sourceTitle, targetTitle ) { mw.track( 'event.ContentTranslation', { version: 1, token: mw.user.id(), - action: 'create-translated-page', - contentLanguage: contentLanguage, - targetLanguage: targetLanguage + session: mw.user.sessionId(), + action: 'publish', + sourceLanguage: sourceLanguage, + targetLanguage: targetLanguage, + sourceTitle: sourceTitle, + targetTitle: targetTitle } ); }, + /** + * Log saving(draft) of translated page. + * @param {string} contentLanguage source language + * @param {string} targetLanguage Target language code + */ + saved: function ( sourceLanguage, targetLanguage, sourceTitle, targetTitle ) { + mw.track( 'event.ContentTranslation', { + version: 1, + token: mw.user.id(), + session: mw.user.sessionId(), + action: 'save', + sourceLanguage: sourceLanguage, + targetLanguage: targetLanguage, + sourceTitle: sourceTitle, + targetTitle: targetTitle + } ); + // Execute only once! + this.saved = $.noop(); + }, + + /** + * Log restore action of translation + */ + restored: function ( sourceLanguage, targetLanguage, sourceTitle, targetTitle ) { + mw.track( 'event.ContentTranslation', { + version: 1, + token: mw.user.id(), + session: mw.user.sessionId(), + action: 'restore', + sourceLanguage: sourceLanguage, + targetLanguage: targetLanguage, + sourceTitle: sourceTitle, + targetTitle: targetTitle, + } ); + // Execute only once! + this.saved = $.noop(); + }, + + /** + * Log deletion of translated page. + */ + deleted: function ( sourceLanguage, targetLanguage, sourceTitle, targetTitle ) { + mw.track( 'event.ContentTranslation', { + version: 1, + token: mw.user.id(), + session: mw.user.sessionId(), + action: 'delete', + sourceLanguage: sourceLanguage, + targetLanguage: targetLanguage, + sourceTitle: sourceTitle, + targetTitle: targetTitle, + } ); + // Execute only once! + this.saved = $.noop(); + }, + ctaShown: function ( campaign ) { mw.track( 'event.ContentTranslationCTA', { version: 1, -- To view, visit https://gerrit.wikimedia.org/r/197512 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I81cab64c07a4d9f474165f96c4686918e08491f0 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ContentTranslation Gerrit-Branch: master Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits