You are on page 1of 3

// Copyright 2010 Google Inc. // // Licensed under the Apache License, Version 2.

0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // See the source code here: // http://code.google.com/p/episodes/ // Don't overwrite pre-existing instances of the object (esp. for older browsers ). var NR_QUEUE=[];typeof window.NREUMQ!="undefined"?NR_QUEUE=NREUMQ:typeof window. EPISODES!="undefined"?NR_QUEUE=EPISODES.q:typeof window.NREUM!="undefined"&&(NR_ QUEUE=NREUM.q);var NREUM=NREUM||{};NREUM.q=NR_QUEUE,NREUM.targetOrigin=document. location.protocol+"//"+document.location.host,NREUM.version=38,NREUM.autorun="un defined"!=typeof NREUM.autorun?NREUM.autorun:!0,NREUM.init=function(){NREUM.data Sent=!1,NREUM.jsonp=!1,NREUM.beaconToken=null,NREUM.navCookie=!0,NREUM.bDone=!1, NREUM.cycle=0,NREUM.logging=!1,NREUM.contentLoadFired=!1,NREUM.marks={},NREUM.me asures={},NREUM.starts={},NREUM.performance=null,NREUM.findStartTime(),NREUM.loa d=null,NREUM.addEventListener("beforeunload",NREUM.beforeUnload,!1),NREUM.addEve ntListener("pagehide",NREUM.beforeUnload,!1),NREUM.processQ(),NREUM.beacon=null, NREUM.licenseKey=null,NREUM.applicationID=null,NREUM.transactionName=null,NREUM. agentToken=null,NREUM.txnParam=null,NREUM.unloaded=!1,document.readyState==="com plete"?NREUM.domContentLoaded():"undefined"!=typeof document.addEventListener?do cument.addEventListener("DOMContentLoaded",NREUM.domContentLoaded,!1):"undefined "!=typeof document.attachEvent&&document.attachEvent("onreadystatechange",NREUM. readyStateChange),NREUM.load||document.loaded?NREUM.onload():NREUM.addEventListe ner("load",NREUM.onload,!1)},NREUM.processQ=function(){var a=NREUM.q.length,b,c, d;for(d=0;d<a;d++){b=NREUM.q[d],c=null;switch(b[0]){case"mark":NREUM.mark(b[1],b [2]);break;case"measure":NREUM.measure(b[1],b[2],b[3]);break;case"done":NREUM.do ne(b[1]);break;case"nrf":case"nrfinish":c="t";break;case"nrf2":case"nrfinish2":c ="to";break;case"nrfj":c="to",NREUM.jsonp=parent==self;break;case"load":NREUM.lo ad=b[1];break;default:NREUM.dprint("Unknown queue command "+b[0])}c&&NREUM.nrfin ish(c,b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8],b[9],b[10],b[11],b[12])}},NREUM.nr finish=function(a,b,c,d,e,f,g,h,i,j,k,l,m){NREUM.dprint("NREUM: finish data rece ived"),NREUM.txnParam=a,NREUM.beacon=b,NREUM.licenseKey=c,NREUM.applicationID=d, NREUM.transactionName=e,NREUM.tt_guid=i,NREUM.user=k,NREUM.account=l,NREUM.produ ct=m,NREUM.measures.qt=f,NREUM.measures.ap=g,NREUM.dom_end_time=h,NREUM.agentTok en=j},NREUM.mark=function(a,b){NREUM.dprint("NREUM.mark: "+a+", "+b);a?(NREUM.ma rks[a]=parseInt(b||(new Date).getTime(),10),"firstbyte"===a?(NREUM.measure("be", "starttime","firstbyte"),NREUM.dom_start_time=NREUM.marks.firstbyte):"onload"=== a?NREUM.measure("fe","firstbyte","onload"):"domContent"===a&&NREUM.measure("dc", "firstbyte","domContent")):NREUM.dprint("Error: markName is undefined in NREUM.m ark.")},NREUM.measure=function(a,b,c){NREUM.dprint("NREUM.measure: "+a+", "+b+", "+c);if(!a)NREUM.dprint("Error: episodeName is undefined in NREUM.measure.");el se{var d;if("undefined"==typeof b)"number"==typeof NREUM.marks[a]?d=NREUM.marks[ a]:d=(new Date).getTime();else if("number"==typeof NREUM.marks[b])d=NREUM.marks[ b];else if("number"==typeof b)d=b;else{NREUM.dprint("Error: unexpected startName OrTime in NREUM.measure: "+b);return}var e;if("undefined"==typeof c)e=(new Date) .getTime();else if("number"==typeof NREUM.marks[c])e=NREUM.marks[c];else if("num ber"==typeof c)e=c;else{NREUM.dprint("NREUM: Error: unexpected endNameOrTime in NREUM.measure: "+c);return}NREUM.starts[a]=parseInt(d,10),NREUM.measures[a]=pars eInt(e-d,10)}},NREUM.done=function(a){NREUM.bDone||(NREUM.bDone=!0,NREUM.mark("d

one"),NREUM.autorun&&NREUM.sendBeacon(),"function"==typeof a&&a())},NREUM.getMar ks=function(){return NREUM.marks},NREUM.getMeasures=function(){return NREUM.meas ures},NREUM.getStarts=function(){return NREUM.starts},NREUM.sendBeacon=function( ){if(!NREUM.dataSent){NREUM.dataSent=!0,NREUM.processQ(),NREUM.domContentLoaded( );if(NREUM.licenseKey===null||NREUM.applicationID===null){NREUM.dprint("NREUM: l icenseKey or applicationID has not been set");return}NREUM.dom_end_time&&NREUM.d om_start_time&&(NREUM.dprint("NREUM: picking up DOM processing time from embedde d JS"),NREUM.mark("domContent",NREUM.dom_end_time)),NREUM.load&&(NREUM.dprint("N REUM: picking up load event time from embedded JS"),NREUM.mark("onload",NREUM.lo ad));var a=NREUM.getMeasures(),b="",c;for(c in a)b+="&"+c+"="+a[c];var d;if(b){v ar e="1";d=("http:"===document.location.protocol?"http:":"https:")+"//"+NREUM.be acon+"/"+e+"/"+NREUM.licenseKey,d+="?a="+NREUM.applicationID,d+=b,d+=NREUM.getPa ram(NREUM.txnParam,NREUM.transactionName),d+=NREUM.getParam("tt",NREUM.tt_guid), d+=NREUM.getParam("us",NREUM.user),d+=NREUM.getParam("ac",NREUM.account),d+=NREU M.getParam("pr",NREUM.product),d+=NREUM.getParam("tk",NREUM.agentToken),d+="&v=" +NREUM.version,NREUM.jsonp&&(d+="&jsonp=NREUM.setToken");if(NREUM.performance){v ar f={};f.timing=NREUM.addPT(NREUM.performance.timing,{}),f.navigation=NREUM.add PN(NREUM.performance.navigation,{}),d+=NREUM.getParam("perf",NREUM.stringify(f)) }if(NREUM.jsonp){var g=document.createElement("script");g.id="nreum-send-beacon" ,g.type="text/javascript",g.src=d,document.body.appendChild(g)}else{var h=new Im age;h.src=d}NREUM.dprint("NREUM: (new) data sent",d)}}},NREUM.getParam=function( a,b){if(b!=null&&b.length>0)return"&"+a+"="+encodeURIComponent(b);return""},NREU M.addPT=function(a,b){var c=a.navigationStart;b.of=c,NREUM.addRel(a.navigationSt art,c,b,"n"),NREUM.addRel(a.unloadEventStart,c,b,"u"),NREUM.addRel(a.unloadEvent End,c,b,"ue"),NREUM.addRel(a.domLoading,c,b,"dl"),NREUM.addRel(a.domInteractive, c,b,"di"),NREUM.addRel(a.domContentLoadedEventStart,c,b,"ds"),NREUM.addRel(a.dom ContentLoadedEventEnd,c,b,"de"),NREUM.addRel(a.domComplete,c,b,"dc"),NREUM.addRe l(a.loadEventStart,c,b,"l"),NREUM.addRel(a.loadEventEnd,c,b,"le"),NREUM.addRT(a, b,c);return b},NREUM.addPN=function(a,b){NREUM.addRel(a.type,0,b,"ty"),NREUM.add Rel(a.redirectCount,0,b,"rc");return b},NREUM.addRT=function(a,b,c){var d;c?d=c: (d=a.startTime,b.of=d),NREUM.addRel(a.redirectStart,d,b,"r"),NREUM.addRel(a.redi rectEnd,d,b,"re"),NREUM.addRel(a.fetchStart,d,b,"f"),NREUM.addRel(a.domainLookup Start,d,b,"dn"),NREUM.addRel(a.domainLookupEnd,d,b,"dne"),NREUM.addRel(a.connect Start,d,b,"c"),NREUM.addRel(a.connectEnd,d,b,"ce"),NREUM.addRel(a.secureConnecti onStart,d,b,"s"),NREUM.addRel(a.requestStart,d,b,"rq"),NREUM.addRel(a.responseSt art,d,b,"rp"),NREUM.addRel(a.responseEnd,d,b,"rpe"),c||(b.n=a.name,b.st=a.startT ime-d,b.it=a.initiatorType,b.du=a.duration);return b},NREUM.addRel=function(a,b, c,d){"number"==typeof a&&a>0&&(c[d]=a-b)},NREUM.setToken=function(a){NREUM.dprin t("NREUM: trace "+a),NREUM.beaconToken=a},NREUM.inlineHit=function(a,b,c,d,e,f){ NREUM.cycle+=1;if(NREUM.licenseKey===null||NREUM.applicationID===null)NREUM.dpri nt("NREUM: licenseKey or applicationID has not been set");else{var g=new Image,h =("http:"===document.location.protocol?"http:":"https:")+"//"+NREUM.beacon+"/1/" +NREUM.licenseKey;h+="?a="+NREUM.applicationID+"&",h+="t="+a+"&",h+="qt="+b+"&", h+="ap="+c+"&",h+="be="+d+"&",h+="dc="+e+"&",h+="fe="+f+"&",h+="c="+NREUM.cycle, g.src=h,NREUM.dprint("NREUM Inline: "+h)}},NREUM.findStartTime=function(){var a= NREUM.findStartWebTiming()||NREUM.findStartGToolbar()||NREUM.findStartCookie();a ?NREUM.mark("starttime",a):NREUM.dprint("NREUM: Error: couldn't find a start tim e")},NREUM.findStartWebTiming=function(){var a;if(/Firefox[\/\s](\d+\.\d+)/.test (navigator.userAgent)){var b=new Number(RegExp.$1);if(b<9)return a}var c=window. performance||window.mozPerformance||window.msPerformance||window.webkitPerforman ce;"undefined"!=typeof c&&"undefined"!=typeof c.timing&&"undefined"!=typeof c.ti ming.navigationStart&&(a=c.timing.navigationStart,NREUM.performance=c,NREUM.dpri nt("NREUM.findStartWebTiming: startTime = "+a)),a&&(NREUM.navCookie=!1);return a },NREUM.findStartGToolbar=function(){var a,b;try{window.external&&window.externa l.pageT?a=window.external.pageT:window.gtbExternal&&window.gtbExternal.pageT?a=w indow.gtbExternal.pageT():window.chrome&&window.chrome.csi&&(a=window.chrome.csi ().pageT),a&&a<6e4&&(b=(new Date).getTime()-a,NREUM.dprint("NREUM.findStartGTool bar: startTime = "+b))}catch(c){}b&&(NREUM.navCookie=!1);return b},NREUM.findSta rtCookie=function(){var a=document.cookie.split(" "),b,c;for(b=0;b<a.length;b++) if(0===a[b].indexOf("NREUM=")){var d,e,f=a[b].substring("NREUM=".length).split("

&"),g,h;for(c=0;c<f.length;c++)0===f[c].indexOf("s=")?g=f[c].substring(2):0===f[ c].indexOf("h=")?(g=f[c].substring(2),NREUM.measure("ph",0,1)):0===f[c].indexOf( "p=")?(e=f[c].substring(2),e.charAt(e.length-1)===";"&&(e=e.substr(0,e.length-1) )):0===f[c].indexOf("r=")&&(d=f[c].substring(2),d.charAt(d.length-1)===";"&&(d=d .substr(0,d.length-1)));if(d){var i=NREUM.sHash(document.referrer);h=i==d,h||(h= NREUM.sHash(document.location.href)==d&&i==e)}if(h&&g){var j=(new Date).getTime( );if(j-g>6e4){NREUM.dprint("NREUM.findStartCookie: startTime > 60s old - ignored ");return undefined}NREUM.dprint("NREUM.findStartCookie: startTime = "+g);return g}}return undefined},NREUM.beforeUnload=function(a){if(!NREUM.unloaded){var b=" s";a.type==="pagehide"&&(b="h"),NREUM.navCookie&&(document.cookie="NREUM="+b+"=" +Number(new Date)+"&r="+NREUM.sHash(document.location.href)+"&p="+NREUM.sHash(do cument.referrer)+"; path=/"),NREUM.beaconToken&&(document.cookie="NRAGENT=tk="+N REUM.beaconToken+"; max-age=1; path=/"),NREUM.unloaded=!0}},NREUM.onload=functio n(a){NREUM.mark("onload"),NREUM.autorun&&NREUM.done()},NREUM.domContentLoaded=fu nction(a){NREUM.contentLoadFired||(NREUM.mark("domContent",(new Date).getTime()) ,NREUM.contentLoadFired=!0)},NREUM.readyStateChange=function(a){document.readySt ate==="complete"&&NREUM.domContentLoaded()},NREUM.addEventListener=function(a,b, c){if("undefined"!=typeof window.attachEvent)return window.attachEvent("on"+a,b) ;if(window.addEventListener)return window.addEventListener(a,b,c)},NREUM.sHash=f unction(a){var b,c=0;for(b=0;b<a.length;b++)c+=(b+1)*a.charCodeAt(b);return Math .abs(c)},NREUM.stringify=function(a){var b=typeof a;switch(b){case"string":retur n'"'+a+'"';case"boolean":case"number":return String(a);case"object":if(a===null) return"null";var c=!1,d="";for(prop in a){var e=String(prop),f=NREUM.stringify(a [prop]);f.length>0&&(c?d+=", ":c=!0,d+='"'+e+'":'+f)}return a instanceof Array?" ["+d+"]":"{"+d+"}";default:return""}},"undefined"!=typeof console&&"undefined"!= typeof console.log?NREUM.dprint=function(a){NREUM.logging&&console.log(a)}:NREUM .dprint=function(a){},NREUM.init()

You might also like