r108519 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108518‎ | r108519 | r108520 >
Date:16:59, 10 January 2012
Author:rsterbin
Status:ok
Tags:
Comment:
Added edit click tracking:
- modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js:
- New public method clickTrackingOn()
- modules/ext.articleFeedbackv5/ext.articleFeedbackv5.js:
- If click tracking is on, add tracking to the edit tab and section
edit links
- ArticleFeedbackv5.hooks.php:
- Updated pushTrackingFieldsToEdit() to pass the edit click tracking
event
- Updated trackEvent() to look for the edit click tracking event and
use it correctly
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.hooks.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/modules/ext.articleFeedbackv5/ext.articleFeedbackv5.js (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js
@@ -2966,6 +2966,18 @@
29672967 };
29682968
29692969 // }}}
 2970+ // {{{ clickTrackingOn
 2971+
 2972+ /**
 2973+ * Returns whether click tracking is on
 2974+ *
 2975+ * @bool whether click tracking is on
 2976+ */
 2977+ $.articleFeedbackv5.clickTrackingOn = function () {
 2978+ return $.articleFeedbackv5.clickTracking;
 2979+ };
 2980+
 2981+ // }}}
29702982 // {{{ trackClick
29712983
29722984 /**
@@ -3011,6 +3023,7 @@
30123024 openAsModal: { args: 1, ret: false },
30133025 closeAsModal: { args: 0, ret: true },
30143026 toggleModal: { args: 1, ret: false },
 3027+ clickTrackingOn: { args: 0, ret: true },
30153028 trackClick: { args: 1, ret: false }
30163029 };
30173030 if ( opts in public ) {
Index: trunk/extensions/ArticleFeedbackv5/modules/ext.articleFeedbackv5/ext.articleFeedbackv5.js
@@ -16,6 +16,27 @@
1717 mw.util.$content.append( $aftDiv );
1818 }
1919
 20+/* Add basic edit tracking */
 21+if ( $aftDiv.articleFeedbackv5( 'clickTrackingOn' ) ) {
 22+ var clickTrackingSession = $.cookie( 'clicktracking-session' );
 23+ var editEventBase = $aftDiv.articleFeedbackv5( 'prefix', $aftDiv.articleFeedbackv5( 'bucketName' ) );
 24+ $( 'span.editsection a, #ca-edit a' ).each( function() {
 25+ var event = editEventBase;
 26+ if ( $(this).is( '#ca-edit a' ) ) {
 27+ event += '-edit_tab_link';
 28+ } else {
 29+ event += '-section_edit_link';
 30+ }
 31+ var href = $( this ).attr( 'href' );
 32+ var editUrl = href + ( href.indexOf( '?' ) >= 0 ? '&' : '?' ) + $.param( {
 33+ 'articleFeedbackv5_click_tracking': 1,
 34+ 'articleFeedbackv5_ct_token': clickTrackingSession,
 35+ 'articleFeedbackv5_ct_event': event
 36+ } );
 37+ $(this).attr( 'href', $.trackActionURL( editUrl, event + '-click' ) );
 38+ } );
 39+}
 40+
2041 /* Setup for feedback links */
2142
2243 // Click event
Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.hooks.php
@@ -307,12 +307,14 @@
308308 $ctaId = $request->getVal( 'articleFeedbackv5_cta_id' );
309309 $location = $request->getVal( 'articleFeedbackv5_location' );
310310 $token = $request->getVal( 'articleFeedbackv5_ct_token' );
 311+ $ctEvent = $request->getVal( 'articleFeedbackv5_ct_event' );
311312
312313 $editPage->editFormTextAfterContent .= Html::hidden( 'articleFeedbackv5_click_tracking', $tracking );
313314 $editPage->editFormTextAfterContent .= Html::hidden( 'articleFeedbackv5_bucket_id', $bucketId );
314315 $editPage->editFormTextAfterContent .= Html::hidden( 'articleFeedbackv5_cta_id', $ctaId );
315316 $editPage->editFormTextAfterContent .= Html::hidden( 'articleFeedbackv5_location', $location );
316317 $editPage->editFormTextAfterContent .= Html::hidden( 'articleFeedbackv5_ct_token', $token );
 318+ $editPage->editFormTextAfterContent .= Html::hidden( 'articleFeedbackv5_ct_event', $ctEvent );
317319
318320 return true;
319321 }
@@ -376,12 +378,17 @@
377379 $ctaId = $request->getVal( 'articleFeedbackv5_cta_id' );
378380 $location = $request->getVal( 'articleFeedbackv5_location' );
379381 $token = $request->getVal( 'articleFeedbackv5_ct_token' );
 382+ $ctEvent = $request->getVal( 'articleFeedbackv5_ct_event' );
380383
381 - $trackingId = 'ext.articleFeedbackv5@' . $version
382 - . '-option' . $bucketId
383 - . '-cta_' . ( isset( $ctas[$ctaId] ) ? $ctas[$ctaId] : 'unknown' )
384 - . '-' . $event
385 - . '-' . $location;
 384+ if ( $ctEvent ) {
 385+ $trackingId = $ctEvent . '-' . $event;
 386+ } else {
 387+ $trackingId = 'ext.articleFeedbackv5@' . $version
 388+ . '-option' . $bucketId
 389+ . '-cta_' . ( isset( $ctas[$ctaId] ) ? $ctas[$ctaId] : 'unknown' )
 390+ . '-' . $event
 391+ . '-' . $location;
 392+ }
386393
387394 $params = new FauxRequest( array(
388395 'action' => 'clicktracking',

Status & tagging log