Page MenuHomePhabricator

Deprecation Information for EventLogging ResourceLoader modules
Closed, ResolvedPublic1 Estimated Story Points

Description

Quick Summary


If you are using mw.track( 'event.SchemaName', .. ), there is nothing to migrate.

If you are using mw.eventLog.logEvent, then there is no longer any need to load schema.* modules.
You can now directly use mw.loader.using( 'ext.eventLogging' ).then(... use mw.eventLog.logEvent as before ...). You should keep the EventLoggingSchemas section of extension.json, however, that's needed to know which revision of the schema to encapsulate the event with.

EventLogging will no longer validate your events client-side on every page view by default.

To automatically validate events, enable debug mode by setting the eventlogging-display-web user preference, see Debug mode to learn how.

The Detail


With T187207 we changed the EventLogging javascript client. We removed validation of events and stripped out ResourceLoader schema modules. So, before this change you would do:

mw.loader.using( 'schema.Example' ).then( () => {
  mw.eventLog.logEvent( 'Example', { some: 'data', here: true } ) );
} );

(no, they won't let you use arrow functions :(, but it's just docs so I can be fancy). This worked as follows:

  • the schema.Example module contained the schema json, which was added to mw.eventLog.schemas (private) with declareSchema (private).
  • this module also depended on ext.eventLogging, so using it also provided mw.eventLog.
  • the call to mw.eventLog.logEvent validated the event you passed against the schema and sent it, regardless of validation result.

Now, after this change, you have two migration options:

For backwards compatibility, the schema modules still exist. We just emptied them out and kept their dependency on ext.eventLogging with a deprecation warning.

  • Switch to using( 'ext.eventLogging' ) before the schema modules are completely removed in the future.
  • Switch to the lightweight subscriber method (preferred), via mw.track().

Event Timeline

Milimetric created this task.

@Milimetric Very nice :)

I made some minor edits to link to debug mode, added a mention of mw.track(), and phrased the recommendation as using the subscriber "method" rather than "module".

Users aren't meant to load or depend the subscriber module explicitly, rather the track is like a "queue and forget", with EventLogging loading the subscriber to start processing the queue. This makes the code dependency-free (given track is core) and makes it so code can't not lazy-load or accidentally load too early.

right, makes sense, I think I understood all this but used all the wrong words. I'll be more careful.

Change 475570 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[mediawiki/extensions/NavigationTiming@master] Remove use of deprecated 'schema.*' modules

https://gerrit.wikimedia.org/r/475570

Change 475570 merged by jenkins-bot:
[mediawiki/extensions/NavigationTiming@master] Remove use of deprecated 'schema.*' modules

https://gerrit.wikimedia.org/r/475570

Nuria subscribed.

Tagging some people in this ticket that should know about these changes.