mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/WikiEditor
synced 2024-11-27 09:42:11 +00:00
Log whether Javascript was supported on saveSuccess
Adds a hidden field to the edit page form, with JS that will set its value. Server-side then checks for that value and logs whether it was correctly set. Bug: T263505 Change-Id: I8be06385aa6d97e5536cfc252d34297e1c000a32
This commit is contained in:
parent
c2d73ba007
commit
cb1c5d49aa
|
@ -16,6 +16,22 @@ class WikiEditorHooks {
|
|||
|
||||
/* Static Methods */
|
||||
|
||||
/**
|
||||
* Should the current session be sampled for EventLogging?
|
||||
*
|
||||
* @param string $sessionId
|
||||
* @return bool Whether to sample the session
|
||||
*/
|
||||
protected static function inEventSample( $sessionId ) {
|
||||
global $wgWMESchemaEditAttemptStepSamplingRate;
|
||||
// Sample 6.25%
|
||||
$samplingRate = $wgWMESchemaEditAttemptStepSamplingRate ?? 0.0625;
|
||||
$inSample = EventLogging::sessionInSample(
|
||||
(int)( 1 / $samplingRate ), $sessionId
|
||||
);
|
||||
return $inSample;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log stuff to EventLogging's Schema:EditAttemptStep -
|
||||
* see https://meta.wikimedia.org/wiki/Schema:EditAttemptStep
|
||||
|
@ -27,16 +43,11 @@ class WikiEditorHooks {
|
|||
* @return bool Whether the event was logged or not.
|
||||
*/
|
||||
public static function doEventLogging( $action, $article, $data = [] ) {
|
||||
global $wgWMESchemaEditAttemptStepSamplingRate;
|
||||
$extensionRegistry = ExtensionRegistry::getInstance();
|
||||
if ( !$extensionRegistry->isLoaded( 'EventLogging' ) ) {
|
||||
return false;
|
||||
}
|
||||
// Sample 6.25%
|
||||
$samplingRate = $wgWMESchemaEditAttemptStepSamplingRate ?? 0.0625;
|
||||
$inSample = EventLogging::sessionInSample(
|
||||
(int)( 1 / $samplingRate ), $data['editing_session_id']
|
||||
);
|
||||
$inSample = self::inEventSample( $data['editing_session_id'] );
|
||||
$shouldOversample = $extensionRegistry->isLoaded( 'WikimediaEvents' ) &&
|
||||
WikimediaEventsHooks::shouldSchemaEditAttemptStepOversample( $article->getContext() );
|
||||
if ( !$inSample && !$shouldOversample ) {
|
||||
|
@ -75,6 +86,49 @@ class WikiEditorHooks {
|
|||
return EventLogging::logEvent( 'EditAttemptStep', 18530416, $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Log stuff to EventLogging's Schema:VisualEditorFeatureUse -
|
||||
* see https://meta.wikimedia.org/wiki/Schema:VisualEditorFeatureUse
|
||||
* If you don't have EventLogging installed, does nothing.
|
||||
*
|
||||
* @param string $feature
|
||||
* @param string $action
|
||||
* @param Article $article Which article (with full context, page, title, etc.)
|
||||
* @param string $sessionId Session identifier
|
||||
* @return bool Whether the event was logged or not.
|
||||
*/
|
||||
public static function doVisualEditorFeatureUseLogging( $feature, $action, $article, $sessionId ) {
|
||||
$extensionRegistry = ExtensionRegistry::getInstance();
|
||||
if ( !$extensionRegistry->isLoaded( 'EventLogging' ) ) {
|
||||
return false;
|
||||
}
|
||||
$inSample = self::inEventSample( $sessionId );
|
||||
$shouldOversample = $extensionRegistry->isLoaded( 'WikimediaEvents' ) &&
|
||||
WikimediaEventsHooks::shouldSchemaEditAttemptStepOversample( $article->getContext() );
|
||||
if ( !$inSample && !$shouldOversample ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$user = $article->getContext()->getUser();
|
||||
|
||||
$data = [
|
||||
'feature' => $feature,
|
||||
'action' => $action,
|
||||
'editing_session_id' => $sessionId,
|
||||
'platform' => 'desktop', // FIXME T249944
|
||||
'integration' => 'page',
|
||||
'editor_interface' => 'wikitext',
|
||||
'user_id' => $user->getId(),
|
||||
'user_editcount' => $user->getEditCount() ?: 0,
|
||||
];
|
||||
|
||||
if ( $user->getOption( 'discussiontools-abtest' ) ) {
|
||||
$data['bucket'] = $user->getOption( 'discussiontools-abtest' );
|
||||
}
|
||||
|
||||
return EventLogging::logEvent( 'VisualEditorFeatureUse', 21199762, $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* EditPage::showEditForm:initial hook
|
||||
*
|
||||
|
@ -177,6 +231,18 @@ class WikiEditorHooks {
|
|||
)
|
||||
);
|
||||
}
|
||||
|
||||
$outputPage->addHTML(
|
||||
Xml::element(
|
||||
'input',
|
||||
[
|
||||
'type' => 'hidden',
|
||||
'name' => 'wikieditorJavascriptSupport',
|
||||
'id' => 'wikieditorJavascriptSupport',
|
||||
'value' => ''
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -299,6 +365,12 @@ class WikiEditorHooks {
|
|||
|
||||
if ( $status->isOK() ) {
|
||||
$action = 'saveSuccess';
|
||||
|
||||
if ( $request->getVal( 'wikieditorJavascriptSupport' ) === 'yes' ) {
|
||||
self::doVisualEditorFeatureUseLogging(
|
||||
'mwSave', 'source-has-js', $article, $request->getVal( 'editingStatsId' )
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$action = 'saveFailure';
|
||||
|
||||
|
|
|
@ -155,6 +155,9 @@
|
|||
origText = $textarea.val(),
|
||||
submitting, onUnloadFallback, readyTime;
|
||||
|
||||
// Tracking Javascript support: T263505
|
||||
$( '#wikieditorJavascriptSupport' ).val( 'yes' );
|
||||
|
||||
if ( $editingSessionIdInput.length ) {
|
||||
editingSessionId = $editingSessionIdInput.val();
|
||||
if ( window.performance && window.performance.timing ) {
|
||||
|
|
Loading…
Reference in a new issue