Comparing version 0.2.2 to 0.2.3
18
bucky.js
@@ -15,3 +15,2 @@ (function() { | ||
} else { | ||
XMLHttpRequest = window.XMLHttpRequest; | ||
now = function() { | ||
@@ -56,3 +55,3 @@ var _ref, _ref1; | ||
exportDef = function() { | ||
var $tag, ACTIVE, HISTORY, TYPE_MAP, client, considerSending, currentLatency, defaults, enqueue, flush, key, latencySent, makeClient, makeRequest, maxTimeout, options, queue, round, sendQueue, sendTimeout, setOptions, tagOptions, updateActive, updateLatency, _i, _len, _ref, _ref1, _ref2; | ||
var $tag, ACTIVE, HISTORY, TYPE_MAP, client, considerSending, defaults, enqueue, flush, key, latencySent, makeClient, makeRequest, maxTimeout, options, queue, round, sendQueue, sendTimeout, setOptions, tagOptions, updateActive, updateLatency, _i, _len, _ref, _ref1, _ref2; | ||
defaults = { | ||
@@ -151,4 +150,4 @@ host: '/bucky', | ||
makeRequest = function(data) { | ||
var body, corsSupport, match, name, origin, req, sameOrigin, sendStart, val; | ||
corsSupport = isServer || (XMLHttpRequest && (XMLHttpRequest.defake || 'withCredentials' in new XMLHttpRequest())); | ||
var body, corsSupport, match, name, origin, req, sameOrigin, sendStart, val, _ref3; | ||
corsSupport = isServer || (window.XMLHttpRequest && (window.XMLHttpRequest.defake || 'withCredentials' in new window.XMLHttpRequest())); | ||
if (isServer) { | ||
@@ -178,3 +177,3 @@ sameOrigin = true; | ||
} else { | ||
req = new XMLHttpRequest; | ||
req = new ((_ref3 = typeof window !== "undefined" && window !== null ? window.XMLHttpRequest : void 0) != null ? _ref3 : XMLHttpRequest); | ||
} | ||
@@ -223,6 +222,5 @@ req.bucky = { | ||
}; | ||
currentLatency = 0; | ||
latencySent = false; | ||
updateLatency = function(time) { | ||
currentLatency = time; | ||
Bucky.latency = time; | ||
if (options.sendLatency && !latencySent) { | ||
@@ -386,3 +384,2 @@ enqueue('bucky.latency', time, 'timer'); | ||
path = requests.urlToKey(document.location.toString()) + '.page'; | ||
console.log(path); | ||
} | ||
@@ -469,3 +466,2 @@ if ((_ref4 = document.readyState) === 'uninitialized' || _ref4 === 'loading') { | ||
var host, mapping, mappingName, parsedUrl, path, stat, _j, _len1, _ref3, _ref4; | ||
console.log(url); | ||
url = url.replace(/https?:\/\//i, ''); | ||
@@ -475,3 +471,2 @@ parsedUrl = /([^/:]*)(?::\d+)?(\/[^\?#]*)?.*/i.exec(url); | ||
path = (_ref3 = parsedUrl[2]) != null ? _ref3 : ''; | ||
console.log(parsedUrl); | ||
_ref4 = requests.transforms.enabled; | ||
@@ -492,5 +487,3 @@ for (_j = 0, _len1 = _ref4.length; _j < _len1; _j++) { | ||
} | ||
console.log('before', path); | ||
path = path.replace(mapping[0], mapping[1]); | ||
console.log('after', mappingName, path); | ||
} | ||
@@ -500,3 +493,2 @@ path = decodeURIComponent(path); | ||
stat = host + path.replace(/[\/ ]/g, '.'); | ||
console.log(stat); | ||
stat = stat.replace(/(^\.)|(\.$)/g, ''); | ||
@@ -503,0 +495,0 @@ stat = stat.replace(/\.com/, ''); |
@@ -1,2 +0,2 @@ | ||
/*! bucky 0.2.2 */ | ||
(function(){var a,b,c,d,e,f,g,h=[].slice;e="undefined"!=typeof module&&null!==module&&!("undefined"!=typeof window&&null!==window?window.module:void 0),e?(a=require("xmlhttprequest").XMLHttpRequest,g=function(){var a;return a=process.hrtime(),1e3*(a[0]+a[1]/1e9)}):(a=window.XMLHttpRequest,g=function(){var a,b;return null!=(a=null!=(b=window.performance)?"function"==typeof b.now?b.now():void 0:void 0)?a:+new Date}),d=+new Date,c=function(){var a,b,c,d,e,f,g,i;for(a=arguments[0],d=2<=arguments.length?h.call(arguments,1):[],i=d.reverse(),f=0,g=i.length;g>f;f++){c=i[f];for(b in c)e=c[b],a[b]=e}return a},f=function(){var a,b;return a=1<=arguments.length?h.call(arguments,0):[],null!=("undefined"!=typeof console&&null!==console?null!=(b=console.log)?b.call:void 0:void 0)?console.log.apply(console,a):void 0},f.error=function(){var a,b;return a=1<=arguments.length?h.call(arguments,0):[],null!=("undefined"!=typeof console&&null!==console?null!=(b=console.error)?b.call:void 0:void 0)?console.error.apply(console,a):void 0},b=function(){var b,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J;if(o={host:"/bucky",maxInterval:3e4,aggregationInterval:5e3,decimalPrecision:3,sendLatency:!1,sample:1,active:!0},C={},!e&&(b=document.querySelector("[data-bucky-host],[data-bucky-page],[data-bucky-requests]")))for(C={host:b.getAttribute("data-bucky-host"),pagePerformanceKey:b.getAttribute("data-bucky-page"),requestsKey:b.getAttribute("data-bucky-requests")},H=["pagePerformanceKey","requestsKey"],F=0,G=H.length;G>F;F++)r=H[F],"true"===(null!=(I=C[r])?I.toString().toLowerCase():void 0)||""===C[r]?C[r]=!0:"false"===(null!=(J=C[r])?J.toString().toLowerCase:void 0)&&(C[r]=null);return w=c({},o,C),k={timer:"ms",gauge:"g",counter:"c"},i=w.active,(D=function(){return i=w.active&&Math.random()<w.sample})(),j=[],B=function(a){return c(w,a),("sample"in a||"active"in a)&&D(),w},y=function(a,b){return null==b&&(b=w.decimalPrecision),Math.round(a*Math.pow(10,b))/Math.pow(10,b)},x={},p=function(a,b,c){var d,e;if(i)return d=1,a in x&&("counter"===c?b+=x[a].value:(d=null!=(e=x[a].count)?e:d,d++,b=x[a].value+(b-x[a].value)/d)),x[a]={value:b,type:c,count:d},m()},A=null,v=null,q=function(){return clearTimeout(A),clearTimeout(v),v=null,A=null,z()},m=function(){return clearTimeout(A),A=setTimeout(q,w.aggregationInterval),null==v?v=setTimeout(q,w.maxInterval):void 0},u=function(b){var c,d,f,h,i,j,k,l,m;d=e||a&&(a.defake||"withCredentials"in new a),e?k=!0:(f=/^(https?:\/\/[^\/]+)/i.exec(w.host),f?(i=f[1],k=i===""+document.location.protocol+"//"+document.location.host?!0:!1):k=!0),l=g(),c="";for(h in b)m=b[h],c+=""+h+":"+m+"\n";return j=k||d||null==("undefined"!=typeof window&&null!==window?window.XDomainRequest:void 0)?new a:new window.XDomainRequest,j.bucky={track:!1},j.open("POST",""+w.host+"/v1/send",!0),j.setRequestHeader("Content-Type","text/plain"),j.addEventListener("load",function(){return E(g()-l)},!1),j.send(c),j},z=function(){var a,b,c,d;if(!i)return f("Would send bucky queue"),void 0;a={};for(r in x)b=x[r],j.push({path:r,count:b.count,type:b.type,value:b.value}),null!=k[b.type]?(c=b.value,("gauge"===(d=b.type)||"timer"===d)&&(c=y(c)),a[r]=""+c+"|"+k[b.type],1!==b.count&&(a[r]+="@"+y(1/b.count,5))):f.error("Type "+b.type+" not understood by Bucky");return u(a),x={}},n=0,s=!1,E=function(a){return n=a,w.sendLatency&&!s?(p("bucky.latency",a,"timer"),s=!0,setTimeout(function(){return s=!1},3e5)):void 0},t=function(a){var b,c,e,k,l,m,n,o,s,u;null==a&&(a=""),b=function(b){return null!=a?a.length:void 0,b},m=function(a,c,d){return null==d&&(d="gauge"),null==c||null==a?(f.error("Can't log "+a+":"+c),void 0):p(b(a),c,d)},s={TIMES:{},send:function(a,b){return m(a,b,"timer")},time:function(){var a,b,c,d,e;return e=arguments[0],a=arguments[1],c=arguments[2],b=4<=arguments.length?h.call(arguments,3):[],s.start(e),d=function(){return s.stop(e)},b.splice(0,0,d),a.apply(c,b)},timeSync:function(){var a,b,c,d,e;return d=arguments[0],a=arguments[1],c=arguments[2],b=4<=arguments.length?h.call(arguments,3):[],s.start(d),e=a.apply(c,b),s.stop(d),e},wrap:function(a,b){return null!=b?function(){var c;return c=1<=arguments.length?h.call(arguments,0):[],s.timeSync.apply(s,[a,b,this].concat(h.call(c)))}:function(b){return function(){var c;return c=1<=arguments.length?h.call(arguments,0):[],s.timeSync.apply(s,[a,b,this].concat(h.call(c)))}}},start:function(a){return s.TIMES[a]=g()},stop:function(a){var b;return null==s.TIMES[a]?(f.error("Timer "+a+" ended without having been started"),void 0):(b=g()-s.TIMES[a],s.TIMES[a]=void 0,s.send(a,b))},stopwatch:function(a,b){var c,d;return null!=b?d=function(){return+new Date}:(d=g,b=d()),c=b,{mark:function(c,e){var f;return null==e&&(e=0),f=d(),a&&(c=a+"."+c),s.send(c,f-b+e)},split:function(b,e){var f;return null==e&&(e=0),f=d(),a&&(b=a+"."+b),s.send(b,f-c+e),c=f}}},mark:function(a,b){var c;return null==b&&(b=+new Date),c=s.navigationStart(),s.send(a,b-c)},navigationStart:function(){var a,b,c;return null!=(a="undefined"!=typeof window&&null!==window?null!=(b=window.performance)?null!=(c=b.timing)?c.navigationStart:void 0:void 0:void 0)?a:d},responseEnd:function(){var a,b,c;return null!=(a="undefined"!=typeof window&&null!==window?null!=(b=window.performance)?null!=(c=b.timing)?c.responseEnd:void 0:void 0:void 0)?a:d},now:function(){return g()}},c=function(a,b){return null==b&&(b=1),m(a,b,"counter")},o=!1,n=function(a){var b,c,d,e,f,g=this;if(null==("undefined"!=typeof window&&null!==window?null!=(d=window.performance)?d.timing:void 0:void 0))return!1;if(o)return!1;if(a&&a!==!0||(a=l.urlToKey(document.location.toString())+".page",console.log(a)),"uninitialized"===(e=document.readyState)||"loading"===e)return"function"==typeof document.addEventListener&&document.addEventListener("DOMContentLoaded",function(){return n.call(g,a)},!1),!1;o=!0,b=window.performance.timing.navigationStart,f=window.performance.timing;for(r in f)c=f[r],c&&s.send(""+a+"."+r,c-b);return!0},l={transforms:{mapping:{guid:/\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,sha1:/\/[0-9a-f]{40}/gi,md5:/\/[0-9a-f]{32}/gi,id:/\/[0-9;_\-]+/g,email:/\/[^/]+@[^/]+/g,domain:[/\/[^/]+\.[a-z]{2,3}\//gi,"/"]},enabled:["guid","sha1","md5","id","email","domain"],enable:function(a,b,c){return null==c&&(c=""),null!=b&&(this.mapping[a]=[b,c]),this.enabled.splice(0,0,a)},disable:function(a){var b,c,d;d=this.enabled;for(c in d)if(b=d[c],c===a)return this.enabled.splice(b,1),void 0}},sendReadyStateTimes:function(a,b){var c,d,e,f,g,h,i,j;if(null!=b){d={1:"sending",2:"headers",3:"waiting",4:"receiving"},e={},f=null;for(c in b)h=b[c],null!=f&&null!=d[c]&&(e[d[c]]=h-f),f=h;j=[];for(g in e)i=e[g],j.push(s.send(""+a+"."+g,i));return j}},urlToKey:function(a,b,c){var d,e,g,h,i,j,k,m,n,o;for(console.log(a),a=a.replace(/https?:\/\//i,""),h=/([^/:]*)(?::\d+)?(\/[^\?#]*)?.*/i.exec(a),d=h[1],i=null!=(n=h[2])?n:"",console.log(h),o=l.transforms.enabled,k=0,m=o.length;m>k;k++)g=o[k],e=l.transforms.mapping[g],null!=e?"function"!=typeof e?(e instanceof RegExp&&(e=[e,""]),console.log("before",i),i=i.replace(e[0],e[1]),console.log("after",g,i)):i=e(i,a,b,c):f.error("Bucky Error: Attempted to enable a mapping which is not defined: "+g);return i=decodeURIComponent(i),i=i.replace(/[^a-zA-Z0-9\-\.\/ ]+/g,"_"),j=d+i.replace(/[\/ ]/g,"."),console.log(j),j=j.replace(/(^\.)|(\.$)/g,""),j=j.replace(/\.com/,""),j=j.replace(/www\./,""),c&&(j=c+"."+j),b&&(j=j+"."+b.toLowerCase()),j=j.replace(/\.\./g,".")},getFullUrl:function(a,b){return null==b&&(b=document.location),/^\//.test(a)?b.hostname+a:/https?:\/\//i.test(a)?a:b.toString()+a},monitor:function(a){var b,d,e;return a&&a!==!0||(a=l.urlToKey(document.location.toString())+".requests"),d=this,b=function(b){var e,f,h,i,j,k,l,n;return l=b.type,n=b.url,f=b.event,i=b.request,h=b.readyStateTimes,j=b.startTime,null!=j?(e=g()-j,n=d.getFullUrl(n),k=d.urlToKey(n,l,a),m(k,e,"timer"),d.sendReadyStateTimes(k,h),null!=(null!=i?i.status:void 0)?(i.status>12e3?c(""+k+".0"):0!==i.status&&c(""+k+"."+i.status.toString().charAt(0)+"xx"),c(""+k+"."+i.status)):void 0):void 0},e=window.XMLHttpRequest,window.XMLHttpRequest=function(){var a,c,d,h,i,j;d=new e;try{h=null,c={},i=d.open,d.open=function(a,e){var j;try{c[0]=g(),d.addEventListener("readystatechange",function(){return c[d.readyState]=g()},!1),d.addEventListener("loadend",function(f){return null==d.bucky||d.bucky.track!==!1?b({type:a,url:e,event:f,startTime:h,readyStateTimes:c,request:d}):void 0},!1)}catch(k){j=k,f.error("Bucky error monitoring XHR open call",j)}return i.apply(d,arguments)},j=d.send,d.send=function(){return h=g(),j.apply(d,arguments)}}catch(k){a=k,f.error("Bucky error monitoring XHR",a)}return d}}},k=function(b){var c;return null==b&&(b=""),c=null!=a?a:"",c&&b&&(c+="."),b&&(c+=b),t(c)},e={send:m,count:c,timer:s,now:g,requests:l,sendPagePerformance:n,flush:q,setOptions:B,options:w,history:j,active:i};for(r in e)u=e[r],k[r]=u;return k},l=t(),w.pagePerformanceKey&&l.sendPagePerformance(w.pagePerformanceKey),w.requestsKey&&l.requests.monitor(w.requestsKey),l},"function"==typeof define&&define.amd?define(b):"object"==typeof exports?module.exports=b():window.Bucky=b()}).call(this); | ||
/*! bucky 0.2.3 */ | ||
(function(){var a,b,c,d,e,f,g,h=[].slice;e="undefined"!=typeof module&&null!==module&&!("undefined"!=typeof window&&null!==window?window.module:void 0),e?(a=require("xmlhttprequest").XMLHttpRequest,g=function(){var a;return a=process.hrtime(),1e3*(a[0]+a[1]/1e9)}):g=function(){var a,b;return null!=(a=null!=(b=window.performance)?"function"==typeof b.now?b.now():void 0:void 0)?a:+new Date},d=+new Date,c=function(){var a,b,c,d,e,f,g,i;for(a=arguments[0],d=2<=arguments.length?h.call(arguments,1):[],i=d.reverse(),f=0,g=i.length;g>f;f++){c=i[f];for(b in c)e=c[b],a[b]=e}return a},f=function(){var a,b;return a=1<=arguments.length?h.call(arguments,0):[],null!=("undefined"!=typeof console&&null!==console?null!=(b=console.log)?b.call:void 0:void 0)?console.log.apply(console,a):void 0},f.error=function(){var a,b;return a=1<=arguments.length?h.call(arguments,0):[],null!=("undefined"!=typeof console&&null!==console?null!=(b=console.error)?b.call:void 0:void 0)?console.error.apply(console,a):void 0},b=function(){var b,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I;if(n={host:"/bucky",maxInterval:3e4,aggregationInterval:5e3,decimalPrecision:3,sendLatency:!1,sample:1,active:!0},B={},!e&&(b=document.querySelector("[data-bucky-host],[data-bucky-page],[data-bucky-requests]")))for(B={host:b.getAttribute("data-bucky-host"),pagePerformanceKey:b.getAttribute("data-bucky-page"),requestsKey:b.getAttribute("data-bucky-requests")},G=["pagePerformanceKey","requestsKey"],E=0,F=G.length;F>E;E++)q=G[E],"true"===(null!=(H=B[q])?H.toString().toLowerCase():void 0)||""===B[q]?B[q]=!0:"false"===(null!=(I=B[q])?I.toString().toLowerCase:void 0)&&(B[q]=null);return v=c({},n,B),k={timer:"ms",gauge:"g",counter:"c"},i=v.active,(C=function(){return i=v.active&&Math.random()<v.sample})(),j=[],A=function(a){return c(v,a),("sample"in a||"active"in a)&&C(),v},x=function(a,b){return null==b&&(b=v.decimalPrecision),Math.round(a*Math.pow(10,b))/Math.pow(10,b)},w={},o=function(a,b,c){var d,e;if(i)return d=1,a in w&&("counter"===c?b+=w[a].value:(d=null!=(e=w[a].count)?e:d,d++,b=w[a].value+(b-w[a].value)/d)),w[a]={value:b,type:c,count:d},m()},z=null,u=null,p=function(){return clearTimeout(z),clearTimeout(u),u=null,z=null,y()},m=function(){return clearTimeout(z),z=setTimeout(p,v.aggregationInterval),null==u?u=setTimeout(p,v.maxInterval):void 0},t=function(b){var c,d,f,h,i,j,k,l,m,n;d=e||window.XMLHttpRequest&&(window.XMLHttpRequest.defake||"withCredentials"in new window.XMLHttpRequest),e?k=!0:(f=/^(https?:\/\/[^\/]+)/i.exec(v.host),f?(i=f[1],k=i===""+document.location.protocol+"//"+document.location.host?!0:!1):k=!0),l=g(),c="";for(h in b)m=b[h],c+=""+h+":"+m+"\n";return j=k||d||null==("undefined"!=typeof window&&null!==window?window.XDomainRequest:void 0)?new(null!=(n="undefined"!=typeof window&&null!==window?window.XMLHttpRequest:void 0)?n:a):new window.XDomainRequest,j.bucky={track:!1},j.open("POST",""+v.host+"/v1/send",!0),j.setRequestHeader("Content-Type","text/plain"),j.addEventListener("load",function(){return D(g()-l)},!1),j.send(c),j},y=function(){var a,b,c,d;if(!i)return f("Would send bucky queue"),void 0;a={};for(q in w)b=w[q],j.push({path:q,count:b.count,type:b.type,value:b.value}),null!=k[b.type]?(c=b.value,("gauge"===(d=b.type)||"timer"===d)&&(c=x(c)),a[q]=""+c+"|"+k[b.type],1!==b.count&&(a[q]+="@"+x(1/b.count,5))):f.error("Type "+b.type+" not understood by Bucky");return t(a),w={}},r=!1,D=function(a){return Bucky.latency=a,v.sendLatency&&!r?(o("bucky.latency",a,"timer"),r=!0,setTimeout(function(){return r=!1},3e5)):void 0},s=function(a){var b,c,e,k,l,m,n,r,t,u;null==a&&(a=""),b=function(b){return null!=a?a.length:void 0,b},m=function(a,c,d){return null==d&&(d="gauge"),null==c||null==a?(f.error("Can't log "+a+":"+c),void 0):o(b(a),c,d)},t={TIMES:{},send:function(a,b){return m(a,b,"timer")},time:function(){var a,b,c,d,e;return e=arguments[0],a=arguments[1],c=arguments[2],b=4<=arguments.length?h.call(arguments,3):[],t.start(e),d=function(){return t.stop(e)},b.splice(0,0,d),a.apply(c,b)},timeSync:function(){var a,b,c,d,e;return d=arguments[0],a=arguments[1],c=arguments[2],b=4<=arguments.length?h.call(arguments,3):[],t.start(d),e=a.apply(c,b),t.stop(d),e},wrap:function(a,b){return null!=b?function(){var c;return c=1<=arguments.length?h.call(arguments,0):[],t.timeSync.apply(t,[a,b,this].concat(h.call(c)))}:function(b){return function(){var c;return c=1<=arguments.length?h.call(arguments,0):[],t.timeSync.apply(t,[a,b,this].concat(h.call(c)))}}},start:function(a){return t.TIMES[a]=g()},stop:function(a){var b;return null==t.TIMES[a]?(f.error("Timer "+a+" ended without having been started"),void 0):(b=g()-t.TIMES[a],t.TIMES[a]=void 0,t.send(a,b))},stopwatch:function(a,b){var c,d;return null!=b?d=function(){return+new Date}:(d=g,b=d()),c=b,{mark:function(c,e){var f;return null==e&&(e=0),f=d(),a&&(c=a+"."+c),t.send(c,f-b+e)},split:function(b,e){var f;return null==e&&(e=0),f=d(),a&&(b=a+"."+b),t.send(b,f-c+e),c=f}}},mark:function(a,b){var c;return null==b&&(b=+new Date),c=t.navigationStart(),t.send(a,b-c)},navigationStart:function(){var a,b,c;return null!=(a="undefined"!=typeof window&&null!==window?null!=(b=window.performance)?null!=(c=b.timing)?c.navigationStart:void 0:void 0:void 0)?a:d},responseEnd:function(){var a,b,c;return null!=(a="undefined"!=typeof window&&null!==window?null!=(b=window.performance)?null!=(c=b.timing)?c.responseEnd:void 0:void 0:void 0)?a:d},now:function(){return g()}},c=function(a,b){return null==b&&(b=1),m(a,b,"counter")},r=!1,n=function(a){var b,c,d,e,f,g=this;if(null==("undefined"!=typeof window&&null!==window?null!=(d=window.performance)?d.timing:void 0:void 0))return!1;if(r)return!1;if(a&&a!==!0||(a=l.urlToKey(document.location.toString())+".page"),"uninitialized"===(e=document.readyState)||"loading"===e)return"function"==typeof document.addEventListener&&document.addEventListener("DOMContentLoaded",function(){return n.call(g,a)},!1),!1;r=!0,b=window.performance.timing.navigationStart,f=window.performance.timing;for(q in f)c=f[q],c&&t.send(""+a+"."+q,c-b);return!0},l={transforms:{mapping:{guid:/\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,sha1:/\/[0-9a-f]{40}/gi,md5:/\/[0-9a-f]{32}/gi,id:/\/[0-9;_\-]+/g,email:/\/[^/]+@[^/]+/g,domain:[/\/[^/]+\.[a-z]{2,3}\//gi,"/"]},enabled:["guid","sha1","md5","id","email","domain"],enable:function(a,b,c){return null==c&&(c=""),null!=b&&(this.mapping[a]=[b,c]),this.enabled.splice(0,0,a)},disable:function(a){var b,c,d;d=this.enabled;for(c in d)if(b=d[c],c===a)return this.enabled.splice(b,1),void 0}},sendReadyStateTimes:function(a,b){var c,d,e,f,g,h,i,j;if(null!=b){d={1:"sending",2:"headers",3:"waiting",4:"receiving"},e={},f=null;for(c in b)h=b[c],null!=f&&null!=d[c]&&(e[d[c]]=h-f),f=h;j=[];for(g in e)i=e[g],j.push(t.send(""+a+"."+g,i));return j}},urlToKey:function(a,b,c){var d,e,g,h,i,j,k,m,n,o;for(a=a.replace(/https?:\/\//i,""),h=/([^/:]*)(?::\d+)?(\/[^\?#]*)?.*/i.exec(a),d=h[1],i=null!=(n=h[2])?n:"",o=l.transforms.enabled,k=0,m=o.length;m>k;k++)g=o[k],e=l.transforms.mapping[g],null!=e?"function"!=typeof e?(e instanceof RegExp&&(e=[e,""]),i=i.replace(e[0],e[1])):i=e(i,a,b,c):f.error("Bucky Error: Attempted to enable a mapping which is not defined: "+g);return i=decodeURIComponent(i),i=i.replace(/[^a-zA-Z0-9\-\.\/ ]+/g,"_"),j=d+i.replace(/[\/ ]/g,"."),j=j.replace(/(^\.)|(\.$)/g,""),j=j.replace(/\.com/,""),j=j.replace(/www\./,""),c&&(j=c+"."+j),b&&(j=j+"."+b.toLowerCase()),j=j.replace(/\.\./g,".")},getFullUrl:function(a,b){return null==b&&(b=document.location),/^\//.test(a)?b.hostname+a:/https?:\/\//i.test(a)?a:b.toString()+a},monitor:function(a){var b,d,e;return a&&a!==!0||(a=l.urlToKey(document.location.toString())+".requests"),d=this,b=function(b){var e,f,h,i,j,k,l,n;return l=b.type,n=b.url,f=b.event,i=b.request,h=b.readyStateTimes,j=b.startTime,null!=j?(e=g()-j,n=d.getFullUrl(n),k=d.urlToKey(n,l,a),m(k,e,"timer"),d.sendReadyStateTimes(k,h),null!=(null!=i?i.status:void 0)?(i.status>12e3?c(""+k+".0"):0!==i.status&&c(""+k+"."+i.status.toString().charAt(0)+"xx"),c(""+k+"."+i.status)):void 0):void 0},e=window.XMLHttpRequest,window.XMLHttpRequest=function(){var a,c,d,h,i,j;d=new e;try{h=null,c={},i=d.open,d.open=function(a,e){var j;try{c[0]=g(),d.addEventListener("readystatechange",function(){return c[d.readyState]=g()},!1),d.addEventListener("loadend",function(f){return null==d.bucky||d.bucky.track!==!1?b({type:a,url:e,event:f,startTime:h,readyStateTimes:c,request:d}):void 0},!1)}catch(k){j=k,f.error("Bucky error monitoring XHR open call",j)}return i.apply(d,arguments)},j=d.send,d.send=function(){return h=g(),j.apply(d,arguments)}}catch(k){a=k,f.error("Bucky error monitoring XHR",a)}return d}}},k=function(b){var c;return null==b&&(b=""),c=null!=a?a:"",c&&b&&(c+="."),b&&(c+=b),s(c)},e={send:m,count:c,timer:t,now:g,requests:l,sendPagePerformance:n,flush:p,setOptions:A,options:v,history:j,active:i};for(q in e)u=e[q],k[q]=u;return k},l=s(),v.pagePerformanceKey&&l.sendPagePerformance(v.pagePerformanceKey),v.requestsKey&&l.requests.monitor(v.requestsKey),l},"function"==typeof define&&define.amd?define(b):"object"==typeof exports?module.exports=b():window.Bucky=b()}).call(this); |
@@ -5,3 +5,3 @@ { | ||
"description": "Collect performance data from the client", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"homepage": "http://github.hubspot.com/BuckyClient", | ||
@@ -8,0 +8,0 @@ "license": "MIT", |
{ | ||
"name": "bucky", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Collect performance data from the client and node", | ||
@@ -5,0 +5,0 @@ "main": "./bucky.js", |
@@ -12,3 +12,3 @@ Bucky | ||
If you already use statsd or OpenTSDB, you can get started in just a few minutes. If you're not | ||
collecting stats, you [should start](https://github.com/HubSpot/BuckyServer/blob/master/docs/start-no-stats.md)! | ||
collecting stats, you [should start](http://github.hubspot.com/BuckyServer/getting_started/choosing_a_stats_service/)! | ||
What gets measured gets managed. | ||
@@ -19,3 +19,3 @@ | ||
You can play with Bucky just using the client, but if you'd like to start collecting data, see the | ||
[Server Instructions](http://github.com/HubSpot/BuckyServer). | ||
[Server Instructions](http://github.hubspot.com/BuckyServer/). | ||
@@ -26,3 +26,3 @@ ### Setup | ||
Include `BuckyClient/bucky.js` file on your page, the most important config can be done right in the script tag: | ||
Include [bucky.js](https://raw.github.com/HubSpot/BuckyClient/v0.2.3/bucky.min.js) on your page, the only required config can be done right in the script tag: | ||
@@ -330,4 +330,4 @@ ```html | ||
[Server Documentation](http://github.com/HubSpot/BuckyServer) | ||
[Server Documentation](http://github.hubspot.com/BuckyServer) | ||
<script src="http://github.hubspot.com/BuckyClient/bucky.js"></script> |
@@ -117,13 +117,10 @@ (function() { | ||
expect(server.requests.length).toBe(1); | ||
return expect(JSON.parse(server.requests[0].requestBody)['data.point']).toBe("4.000|g"); | ||
return expect(server.requests[0].requestBody).toBe("data.point:4|g\n"); | ||
}); | ||
return it('should send timers', function() { | ||
var body; | ||
Bucky.send('data.1', 5, 'timer'); | ||
Bucky.send('data.2', 3, 'timer'); | ||
Bucky.flush(); | ||
body = JSON.parse(server.requests[0].requestBody); | ||
expect(body['data.1']).toBe("5.000|ms"); | ||
expect(body['data.2']).toBe("3.000|ms"); | ||
return expect(server.requests.length).toBe(1); | ||
expect(server.requests.length).toBe(1); | ||
return expect(server.requests[0].requestBody).toBe("data.1:5|ms\ndata.2:3|ms\n"); | ||
}); | ||
@@ -130,0 +127,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
680667
22
17893