Santhosh has uploaded a new change for review. https://gerrit.wikimedia.org/r/197489
Change subject: Add eventlogging to measure entry point effectiveness ...................................................................... Add eventlogging to measure entry point effectiveness Schema: https://meta.wikimedia.org/wiki/Schema:ContentTranslationCTA Integrated to red interlanguage link and new article by translation campaigns Uses session id to log 3 actions by the entry points: - An entry point is shown to user - red interlanguage link dialog, or new article-by-translation campaign dialog - User accept it - User reject it After this stage, translation can happen. Publishing may happen. Those steps will be measured in follow up commits using different schema Bug: T90529, T88569 Change-Id: I3b1d54f879ba49542b4bda9585aa02f994ba2ac3 --- M ContentTranslation.hooks.php M modules/base/ext.cx.sitemapper.js M modules/campaigns/ext.cx.campaigns.newarticle.js M modules/dashboard/ext.cx.dashboard.js M modules/entrypoint/ext.cx.entrypoint.js M modules/entrypoint/ext.cx.redlink.js M modules/eventlogging/ext.cx.eventlogging.js 7 files changed, 67 insertions(+), 23 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation refs/changes/89/197489/1 diff --git a/ContentTranslation.hooks.php b/ContentTranslation.hooks.php index fbf12da..1fbe673 100644 --- a/ContentTranslation.hooks.php +++ b/ContentTranslation.hooks.php @@ -106,6 +106,7 @@ */ public static function addEventLogging( array &$schemas ) { $schemas['ContentTranslation'] = 7146627; + $schemas['ContentTranslationCTA'] = 11616099; } /** diff --git a/modules/base/ext.cx.sitemapper.js b/modules/base/ext.cx.sitemapper.js index 605b3ed..8558b8b 100644 --- a/modules/base/ext.cx.sitemapper.js +++ b/modules/base/ext.cx.sitemapper.js @@ -109,12 +109,14 @@ * @param {string} targetTitle * @param {string} sourceLanguage * @param {string} targetLanguage + * @param {string} [campaign] */ mw.cx.SiteMapper.prototype.getCXUrl = function ( sourceTitle, targetTitle, sourceLanguage, - targetLanguage + targetLanguage, + campaign ) { var cxPage, uri, queryParams; @@ -123,9 +125,12 @@ page: sourceTitle, from: sourceLanguage, to: targetLanguage, - targettitle: targetTitle + targettitle: targetTitle, }; + if ( campaign ) { + queryParams.campaign = campaign; + } if ( mw.config.get( 'wgContentTranslationTranslateInTarget' ) ) { uri = new mw.Uri( this.getPageUrl( targetLanguage, cxPage ) ); $.extend( uri.query, queryParams ); diff --git a/modules/campaigns/ext.cx.campaigns.newarticle.js b/modules/campaigns/ext.cx.campaigns.newarticle.js index 78c1862..b85e954 100644 --- a/modules/campaigns/ext.cx.campaigns.newarticle.js +++ b/modules/campaigns/ext.cx.campaigns.newarticle.js @@ -56,10 +56,16 @@ path: '/' } ); + // Campaign or call to action was rejected by the user. + mw.hook( 'mw.cx.cta.reject' ).fire( campaign ); } ); $tryCX.on( 'click', function () { location.href = cxLink; + // We need to log this using eventlogging, but since we are navigating away + // we cannot do it reliably here(See https://phabricator.wikimedia.org/T44815). + // We will do it at server side } ); + mw.hook( 'mw.cx.cta.shown' ).fire( campaign ); } $( function () { diff --git a/modules/dashboard/ext.cx.dashboard.js b/modules/dashboard/ext.cx.dashboard.js index 0ef91a8..9a5c831 100644 --- a/modules/dashboard/ext.cx.dashboard.js +++ b/modules/dashboard/ext.cx.dashboard.js @@ -72,6 +72,9 @@ sourceSelectorOptions.sourceTitle = query.page; sourceSelectorOptions.targetTitle = query.targettitle; this.$newTranslationButton.cxSourceSelector( sourceSelectorOptions ); + if ( query.campaign ) { + mw.hook( 'mw.cx.cta.accept' ).fire( query.campaign, query.from, query.to ); + } }; $.fn.cxDashboard = function ( siteMapper, options ) { diff --git a/modules/entrypoint/ext.cx.entrypoint.js b/modules/entrypoint/ext.cx.entrypoint.js index 14920f3..19d07f6 100644 --- a/modules/entrypoint/ext.cx.entrypoint.js +++ b/modules/entrypoint/ext.cx.entrypoint.js @@ -108,6 +108,7 @@ this.shown = true; this.position(); this.$titleInput.focus(); + mw.hook( 'mw.cx.cta.shown' ).fire( this.options.entryPointName ); }; /** @@ -137,9 +138,9 @@ CXEntryPoint.prototype.hide = function () { if ( this.shown ) { this.$dialog.hide(); + mw.hook( 'mw.cx.cta.reject' ).fire( this.options.entryPointName ); + this.shown = false; } - - this.shown = false; }; /** @@ -154,7 +155,8 @@ sourceTitle, this.$titleInput.val(), sourceLanguage, - this.options.targetLanguage + this.options.targetLanguage, + this.options.entryPointName ); }; diff --git a/modules/entrypoint/ext.cx.redlink.js b/modules/entrypoint/ext.cx.redlink.js index 36d6511..4d3d48d 100644 --- a/modules/entrypoint/ext.cx.redlink.js +++ b/modules/entrypoint/ext.cx.redlink.js @@ -11,6 +11,7 @@ ( function ( $, mw ) { 'use strict'; + var campaign = 'redinterlanguagelink'; /** * Get the list of target languages that should be suggested * to the current user: @@ -159,7 +160,8 @@ $pLangList.prepend( $newItem ); $newItem.cxEntryPoint( { targetLanguage: code, - left: cxEntryPointDialogLeft + left: cxEntryPointDialogLeft, + entryPointName: campaign } ); } } ); diff --git a/modules/eventlogging/ext.cx.eventlogging.js b/modules/eventlogging/ext.cx.eventlogging.js index 2994255..1bec68f 100644 --- a/modules/eventlogging/ext.cx.eventlogging.js +++ b/modules/eventlogging/ext.cx.eventlogging.js @@ -14,31 +14,19 @@ * ContentTranslation event logger */ function ContentTranslationEventLogging() { - this.defaults = { - version: 1, - token: mw.user.id() - }; this.listen(); } ContentTranslationEventLogging.prototype = { /** - * Log the event - * - * @param {Object} event Event action and optional fields - */ - log: function ( event ) { - mw.track( 'event.ContentTranslation', $.extend( {}, event, this.defaults ) ); - }, - - /** * Listen for event logging. */ 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.translatedPageCreated, 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 ) ); }, /** @@ -47,11 +35,48 @@ * @param {string} targetLanguage Target language code */ translatedPageCreated: function ( contentLanguage, targetLanguage ) { - this.log( { + mw.track( 'event.ContentTranslation', { + version: 1, + token: mw.user.id(), action: 'create-translated-page', contentLanguage: contentLanguage, targetLanguage: targetLanguage } ); + }, + + ctaShown: function ( campaign ) { + mw.track( 'event.ContentTranslationCTA', { + version: 1, + cta: campaign, + action: 'shown', + session: mw.user.sessionId(), + contentLanguage: mw.config.get( 'wgContentLanguage' ), + interfaceLanguage: mw.config.get( 'wgUserLanguage' ) + } ); + }, + + ctaAccept: function ( campaign, sourceLanguage, targetLanguage ) { + mw.track( 'event.ContentTranslationCTA', { + version: 1, + cta: campaign, + action: 'accept', + session: mw.user.sessionId(), + contentLanguage: mw.config.get( 'wgContentLanguage' ), + interfaceLanguage: mw.config.get( 'wgUserLanguage' ), + sourceLanguage: sourceLanguage, + targetLanguage: targetLanguage + } ); + }, + + ctaReject: function ( campaign ) { + mw.track( 'event.ContentTranslationCTA', { + version: 1, + cta: campaign, + action: 'reject', + session: mw.user.sessionId(), + contentLanguage: mw.config.get( 'wgContentLanguage' ), + interfaceLanguage: mw.config.get( 'wgUserLanguage' ) + } ); } }; -- To view, visit https://gerrit.wikimedia.org/r/197489 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3b1d54f879ba49542b4bda9585aa02f994ba2ac3 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