Page MenuHomeWickedGov Phorge

useInstrument.js
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

useInstrument.js

'use strict';
/**
* Additional context for an instrumentation event.
*
* @typedef {Object} InteractionData
* @property {number} [sessionLength] The duration IP auto-reveal mode is enabled for, in seconds
*/
/**
* @callback LogEvent Log an event to the IP auto-reveal event stream.
*
* @param {string} action
* @param {InteractionData} [data]
*/
/**
* Composable to create an event logging function configured to log events to the
* IP auto-reveal event stream.
*
* @return {LogEvent}
*/
const useInstrument = () => {
if ( !mw.eventLog ) {
// EventLogging is not installed
return () => {};
}
const instrument = mw.eventLog.newInstrument(
'mediawiki.product_metrics.checkuser_ip_auto_reveal_interaction',
'/analytics/product_metrics/web/base/1.4.2'
);
return ( action, data = {} ) => {
const interactionData = {};
if ( data.sessionLength ) {
// eslint-disable-next-line camelcase
interactionData.action_context = JSON.stringify( {
// eslint-disable-next-line camelcase
session_length: data.sessionLength
} );
}
instrument.submitInteraction( action, interactionData );
};
};
module.exports = useInstrument;

File Metadata

Mime Type
text/plain
Expires
Sat, Oct 3, 03:47 (3 w, 4 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
48/af/382fe9192777ef527afb61b4b2d4
Default Alt Text
useInstrument.js (1 KB)

Event Timeline