Index: trunk/extensions/ArticleFeedback/ArticleFeedback.hooks.php |
— | — | @@ -214,12 +214,10 @@ |
215 | 215 | public static function resourceLoaderGetConfigVars( &$vars ) { |
216 | 216 | global $wgArticleFeedbackCategories, |
217 | 217 | $wgArticleFeedbackLotteryOdds, |
218 | | - $wgArticleFeedbackTrackingVersion, |
219 | | - $wgArticleFeedbackTrackingOdds; |
| 218 | + $wgArticleFeedbackTracking; |
220 | 219 | $vars['wgArticleFeedbackCategories'] = $wgArticleFeedbackCategories; |
221 | 220 | $vars['wgArticleFeedbackLotteryOdds'] = $wgArticleFeedbackLotteryOdds; |
222 | | - $vars['wgArticleFeedbackTrackingVersion'] = $wgArticleFeedbackTrackingVersion; |
223 | | - $vars['wgArticleFeedbackTrackingOdds'] = $wgArticleFeedbackTrackingOdds; |
| 221 | + $vars['wgArticleFeedbackTracking'] = $wgArticleFeedbackTracking; |
224 | 222 | return true; |
225 | 223 | } |
226 | 224 | } |
Index: trunk/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js |
— | — | @@ -5,7 +5,9 @@ |
6 | 6 | ( function( $, mw ) { |
7 | 7 | |
8 | 8 | // Only track users who have been assigned to the tracking group |
9 | | -var tracked = Number( $.cookie( 'ext.articleFeedback-tracking' ) ); |
| 9 | +var tracked = mw.user.bucket( |
| 10 | + 'ext.articleFeedback-tracking', mw.config.get( 'wgArticleFeedbackTracking' ) |
| 11 | +); |
10 | 12 | |
11 | 13 | /** |
12 | 14 | * Prefixes a key for cookies or events, with extension and version information |
— | — | @@ -14,7 +16,7 @@ |
15 | 17 | * @return String: Prefixed event name |
16 | 18 | */ |
17 | 19 | function prefix( key ) { |
18 | | - var version = mw.config.get( 'wgArticleFeedbackTrackingVersion' ) || 0; |
| 20 | + var version = mw.config.get( 'wgArticleFeedbackTracking' ).version || 0; |
19 | 21 | return 'ext.articleFeedback@' + version + '-' + key; |
20 | 22 | } |
21 | 23 | |
Index: trunk/extensions/ArticleFeedback/modules/ext.articleFeedback/ext.articleFeedback.js |
— | — | @@ -5,7 +5,9 @@ |
6 | 6 | ( function( $, mw ) { |
7 | 7 | |
8 | 8 | // Only track users who have been assigned to the tracking group |
9 | | -var tracked = Number( $.cookie( 'ext.articleFeedback-tracking' ) ); |
| 9 | +var tracked = 'track' === mw.user.bucket( |
| 10 | + 'ext.articleFeedback-tracking', mw.config.get( 'wgArticleFeedbackTracking' ) |
| 11 | +); |
10 | 12 | |
11 | 13 | /** |
12 | 14 | * Prefixes a key for cookies or events, with extension and version information |
— | — | @@ -14,7 +16,7 @@ |
15 | 17 | * @return String: Prefixed event name |
16 | 18 | */ |
17 | 19 | function prefix( key ) { |
18 | | - var version = mw.config.get( 'wgArticleFeedbackTrackingVersion' ) || 0; |
| 20 | + var version = mw.config.get( 'wgArticleFeedbackTracking' ).version || 0; |
19 | 21 | return 'ext.articleFeedback@' + version + '-' + key; |
20 | 22 | } |
21 | 23 | |
Index: trunk/extensions/ArticleFeedback/modules/ext.articleFeedback/ext.articleFeedback.startup.js |
— | — | @@ -12,36 +12,9 @@ |
13 | 13 | && mw.util.getParamValue( 'diff' ) === null |
14 | 14 | && mw.util.getParamValue( 'oldid' ) === null |
15 | 15 | ) { |
16 | | - // If the version in the client's cookie doesn't match wgArticleFeedbackTrackingVersion, |
17 | | - // then we need to disregard the bucket they may already be in to ensure accurate |
18 | | - // redistribution when the odds are changed |
19 | | - var previousVersion = $.cookie( 'ext.articleFeedback-version' ); |
20 | | - var currentVersion = Number( mw.config.get( 'wgArticleFeedbackTrackingVersion', 0 ) ); |
21 | | - var tracking = null; |
22 | | - if ( previousVersion === null || Number( previousVersion ) != currentVersion ) { |
23 | | - $.cookie( 'ext.articleFeedback-version', currentVersion ); |
24 | | - } else { |
25 | | - tracking = $.cookie( 'ext.articleFeedback-tracking' ); |
26 | | - } |
27 | | - if ( tracking === null ) { |
28 | | - // Percentage chance of being tracked |
29 | | - var odds = Math.min( 100, Math.max( 0, |
30 | | - Number( mw.config.get( 'wgArticleFeedbackTrackingOdds', 0 ) ) |
31 | | - ) ); |
32 | | - // 0 = not tracked, 1 = tracked |
33 | | - tracking = Number( Math.random() * 100 < odds ); |
34 | | - // Let the cookie expire after 30 days, allowing rotation in which users are tracked |
35 | | - $.cookie( 'ext.articleFeedback-tracking', tracking, { 'path': '/', 'expires': 30 } ); |
36 | | - // To be extra-sure that the odds are being applied properly, track whether a user is to |
37 | | - // be tracked or not - this way we can compare the number of people in each bucket to |
38 | | - // the intended percentages defined by wgArticleFeedbackTrackingOdds |
39 | | - if ( 'trackAction' in $ ) { |
40 | | - $.trackAction( |
41 | | - 'ext.articleFeedback@' + currentVersion + '-tracking-' + |
42 | | - ( tracking ? 'on' : 'off' ) |
43 | | - ); |
44 | | - } |
45 | | - } |
| 16 | + var trackingBucket = mw.user.bucket( |
| 17 | + 'ext.articleFeedback-tracking', mw.config.get( 'wgArticleFeedbackTracking' ) |
| 18 | + ); |
46 | 19 | // Category activation |
47 | 20 | var articleFeedbackCategories = mw.config.get( 'wgArticleFeedbackCategories', [] ); |
48 | 21 | var articleCategories = mw.config.get( 'wgCategories', [] ); |
Index: trunk/extensions/ArticleFeedback/ArticleFeedback.php |
— | — | @@ -31,17 +31,27 @@ |
32 | 32 | // are the smallest increments used. |
33 | 33 | $wgArticleFeedbackLotteryOdds = 0; |
34 | 34 | |
35 | | -// This version number is added to all tracking event names, so that changes in the software don't |
36 | | -// corrupt the data being collected. Bump this when you want to start a new "experiment". |
37 | | -$wgArticleFeedbackTrackingVersion = 0; |
| 35 | +// Bucket settings for tracking users |
| 36 | +$wgArticleFeedbackTracking = array( |
| 37 | + // Not all users need to be tracked, but we do want to track some users over time - these |
| 38 | + // buckets are used when deciding to track someone or not, placing them in one of two buckets: |
| 39 | + // "ignore" or "track". When $wgArticleFeedbackTrackingVersion changes, users will be |
| 40 | + // re-bucketed, so you should always increment $wgArticleFeedbackTrackingVersion when changing |
| 41 | + // this number to ensure the new odds are applied to everyone, not just people who have yet to |
| 42 | + // be placed in a bucket. |
| 43 | + 'buckets' => array( |
| 44 | + 'ignore' => 100, |
| 45 | + 'track' => 0, |
| 46 | + ), |
| 47 | + // This version number is added to all tracking event names, so that changes in the software |
| 48 | + // don't corrupt the data being collected. Bump this when you want to start a new "experiment". |
| 49 | + 'version' => 0, |
| 50 | + // Let user's be tracked for a month, and then rebucket them, allowing some churn |
| 51 | + 'expires' => 30, |
| 52 | + // Track the event of users being bucketed - so we can be sure the odds worked out right |
| 53 | + 'tracked' => true |
| 54 | +); |
38 | 55 | |
39 | | -// Not all users need to be tracked, but we do want to track some users over time - this value is |
40 | | -// used when deciding to track someone or not, placing them in one of two buckets: tracked and not. |
41 | | -// When $wgArticleFeedbackTrackingVersion changes, users will be re-bucketed, so you should always |
42 | | -// increment $wgArticleFeedbackTrackingVersion when changing this number to ensure the new odds |
43 | | -// are applied to everyone, not just people who have yet to be placed in a bucket. |
44 | | -$wgArticleFeedbackTrackingOdds = 100; |
45 | | - |
46 | 56 | // Would ordinarily call this articlefeedback but survey names are 16 chars max |
47 | 57 | $wgPrefSwitchSurveys['articlerating'] = array( |
48 | 58 | 'updatable' => false, |