jenkins-bot has submitted this change and it was merged.
Change subject: Give RecordImpression different reasons for different cases
......................................................................
Give RecordImpression different reasons for different cases
Now that we can tell donate cookies and hide cookies apart, send
the different reasons to Special:RecordImpression. Also add a
reason to mark when the alterImpressionData callback says 'hide'.
Lastly, add banner and campaign info even to 'hide' impressions.
Change-Id: I0c7749e1fef4b2b6f8807f39762d381f391d5219
---
M modules/ext.centralNotice.bannerController/bannerController.js
1 file changed, 22 insertions(+), 14 deletions(-)
Approvals:
AndyRussG: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/ext.centralNotice.bannerController/bannerController.js
b/modules/ext.centralNotice.bannerController/bannerController.js
index 477b1ca..5181653 100644
--- a/modules/ext.centralNotice.bannerController/bannerController.js
+++ b/modules/ext.centralNotice.bannerController/bannerController.js
@@ -273,7 +273,7 @@
//
// TODO: Migrate away from global functions
window.insertBanner = function ( bannerJson ) {
- var url, targets, expiry, cookieName, cookieVal, deleteOld, now;
+ var url, targets, expiry, cookieName, cookieVal, deleteOld,
now, parsedCookie;
var impressionData = {
country: mw.centralNotice.data.country,
@@ -295,6 +295,11 @@
reason: 'empty'
};
} else {
+ impressionData = $.extend( impressionData, {
+ banner: bannerJson.bannerName,
+ campaign: bannerJson.campaign
+ } );
+
// Ok, we have a banner! Get the banner type for more
queryness
mw.centralNotice.data.category = encodeURIComponent(
bannerJson.category );
@@ -314,19 +319,23 @@
if ( cookieVal === 'hide' && deleteOld ) {
// Delete old-style cookie
$.cookie( cookieName, null, { path: '/'
} );
- } else if (
- cookieVal === 'hide' || (
- cookieVal !== null &&
- cookieVal.indexOf( '{'
) === 0 &&
- expiry[JSON.parse(
cookieVal ).reason] &&
- now < JSON.parse(
cookieVal ).created + expiry[JSON.parse( cookieVal ).reason]
- )
- ) {
- // The banner was hidden by a category
hide cookie and we're not testing
+ } else if ( cookieVal === 'hide' ) {
+ // The banner was hidden by a legacy
hide cookie.
impressionResultData = {
result: 'hide',
- reason: 'cookie'
+ reason: 'cookie' // Or
'donate'? Legacy 'close' are gone by now
};
+ } else if ( cookieVal !== null &&
cookieVal.indexOf( '{' ) === 0 ) {
+ parsedCookie = JSON.parse( cookieVal );
+ if ( expiry[parsedCookie.reason]
+ && now < parsedCookie.created +
expiry[parsedCookie.reason]
+ ) {
+ // The banner was hidden by a
cookie with a reason
+ impressionResultData = {
+ result: 'hide',
+ reason:
parsedCookie.reason
+ };
+ }
}
}
if ( !impressionResultData ) {
@@ -368,13 +377,12 @@
// ~~ as of 2012-11-27
if ( bannerShown ) {
impressionResultData = {
- banner: bannerJson.bannerName,
- campaign: bannerJson.campaign,
result: 'show'
};
} else {
impressionResultData = {
- result: 'hide'
+ result: 'hide',
+ reason: 'alterImpressionData'
};
}
}
--
To view, visit https://gerrit.wikimedia.org/r/165607
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0c7749e1fef4b2b6f8807f39762d381f391d5219
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/CentralNotice
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
Gerrit-Reviewer: AndyRussG <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Ejegg <[email protected]>
Gerrit-Reviewer: Mwalker <[email protected]>
Gerrit-Reviewer: Ssmith <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits