Index: trunk/extensions/Vector/modules/ext.vector.sectionEditLinks.js |
— | — | @@ -3,16 +3,19 @@ |
4 | 4 | */ |
5 | 5 | ( function( $, mw ) { |
6 | 6 | |
| 7 | +var eventBase = 'ext.vector.sectionEditLinks-bucket:'; |
| 8 | +var cookieBase = 'ext.vector.sectionEditLinks-'; |
| 9 | + |
7 | 10 | if ( mw.config.get( 'wgVectorSectionEditLinksBucketTest', false ) ) { |
8 | 11 | // If the version in the client's cookie doesn't match wgVectorSectionEditLinksExperiment, then |
9 | 12 | // we need to disregard the bucket they may already be in to ensure accurate redistribution |
10 | | - var currentExperiment = $.cookie( 'ext.vector.sectionEditLinks-experiment' ); |
| 13 | + var currentExperiment = $.cookie( cookieBase + 'experiment' ); |
11 | 14 | var experiment = Number( mw.config.get( 'wgVectorSectionEditLinksExperiment', 0 ) ); |
12 | 15 | var bucket = null; |
13 | 16 | if ( currentExperiment === null || Number( currentExperiment ) != experiment ) { |
14 | | - $.cookie( 'ext.vector.sectionEditLinks-experiment', experiment ); |
| 17 | + $.cookie( cookieBase + 'experiment', experiment ); |
15 | 18 | } else { |
16 | | - bucket = $.cookie( 'ext.vector.sectionEditLinks-bucket' ); |
| 19 | + bucket = $.cookie( cookieBase + 'bucket' ); |
17 | 20 | } |
18 | 21 | if ( bucket === null ) { |
19 | 22 | // Percentage chance of being tracked |
— | — | @@ -21,27 +24,28 @@ |
22 | 25 | ) ); |
23 | 26 | // 0 = not tracked, 1 = tracked with old version, 2 = tracked with new version |
24 | 27 | bucket = ( Math.random() * 100 ) < odds ? Number( Math.random() < 0.5 ) + 1 : 0; |
25 | | - $.cookie( 'ext.vector.sectionEditLinks-bucket', bucket, { 'path': '/', 'expires': 30 } ); |
| 28 | + $.cookie( cookieBase + 'bucket', bucket, { 'path': '/', 'expires': 30 } ); |
26 | 29 | // If we are going to track this person from now on, let's also track which bucket we put |
27 | 30 | // them into and when |
28 | 31 | if ( bucket > 0 && 'trackAction' in $ ) { |
29 | | - $.trackAction( 'ext.vector.sectionEditLinks-bucket:' + bucket + '@' + experiment ); |
| 32 | + $.trackAction( eventBase + bucket + '@' + experiment ); |
30 | 33 | } |
31 | 34 | } |
32 | 35 | } |
33 | 36 | if ( bucket > 0 ) { |
34 | 37 | // Transform the targets of section edit links to route through the click tracking API |
35 | | - $( 'span.editsection a' ).each( function() { |
36 | | - var session = $.cookie( 'clicktracking-session' ); |
37 | | - var editUrl = $( this ).attr( 'href' ); |
38 | | - editUrl += ( editUrl.indexOf( '?' ) >= 0 ? '&' : '?' ) + $.param( { |
| 38 | + var session = $.cookie( 'clicktracking-session' ); |
| 39 | + $( 'span.editsection a, #ca-edit a' ).each( function() { |
| 40 | + var event = eventBase + bucket + '@' + experiment; |
| 41 | + if ( $(this).is( '#ca-edit a' ) ) { |
| 42 | + event += '-tab'; |
| 43 | + } |
| 44 | + var href = $( this ).attr( 'href' ); |
| 45 | + var editUrl = href + ( href.indexOf( '?' ) >= 0 ? '&' : '?' ) + $.param( { |
39 | 46 | 'clicktrackingsession': session, |
40 | | - 'clicktrackingevent': |
41 | | - 'ext.vector.sectionEditLinks-bucket:' + bucket + '@' + experiment + '-save' |
| 47 | + 'clicktrackingevent': event + '-save' |
42 | 48 | } ); |
43 | | - $(this).attr( 'href', $.trackActionURL( editUrl, |
44 | | - 'ext.vector.sectionEditLinks-bucket: ' + bucket + '@' + experiment + '-click' |
45 | | - ) ); |
| 49 | + $(this).attr( 'href', $.trackActionURL( editUrl, event + '-click' ) ); |
46 | 50 | } ); |
47 | 51 | if ( bucket == 2 ) { |
48 | 52 | // Move the link over to be next to the heading text and style it with an icon |