Bmansurov has uploaded a new change for review.
https://gerrit.wikimedia.org/r/169626
Change subject: WIP: WikiGrok error logging
......................................................................
WIP: WikiGrok error logging
Change-Id: Ife929050b118724c10bf1df27ca71e72f187330b
---
M includes/MobileFrontend.hooks.php
A javascripts/loggingSchemas/mobileWebWikiGrokError.js
M javascripts/modules/wikigrok/WikiDataApi.js
M javascripts/modules/wikigrok/WikiGrokDialog.js
4 files changed, 58 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/26/169626/1
diff --git a/includes/MobileFrontend.hooks.php
b/includes/MobileFrontend.hooks.php
index c9599c6..35b6e3d 100644
--- a/includes/MobileFrontend.hooks.php
+++ b/includes/MobileFrontend.hooks.php
@@ -833,6 +833,7 @@
'MobileWebCta' => 5972684,
'MobileWebClickTracking' => 5929948,
'MobileWebWikiGrok' => 10286500,
+ 'MobileWebWikiGrokError' => 10352248,
);
$schemas += $mobileEventLoggingSchemas;
@@ -872,6 +873,7 @@
'javascripts/loggingSchemas/mobileWebEditing.js',
'javascripts/loggingSchemas/MobileWebClickTracking.js',
'javascripts/loggingSchemas/mobileWebWikiGrok.js',
+ 'javascripts/loggingSchemas/mobileWebWikiGrokError.js',
);
$wgResourceModules['mobile.loggingSchemas'] =
$wgMFMobileResourceBoilerplate + array(
diff --git a/javascripts/loggingSchemas/mobileWebWikiGrokError.js
b/javascripts/loggingSchemas/mobileWebWikiGrokError.js
new file mode 100644
index 0000000..f50c4cc
--- /dev/null
+++ b/javascripts/loggingSchemas/mobileWebWikiGrokError.js
@@ -0,0 +1,13 @@
+( function ( M, $ ) {
+ function log( data ) {
+ var options = {
+ pageId: mw.config.get( 'wgArticleId' ),
+ mobileMode: mw.config.get( 'wgMFMode' )
+ };
+ return M.log( 'MobileWebWikiGrokError', $.extend( options, data
) );
+ }
+
+ M.define( 'loggingSchemas/mobileWebWikiGrokError', { log: log } );
+
+} )( mw.mobileFrontend, jQuery );
+
diff --git a/javascripts/modules/wikigrok/WikiDataApi.js
b/javascripts/modules/wikigrok/WikiDataApi.js
index c0d3fe0..142fb7e 100644
--- a/javascripts/modules/wikigrok/WikiDataApi.js
+++ b/javascripts/modules/wikigrok/WikiDataApi.js
@@ -14,7 +14,9 @@
Api.prototype.initialize.apply( this, arguments );
},
getClaims: function () {
- var id = this.subjectId;
+ var self = this,
+ id = this.subjectId;
+
return this.ajax( {
action: 'wbgetentities',
ids: id,
@@ -24,7 +26,8 @@
var instanceClaims, entityClaims,
claims = {};
// See if the page has any 'instance of' claims.
- if ( data.entities !== undefined &&
data.entities[id].claims.P31 !== undefined ) {
+ if ( data.entities !== undefined &&
data.entities[id ].claims !== undefined &&
+ data.entities[id].claims.P31 !==
undefined ) {
entityClaims = data.entities[id].claims;
instanceClaims = entityClaims.P31;
@@ -38,8 +41,11 @@
} );
return claims;
} else {
+ self.logError(
'no-impression-cannot-fetch-claims' );
return false;
}
+ } ).fail( function () {
+ self.logError(
'no-impression-cannot-fetch-claims' );
} );
},
/**
diff --git a/javascripts/modules/wikigrok/WikiGrokDialog.js
b/javascripts/modules/wikigrok/WikiGrokDialog.js
index af4c71c..592a131 100644
--- a/javascripts/modules/wikigrok/WikiGrokDialog.js
+++ b/javascripts/modules/wikigrok/WikiGrokDialog.js
@@ -5,6 +5,7 @@
WikiGrokApi = M.require( 'modules/wikigrok/WikiGrokApi' ),
WikiDataApi = M.require( 'modules/wikigrok/WikiDataApi' ),
schema = M.require( 'loggingSchemas/mobileWebWikiGrok' ),
+ errorSchema = M.require(
'loggingSchemas/mobileWebWikiGrokError' ),
WikiGrokDialog,
timer = null,
$window = $( window );
@@ -57,6 +58,11 @@
} );
},
+ /**
+ * Log data to the schema
+ * @method
+ * @param {string} action
+ */
log: function ( action ) {
var data = {
action: action,
@@ -73,6 +79,26 @@
}
schema.log( data );
},
+
+ /**
+ * Log data to the error schema
+ * @method
+ * @param {string} error
+ */
+ logError: function ( error ) {
+ var data = {
+ error: error,
+ taskType: 'version ' + this.version,
+ taskToken: this.defaults.taskToken,
+ userToken: this.options.userToken,
+ isLoggedIn: !mw.user.isAnon()
+ };
+ if ( this.options.testing ) {
+ data.testing = true;
+ }
+ errorSchema.log( data );
+ },
+
/**
* Return a new array from 'array' with 'count' randomly
selected elements.
* @param {Array} array Array from which random elements are
selected
@@ -180,6 +206,8 @@
this.apiWikiGrok.recordClaims( [ claim ] ).done(
function () {
options.claimRecorded = true;
self.thankUser( options, options.claimRecorded
);
+ } ).fail(function () {
+ self.logError(
'no-response-cannot-record-user-input' );
} );
},
@@ -345,16 +373,20 @@
options.suggestions = [];
self.apiWikiData.getClaims().done( function (
claims ) {
if ( claims.isHuman ) {
-
self.apiWikiGrok.getSuggestions().done( function ( suggestions ) {
+
self.apiWikiGrok.getSuggestions().fail( function () {
+ self.logError(
'no-impression-cannot-fetch-suggestions' );
+ } ).done( function (
suggestions ) {
// FIXME: add support
for DOB and DOD
- if (
suggestions.occupations.list.length ) {
+ if (
suggestions.occupations && suggestions.occupations.list.length ) {
options.suggestions.push( suggestions.occupations );
}
- if (
suggestions.nationalities.list.length ) {
+ if (
suggestions.nationalities && suggestions.nationalities.list.length ) {
options.suggestions.push( suggestions.nationalities );
}
if (
options.suggestions.length ) {
self.show();
+ } else {
+ self.logError(
'no-impression-not-enough-suggestions' );
}
} );
}
--
To view, visit https://gerrit.wikimedia.org/r/169626
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ife929050b118724c10bf1df27ca71e72f187330b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Bmansurov <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits