diff --git a/extension.json b/extension.json index eef774fb..c1b4e463 100644 --- a/extension.json +++ b/extension.json @@ -76,6 +76,7 @@ "widgets/LanguageResultWidget.js", "widgets/LanguageSearchWidget.js", "Dialog.js", + "Metrics.js", "Target.js" ], "dependencies": [ @@ -214,6 +215,11 @@ ] }, "attributes": { + "EventLogging": { + "Schemas": { + "TemplateDataEditor": 20735408 + } + }, "VisualEditor": { "PluginModules": [ "ext.templateDataGenerator.editPage" diff --git a/modules/ext.templateDataGenerator.editTemplatePage/Dialog.js b/modules/ext.templateDataGenerator.editTemplatePage/Dialog.js index 1a1be459..4160e380 100644 --- a/modules/ext.templateDataGenerator.editTemplatePage/Dialog.js +++ b/modules/ext.templateDataGenerator.editTemplatePage/Dialog.js @@ -1,4 +1,5 @@ var LanguageSearchWidget = require( './widgets/LanguageSearchWidget.js' ), + Metrics = require( './Metrics.js' ), Model = require( 'ext.templateDataGenerator.data' ).Model, ParamImportWidget = require( './widgets/ParamImportWidget.js' ), ParamSelectWidget = require( './widgets/ParamSelectWidget.js' ), @@ -385,7 +386,6 @@ Dialog.prototype.initialize = function () { change: 'onTemplateFormatInputWidgetChange', enter: 'onTemplateFormatInputWidgetEnter' } ); - }; /** @@ -1413,6 +1413,9 @@ Dialog.prototype.setupDetailsFromModel = function () { // Repopulate the parameter list this.repopulateParamSelectWidget(); + + Metrics.logEvent( this.model.getOriginalTemplateDataObject() ? + 'dialog-open-edit' : 'dialog-open-create' ); }; /** diff --git a/modules/ext.templateDataGenerator.editTemplatePage/Metrics.js b/modules/ext.templateDataGenerator.editTemplatePage/Metrics.js new file mode 100644 index 00000000..37fceb00 --- /dev/null +++ b/modules/ext.templateDataGenerator.editTemplatePage/Metrics.js @@ -0,0 +1,17 @@ +function logEvent( eventName ) { + mw.track( 'event.TemplateDataEditor', { + /* eslint-disable camelcase */ + action: eventName, + page_id: mw.config.get( 'wgArticleId' ), + page_title: mw.config.get( 'wgPageName' ), + page_namespace: mw.config.get( 'wgNamespaceNumber' ), + rev_id: mw.config.get( 'wgCurRevisionId' ), + user_edit_count: mw.config.get( 'wgUserEditCount', 0 ), + user_id: mw.user.getId() + /* eslint-enable camelcase */ + } ); +} + +module.exports = { + logEvent: logEvent +};