r112649 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112648‎ | r112649 | r112650 >
Date:21:47, 28 February 2012
Author:kaldari
Status:ok (Comments)
Tags:acw-deploy 
Comment:
fixing confusing module/file name - the existing ext module is a specific campaign for tracking sidebar clicks. Also separating throttling logic from module outputting logic in case people add some more modules and only want to enable some of them.
Modified paths:
  • /trunk/extensions/ClickTracking/ClickTracking.hooks.php (modified) (history)
  • /trunk/extensions/ClickTracking/ClickTracking.php (modified) (history)
  • /trunk/extensions/ClickTracking/modules/ext.clickTracking.js (deleted) (history)
  • /trunk/extensions/ClickTracking/modules/ext.clickTrackingSidebar.js (added) (history)

Diff [purge]

Index: trunk/extensions/ClickTracking/ClickTracking.hooks.php
@@ -71,9 +71,12 @@
7272 public static function beforePageDisplay( $out, $skin ) {
7373 global $wgClickTrackSidebar, $wgClickTrackThrottle;
7474 $out->addModules( 'ext.UserBuckets' );
75 -
76 - if ( $wgClickTrackSidebar && $wgClickTrackThrottle >= 0 && rand() % $wgClickTrackThrottle == 0 ) {
77 - $out->addModules( 'ext.clickTracking' );
 75+ // Throttle ClickTracking if neccessary
 76+ // 1 out of every $wgClickTrackThrottle users will have ClickTracking enabled
 77+ if ( $wgClickTrackThrottle > 0 && rand() % $wgClickTrackThrottle == 0 ) {
 78+ if ( $wgClickTrackSidebar ) {
 79+ $out->addModules( 'ext.clickTrackingSidebar' );
 80+ }
7881 }
7982 return true;
8083 }
Index: trunk/extensions/ClickTracking/modules/ext.clickTracking.js
@@ -1,15 +0,0 @@
2 -/*
3 - * JavaScript for ClickTracking extension
4 - */
5 -
6 -jQuery( function( $ ) {
7 - // Add click tracking hooks to the sidebar
8 - $( '#p-logo a, #p-navigation a, #p-interaction a, #p-tb a' ).each( function() {
9 - var $el = $(this), href = $el.attr( 'href' );
10 - // Only modify local URLs
11 - if ( href.length > 0 && href[0] == '/' && ( href.length == 1 || href[1] != '/' ) ) {
12 - var id = 'leftnav-' + skin + '-' + ( $el.attr( 'id' ) || $el.parent().attr( 'id' ) );
13 - $el.attr( 'href', $.trackActionURL( href, id ) );
14 - }
15 - } );
16 -} );
Index: trunk/extensions/ClickTracking/modules/ext.clickTrackingSidebar.js
@@ -0,0 +1,15 @@
 2+/*
 3+ * JavaScript for sidebar ClickTracking campaign
 4+ */
 5+
 6+jQuery( function( $ ) {
 7+ // Add click tracking hooks to the sidebar
 8+ $( '#p-logo a, #p-navigation a, #p-interaction a, #p-tb a' ).each( function() {
 9+ var $el = $(this), href = $el.attr( 'href' );
 10+ // Only modify local URLs
 11+ if ( href.length > 0 && href[0] == '/' && ( href.length == 1 || href[1] != '/' ) ) {
 12+ var id = 'leftnav-' + skin + '-' + ( $el.attr( 'id' ) || $el.parent().attr( 'id' ) );
 13+ $el.attr( 'href', $.trackActionURL( href, id ) );
 14+ }
 15+ } );
 16+} );
Property changes on: trunk/extensions/ClickTracking/modules/ext.clickTrackingSidebar.js
___________________________________________________________________
Added: svn:eol-style
117 + native
Index: trunk/extensions/ClickTracking/ClickTracking.php
@@ -75,8 +75,8 @@
7676 'scripts' => 'jquery.clickTracking.js',
7777 'dependencies' => 'jquery.cookie',
7878 ) + $ctResourceTemplate;
79 -$wgResourceModules['ext.clickTracking'] = array(
80 - 'scripts' => 'ext.clickTracking.js',
 79+$wgResourceModules['ext.clickTrackingSidebar'] = array(
 80+ 'scripts' => 'ext.clickTrackingSidebar.js',
8181 'dependencies' => 'jquery.clickTracking',
8282 ) + $ctResourceTemplate;
8383 $wgResourceModules['ext.UserBuckets'] = array(

Comments

#Comment by Kaldari (talk | contribs)   21:49, 28 February 2012
+ if ( $wgClickTrackThrottle > 0 && rand() % $wgClickTrackThrottle == 0 ) {

This also avoids a potential divide by 0 error.

Status & tagging log