Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/246464

Change subject: Log the save and restore failures to eventlogging system
......................................................................

Log the save and restore failures to eventlogging system

Uses https://meta.wikimedia.org/wiki/Schema:ContentTranslationError

Bug: T104059
Change-Id: I51b661b79685c02aad290e9c58c43c4b9f591b71
---
M modules/draft/ext.cx.draft.js
M modules/eventlogging/ext.cx.eventlogging.js
2 files changed, 80 insertions(+), 9 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/64/246464/1

diff --git a/modules/draft/ext.cx.draft.js b/modules/draft/ext.cx.draft.js
index 6ea852e..5e1e860 100644
--- a/modules/draft/ext.cx.draft.js
+++ b/modules/draft/ext.cx.draft.js
@@ -158,13 +158,23 @@
                                self.restore();
                                mw.hook( 'mw.cx.draft.restored' ).fire();
                        } );
-               } ).fail( function () {
+               } ).fail( function ( errorCode, details ) {
                        var uri = new mw.Uri();
 
                        // Wrong draft id passed.
                        delete uri.query.draft;
                        location.href = uri.toString();
-                       mw.hook( 'mw.cx.draft.restore-failed' ).fire();
+
+                       if ( details.exception instanceof Error ) {
+                               details.exception = 
details.exception.toString();
+                       }
+                       details.errorCode = errorCode;
+                       mw.hook( 'mw.cx.draft.restore-failed' ).fire(
+                               mw.cx.sourceLanguage,
+                               mw.cx.targetLanguage,
+                               mw.cx.sourceTitle,
+                               this.targetTitle,
+                               JSON.stringify( details ) );
                } );
        };
 
@@ -352,11 +362,20 @@
                        timer = setInterval( function () {
                                checkAndsave();
                        }, 5 * 60 * 1000 );
-               } ).fail( function ( errorCode ) {
+               } ).fail( function ( errorCode, details ) {
                        if ( errorCode === 'assertuserfailed' ) {
                                mw.hook( 'mw.cx.error' ).fire( mw.msg( 
'cx-lost-session-draft' ) );
                        }
-                       mw.hook( 'mw.cx.translation.save-failed' ).fire();
+                       if ( details.exception instanceof Error ) {
+                               details.exception = 
details.exception.toString();
+                       }
+                       details.errorCode = errorCode;
+                       mw.hook( 'mw.cx.translation.save-failed' ).fire(
+                               mw.cx.sourceLanguage,
+                               mw.cx.targetLanguage,
+                               mw.cx.sourceTitle,
+                               this.targetTitle,
+                               JSON.stringify( details ) );
                } );
        };
 
diff --git a/modules/eventlogging/ext.cx.eventlogging.js 
b/modules/eventlogging/ext.cx.eventlogging.js
index 056c08c..8b4af6c 100644
--- a/modules/eventlogging/ext.cx.eventlogging.js
+++ b/modules/eventlogging/ext.cx.eventlogging.js
@@ -32,6 +32,8 @@
                        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 ) );
+                       mw.hook( 'mw.cx.draft.restore-failed' ).add( $.proxy( 
this.restoreFailed, this ) );
+                       mw.hook( 'mw.cx.translation.save-failed' ).add( 
$.proxy( this.saveFailed, this ) );
                },
 
                /**
@@ -56,7 +58,8 @@
 
                /**
                 * Log publish failures
-                * @param {string} contentLanguage source language
+                *
+                * @param {string} sourceLanguage source language
                 * @param {string} targetLanguage Target language code
                 * @param {string} sourceTitle Source title
                 * @param {string} targetTitle Target title
@@ -87,8 +90,55 @@
                },
 
                /**
+                * Log save failures
+                *
+                * @param {string} sourceLanguage source language
+                * @param {string} targetLanguage Target language code
+                * @param {string} sourceTitle Source title
+                * @param {string} targetTitle Target title
+                * @param {string} trace Error trace
+                */
+               saveFailed: function ( sourceLanguage, targetLanguage, 
sourceTitle, targetTitle, trace ) {
+                       mw.track( 'event.ContentTranslationError', {
+                               version: 1,
+                               token: mw.user.id(),
+                               session: mw.user.sessionId(),
+                               context: 'save-failure',
+                               sourceLanguage: sourceLanguage,
+                               targetLanguage: targetLanguage,
+                               sourceTitle: sourceTitle,
+                               targetTitle: targetTitle,
+                               trace: trace.substring( 0, 500 )
+                       } );
+               },
+
+               /**
+                * Log translation restore failures
+                *
+                * @param {string} sourceLanguage source language
+                * @param {string} targetLanguage Target language code
+                * @param {string} sourceTitle Source title
+                * @param {string} targetTitle Target title
+                * @param {string} trace Error trace
+                */
+               restoreFailed: function ( sourceLanguage, targetLanguage, 
sourceTitle, targetTitle, trace ) {
+                       mw.track( 'event.ContentTranslationError', {
+                               version: 1,
+                               token: mw.user.id(),
+                               session: mw.user.sessionId(),
+                               context: 'restore-failure',
+                               sourceLanguage: sourceLanguage,
+                               targetLanguage: targetLanguage,
+                               sourceTitle: sourceTitle,
+                               targetTitle: targetTitle,
+                               trace: trace.substring( 0, 500 )
+                       } );
+               },
+
+               /**
                 * Log saving(draft) of translated page.
-                * @param {string} contentLanguage source language
+                *
+                * @param {string} sourceLanguage source language
                 * @param {string} targetLanguage Target language code
                 * @param {string} sourceTitle Source title
                 * @param {string} targetTitle Target title
@@ -111,8 +161,9 @@
                },
 
                /**
-                * Log continuing translation
-                * @param {string} contentLanguage source language
+                * Log continuing translation.
+                *
+                * @param {string} sourceLanguage source language
                 * @param {string} targetLanguage Target language code
                 * @param {string} sourceTitle Source title
                 */
@@ -130,7 +181,8 @@
 
                /**
                 * Log deletion of translated page.
-                * @param {string} contentLanguage Source language code
+                *
+                * @param {string} sourceLanguage Source language code
                 * @param {string} targetLanguage Target language code
                 * @param {string} sourceTitle Source title
                 * @param {string} targetTitle Target title

-- 
To view, visit https://gerrit.wikimedia.org/r/246464
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I51b661b79685c02aad290e9c58c43c4b9f591b71
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

Reply via email to