diff --git a/dist/keen-tracking.js b/dist/keen-tracking.js index 469e04f..d9bf68b 100644 --- a/dist/keen-tracking.js +++ b/dist/keen-tracking.js @@ -714,7 +714,7 @@ function sendBeacon(url, callback){ },{"./extend-events":3,"./index":10,"./utils/base64":12,"./utils/each":15,"./utils/extend":16}],12:[function(require,module,exports){ module.exports = require('keen-core/lib/utils/base64'); },{"keen-core/lib/utils/base64":23}],13:[function(require,module,exports){ -var Cookies = require('cookies-js'); +var Cookies = require('js-cookie'); var extend = require('./extend'); module.exports = cookie; function cookie(str){ @@ -724,7 +724,9 @@ function cookie(str){ } this.config = { key: str, - options: {} + options: { + expires: 365 + } }; this.data = this.get(); return this; @@ -732,10 +734,10 @@ function cookie(str){ cookie.prototype.get = function(str){ var data = {}; if (Cookies.get(this.config.key)) { - data = JSON.parse( decodeURIComponent(Cookies.get(this.config.key)) ); + data = JSON.parse(Cookies.get(this.config.key)); } if (str) { - return ('undefined' !== typeof data[str]) ? data[str] : null; + return (typeof data[str] !== 'undefined') ? data[str] : null; } else { return data; @@ -743,18 +745,22 @@ cookie.prototype.get = function(str){ }; cookie.prototype.set = function(str, value){ if (!arguments.length || !this.enabled()) return this; - if ('string' === typeof str && arguments.length === 2) { + if (typeof str === 'string' && arguments.length === 2) { this.data[str] = value ? value : null; } - else if ('object' === typeof str && arguments.length === 1) { + else if (typeof str === 'object' && arguments.length === 1) { extend(this.data, str); } - Cookies.set(this.config.key, encodeURIComponent( JSON.stringify(this.data) ), this.config.options); + Cookies.set(this.config.key, this.data, this.config.options); return this; }; -cookie.prototype.expire = function(){ - Cookies.expire(this.config.key); - this.data = {}; +cookie.prototype.expire = function(daysUntilExpire){ + if (daysUntilExpire) { + Cookies.set(this.config.key, this.data, extend(this.config.options, { expires: daysUntilExpire })); + } else { + Cookies.remove(this.config.key); + this.data = {}; + } return this; }; cookie.prototype.options = function(obj){ @@ -763,9 +769,9 @@ cookie.prototype.options = function(obj){ return this; }; cookie.prototype.enabled = function(){ - return Cookies.enabled; + return navigator.cookieEnabled; }; -},{"./extend":16,"cookies-js":21}],14:[function(require,module,exports){ +},{"./extend":16,"js-cookie":21}],14:[function(require,module,exports){ module.exports = deepExtend; function deepExtend(target){ for (var i = 1; i < arguments.length; i++) { @@ -1160,7 +1166,123 @@ Emitter.prototype.hasListeners = function(event){ return !! this.listeners(event).length; }; },{}],21:[function(require,module,exports){ -/* * Cookies.js - 1.2.1 * https://github.com/ScottHamper/Cookies * * This is free and unencumbered software released into the public domain. */ (function (global, undefined) { 'use strict'; var factory = function (window) { if (typeof window.document !== 'object') { throw new Error('Cookies.js requires a `window` with a `document` object'); } var Cookies = function (key, value, options) { return arguments.length === 1 ? Cookies.get(key) : Cookies.set(key, value, options); }; Cookies._document = window.document; Cookies._cacheKeyPrefix = 'cookey.'; Cookies._maxExpireDate = new Date('Fri, 31 Dec 9999 23:59:59 UTC'); Cookies.defaults = { path: '/', secure: false }; Cookies.get = function (key) { if (Cookies._cachedDocumentCookie !== Cookies._document.cookie) { Cookies._renewCache(); } return Cookies._cache[Cookies._cacheKeyPrefix + key]; }; Cookies.set = function (key, value, options) { options = Cookies._getExtendedOptions(options); options.expires = Cookies._getExpiresDate(value === undefined ? -1 : options.expires); Cookies._document.cookie = Cookies._generateCookieString(key, value, options); return Cookies; }; Cookies.expire = function (key, options) { return Cookies.set(key, undefined, options); }; Cookies._getExtendedOptions = function (options) { return { path: options && options.path || Cookies.defaults.path, domain: options && options.domain || Cookies.defaults.domain, expires: options && options.expires || Cookies.defaults.expires, secure: options && options.secure !== undefined ? options.secure : Cookies.defaults.secure }; }; Cookies._isValidDate = function (date) { return Object.prototype.toString.call(date) === '[object Date]' && !isNaN(date.getTime()); }; Cookies._getExpiresDate = function (expires, now) { now = now || new Date(); if (typeof expires === 'number') { expires = expires === Infinity ? Cookies._maxExpireDate : new Date(now.getTime() + expires * 1000); } else if (typeof expires === 'string') { expires = new Date(expires); } if (expires && !Cookies._isValidDate(expires)) { throw new Error('`expires` parameter cannot be converted to a valid Date instance'); } return expires; }; Cookies._generateCookieString = function (key, value, options) { key = key.replace(/[^#$&+\^`|]/g, encodeURIComponent); key = key.replace(/\(/g, '%28').replace(/\)/g, '%29'); value = (value + '').replace(/[^!#$&-+\--:<-\[\]-~]/g, encodeURIComponent); options = options || {}; var cookieString = key + '=' + value; cookieString += options.path ? ';path=' + options.path : ''; cookieString += options.domain ? ';domain=' + options.domain : ''; cookieString += options.expires ? ';expires=' + options.expires.toUTCString() : ''; cookieString += options.secure ? ';secure' : ''; return cookieString; }; Cookies._getCacheFromString = function (documentCookie) { var cookieCache = {}; var cookiesArray = documentCookie ? documentCookie.split('; ') : []; for (var i = 0; i < cookiesArray.length; i++) { var cookieKvp = Cookies._getKeyValuePairFromCookieString(cookiesArray[i]); if (cookieCache[Cookies._cacheKeyPrefix + cookieKvp.key] === undefined) { cookieCache[Cookies._cacheKeyPrefix + cookieKvp.key] = cookieKvp.value; } } return cookieCache; }; Cookies._getKeyValuePairFromCookieString = function (cookieString) { var separatorIndex = cookieString.indexOf('='); separatorIndex = separatorIndex < 0 ? cookieString.length : separatorIndex; return { key: decodeURIComponent(cookieString.substr(0, separatorIndex)), value: decodeURIComponent(cookieString.substr(separatorIndex + 1)) }; }; Cookies._renewCache = function () { Cookies._cache = Cookies._getCacheFromString(Cookies._document.cookie); Cookies._cachedDocumentCookie = Cookies._document.cookie; }; Cookies._areEnabled = function () { var testKey = 'cookies.js'; var areEnabled = Cookies.set(testKey, 1).get(testKey) === '1'; Cookies.expire(testKey); return areEnabled; }; Cookies.enabled = Cookies._areEnabled(); return Cookies; }; var cookiesExport = typeof global.document === 'object' ? factory(global) : factory; if (false) { define(function () { return cookiesExport; }); } else if (typeof exports === 'object') { if (typeof module === 'object' && typeof module.exports === 'object') { exports = module.exports = cookiesExport; } exports.Cookies = cookiesExport; } else { global.Cookies = cookiesExport; } })(typeof window === 'undefined' ? this : window); +/*! + * JavaScript Cookie v2.1.0 + * https://github.com/js-cookie/js-cookie + * + * Copyright 2006, 2015 Klaus Hartl & Fagner Brack + * Released under the MIT license + */ +(function (factory) { + if (false) { + define(factory); + } else if (typeof exports === 'object') { + module.exports = factory(); + } else { + var _OldCookies = window.Cookies; + var api = window.Cookies = factory(); + api.noConflict = function () { + window.Cookies = _OldCookies; + return api; + }; + } +}(function () { + function extend () { + var i = 0; + var result = {}; + for (; i < arguments.length; i++) { + var attributes = arguments[ i ]; + for (var key in attributes) { + result[key] = attributes[key]; + } + } + return result; + } + function init (converter) { + function api (key, value, attributes) { + var result; + if (arguments.length > 1) { + attributes = extend({ + path: '/' + }, api.defaults, attributes); + if (typeof attributes.expires === 'number') { + var expires = new Date(); + expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5); + attributes.expires = expires; + } + try { + result = JSON.stringify(value); + if (/^[\{\[]/.test(result)) { + value = result; + } + } catch (e) {} + if (!converter.write) { + value = encodeURIComponent(String(value)) + .replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent); + } else { + value = converter.write(value, key); + } + key = encodeURIComponent(String(key)); + key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent); + key = key.replace(/[\(\)]/g, escape); + return (document.cookie = [ + key, '=', value, + attributes.expires && '; expires=' + attributes.expires.toUTCString(), + attributes.path && '; path=' + attributes.path, + attributes.domain && '; domain=' + attributes.domain, + attributes.secure ? '; secure' : '' + ].join('')); + } + if (!key) { + result = {}; + } + var cookies = document.cookie ? document.cookie.split('; ') : []; + var rdecode = /(%[0-9A-Z]{2})+/g; + var i = 0; + for (; i < cookies.length; i++) { + var parts = cookies[i].split('='); + var name = parts[0].replace(rdecode, decodeURIComponent); + var cookie = parts.slice(1).join('='); + if (cookie.charAt(0) === '"') { + cookie = cookie.slice(1, -1); + } + try { + cookie = converter.read ? + converter.read(cookie, name) : converter(cookie, name) || + cookie.replace(rdecode, decodeURIComponent); + if (this.json) { + try { + cookie = JSON.parse(cookie); + } catch (e) {} + } + if (key === name) { + result = cookie; + break; + } + if (!key) { + result[name] = cookie; + } + } catch (e) {} + } + return result; + } + api.get = api.set = api; + api.getJSON = function () { + return api.apply({ + json: true + }, [].slice.call(arguments)); + }; + api.defaults = {}; + api.remove = function (key, attributes) { + api(key, '', extend(attributes, { + expires: -1 + })); + }; + api.withConverter = init; + return api; + } + return init(function () {}); +})); },{}],22:[function(require,module,exports){ (function (global){ var each = require('./utils/each'), @@ -1199,7 +1321,7 @@ var Emitter = require('component-emitter'); 'parseParams' : parseParams, 'serialize' : serialize }, - version: '0.1.1' + version: '1.0.0' }); Client.log = function(str){ if (Client.debug && typeof console === 'object') { diff --git a/dist/keen-tracking.min.js b/dist/keen-tracking.min.js index e88a971..2467cc2 100644 --- a/dist/keen-tracking.min.js +++ b/dist/keen-tracking.min.js @@ -1 +1,9 @@ -(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(u){x=function(){if(!p){p=true;u()}}}this.recordEvent(n,v,x);setTimeout(x,o);if(!w.metaKey){return false}}if(!Array.prototype.indexOf){Array.prototype.indexOf=function(o){var n=this.length>>>0;var p=Number(arguments[1])||0;p=(p<0)?Math.ceil(p):Math.floor(p);if(p<0){p+=n}for(;p0){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: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("cookies-js");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:{}};this.data=this.get();return this}c.prototype.get=function(i){var h={};if(d.get(this.config.key)){h=JSON.parse(decodeURIComponent(d.get(this.config.key)))}if(i){return("undefined"!==typeof h[i])?h[i]:null}else{return h}};c.prototype.set=function(i,h){if(!arguments.length||!this.enabled()){return this}if("string"===typeof i&&arguments.length===2){this.data[i]=h?h:null}else{if("object"===typeof i&&arguments.length===1){g(this.data,i)}}d.set(this.config.key,encodeURIComponent(JSON.stringify(this.data)),this.config.options);return this};c.prototype.expire=function(){d.expire(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 d.enabled}},{"./extend":16,"cookies-js":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-1){n.protocol=document.location.protocol.replace(":","")}if(n.host){n.host.replace(/.*?:\/\//g,"")}j(this.config,n);return this};m.prototype.masterKey=function(n){if(!arguments.length){return this.config.masterKey}this.config.masterKey=n?String(n):null;return this};m.prototype.projectId=function(n){if(!arguments.length){return this.config.projectId}this.config.projectId=(n?String(n):null);return this};m.prototype.resources=function(o){if(!arguments.length){return this.config.resources}var n=this;if(typeof o==="object"){i(o,function(q,p){n.config.resources[p]=(q?q:null)})}return n};m.prototype.url=function(o){var n=Array.prototype.slice.call(arguments,1),p=m.resources.base||"{protocol}://{host}",q;if(o&&typeof o==="string"){if(this.config.resources[o]){q=this.config.resources[o]}else{q=p+o}}else{q=p}i(this.config,function(s,r){if(typeof s!=="object"){q=q.replace("{"+r+"}",s)}});i(n,function(r,s){if(typeof r==="string"){q+="/"+r}else{if(typeof r==="object"){q+="?";i(r,function(u,t){q+=t+"="+u+"&"});q=q.slice(0,-1)}}});return q};if(k){k.Keen=m}if(typeof c!=="undefined"&&c.exports){c.exports=m}if(typeof define!=="undefined"&&define.amd){define("keen-core",[],function(){return m})}}).call(this,typeof window!=="undefined"?window:typeof g!=="undefined"?g: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 or DOM element")}}if(u){x=function(){if(!p){p=true;u()}}}this.recordEvent(n,v,x);setTimeout(x,o);if(!w.metaKey){return false}}if(!Array.prototype.indexOf){Array.prototype.indexOf=function(o){var n=this.length>>>0;var p=Number(arguments[1])||0;p=(p<0)?Math.ceil(p):Math.floor(p);if(p<0){p+=n}for(;p0){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: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=JSON.parse(d.get(this.config.key))}if(i){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){n.protocol=document.location.protocol.replace(":","")}if(n.host){n.host.replace(/.*?:\/\//g,"")}j(this.config,n);return this};m.prototype.masterKey=function(n){if(!arguments.length){return this.config.masterKey}this.config.masterKey=n?String(n):null;return this};m.prototype.projectId=function(n){if(!arguments.length){return this.config.projectId}this.config.projectId=(n?String(n):null);return this};m.prototype.resources=function(o){if(!arguments.length){return this.config.resources}var n=this;if(typeof o==="object"){i(o,function(q,p){n.config.resources[p]=(q?q:null)})}return n};m.prototype.url=function(o){var n=Array.prototype.slice.call(arguments,1),p=m.resources.base||"{protocol}://{host}",q;if(o&&typeof o==="string"){if(this.config.resources[o]){q=this.config.resources[o]}else{q=p+o}}else{q=p}i(this.config,function(s,r){if(typeof s!=="object"){q=q.replace("{"+r+"}",s)}});i(n,function(r,s){if(typeof r==="string"){q+="/"+r}else{if(typeof r==="object"){q+="?";i(r,function(u,t){q+=t+"="+u+"&"});q=q.slice(0,-1)}}});return q};if(k){k.Keen=m}if(typeof c!=="undefined"&&c.exports){c.exports=m}if(typeof define!=="undefined"&&define.amd){define("keen-core",[],function(){return m})}}).call(this,typeof window!=="undefined"?window:typeof g!=="undefined"?g: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