Page MenuHomePhabricator

Investigate how to collect data on switches from mobile to desktop [8hr]
Closed, ResolvedPublic

Description

The mobile web site has a button at the bottom of every page which takes users to the desktop version of the site.

Screenshot 2022-06-07 at 09.54.22.png (205×344 px, 23 KB)

The Moderator-Tools-Team would like to understand when and why this button is clicked, to help us prioritise features for improvement and measure the impact of our changes. We can do this to some extent by looking directly at web request data, but this only provides project- and IP-level data. We don't know anything about the user who clicked the link and it's hard to parse the page they were on.

We would like to be able to collect at least the following data when this toggle is clicked:

  • Wikimedia project
  • Page title
  • Page namespace
  • User edit count (can be bucketed; can be local or global)
  • User groups
  • User anonymous or logged-in

Questions

  • How can we collect this data?
  • We would need to create/generate a new json schema as noted here.
  • Once we have a schema we will need to declare that schema in $wgEventStreams config value by editing
wmf-config/InitialiseSettings-labs.php /  InitialiseSettings.php
  • Write instrumentation code to use event logging
$( '#content' ).on( 'click', 'a.desktop_toggle, function ( jqEvent ) {
	var link = jqEvent.target;
	var event = {

	};
	var streamName = 'mediawiki.interwiki_desktop_mobile_link';
	mw.eventLog.submit( streamName, event );
} );
  • UPDATE - there is an easier way of implementing event-logging as per a conversation with @phuedx -> the new Metrics Platform has simplified the process and removed the need to create yaml files for new streams. We will use this new method as it is currently in production. Please see new mono-yaml file with all the usual metric suspects here

Event Timeline

Samwalton9-WMF renamed this task from Investigate how to collect data on switches from mobile to desktop to Investigate how to collect data on switches from mobile to desktop [8hr].Jun 7 2022, 9:01 AM
Samwalton9-WMF triaged this task as Medium priority.
Samwalton9-WMF created this task.
eigyan updated the task description. (Show Details)
eigyan added a subscriber: phuedx.

UPDATE - there is an easier way of implementing event-logging as per a conversation with @phuedx -> the new Metrics Platform has simplified the process and removed the need to create yaml files for new streams. We will use this new method as it is currently in production. Please see new mono-yaml file with all the usual metric suspects here

👋

Yeah! As @eigyan says, using the Metrics Platform should simplify adding this instrumentation somewhat. It should take three steps:

  1. Add the instrumentation:
WikimediaEvents/modules/
$( '#mw-mf-display-toggle' ).click( () => mw.eventLog.dispatch( 'mediawiki.desktop_link.click' );
$( '#footer-places-mobileview a' ).click( () => mw.eventLog.dispatch( 'mediawiki.mobile_link.click' );
  1. Create a stream with a producer configuration for the Metrics Platform:
LocalSettings.php
$wgEventStreams = [
  [
    'stream' => 'desktop_mobile_link_clicks',
    'schema_title' => '/analytics/mediawiki/client/metrics_event',
    'destination_event_service' => 'eventgate-analytics-external',

    // TODO: Determine whether this stream should be sampled
    // 'sample' => [
    //   'unit' => 'pageview',
    //   'rate' => ...,
    // ],

    'producers' => [
      'metrics_platform_client' => [
        'events' => [
          'mediawiki.desktop_link.click',
          'mediawiki.mobile_link.click',
        ],
        'provide_values' => [
          'page_title',
          'page_namespace',
          'performer_edit_count_bucket',
          'performer_groups',
          'performer_is_logged_in',
        ],
      ],
    ],
  ],
];
  1. Add the stream to the list of streams that the EventLogging extension knows about:
LocalSettings.php
$wgEventLoggingStreamNames[] = 'desktop_mobile_link_clicks';

FWIW you can do 1, 2, and 3 in any order.

displays link
<a href="//m.mediawiki.org/w/index.php?title=Moderator_Tools/Content_moderation_on_mobile_web/Preferences&amp;useskin=vector-2022&amp;mobileaction=toggle_view_mobile" class="noprint stopMobileRedirectToggle">Mobile view</a
You10:39 AM
includes/MobileFrontendSkinHooks.php
You10:40 AM
$args['mobileaction'] = 'toggle_view_mobile';

@phuedx Thanks for dropping by and sharing the pertinent details - 🚀

This comment was removed by eigyan.