Page MenuHomeWickedGov Phorge

index.js
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

index.js

( function () {
'use strict';
const streamName = 'mediawiki.product_metrics.translate_extension';
const schemaId = '/analytics/product_metrics/web/translation/1.0.0';
const config = require( './config.json' );
const eventLoggingHelpers = {
isEventLoggingEnabled: function () {
return config.TranslateEnableEventLogging;
},
/**
* @param {string|null} actionSubtype
* @param {string|null} actionSource
* @param {Object|null} translation
*/
logClickEvent: function ( actionSubtype, actionSource, translation ) {
if ( !this.isEventLoggingEnabled() ) {
return;
}
const interactionData = {
translation: translation || {}
};
if ( actionSubtype ) {
// eslint-disable-next-line camelcase
interactionData.action_subtype = actionSubtype;
}
if ( actionSource ) {
// eslint-disable-next-line camelcase
interactionData.action_source = actionSource;
}
mw.eventLog.submitInteraction( streamName, schemaId, 'click', interactionData );
},
/**
* @param {string} action
* @param {string|null} actionSubtype
* @param {string|null} actionSource
* @param {Object|null} translation
*/
logEvent: function ( action, actionSubtype, actionSource, translation ) {
if ( !config.TranslateEnableEventLogging ) {
return;
}
const interactionData = {
translation: translation || {}
};
if ( actionSubtype ) {
// eslint-disable-next-line camelcase
interactionData.action_subtype = actionSubtype;
}
if ( actionSource ) {
// eslint-disable-next-line camelcase
interactionData.action_source = actionSource;
}
mw.eventLog.submitInteraction( streamName, schemaId, action, interactionData );
}
};
module.exports = eventLoggingHelpers;
}() );

File Metadata

Mime Type
text/plain
Expires
Wed, Aug 19, 10:04 (2 w, 5 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
d3/80/0e3a5e8f464f8b37ad04e7913ccf
Default Alt Text
index.js (1 KB)

Event Timeline