Use EventLogging::submit() to submit analytics events

EventLogging::logEvent() was marked as deprecated at the beginning of
2021 in I0cfd07295d4b51ca4805c79a28a9a4bd64ff7cc9.

Bug: T318263
Change-Id: I2d89784cc249e97954c9be05169f3060fd69945f
This commit is contained in:
Sam Smith 2023-01-30 16:47:15 +00:00
parent 0e789fdbb4
commit 0f4d04e83f
4 changed files with 24 additions and 31 deletions

View file

@ -5,14 +5,9 @@ namespace MediaWiki\Extension\EventLogging;
class EventLogging {
/**
* @param string $schemaName
* @param int $revId
* @param string $streamName
* @param array $event
* @param int $options
* @return bool
*/
public static function logEvent( $schemaName, $revId, $event, $options = 0 ) {
return true;
public static function submit( string $streamName, array $event ): void {
}
}

View file

@ -224,12 +224,6 @@
]
},
"attributes": {
"EventLogging": {
"Schemas": {
"TemplateDataEditor": "/analytics/legacy/templatedataeditor/1.0.0",
"TemplateDataApi": "/analytics/legacy/templatedataapi/1.0.0"
}
},
"VisualEditor": {
"PluginModules": [
"ext.templateDataGenerator.editPage"

View file

@ -181,13 +181,15 @@ class ApiTemplateData extends ApiBase {
// template usage for the Technical Wishes topic area see T258917
if ( ExtensionRegistry::getInstance()->isLoaded( 'EventLogging' ) ) {
foreach ( $resp as $pageInfo ) {
EventLogging::logEvent(
'TemplateDataApi',
-1,
EventLogging::submit(
'eventlogging_TemplateDataApi',
[
'template_name' => $wikiPageFactory->newFromTitle( $pageInfo['title'] )
->getTitle()->getDBkey(),
'has_template_data' => !isset( $pageInfo['notemplatedata'] ),
'$schema' => '/analytics/legacy/templatedataapi/1.0.0',
'event' => [
'template_name' => $wikiPageFactory->newFromTitle( $pageInfo['title'] )
->getTitle()->getDBkey(),
'has_template_data' => !isset( $pageInfo['notemplatedata'] ),
],
]
);
}

View file

@ -138,19 +138,21 @@ class Hooks {
$generatorUsed = RequestContext::getMain()->getRequest()->getBool( 'TemplateDataGeneratorUsed' );
$userEditCount = MediaWikiServices::getInstance()->getUserEditTracker()->getUserEditCount( $user );
// Note: We know that irrelevant changes (e.g. whitespace changes) aren't logged here
EventLogging::logEvent(
'TemplateDataEditor',
-1,
EventLogging::submit(
'eventlogging_TemplateDataEditor',
[
// Note: The "Done" button is disabled unless something changed, which means it's
// very likely (but not guaranteed) the generator was used to make the changes
'action' => $generatorUsed ? 'save-tag-edit-generator-used' : 'save-tag-edit-no-generator',
'page_id' => $pageId,
'page_namespace' => $page->getNamespace(),
'page_title' => $page->getDBkey(),
'rev_id' => $revisionRecord->getId() ?? 0,
'user_edit_count' => $userEditCount ?? 0,
'user_id' => $user->getId(),
'$schema' => '/analytics/legacy/templatedataeditor/1.0.0',
'event' => [
// Note: The "Done" button is disabled unless something changed, which means it's
// very likely (but not guaranteed) the generator was used to make the changes
'action' => $generatorUsed ? 'save-tag-edit-generator-used' : 'save-tag-edit-no-generator',
'page_id' => $pageId,
'page_namespace' => $page->getNamespace(),
'page_title' => $page->getDBkey(),
'rev_id' => $revisionRecord->getId() ?? 0,
'user_edit_count' => $userEditCount ?? 0,
'user_id' => $user->getId(),
],
]
);
}