From aea00324dfd5309d8c2b2b3b49fb82fe9dbc14b1 Mon Sep 17 00:00:00 2001 From: dustinlarimer Date: Sat, 24 Dec 2016 16:14:23 -0600 Subject: [PATCH 1/3] Install keen-core@0.1.2, drop resource mapping --- dist/keen-tracking.js | 45 ++++++++++++++++++++------------------- dist/keen-tracking.min.js | 4 ++-- lib/browser.js | 25 +++++++++++----------- lib/index.js | 15 ++++++------- package.json | 2 +- 5 files changed, 45 insertions(+), 46 deletions(-) diff --git a/dist/keen-tracking.js b/dist/keen-tracking.js index 795830a..813909a 100644 --- a/dist/keen-tracking.js +++ b/dist/keen-tracking.js @@ -2,18 +2,18 @@ (function (global){ (function(env) { 'use strict'; - var K = require('./'); + var KeenLibrary = require('./'); var each = require('./utils/each'); var extend = require('./utils/extend'); - var listener = require('./utils/listener')(K); - extend(K.prototype, require('./record-events-browser')); - extend(K.prototype, require('./defer-events')); - extend(K.prototype, { + var listener = require('./utils/listener')(KeenLibrary); + extend(KeenLibrary.prototype, require('./record-events-browser')); + extend(KeenLibrary.prototype, require('./defer-events')); + extend(KeenLibrary.prototype, { 'extendEvent': require('./extend-events').extendEvent, 'extendEvents': require('./extend-events').extendEvents }); - K.prototype.trackExternalLink = trackExternalLink; - extend(K.helpers, { + KeenLibrary.prototype.trackExternalLink = trackExternalLink; + extend(KeenLibrary.helpers, { 'getBrowserProfile' : require('./helpers/getBrowserProfile'), 'getDatetimeIndex' : require('./helpers/getDatetimeIndex'), 'getDomNodePath' : require('./helpers/getDomNodePath'), @@ -21,13 +21,13 @@ 'getUniqueId' : require('./helpers/getUniqueId'), 'getWindowProfile' : require('./helpers/getWindowProfile') }); - extend(K.utils, { + extend(KeenLibrary.utils, { 'cookie' : require('./utils/cookie'), 'deepExtend' : require('./utils/deepExtend'), 'listener' : listener, 'timer' : require('./utils/timer') }); - K.listenTo = function(listenerHash){ + KeenLibrary.listenTo = function(listenerHash){ each(listenerHash, function(callback, key){ var split = key.split(' '); var eventType = split[0], @@ -104,14 +104,14 @@ }; } if (typeof module !== 'undefined' && module.exports) { - module.exports = K; + module.exports = KeenLibrary; } if (typeof define !== 'undefined' && define.amd) { define('keen-tracking', [], function(){ - return K; + return KeenLibrary; }); } - env.Keen = K.extendLibrary(K); + env.Keen = KeenLibrary.extendLibrary(KeenLibrary); }).call(this, typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}); }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"./":10,"./defer-events":2,"./extend-events":3,"./helpers/getBrowserProfile":4,"./helpers/getDatetimeIndex":5,"./helpers/getDomNodePath":6,"./helpers/getScreenProfile":7,"./helpers/getUniqueId":8,"./helpers/getWindowProfile":9,"./record-events-browser":11,"./utils/cookie":13,"./utils/deepExtend":14,"./utils/each":15,"./utils/extend":16,"./utils/listener":17,"./utils/timer":19}],2:[function(require,module,exports){ @@ -331,13 +331,12 @@ module.exports = getWindowProfile; document.documentElement.offsetHeight/Width is a workaround for IE8 and below, where window.innerHeight/Width is undefined */ },{}],10:[function(require,module,exports){ -var K = require('keen-core'); +var KeenCore = require('keen-core'); var each = require('./utils/each'), extend = require('./utils/extend'), queue = require('./utils/queue'); -K.helpers = K.helpers || {}; -K.resources.events = '{protocol}://{host}/3.0/projects/{projectId}/events'; -K.on('client', function(client){ +KeenCore.helpers = KeenCore.helpers || {}; +KeenCore.on('client', function(client){ client.extensions = { events: [], collections: {} @@ -347,13 +346,13 @@ K.on('client', function(client){ client.recordDeferredEvents(); }); }); -K.prototype.writeKey = function(str){ +KeenCore.prototype.writeKey = function(str){ if (!arguments.length) return this.config.writeKey; this.config.writeKey = (str ? String(str) : null); return this; }; -K.prototype.setGlobalProperties = function(props){ - K.log('This method has been deprecated. Check out #extendEvents: https://github.com/keen/keen-tracking.js#extend-events'); +KeenCore.prototype.setGlobalProperties = function(props){ + KeenCore.log('This method has been deprecated. Check out #extendEvents: https://github.com/keen/keen-tracking.js#extend-events'); if (!props || typeof props !== 'function') { this.emit('error', 'Invalid value for global properties: ' + props); return; @@ -361,7 +360,7 @@ K.prototype.setGlobalProperties = function(props){ this.config.globalProperties = props; return this; }; -module.exports = K; +module.exports = KeenCore; },{"./utils/each":15,"./utils/extend":16,"./utils/queue":18,"keen-core":22}],11:[function(require,module,exports){ var Keen = require('./index'); var base64 = require('./utils/base64'); @@ -1282,7 +1281,9 @@ Emitter.prototype.hasListeners = function(event){ 'base' : '{protocol}://{host}', 'version' : '{protocol}://{host}/3.0', 'projects' : '{protocol}://{host}/3.0/projects', - 'projectId' : '{protocol}://{host}/3.0/projects/{projectId}' + 'projectId' : '{protocol}://{host}/3.0/projects/{projectId}', + 'events' : '{protocol}://{host}/3.0/projects/{projectId}/events', + 'queries' : '{protocol}://{host}/3.0/projects/{projectId}/queries' }); Client.utils = Client.utils || {}; extend(Client.utils, { @@ -1367,7 +1368,7 @@ Emitter.prototype.hasListeners = function(event){ }; Client.prototype.url = function(name){ var args = Array.prototype.slice.call(arguments, 1), - baseUrl = Client.resources.base || '{protocol}://{host}', + baseUrl = this.config.resources.base || '{protocol}://{host}', path; if (name && typeof name === 'string') { if (this.config.resources[name]) { diff --git a/dist/keen-tracking.min.js b/dist/keen-tracking.min.js index b92d16d..ad119f0 100644 --- a/dist/keen-tracking.min.js +++ b/dist/keen-tracking.min.js @@ -1,4 +1,4 @@ -(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 or
DOM element")}}if(s){v=function(){if(!n){n=true;s()}}}this.recordEvent(l,t,v);setTimeout(v,m);if(!u.metaKey){return false}}if(!Array.prototype.indexOf){Array.prototype.indexOf=function(m){var l=this.length>>>0;var n=Number(arguments[1])||0;n=(n<0)?Math.ceil(n):Math.floor(n);if(n<0){n+=l}for(;n0){o=JSON.parse(JSON.stringify(n.queue));n.queue=h();n.queue.options=o.options;n.emit("recordDeferredEvents",o.events);n.recordEvents(o.events,function(q,p){if(q){n.recordEvents(o.events)}else{o=void 0}})}return n}function i(o){var n="Event(s) not deferred: "+o;this.emit("error",n)}},{"./index":10,"./utils/each":15,"./utils/queue":18}],3:[function(d,c,g){var f=d("./utils/deepExtend");var i=d("./utils/each");c.exports={extendEvent:b,extendEvents:j,getExtendedEventBody:a};function b(k,l){if(arguments.length!==2||typeof k!=="string"||("object"!==typeof l&&"function"!==typeof l)){h.call(this,"Incorrect arguments provided to #extendEvent method");return}this.extensions.collections[k]=this.extensions.collections[k]||[];this.extensions.collections[k].push(l);this.emit("extendEvent",k,l);return this}function j(k){if(arguments.length!==1||("object"!==typeof k&&"function"!==typeof k)){h.call(this,"Incorrect arguments provided to #extendEvents method");return}this.extensions.events.push(k);this.emit("extendEvents",k);return this}function h(l){var k="Event(s) not extended: "+l;this.emit("error",k)}function a(l,k){if(k&&k.length>0){i(k,function(o,n){var m=(typeof o==="function")?o():o;f(l,m)})}return l}},{"./utils/deepExtend":14,"./utils/each":15}],4:[function(d,f,b){var a=d("./getScreenProfile"),g=d("./getWindowProfile");function c(){return{cookies:("undefined"!==typeof navigator.cookieEnabled)?navigator.cookieEnabled:false,codeName:navigator.appCodeName,language:navigator.language,name:navigator.appName,online:navigator.onLine,platform:navigator.platform,useragent:navigator.userAgent,version:navigator.appVersion,screen:a(),window:g()}}f.exports=c},{"./getScreenProfile":7,"./getWindowProfile":9}],5:[function(b,c,a){function d(f){var g=f||new Date();return{hour_of_day:g.getHours(),day_of_week:parseInt(1+g.getDay()),day_of_month:g.getDate(),month:parseInt(1+g.getMonth()),year:g.getFullYear()}}c.exports=d},{}],6:[function(c,d,a){function b(l){if(!l.nodeName){return""}var f=[];while(l.parentNode!=null){var k=0;var g=0;for(var j=0;j1){f.unshift(l.nodeName.toLowerCase()+":eq("+g+")")}else{f.unshift(l.nodeName.toLowerCase())}}l=l.parentNode}return f.slice(1).join(" > ")}d.exports=b},{}],7:[function(c,d,b){function a(){var h,f;if("undefined"==typeof window||!window.screen){return{}}h=["height","width","colorDepth","pixelDepth","availHeight","availWidth"];f={};for(var g=0;gwindow.innerHeight?"landscape":"portrait"};return f}d.exports=a},{}],8:[function(b,c,a){function d(){var f="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";return f.replace(/[xy]/g,function(i){var h=Math.random()*16|0,g=i=="x"?h:(h&3|8);return g.toString(16)})}c.exports=d},{}],9:[function(b,c,a){function d(){var f,h,g;if("undefined"==typeof document){return{}}f=document.body;h=document.documentElement;g={height:("innerHeight" in window)?window.innerHeight:document.documentElement.offsetHeight,width:("innerWidth" in window)?window.innerWidth:document.documentElement.offsetWidth,scrollHeight:Math.max(f.scrollHeight,f.offsetHeight,h.clientHeight,h.scrollHeight,h.offsetHeight)||null};if(window.screen){g.ratio={height:(window.screen.availHeight)?parseFloat((window.innerHeight/window.screen.availHeight).toFixed(2)):null,width:(window.screen.availWidth)?parseFloat((window.innerWidth/window.screen.availWidth).toFixed(2)):null}}return g}c.exports=d},{}],10:[function(d,f,c){var b=d("keen-core");var g=d("./utils/each"),h=d("./utils/extend"),a=d("./utils/queue");b.helpers=b.helpers||{};b.resources.events="{protocol}://{host}/3.0/projects/{projectId}/events";b.on("client",function(i){i.extensions={events:[],collections:{}};i.queue=a();i.queue.on("flush",function(){i.recordDeferredEvents()})});b.prototype.writeKey=function(i){if(!arguments.length){return this.config.writeKey}this.config.writeKey=(i?String(i):null);return this};b.prototype.setGlobalProperties=function(i){b.log("This method has been deprecated. Check out #extendEvents: https://github.com/keen/keen-tracking.js#extend-events");if(!i||typeof i!=="function"){this.emit("error","Invalid value for global properties: "+i);return}this.config.globalProperties=i;return this};f.exports=b},{"./utils/each":15,"./utils/extend":16,"./utils/queue":18,"keen-core":22}],11:[function(h,d,v){var c=h("./index");var b=h("./utils/base64");var f=h("./utils/each");var r=h("./utils/extend");var q=h("./extend-events");d.exports={recordEvent:k,recordEvents:i,addEvent:n,addEvents:l};function k(w,F,E,z){var x,C,A,G,B,D,y;x=this.url("events",encodeURIComponent(w));C={};A=E;y=("boolean"===typeof z)?z:true;if(!t.call(this,A)){return}if(!w||typeof w!=="string"){m.call(this,"Collection name must be a string.",A);return}if(this.config.globalProperties){C=this.config.globalProperties(w)}r(C,F);D={};q.getExtendedEventBody(D,this.extensions.events);q.getExtendedEventBody(D,this.extensions.collections[w]);q.getExtendedEventBody(D,[C]);this.emit("recordEvent",w,D);if(!c.enabled){m.call(this,"Keen.enabled is set to false.",A);return false}G=this.url("events",encodeURIComponent(w),{api_key:this.writeKey(),data:encodeURIComponent(b.encode(JSON.stringify(D))),modified:new Date().getTime()});B=G.length2){m.call(this,"Incorrect arguments provided to #recordEvents method",w);return}if(this.config.globalProperties){f(A,function(C,D){f(C,function(E,G){var F=x.config.globalProperties(D);A[D][G]=r(F,E)})})}y={};f(A,function(D,C){y[C]=y[C]||[];f(D,function(G,F){var E={};q.getExtendedEventBody(E,x.extensions.events);q.getExtendedEventBody(E,x.extensions.collections[C]);q.getExtendedEventBody(E,[G]);y[C].push(E)})});this.emit("recordEvents",y);if(!c.enabled){m.call(this,"Keen.enabled is set to false.",w);return false}if(p()){u.call(this,"POST",z,y,w)}else{}B=w=null;return this}function n(){this.emit("error","This method has been deprecated. Check out #recordEvent: https://github.com/keen/keen-tracking.js#record-a-single-event");k.apply(this,arguments)}function l(){this.emit("error","This method has been deprecated. Check out #recordEvents: https://github.com/keen/keen-tracking.js#record-multiple-events");i.apply(this,arguments)}function t(x){var w=x;x=null;if(!this.projectId()){m.call(this,"Keen.Client is missing a projectId property.",w);return false}if(!this.writeKey()){m.call(this,"Keen.Client is missing a writeKey property.",w);return false}return true}function m(y,w){var x="Event(s) not recorded: "+y;this.emit("error",x);if(w){w.call(this,x,null);w=null}}function s(){if("undefined"!==typeof window){if(navigator.userAgent.indexOf("MSIE")!==-1||navigator.appVersion.indexOf("Trident/")>0){return 2000}}return 16000}function o(w,y,x,z){if(p()){u.call(this,"POST",w,y,z)}else{m.call(this,x)}}function u(D,y,z,C){var x=this;var A;var B=p();var w=C;C=null;B.onreadystatechange=function(){var E;if(B.readyState==4){if(B.status>=200&&B.status<300){try{E=JSON.parse(B.responseText)}catch(F){c.emit("error","Could not parse HTTP response: "+B.responseText);if(w){w.call(x,B,null)}}if(w&&E){w.call(x,null,E)}}else{c.emit("error","HTTP request failed.");if(w){w.call(x,B,null)}}}};B.open(D,y,true);B.setRequestHeader("Authorization",x.writeKey());B.setRequestHeader("Content-Type","application/json");if(z){A=JSON.stringify(z)}if(D.toUpperCase()==="GET"){B.send()}if(D.toUpperCase()==="POST"){B.send(A)}}function a(w){var x=p();if(x){x.open("GET",w,false);x.send(null)}}function p(){var w="undefined"==typeof window?this:window;if(w.XMLHttpRequest&&("file:"!=w.location.protocol||!w.ActiveXObject)){return new XMLHttpRequest}else{try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(x){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(x){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(x){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(x){}}return false}function g(w,F){var G=this,z=F,B=new Date().getTime(),D=document.createElement("script"),E=document.getElementsByTagName("head")[0],C="keenJSONPCallback",A=false;F=null;C+=B;while(C in window){C+="a"}window[C]=function(H){if(A===true){return}A=true;if(z){z.call(G,null,H)}x()};D.src=w+"&jsonp="+C;E.appendChild(D);D.onreadystatechange=function(){if(A===false&&this.readyState==="loaded"){A=true;y();x()}};D.onerror=function(){if(A===false){A=true;y();x()}};function y(){if(z){z.call(G,"An error occurred!",null)}}function x(){window[C]=undefined;try{delete window[C]}catch(H){}E.removeChild(D)}}function j(A,B){var y=this,w=B,x=document.createElement("img"),z=false;B=null;x.onload=function(){z=true;if("naturalHeight" in this){if(this.naturalHeight+this.naturalWidth===0){this.onerror();return}}else{if(this.width+this.height===0){this.onerror();return}}if(w){w.call(y)}};x.onerror=function(){z=true;if(w){w.call(y,"An error occurred!",null)}};x.src=A+"&c=clv1"}},{"./extend-events":3,"./index":10,"./utils/base64":12,"./utils/each":15,"./utils/extend":16}],12:[function(b,c,a){c.exports=b("keen-core/lib/utils/base64")},{"keen-core/lib/utils/base64":23}],13:[function(b,f,a){var d=b("js-cookie");var g=b("./extend");f.exports=c;function c(h){if(!arguments.length){return}if(this instanceof c===false){return new c(h)}this.config={key:h,options:{expires:365}};this.data=this.get();return this}c.prototype.get=function(i){var h={};if(d.get(this.config.key)){h=d.getJSON(this.config.key)}if(i&&typeof h==="object"&&typeof h!==null){return(typeof h[i]!=="undefined")?h[i]:null}else{return h}};c.prototype.set=function(i,h){if(!arguments.length||!this.enabled()){return this}if(typeof i==="string"&&arguments.length===2){this.data[i]=h?h:null}else{if(typeof i==="object"&&arguments.length===1){g(this.data,i)}}d.set(this.config.key,this.data,this.config.options);return this};c.prototype.expire=function(h){if(h){d.set(this.config.key,this.data,g(this.config.options,{expires:h}))}else{d.remove(this.config.key);this.data={}}return this};c.prototype.options=function(h){if(!arguments.length){return this.config.options}this.config.options=(typeof h==="object")?h:{};return this};c.prototype.enabled=function(){return navigator.cookieEnabled}},{"./extend":16,"js-cookie":21}],14:[function(c,d,a){d.exports=b;function b(k){for(var h=1;h0&&this.interval>=this.config.interval)||this.capacity>=this.config.capacity){this.emit("flush");this.interval=0}}f(a.prototype)},{"component-emitter":20}],19:[function(b,c,a){c.exports=d;function d(f){if(this instanceof d===false){return new d(f)}this.count=f||0;return this}d.prototype.start=function(){var f=this;this.pause();this.interval=setInterval(function(){f.count++},1000);return this};d.prototype.pause=function(){clearInterval(this.interval);return this};d.prototype.value=function(){return this.count};d.prototype.clear=function(){this.count=0;return this}},{}],20:[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(i,h){function g(){this.off(i,g);h.apply(this,arguments)}g.fn=h;this.on(i,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 or DOM element")}}if(s){v=function(){if(!n){n=true;s()}}}this.recordEvent(l,t,v);setTimeout(v,m);if(!u.metaKey){return false}}if(!Array.prototype.indexOf){Array.prototype.indexOf=function(m){var l=this.length>>>0;var n=Number(arguments[1])||0;n=(n<0)?Math.ceil(n):Math.floor(n);if(n<0){n+=l}for(;n0){o=JSON.parse(JSON.stringify(n.queue));n.queue=h();n.queue.options=o.options;n.emit("recordDeferredEvents",o.events);n.recordEvents(o.events,function(q,p){if(q){n.recordEvents(o.events)}else{o=void 0}})}return n}function i(o){var n="Event(s) not deferred: "+o;this.emit("error",n)}},{"./index":10,"./utils/each":15,"./utils/queue":18}],3:[function(d,c,g){var f=d("./utils/deepExtend");var i=d("./utils/each");c.exports={extendEvent:b,extendEvents:j,getExtendedEventBody:a};function b(k,l){if(arguments.length!==2||typeof k!=="string"||("object"!==typeof l&&"function"!==typeof l)){h.call(this,"Incorrect arguments provided to #extendEvent method");return}this.extensions.collections[k]=this.extensions.collections[k]||[];this.extensions.collections[k].push(l);this.emit("extendEvent",k,l);return this}function j(k){if(arguments.length!==1||("object"!==typeof k&&"function"!==typeof k)){h.call(this,"Incorrect arguments provided to #extendEvents method");return}this.extensions.events.push(k);this.emit("extendEvents",k);return this}function h(l){var k="Event(s) not extended: "+l;this.emit("error",k)}function a(l,k){if(k&&k.length>0){i(k,function(o,n){var m=(typeof o==="function")?o():o;f(l,m)})}return l}},{"./utils/deepExtend":14,"./utils/each":15}],4:[function(d,f,b){var a=d("./getScreenProfile"),g=d("./getWindowProfile");function c(){return{cookies:("undefined"!==typeof navigator.cookieEnabled)?navigator.cookieEnabled:false,codeName:navigator.appCodeName,language:navigator.language,name:navigator.appName,online:navigator.onLine,platform:navigator.platform,useragent:navigator.userAgent,version:navigator.appVersion,screen:a(),window:g()}}f.exports=c},{"./getScreenProfile":7,"./getWindowProfile":9}],5:[function(b,c,a){function d(f){var g=f||new Date();return{hour_of_day:g.getHours(),day_of_week:parseInt(1+g.getDay()),day_of_month:g.getDate(),month:parseInt(1+g.getMonth()),year:g.getFullYear()}}c.exports=d},{}],6:[function(c,d,a){function b(l){if(!l.nodeName){return""}var f=[];while(l.parentNode!=null){var k=0;var g=0;for(var j=0;j1){f.unshift(l.nodeName.toLowerCase()+":eq("+g+")")}else{f.unshift(l.nodeName.toLowerCase())}}l=l.parentNode}return f.slice(1).join(" > ")}d.exports=b},{}],7:[function(c,d,b){function a(){var h,f;if("undefined"==typeof window||!window.screen){return{}}h=["height","width","colorDepth","pixelDepth","availHeight","availWidth"];f={};for(var g=0;gwindow.innerHeight?"landscape":"portrait"};return f}d.exports=a},{}],8:[function(b,c,a){function d(){var f="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";return f.replace(/[xy]/g,function(i){var h=Math.random()*16|0,g=i=="x"?h:(h&3|8);return g.toString(16)})}c.exports=d},{}],9:[function(b,c,a){function d(){var f,h,g;if("undefined"==typeof document){return{}}f=document.body;h=document.documentElement;g={height:("innerHeight" in window)?window.innerHeight:document.documentElement.offsetHeight,width:("innerWidth" in window)?window.innerWidth:document.documentElement.offsetWidth,scrollHeight:Math.max(f.scrollHeight,f.offsetHeight,h.clientHeight,h.scrollHeight,h.offsetHeight)||null};if(window.screen){g.ratio={height:(window.screen.availHeight)?parseFloat((window.innerHeight/window.screen.availHeight).toFixed(2)):null,width:(window.screen.availWidth)?parseFloat((window.innerWidth/window.screen.availWidth).toFixed(2)):null}}return g}c.exports=d},{}],10:[function(d,f,b){var c=d("keen-core");var g=d("./utils/each"),h=d("./utils/extend"),a=d("./utils/queue");c.helpers=c.helpers||{};c.on("client",function(i){i.extensions={events:[],collections:{}};i.queue=a();i.queue.on("flush",function(){i.recordDeferredEvents()})});c.prototype.writeKey=function(i){if(!arguments.length){return this.config.writeKey}this.config.writeKey=(i?String(i):null);return this};c.prototype.setGlobalProperties=function(i){c.log("This method has been deprecated. Check out #extendEvents: https://github.com/keen/keen-tracking.js#extend-events");if(!i||typeof i!=="function"){this.emit("error","Invalid value for global properties: "+i);return}this.config.globalProperties=i;return this};f.exports=c},{"./utils/each":15,"./utils/extend":16,"./utils/queue":18,"keen-core":22}],11:[function(h,d,v){var c=h("./index");var b=h("./utils/base64");var f=h("./utils/each");var r=h("./utils/extend");var q=h("./extend-events");d.exports={recordEvent:k,recordEvents:i,addEvent:n,addEvents:l};function k(w,F,E,z){var x,C,A,G,B,D,y;x=this.url("events",encodeURIComponent(w));C={};A=E;y=("boolean"===typeof z)?z:true;if(!t.call(this,A)){return}if(!w||typeof w!=="string"){m.call(this,"Collection name must be a string.",A);return}if(this.config.globalProperties){C=this.config.globalProperties(w)}r(C,F);D={};q.getExtendedEventBody(D,this.extensions.events);q.getExtendedEventBody(D,this.extensions.collections[w]);q.getExtendedEventBody(D,[C]);this.emit("recordEvent",w,D);if(!c.enabled){m.call(this,"Keen.enabled is set to false.",A);return false}G=this.url("events",encodeURIComponent(w),{api_key:this.writeKey(),data:encodeURIComponent(b.encode(JSON.stringify(D))),modified:new Date().getTime()});B=G.length2){m.call(this,"Incorrect arguments provided to #recordEvents method",w);return}if(this.config.globalProperties){f(A,function(C,D){f(C,function(E,G){var F=x.config.globalProperties(D);A[D][G]=r(F,E)})})}y={};f(A,function(D,C){y[C]=y[C]||[];f(D,function(G,F){var E={};q.getExtendedEventBody(E,x.extensions.events);q.getExtendedEventBody(E,x.extensions.collections[C]);q.getExtendedEventBody(E,[G]);y[C].push(E)})});this.emit("recordEvents",y);if(!c.enabled){m.call(this,"Keen.enabled is set to false.",w);return false}if(p()){u.call(this,"POST",z,y,w)}else{}B=w=null;return this}function n(){this.emit("error","This method has been deprecated. Check out #recordEvent: https://github.com/keen/keen-tracking.js#record-a-single-event");k.apply(this,arguments)}function l(){this.emit("error","This method has been deprecated. Check out #recordEvents: https://github.com/keen/keen-tracking.js#record-multiple-events");i.apply(this,arguments)}function t(x){var w=x;x=null;if(!this.projectId()){m.call(this,"Keen.Client is missing a projectId property.",w);return false}if(!this.writeKey()){m.call(this,"Keen.Client is missing a writeKey property.",w);return false}return true}function m(y,w){var x="Event(s) not recorded: "+y;this.emit("error",x);if(w){w.call(this,x,null);w=null}}function s(){if("undefined"!==typeof window){if(navigator.userAgent.indexOf("MSIE")!==-1||navigator.appVersion.indexOf("Trident/")>0){return 2000}}return 16000}function o(w,y,x,z){if(p()){u.call(this,"POST",w,y,z)}else{m.call(this,x)}}function u(D,y,z,C){var x=this;var A;var B=p();var w=C;C=null;B.onreadystatechange=function(){var E;if(B.readyState==4){if(B.status>=200&&B.status<300){try{E=JSON.parse(B.responseText)}catch(F){c.emit("error","Could not parse HTTP response: "+B.responseText);if(w){w.call(x,B,null)}}if(w&&E){w.call(x,null,E)}}else{c.emit("error","HTTP request failed.");if(w){w.call(x,B,null)}}}};B.open(D,y,true);B.setRequestHeader("Authorization",x.writeKey());B.setRequestHeader("Content-Type","application/json");if(z){A=JSON.stringify(z)}if(D.toUpperCase()==="GET"){B.send()}if(D.toUpperCase()==="POST"){B.send(A)}}function a(w){var x=p();if(x){x.open("GET",w,false);x.send(null)}}function p(){var w="undefined"==typeof window?this:window;if(w.XMLHttpRequest&&("file:"!=w.location.protocol||!w.ActiveXObject)){return new XMLHttpRequest}else{try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(x){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(x){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(x){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(x){}}return false}function g(w,F){var G=this,z=F,B=new Date().getTime(),D=document.createElement("script"),E=document.getElementsByTagName("head")[0],C="keenJSONPCallback",A=false;F=null;C+=B;while(C in window){C+="a"}window[C]=function(H){if(A===true){return}A=true;if(z){z.call(G,null,H)}x()};D.src=w+"&jsonp="+C;E.appendChild(D);D.onreadystatechange=function(){if(A===false&&this.readyState==="loaded"){A=true;y();x()}};D.onerror=function(){if(A===false){A=true;y();x()}};function y(){if(z){z.call(G,"An error occurred!",null)}}function x(){window[C]=undefined;try{delete window[C]}catch(H){}E.removeChild(D)}}function j(A,B){var y=this,w=B,x=document.createElement("img"),z=false;B=null;x.onload=function(){z=true;if("naturalHeight" in this){if(this.naturalHeight+this.naturalWidth===0){this.onerror();return}}else{if(this.width+this.height===0){this.onerror();return}}if(w){w.call(y)}};x.onerror=function(){z=true;if(w){w.call(y,"An error occurred!",null)}};x.src=A+"&c=clv1"}},{"./extend-events":3,"./index":10,"./utils/base64":12,"./utils/each":15,"./utils/extend":16}],12:[function(b,c,a){c.exports=b("keen-core/lib/utils/base64")},{"keen-core/lib/utils/base64":23}],13:[function(b,f,a){var d=b("js-cookie");var g=b("./extend");f.exports=c;function c(h){if(!arguments.length){return}if(this instanceof c===false){return new c(h)}this.config={key:h,options:{expires:365}};this.data=this.get();return this}c.prototype.get=function(i){var h={};if(d.get(this.config.key)){h=d.getJSON(this.config.key)}if(i&&typeof h==="object"&&typeof h!==null){return(typeof h[i]!=="undefined")?h[i]:null}else{return h}};c.prototype.set=function(i,h){if(!arguments.length||!this.enabled()){return this}if(typeof i==="string"&&arguments.length===2){this.data[i]=h?h:null}else{if(typeof i==="object"&&arguments.length===1){g(this.data,i)}}d.set(this.config.key,this.data,this.config.options);return this};c.prototype.expire=function(h){if(h){d.set(this.config.key,this.data,g(this.config.options,{expires:h}))}else{d.remove(this.config.key);this.data={}}return this};c.prototype.options=function(h){if(!arguments.length){return this.config.options}this.config.options=(typeof h==="object")?h:{};return this};c.prototype.enabled=function(){return navigator.cookieEnabled}},{"./extend":16,"js-cookie":21}],14:[function(c,d,a){d.exports=b;function b(k){for(var h=1;h0&&this.interval>=this.config.interval)||this.capacity>=this.config.capacity){this.emit("flush");this.interval=0}}f(a.prototype)},{"component-emitter":20}],19:[function(b,c,a){c.exports=d;function d(f){if(this instanceof d===false){return new d(f)}this.count=f||0;return this}d.prototype.start=function(){var f=this;this.pause();this.interval=setInterval(function(){f.count++},1000);return this};d.prototype.pause=function(){clearInterval(this.interval);return this};d.prototype.value=function(){return this.count};d.prototype.clear=function(){this.count=0;return this}},{}],20:[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(i,h){function g(){this.off(i,g);h.apply(this,arguments)}g.fn=h;this.on(i,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;h1){n=f({path:"/"},g.defaults,n);if(typeof n.expires==="number"){var l=new Date();l.setMilliseconds(l.getMilliseconds()+n.expires*86400000);n.expires=l}try{u=JSON.stringify(q);if(/^[\{\[]/.test(u)){q=u}}catch(p){}if(!h.write){q=encodeURIComponent(String(q)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent)}else{q=h.write(q,r)}r=encodeURIComponent(String(r));r=r.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent);r=r.replace(/[\(\)]/g,escape);return(document.cookie=[r,"=",q,n.expires&&"; expires="+n.expires.toUTCString(),n.path&&"; path="+n.path,n.domain&&"; domain="+n.domain,n.secure?"; secure":""].join(""))}if(!r){u={}}var t=document.cookie?document.cookie.split("; "):[];var s=/(%[0-9A-Z]{2})+/g;var o=0;for(;o-1){r.protocol=document.location.protocol.replace(":","")}if(r.host){r.host.replace(/.*?:\/\//g,"")}m(this.config,r);return this};h.prototype.masterKey=function(r){if(!arguments.length){return this.config.masterKey}this.config.masterKey=r?String(r):null;return this};h.prototype.projectId=function(r){if(!arguments.length){return this.config.projectId}this.config.projectId=(r?String(r):null);return this};h.prototype.resources=function(s){if(!arguments.length){return this.config.resources}var r=this;if(typeof s==="object"){o(s,function(u,t){r.config.resources[t]=(u?u:null)})}return r};h.prototype.url=function(s){var r=Array.prototype.slice.call(arguments,1),t=h.resources.base||"{protocol}://{host}",u;if(s&&typeof s==="string"){if(this.config.resources[s]){u=this.config.resources[s]}else{u=t+s}}else{u=t}o(this.config,function(w,v){if(typeof w!=="object"){u=u.replace("{"+v+"}",w)}});o(r,function(v,w){if(typeof v==="string"){u+="/"+v}else{if(typeof v==="object"){u+="?";o(v,function(y,x){u+=x+"="+y+"&"});u=u.slice(0,-1)}}});return u};g(function(){h.loaded=true;h.emit("ready")});function g(s){if(h.loaded||typeof document==="undefined"){s();return}if(document.readyState==null&&document.addEventListener){document.addEventListener("DOMContentLoaded",function r(){document.removeEventListener("DOMContentLoaded",r,false);document.readyState="complete"},false);document.readyState="loading"}f(s)}function f(r){if(/in/.test(document.readyState)){setTimeout(function(){f(r)},9)}else{r()}}function p(r){return typeof r!=="undefined"}function i(r){return typeof r==="undefined"}c.exports=h}).call(this,typeof window!=="undefined"?window:typeof d!=="undefined"?d:typeof self!=="undefined"?self:{})}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./utils/each":24,"./utils/extend":25,"./utils/parse-params":26,"./utils/serialize":27,"component-emitter":20}],23:[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>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>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(d127)&&(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(f191)&&(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}}}},{}],24:[function(b,c,a){c.exports=d;function d(h,f,g){var i;if(!h){return 0}g=!g?h:g;if(h instanceof Array){for(i=0;i1){n=f({path:"/"},g.defaults,n);if(typeof n.expires==="number"){var l=new Date();l.setMilliseconds(l.getMilliseconds()+n.expires*86400000);n.expires=l}try{u=JSON.stringify(q);if(/^[\{\[]/.test(u)){q=u}}catch(p){}if(!h.write){q=encodeURIComponent(String(q)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent)}else{q=h.write(q,r)}r=encodeURIComponent(String(r));r=r.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent);r=r.replace(/[\(\)]/g,escape);return(document.cookie=[r,"=",q,n.expires&&"; expires="+n.expires.toUTCString(),n.path&&"; path="+n.path,n.domain&&"; domain="+n.domain,n.secure?"; secure":""].join(""))}if(!r){u={}}var t=document.cookie?document.cookie.split("; "):[];var s=/(%[0-9A-Z]{2})+/g;var o=0;for(;o-1){r.protocol=document.location.protocol.replace(":","")}if(r.host){r.host.replace(/.*?:\/\//g,"")}m(this.config,r);return this};h.prototype.masterKey=function(r){if(!arguments.length){return this.config.masterKey}this.config.masterKey=r?String(r):null;return this};h.prototype.projectId=function(r){if(!arguments.length){return this.config.projectId}this.config.projectId=(r?String(r):null);return this};h.prototype.resources=function(s){if(!arguments.length){return this.config.resources}var r=this;if(typeof s==="object"){o(s,function(u,t){r.config.resources[t]=(u?u:null)})}return r};h.prototype.url=function(s){var r=Array.prototype.slice.call(arguments,1),t=this.config.resources.base||"{protocol}://{host}",u;if(s&&typeof s==="string"){if(this.config.resources[s]){u=this.config.resources[s]}else{u=t+s}}else{u=t}o(this.config,function(w,v){if(typeof w!=="object"){u=u.replace("{"+v+"}",w)}});o(r,function(v,w){if(typeof v==="string"){u+="/"+v}else{if(typeof v==="object"){u+="?";o(v,function(y,x){u+=x+"="+y+"&"});u=u.slice(0,-1)}}});return u};g(function(){h.loaded=true;h.emit("ready")});function g(s){if(h.loaded||typeof document==="undefined"){s();return}if(document.readyState==null&&document.addEventListener){document.addEventListener("DOMContentLoaded",function r(){document.removeEventListener("DOMContentLoaded",r,false);document.readyState="complete"},false);document.readyState="loading"}f(s)}function f(r){if(/in/.test(document.readyState)){setTimeout(function(){f(r)},9)}else{r()}}function p(r){return typeof r!=="undefined"}function i(r){return typeof r==="undefined"}c.exports=h}).call(this,typeof window!=="undefined"?window:typeof d!=="undefined"?d:typeof self!=="undefined"?self:{})}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./utils/each":24,"./utils/extend":25,"./utils/parse-params":26,"./utils/serialize":27,"component-emitter":20}],23:[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>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>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(d127)&&(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(f191)&&(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}}}},{}],24:[function(b,c,a){c.exports=d;function d(h,f,g){var i;if(!h){return 0}g=!g?h:g;if(h instanceof Array){for(i=0;i Date: Sat, 24 Dec 2016 16:19:53 -0600 Subject: [PATCH 2/3] Version bump, update CHANGELOG and README --- CHANGELOG.md | 7 +++++++ README.md | 2 +- package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66bfad1..44cf423 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ **BREAKING:** **CHANGE:** --> + +# 1.1.1 Fix Resource Mapping + +**NEW:** +* This patch installs `keen-core@0.1.2` and removes the internal `events` resource mapping (now in keen-core) to fix an issue with prototype inheritance and state. + + # 1.1.1 Global Namespace Fix (Pt2) diff --git a/README.md b/README.md index 38160de..deb224a 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ Copy/paste this snippet of JavaScript above the `` tag of your page to lo // Loads the library asynchronously from any URI !function(name,path,ctx){ var latest,prev=name!=='Keen'&&window.Keen?window.Keen:false;ctx[name]=ctx[name]||{ready:function(fn){var h=document.getElementsByTagName('head')[0],s=document.createElement('script'),w=window,loaded;s.onload=s.onerror=s.onreadystatechange=function(){if((s.readyState&&!(/^c|loade/.test(s.readyState)))||loaded){return}s.onload=s.onreadystatechange=null;loaded=1;latest=w.Keen;if(prev){w.Keen=prev}else{try{delete w.Keen}catch(e){w.Keen=void 0}}ctx[name]=latest;ctx[name].ready(fn)};s.async=1;s.src=path;h.parentNode.insertBefore(s,h)}} -}('Keen','https://d26b395fwzu5fz.cloudfront.net/keen-tracking-1.1.1.min.js',this); +}('Keen','https://d26b395fwzu5fz.cloudfront.net/keen-tracking-1.1.2.min.js',this); // Executes when the library is loaded and ready Keen.ready(function(){ diff --git a/package.json b/package.json index 27be8d9..b85fb75 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "keen-tracking", - "version": "1.1.1", + "version": "1.1.2", "description": "Data Collection SDK for Keen IO", "main": "lib/server.js", "browser": "lib/browser.js", From 254f6aade2f87ec4a9e7c92bc89c9b93b44491c4 Mon Sep 17 00:00:00 2001 From: dustinlarimer Date: Sat, 24 Dec 2016 16:26:32 -0600 Subject: [PATCH 3/3] Commit built files --- dist/keen-tracking.js | 2 +- dist/keen-tracking.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/keen-tracking.js b/dist/keen-tracking.js index 813909a..3ff3154 100644 --- a/dist/keen-tracking.js +++ b/dist/keen-tracking.js @@ -1273,7 +1273,7 @@ Emitter.prototype.hasListeners = function(event){ debug: false, enabled: true, loaded: false, - version: '1.1.1' + version: '1.1.2' }); Client.helpers = Client.helpers || {}; Client.resources = Client.resources || {}; diff --git a/dist/keen-tracking.min.js b/dist/keen-tracking.min.js index ad119f0..a29ab13 100644 --- a/dist/keen-tracking.min.js +++ b/dist/keen-tracking.min.js @@ -6,4 +6,4 @@ * Copyright 2006, 2015 Klaus Hartl & Fagner Brack * Released under the MIT license */ -(function(d){if(false){define(d)}else{if(typeof a==="object"){c.exports=d()}else{var g=window.Cookies;var f=window.Cookies=d();f.noConflict=function(){window.Cookies=g;return f}}}}(function(){function f(){var k=0;var g={};for(;k1){n=f({path:"/"},g.defaults,n);if(typeof n.expires==="number"){var l=new Date();l.setMilliseconds(l.getMilliseconds()+n.expires*86400000);n.expires=l}try{u=JSON.stringify(q);if(/^[\{\[]/.test(u)){q=u}}catch(p){}if(!h.write){q=encodeURIComponent(String(q)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent)}else{q=h.write(q,r)}r=encodeURIComponent(String(r));r=r.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent);r=r.replace(/[\(\)]/g,escape);return(document.cookie=[r,"=",q,n.expires&&"; expires="+n.expires.toUTCString(),n.path&&"; path="+n.path,n.domain&&"; domain="+n.domain,n.secure?"; secure":""].join(""))}if(!r){u={}}var t=document.cookie?document.cookie.split("; "):[];var s=/(%[0-9A-Z]{2})+/g;var o=0;for(;o-1){r.protocol=document.location.protocol.replace(":","")}if(r.host){r.host.replace(/.*?:\/\//g,"")}m(this.config,r);return this};h.prototype.masterKey=function(r){if(!arguments.length){return this.config.masterKey}this.config.masterKey=r?String(r):null;return this};h.prototype.projectId=function(r){if(!arguments.length){return this.config.projectId}this.config.projectId=(r?String(r):null);return this};h.prototype.resources=function(s){if(!arguments.length){return this.config.resources}var r=this;if(typeof s==="object"){o(s,function(u,t){r.config.resources[t]=(u?u:null)})}return r};h.prototype.url=function(s){var r=Array.prototype.slice.call(arguments,1),t=this.config.resources.base||"{protocol}://{host}",u;if(s&&typeof s==="string"){if(this.config.resources[s]){u=this.config.resources[s]}else{u=t+s}}else{u=t}o(this.config,function(w,v){if(typeof w!=="object"){u=u.replace("{"+v+"}",w)}});o(r,function(v,w){if(typeof v==="string"){u+="/"+v}else{if(typeof v==="object"){u+="?";o(v,function(y,x){u+=x+"="+y+"&"});u=u.slice(0,-1)}}});return u};g(function(){h.loaded=true;h.emit("ready")});function g(s){if(h.loaded||typeof document==="undefined"){s();return}if(document.readyState==null&&document.addEventListener){document.addEventListener("DOMContentLoaded",function r(){document.removeEventListener("DOMContentLoaded",r,false);document.readyState="complete"},false);document.readyState="loading"}f(s)}function f(r){if(/in/.test(document.readyState)){setTimeout(function(){f(r)},9)}else{r()}}function p(r){return typeof r!=="undefined"}function i(r){return typeof r==="undefined"}c.exports=h}).call(this,typeof window!=="undefined"?window:typeof d!=="undefined"?d:typeof self!=="undefined"?self:{})}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./utils/each":24,"./utils/extend":25,"./utils/parse-params":26,"./utils/serialize":27,"component-emitter":20}],23:[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>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>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(d127)&&(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(f191)&&(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}}}},{}],24:[function(b,c,a){c.exports=d;function d(h,f,g){var i;if(!h){return 0}g=!g?h:g;if(h instanceof Array){for(i=0;i1){n=f({path:"/"},g.defaults,n);if(typeof n.expires==="number"){var l=new Date();l.setMilliseconds(l.getMilliseconds()+n.expires*86400000);n.expires=l}try{u=JSON.stringify(q);if(/^[\{\[]/.test(u)){q=u}}catch(p){}if(!h.write){q=encodeURIComponent(String(q)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent)}else{q=h.write(q,r)}r=encodeURIComponent(String(r));r=r.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent);r=r.replace(/[\(\)]/g,escape);return(document.cookie=[r,"=",q,n.expires&&"; expires="+n.expires.toUTCString(),n.path&&"; path="+n.path,n.domain&&"; domain="+n.domain,n.secure?"; secure":""].join(""))}if(!r){u={}}var t=document.cookie?document.cookie.split("; "):[];var s=/(%[0-9A-Z]{2})+/g;var o=0;for(;o-1){r.protocol=document.location.protocol.replace(":","")}if(r.host){r.host.replace(/.*?:\/\//g,"")}m(this.config,r);return this};h.prototype.masterKey=function(r){if(!arguments.length){return this.config.masterKey}this.config.masterKey=r?String(r):null;return this};h.prototype.projectId=function(r){if(!arguments.length){return this.config.projectId}this.config.projectId=(r?String(r):null);return this};h.prototype.resources=function(s){if(!arguments.length){return this.config.resources}var r=this;if(typeof s==="object"){o(s,function(u,t){r.config.resources[t]=(u?u:null)})}return r};h.prototype.url=function(s){var r=Array.prototype.slice.call(arguments,1),t=this.config.resources.base||"{protocol}://{host}",u;if(s&&typeof s==="string"){if(this.config.resources[s]){u=this.config.resources[s]}else{u=t+s}}else{u=t}o(this.config,function(w,v){if(typeof w!=="object"){u=u.replace("{"+v+"}",w)}});o(r,function(v,w){if(typeof v==="string"){u+="/"+v}else{if(typeof v==="object"){u+="?";o(v,function(y,x){u+=x+"="+y+"&"});u=u.slice(0,-1)}}});return u};g(function(){h.loaded=true;h.emit("ready")});function g(s){if(h.loaded||typeof document==="undefined"){s();return}if(document.readyState==null&&document.addEventListener){document.addEventListener("DOMContentLoaded",function r(){document.removeEventListener("DOMContentLoaded",r,false);document.readyState="complete"},false);document.readyState="loading"}f(s)}function f(r){if(/in/.test(document.readyState)){setTimeout(function(){f(r)},9)}else{r()}}function p(r){return typeof r!=="undefined"}function i(r){return typeof r==="undefined"}c.exports=h}).call(this,typeof window!=="undefined"?window:typeof d!=="undefined"?d:typeof self!=="undefined"?self:{})}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./utils/each":24,"./utils/extend":25,"./utils/parse-params":26,"./utils/serialize":27,"component-emitter":20}],23:[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>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>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(d127)&&(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(f191)&&(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}}}},{}],24:[function(b,c,a){c.exports=d;function d(h,f,g){var i;if(!h){return 0}g=!g?h:g;if(h instanceof Array){for(i=0;i