diff options
-rw-r--r-- | js/piwik.js | 4 | ||||
-rw-r--r-- | js/piwik.min.js | 2 | ||||
-rw-r--r-- | matomo.js | 2 | ||||
-rw-r--r-- | piwik.js | 2 | ||||
-rw-r--r-- | tests/javascript/index.php | 20 |
5 files changed, 17 insertions, 13 deletions
diff --git a/js/piwik.js b/js/piwik.js index f4880ab7dd..c6bb15fe92 100644 --- a/js/piwik.js +++ b/js/piwik.js @@ -4425,7 +4425,7 @@ if (typeof window.Piwik !== 'object') { var index = i.replace('dimension', ''); customDimensionIdsAlreadyHandled.push(parseInt(index, 10)); customDimensionIdsAlreadyHandled.push(String(index)); - request += '&' + i + '=' + customData[i]; + request += '&' + i + '=' + encodeWrapper(customData[i]); delete customData[i]; } } @@ -4441,7 +4441,7 @@ if (typeof window.Piwik !== 'object') { if (Object.prototype.hasOwnProperty.call(customDimensions, i)) { var isNotSetYet = (-1 === indexOfArray(customDimensionIdsAlreadyHandled, i)); if (isNotSetYet) { - request += '&dimension' + i + '=' + customDimensions[i]; + request += '&dimension' + i + '=' + encodeWrapper(customDimensions[i]); } } } diff --git a/js/piwik.min.js b/js/piwik.min.js index dbd0a30ed8..b5eb529942 100644 --- a/js/piwik.min.js +++ b/js/piwik.min.js @@ -48,7 +48,7 @@ cj()}function cx(df){var dc=new Date();var db=dc.getTime();cS=db;if(cw&&db<cw){v return de}}return""}function cI(){if(!bJ){bJ=c9(bI)}var dd=new Date(),db=Math.round(dd.getTime()/1000),dc=aP("id"),dg=az(dc),df,de;if(dg){df=dg.split(".");df.unshift("0");if(bJ.length){df[1]=bJ}return df}if(bJ.length){de=bJ}else{if("0"===b0()){de=""}else{de=cL()}}df=["1",de,db,0,db,"",""];return df}function aU(){var di=cI(),de=di[0],df=di[1],dc=di[2],db=di[3],dg=di[4],dd=di[5];if(!J(di[6])){di[6]=""}var dh=di[6];return{newVisitor:de,uuid:df,createTs:dc,visitCount:db,currentVisitTs:dg,lastVisitTs:dd,lastEcommerceOrderTs:dh}}function aD(){var de=new Date(),dc=de.getTime(),df=aU().createTs;var db=parseInt(df,10);var dd=(db*1000)+cD-dc;return dd}function aI(db){if(!b1){return}var dd=new Date(),dc=Math.round(dd.getTime()/1000);if(!J(db)){db=aU()}var de=db.uuid+"."+db.createTs+"."+db.visitCount+"."+dc+"."+db.lastVisitTs+"."+db.lastEcommerceOrderTs;c6(aP("id"),de,aD(),bk,cR,bN)}function bH(){var db=az(aP("ref"));if(db.length){try{db=JSON_PIWIK.parse(db);if(W(db)){return db}}catch(dc){}}return["","",0,""] }function bT(dd,dc,db){c6(dd,"",-86400,dc,db)}function br(dc){var db="testvalue";c6("test",db,10000,null,dc);if(az("test")===db){bT("test",null,dc);return true}return false}function aB(){var dc=bg;bg=false;var db,dd;for(db=0;db<bp.length;db++){dd=aP(bp[db]);if(dd!==cG&&dd!==a9&&0!==az(dd)){bT(dd,bk,cR)}}bg=dc}function bY(db){b1=db;aI()}function da(df){if(!df||!W(df)){return}var de=[];var dd;for(dd in df){if(Object.prototype.hasOwnProperty.call(df,dd)){de.push(dd)}}var dg={};de.sort();var db=de.length;var dc;for(dc=0;dc<db;dc++){dg[de[dc]]=df[de[dc]]}return dg}function b8(){c6(aP("ses"),"1",ck,bk,cR,bN)}function bc(){var de="";var dc="abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";var dd=dc.length;var db;for(db=0;db<6;db++){de+=dc.charAt(Math.floor(Math.random()*dd))}return de}function co(dd,dz,dA,de){var dy,dc=new Date(),dl=Math.round(dc.getTime()/1000),di,dx,df=1024,dF,dm,dv=aM,dg=aP("ses"),dt=aP("ref"),dq=aP("cvar"),dr=az(dg),dw=bH(),dC=a0||bI,dj,db;if(bg){aB()}if(cK){return"" }var ds=aU();if(!J(de)){de=""}var dp=G.characterSet||G.charset;if(!dp||dp.toLowerCase()==="utf-8"){dp=null}dj=dw[0];db=dw[1];di=dw[2];dx=dw[3];if(!dr){var dB=ck/1000;if(!ds.lastVisitTs||(dl-ds.lastVisitTs)>dB){ds.visitCount++;ds.lastVisitTs=ds.currentVisitTs}if(!bq||!dj.length){for(dy in cm){if(Object.prototype.hasOwnProperty.call(cm,dy)){dj=f(dC,cm[dy]);if(dj.length){break}}}for(dy in bB){if(Object.prototype.hasOwnProperty.call(bB,dy)){db=f(dC,bB[dy]);if(db.length){break}}}}dF=d(bi);dm=dx.length?d(dx):"";if(dF.length&&!aR(dF)&&(!bq||!dm.length||aR(dm))){dx=bi}if(dx.length||dj.length){di=dl;dw=[dj,db,di,bX(dx.slice(0,df))];c6(dt,JSON_PIWIK.stringify(dw),cZ,bk,cR)}}dd+="&idsite="+b1+"&rec=1&r="+String(Math.random()).slice(2,8)+"&h="+dc.getHours()+"&m="+dc.getMinutes()+"&s="+dc.getSeconds()+"&url="+t(bX(dC))+(bi.length?"&urlref="+t(bX(bi)):"")+((bt&&bt.length)?"&uid="+t(bt):"")+"&_id="+ds.uuid+"&_idts="+ds.createTs+"&_idvc="+ds.visitCount+"&_idn="+ds.newVisitor+(dj.length?"&_rcn="+t(dj):"")+(db.length?"&_rck="+t(db):"")+"&_refts="+di+"&_viewts="+ds.lastVisitTs+(String(ds.lastEcommerceOrderTs).length?"&_ects="+ds.lastEcommerceOrderTs:"")+(String(dx).length?"&_ref="+t(bX(dx.slice(0,df))):"")+(dp?"&cs="+t(dp):"")+"&send_image=0"; -for(dy in c1){if(Object.prototype.hasOwnProperty.call(c1,dy)){dd+="&"+dy+"="+c1[dy]}}var dE=[];if(dz){for(dy in dz){if(Object.prototype.hasOwnProperty.call(dz,dy)&&/^dimension\d+$/.test(dy)){var dh=dy.replace("dimension","");dE.push(parseInt(dh,10));dE.push(String(dh));dd+="&"+dy+"="+dz[dy];delete dz[dy]}}}if(dz&&B(dz)){dz=null}for(dy in bh){if(Object.prototype.hasOwnProperty.call(bh,dy)){var dn=(-1===M(dE,dy));if(dn){dd+="&dimension"+dy+"="+bh[dy]}}}if(dz){dd+="&data="+t(JSON_PIWIK.stringify(dz))}else{if(al){dd+="&data="+t(JSON_PIWIK.stringify(al))}}function dk(dG,dH){var dI=JSON_PIWIK.stringify(dG);if(dI.length>2){return"&"+dH+"="+t(dI)}return""}var dD=da(bR);var du=da(ch);dd+=dk(dD,"cvar");dd+=dk(du,"e_cvar");if(aM){dd+=dk(aM,"_cvar");for(dy in dv){if(Object.prototype.hasOwnProperty.call(dv,dy)){if(aM[dy][0]===""||aM[dy][1]===""){delete aM[dy]}}}if(bL){c6(dq,JSON_PIWIK.stringify(aM),ck,bk,cR)}}if(aY){if(ci){dd+=">_ms="+ci}else{if(i&&i.timing&&i.timing.requestStart&&i.timing.responseEnd){dd+=">_ms="+(i.timing.responseEnd-i.timing.requestStart) +for(dy in c1){if(Object.prototype.hasOwnProperty.call(c1,dy)){dd+="&"+dy+"="+c1[dy]}}var dE=[];if(dz){for(dy in dz){if(Object.prototype.hasOwnProperty.call(dz,dy)&&/^dimension\d+$/.test(dy)){var dh=dy.replace("dimension","");dE.push(parseInt(dh,10));dE.push(String(dh));dd+="&"+dy+"="+t(dz[dy]);delete dz[dy]}}}if(dz&&B(dz)){dz=null}for(dy in bh){if(Object.prototype.hasOwnProperty.call(bh,dy)){var dn=(-1===M(dE,dy));if(dn){dd+="&dimension"+dy+"="+t(bh[dy])}}}if(dz){dd+="&data="+t(JSON_PIWIK.stringify(dz))}else{if(al){dd+="&data="+t(JSON_PIWIK.stringify(al))}}function dk(dG,dH){var dI=JSON_PIWIK.stringify(dG);if(dI.length>2){return"&"+dH+"="+t(dI)}return""}var dD=da(bR);var du=da(ch);dd+=dk(dD,"cvar");dd+=dk(du,"e_cvar");if(aM){dd+=dk(aM,"_cvar");for(dy in dv){if(Object.prototype.hasOwnProperty.call(dv,dy)){if(aM[dy][0]===""||aM[dy][1]===""){delete aM[dy]}}}if(bL){c6(dq,JSON_PIWIK.stringify(aM),ck,bk,cR)}}if(aY){if(ci){dd+=">_ms="+ci}else{if(i&&i.timing&&i.timing.requestStart&&i.timing.responseEnd){dd+=">_ms="+(i.timing.responseEnd-i.timing.requestStart) }}}if(aH){dd+="&pv_id="+aH}ds.lastEcommerceOrderTs=J(de)&&String(de).length?de:ds.lastEcommerceOrderTs;aI(ds);b8();dd+=aa(dA,{tracker:bD,request:dd});if(cT.length){dd+="&"+cT}if(A(b6)){dd=b6(dd)}return dd}bM=function a3(){var db=new Date();if(cS+a1<=db.getTime()){bD.ping();return true}return false};function bl(de,dd,dj,df,db,dm){var dh="idgoal=0",di,dc=new Date(),dk=[],dl,dg=String(de).length;if(dg){dh+="&ec_id="+t(de);di=Math.round(dc.getTime()/1000)}dh+="&revenue="+dd;if(String(dj).length){dh+="&ec_st="+dj}if(String(df).length){dh+="&ec_tx="+df}if(String(db).length){dh+="&ec_sh="+db}if(String(dm).length){dh+="&ec_dt="+dm}if(cU){for(dl in cU){if(Object.prototype.hasOwnProperty.call(cU,dl)){if(!J(cU[dl][1])){cU[dl][1]=""}if(!J(cU[dl][2])){cU[dl][2]=""}if(!J(cU[dl][3])||String(cU[dl][3]).length===0){cU[dl][3]=0}if(!J(cU[dl][4])||String(cU[dl][4]).length===0){cU[dl][4]=1}dk.push(cU[dl])}}dh+="&ec_items="+t(JSON_PIWIK.stringify(dk))}dh=co(dh,al,"ecommerce",di);bA(dh,bE);if(dg){cU={}}}function bU(db,df,de,dd,dc,dg){if(String(db).length&&J(df)){bl(db,df,de,dd,dc,dg) }}function bn(db){if(J(db)){bl("",db,"","","","")}}function bV(dc,de,dd){aH=bc();var db=co("action_name="+t(ai(dc||be)),de,"log");bA(db,bE,dd)}function aW(dd,dc){var de,db="(^| )(piwik[_-]"+dc;if(dd){for(de=0;de<dd.length;de++){db+="|"+dd[de]}}db+=")( |$)";return new RegExp(db)}function aQ(db){return(aA&&db&&0===String(db).indexOf(aA))}function cq(df,db,dg,dc){if(aQ(db)){return 0}var de=aW(bG,"download"),dd=aW(a4,"link"),dh=new RegExp("\\.("+c0.join("|")+")([?&#]|$)","i");if(dd.test(df)){return"link"}if(dc||de.test(df)||dh.test(db)){return"download"}if(dg){return 0}return"link"}function aq(dc){var db;db=dc.parentNode;while(db!==null&&J(db)){if(ac.isLinkElement(dc)){break}dc=db;db=dc.parentNode}return dc}function c5(dg){dg=aq(dg);if(!ac.hasNodeAttribute(dg,"href")){return}if(!J(dg.href)){return}var df=ac.getAttributeValueFromNode(dg,"href");if(aQ(df)){return}var dc=dg.pathname||cg(dg.href);var dh=dg.hostname||d(dg.href);var di=dh.toLowerCase();var dd=dg.href.replace(dh,di);var de=new RegExp("^(javascript|vbscript|jscript|mocha|livescript|ecmascript|mailto|tel):","i"); if(!de.test(dd)){var db=cq(dg.className,dd,ao(di,dc),ac.hasNodeAttribute(dg,"download"));if(db){return{type:db,href:dd}}}}function aL(db,dc,dd,de){var df=v.buildInteractionRequestParams(db,dc,dd,de);if(!df){return}return co(df,null,"contentInteraction")}function cF(dd,de,di,db,dc){if(!J(dd)){return}if(aQ(dd)){return dd}var dg=v.toAbsoluteUrl(dd);var df="redirecturl="+t(dg)+"&";df+=aL(de,di,db,(dc||dd));var dh="&";if(aA.indexOf("?")<0){dh="?"}return aA+dh+df}function a7(db,dc){if(!db||!dc){return false}var dd=v.findTargetNode(db);if(v.shouldIgnoreInteraction(dd)){return false}dd=v.findTargetNodeNoDefault(db);if(dd&&!V(dd,dc)){return false}return true}function cp(dd,dc,df){if(!dd){return}var db=v.findParentContentNode(dd);if(!db){return}if(!a7(db,dd)){return}var de=v.buildContentBlock(db);if(!de){return}if(!de.target&&df){de.target=df}return v.buildInteractionRequestParams(dc,de.name,de.piece,de.target)}function aS(dc){if(!b5||!b5.length){return false}var db,dd;for(db=0;db<b5.length;db++){dd=b5[db]; @@ -48,7 +48,7 @@ cj()}function cx(df){var dc=new Date();var db=dc.getTime();cS=db;if(cw&&db<cw){v return de}}return""}function cI(){if(!bJ){bJ=c9(bI)}var dd=new Date(),db=Math.round(dd.getTime()/1000),dc=aP("id"),dg=az(dc),df,de;if(dg){df=dg.split(".");df.unshift("0");if(bJ.length){df[1]=bJ}return df}if(bJ.length){de=bJ}else{if("0"===b0()){de=""}else{de=cL()}}df=["1",de,db,0,db,"",""];return df}function aU(){var di=cI(),de=di[0],df=di[1],dc=di[2],db=di[3],dg=di[4],dd=di[5];if(!J(di[6])){di[6]=""}var dh=di[6];return{newVisitor:de,uuid:df,createTs:dc,visitCount:db,currentVisitTs:dg,lastVisitTs:dd,lastEcommerceOrderTs:dh}}function aD(){var de=new Date(),dc=de.getTime(),df=aU().createTs;var db=parseInt(df,10);var dd=(db*1000)+cD-dc;return dd}function aI(db){if(!b1){return}var dd=new Date(),dc=Math.round(dd.getTime()/1000);if(!J(db)){db=aU()}var de=db.uuid+"."+db.createTs+"."+db.visitCount+"."+dc+"."+db.lastVisitTs+"."+db.lastEcommerceOrderTs;c6(aP("id"),de,aD(),bk,cR,bN)}function bH(){var db=az(aP("ref"));if(db.length){try{db=JSON_PIWIK.parse(db);if(W(db)){return db}}catch(dc){}}return["","",0,""] }function bT(dd,dc,db){c6(dd,"",-86400,dc,db)}function br(dc){var db="testvalue";c6("test",db,10000,null,dc);if(az("test")===db){bT("test",null,dc);return true}return false}function aB(){var dc=bg;bg=false;var db,dd;for(db=0;db<bp.length;db++){dd=aP(bp[db]);if(dd!==cG&&dd!==a9&&0!==az(dd)){bT(dd,bk,cR)}}bg=dc}function bY(db){b1=db;aI()}function da(df){if(!df||!W(df)){return}var de=[];var dd;for(dd in df){if(Object.prototype.hasOwnProperty.call(df,dd)){de.push(dd)}}var dg={};de.sort();var db=de.length;var dc;for(dc=0;dc<db;dc++){dg[de[dc]]=df[de[dc]]}return dg}function b8(){c6(aP("ses"),"1",ck,bk,cR,bN)}function bc(){var de="";var dc="abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";var dd=dc.length;var db;for(db=0;db<6;db++){de+=dc.charAt(Math.floor(Math.random()*dd))}return de}function co(dd,dz,dA,de){var dy,dc=new Date(),dl=Math.round(dc.getTime()/1000),di,dx,df=1024,dF,dm,dv=aM,dg=aP("ses"),dt=aP("ref"),dq=aP("cvar"),dr=az(dg),dw=bH(),dC=a0||bI,dj,db;if(bg){aB()}if(cK){return"" }var ds=aU();if(!J(de)){de=""}var dp=G.characterSet||G.charset;if(!dp||dp.toLowerCase()==="utf-8"){dp=null}dj=dw[0];db=dw[1];di=dw[2];dx=dw[3];if(!dr){var dB=ck/1000;if(!ds.lastVisitTs||(dl-ds.lastVisitTs)>dB){ds.visitCount++;ds.lastVisitTs=ds.currentVisitTs}if(!bq||!dj.length){for(dy in cm){if(Object.prototype.hasOwnProperty.call(cm,dy)){dj=f(dC,cm[dy]);if(dj.length){break}}}for(dy in bB){if(Object.prototype.hasOwnProperty.call(bB,dy)){db=f(dC,bB[dy]);if(db.length){break}}}}dF=d(bi);dm=dx.length?d(dx):"";if(dF.length&&!aR(dF)&&(!bq||!dm.length||aR(dm))){dx=bi}if(dx.length||dj.length){di=dl;dw=[dj,db,di,bX(dx.slice(0,df))];c6(dt,JSON_PIWIK.stringify(dw),cZ,bk,cR)}}dd+="&idsite="+b1+"&rec=1&r="+String(Math.random()).slice(2,8)+"&h="+dc.getHours()+"&m="+dc.getMinutes()+"&s="+dc.getSeconds()+"&url="+t(bX(dC))+(bi.length?"&urlref="+t(bX(bi)):"")+((bt&&bt.length)?"&uid="+t(bt):"")+"&_id="+ds.uuid+"&_idts="+ds.createTs+"&_idvc="+ds.visitCount+"&_idn="+ds.newVisitor+(dj.length?"&_rcn="+t(dj):"")+(db.length?"&_rck="+t(db):"")+"&_refts="+di+"&_viewts="+ds.lastVisitTs+(String(ds.lastEcommerceOrderTs).length?"&_ects="+ds.lastEcommerceOrderTs:"")+(String(dx).length?"&_ref="+t(bX(dx.slice(0,df))):"")+(dp?"&cs="+t(dp):"")+"&send_image=0"; -for(dy in c1){if(Object.prototype.hasOwnProperty.call(c1,dy)){dd+="&"+dy+"="+c1[dy]}}var dE=[];if(dz){for(dy in dz){if(Object.prototype.hasOwnProperty.call(dz,dy)&&/^dimension\d+$/.test(dy)){var dh=dy.replace("dimension","");dE.push(parseInt(dh,10));dE.push(String(dh));dd+="&"+dy+"="+dz[dy];delete dz[dy]}}}if(dz&&B(dz)){dz=null}for(dy in bh){if(Object.prototype.hasOwnProperty.call(bh,dy)){var dn=(-1===M(dE,dy));if(dn){dd+="&dimension"+dy+"="+bh[dy]}}}if(dz){dd+="&data="+t(JSON_PIWIK.stringify(dz))}else{if(al){dd+="&data="+t(JSON_PIWIK.stringify(al))}}function dk(dG,dH){var dI=JSON_PIWIK.stringify(dG);if(dI.length>2){return"&"+dH+"="+t(dI)}return""}var dD=da(bR);var du=da(ch);dd+=dk(dD,"cvar");dd+=dk(du,"e_cvar");if(aM){dd+=dk(aM,"_cvar");for(dy in dv){if(Object.prototype.hasOwnProperty.call(dv,dy)){if(aM[dy][0]===""||aM[dy][1]===""){delete aM[dy]}}}if(bL){c6(dq,JSON_PIWIK.stringify(aM),ck,bk,cR)}}if(aY){if(ci){dd+=">_ms="+ci}else{if(i&&i.timing&&i.timing.requestStart&&i.timing.responseEnd){dd+=">_ms="+(i.timing.responseEnd-i.timing.requestStart) +for(dy in c1){if(Object.prototype.hasOwnProperty.call(c1,dy)){dd+="&"+dy+"="+c1[dy]}}var dE=[];if(dz){for(dy in dz){if(Object.prototype.hasOwnProperty.call(dz,dy)&&/^dimension\d+$/.test(dy)){var dh=dy.replace("dimension","");dE.push(parseInt(dh,10));dE.push(String(dh));dd+="&"+dy+"="+t(dz[dy]);delete dz[dy]}}}if(dz&&B(dz)){dz=null}for(dy in bh){if(Object.prototype.hasOwnProperty.call(bh,dy)){var dn=(-1===M(dE,dy));if(dn){dd+="&dimension"+dy+"="+t(bh[dy])}}}if(dz){dd+="&data="+t(JSON_PIWIK.stringify(dz))}else{if(al){dd+="&data="+t(JSON_PIWIK.stringify(al))}}function dk(dG,dH){var dI=JSON_PIWIK.stringify(dG);if(dI.length>2){return"&"+dH+"="+t(dI)}return""}var dD=da(bR);var du=da(ch);dd+=dk(dD,"cvar");dd+=dk(du,"e_cvar");if(aM){dd+=dk(aM,"_cvar");for(dy in dv){if(Object.prototype.hasOwnProperty.call(dv,dy)){if(aM[dy][0]===""||aM[dy][1]===""){delete aM[dy]}}}if(bL){c6(dq,JSON_PIWIK.stringify(aM),ck,bk,cR)}}if(aY){if(ci){dd+=">_ms="+ci}else{if(i&&i.timing&&i.timing.requestStart&&i.timing.responseEnd){dd+=">_ms="+(i.timing.responseEnd-i.timing.requestStart) }}}if(aH){dd+="&pv_id="+aH}ds.lastEcommerceOrderTs=J(de)&&String(de).length?de:ds.lastEcommerceOrderTs;aI(ds);b8();dd+=aa(dA,{tracker:bD,request:dd});if(cT.length){dd+="&"+cT}if(A(b6)){dd=b6(dd)}return dd}bM=function a3(){var db=new Date();if(cS+a1<=db.getTime()){bD.ping();return true}return false};function bl(de,dd,dj,df,db,dm){var dh="idgoal=0",di,dc=new Date(),dk=[],dl,dg=String(de).length;if(dg){dh+="&ec_id="+t(de);di=Math.round(dc.getTime()/1000)}dh+="&revenue="+dd;if(String(dj).length){dh+="&ec_st="+dj}if(String(df).length){dh+="&ec_tx="+df}if(String(db).length){dh+="&ec_sh="+db}if(String(dm).length){dh+="&ec_dt="+dm}if(cU){for(dl in cU){if(Object.prototype.hasOwnProperty.call(cU,dl)){if(!J(cU[dl][1])){cU[dl][1]=""}if(!J(cU[dl][2])){cU[dl][2]=""}if(!J(cU[dl][3])||String(cU[dl][3]).length===0){cU[dl][3]=0}if(!J(cU[dl][4])||String(cU[dl][4]).length===0){cU[dl][4]=1}dk.push(cU[dl])}}dh+="&ec_items="+t(JSON_PIWIK.stringify(dk))}dh=co(dh,al,"ecommerce",di);bA(dh,bE);if(dg){cU={}}}function bU(db,df,de,dd,dc,dg){if(String(db).length&&J(df)){bl(db,df,de,dd,dc,dg) }}function bn(db){if(J(db)){bl("",db,"","","","")}}function bV(dc,de,dd){aH=bc();var db=co("action_name="+t(ai(dc||be)),de,"log");bA(db,bE,dd)}function aW(dd,dc){var de,db="(^| )(piwik[_-]"+dc;if(dd){for(de=0;de<dd.length;de++){db+="|"+dd[de]}}db+=")( |$)";return new RegExp(db)}function aQ(db){return(aA&&db&&0===String(db).indexOf(aA))}function cq(df,db,dg,dc){if(aQ(db)){return 0}var de=aW(bG,"download"),dd=aW(a4,"link"),dh=new RegExp("\\.("+c0.join("|")+")([?&#]|$)","i");if(dd.test(df)){return"link"}if(dc||de.test(df)||dh.test(db)){return"download"}if(dg){return 0}return"link"}function aq(dc){var db;db=dc.parentNode;while(db!==null&&J(db)){if(ac.isLinkElement(dc)){break}dc=db;db=dc.parentNode}return dc}function c5(dg){dg=aq(dg);if(!ac.hasNodeAttribute(dg,"href")){return}if(!J(dg.href)){return}var df=ac.getAttributeValueFromNode(dg,"href");if(aQ(df)){return}var dc=dg.pathname||cg(dg.href);var dh=dg.hostname||d(dg.href);var di=dh.toLowerCase();var dd=dg.href.replace(dh,di);var de=new RegExp("^(javascript|vbscript|jscript|mocha|livescript|ecmascript|mailto|tel):","i"); if(!de.test(dd)){var db=cq(dg.className,dd,ao(di,dc),ac.hasNodeAttribute(dg,"download"));if(db){return{type:db,href:dd}}}}function aL(db,dc,dd,de){var df=v.buildInteractionRequestParams(db,dc,dd,de);if(!df){return}return co(df,null,"contentInteraction")}function cF(dd,de,di,db,dc){if(!J(dd)){return}if(aQ(dd)){return dd}var dg=v.toAbsoluteUrl(dd);var df="redirecturl="+t(dg)+"&";df+=aL(de,di,db,(dc||dd));var dh="&";if(aA.indexOf("?")<0){dh="?"}return aA+dh+df}function a7(db,dc){if(!db||!dc){return false}var dd=v.findTargetNode(db);if(v.shouldIgnoreInteraction(dd)){return false}dd=v.findTargetNodeNoDefault(db);if(dd&&!V(dd,dc)){return false}return true}function cp(dd,dc,df){if(!dd){return}var db=v.findParentContentNode(dd);if(!db){return}if(!a7(db,dd)){return}var de=v.buildContentBlock(db);if(!de){return}if(!de.target&&df){de.target=df}return v.buildInteractionRequestParams(dc,de.name,de.piece,de.target)}function aS(dc){if(!b5||!b5.length){return false}var db,dd;for(db=0;db<b5.length;db++){dd=b5[db]; @@ -48,7 +48,7 @@ cj()}function cx(df){var dc=new Date();var db=dc.getTime();cS=db;if(cw&&db<cw){v return de}}return""}function cI(){if(!bJ){bJ=c9(bI)}var dd=new Date(),db=Math.round(dd.getTime()/1000),dc=aP("id"),dg=az(dc),df,de;if(dg){df=dg.split(".");df.unshift("0");if(bJ.length){df[1]=bJ}return df}if(bJ.length){de=bJ}else{if("0"===b0()){de=""}else{de=cL()}}df=["1",de,db,0,db,"",""];return df}function aU(){var di=cI(),de=di[0],df=di[1],dc=di[2],db=di[3],dg=di[4],dd=di[5];if(!J(di[6])){di[6]=""}var dh=di[6];return{newVisitor:de,uuid:df,createTs:dc,visitCount:db,currentVisitTs:dg,lastVisitTs:dd,lastEcommerceOrderTs:dh}}function aD(){var de=new Date(),dc=de.getTime(),df=aU().createTs;var db=parseInt(df,10);var dd=(db*1000)+cD-dc;return dd}function aI(db){if(!b1){return}var dd=new Date(),dc=Math.round(dd.getTime()/1000);if(!J(db)){db=aU()}var de=db.uuid+"."+db.createTs+"."+db.visitCount+"."+dc+"."+db.lastVisitTs+"."+db.lastEcommerceOrderTs;c6(aP("id"),de,aD(),bk,cR,bN)}function bH(){var db=az(aP("ref"));if(db.length){try{db=JSON_PIWIK.parse(db);if(W(db)){return db}}catch(dc){}}return["","",0,""] }function bT(dd,dc,db){c6(dd,"",-86400,dc,db)}function br(dc){var db="testvalue";c6("test",db,10000,null,dc);if(az("test")===db){bT("test",null,dc);return true}return false}function aB(){var dc=bg;bg=false;var db,dd;for(db=0;db<bp.length;db++){dd=aP(bp[db]);if(dd!==cG&&dd!==a9&&0!==az(dd)){bT(dd,bk,cR)}}bg=dc}function bY(db){b1=db;aI()}function da(df){if(!df||!W(df)){return}var de=[];var dd;for(dd in df){if(Object.prototype.hasOwnProperty.call(df,dd)){de.push(dd)}}var dg={};de.sort();var db=de.length;var dc;for(dc=0;dc<db;dc++){dg[de[dc]]=df[de[dc]]}return dg}function b8(){c6(aP("ses"),"1",ck,bk,cR,bN)}function bc(){var de="";var dc="abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";var dd=dc.length;var db;for(db=0;db<6;db++){de+=dc.charAt(Math.floor(Math.random()*dd))}return de}function co(dd,dz,dA,de){var dy,dc=new Date(),dl=Math.round(dc.getTime()/1000),di,dx,df=1024,dF,dm,dv=aM,dg=aP("ses"),dt=aP("ref"),dq=aP("cvar"),dr=az(dg),dw=bH(),dC=a0||bI,dj,db;if(bg){aB()}if(cK){return"" }var ds=aU();if(!J(de)){de=""}var dp=G.characterSet||G.charset;if(!dp||dp.toLowerCase()==="utf-8"){dp=null}dj=dw[0];db=dw[1];di=dw[2];dx=dw[3];if(!dr){var dB=ck/1000;if(!ds.lastVisitTs||(dl-ds.lastVisitTs)>dB){ds.visitCount++;ds.lastVisitTs=ds.currentVisitTs}if(!bq||!dj.length){for(dy in cm){if(Object.prototype.hasOwnProperty.call(cm,dy)){dj=f(dC,cm[dy]);if(dj.length){break}}}for(dy in bB){if(Object.prototype.hasOwnProperty.call(bB,dy)){db=f(dC,bB[dy]);if(db.length){break}}}}dF=d(bi);dm=dx.length?d(dx):"";if(dF.length&&!aR(dF)&&(!bq||!dm.length||aR(dm))){dx=bi}if(dx.length||dj.length){di=dl;dw=[dj,db,di,bX(dx.slice(0,df))];c6(dt,JSON_PIWIK.stringify(dw),cZ,bk,cR)}}dd+="&idsite="+b1+"&rec=1&r="+String(Math.random()).slice(2,8)+"&h="+dc.getHours()+"&m="+dc.getMinutes()+"&s="+dc.getSeconds()+"&url="+t(bX(dC))+(bi.length?"&urlref="+t(bX(bi)):"")+((bt&&bt.length)?"&uid="+t(bt):"")+"&_id="+ds.uuid+"&_idts="+ds.createTs+"&_idvc="+ds.visitCount+"&_idn="+ds.newVisitor+(dj.length?"&_rcn="+t(dj):"")+(db.length?"&_rck="+t(db):"")+"&_refts="+di+"&_viewts="+ds.lastVisitTs+(String(ds.lastEcommerceOrderTs).length?"&_ects="+ds.lastEcommerceOrderTs:"")+(String(dx).length?"&_ref="+t(bX(dx.slice(0,df))):"")+(dp?"&cs="+t(dp):"")+"&send_image=0"; -for(dy in c1){if(Object.prototype.hasOwnProperty.call(c1,dy)){dd+="&"+dy+"="+c1[dy]}}var dE=[];if(dz){for(dy in dz){if(Object.prototype.hasOwnProperty.call(dz,dy)&&/^dimension\d+$/.test(dy)){var dh=dy.replace("dimension","");dE.push(parseInt(dh,10));dE.push(String(dh));dd+="&"+dy+"="+dz[dy];delete dz[dy]}}}if(dz&&B(dz)){dz=null}for(dy in bh){if(Object.prototype.hasOwnProperty.call(bh,dy)){var dn=(-1===M(dE,dy));if(dn){dd+="&dimension"+dy+"="+bh[dy]}}}if(dz){dd+="&data="+t(JSON_PIWIK.stringify(dz))}else{if(al){dd+="&data="+t(JSON_PIWIK.stringify(al))}}function dk(dG,dH){var dI=JSON_PIWIK.stringify(dG);if(dI.length>2){return"&"+dH+"="+t(dI)}return""}var dD=da(bR);var du=da(ch);dd+=dk(dD,"cvar");dd+=dk(du,"e_cvar");if(aM){dd+=dk(aM,"_cvar");for(dy in dv){if(Object.prototype.hasOwnProperty.call(dv,dy)){if(aM[dy][0]===""||aM[dy][1]===""){delete aM[dy]}}}if(bL){c6(dq,JSON_PIWIK.stringify(aM),ck,bk,cR)}}if(aY){if(ci){dd+=">_ms="+ci}else{if(i&&i.timing&&i.timing.requestStart&&i.timing.responseEnd){dd+=">_ms="+(i.timing.responseEnd-i.timing.requestStart) +for(dy in c1){if(Object.prototype.hasOwnProperty.call(c1,dy)){dd+="&"+dy+"="+c1[dy]}}var dE=[];if(dz){for(dy in dz){if(Object.prototype.hasOwnProperty.call(dz,dy)&&/^dimension\d+$/.test(dy)){var dh=dy.replace("dimension","");dE.push(parseInt(dh,10));dE.push(String(dh));dd+="&"+dy+"="+t(dz[dy]);delete dz[dy]}}}if(dz&&B(dz)){dz=null}for(dy in bh){if(Object.prototype.hasOwnProperty.call(bh,dy)){var dn=(-1===M(dE,dy));if(dn){dd+="&dimension"+dy+"="+t(bh[dy])}}}if(dz){dd+="&data="+t(JSON_PIWIK.stringify(dz))}else{if(al){dd+="&data="+t(JSON_PIWIK.stringify(al))}}function dk(dG,dH){var dI=JSON_PIWIK.stringify(dG);if(dI.length>2){return"&"+dH+"="+t(dI)}return""}var dD=da(bR);var du=da(ch);dd+=dk(dD,"cvar");dd+=dk(du,"e_cvar");if(aM){dd+=dk(aM,"_cvar");for(dy in dv){if(Object.prototype.hasOwnProperty.call(dv,dy)){if(aM[dy][0]===""||aM[dy][1]===""){delete aM[dy]}}}if(bL){c6(dq,JSON_PIWIK.stringify(aM),ck,bk,cR)}}if(aY){if(ci){dd+=">_ms="+ci}else{if(i&&i.timing&&i.timing.requestStart&&i.timing.responseEnd){dd+=">_ms="+(i.timing.responseEnd-i.timing.requestStart) }}}if(aH){dd+="&pv_id="+aH}ds.lastEcommerceOrderTs=J(de)&&String(de).length?de:ds.lastEcommerceOrderTs;aI(ds);b8();dd+=aa(dA,{tracker:bD,request:dd});if(cT.length){dd+="&"+cT}if(A(b6)){dd=b6(dd)}return dd}bM=function a3(){var db=new Date();if(cS+a1<=db.getTime()){bD.ping();return true}return false};function bl(de,dd,dj,df,db,dm){var dh="idgoal=0",di,dc=new Date(),dk=[],dl,dg=String(de).length;if(dg){dh+="&ec_id="+t(de);di=Math.round(dc.getTime()/1000)}dh+="&revenue="+dd;if(String(dj).length){dh+="&ec_st="+dj}if(String(df).length){dh+="&ec_tx="+df}if(String(db).length){dh+="&ec_sh="+db}if(String(dm).length){dh+="&ec_dt="+dm}if(cU){for(dl in cU){if(Object.prototype.hasOwnProperty.call(cU,dl)){if(!J(cU[dl][1])){cU[dl][1]=""}if(!J(cU[dl][2])){cU[dl][2]=""}if(!J(cU[dl][3])||String(cU[dl][3]).length===0){cU[dl][3]=0}if(!J(cU[dl][4])||String(cU[dl][4]).length===0){cU[dl][4]=1}dk.push(cU[dl])}}dh+="&ec_items="+t(JSON_PIWIK.stringify(dk))}dh=co(dh,al,"ecommerce",di);bA(dh,bE);if(dg){cU={}}}function bU(db,df,de,dd,dc,dg){if(String(db).length&&J(df)){bl(db,df,de,dd,dc,dg) }}function bn(db){if(J(db)){bl("",db,"","","","")}}function bV(dc,de,dd){aH=bc();var db=co("action_name="+t(ai(dc||be)),de,"log");bA(db,bE,dd)}function aW(dd,dc){var de,db="(^| )(piwik[_-]"+dc;if(dd){for(de=0;de<dd.length;de++){db+="|"+dd[de]}}db+=")( |$)";return new RegExp(db)}function aQ(db){return(aA&&db&&0===String(db).indexOf(aA))}function cq(df,db,dg,dc){if(aQ(db)){return 0}var de=aW(bG,"download"),dd=aW(a4,"link"),dh=new RegExp("\\.("+c0.join("|")+")([?&#]|$)","i");if(dd.test(df)){return"link"}if(dc||de.test(df)||dh.test(db)){return"download"}if(dg){return 0}return"link"}function aq(dc){var db;db=dc.parentNode;while(db!==null&&J(db)){if(ac.isLinkElement(dc)){break}dc=db;db=dc.parentNode}return dc}function c5(dg){dg=aq(dg);if(!ac.hasNodeAttribute(dg,"href")){return}if(!J(dg.href)){return}var df=ac.getAttributeValueFromNode(dg,"href");if(aQ(df)){return}var dc=dg.pathname||cg(dg.href);var dh=dg.hostname||d(dg.href);var di=dh.toLowerCase();var dd=dg.href.replace(dh,di);var de=new RegExp("^(javascript|vbscript|jscript|mocha|livescript|ecmascript|mailto|tel):","i"); if(!de.test(dd)){var db=cq(dg.className,dd,ao(di,dc),ac.hasNodeAttribute(dg,"download"));if(db){return{type:db,href:dd}}}}function aL(db,dc,dd,de){var df=v.buildInteractionRequestParams(db,dc,dd,de);if(!df){return}return co(df,null,"contentInteraction")}function cF(dd,de,di,db,dc){if(!J(dd)){return}if(aQ(dd)){return dd}var dg=v.toAbsoluteUrl(dd);var df="redirecturl="+t(dg)+"&";df+=aL(de,di,db,(dc||dd));var dh="&";if(aA.indexOf("?")<0){dh="?"}return aA+dh+df}function a7(db,dc){if(!db||!dc){return false}var dd=v.findTargetNode(db);if(v.shouldIgnoreInteraction(dd)){return false}dd=v.findTargetNodeNoDefault(db);if(dd&&!V(dd,dc)){return false}return true}function cp(dd,dc,df){if(!dd){return}var db=v.findParentContentNode(dd);if(!db){return}if(!a7(db,dd)){return}var de=v.buildContentBlock(db);if(!de){return}if(!de.target&&df){de.target=df}return v.buildInteractionRequestParams(dc,de.name,de.piece,de.target)}function aS(dc){if(!b5||!b5.length){return false}var db,dd;for(db=0;db<b5.length;db++){dd=b5[db]; diff --git a/tests/javascript/index.php b/tests/javascript/index.php index 1de34609ac..cdb17efb8a 100644 --- a/tests/javascript/index.php +++ b/tests/javascript/index.php @@ -17,7 +17,7 @@ $root = dirname(__FILE__) . '/../..'; try { $mysql = include_once $root . "/tests/PHPUnit/bootstrap.php"; } catch (Exception $e) { - echo 'alert("' . $e->getMessage() . '")'; + echo 'alert("ERROR, not all tests are running! --> ' . $e->getMessage() . '")'; $mysql = false; } @@ -3611,7 +3611,7 @@ if ($mysql) { test("tracking", function() { - expect(164); + expect(165); // Prevent Opera and HtmlUnit from performing the default action (i.e., load the href URL) var stopEvent = function (evt) { @@ -3698,8 +3698,8 @@ if ($mysql) { equal(tracker.getCustomDimension('not valid'), null, "if custom dimension index is invalid should return null"); tracker.setCustomDimension(1, 5); equal(tracker.getCustomDimension(1), "5", "set custom dimension should convert any value to a string" ); - tracker.setCustomDimension(1, "my custom value"); - equal(tracker.getCustomDimension(1), "my custom value", "should get stored custom dimension value" ); + tracker.setCustomDimension(1, "my custom value with éàç&*() EOL"); + equal(tracker.getCustomDimension(1), "my custom value with éàç&*() EOL", "should get stored custom dimension value" ); tracker.setCustomDimension(2, undefined); equal(tracker.getCustomDimension(2), "", "setCustomDimension should convert undefined to an empty string" ); @@ -3756,7 +3756,7 @@ if ($mysql) { var idPageview = tracker.getConfigIdPageView(); ok(/([0-9a-zA-Z]){6}/.test(idPageview), 'trackPageview, should generate a random pageview id'); - equal(tracker.getCustomDimension(1), "my custom value", "custom dimensions should not be cleared after a tracked pageview"); + equal(tracker.getCustomDimension(1), "my custom value with éàç&*() EOL", "custom dimensions should not be cleared after a tracked pageview"); equal(tracker.getCustomDimension(2), "", "custom dimensions should not be cleared after a tracked pageview"); tracker.trackPageView("CustomTitleTest", {dimension2: 'my new value', dimension5: 'another dimension'}); @@ -4077,7 +4077,11 @@ if ($mysql) { xhr.open("GET", "matomo.php?requests=" + getToken(), false); xhr.send(null); results = xhr.responseText; - equal( (/<span\>([0-9]+)\<\/span\>/.exec(results))[1], "41", "count tracking events" ); + var countTrackingEvents = /<span\>([0-9]+)\<\/span\>/.exec(results); + ok (countTrackingEvents, "countTrackingEvents is set"); + if(countTrackingEvents) { + equal( countTrackingEvents[1], "41", "count tracking events" ); + } // firing callback ok( trackLinkCallbackFired, "trackLink() callback fired" ); @@ -4124,10 +4128,10 @@ if ($mysql) { ok( /SaveCustomVariableCookie.*&cvar=%7B%222%22%3A%5B%22cookiename2PAGE%22%2C%22cookievalue2PAGE%22%5D%7D.*&_cvar=%7B%221%22%3A%5B%22cookiename%22%2C%22cookievalue%22%5D%2C%222%22%3A%5B%22cookiename2%22%2C%22cookievalue2%22%5D%7D/.test(results), "test custom vars are set"); // Test CustomDimension (persistent ones across requests) - ok( /dimension1=my%20custom%20value&dimension2=&/.test(results), "test custom dimensions are set"); + ok( /dimension1=my%20custom%20value%20with%20%C3%A9%C3%A0%C3%A7%26\*\(\)%20EOL&dimension2=&/.test(results), "test custom dimensions are set"); // send along a page view and ony valid for this pageview (dimension 2 overwrites another one) - ok( /dimension2=my%20new%20value&dimension5=another%20dimension&dimension1=my%20custom%20value&data=%7B%22token/.test( results ), "trackPageView(customTitle, customData)" ); + ok( /dimension2=my%20new%20value&dimension5=another%20dimension&dimension1=my%.*&data=%7B%22token/.test( results ), "trackPageView(customTitle, customData)" ); // Test campaign parameters set ok( /&_rcn=YEAH&_rck=RIGHT!/.test( results), "Test campaign parameters found"); |