Extension:EventLogging/ru

Справка по расширениям MediaWiki
OOjs UI icon advanced.svg
EventLogging
Статус релиза: стабильный
Реализация Служебная страница , База данных , ContentHandler
Описание Обеспечивает основу для регистрации аналитических событий
Автор(ы) Ori.livnehобсуждение
Последняя версия continuous updates
Политика совместимости ветвь релиза
MediaWiki 1.33+
PHP 5.5+
Изменения БД Нет
Лицензия GNU General Public License 2.0 or later
Загрузка
  • $wgEventLoggingStreamNames
  • $wgEventLoggingSchemaApiUri
  • $wgEventLoggingServiceUri
  • $wgEventLoggingQueueLingerSeconds
  • $wgEventLoggingBaseUri
  • $wgEventLoggingSchemas
  • $wgEventLoggingDBname
Переведите расширение EventLogging если оно доступно на translatewiki.net
Проверьте использование и версию.
Vagrant role eventlogging
Проблемы Открытые задачи · Сообщить об ошибке

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

ХарактеристикиEdit

  • 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 does not include any back-end code for transporting, parsing, or loading these events. A separate repository, Eventlogging server, implements this functionality and deals with inserting into Kafka streams, SQL tables (automatically generated from the same schemas), and MongoDB collections. The details of these components are specific to Wikimedia Foundation's configuration.

EventLogging в ВикимедиаEdit

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. For Wikimedia-specific documentation, see wikitech:Analytics/Systems/EventLogging.

УстановкаEdit

  • Если вы используете Vagrant , установите с помощью vagrant roles enable eventlogging --provision
Ручная установка
  • Скачайте и распакуйте файл(ы) в папку с названием EventLogging в вашей папке extensions/.
  • Добавьте следующие строки в конец файла LocalSettings.php:
    wfLoadExtension( 'EventLogging' );
    $wgEventLoggingBaseUri = '/beacon/event';
    
  • If you would like to express a conditional dependency on EventLogging in your extension, see this sample code snippet.
  •   Готово – Перейдите на страницу Special:Version на своей вики, чтобы удостовериться в том, что расширение успешно установлено.

Настройка расположения схемыEdit

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).

Регистрация событий с использованием EventLoggingEdit

СоветыEdit

Read Extension:EventLogging/Guide to learn about creating and using a proper schema for your event.

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 ($wgEventLoggingSchemaApiUri) during development.

Your code that logs events can fail if EventLogging is not available, or it can have a soft dependency.

Разработка расширения EventLoggingEdit

Настройка разработчикаEdit

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

Sanity-проверки (проверки на здравомыслие) ваших настроекEdit

Your local development wiki 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.

If not using MediaWiki-Vagrant, you will need to clone eventlogging server repository for local development.

So you can set

$wgEventLoggingBaseUri = 'http://localhost:8100/event.gif';

and run export PYTHONPATH=./server && 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.using( '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.

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 EventLogger::LogEvent() function.

Использование mediawiki-vagrantEdit

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

$ vagrant roles enable eventlogging
$ vagrant provision

And once in vagrant please take a look at Extension:EventLogging/Guide#Installing_the_eventlogging-devserver to see how to run the eventlogging devserver

Для разработки JavaScriptEdit

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 ./node_modules/grunt/bin/grunt eslint to lint for example. The "How to run tests" section below points out how to see JavaScript test results.

Как запустить тестыEdit

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/extensions/EventLogging/tests$ php /vagrant/mediawiki/tests/phpunit/phpunit.php EventLoggingExtensionFunctionsTest.php

To run eventlogging server 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). For example:

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 
vagrant@mediawiki-vagrant:/vagrant/mediawiki/extensions/EventLogging$ git submodule update --init # to get server/ checked out

Then, run tox:

$ tox

Note that tox tries to run tests for Python 2.7 and Python 3.4. EventLogging runs with Python 2.7 in production. If you want to install Python 3 in Vagrant, run:

$ sudo apt-get install python3

Как запустить flake8Edit

vagrant@mediawiki-vagrant:/vagrant/mediawiki/extensions/EventLogging$ tox -e flake8