Page MenuHomePhabricator

Deprecation Information for EventLogging ResourceLoader modules
Closed, ResolvedPublic1 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().

Details

Related Gerrit Patches:
mediawiki/extensions/NavigationTiming : masterRemove use of deprecated 'schema.*' modules

Event Timeline

Milimetric triaged this task as High priority.Sep 28 2018, 8:28 PM
Milimetric created this task.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 28 2018, 8:28 PM
Milimetric updated the task description. (Show Details)Oct 1 2018, 9:55 PM
Milimetric updated the task description. (Show Details)Oct 1 2018, 9:59 PM
Milimetric moved this task from In Progress to In Code Review on the Analytics-Kanban board.
Krinkle updated the task description. (Show Details)Oct 4 2018, 2:37 AM
Krinkle added a subscriber: Krinkle.Oct 4 2018, 3:51 AM

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

Nuria closed this task as Resolved.Oct 10 2018, 5:25 PM
Niedzielski added a subscriber: Niedzielski.

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

Milimetric updated the task description. (Show Details)Nov 28 2018, 2:07 AM
Nuria added a subscriber: Nuria.

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

D3r1ck01 updated the task description. (Show Details)Apr 25 2019, 7:40 PM