Extension:EventLogging
EventLogging Release status: stable |
|||
---|---|---|---|
Implementation | Special page, Database, ContentHandler | ||
Description | Framework for logging analytic events | ||
Author(s) | Ori.livnehtalk | ||
Latest version | 0.8 (2014-03-26) | ||
MediaWiki | 1.21+ | ||
PHP | 5.3+ | ||
Database changes | No | ||
License | GNU General Public License 2.0 or later | ||
Download | |||
|
|||
|
|||
Translate the EventLogging extension if it is available at translatewiki.net |
|||
Check usage and version matrix; code metrics | |||
Bugs: list open list all report |
The EventLogging extension facilitates the collection of metrics on how users interact with MediaWiki's interface. The Wikimedia Foundation captures this data and analyses it in aggregate to better understand how readers and editors interact with our site, to identify usability or performance problems, and to provide feedback for features engineers, with the overarching goal of driving improvements to user experience.
Contents
Features[edit | edit source]
- EventLogging supports client-side logging from JavaScript and server-side logging from PHP.
- The events are JSON objects defined by JSON schemas that can be edited on a MediaWiki server in a Schema: namespace; the latter feature is generally useful for storing other structured data in wiki pages.
- The extension includes much back-end code for transporting, parsing and loading these events into SQL tables (automatically generated from the same schemas) and MongoDB collections. The details of these components are specific to Wikimedia Foundation's configuration.
Download[edit | edit source]
You can download the extension directly from the MediaWiki source code repository (browse code). You can get:
- One of the extensions tags
Not all extensions have tags. Some extensions have tags for each release, in which case those tags have the same stability as the release. To download a tag
- Go to the tags list
- Click the name of the tag you want to download
- Click "snapshot"
- The latest version of one of the extensions branches
Each extension has a master branch containing the latest code (might be unstable). Extensions can have further branches as well.
- Go to the branches list
- Click the branch name
- Click "snapshot"
- A snapshot made during the release of a MediaWiki version.
This might be unstable and is not guaranteed to work with the associated MediaWiki version.
After you've got the code, save it into the extensions/EventLogging directory of your wiki.
If you are familiar with git and have shell access to your server, you can obtain the extension, with all its tags and branches, as follows:
cd extensions
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/EventLogging.git
Installation[edit | edit source]
- Download and extract the file(s) in a directory called
EventLogging
in yourextensions/
folder. If you're a developer and this extension is in a Git repository, then instead you should clone the repository. - Add the following code at the bottom of your LocalSettings.php:
require_once "$IP/extensions/EventLogging/EventLogging.php"; $wgEventLoggingBaseUri = 'http://localhost:8080/event.gif'; $wgEventLoggingFile = '/var/log/mediawiki/events.log';
- If you would like to express a conditional dependency on EventLogging in your extension, see this sample code snippet.
- Done! Navigate to "Special:Version" on your wiki to verify that the extension is successfully installed.
Documentation[edit | edit source]
- /Guide to developing and deploying EventLogging schemas, and more
- /Programming has tips and suggestions for developers writing code to log events
- /Events
- /Comparison notes
- /UserAgentSanitization
- Trello board
- See also: Event logging on Wikitech
Operational Support[edit | edit source]
EventLogging/OperationalSupport
For developers[edit | edit source]
Developer setup[edit | edit source]
Your local instance must be running some cache server, such as memcached.
$wgMainCacheType = CACHE_MEMCACHED; $wgMemCachedServers = array( '127.0.0.1:11211' ); // this matches Debian /etc/memcached
EventLogging.php describes the EventLogging configuration variables. The extension provides a dummy web server in server/bin
that responds to EventLogging's requests to its beacon URL, by default on port 8080. See server/README.rst for Python setup instructions. So you can set
$wgEventLoggingBaseUri = 'http://localhost:8080/event.gif';
and run python EventLogging/server/bin/eventlogging-devserver in a terminal to see events. The MediaWiki-Vagrant server "appliance" uses port 8080, so you may want to use another port like 8081 for event.gif requests.
To verify your setup, browse to any page of your wiki, and in a JavaScript console enter
mw.loader.load( 'ext.eventLogging' ); // load the core module mw.loader.getState( 'ext.eventLogging' ); // should be "ready" mw.eventLog.logEvent( null, { "foo": 42 } );
The last line will generate console warnings in debug mode as null is not a known schema, but eventlogging-devserver should dump the event along with its own warnings.
Now read /Guide to learn about creating and using a proper schema for your event.
For server-side events, set $wgEventLoggingFile to a local file writable by the PHP/Web server, and in a terminal run tail -f on that file. This will dump any calls to the PHP efLogServerSideEvent()
function.
Tips[edit | edit source]
Don't use a schema name like "MyFakeTest" during development. Since schemas are referenced by MediaWiki revision ID, development versions won't conflict with production, so you should always use a real name and can point to the production wiki holding schemas (wgEventLoggingSchemaIndexUri
) during development.
How to run tests[edit | edit source]
There are PHP tests and python tests on EL. To run PHP tests:
After doing ssh vagrant: > vagrant@mediawiki-vagrant:/vagrant/mediawiki/tests/phpunit$ php phpunit.php --group EventLogging
To run python tests in vagrant you need to install tox. If you use Windows, may also need to clone it to a directory that is not shared between guest and host (to work around an apparent VirtualBox shared folder issue). E.g.:
> vagrant@mediawiki-vagrant:/vagrant/mediawiki/extensions/EventLogging$ git clone . ~/EventLogging > vagrant@mediawiki-vagrant:/vagrant/mediawiki/extensions/EventLogging$ sudo pip install tox > vagrant@mediawiki-vagrant:/vagrant/mediawiki/extensions/EventLogging$ cd ~/EventLogging
Then, run tox:
> tox
Note that tox tries to run tests for Python 2.7 and Python 3.2. EventLogging runs with Python 2.7 in production. If you want to install Python3 in vagrant please run:
>sudo apt-get install python3
How to run flake8[edit | edit source]
> vagrant@mediawiki-vagrant:/vagrant/mediawiki/extensions/EventLogging$ tox -e flake8
![]() |
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. |
- Extensions with unknown license
- Stable extensions
- Special page extensions
- Database extensions
- ContentHandler extensions
- GPL licensed extensions
- Extensions in Wikimedia version control
- ResourceLoaderGetConfigVars extensions
- ResourceLoaderTestModules extensions
- UnitTestsList extensions
- AddNewAccount extensions
- All extensions
- Extensions used on Wikimedia
- Analytics extensions