diff options
-rw-r--r-- | js/piwik.js | 2 | ||||
-rw-r--r-- | piwik.js | 16 | ||||
-rw-r--r-- | tests/javascript/index.php | 10 |
3 files changed, 17 insertions, 11 deletions
diff --git a/js/piwik.js b/js/piwik.js index 6ba9d3dc04..6c702143c5 100644 --- a/js/piwik.js +++ b/js/piwik.js @@ -4082,7 +4082,7 @@ if (typeof Piwik !== 'object') { * @return string Visitor ID in hexits (or null, if not yet known) */ getVisitorId: function () { - return configUserId ? sha1(configUserId).substr(0, 16) : (loadVisitorIdCookie())[1]; + return configUserId.length ? sha1(configUserId).substr(0, 16) : (loadVisitorIdCookie())[1]; }, /** @@ -30,8 +30,8 @@ if(Q.hasNodeAttributeWithValue(W,"href")){X=Q.getAttributeValueFromNode(W,"href" G.name=W+"###"+ac+"###"+X}var ab=G.name.split("###");return ab.length===3&&ab[0]===W}function M(X,ac,Z){var ab=G.name.split("###"),aa=ab[1],W=ab[2],Y=B(X,ac);i(Y+"plugins/Overlay/client/client.js?v=1",function(){Piwik_Overlay_Client.initialize(Y,Z,aa,W)})}function D(aE,bl,bJ){var ad=N(u.domain,G.location.href,x()),bL=y(ad[0]),b3=ad[1],bt=ad[2],b6=false,bp="GET",br=bp,bb="application/x-www-form-urlencoded; charset=UTF-8",aK=bb,aa=aE||"",ax="",bn="",bR=bl||"",aJ="",a6,aS=u.title,aU="7z|aac|apk|ar[cj]|as[fx]|avi|azw3|bin|csv|deb|dmg|docx?|epub|exe|flv|gif|gz|gzip|hqx|jar|jpe?g|js|mobi|mp(2|3|4|e?g)|mov(ie)?|ms[ip]|od[bfgpst]|og[gv]|pdf|phps|png|pptx?|qtm?|ra[mr]?|rpm|sea|sit|tar|t?bz2?|tgz|torrent|txt|wav|wm[av]|wpd||xlsx?|xml|z|zip",bo=[bL],ai=[],be=[],aC=[],bm=500,aj,aG,ak,an,aY=["pk_campaign","piwik_campaign","utm_campaign","utm_source","utm_medium"],aP=["pk_kwd","piwik_kwd","utm_term"],b1="_pk_",aq,b2,ao=false,bV,a0,a4,aw=33955200000,az=1800000,a9=15768000000,a1=true,aI=0,a5=false,ag=false,au,bf={},ab={},bW=200,bD={},bS={},ah=[],ay=false,a8=false,by=false,bT=false,bv=false,bs,bi,at,aX=T,bx,a2=bJ; function bF(cf,cc,cb,ce,ca,cd){if(ao){return}var b9;if(cb){b9=new Date();b9.setTime(b9.getTime()+cb)}u.cookie=cf+"="+l(cc)+(cb?";expires="+b9.toGMTString():"")+";path="+(ce||"/")+(ca?";domain="+ca:"")+(cd?";secure":"")}function av(cb){if(ao){return 0}var b9=new RegExp("(^|;)[ ]*"+cb+"=([^;]*)"),ca=b9.exec(u.cookie);return ca?F(ca[2]):0}function bX(b9){var ca;if(ak){ca=new RegExp("#.*");return b9.replace(ca,"")}return b9}function bK(cb,b9){var cc=k(b9),ca;if(cc){return b9}if(b9.slice(0,1)==="/"){return k(cb)+"://"+b(cb)+b9}cb=bX(cb);ca=cb.indexOf("?");if(ca>=0){cb=cb.slice(0,ca)}ca=cb.lastIndexOf("/");if(ca!==cb.length-1){cb=cb.slice(0,ca+1)}return cb+b9}function bq(cc){var ca,b9,cb;for(ca=0;ca<bo.length;ca++){b9=y(bo[ca].toLowerCase());if(cc===b9){return true}if(b9.slice(0,1)==="."){if(cc===b9.slice(1)){return true}cb=cc.length-b9.length;if((cb>0)&&(cc.slice(cb)===b9)){return true}}}return false}function b8(b9,cb){var ca=new Image(1,1);ca.onload=function(){t=0;if(typeof cb==="function"){cb() }};ca.src=aa+(aa.indexOf("?")<0?"?":"&")+b9}function bG(ca,cd,b9){if(!w(b9)||null===b9){b9=true}try{var cc=G.XMLHttpRequest?new G.XMLHttpRequest():G.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):null;cc.open("POST",aa,true);cc.onreadystatechange=function(){if(this.readyState===4&&!(this.status>=200&&this.status<300)&&b9){b8(ca,cd)}else{if(typeof cd==="function"){cd()}}};cc.setRequestHeader("Content-Type",aK);cc.send(ca)}catch(cb){if(b9){b8(ca,cd)}}}function bY(ca){var b9=new Date();var cb=b9.getTime()+ca;if(!j||cb>j){j=cb}}function aD(cd){var ca=new Date();var b9=ca.getTime();if(a8&&b9<a8){var cb=a8-b9;setTimeout(cd,cb);bY(cb+50);a8+=50;return}if(a8===false){var cc=800;a8=b9+cc}cd()}function aZ(ca,b9,cb){if(!bV&&ca){aD(function(){if(br==="POST"){bG(ca,cb)}else{b8(ca,cb)}bY(b9)})}}function ba(b9){if(bV){return false}return(b9&&b9.length)}function ap(cb,b9){if(!ba(cb)){return}var ca='{"requests":["?'+cb.join('","?')+'"]}';aD(function(){bG(ca,null,false);bY(b9)})}function bE(b9){return b1+b9+"."+bR+"."+bx -}function ae(){if(ao){return"0"}if(!w(e.cookieEnabled)){var b9=bE("testcookie");bF(b9,"1");return av(b9)==="1"?"1":"0"}return e.cookieEnabled?"1":"0"}function bj(){bx=aX((aq||bL)+(b2||"/")).slice(0,4)}function ar(){var ca=bE("cvar"),b9=av(ca);if(b9.length){b9=JSON2.parse(b9);if(J(b9)){return b9}}return{}}function Z(){if(ag===false){ag=ar()}}function bQ(){var b9=new Date();bs=b9.getTime()}function Y(){var ca=new Date(),b9=Math.round(ca.getTime()/1000),cc=av(bE("id")),cb;if(cc){cb=cc.split(".");cb.unshift("0")}else{if(!a2){a2=aX((e.userAgent||"")+(e.platform||"")+JSON2.stringify(bS)+ca.getTime()+Math.random()).slice(0,16)}cb=["1",a2,b9,0,b9,"",""]}return cb}function aL(){var cd=new Date(),ca=cd.getTime(),cc=Y();var b9=parseInt(cc[2],10);var cb=(b9*1000)+aw-ca;return cb}function am(cd,ca,b9,cc,cb,cf){var ce=aL();bF(bE("id"),cd+"."+ca+"."+b9+"."+cc+"."+cb+"."+cf,ce,b2,aq)}function X(){var b9=av(bE("ref"));if(b9.length){try{b9=JSON2.parse(b9);if(J(b9)){return b9}}catch(ca){}}return["","",0,""] -}function W(){var b9=ao;ao=false;bF(bE("id"),"",-86400,b2,aq);bF(bE("ses"),"",-86400,b2,aq);bF(bE("cvar"),"",-86400,b2,aq);bF(bE("ref"),"",-86400,b2,aq);ao=b9}function bP(cd){if(!cd||!J(cd)){return}var cc=[];var cb;for(cb in cd){if(Object.prototype.hasOwnProperty.call(cd,cb)){cc.push(cb)}}var ce={};cc.sort();var b9=cc.length;var ca;for(ca=0;ca<b9;ca++){ce[cc[ca]]=cd[cc[ca]]}return ce}function aT(cb,cz,cA,cc){var cx,ca=new Date(),cj=Math.round(ca.getTime()/1000),cD,cy,ce,cp,cu,ci,cs,cf,cw,cd=1024,cF,cm,ct=ag,ck=bE("ses"),cl=bE("ref"),cG=bE("cvar"),cq=Y(),co=av(ck),cv=X(),cC=a6||b3,cg,b9;if(ao){W()}if(bV){return""}cD=cq[0];cy=cq[1];cp=cq[2];ce=cq[3];cu=cq[4];ci=cq[5];if(!w(cq[6])){cq[6]=""}cs=cq[6];if(!w(cc)){cc=""}var cn=u.characterSet||u.charset;if(!cn||cn.toLowerCase()==="utf-8"){cn=null}cg=cv[0];b9=cv[1];cf=cv[2];cw=cv[3];if(!co){var cB=az/1000;if(!ci||(cj-ci)>cB){ce++;ci=cu}if(!a4||!cg.length){for(cx in aY){if(Object.prototype.hasOwnProperty.call(aY,cx)){cg=I(cC,aY[cx]);if(cg.length){break +}function ae(){if(ao){return"0"}if(!w(e.cookieEnabled)){var b9=bE("testcookie");bF(b9,"1");return av(b9)==="1"?"1":"0"}return e.cookieEnabled?"1":"0"}function bj(){bx=aX((aq||bL)+(b2||"/")).slice(0,4)}function ar(){var ca=bE("cvar"),b9=av(ca);if(b9.length){b9=JSON2.parse(b9);if(J(b9)){return b9}}return{}}function Z(){if(ag===false){ag=ar()}}function bQ(){var b9=new Date();bs=b9.getTime()}function Y(){var ca=new Date(),b9=Math.round(ca.getTime()/1000),cc=av(bE("id")),cb;if(cc){cb=cc.split(".");cb.unshift("0")}else{if(!a2){a2=aX((e.userAgent||"")+(e.platform||"")+JSON2.stringify(bS)+ca.getTime()+Math.random()).slice(0,16)}cb=["1",a2,b9,0,b9,"",""]}return cb}function aL(){var cd=new Date(),ca=cd.getTime(),cc=Y();var b9=parseInt(cc[2],10);var cb=(b9*1000)+aw-ca;return cb}function am(cd,ca,b9,cc,cb,cf){var ce=aL();alert(cd);bF(bE("id"),cd+"."+ca+"."+b9+"."+cc+"."+cb+"."+cf,ce,b2,aq)}function X(){var b9=av(bE("ref"));if(b9.length){try{b9=JSON2.parse(b9);if(J(b9)){return b9}}catch(ca){}}return["","",0,""] +}function W(){var b9=ao;ao=false;bF(bE("id"),"",-86400,b2,aq);bF(bE("ses"),"",-86400,b2,aq);bF(bE("cvar"),"",-86400,b2,aq);bF(bE("ref"),"",-86400,b2,aq);ao=b9}function bP(cd){if(!cd||!J(cd)){return}var cc=[];var cb;for(cb in cd){if(Object.prototype.hasOwnProperty.call(cd,cb)){cc.push(cb)}}var ce={};cc.sort();var b9=cc.length;var ca;for(ca=0;ca<b9;ca++){ce[cc[ca]]=cd[cc[ca]]}return ce}function aT(cb,cz,cA,cc){var cx,ca=new Date(),cj=Math.round(ca.getTime()/1000),cD,cy,ce,cp,cu,ci,cs,cf,cw,cd=1024,cF,cm,ct=ag,ck=bE("ses"),cl=bE("ref"),cG=bE("cvar"),cq=Y(),co=av(ck),cv=X(),cC=a6||b3,cg,b9;if(ao){W()}if(bV){return""}cD=cq[0];cy=L.getVisitorId();cp=cq[2];ce=cq[3];cu=cq[4];ci=cq[5];if(!w(cq[6])){cq[6]=""}cs=cq[6];if(!w(cc)){cc=""}var cn=u.characterSet||u.charset;if(!cn||cn.toLowerCase()==="utf-8"){cn=null}cg=cv[0];b9=cv[1];cf=cv[2];cw=cv[3];if(!co){var cB=az/1000;if(!ci||(cj-ci)>cB){ce++;ci=cu}if(!a4||!cg.length){for(cx in aY){if(Object.prototype.hasOwnProperty.call(aY,cx)){cg=I(cC,aY[cx]);if(cg.length){break }}}for(cx in aP){if(Object.prototype.hasOwnProperty.call(aP,cx)){b9=I(cC,aP[cx]);if(b9.length){break}}}}cF=b(bt);cm=cw.length?b(cw):"";if(cF.length&&!bq(cF)&&(!a4||!cm.length||bq(cm))){cw=bt}if(cw.length||cg.length){cf=cj;cv=[cg,b9,cf,bX(cw.slice(0,cd))];bF(cl,JSON2.stringify(cv),a9,b2,aq)}}cb+="&idsite="+bR+"&rec=1&r="+String(Math.random()).slice(2,8)+"&h="+ca.getHours()+"&m="+ca.getMinutes()+"&s="+ca.getSeconds()+"&url="+l(bX(cC))+(bt.length?"&urlref="+l(bX(bt)):"")+((aJ&&aJ.length)?"&uid="+l(aJ):"")+"&_id="+cy+"&_idts="+cp+"&_idvc="+ce+"&_idn="+cD+(cg.length?"&_rcn="+l(cg):"")+(b9.length?"&_rck="+l(b9):"")+"&_refts="+cf+"&_viewts="+ci+(String(cs).length?"&_ects="+cs:"")+(String(cw).length?"&_ref="+l(bX(cw.slice(0,cd))):"")+(cn?"&cs="+l(cn):"")+"&send_image=0";for(cx in bS){if(Object.prototype.hasOwnProperty.call(bS,cx)){cb+="&"+cx+"="+bS[cx]}}if(cz){cb+="&data="+l(JSON2.stringify(cz))}else{if(an){cb+="&data="+l(JSON2.stringify(an))}}function ch(cH,cI){var cJ=JSON2.stringify(cH);if(cJ.length>2){return"&"+cI+"="+l(cJ) }return""}var cE=bP(bf);var cr=bP(ab);cb+=ch(cE,"cvar");cb+=ch(cr,"e_cvar");if(ag){cb+=ch(ag,"_cvar");for(cx in ct){if(Object.prototype.hasOwnProperty.call(ct,cx)){if(ag[cx][0]===""||ag[cx][1]===""){delete ag[cx]}}}if(a5){bF(cG,JSON2.stringify(ag),az,b2,aq)}}if(a1){if(aI){cb+=">_ms="+aI}else{if(f&&f.timing&&f.timing.requestStart&&f.timing.responseEnd){cb+=">_ms="+(f.timing.responseEnd-f.timing.requestStart)}}}am(cy,cp,ce,cj,ci,w(cc)&&String(cc).length?cc:cs);bF(ck,"*",az,b2,aq);cb+=O(cA);if(bn.length){cb+="&"+bn}if(q(au)){cb=au(cb)}return cb}function bI(cc,cb,cg,cd,b9,cj){var ce="idgoal=0",cf,ca=new Date(),ch=[],ci;if(String(cc).length){ce+="&ec_id="+l(cc);cf=Math.round(ca.getTime()/1000)}ce+="&revenue="+cb;if(String(cg).length){ce+="&ec_st="+cg}if(String(cd).length){ce+="&ec_tx="+cd}if(String(b9).length){ce+="&ec_sh="+b9}if(String(cj).length){ce+="&ec_dt="+cj}if(bD){for(ci in bD){if(Object.prototype.hasOwnProperty.call(bD,ci)){if(!w(bD[ci][1])){bD[ci][1]=""}if(!w(bD[ci][2])){bD[ci][2]="" }if(!w(bD[ci][3])||String(bD[ci][3]).length===0){bD[ci][3]=0}if(!w(bD[ci][4])||String(bD[ci][4]).length===0){bD[ci][4]=1}ch.push(bD[ci])}}ce+="&ec_items="+l(JSON2.stringify(ch))}ce=aT(ce,an,"ecommerce",cf);aZ(ce,bm)}function bH(b9,cd,cc,cb,ca,ce){if(String(b9).length&&w(cd)){bI(b9,cd,cc,cb,ca,ce)}}function b0(b9){if(w(b9)){bI("",b9,"","","","")}}function bd(cc,cd){var b9=new Date(),cb=aT("action_name="+l(V(cc||aS)),cd,"log");aZ(cb,bm);if(aj&&aG&&!bv){bv=true;U(u,"click",bQ);U(u,"mouseup",bQ);U(u,"mousedown",bQ);U(u,"mousemove",bQ);U(u,"mousewheel",bQ);U(G,"DOMMouseScroll",bQ);U(G,"scroll",bQ);U(u,"keypress",bQ);U(u,"keydown",bQ);U(u,"keyup",bQ);U(G,"resize",bQ);U(G,"focus",bQ);U(G,"blur",bQ);bs=b9.getTime();setTimeout(function ca(){var ce;b9=new Date();if((bs+aG)>b9.getTime()){if(aj<b9.getTime()){ce=aT("ping=1",cd,"ping");aZ(ce,bm)}setTimeout(ca,aG)}},aG)}}function aH(cb,ca){var cc,b9="(^| )(piwik[_-]"+ca;if(cb){for(cc=0;cc<cb.length;cc++){b9+="|"+cb[cc]}}b9+=")( |$)";return new RegExp(b9) @@ -42,12 +42,12 @@ if(by&&ci&&ci.type){return ci.type}if(ac(cd)){return"href"}var cf=m.buildContent }return aW(ca)}function bM(cb,b9,ca){var cc=m.buildImpressionRequestParams(cb,b9,ca);return aT(cc,null,"contentImpression")}function aV(cc,ca){if(!cc){return}var b9=m.findParentContentNode(cc);var cb=m.buildContentBlock(b9);if(!cb){return}if(!ca){ca="Unknown"}return b5(ca,cb.name,cb.piece,cb.target)}function bw(ca,cc,b9,cb){return"e_c="+l(ca)+"&e_a="+l(cc)+(w(b9)?"&e_n="+l(b9):"")+(w(cb)?"&e_v="+l(cb):"")}function al(cb,cd,b9,cc,ce){if(String(cb).length===0||String(cd).length===0){return false}var ca=aT(bw(cb,cd,b9,cc),ce,"event");aZ(ca,bm)}function aN(b9,cc,ca,cd){var cb=aT("search="+l(b9)+(cc?"&search_cat="+l(cc):"")+(w(ca)?"&search_count="+ca:""),cd,"sitesearch");aZ(cb,bm)}function bk(b9,cc,cb){var ca=aT("idgoal="+b9+(cc?"&revenue="+cc:""),cb,"goal");aZ(ca,bm)}function bN(cc,b9,cg,cf,cb){var ce=b9+"="+l(bX(cc));var ca=aR(cb,"click",cc);if(ca){ce+="&"+ca}var cd=aT(ce,cg,"link");aZ(cd,(cf?0:bm),cf)}function bU(ca,b9){if(ca!==""){return ca+b9.charAt(0).toUpperCase()+b9.slice(1)}return b9 }function aM(ce){var cd,b9,cc=["","webkit","ms","moz"],cb;if(!a0){for(b9=0;b9<cc.length;b9++){cb=cc[b9];if(Object.prototype.hasOwnProperty.call(u,bU(cb,"hidden"))){if(u[bU(cb,"visibilityState")]==="prerender"){cd=true}break}}}if(cd){U(u,cb+"visibilitychange",function ca(){u.removeEventListener(cb+"visibilitychange",ca,false);ce()});return}ce()}function aQ(b9){if(u.readyState==="complete"){b9()}else{if(G.addEventListener){G.addEventListener("load",b9)}else{if(G.attachEvent){G.attachEvent("onLoad",b9)}}}}function aA(ca){var b9=false;if(u.attachEvent){b9=u.readyState==="complete"}else{b9=u.readyState!=="loading"}if(b9){ca()}else{if(u.addEventListener){u.addEventListener("DOMContentLoaded",ca)}else{if(u.attachEvent){u.attachEvent("onreadystatechange",ca)}}}}function bC(b9){var ca=bh(b9);if(ca&&ca.type){ca.href=h(ca.href);bN(ca.href,ca.type,undefined,null,b9)}}function b7(b9){var ca,cb;b9=b9||G.event;ca=b9.which||b9.button;cb=b9.target||b9.srcElement;if(b9.type==="click"){if(cb){bC(cb)}}else{if(b9.type==="mousedown"){if((ca===1||ca===2)&&cb){bi=ca; at=cb}else{bi=at=null}}else{if(b9.type==="mouseup"){if(ca===bi&&cb===at){bC(cb)}bi=at=null}}}}function bz(ca,b9){if(b9){U(ca,"mouseup",b7,false);U(ca,"mousedown",b7,false)}else{U(ca,"click",b7,false)}}function bc(ca){if(!by){by=true;var cb,b9=aH(ai,"ignore"),cc=u.links;if(cc){for(cb=0;cb<cc.length;cb++){if(!b9.test(cc[cb].className)){bz(cc[cb],ca)}}}}}function bu(cb,cd,ce){if(ay){return true}ay=true;var cf=false;var cc,ca;function b9(){cf=true}aQ(function(){function cg(ci){setTimeout(function(){if(!ay){return}cf=false;ce.trackVisibleContentImpressions();cg(ci)},ci)}function ch(ci){setTimeout(function(){if(!ay){return}if(cf){cf=false;ce.trackVisibleContentImpressions()}ch(ci)},ci)}if(cb){cc=["scroll","resize"];for(ca=0;ca<cc.length;ca++){if(u.addEventListener){u.addEventListener(cc[ca],b9)}else{G.attachEvent("on"+cc[ca],b9)}}ch(100)}if(cd&&cd>0){cd=parseInt(cd,10);cg(cd)}})}function bZ(){var ca,cb,cc={pdf:"application/pdf",qt:"video/quicktime",realp:"audio/x-pn-realaudio-plugin",wma:"application/x-mplayer2",dir:"application/x-director",fla:"application/x-shockwave-flash",java:"application/x-java-vm",gears:"application/x-googlegears",ag:"application/x-silverlight"},b9=(new RegExp("Mac OS X.*Safari/")).test(e.userAgent)?G.devicePixelRatio||1:1; -if(!((new RegExp("MSIE")).test(e.userAgent))){if(e.mimeTypes&&e.mimeTypes.length){for(ca in cc){if(Object.prototype.hasOwnProperty.call(cc,ca)){cb=e.mimeTypes[cc[ca]];bS[ca]=(cb&&cb.enabledPlugin)?"1":"0"}}}if(typeof navigator.javaEnabled!=="unknown"&&w(e.javaEnabled)&&e.javaEnabled()){bS.java="1"}if(q(G.GearsFactory)){bS.gears="1"}bS.cookie=ae()}bS.res=K.width*b9+"x"+K.height*b9}bZ();bj();return{getVisitorId:function(){return(Y())[1]},getVisitorInfo:function(){return Y()},getAttributionInfo:function(){return X()},getAttributionCampaignName:function(){return X()[0]},getAttributionCampaignKeyword:function(){return X()[1]},getAttributionReferrerTimestamp:function(){return X()[2]},getAttributionReferrerUrl:function(){return X()[3]},setTrackerUrl:function(b9){aa=b9},setSiteId:function(b9){bR=b9},setUserId:function(b9){aJ=b9},getUserId:function(){return aJ},setCustomData:function(b9,ca){if(J(b9)){an=b9}else{if(!an){an={}}an[b9]=ca}},getCustomData:function(){return an},setCustomRequestProcessing:function(b9){au=b9 -},appendToTrackingUrl:function(b9){bn=b9},getRequest:function(b9){return aT(b9)},addPlugin:function(b9,ca){a[b9]=ca},setCustomVariable:function(ca,b9,cd,cb){var cc;if(!w(cb)){cb="visit"}if(!w(b9)){return}if(!w(cd)){cd=""}if(ca>0){b9=!n(b9)?String(b9):b9;cd=!n(cd)?String(cd):cd;cc=[b9.slice(0,bW),cd.slice(0,bW)];if(cb==="visit"||cb===2){Z();ag[ca]=cc}else{if(cb==="page"||cb===3){bf[ca]=cc}else{if(cb==="event"){ab[ca]=cc}}}}},getCustomVariable:function(ca,cb){var b9;if(!w(cb)){cb="visit"}if(cb==="page"||cb===3){b9=bf[ca]}else{if(cb==="event"){b9=ab[ca]}else{if(cb==="visit"||cb===2){Z();b9=ag[ca]}}}if(!w(b9)||(b9&&b9[0]==="")){return false}return b9},deleteCustomVariable:function(b9,ca){if(this.getCustomVariable(b9,ca)){this.setCustomVariable(b9,"","",ca)}},storeCustomVariablesInCookie:function(){a5=true},setLinkTrackingTimer:function(b9){bm=b9},setDownloadExtensions:function(b9){aU=b9},addDownloadExtensions:function(b9){aU+="|"+b9},setDomains:function(b9){bo=n(b9)?[b9]:b9;bo.push(bL)},setIgnoreClasses:function(b9){ai=n(b9)?[b9]:b9 -},setRequestMethod:function(b9){br=b9||bp},setRequestContentType:function(b9){aK=b9||bb},setReferrerUrl:function(b9){bt=b9},setCustomUrl:function(b9){a6=bK(b3,b9)},setDocumentTitle:function(b9){aS=b9},setAPIUrl:function(b9){ax=b9},setDownloadClasses:function(b9){be=n(b9)?[b9]:b9},setLinkClasses:function(b9){aC=n(b9)?[b9]:b9},setCampaignNameKey:function(b9){aY=n(b9)?[b9]:b9},setCampaignKeywordKey:function(b9){aP=n(b9)?[b9]:b9},discardHashTag:function(b9){ak=b9},setCookieNamePrefix:function(b9){b1=b9;ag=ar()},setCookieDomain:function(b9){aq=y(b9);bj()},setCookiePath:function(b9){b2=b9;bj()},setVisitorCookieTimeout:function(b9){aw=b9*1000},setSessionCookieTimeout:function(b9){az=b9*1000},setReferralCookieTimeout:function(b9){a9=b9*1000},setConversionAttributionFirstReferrer:function(b9){a4=b9},disableCookies:function(){ao=true;bS.cookie="0"},deleteCookies:function(){W()},setDoNotTrack:function(ca){var b9=e.doNotTrack||e.msDoNotTrack;bV=ca&&(b9==="yes"||b9==="1");if(bV){this.disableCookies() -}},addListener:function(ca,b9){bz(ca,b9)},enableLinkTracking:function(b9){bT=true;if(p){bc(b9)}else{E.push(function(){bc(b9)})}},enableJSErrorTracking:function(){if(b6){return}b6=true;var b9=G.onerror;G.onerror=function(ce,cc,cb,cd,ca){aM(function(){var cf="JavaScript Errors";var cg=cc+":"+cb;if(cd){cg+=":"+cd}al(cf,cg,ce)});if(b9){return b9(ce,cc,cb,cd,ca)}return false}},disablePerformanceTracking:function(){a1=false},setGenerationTimeMs:function(b9){aI=parseInt(b9,10)},setHeartBeatTimer:function(cb,ca){var b9=new Date();aj=b9.getTime()+cb*1000;aG=ca*1000},killFrame:function(){if(G.location!==G.top.location){G.top.location=G.location}},redirectFile:function(b9){if(G.location.protocol==="file:"){G.location=b9}},setCountPreRendered:function(b9){a0=b9},trackGoal:function(b9,cb,ca){aM(function(){bk(b9,cb,ca)})},trackLink:function(ca,b9,cc,cb){aM(function(){bN(ca,b9,cc,cb)})},trackPageView:function(b9,ca){ah=[];if(A(bR)){aM(function(){M(aa,ax,bR)})}else{aM(function(){bd(b9,ca)})}},trackAllContentImpressions:function(){if(A(bR)){return -}aM(function(){aA(function(){var b9=m.findContentNodes();var ca=aW(b9);ap(ca,bm)})})},trackVisibleContentImpressions:function(b9,ca){if(A(bR)){return}if(!w(b9)){b9=true}if(!w(ca)){ca=750}bu(b9,ca,this);aM(function(){aQ(function(){var cb=m.findContentNodes();var cc=bA(cb);ap(cc,bm)})})},trackContentImpression:function(cb,b9,ca){if(A(bR)){return}if(!cb){return}b9=b9||"Unknown";aM(function(){var cc=bM(cb,b9,ca);aZ(cc,bm)})},trackContentImpressionsWithinNode:function(b9){if(A(bR)||!b9){return}aM(function(){if(ay){aQ(function(){var ca=m.findContentNodesWithinNode(b9);var cb=bA(ca);ap(cb,bm)})}else{aA(function(){var ca=m.findContentNodesWithinNode(b9);var cb=aW(ca);ap(cb,bm)})}})},trackContentInteraction:function(cb,cc,b9,ca){if(A(bR)){return}if(!cb||!cc){return}b9=b9||"Unknown";aM(function(){var cd=b5(cb,cc,b9,ca);aZ(cd,bm)})},trackContentInteractionNode:function(ca,b9){if(A(bR)||!ca){return}aM(function(){var cb=aV(ca,b9);aZ(cb,bm)})},trackEvent:function(ca,cc,b9,cb){aM(function(){al(ca,cc,b9,cb) -})},trackSiteSearch:function(b9,cb,ca){aM(function(){aN(b9,cb,ca)})},setEcommerceView:function(cc,b9,cb,ca){if(!w(cb)||!cb.length){cb=""}else{if(cb instanceof Array){cb=JSON2.stringify(cb)}}bf[5]=["_pkc",cb];if(w(ca)&&String(ca).length){bf[2]=["_pkp",ca]}if((!w(cc)||!cc.length)&&(!w(b9)||!b9.length)){return}if(w(cc)&&cc.length){bf[3]=["_pks",cc]}if(!w(b9)||!b9.length){b9=""}bf[4]=["_pkn",b9]},addEcommerceItem:function(cd,b9,cb,ca,cc){if(cd.length){bD[cd]=[cd,b9,cb,ca,cc]}},trackEcommerceOrder:function(b9,cd,cc,cb,ca,ce){bH(b9,cd,cc,cb,ca,ce)},trackEcommerceCartUpdate:function(b9){b0(b9)}}}function v(){return{push:R}}U(G,"beforeunload",S,false);o();Date.prototype.getTimeAlias=Date.prototype.getTime;L=new D();var r={setTrackerUrl:1,setAPIUrl:1,setUserId:1,setSiteId:1,disableCookies:1,enableLinkTracking:1};var d;for(t=0;t<_paq.length;t++){d=_paq[t][0];if(r[d]){R(_paq[t]);delete _paq[t];if(r[d]>1){if(console!==undefined&&console&&console.error){console.error("The method "+d+' is registered more than once in "_paq" variable. Only the last call has an effect. Please have a look at the multiple Piwik trackers documentation: http://developer.piwik.org/api-reference/tracking-javascript#multiple-piwik-trackers') +if(!((new RegExp("MSIE")).test(e.userAgent))){if(e.mimeTypes&&e.mimeTypes.length){for(ca in cc){if(Object.prototype.hasOwnProperty.call(cc,ca)){cb=e.mimeTypes[cc[ca]];bS[ca]=(cb&&cb.enabledPlugin)?"1":"0"}}}if(typeof navigator.javaEnabled!=="unknown"&&w(e.javaEnabled)&&e.javaEnabled()){bS.java="1"}if(q(G.GearsFactory)){bS.gears="1"}bS.cookie=ae()}bS.res=K.width*b9+"x"+K.height*b9}bZ();bj();return{getVisitorId:function(){alert("getVisitorId for: "+aJ);return aJ.length?T(aJ).substr(0,16):(Y())[1]},getVisitorInfo:function(){return Y()},getAttributionInfo:function(){return X()},getAttributionCampaignName:function(){return X()[0]},getAttributionCampaignKeyword:function(){return X()[1]},getAttributionReferrerTimestamp:function(){return X()[2]},getAttributionReferrerUrl:function(){return X()[3]},setTrackerUrl:function(b9){aa=b9},setSiteId:function(b9){bR=b9},setUserId:function(b9){aJ=b9},getUserId:function(){return aJ},setCustomData:function(b9,ca){if(J(b9)){an=b9}else{if(!an){an={}}an[b9]=ca}},getCustomData:function(){return an +},setCustomRequestProcessing:function(b9){au=b9},appendToTrackingUrl:function(b9){bn=b9},getRequest:function(b9){return aT(b9)},addPlugin:function(b9,ca){a[b9]=ca},setCustomVariable:function(ca,b9,cd,cb){var cc;if(!w(cb)){cb="visit"}if(!w(b9)){return}if(!w(cd)){cd=""}if(ca>0){b9=!n(b9)?String(b9):b9;cd=!n(cd)?String(cd):cd;cc=[b9.slice(0,bW),cd.slice(0,bW)];if(cb==="visit"||cb===2){Z();ag[ca]=cc}else{if(cb==="page"||cb===3){bf[ca]=cc}else{if(cb==="event"){ab[ca]=cc}}}}},getCustomVariable:function(ca,cb){var b9;if(!w(cb)){cb="visit"}if(cb==="page"||cb===3){b9=bf[ca]}else{if(cb==="event"){b9=ab[ca]}else{if(cb==="visit"||cb===2){Z();b9=ag[ca]}}}if(!w(b9)||(b9&&b9[0]==="")){return false}return b9},deleteCustomVariable:function(b9,ca){if(this.getCustomVariable(b9,ca)){this.setCustomVariable(b9,"","",ca)}},storeCustomVariablesInCookie:function(){a5=true},setLinkTrackingTimer:function(b9){bm=b9},setDownloadExtensions:function(b9){aU=b9},addDownloadExtensions:function(b9){aU+="|"+b9},setDomains:function(b9){bo=n(b9)?[b9]:b9; +bo.push(bL)},setIgnoreClasses:function(b9){ai=n(b9)?[b9]:b9},setRequestMethod:function(b9){br=b9||bp},setRequestContentType:function(b9){aK=b9||bb},setReferrerUrl:function(b9){bt=b9},setCustomUrl:function(b9){a6=bK(b3,b9)},setDocumentTitle:function(b9){aS=b9},setAPIUrl:function(b9){ax=b9},setDownloadClasses:function(b9){be=n(b9)?[b9]:b9},setLinkClasses:function(b9){aC=n(b9)?[b9]:b9},setCampaignNameKey:function(b9){aY=n(b9)?[b9]:b9},setCampaignKeywordKey:function(b9){aP=n(b9)?[b9]:b9},discardHashTag:function(b9){ak=b9},setCookieNamePrefix:function(b9){b1=b9;ag=ar()},setCookieDomain:function(b9){aq=y(b9);bj()},setCookiePath:function(b9){b2=b9;bj()},setVisitorCookieTimeout:function(b9){aw=b9*1000},setSessionCookieTimeout:function(b9){az=b9*1000},setReferralCookieTimeout:function(b9){a9=b9*1000},setConversionAttributionFirstReferrer:function(b9){a4=b9},disableCookies:function(){ao=true;bS.cookie="0"},deleteCookies:function(){W()},setDoNotTrack:function(ca){var b9=e.doNotTrack||e.msDoNotTrack; +bV=ca&&(b9==="yes"||b9==="1");if(bV){this.disableCookies()}},addListener:function(ca,b9){bz(ca,b9)},enableLinkTracking:function(b9){bT=true;if(p){bc(b9)}else{E.push(function(){bc(b9)})}},enableJSErrorTracking:function(){if(b6){return}b6=true;var b9=G.onerror;G.onerror=function(ce,cc,cb,cd,ca){aM(function(){var cf="JavaScript Errors";var cg=cc+":"+cb;if(cd){cg+=":"+cd}al(cf,cg,ce)});if(b9){return b9(ce,cc,cb,cd,ca)}return false}},disablePerformanceTracking:function(){a1=false},setGenerationTimeMs:function(b9){aI=parseInt(b9,10)},setHeartBeatTimer:function(cb,ca){var b9=new Date();aj=b9.getTime()+cb*1000;aG=ca*1000},killFrame:function(){if(G.location!==G.top.location){G.top.location=G.location}},redirectFile:function(b9){if(G.location.protocol==="file:"){G.location=b9}},setCountPreRendered:function(b9){a0=b9},trackGoal:function(b9,cb,ca){aM(function(){bk(b9,cb,ca)})},trackLink:function(ca,b9,cc,cb){aM(function(){bN(ca,b9,cc,cb)})},trackPageView:function(b9,ca){ah=[];if(A(bR)){aM(function(){M(aa,ax,bR) +})}else{aM(function(){bd(b9,ca)})}},trackAllContentImpressions:function(){if(A(bR)){return}aM(function(){aA(function(){var b9=m.findContentNodes();var ca=aW(b9);ap(ca,bm)})})},trackVisibleContentImpressions:function(b9,ca){if(A(bR)){return}if(!w(b9)){b9=true}if(!w(ca)){ca=750}bu(b9,ca,this);aM(function(){aQ(function(){var cb=m.findContentNodes();var cc=bA(cb);ap(cc,bm)})})},trackContentImpression:function(cb,b9,ca){if(A(bR)){return}if(!cb){return}b9=b9||"Unknown";aM(function(){var cc=bM(cb,b9,ca);aZ(cc,bm)})},trackContentImpressionsWithinNode:function(b9){if(A(bR)||!b9){return}aM(function(){if(ay){aQ(function(){var ca=m.findContentNodesWithinNode(b9);var cb=bA(ca);ap(cb,bm)})}else{aA(function(){var ca=m.findContentNodesWithinNode(b9);var cb=aW(ca);ap(cb,bm)})}})},trackContentInteraction:function(cb,cc,b9,ca){if(A(bR)){return}if(!cb||!cc){return}b9=b9||"Unknown";aM(function(){var cd=b5(cb,cc,b9,ca);aZ(cd,bm)})},trackContentInteractionNode:function(ca,b9){if(A(bR)||!ca){return}aM(function(){var cb=aV(ca,b9); +aZ(cb,bm)})},trackEvent:function(ca,cc,b9,cb){aM(function(){al(ca,cc,b9,cb)})},trackSiteSearch:function(b9,cb,ca){aM(function(){aN(b9,cb,ca)})},setEcommerceView:function(cc,b9,cb,ca){if(!w(cb)||!cb.length){cb=""}else{if(cb instanceof Array){cb=JSON2.stringify(cb)}}bf[5]=["_pkc",cb];if(w(ca)&&String(ca).length){bf[2]=["_pkp",ca]}if((!w(cc)||!cc.length)&&(!w(b9)||!b9.length)){return}if(w(cc)&&cc.length){bf[3]=["_pks",cc]}if(!w(b9)||!b9.length){b9=""}bf[4]=["_pkn",b9]},addEcommerceItem:function(cd,b9,cb,ca,cc){if(cd.length){bD[cd]=[cd,b9,cb,ca,cc]}},trackEcommerceOrder:function(b9,cd,cc,cb,ca,ce){bH(b9,cd,cc,cb,ca,ce)},trackEcommerceCartUpdate:function(b9){b0(b9)}}}function v(){return{push:R}}U(G,"beforeunload",S,false);o();Date.prototype.getTimeAlias=Date.prototype.getTime;L=new D();var r={setTrackerUrl:1,setAPIUrl:1,setUserId:1,setSiteId:1,disableCookies:1,enableLinkTracking:1};var d;for(t=0;t<_paq.length;t++){d=_paq[t][0];if(r[d]){R(_paq[t]);delete _paq[t];if(r[d]>1){if(console!==undefined&&console&&console.error){console.error("The method "+d+' is registered more than once in "_paq" variable. Only the last call has an effect. Please have a look at the multiple Piwik trackers documentation: http://developer.piwik.org/api-reference/tracking-javascript#multiple-piwik-trackers') }}r[d]++}}for(t=0;t<_paq.length;t++){if(_paq[t]){R(_paq[t])}}_paq=new v();c={addPlugin:function(W,X){a[W]=X},getTracker:function(W,X){return new D(W,X,L.getVisitorId())},getAsyncTracker:function(){return L}};if(typeof define==="function"&&define.amd){define("piwik",[],function(){return c})}return c}())}if(window&&window.piwikAsyncInit){window.piwikAsyncInit()}(function(){var a=(typeof AnalyticsTracker);if(a==="undefined"){AnalyticsTracker=Piwik}}());if(typeof piwik_log!=="function"){piwik_log=function(b,f,d,g){function a(h){try{return eval("piwik_"+h)}catch(i){}return}var c,e=Piwik.getTracker(d,f);e.setDocumentTitle(b);e.setCustomData(g);c=a("tracker_pause");if(c){e.setLinkTrackingTimer(c)}c=a("download_extensions");if(c){e.setDownloadExtensions(c)}c=a("hosts_alias");if(c){e.setDomains(c)}c=a("ignore_classes");if(c){e.setIgnoreClasses(c)}e.trackPageView();if(a("install_tracker")){piwik_track=function(i,k,j,h){e.setSiteId(k);e.setTrackerUrl(j);e.trackLink(i,h)};e.enableLinkTracking() }}; /*! @license-end */ diff --git a/tests/javascript/index.php b/tests/javascript/index.php index a23a521c74..5e8570b620 100644 --- a/tests/javascript/index.php +++ b/tests/javascript/index.php @@ -2586,7 +2586,7 @@ if ($sqlite) { }); test("tracking", function() { - expect(103); + expect(106); /* * Prevent Opera and HtmlUnit from performing the default action (i.e., load the href URL) @@ -2826,8 +2826,14 @@ if ($sqlite) { // User ID var userIdString = 'userid@mydomain.org'; - tracker3.setUserId(userIdString); + // Visitor ID is not yet the User id + notEqual(tracker.hook.test._sha1(userIdString).substr(0, 16), tracker3.getVisitorId()); + notEqual("s", tracker3.getVisitorId()); + ok( tracker3.getVisitorId().length === 16, "Visitor ID is 16 chars string"); + + // Set User ID and verify it was set + tracker3.setUserId(userIdString); equal(userIdString, tracker3.getUserId()); equal(tracker.hook.test._sha1(userIdString).substr(0, 16), tracker3.getVisitorId()); |