Add instrumentation to Special:Mute
authorDayllan Maza <dmaza@wikimedia.org>
Mon, 5 Aug 2019 21:30:45 +0000 (17:30 -0400)
committerDmaza <dmaza@wikimedia.org>
Mon, 19 Aug 2019 15:18:11 +0000 (15:18 +0000)
We are already tracking pageviews and with following change we should be able
to answer the following questions:
* Of the users who land on this page, what percentage of users actually
  mute or unmute someone
* Of the users who mute a user, which option(s) did they check/uncheck in order
  to mute/unmute the user

EventLogging Schema: https://meta.wikimedia.org/wiki/Schema:SpecialMuteSubmit

Bug: T224958
Change-Id: I655dbd999fd5d3d8f792c4f53b7cc502fe05afd5

docs/hooks.txt
includes/specials/SpecialMute.php

index d832012..5de2dc7 100644 (file)
@@ -3205,6 +3205,9 @@ $request: WebRequest object for getting the value provided by the current user
 $sp: SpecialPage object, for context
 &$fields: Current HTMLForm fields descriptors
 
+'SpecialMuteSubmit': DEPRECATED since 1.34! Used only for instrumentation on SpecialMute
+$data: Array containing information about submitted options on SpecialMute form
+
 'SpecialNewpagesConditions': Called when building sql query for
 Special:NewPages.
 &$special: NewPagesPager object (subclass of ReverseChronologicalPager)
index f3ae31a..77c0710 100644 (file)
@@ -99,14 +99,20 @@ class SpecialMute extends FormSpecialPage {
         * @return bool
         */
        public function onSubmit( array $data, HTMLForm $form = null ) {
+               $hookData = [];
                foreach ( $data as $userOption => $value ) {
+                       $hookData[$userOption]['before'] = $this->isTargetBlacklisted( $userOption );
                        if ( $value ) {
                                $this->muteTarget( $userOption );
                        } else {
                                $this->unmuteTarget( $userOption );
                        }
+                       $hookData[$userOption]['after'] = (bool)$value;
                }
 
+               // NOTE: this hook is temporary
+               Hooks::run( 'SpecialMuteSubmit', [ $hookData ] );
+
                return true;
        }