Skip to content

Draft: Allow instrument maintainers to tag events

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.

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