r67551 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67550‎ | r67551 | r67552 >
Date:18:42, 7 June 2010
Author:nimishg
Status:ok (Comments)
Tags:
Comment:
Updated click tracking so individual actions can hold information like state info
Modified paths:
  • /trunk/extensions/UsabilityInitiative/ClickTracking/ApiClickTracking.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/ClickTracking/patch-additional_info.sql (added) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.hooks.php
@@ -163,7 +163,7 @@
164164 * @return true if the event was stored in the DB
165165 */
166166 public static function trackEvent( $session_id, $is_logged_in, $namespace, $event_id, $contribs = 0,
167 - $contribs_in_timespan1 = 0, $contribs_in_timespan2 = 0, $contribs_in_timespan3 = 0 ) {
 167+ $contribs_in_timespan1 = 0, $contribs_in_timespan2 = 0, $contribs_in_timespan3 = 0, $additional= null ) {
168168 $dbw = wfGetDB( DB_MASTER );
169169
170170 $dbw->begin();
@@ -178,7 +178,8 @@
179179 'user_contribs_span2' => ( $is_logged_in ? (int) $contribs_in_timespan2 : null ),
180180 'user_contribs_span3' => ( $is_logged_in ? (int) $contribs_in_timespan3 : null ),
181181 'namespace' => (int) $namespace,
182 - 'event_id' => (int) $event_id
 182+ 'event_id' => (int) $event_id,
 183+ 'additional_info' => ( isset($additional) ? (string) $additional : null )
183184 );
184185
185186 $db_status = $dbw->insert( 'click_tracking', $data, __METHOD__ );
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.js
@@ -6,6 +6,14 @@
77 wgScriptPath + '/api.php', { 'action': 'clicktracking', 'eventid': id, 'token': wgTrackingToken }
88 );
99 };
 10+
 11+ $.trackActionWithInfo = function( id, info ) {
 12+ $j.post(
 13+ wgScriptPath + '/api.php', { 'action': 'clicktracking', 'eventid': id, 'token': wgTrackingToken, 'additional': info }
 14+ );
 15+ };
 16+
 17+
1018 // Add click tracking hooks to the sidebar
1119 $j(document).ready( function() {
1220 $( '#p-logo a, #p-navigation a, #p-interaction a, #p-tb a' ).each( function() {
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ApiClickTracking.php
@@ -19,7 +19,15 @@
2020 $this->validateParams( $params );
2121 $eventid_to_lookup = $params['eventid'];
2222 $session_id = $params['token'];
23 -
 23+
 24+ $additional = null;
 25+
 26+ if( isset($params['additional']) && strlen($params['additional']) > 0){
 27+ $additional = $params['additional'];
 28+
 29+ }
 30+
 31+
2432 // Event ID lookup table
2533 // FIXME: API should already have urldecode()d
2634 $event_id = ClickTrackingHooks::getEventIDFromName( urldecode( $eventid_to_lookup ) );
@@ -43,7 +51,8 @@
4452 ( $is_logged_in ? $wgUser->getEditCount() : 0 ), // total edit count or 0 if anonymous
4553 $granularity1, // contributions made in granularity 1 time frame
4654 $granularity2, // contributions made in granularity 2 time frame
47 - $granularity3 // contributions made in granularity 3 time frame
 55+ $granularity3, // contributions made in granularity 3 time frame
 56+ $additional
4857 );
4958
5059 // For links that go off the page, redirect the user
@@ -83,7 +92,8 @@
8493 return array(
8594 'eventid' => 'string of eventID',
8695 'token' => 'unique edit ID for this edit session',
87 - 'redirectto' => 'URL to redirect to (only used for links that go off the page)'
 96+ 'redirectto' => 'URL to redirect to (only used for links that go off the page)',
 97+ 'additional' => 'additional info for the event, like state information'
8898 );
8999 }
90100
@@ -104,7 +114,8 @@
105115 return array(
106116 'eventid' => null,
107117 'token' => null,
108 - 'redirectto' => null
 118+ 'redirectto' => null,
 119+ 'additional' => null
109120 );
110121 }
111122
Index: trunk/extensions/UsabilityInitiative/ClickTracking/patch-additional_info.sql
@@ -0,0 +1,4 @@
 2+--
 3+-- create click_tracking.additional_info
 4+--
 5+ALTER TABLE /*_*/click_tracking ADD additional_info varbinary(255);
Property changes on: trunk/extensions/UsabilityInitiative/ClickTracking/patch-additional_info.sql
___________________________________________________________________
Name: svn:eol-style
16 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r67574added line for additional_info update (r67551)nimishg22:55, 7 June 2010
r67656ClickTracking: Add reference to updater added in r67551 so it gets picked up ...catrope18:29, 8 June 2010

Comments

#Comment by Catrope (talk | contribs)   19:56, 7 June 2010
+--
+-- create click_tracking.additional_info
+--
+ALTER TABLE /*_*/click_tracking ADD additional_info varbinary(255);

You also need to modify ClickTracking.sql for this change.

#Comment by Nimish Gautam (talk | contribs)   22:56, 7 June 2010

added the sql in r67574

Status & tagging log