Skip to content
Snippets Groups Projects

Draft: [JS] Allow instrument maintainers to tag events

Open Phuedx requested to merge work/phuedx/tags into main

In order to record if the user has some feature enabled, e.g. a UX feature, a gadget, they are seeing a variant of a feature, etc., then the instrument maintainers must add a feature-specific property to their schema and update their instrument to set that property. In order to reduce friction for instrument maintainers, I propose adding a tags section to all interaction events and corresponding methods on MetricsClient.

Bug: T317656

TODO

  1. Use "label" instead of "tag"

Motivating Examples

DesktopWebWebUIActions

The associated schema defines the is_page_preview_on?: boolean property. If Page Previews is enabled, then is_page_preview_on is set to true.

This:

const isPagePreviewsEnabled = mw.popups ? mw.popups.isEnabled() : false;

// …

const event = {
    is_page_preview_on: isPagePreviewsEnabled,

    // …
};

could be replaced with this:

mw.eventLog.addTagIf(
	STREAM_NAME,
	'has_page_previews',
	mw.popups && mw.popups.isEnabled()
);

MobileWebUIActions

The associated schema defines the modes property, modes?: string[]. If the "Advanced mode" setting is enabled, then "amc" is appended to the modes property.

This:

const mode = mw.config.get( 'wgMFMode', 'desktop' );
const modes = [ mode ];

if ( mode !== 'desktop' && mw.config.get( 'wgMFAmc') ) {
    modes.push( 'amc' )
}

// …

const event = {
    modes,

    // …
};

could be replaced with this:

const mode = mw.config.has( 'wgMFMode' ) ? 'mobile' : 'desktop';

mw.eventLog.addTagsIf( 
    STREAM_NAME,
    {
        'is_mobile' => mw.config.has( 'wgMFMode' ),
        'has_amc' => mw.config.has( 'wgMFAmc' )
    }
);
Edited by Phuedx

Merge request reports

Pipeline #46922 passed

Pipeline passed for 7568de3a on work/phuedx/tags

Approval is optional
Merge blocked: 2 checks failed
Merge request must not be draft.
Merge conflicts must be resolved.

Merge details

  • The source branch is 96 commits behind the target branch.
  • 4 commits and 1 merge commit will be added to main.
  • Source branch will be deleted.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
Please register or sign in to reply