diff --git a/extension.json b/extension.json index 4ef00fe53..3edce08e9 100644 --- a/extension.json +++ b/extension.json @@ -203,6 +203,7 @@ }, "Hooks": { "BeforePageDisplay": "DiscussionToolsHooks::onBeforePageDisplay", + "ResourceLoaderGetConfigVars": "DiscussionToolsHooks::onResourceLoaderGetConfigVars", "GetBetaFeaturePreferences": "DiscussionToolsHooks::onGetBetaPreferences", "ListDefinedTags": "DiscussionToolsHooks::onListDefinedTags", "ChangeTagsListActive": "DiscussionToolsHooks::onListDefinedTags", @@ -220,6 +221,14 @@ "DiscussionToolsUseVisualEditor": { "value": false, "description": "Use VisualEditor for editing replies (both visual and wikitext)." + }, + "DTSchemaEditAttemptStepSamplingRate": { + "value": false, + "description": "Rate at which to sample sessions for instrumentation; overrides WikimediaEvents rate if set" + }, + "DTSchemaEditAttemptStepOversample": { + "value": false, + "description": "Oversample EditAttemptStep logging; distinct from rate tuning, as it'll flag the events as being oversampled" } }, "ConfigRegistry": { diff --git a/includes/DiscussionToolsHooks.php b/includes/DiscussionToolsHooks.php index 86f7afc72..d1cd80c1c 100644 --- a/includes/DiscussionToolsHooks.php +++ b/includes/DiscussionToolsHooks.php @@ -80,6 +80,23 @@ class DiscussionToolsHooks { } } + /** + * Set static (not request-specific) JS configuration variables + * + * @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderGetConfigVars + * @param array &$vars Array of variables to be added into the output of the startup module + * @param string $skinName Current skin name to restrict config variables to a certain skin + */ + public static function onResourceLoaderGetConfigVars( &$vars, $skinName ) { + $dtConfig = MediaWikiServices::getInstance()->getConfigFactory() + ->makeConfig( 'discussiontools' ); + + $vars['wgDTSchemaEditAttemptStepSamplingRate'] = + $dtConfig->get( 'DTSchemaEditAttemptStepSamplingRate' ); + $vars['wgDTSchemaEditAttemptStepOversample'] = + $dtConfig->get( 'DTSchemaEditAttemptStepOversample' ); + } + /** * Handler for the GetBetaPreferences hook, to add and hide user beta preferences as configured * diff --git a/modules/logger.js b/modules/logger.js index 6bfd90c5f..9dfc6aeb3 100644 --- a/modules/logger.js +++ b/modules/logger.js @@ -18,7 +18,8 @@ mw.loader.using( 'ext.eventLogging' ).done( function () { var // Schema class is provided by ext.eventLogging Schema = mw.eventLog.Schema, user = mw.user, - sampleRate = mw.config.get( 'wgWMESchemaEditAttemptStepSamplingRate' ), + sampleRate = mw.config.get( 'wgDTSchemaEditAttemptStepSamplingRate' ) || + mw.config.get( 'wgWMESchemaEditAttemptStepSamplingRate' ), actionPrefixMap = { firstChange: 'first_change', saveIntent: 'save_intent', @@ -180,7 +181,10 @@ mw.loader.using( 'ext.eventLogging' ).done( function () { } else { schemaEditAttemptStep.log( data, - mw.config.get( 'wgWMESchemaEditAttemptStepOversample' ) ? 1 : sampleRate + ( + mw.config.get( 'wgDTSchemaEditAttemptStepOversample' ) || + mw.config.get( 'wgWMESchemaEditAttemptStepOversample' ) + ) ? 1 : sampleRate ); } } );