Page MenuHomePhabricator

DRY up event logging by creating a logger function
Closed, ResolvedPublic3 Estimated Story Points

Description

Background

After T296415, events can be passed to EventLogging eg:

{
  "$schema": "analytics.mediawiki.ipinfo_interaction/1.0.0",
  event_action: "expand",
  event_context: "accordion",
  user_editBucket: "...",
  user_groups: [ "users", ... ]
}
{
  "$schema": "analytics.mediawiki.ipinfo_interaction/1.0.0",
  event_action: "collapse",
  event_context: "accordion",
  user_editBucket: "...",
  user_groups: [ "users", ... ]
}

Given the repetition in fields like the schema, the user_editBucket, and the user_groups, this function could be DRYed and instead of manually writing out the entire object for every tracked event, we should instead pass along a generic logger function that takes parameters, extends a base event data object, and then passes it to the event logging server.

An example can be seen here:
https://github.com/wikimedia/mediawiki-extensions-WikimediaEvents/blob/master/modules/ext.wikimediaEvents/universalLanguageSelector.js

AC

  • a file exists containing the logger function and any necessary other functionality
  • anywhere an event should be logged (ie. mw.eventLog.submit) it should instead use this function, passing along parameters as necessary

Notes

Helpful documentation on loading JS modules:

Event Timeline

Restricted Application added a subscriber: Aklapper. ยท View Herald TranscriptJan 27 2022, 11:01 AM

Change 767519 had a related patch set uploaded (by Tchanders; author: Tchanders):

[mediawiki/extensions/IPInfo@master] Introduce reusable log function for event logging

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

Change 767519 merged by jenkins-bot:

[mediawiki/extensions/IPInfo@master] Introduce reusable log function for event logging

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