Lucas Werkmeister (WMDE) has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/391858 )
Change subject: Add HTTP header indicating gadget to API requests ...................................................................... Add HTTP header indicating gadget to API requests This adds an HTTP header “X-MediaWiki-Gadget” to all API requests by the gadget. If the gadget is loaded as a ResourceLoader module (as it should be), the header’s value is “checkConstraints”, otherwise (for instance, if someone copied the code to their common.js) the value is “checkConstraints-custom”. This should give us an idea of how many external users of the constraint APIs outside of the gadget exist (corresponding to API requests without the header). Change-Id: I37caea4c4eda720a16ab4735355dfaca51c2371a --- M modules/gadget.js 1 file changed, 14 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints refs/changes/58/391858/1 diff --git a/modules/gadget.js b/modules/gadget.js index 8974419..6603bd6 100644 --- a/modules/gadget.js +++ b/modules/gadget.js @@ -261,6 +261,19 @@ } } + function mwApiOptions() { + var gadgetState = mw.loader.getState( 'wikibase.quality.constraints.gadget' ); + return { + ajax: { + headers: { + 'X-MediaWiki-Gadget': gadgetState === 'executing' ? + 'checkConstraints' : + 'checkConstraints-custom' + } + } + }; + } + entityId = mw.config.get( 'wbEntityId' ); if ( entityId === null || mw.config.get( 'wgMFMode' ) ) { @@ -276,7 +289,7 @@ 'wikibase.quality.constraints.icon', 'wikibase.quality.constraints.ui' ] ).done( function () { - var api = new mw.Api(), + var api = new mw.Api( mwApiOptions() ), lang = mw.config.get( 'wgUserLanguage' ); api.get( { action: 'wbcheckconstraints', -- To view, visit https://gerrit.wikimedia.org/r/391858 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I37caea4c4eda720a16ab4735355dfaca51c2371a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints Gerrit-Branch: master Gerrit-Owner: Lucas Werkmeister (WMDE) <lucas.werkmeis...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits