Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.hooks.php |
— | — | @@ -38,14 +38,16 @@ |
39 | 39 | |
40 | 40 | |
41 | 41 | /* |
42 | | - * Gives the user clicktrack JS if they're in the threshhold |
| 42 | + * check to see if user is throttled |
43 | 43 | */ |
44 | | - public static function addJSThrottle(){ |
| 44 | + public static function isUserThrottled(){ |
45 | 45 | global $wgClickTrackThrottle; |
46 | 46 | if(rand() % $wgClickTrackThrottle == 0){ |
47 | | - ClickTrackingHooks::addJS(); |
| 47 | + return 'false'; |
48 | 48 | } |
49 | | - return true; |
| 49 | + else { |
| 50 | + return 'true'; |
| 51 | + } |
50 | 52 | } |
51 | 53 | |
52 | 54 | |
— | — | @@ -53,11 +55,14 @@ |
54 | 56 | * Adds JavaScript |
55 | 57 | */ |
56 | 58 | public static function addJS(){ |
57 | | - UsabilityInitiativeHooks::initialize(); |
58 | | - UsabilityInitiativeHooks::addScript( 'ClickTracking/ClickTracking.js' ); |
59 | | - UsabilityInitiativeHooks::addVariables( |
60 | | - array( 'wgTrackingToken' => ClickTrackingHooks::get_session_id() ) |
61 | | - ); |
| 59 | + UsabilityInitiativeHooks::initialize(); |
| 60 | + UsabilityInitiativeHooks::addScript( 'ClickTracking/ClickTracking.js' ); |
| 61 | + UsabilityInitiativeHooks::addVariables( |
| 62 | + array( |
| 63 | + 'wgTrackingToken' => ClickTrackingHooks::get_session_id(), |
| 64 | + 'wgClickTrackingIsThrottled' => ClickTrackingHooks::isUserThrottled() |
| 65 | + ) |
| 66 | + ); |
62 | 67 | |
63 | 68 | return true; |
64 | 69 | |
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.js |
— | — | @@ -1,9 +1,11 @@ |
2 | 2 | (function($) { |
3 | 3 | |
4 | | - // creates 'track action' function to call the clicktracking API and send the ID |
5 | | -$.trackAction = function ( id ){ |
6 | | - $j.post( wgScriptPath + '/api.php', { 'action': 'clicktracking', 'eventid': id, 'token': wgTrackingToken } ); |
7 | | -}; |
| 4 | + if(wgClickTrackingIsThrottled == 'false'){ |
| 5 | + // creates 'track action' function to call the clicktracking API and send the ID |
| 6 | + $.trackAction = function ( id ){ |
| 7 | + $j.post( wgScriptPath + '/api.php', { 'action': 'clicktracking', 'eventid': id, 'token': wgTrackingToken } ); |
| 8 | + }; |
| 9 | + } |
8 | 10 | |
9 | 11 | return $(this); |
10 | 12 | |
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.php |
— | — | @@ -51,7 +51,7 @@ |
52 | 52 | // Hooked functions |
53 | 53 | $wgHooks['LoadExtensionSchemaUpdates'][] = 'ClickTrackingHooks::schema'; |
54 | 54 | $wgHooks['ArticleSaveComplete'][] = 'ClickTrackingHooks::storeNewContrib'; |
55 | | -$wgHooks['EditPage::showEditForm:initial'][] = 'ClickTrackingHooks::addJSThrottle'; |
| 55 | +$wgHooks['EditPage::showEditForm:initial'][] = 'ClickTrackingHooks::addJS'; |
56 | 56 | |
57 | 57 | // Set up the new API module |
58 | 58 | $wgAPIModules['clicktracking'] = 'ApiClickTracking'; |
\ No newline at end of file |