Extension:EventLogging

From Linux Web Expert

MediaWiki extensions manual
EventLogging
Release status: stable
Implementation Special page , Database , ContentHandler
Description Provides a framework for logging analytics events
Author(s) Ori.livnehtalk
Latest version continuous updates
MediaWiki 1.33+
PHP 5.5+
Database changes No
License GNU General Public License 2.0 or later
Download
  • $wgEventLoggingStreamNames
  • $wgEventLoggingSchemaApiUri
  • $wgEventLoggingServiceUri
  • $wgEventLoggingQueueLingerSeconds
  • $wgEventLoggingBaseUri
  • $wgEventLoggingSchemas
  • $wgEventLoggingDBname
Quarterly downloads Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin').
Public wikis using Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin').
Translate the EventLogging extension if it is available at translatewiki.net
Vagrant role eventlogging
Issues Open tasks · Report a bug

The EventLogging extension makes it possible to collect structured data on how users interact with MediaWiki sites.

Features

  • EventLogging supports client-side logging from JavaScript and server-side logging from PHP.
  • 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

The Wikimedia Foundation uses the EventLogging extension as part of a broader system for collecting, aggregating, storing, and analyzing user data within the limits set out by our privacy policy and data retention guidelines.

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.

Installation

  • <translate> [[<tvar name=2>Special:ExtensionDistributor/EventLogging</tvar>|Download]] and move the extracted <tvar name=name>EventLogging</tvar> folder to your <tvar name=ext>extensions/</tvar> directory.</translate>
    <translate> Developers and code contributors should install the extension [[<tvar name=git>Special:MyLanguage/Download from Git</tvar>|from Git]] instead, using:</translate>cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/EventLogging
  • <translate> Add the following code at the bottom of your <tvar name=1>LocalSettings.php </tvar> file:</translate>
    wfLoadExtension( 'EventLogging' );
    $wgEventLoggingBaseUri = '/beacon/event';
    $wgEventLoggingServiceUri = '/beacon/intake-analytics';
    $wgEventLoggingStreamNames = false;
    
  • File:OOjs UI icon check-constructive.svg <translate> Done</translate> – <translate> Navigate to <tvar name=special>Special:Version</tvar> on your wiki to verify that the extension is successfully installed.</translate>


<translate> Vagrant installation:</translate>

  • <translate> If using <tvar name=vagrant>Vagrant </tvar>, install with <tvar name=code>vagrant roles enable eventlogging --provision</tvar></translate>

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

Developing the EventLogging extension

Developer setup

As a developer, you will want to set up and use EventLogging on your development wiki to simulate its use in production.

Using Docker

See MediaWiki-Docker/Configuration recipes/EventLogging

Using mediawiki-vagrant

If you develop using mediawiki-vagrant, everything you need is encapsulated in the eventlogging role. To enable it, run:

$ vagrant roles enable eventlogging
$ vagrant provision

For JavaScript development

If working on the JavaScript client, you'll need to install dependencies with npm install from the folder you're developing in. Then you can use npm test to run ESLint for example. The "How to run tests" section below points out how to see JavaScript test results.

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

There are PHP tests, Python tests, and JavaScript tests.

To run JavaScript tests, visit Special:JavaScriptTest/qunit on your development wiki. (See Manual:JavaScript unit testing .)

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