Release status: stable
|Implementation||Special page, Database, ContentHandler|
|Description||Provides a framework for logging analytics events|
|Latest version||continuous updates|
|License||GNU General Public License 2.0 or later|
|Quarterly downloads||82 (Ranked 91st)|
|Public wikis using||1,078 (Ranked 221st)|
|Translate the EventLogging extension if it is available at translatewiki.net|
|Issues||Open tasks · Report a bug|
The EventLogging extension makes it possible to collect structured data on how users interact with MediaWiki sites.
- Logging behavior can be dynamically configured using Extension:EventStreamConfig.
- The events are JSON objects defined by versioned JSONSchemas stored in a schema git repository.
- The extension does not include any back-end code for transporting, parsing, or loading these events. A separate service, EventGate, implements this functionality and deals with inserting events into Kafka. Events are then persisted in downstream datastores (e.g. Hive) via various ingestion pipelines. The details of these components are specific to Wikimedia Foundation's configuration.
EventLogging at Wikimedia
This page is about general use of the EventLogging extension. The Wikimedia Foundation uses EventLogging with WMF specific backend components and schema repositories. For Wikimedia specific and maintained documentation, see wikitech:Analytics/Systems/EventLogging and wikitech:Event Platform.
- Download and move the extracted
EventLoggingfolder to your
Developers and code contributors should install the extension from Git instead, using:
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/EventLogging
- Add the following code at the bottom of your LocalSettings.php file:
wfLoadExtension( 'EventLogging' ); $wgEventLoggingBaseUri = '/beacon/event'; $wgEventLoggingServiceUri = '/beacon/intake-analytics'; $wgEventLoggingStreamNames = false;
- Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
- If using Vagrant, install with
vagrant roles enable eventlogging --provision
Configuring the schema location
By default, the extension will look for schemas on Meta-Wiki. The relevant default settings are:
# (default) $wgEventLoggingSchemaApiUri = 'https://meta.wikimedia.org/w/api.php'; # (default) $wgEventLoggingDBname = 'metawiki';
To use local schemas, or schemas from the central wiki of your own wikifarm, you need to override these. E.g. to use the
Schema namespace of the local wiki, set
$wgEventLoggingSchemaApiUri = $wgServer . '/w/api.php'; $wgEventLoggingDBname = $wgDBname;
(and ensure the user account that will create the schemas is autoconfirmed).
Logging events using EventLogging
- Extension:EventLogging/Guide - to developing and deploying EventLogging schemas, and more
- Extension:EventLogging/Programming - tips and suggestions for developers writing code to log events
Developing the EventLogging extension
As a developer, you will want to set up and use EventLogging on your development wiki to simulate its use in production.
If you develop using mediawiki-vagrant, everything you need is encapsulated in the
To enable it, run:
$ vagrant roles enable eventlogging $ vagrant provision
npm install from the folder you're developing in.
Then you can use
npm test to run ESLint for example.
When adding the parameter
trackdebug=true to the URL, the console in the browser's devtools will show the event logging being triggered.
How to run tests
To run PHP tests, we use PHPUnit. Make sure it is installed, then:
$ vagrant ssh vagrant@mediawiki-vagrant:/vagrant/mediawiki$ composer phpunit:entrypoint -- extensions/EventLogging/testsEventLoggingExtensionFunctionsTest.php
|This extension is being used on one or more Wikimedia projects. This probably means that the extension is stable and works well enough to be used by such high-traffic websites. Look for this extension's name in Wikimedia's CommonSettings.php and InitialiseSettings.php configuration files to see where it's installed. A full list of the extensions installed on a particular wiki can be seen on the wiki's Special:Version page.|
|This extension is included in the following wiki farms/hosts and/or packages:|