Ejegg has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/165607

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'

Change-Id: I0c7749e1fef4b2b6f8807f39762d381f391d5219
---
M modules/ext.centralNotice.bannerController/bannerController.js
1 file changed, 17 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralNotice 
refs/changes/07/165607/1

diff --git a/modules/ext.centralNotice.bannerController/bannerController.js 
b/modules/ext.centralNotice.bannerController/bannerController.js
index 477b1ca..dd066f8 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,
@@ -314,19 +314,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 ) {
@@ -374,7 +378,8 @@
                                        };
                                } 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: newchange
Gerrit-Change-Id: I0c7749e1fef4b2b6f8807f39762d381f391d5219
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralNotice
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to