keen-botkit
Version:
Bot Kit Integration for Keen IO
5 lines • 29.5 kB
JavaScript
(function e(b,g,d){function c(m,j){if(!g[m]){if(!b[m]){var i=typeof require=="function"&&require;if(!j&&i){return i(m,!0)}if(a){return a(m,!0)}var k=new Error("Cannot find module '"+m+"'");throw k.code="MODULE_NOT_FOUND",k}var h=g[m]={exports:{}};b[m][0].call(h.exports,function(l){var o=b[m][1][l];return c(o?o:l)},h,h.exports,e,b,g,d)}return g[m].exports}var a=typeof require=="function"&&require;for(var f=0;f<d.length;f++){c(d[f])}return c})({1:[function(require,module,exports){(function(exports){if(typeof exports.decycle!=="function"){exports.decycle=function decycle(object){var objects=[],paths=[];return(function derez(value,path){var i,name,nu;switch(typeof value){case"object":if(!value){return null}for(i=0;i<objects.length;i+=1){if(objects[i]===value){return{$ref:paths[i]}}}objects.push(value);paths.push(path);if(Object.prototype.toString.apply(value)==="[object Array]"){nu=[];for(i=0;i<value.length;i+=1){nu[i]=derez(value[i],path+"["+i+"]")}}else{nu={};for(name in value){if(Object.prototype.hasOwnProperty.call(value,name)){nu[name]=derez(value[name],path+"["+JSON.stringify(name)+"]")}}}return nu;case"number":case"string":case"boolean":return value}}(object,"$"))}}if(typeof exports.retrocycle!=="function"){exports.retrocycle=function retrocycle($){var px=/^\$(?:\[(?:\d+|\"(?:[^\\\"\u0000-\u001f]|\\([\\\"\/bfnrt]|u[0-9a-zA-Z]{4}))*\")\])*$/;(function rez(value){var i,item,name,path;if(value&&typeof value==="object"){if(Object.prototype.toString.apply(value)==="[object Array]"){for(i=0;i<value.length;i+=1){item=value[i];if(item&&typeof item==="object"){path=item.$ref;if(typeof path==="string"&&px.test(path)){value[i]=eval(path)}else{rez(item)}}}}else{for(name in value){if(typeof value[name]==="object"){item=value[name];if(item){path=item.$ref;if(typeof path==="string"&&px.test(path)){value[name]=eval(path)}else{rez(item)}}}}}}}($));return $}}})((typeof exports!=="undefined")?exports:(window.JSON?(window.JSON):(window.JSON={})))},{}],2:[function(b,d,a){var f=b("./json2");var c=b("./cycle");f.decycle=c.decycle;f.retrocycle=c.retrocycle;d.exports=f},{"./cycle":1,"./json2":3}],3:[function(require,module,exports){(function(JSON){function f(n){return n<10?"0"+n:n}if(typeof exports==="undefined"){if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null}}if(typeof String.prototype.toJSON!=="function"){String.prototype.toJSON=function(key){return this.valueOf()}}if(typeof Number.prototype.toJSON!=="function"){Number.prototype.toJSON=function(key){return this.valueOf()}}if(typeof Boolean.prototype.toJSON!=="function"){Boolean.prototype.toJSON=function(key){return this.valueOf()}}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key)}if(typeof rep==="function"){value=rep.call(holder,key,value)}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||"null"}v=partial.length===0?"[]":gap?"[\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"]":"["+partial.join(",")+"]";gap=mind;return v}if(rep&&typeof rep==="object"){length=rep.length;for(i=0;i<length;i+=1){if(typeof rep[i]==="string"){k=rep[i];v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}else{for(k in value){if(Object.prototype.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}v=partial.length===0?"{}":gap?"{\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"}":"{"+partial.join(",")+"}";gap=mind;return v}}if(typeof JSON.stringify!=="function"){JSON.stringify=function(value,replacer,space){var i;gap="";indent="";if(typeof space==="number"){for(i=0;i<space;i+=1){indent+=" "}}else{if(typeof space==="string"){indent=space}}rep=replacer;if(replacer&&typeof replacer!=="function"&&(typeof replacer!=="object"||typeof replacer.length!=="number")){throw new Error("JSON.stringify")}return str("",{"":value})}}if(typeof JSON.parse!=="function"){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==="object"){for(k in value){if(Object.prototype.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v}else{delete value[k]}}}}return reviver.call(holder,key,value)}text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver==="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")}}})((typeof exports!=="undefined")?exports:(window.JSON?(window.JSON):(window.JSON={})))},{}],4:[function(c,d,b){d.exports=f;function f(g){if(g){return a(g)}}function a(h){for(var g in f.prototype){h[g]=f.prototype[g]}return h}f.prototype.on=f.prototype.addEventListener=function(h,g){this._callbacks=this._callbacks||{};(this._callbacks[h]=this._callbacks[h]||[]).push(g);return this};f.prototype.once=function(j,i){var h=this;this._callbacks=this._callbacks||{};function g(){h.off(j,g);i.apply(this,arguments)}g.fn=i;this.on(j,g);return this};f.prototype.off=f.prototype.removeListener=f.prototype.removeAllListeners=f.prototype.removeEventListener=function(l,j){this._callbacks=this._callbacks||{};if(0==arguments.length){this._callbacks={};return this}var k=this._callbacks[l];if(!k){return this}if(1==arguments.length){delete this._callbacks[l];return this}var g;for(var h=0;h<k.length;h++){g=k[h];if(g===j||g.fn===j){k.splice(h,1);break}}return this};f.prototype.emit=function(l){this._callbacks=this._callbacks||{};var h=[].slice.call(arguments,1),k=this._callbacks[l];if(k){k=k.slice(0);for(var j=0,g=k.length;j<g;++j){k[j].apply(this,h)}}return this};f.prototype.listeners=function(g){this._callbacks=this._callbacks||{};return this._callbacks[g]||[]};f.prototype.hasListeners=function(g){return !!this.listeners(g).length}},{}],5:[function(b,c,a){
/*!
* domready (c) Dustin Diaz 2012 - License MIT
*/
!function(d,f){if(typeof c!="undefined"){c.exports=f()}else{if(typeof define=="function"&&typeof define.amd=="object"){define(f)}else{this[d]=f()}}}("domready",function(m){var r=[],l,k=false,n=document,g=n.documentElement,q=g.doScroll,d="DOMContentLoaded",h="addEventListener",p="onreadystatechange",j="readyState",s=q?/^loaded|^c/:/^loaded|c/,i=s.test(n[j]);function o(t){i=1;while(t=r.shift()){t()}}n[h]&&n[h](d,l=function(){n.removeEventListener(d,l,k);o()},k);q&&n.attachEvent(p,l=function(){if(/^c/.test(n[j])){n.detachEvent(p,l);o()}});return(m=q?function(f){self!=top?i?f():r.push(f):function(){try{g.doScroll("left")}catch(t){return setTimeout(function(){m(f)},50)}f()}()}:function(f){i?f():r.push(f)})})},{}],6:[function(i,b,t){var l=i("emitter");var k=i("reduce");var p="undefined"==typeof window?this:window;function f(){}function m(u){var v={}.toString.call(u);switch(v){case"[object File]":case"[object Blob]":case"[object FormData]":return true;default:return false}}function n(){if(p.XMLHttpRequest&&("file:"!=p.location.protocol||!p.ActiveXObject)){return new XMLHttpRequest}else{try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(u){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(u){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(u){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(u){}}return false}var r="".trim?function(u){return u.trim()}:function(u){return u.replace(/(^\s*|\s*$)/g,"")};function j(u){return u===Object(u)}function o(w){if(!j(w)){return w}var v=[];for(var u in w){if(null!=w[u]){v.push(encodeURIComponent(u)+"="+encodeURIComponent(w[u]))}}return v.join("&")}d.serializeObject=o;function h(A){var y={};var w=A.split("&");var x;var z;for(var v=0,u=w.length;v<u;++v){z=w[v];x=z.split("=");y[decodeURIComponent(x[0])]=decodeURIComponent(x[1])}return y}d.parseString=h;d.types={html:"text/html",json:"application/json",xml:"application/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"};d.serialize={"application/x-www-form-urlencoded":o,"application/json":JSON.stringify};d.parse={"application/x-www-form-urlencoded":h,"application/json":JSON.parse};function c(z){var B=z.split(/\r?\n/);var w={};var y;var C;var A;var u;B.pop();for(var v=0,x=B.length;v<x;++v){C=B[v];y=C.indexOf(":");A=C.slice(0,y).toLowerCase();u=r(C.slice(y+1));w[A]=u}return w}function g(u){return u.split(/ *; */).shift()}function s(u){return k(u.split(/ *; */),function(x,z){var w=z.split(/ *= */),v=w.shift(),y=w.shift();if(v&&y){x[v]=y}return x},{})}function a(v,u){u=u||{};this.req=v;this.xhr=this.req.xhr;this.text=this.req.method!="HEAD"?this.xhr.responseText:null;this.setStatusProperties(this.xhr.status);this.header=this.headers=c(this.xhr.getAllResponseHeaders());this.header["content-type"]=this.xhr.getResponseHeader("content-type");this.setHeaderProperties(this.header);this.body=this.req.method!="HEAD"?this.parseBody(this.text):null}a.prototype.get=function(u){return this.header[u.toLowerCase()]};a.prototype.setHeaderProperties=function(x){var v=this.header["content-type"]||"";this.type=g(v);var w=s(v);for(var u in w){this[u]=w[u]}};a.prototype.parseBody=function(v){var u=d.parse[this.type];return u&&v&&v.length?u(v):null};a.prototype.setStatusProperties=function(u){var v=u/100|0;this.status=u;this.statusType=v;this.info=1==v;this.ok=2==v;this.clientError=4==v;this.serverError=5==v;this.error=(4==v||5==v)?this.toError():false;this.accepted=202==u;this.noContent=204==u||1223==u;this.badRequest=400==u;this.unauthorized=401==u;this.notAcceptable=406==u;this.notFound=404==u;this.forbidden=403==u};a.prototype.toError=function(){var w=this.req;var y=w.method;var u=w.url;var x="cannot "+y+" "+u+" ("+this.status+")";var v=new Error(x);v.status=this.status;v.method=y;v.url=u;return v};d.Response=a;function q(w,v){var u=this;l.call(this);this._query=this._query||[];this.method=w;this.url=v;this.header={};this._header={};this.on("end",function(){var y=null;var x=null;try{x=new a(u)}catch(z){y=new Error("Parser is unable to parse the response");y.parse=true;y.original=z}u.callback(y,x)})}l(q.prototype);q.prototype.use=function(u){u(this);return this};q.prototype.timeout=function(u){this._timeout=u;return this};q.prototype.clearTimeout=function(){this._timeout=0;clearTimeout(this._timer);return this};q.prototype.abort=function(){if(this.aborted){return}this.aborted=true;this.xhr.abort();this.clearTimeout();this.emit("abort");return this};q.prototype.set=function(v,w){if(j(v)){for(var u in v){this.set(u,v[u])}return this}this._header[v.toLowerCase()]=w;this.header[v]=w;return this};q.prototype.unset=function(u){delete this._header[u.toLowerCase()];delete this.header[u];return this};q.prototype.getHeader=function(u){return this._header[u.toLowerCase()]};q.prototype.type=function(u){this.set("Content-Type",d.types[u]||u);return this};q.prototype.accept=function(u){this.set("Accept",d.types[u]||u);return this};q.prototype.auth=function(u,v){var w=btoa(u+":"+v);this.set("Authorization","Basic "+w);return this};q.prototype.query=function(u){if("string"!=typeof u){u=o(u)}if(u){this._query.push(u)}return this};q.prototype.field=function(u,v){if(!this._formData){this._formData=new FormData()}this._formData.append(u,v);return this};q.prototype.attach=function(w,v,u){if(!this._formData){this._formData=new FormData()}this._formData.append(w,v,u);return this};q.prototype.send=function(w){var x=j(w);var v=this.getHeader("Content-Type");if(x&&j(this._data)){for(var u in w){this._data[u]=w[u]}}else{if("string"==typeof w){if(!v){this.type("form")}v=this.getHeader("Content-Type");if("application/x-www-form-urlencoded"==v){this._data=this._data?this._data+"&"+w:w}else{this._data=(this._data||"")+w}}else{this._data=w}}if(!x){return this}if(!v){this.type("json")}return this};q.prototype.callback=function(w,u){var v=this._callback;this.clearTimeout();if(2==v.length){return v(w,u)}if(w){return this.emit("error",w)}v(u)};q.prototype.crossDomainError=function(){var u=new Error("Origin is not allowed by Access-Control-Allow-Origin");u.crossDomain=true;this.callback(u)};q.prototype.timeoutError=function(){var v=this._timeout;var u=new Error("timeout of "+v+"ms exceeded");u.timeout=v;this.callback(u)};q.prototype.withCredentials=function(){this._withCredentials=true;return this};q.prototype.end=function(w){var u=this;var B=this.xhr=n();var z=this._query.join("&");var y=this._timeout;var x=this._formData||this._data;this._callback=w||f;B.onreadystatechange=function(){if(4!=B.readyState){return}if(0==B.status){if(u.aborted){return u.timeoutError()}return u.crossDomainError()}u.emit("end")};if(B.upload){B.upload.onprogress=function(C){C.percent=C.loaded/C.total*100;u.emit("progress",C)}}if(y&&!this._timer){this._timer=setTimeout(function(){u.abort()},y)}if(z){z=d.serializeObject(z);this.url+=~this.url.indexOf("?")?"&"+z:"?"+z}B.open(this.method,this.url,true);if(this._withCredentials){B.withCredentials=true}if("GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof x&&!m(x)){var v=d.serialize[this.getHeader("Content-Type")];if(v){x=v(x)}}for(var A in this.header){if(null==this.header[A]){continue}B.setRequestHeader(A,this.header[A])}this.emit("request",this);B.send(x);return this};d.Request=q;function d(v,u){if("function"==typeof u){return new q("GET",v).end(u)}if(1==arguments.length){return new q("GET",v)}return new q(v,u)}d.get=function(u,x,v){var w=d("GET",u);if("function"==typeof x){v=x,x=null}if(x){w.query(x)}if(v){w.end(v)}return w};d.head=function(u,x,v){var w=d("HEAD",u);if("function"==typeof x){v=x,x=null}if(x){w.send(x)}if(v){w.end(v)}return w};d.del=function(u,v){var w=d("DELETE",u);if(v){w.end(v)}return w};d.patch=function(u,x,v){var w=d("PATCH",u);if("function"==typeof x){v=x,x=null}if(x){w.send(x)}if(v){w.end(v)}return w};d.post=function(u,x,v){var w=d("POST",u);if("function"==typeof x){v=x,x=null}if(x){w.send(x)}if(v){w.end(v)}return w};d.put=function(u,x,v){var w=d("PUT",u);if("function"==typeof x){v=x,x=null}if(x){w.send(x)}if(v){w.end(v)}return w};b.exports=d},{emitter:7,reduce:8}],7:[function(b,c,a){arguments[4][4][0].apply(a,arguments)},{dup:4}],8:[function(b,c,a){c.exports=function(g,i,h){var f=0;var d=g.length;var j=arguments.length==3?h:g[f++];while(f<d){j=i.call(null,j,g[f],++f,g)}return j}},{}],9:[function(c,d,b){var a=c("./index"),f=c("./utils/each");d.exports=function(){var h=window.Keen||null,j=window._Keen||null,g,i;if(h&&j){g=j.clients||{},i=j.ready||[];f(g,function(l,n){f(a.prototype,function(p,o){h.prototype[o]=p});f(["Query","Request","Dataset","Dataviz"],function(o){h[o]=(a[o])?a[o]:function(){}});if(l._config){l.configure.call(l,l._config)}if(l._setGlobalProperties){f(l._setGlobalProperties,function(o){l.setGlobalProperties.apply(l,o)})}if(l._addEvent){f(l._addEvent,function(o){l.addEvent.apply(l,o)})}var m=l._on||[];if(l._on){f(l._on,function(o){l.on.apply(l,o)});l.trigger("ready")}f(["_config","_setGlobalProperties","_addEvent","_on"],function(o){if(l[o]){l[o]=undefined;try{delete l[o]}catch(p){}}})});f(i,function(l,m){a.once("ready",l)})}window._Keen=undefined;try{delete window._Keen}catch(k){}}},{"./index":17,"./utils/each":23}],10:[function(b,c,a){var d=b("component-emitter");d.prototype.trigger=d.prototype.emit;c.exports=d},{"component-emitter":4}],11:[function(b,c,a){c.exports=function(){return"undefined"==typeof window?"server":"browser"}},{}],12:[function(b,c,a){var f=b("../utils/each"),d=b("JSON2");c.exports=function(h){var g=[];f(h,function(j,i){if("string"!==typeof j){j=d.stringify(j)}g.push(i+"="+encodeURIComponent(j))});return"?"+g.join("&")}},{"../utils/each":23,JSON2:2}],13:[function(b,c,a){c.exports=function(){if("undefined"!==typeof window){if(navigator.userAgent.indexOf("MSIE")!==-1||navigator.appVersion.indexOf("Trident/")>0){return 2000}}return 16000}},{}],14:[function(b,c,a){c.exports=function(){var d="undefined"==typeof window?this:window;if(d.XMLHttpRequest&&("file:"!=d.location.protocol||!d.ActiveXObject)){return new XMLHttpRequest}else{try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(f){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(f){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(f){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(f){}}return false}},{}],15:[function(b,c,a){c.exports=function(h,g,i){var f=i||function(){};if(g&&!g.ok){var d=g.body&&g.body.error_code;h=new Error(d?g.body.message:"Unknown error occurred");h.code=d?g.body.error_code:"UnknownError"}if(h){f(h,null)}else{f(null,g.body)}return}},{}],16:[function(f,b,g){var n=f("superagent");var l=f("../utils/each"),a=f("./get-xhr-object");b.exports=function(o,p){return function(q){var r=q.constructor.prototype.end;if("undefined"===typeof window){return}q.requestType=q.requestType||{};q.requestType.type=o;q.requestType.options=q.requestType.options||{async:true,success:{responseText:'{ "created": true }',status:201},error:{responseText:'{ "error_code": "ERROR", "message": "Request failed" }',status:404}};if(p){if("boolean"===typeof p.async){q.requestType.options.async=p.async}if(p.success){extend(q.requestType.options.success,p.success)}if(p.error){extend(q.requestType.options.error,p.error)}}q.end=function(u){var t=this,s=(this.requestType)?this.requestType.type:"xhr",w,v;if(("GET"!==t.method||"xhr"===s)&&t.requestType.options.async){r.call(t,u);return}w=t._query.join("&");v=t._timeout;t._callback=u||noop;if(v&&!t._timer){t._timer=setTimeout(function(){h.call(t)},v)}if(w){w=n.serializeObject(w);t.url+=~t.url.indexOf("?")?"&"+w:"?"+w}t.emit("request",t);if(!t.requestType.options.async){k.call(t)}else{if("jsonp"===s){j.call(t)}else{if("beacon"===s){i.call(t)}}}return t};return q}};function k(){var o=a();if(o){o.open("GET",this.url,false);o.send(null)}return this}function j(){var p=this,t=new Date().getTime(),o=document.createElement("script"),s=document.getElementsByTagName("head")[0],u="keenJSONPCallback",q=false;u+=t;while(u in window){u+="a"}window[u]=function(v){if(q===true){return}q=true;d.call(p,v);r()};o.src=p.url+"&jsonp="+u;s.appendChild(o);o.onreadystatechange=function(){if(q===false&&p.readyState==="loaded"){q=true;c.call(p);r()}};o.onerror=function(){if(q===false){q=true;c.call(p);r()}};function r(){window[u]=undefined;try{delete window[u]}catch(v){}s.removeChild(o)}}function i(){var p=this,o=document.createElement("img"),q=false;o.onload=function(){q=true;if("naturalHeight" in this){if(this.naturalHeight+this.naturalWidth===0){this.onerror();return}}else{if(this.width+this.height===0){this.onerror();return}}d.call(p)};o.onerror=function(){q=true;c.call(p)};o.src=p.url+"&c=clv1"}function d(p){var q=this.requestType.options["success"],o="";m.call(this,q);if(p){try{o=JSON.stringify(p)}catch(r){}}else{o=q.responseText}this.xhr.responseText=o;this.xhr.status=q.status;this.emit("end")}function c(){var o=this.requestType.options["error"];m.call(this,o);this.xhr.responseText=o.responseText;this.xhr.status=o.status;this.emit("end")}function h(){this.aborted=true;this.clearTimeout();this.emit("abort")}function m(o){this.xhr={getAllResponseHeaders:function(){return""},getResponseHeader:function(){return"application/json"},responseText:o.responseText,status:o.status};return this}},{"../utils/each":23,"./get-xhr-object":14,superagent:6}],17:[function(d,f,c){var b=this;var h=b.Keen;var i=d("./utils/extend");var g=d("./helpers/emitter-shim");function a(j){this.configure(j||{});a.trigger("client",this)}a.debug=false;a.enabled=true;a.loaded=true;a.version="3.2.1";g(a);g(a.prototype);a.prototype.configure=function(j){var k=j||{};if(k.host){k.host.replace(/.*?:\/\//g,"")}if(k.protocol&&k.protocol==="auto"){k.protocol=location.protocol.replace(/:/g,"")}this.config={projectId:k.projectId,writeKey:k.writeKey,readKey:k.readKey,masterKey:k.masterKey,requestType:k.requestType||"jsonp",host:k.host||"api.keen.io/3.0",protocol:k.protocol||"https",globalProperties:null};if(a.debug){this.on("error",a.log)}this.trigger("ready")};a.prototype.projectId=function(j){if(!arguments.length){return this.config.projectId}this.config.projectId=(j?String(j):null);return this};a.prototype.masterKey=function(j){if(!arguments.length){return this.config.masterKey}this.config.masterKey=(j?String(j):null);return this};a.prototype.readKey=function(j){if(!arguments.length){return this.config.readKey}this.config.readKey=(j?String(j):null);return this};a.prototype.writeKey=function(j){if(!arguments.length){return this.config.writeKey}this.config.writeKey=(j?String(j):null);return this};a.prototype.url=function(j){if(!this.projectId()){this.trigger("error","Client is missing projectId property");return}return this.config.protocol+"://"+this.config.host+"/projects/"+this.projectId()+j};a.log=function(j){if(a.debug&&typeof console=="object"){console.log("[Keen IO]",j)}};a.noConflict=function(){b.Keen=h;return a};a.ready=function(j){if(a.loaded){j()}else{a.once("ready",j)}};f.exports=a},{"./helpers/emitter-shim":10,"./utils/extend":24}],18:[function(f,c,h){var n=f("JSON2");var g=f("superagent");var i=f("../index");var j=f("../utils/base64"),m=f("../utils/each"),o=f("../helpers/get-context"),d=f("../helpers/get-query-string"),b=f("../helpers/get-url-max-length"),a=f("../helpers/get-xhr-object"),k=f("../helpers/superagent-request-types"),p=f("../helpers/superagent-handle-response");c.exports=function(x,A,B,t){var C=this,v=this.url("/events/"+x),q=this.config.requestType,u={},s=B,r,z;r=("boolean"===typeof t)?t:true;if(!i.enabled){y.call(C,"Keen.enabled = false");return}if(!C.projectId()){y.call(C,"Missing projectId property");return}if(!C.writeKey()){y.call(C,"Missing writeKey property");return}if(!x||typeof x!=="string"){y.call(C,"Collection name must be a string");return}if(C.config.globalProperties){u=C.config.globalProperties(x)}m(A,function(E,D){u[D]=E});if(!a()&&"xhr"===q){q="jsonp"}if("xhr"!==q||!r){z=l.call(C,v,u)}if(z&&o()==="browser"){g.get(z).use(function(D){D.async=r;return D}).use(k(q)).end(w)}else{if(a()||o()==="server"){g.post(v).set("Content-Type","application/json").set("Authorization",C.writeKey()).send(u).end(w)}else{C.trigger("error","Request not sent: URL length exceeds current browser limit, and XHR (POST) is not supported.")}}function w(E,D){p(E,D,s);s=B=null}function y(E){var D="Event not recorded: "+E;C.trigger("error",D);if(s){s.call(C,D,null);s=B=null}}return};function l(q,r){q+=d({api_key:this.writeKey(),data:j.encode(n.stringify(r)),modified:new Date().getTime()});return(q.length<b())?q:false}},{"../helpers/get-context":11,"../helpers/get-query-string":12,"../helpers/get-url-max-length":13,"../helpers/get-xhr-object":14,"../helpers/superagent-handle-response":15,"../helpers/superagent-request-types":16,"../index":17,"../utils/base64":22,"../utils/each":23,JSON2:2,superagent:6}],19:[function(c,b,f){var g=c("../index");var d=c("superagent");var i=c("../utils/each"),j=c("../helpers/get-context"),a=c("../helpers/get-xhr-object"),h=c("../helpers/superagent-request-types"),k=c("../helpers/superagent-handle-response");b.exports=function(p,r){var n=this,m=this.url("/events"),o={},l=r;if(!g.enabled){q.call(n,"Keen.enabled = false");return}if(!n.projectId()){q.call(n,"Missing projectId property");return}if(!n.writeKey()){q.call(n,"Missing writeKey property");return}if(arguments.length>2){q.call(n,"Incorrect arguments provided to #addEvents method");return}if(typeof p!=="object"||p instanceof Array){q.call(n,"Request payload must be an object");return}if(n.config.globalProperties){i(p,function(s,t){i(s,function(u,v){var w=n.config.globalProperties(t);i(u,function(y,x){w[x]=y});o[t].push(w)})})}else{o=p}if(a()||j()==="server"){d.post(m).set("Content-Type","application/json").set("Authorization",n.writeKey()).send(o).end(function(t,s){k(t,s,l);l=r=null})}else{n.trigger("error","Events not recorded: XHR support is required for batch upload")}function q(t){var s="Events not recorded: "+t;n.trigger("error",s);if(l){l.call(n,s,null);l=r=null}}return}},{"../helpers/get-context":11,"../helpers/get-xhr-object":14,"../helpers/superagent-handle-response":15,"../helpers/superagent-request-types":16,"../index":17,"../utils/each":23,superagent:6}],20:[function(b,c,a){c.exports=function(d){if(d&&typeof(d)=="function"){this.config.globalProperties=d}else{this.trigger("error","Invalid value for global properties: "+d)}}},{}],21:[function(b,c,a){var d=b("./addEvent");c.exports=function(k,f,n,l,m){var o=k,j=(o.currentTarget)?o.currentTarget:(o.srcElement||o.target),g=l||500,h=false,q="",p,i;if(j.getAttribute!==void 0){q=j.getAttribute("target")}else{if(j.target){q=j.target}}if((q=="_blank"||q=="blank")&&!o.metaKey){i=window.open("about:blank");i.document.location=j.href}if(j.nodeName==="A"){p=function(){if(!h&&!o.metaKey&&(q!=="_blank"&&q!=="blank")){h=true;window.location=j.href}}}else{if(j.nodeName==="FORM"){p=function(){if(!h){h=true;j.submit()}}}else{this.trigger("error","#trackExternalLink method not attached to an <a> or <form> DOM element")}}if(m){p=function(){if(!h){h=true;m()}}}d.call(this,f,n,p);setTimeout(p,g);if(!o.metaKey){return false}}},{"./addEvent":18}],22:[function(b,c,a){c.exports={map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(f){var d="",l=0,h=this.map,k,j,g,s,r,q,p;f=this.utf8.encode(f);while(l<f.length){k=f.charCodeAt(l++);j=f.charCodeAt(l++);g=f.charCodeAt(l++);s=(k>>2);r=(((k&3)<<4)|(j>>4));q=(isNaN(j)?64:((j&15)<<2)|(g>>6));p=(isNaN(j)||isNaN(g))?64:g&63;d=d+h.charAt(s)+h.charAt(r)+h.charAt(q)+h.charAt(p)}return d},decode:function(f){var d="",p=0,h=this.map,g=String.fromCharCode,t,s,r,q,l,k,j;f=f.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(p<f.length){t=h.indexOf(f.charAt(p++));s=h.indexOf(f.charAt(p++));r=h.indexOf(f.charAt(p++));q=h.indexOf(f.charAt(p++));l=(t<<2)|(s>>4);k=((s&15)<<4)|(r>>2);j=((r&3)<<6)|q;d=d+(g(l)+((r!=64)?g(k):""))+(((q!=64)?g(j):""))}return this.utf8.decode(d)},utf8:{encode:function(j){var f="",d=0,h=String.fromCharCode,g;while(d<j.length){g=j.charCodeAt(d++);f=f+((g<128)?h(g):((g>127)&&(g<2048))?(h((g>>6)|192)+h((g&63)|128)):(h((g>>12)|224)+h(((g>>6)&63)|128)+h((g&63)|128)))}return f},decode:function(k){var g="",f=0,j=String.fromCharCode,d,h;while(f<k.length){h=k.charCodeAt(f);g=g+((h<128)?[j(h),f++][0]:((h>191)&&(h<224))?[j(((h&31)<<6)|((d=k.charCodeAt(f+1))&63)),(f+=2)][0]:[j(((h&15)<<12)|(((d=k.charCodeAt(f+1))&63)<<6)|((c3=k.charCodeAt(f+2))&63)),(f+=3)][0])}return g}}}},{}],23:[function(b,c,a){c.exports=function(g,d,f){var h;if(!g){return 0}f=!f?g:f;if(g instanceof Array){for(h=0;h<g.length;h++){if(d.call(f,g[h],h,g)===false){return 0}}}else{for(h in g){if(g.hasOwnProperty(h)){if(d.call(f,g[h],h,g)===false){return 0}}}}return 1}},{}],24:[function(b,c,a){c.exports=function(f){for(var d=1;d<arguments.length;d++){for(var g in arguments[d]){f[g]=arguments[d][g]}}return f}},{}],25:[function(b,c,a){function d(l){var f={},g,i=/\+/g,h=/([^&=]+)=?([^&]*)/g,k=function(m){return decodeURIComponent(m.replace(i," "))},j=l.split("?")[1];while(!!(g=h.exec(j))){f[k(g[1])]=k(g[2])}return f}c.exports=d},{}],26:[function(b,c,a){(function(d){(function(i){if(typeof define==="function"&&define.amd){define("keen",[],function(){return i()})}if(typeof a==="object"&&typeof c!=="undefined"){c.exports=i()}var h=null;if(typeof window!=="undefined"){h=window}else{if(typeof d!=="undefined"){h=d}else{if(typeof self!=="undefined"){h=self}}}if(h){h.Keen=i()}})(function(){var f=b("./core"),g=b("./core/utils/extend");g(f.prototype,{addEvent:b("./core/lib/addEvent"),addEvents:b("./core/lib/addEvents"),setGlobalProperties:b("./core/lib/setGlobalProperties"),trackExternalLink:b("./core/lib/trackExternalLink")});f.Base64=b("./core/utils/base64");f.utils={domready:b("domready"),each:b("./core/utils/each"),extend:g,parseParams:b("./core/utils/parseParams")};if(f.loaded){setTimeout(function(){f.utils.domready(function(){f.emit("ready")})},0)}b("./core/async")();c.exports=f;return f})}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./core":17,"./core/async":9,"./core/lib/addEvent":18,"./core/lib/addEvents":19,"./core/lib/setGlobalProperties":20,"./core/lib/trackExternalLink":21,"./core/utils/base64":22,"./core/utils/each":23,"./core/utils/extend":24,"./core/utils/parseParams":25,domready:5}]},{},[26]);