From f443a9678f6d318f33baeeb4a24f6bd91dd5c6a0 Mon Sep 17 00:00:00 2001 From: dustinlarimer Date: Tue, 16 Feb 2016 20:31:41 -0800 Subject: [PATCH 01/10] Update docs to resolve #387 --- README.md | 10 +++--- dist/keen-query.js | 54 ++++++++++++++++---------------- dist/keen-query.min.js | 2 +- dist/keen-tracker.js | 50 +++++++++++++++--------------- dist/keen-tracker.min.js | 2 +- dist/keen.js | 66 ++++++++++++++++++++-------------------- dist/keen.min.js | 4 +-- docs/installation.md | 2 +- docs/query.md | 42 ++++++++++++------------- docs/recipes.md | 26 ++++++++-------- docs/visualization.md | 32 +++++++++---------- 11 files changed, 145 insertions(+), 145 deletions(-) diff --git a/README.md b/README.md index 0afdec1..fd0c2f5 100644 --- a/README.md +++ b/README.md @@ -173,7 +173,7 @@ The `.run` method is available on each configured client instance to run ```javascript var your_analysis = new Keen.Query(analysisType, { - eventCollection: 'YOUR_EVENT_COLLECTION', // (required) + event_collection: 'YOUR_EVENT_COLLECTION', // (required) timeframe: "YOUR_TIMEFRAME" // (required) // ... additional parameters }); @@ -192,8 +192,8 @@ Keen.ready(function(){ // Create a query instance var count = new Keen.Query("count", { - eventCollection: "pageviews", - groupBy: "property", + event_collection: "pageviews", + group_by: "property", timeframe: "this_7_days" }); @@ -348,8 +348,8 @@ Keen.ready(function(){ // Create a query instance var count = new Keen.Query("count", { - eventCollection: "pageviews", - groupBy: "visitor.geo.country", + event_collection: "pageviews", + group_by: "visitor.geo.country", interval: "daily", timeframe: "this_21_days" }); diff --git a/dist/keen-query.js b/dist/keen-query.js index 7df8f37..9427358 100644 --- a/dist/keen-query.js +++ b/dist/keen-query.js @@ -719,27 +719,6 @@ Emitter.prototype.hasListeners = function(event){ }).call(this); }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}],3:[function(require,module,exports){ -/** - * Reduce `arr` with `fn`. - * - * @param {Array} arr - * @param {Function} fn - * @param {Mixed} initial - * - * TODO: combatible error handling? - */ -module.exports = function(arr, fn, initial){ - var idx = 0; - var len = arr.length; - var curr = arguments.length == 3 - ? initial - : arr[idx++]; - while (idx < len) { - curr = fn.call(null, curr, arr[idx], ++idx, arr); - } - return curr; -}; -},{}],4:[function(require,module,exports){ /** * Module dependencies. */ @@ -1663,7 +1642,7 @@ request.put = function(url, data, fn){ * Expose `request`. */ module.exports = request; -},{"emitter":5,"reduce":3}],5:[function(require,module,exports){ +},{"emitter":4,"reduce":5}],4:[function(require,module,exports){ /** * Expose `Emitter`. */ @@ -1798,6 +1777,27 @@ Emitter.prototype.listeners = function(event){ Emitter.prototype.hasListeners = function(event){ return !! this.listeners(event).length; }; +},{}],5:[function(require,module,exports){ +/** + * Reduce `arr` with `fn`. + * + * @param {Array} arr + * @param {Function} fn + * @param {Mixed} initial + * + * TODO: combatible error handling? + */ +module.exports = function(arr, fn, initial){ + var idx = 0; + var len = arr.length; + var curr = arguments.length == 3 + ? initial + : arr[idx++]; + while (idx < len) { + curr = fn.call(null, curr, arr[idx], ++idx, arr); + } + return curr; +}; },{}],6:[function(require,module,exports){ module.exports = function(){ return "undefined" == typeof window ? "server" : "browser"; @@ -2025,7 +2025,7 @@ function xhrShim(opts){ }; return this; } -},{"../utils/each":18,"./get-xhr-object":9,"superagent":4}],12:[function(require,module,exports){ +},{"../utils/each":18,"./get-xhr-object":9,"superagent":3}],12:[function(require,module,exports){ var root = 'undefined' !== typeof window ? window : this; var previous_Keen = root.Keen; var Emitter = require('./utils/emitter-shim'); @@ -2126,7 +2126,7 @@ module.exports = function(url, params, api_key, callback){ callback = null; }); }; -},{"../helpers/get-query-string":7,"../helpers/superagent-handle-response":10,"../helpers/superagent-request-types":11,"superagent":4}],14:[function(require,module,exports){ +},{"../helpers/get-query-string":7,"../helpers/superagent-handle-response":10,"../helpers/superagent-request-types":11,"superagent":3}],14:[function(require,module,exports){ var Request = require("../request"); module.exports = function(query, callback) { var queries = [], @@ -2368,7 +2368,7 @@ function savedQueries() { return this; } module.exports = savedQueries; -},{"./helpers/superagent-handle-response":10,"superagent":4}],18:[function(require,module,exports){ +},{"./helpers/superagent-handle-response":10,"superagent":3}],18:[function(require,module,exports){ module.exports = function(o, cb, s){ var n; if (!o){ @@ -2451,7 +2451,7 @@ module.exports = function(path, params, callback){ } return; } -},{"../helpers/get-context":6,"../helpers/get-xhr-object":9,"../helpers/superagent-handle-response":10,"superagent":4}],24:[function(require,module,exports){ +},{"../helpers/get-context":6,"../helpers/get-xhr-object":9,"../helpers/superagent-handle-response":10,"superagent":3}],24:[function(require,module,exports){ var request = require('superagent'); var responseHandler = require('../helpers/superagent-handle-response'); module.exports = function(path, params, callback){ @@ -2474,7 +2474,7 @@ module.exports = function(path, params, callback){ }); return; } -},{"../helpers/superagent-handle-response":10,"superagent":4}],25:[function(require,module,exports){ +},{"../helpers/superagent-handle-response":10,"superagent":3}],25:[function(require,module,exports){ (function (global){ ;(function (f) { if (typeof define === "function" && define.amd) { diff --git a/dist/keen-query.min.js b/dist/keen-query.min.js index 06d0a69..958b29f 100644 --- a/dist/keen-query.min.js +++ b/dist/keen-query.min.js @@ -1,3 +1,3 @@ (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;f1)))/4)-w((ag-1901+ah)/100)+w((ag-1601+ah)/400)}}if(!(v=r.hasOwnProperty)){v=function(ai){var ag={},ah;if((ag.__proto__=null,ag.__proto__={toString:1},ag).toString!=y){v=function(al){var ak=this.__proto__,aj=al in (this.__proto__=null,this);this.__proto__=ak;return aj}}else{ah=ag.constructor;v=function(ak){var aj=(this.constructor||ah).prototype;return ak in this&&!(ak in aj&&this[ak]===aj[ak])}}ag=null;return v.call(this,ai)}}q=function(ai,al){var aj=0,ag,ah,ak;(ag=function(){this.valueOf=0}).prototype.valueOf=0;ah=new ag();for(ak in ah){if(v.call(ah,ak)){aj++}}ag=ah=null;if(!aj){ah=["valueOf","toString","toLocaleString","propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"];q=function(an,ar){var aq=y.call(an)==Y,ap,ao;var am=!aq&&typeof an.constructor!="function"&&i[typeof an.hasOwnProperty]&&an.hasOwnProperty||v;for(ap in an){if(!(aq&&ap=="prototype")&&am.call(an,ap)){ar(ap)}}for(ao=ah.length;ap=ah[--ao];am.call(an,ap)&&ar(ap)){}}}else{if(aj==2){q=function(an,aq){var am={},ap=y.call(an)==Y,ao;for(ao in an){if(!(ap&&ao=="prototype")&&!v.call(am,ao)&&(am[ao]=1)&&v.call(an,ao)){aq(ao)}}}}else{q=function(an,aq){var ap=y.call(an)==Y,ao,am;for(ao in an){if(!(ap&&ao=="prototype")&&v.call(an,ao)&&!(am=ao==="constructor")){aq(ao)}}if(am||v.call(an,(ao="constructor"))){aq(ao)}}}}return q(ai,al)};if(!s("json-stringify")){var u={92:"\\\\",34:'\\"',8:"\\b",12:"\\f",10:"\\n",13:"\\r",9:"\\t"};var M="000000";var x=function(ag,ah){return(M+(ah||0)).slice(-ag)};var D="\\u00";var G=function(am){var ah='"',ak=0,al=am.length,ag=!J||al>10;var aj=ag&&(J?am.split(""):am);for(;ak-1/0&&ax<1/0){if(H){aC=w(ax/86400000);for(au=w(aC/365.2425)+1970-1;H(au+1,0)<=aC;au++){}for(aD=w((aC-H(au,0))/30.42);H(au,aD+1)<=aC;aD++){}aC=1+aC-H(au,aD);ao=(ax%86400000+86400000)%86400000;aA=w(ao/3600000)%24;ay=w(ao/60000)%60;av=w(ao/1000)%60;ar=ao%1000}else{au=ax.getUTCFullYear();aD=ax.getUTCMonth();aC=ax.getUTCDate();aA=ax.getUTCHours();ay=ax.getUTCMinutes();av=ax.getUTCSeconds();ar=ax.getUTCMilliseconds()}ax=(au<=0||au>=10000?(au<0?"-":"+")+x(6,au<0?-au:au):x(4,au))+"-"+x(2,aD+1)+"-"+x(2,aC)+"T"+x(2,aA)+":"+x(2,ay)+":"+x(2,av)+"."+x(3,ar)+"Z"}else{ax=null}}else{if(typeof ax.toJSON=="function"&&((ai!=R&&ai!=S&&ai!=I)||v.call(ax,"toJSON"))){ax=ax.toJSON(am)}}}if(ak){ax=ak.call(aE,am,ax)}if(ax===null){return"null"}ai=y.call(ax);if(ai==E){return""+ax}else{if(ai==R){return ax>-1/0&&ax<1/0?""+ax:"null"}else{if(ai==S){return G(""+ax)}}}if(typeof ax=="object"){for(aj=an.length;aj--;){if(an[aj]===ax){throw ae()}}an.push(ax);aw=[];az=ag;ag+=aB;if(ai==I){for(al=0,aj=ax.length;al0){for(ah="",aj>10&&(aj=10);ah.length=48&&ah<=57||ah>=97&&ah<=102||ah>=65&&ah<=70)){L()}}ak+=Q("0x"+al.slice(ai,K));break;default:L()}}else{if(ah==34){break}ah=al.charCodeAt(K);ai=K;while(ah>=32&&ah!=92&&ah!=34){ah=al.charCodeAt(++K)}ak+=al.slice(ai,K)}}}if(al.charCodeAt(K)==34){K++;return ak}L();default:ai=K;if(ah==45){am=true;ah=al.charCodeAt(++K)}if(ah>=48&&ah<=57){if(ah==48&&((ah=al.charCodeAt(K+1)),ah>=48&&ah<=57)){L()}am=false;for(;K=48&&ah<=57);K++){}if(al.charCodeAt(K)==46){ag=++K;for(;ag=48&&ah<=57);ag++){}if(ag==K){L()}K=ag}ah=al.charCodeAt(K);if(ah==101||ah==69){ah=al.charCodeAt(++K);if(ah==43||ah==45){K++}for(ag=K;ag=48&&ah<=57);ag++){}if(ag==K){L()}K=ag}return +al.slice(ai,K)}if(am){L()}if(al.slice(K,K+4)=="true"){K+=4;return true}else{if(al.slice(K,K+5)=="false"){K+=5;return false}else{if(al.slice(K,K+4)=="null"){K+=4;return null}}}L()}}return"$"};var aa=function(ah){var ag,ai;if(ah=="$"){L()}if(typeof ah=="string"){if((J?ah.charAt(0):ah[0])=="@"){return ah.slice(1)}if(ah=="["){ag=[];for(;;ai||(ai=true)){ah=C();if(ah=="]"){break}if(ai){if(ah==","){ah=C();if(ah=="]"){L()}}else{L()}}if(ah==","){L()}ag.push(aa(ah))}return ag}else{if(ah=="{"){ag={};for(;;ai||(ai=true)){ah=C();if(ah=="}"){break}if(ai){if(ah==","){ah=C();if(ah=="}"){L()}}else{L()}}if(ah==","||typeof ah!="string"||(J?ah.charAt(0):ah[0])!="@"||C()!=":"){L()}ag[ah.slice(1)]=aa(C())}return ag}}L()}return ah};var T=function(ai,ah,aj){var ag=A(ai,ah,aj);if(ag===P){delete ai[ah]}else{ai[ah]=ag}};var A=function(aj,ai,ak){var ah=aj[ai],ag;if(typeof ah=="object"&&ah){if(y.call(ah)==I){for(ag=ah.length;ag--;){T(ah,ag,ak)}}else{q(ah,function(al){T(ah,al,ak)})}}return ak.call(aj,ai,ah)};Z.parse=function(ai,aj){var ag,ah;K=0;ab=""+ai;ag=aa(C());if(C()!="$"){L()}K=ab=null;return aj&&y.call(aj)==Y?A((ah={},ah[""]=ag,ah),"",aj):ag}}}Z.runInContext=n;return Z}if(l&&!g){n(m,l)}else{var j=m.JSON,o=m.JSON3,h=false;var k=n(m,(m.JSON3={noConflict:function(){if(!h){h=true;m.JSON=j;m.JSON3=o;j=o=null}return k}}));m.JSON={parse:k.parse,stringify:k.stringify}}if(g){define(function(){return k})}}).call(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],3:[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(f1)))/4)-w((ag-1901+ah)/100)+w((ag-1601+ah)/400)}}if(!(v=r.hasOwnProperty)){v=function(ai){var ag={},ah;if((ag.__proto__=null,ag.__proto__={toString:1},ag).toString!=y){v=function(al){var ak=this.__proto__,aj=al in (this.__proto__=null,this);this.__proto__=ak;return aj}}else{ah=ag.constructor;v=function(ak){var aj=(this.constructor||ah).prototype;return ak in this&&!(ak in aj&&this[ak]===aj[ak])}}ag=null;return v.call(this,ai)}}q=function(ai,al){var aj=0,ag,ah,ak;(ag=function(){this.valueOf=0}).prototype.valueOf=0;ah=new ag();for(ak in ah){if(v.call(ah,ak)){aj++}}ag=ah=null;if(!aj){ah=["valueOf","toString","toLocaleString","propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"];q=function(an,ar){var aq=y.call(an)==Y,ap,ao;var am=!aq&&typeof an.constructor!="function"&&i[typeof an.hasOwnProperty]&&an.hasOwnProperty||v;for(ap in an){if(!(aq&&ap=="prototype")&&am.call(an,ap)){ar(ap)}}for(ao=ah.length;ap=ah[--ao];am.call(an,ap)&&ar(ap)){}}}else{if(aj==2){q=function(an,aq){var am={},ap=y.call(an)==Y,ao;for(ao in an){if(!(ap&&ao=="prototype")&&!v.call(am,ao)&&(am[ao]=1)&&v.call(an,ao)){aq(ao)}}}}else{q=function(an,aq){var ap=y.call(an)==Y,ao,am;for(ao in an){if(!(ap&&ao=="prototype")&&v.call(an,ao)&&!(am=ao==="constructor")){aq(ao)}}if(am||v.call(an,(ao="constructor"))){aq(ao)}}}}return q(ai,al)};if(!s("json-stringify")){var u={92:"\\\\",34:'\\"',8:"\\b",12:"\\f",10:"\\n",13:"\\r",9:"\\t"};var M="000000";var x=function(ag,ah){return(M+(ah||0)).slice(-ag)};var D="\\u00";var G=function(am){var ah='"',ak=0,al=am.length,ag=!J||al>10;var aj=ag&&(J?am.split(""):am);for(;ak-1/0&&ax<1/0){if(H){aC=w(ax/86400000);for(au=w(aC/365.2425)+1970-1;H(au+1,0)<=aC;au++){}for(aD=w((aC-H(au,0))/30.42);H(au,aD+1)<=aC;aD++){}aC=1+aC-H(au,aD);ao=(ax%86400000+86400000)%86400000;aA=w(ao/3600000)%24;ay=w(ao/60000)%60;av=w(ao/1000)%60;ar=ao%1000}else{au=ax.getUTCFullYear();aD=ax.getUTCMonth();aC=ax.getUTCDate();aA=ax.getUTCHours();ay=ax.getUTCMinutes();av=ax.getUTCSeconds();ar=ax.getUTCMilliseconds()}ax=(au<=0||au>=10000?(au<0?"-":"+")+x(6,au<0?-au:au):x(4,au))+"-"+x(2,aD+1)+"-"+x(2,aC)+"T"+x(2,aA)+":"+x(2,ay)+":"+x(2,av)+"."+x(3,ar)+"Z"}else{ax=null}}else{if(typeof ax.toJSON=="function"&&((ai!=R&&ai!=S&&ai!=I)||v.call(ax,"toJSON"))){ax=ax.toJSON(am)}}}if(ak){ax=ak.call(aE,am,ax)}if(ax===null){return"null"}ai=y.call(ax);if(ai==E){return""+ax}else{if(ai==R){return ax>-1/0&&ax<1/0?""+ax:"null"}else{if(ai==S){return G(""+ax)}}}if(typeof ax=="object"){for(aj=an.length;aj--;){if(an[aj]===ax){throw ae()}}an.push(ax);aw=[];az=ag;ag+=aB;if(ai==I){for(al=0,aj=ax.length;al0){for(ah="",aj>10&&(aj=10);ah.length=48&&ah<=57||ah>=97&&ah<=102||ah>=65&&ah<=70)){L()}}ak+=Q("0x"+al.slice(ai,K));break;default:L()}}else{if(ah==34){break}ah=al.charCodeAt(K);ai=K;while(ah>=32&&ah!=92&&ah!=34){ah=al.charCodeAt(++K)}ak+=al.slice(ai,K)}}}if(al.charCodeAt(K)==34){K++;return ak}L();default:ai=K;if(ah==45){am=true;ah=al.charCodeAt(++K)}if(ah>=48&&ah<=57){if(ah==48&&((ah=al.charCodeAt(K+1)),ah>=48&&ah<=57)){L()}am=false;for(;K=48&&ah<=57);K++){}if(al.charCodeAt(K)==46){ag=++K;for(;ag=48&&ah<=57);ag++){}if(ag==K){L()}K=ag}ah=al.charCodeAt(K);if(ah==101||ah==69){ah=al.charCodeAt(++K);if(ah==43||ah==45){K++}for(ag=K;ag=48&&ah<=57);ag++){}if(ag==K){L()}K=ag}return +al.slice(ai,K)}if(am){L()}if(al.slice(K,K+4)=="true"){K+=4;return true}else{if(al.slice(K,K+5)=="false"){K+=5;return false}else{if(al.slice(K,K+4)=="null"){K+=4;return null}}}L()}}return"$"};var aa=function(ah){var ag,ai;if(ah=="$"){L()}if(typeof ah=="string"){if((J?ah.charAt(0):ah[0])=="@"){return ah.slice(1)}if(ah=="["){ag=[];for(;;ai||(ai=true)){ah=C();if(ah=="]"){break}if(ai){if(ah==","){ah=C();if(ah=="]"){L()}}else{L()}}if(ah==","){L()}ag.push(aa(ah))}return ag}else{if(ah=="{"){ag={};for(;;ai||(ai=true)){ah=C();if(ah=="}"){break}if(ai){if(ah==","){ah=C();if(ah=="}"){L()}}else{L()}}if(ah==","||typeof ah!="string"||(J?ah.charAt(0):ah[0])!="@"||C()!=":"){L()}ag[ah.slice(1)]=aa(C())}return ag}}L()}return ah};var T=function(ai,ah,aj){var ag=A(ai,ah,aj);if(ag===P){delete ai[ah]}else{ai[ah]=ag}};var A=function(aj,ai,ak){var ah=aj[ai],ag;if(typeof ah=="object"&&ah){if(y.call(ah)==I){for(ag=ah.length;ag--;){T(ah,ag,ak)}}else{q(ah,function(al){T(ah,al,ak)})}}return ak.call(aj,ai,ah)};Z.parse=function(ai,aj){var ag,ah;K=0;ab=""+ai;ag=aa(C());if(C()!="$"){L()}K=ab=null;return aj&&y.call(aj)==Y?A((ah={},ah[""]=ag,ah),"",aj):ag}}}Z.runInContext=n;return Z}if(l&&!g){n(m,l)}else{var j=m.JSON,o=m.JSON3,h=false;var k=n(m,(m.JSON3={noConflict:function(){if(!h){h=true;m.JSON=j;m.JSON3=o;j=o=null}return k}}));m.JSON={parse:k.parse,stringify:k.stringify}}if(g){define(function(){return k})}}).call(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],3:[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;v1)))/4)-w((ag-1901+ah)/100)+w((ag-1601+ah)/400)}}if(!(v=r.hasOwnProperty)){v=function(ai){var ag={},ah;if((ag.__proto__=null,ag.__proto__={toString:1},ag).toString!=y){v=function(al){var ak=this.__proto__,aj=al in (this.__proto__=null,this);this.__proto__=ak;return aj}}else{ah=ag.constructor;v=function(ak){var aj=(this.constructor||ah).prototype;return ak in this&&!(ak in aj&&this[ak]===aj[ak])}}ag=null;return v.call(this,ai)}}q=function(ai,al){var aj=0,ag,ah,ak;(ag=function(){this.valueOf=0}).prototype.valueOf=0;ah=new ag();for(ak in ah){if(v.call(ah,ak)){aj++}}ag=ah=null;if(!aj){ah=["valueOf","toString","toLocaleString","propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"];q=function(an,ar){var aq=y.call(an)==Y,ap,ao;var am=!aq&&typeof an.constructor!="function"&&i[typeof an.hasOwnProperty]&&an.hasOwnProperty||v;for(ap in an){if(!(aq&&ap=="prototype")&&am.call(an,ap)){ar(ap)}}for(ao=ah.length;ap=ah[--ao];am.call(an,ap)&&ar(ap)){}}}else{if(aj==2){q=function(an,aq){var am={},ap=y.call(an)==Y,ao;for(ao in an){if(!(ap&&ao=="prototype")&&!v.call(am,ao)&&(am[ao]=1)&&v.call(an,ao)){aq(ao)}}}}else{q=function(an,aq){var ap=y.call(an)==Y,ao,am;for(ao in an){if(!(ap&&ao=="prototype")&&v.call(an,ao)&&!(am=ao==="constructor")){aq(ao)}}if(am||v.call(an,(ao="constructor"))){aq(ao)}}}}return q(ai,al)};if(!s("json-stringify")){var u={92:"\\\\",34:'\\"',8:"\\b",12:"\\f",10:"\\n",13:"\\r",9:"\\t"};var M="000000";var x=function(ag,ah){return(M+(ah||0)).slice(-ag)};var D="\\u00";var G=function(am){var ah='"',ak=0,al=am.length,ag=!J||al>10;var aj=ag&&(J?am.split(""):am);for(;ak-1/0&&ax<1/0){if(H){aC=w(ax/86400000);for(au=w(aC/365.2425)+1970-1;H(au+1,0)<=aC;au++){}for(aD=w((aC-H(au,0))/30.42);H(au,aD+1)<=aC;aD++){}aC=1+aC-H(au,aD);ao=(ax%86400000+86400000)%86400000;aA=w(ao/3600000)%24;ay=w(ao/60000)%60;av=w(ao/1000)%60;ar=ao%1000}else{au=ax.getUTCFullYear();aD=ax.getUTCMonth();aC=ax.getUTCDate();aA=ax.getUTCHours();ay=ax.getUTCMinutes();av=ax.getUTCSeconds();ar=ax.getUTCMilliseconds()}ax=(au<=0||au>=10000?(au<0?"-":"+")+x(6,au<0?-au:au):x(4,au))+"-"+x(2,aD+1)+"-"+x(2,aC)+"T"+x(2,aA)+":"+x(2,ay)+":"+x(2,av)+"."+x(3,ar)+"Z"}else{ax=null}}else{if(typeof ax.toJSON=="function"&&((ai!=R&&ai!=S&&ai!=I)||v.call(ax,"toJSON"))){ax=ax.toJSON(am)}}}if(ak){ax=ak.call(aE,am,ax)}if(ax===null){return"null"}ai=y.call(ax);if(ai==E){return""+ax}else{if(ai==R){return ax>-1/0&&ax<1/0?""+ax:"null"}else{if(ai==S){return G(""+ax)}}}if(typeof ax=="object"){for(aj=an.length;aj--;){if(an[aj]===ax){throw ae()}}an.push(ax);aw=[];az=ag;ag+=aB;if(ai==I){for(al=0,aj=ax.length;al0){for(ah="",aj>10&&(aj=10);ah.length=48&&ah<=57||ah>=97&&ah<=102||ah>=65&&ah<=70)){L()}}ak+=Q("0x"+al.slice(ai,K));break;default:L()}}else{if(ah==34){break}ah=al.charCodeAt(K);ai=K;while(ah>=32&&ah!=92&&ah!=34){ah=al.charCodeAt(++K)}ak+=al.slice(ai,K)}}}if(al.charCodeAt(K)==34){K++;return ak}L();default:ai=K;if(ah==45){am=true;ah=al.charCodeAt(++K)}if(ah>=48&&ah<=57){if(ah==48&&((ah=al.charCodeAt(K+1)),ah>=48&&ah<=57)){L()}am=false;for(;K=48&&ah<=57);K++){}if(al.charCodeAt(K)==46){ag=++K;for(;ag=48&&ah<=57);ag++){}if(ag==K){L()}K=ag}ah=al.charCodeAt(K);if(ah==101||ah==69){ah=al.charCodeAt(++K);if(ah==43||ah==45){K++}for(ag=K;ag=48&&ah<=57);ag++){}if(ag==K){L()}K=ag}return +al.slice(ai,K)}if(am){L()}if(al.slice(K,K+4)=="true"){K+=4;return true}else{if(al.slice(K,K+5)=="false"){K+=5;return false}else{if(al.slice(K,K+4)=="null"){K+=4;return null}}}L()}}return"$"};var aa=function(ah){var ag,ai;if(ah=="$"){L()}if(typeof ah=="string"){if((J?ah.charAt(0):ah[0])=="@"){return ah.slice(1)}if(ah=="["){ag=[];for(;;ai||(ai=true)){ah=C();if(ah=="]"){break}if(ai){if(ah==","){ah=C();if(ah=="]"){L()}}else{L()}}if(ah==","){L()}ag.push(aa(ah))}return ag}else{if(ah=="{"){ag={};for(;;ai||(ai=true)){ah=C();if(ah=="}"){break}if(ai){if(ah==","){ah=C();if(ah=="}"){L()}}else{L()}}if(ah==","||typeof ah!="string"||(J?ah.charAt(0):ah[0])!="@"||C()!=":"){L()}ag[ah.slice(1)]=aa(C())}return ag}}L()}return ah};var T=function(ai,ah,aj){var ag=A(ai,ah,aj);if(ag===P){delete ai[ah]}else{ai[ah]=ag}};var A=function(aj,ai,ak){var ah=aj[ai],ag;if(typeof ah=="object"&&ah){if(y.call(ah)==I){for(ag=ah.length;ag--;){T(ah,ag,ak)}}else{q(ah,function(al){T(ah,al,ak)})}}return ak.call(aj,ai,ah)};Z.parse=function(ai,aj){var ag,ah;K=0;ab=""+ai;ag=aa(C());if(C()!="$"){L()}K=ab=null;return aj&&y.call(aj)==Y?A((ah={},ah[""]=ag,ah),"",aj):ag}}}Z.runInContext=n;return Z}if(l&&!g){n(m,l)}else{var j=m.JSON,o=m.JSON3,h=false;var k=n(m,(m.JSON3={noConflict:function(){if(!h){h=true;m.JSON=j;m.JSON3=o;j=o=null}return k}}));m.JSON={parse:k.parse,stringify:k.stringify}}if(g){define(function(){return k})}}).call(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],4:[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(f0){return 2000}}return 16000}},{}],11:[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}},{}],12:[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}},{}],13:[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(typeof window==="undefined"){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(typeof p.async==="boolean"){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||s==="xhr")&&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(s==="jsonp"){j.call(t)}else{if(s==="beacon"){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":20,"./get-xhr-object":11,superagent:5}],14:[function(d,f,c){var b="undefined"!==typeof window?window:this;var h=b.Keen;var g=d("./utils/emitter-shim");function a(i){this.configure(i||{});a.trigger("client",this)}a.debug=false;a.enabled=true;a.loaded=true;a.version="3.4.0-rc4";g(a);g(a.prototype);a.prototype.configure=function(i){var j=i||{};if(j.host){j.host.replace(/.*?:\/\//g,"")}if(j.protocol&&j.protocol==="auto"){j.protocol=location.protocol.replace(/:/g,"")}this.config={projectId:j.projectId,writeKey:j.writeKey,readKey:j.readKey,masterKey:j.masterKey,requestType:j.requestType||"jsonp",host:j.host||"api.keen.io/3.0",protocol:j.protocol||"https",globalProperties:null};if(a.debug){this.on("error",a.log)}this.trigger("ready")};a.prototype.projectId=function(i){if(!arguments.length){return this.config.projectId}this.config.projectId=(i?String(i):null);return this};a.prototype.masterKey=function(i){if(!arguments.length){return this.config.masterKey}this.config.masterKey=(i?String(i):null);return this};a.prototype.readKey=function(i){if(!arguments.length){return this.config.readKey}this.config.readKey=(i?String(i):null);return this};a.prototype.writeKey=function(i){if(!arguments.length){return this.config.writeKey}this.config.writeKey=(i?String(i):null);return this};a.prototype.url=function(i){if(!this.projectId()){this.trigger("error","Client is missing projectId property");return}return this.config.protocol+"://"+this.config.host+"/projects/"+this.projectId()+i};a.log=function(i){if(a.debug&&typeof console=="object"){console.log("[Keen IO]",i)}};a.noConflict=function(){b.Keen=h;return a};a.ready=function(i){if(a.loaded){i()}else{a.once("ready",i)}};f.exports=a},{"./utils/emitter-shim":21}],15:[function(f,c,h){var p=f("../utils/json-shim");var g=f("superagent");var i=f("../index");var j=f("../utils/base64"),m=f("../utils/each"),n=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"),o=f("../helpers/superagent-handle-response");c.exports=function(x,A,B,t){var C=this,v=this.url("/events/"+encodeURIComponent(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&&n()==="browser"){g.get(z).use(k(q,{async:r})).end(w)}else{if(a()||n()==="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){o(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(p.stringify(r)),modified:new Date().getTime()});return(q.length2){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":8,"../helpers/get-xhr-object":11,"../helpers/superagent-handle-response":12,"../helpers/superagent-request-types":13,"../index":14,"../utils/each":20,superagent:5}],17:[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)}}},{}],18:[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 or
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":15}],19:[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}}}},{}],20:[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;h1)))/4)-w((ag-1901+ah)/100)+w((ag-1601+ah)/400)}}if(!(v=r.hasOwnProperty)){v=function(ai){var ag={},ah;if((ag.__proto__=null,ag.__proto__={toString:1},ag).toString!=y){v=function(al){var ak=this.__proto__,aj=al in (this.__proto__=null,this);this.__proto__=ak;return aj}}else{ah=ag.constructor;v=function(ak){var aj=(this.constructor||ah).prototype;return ak in this&&!(ak in aj&&this[ak]===aj[ak])}}ag=null;return v.call(this,ai)}}q=function(ai,al){var aj=0,ag,ah,ak;(ag=function(){this.valueOf=0}).prototype.valueOf=0;ah=new ag();for(ak in ah){if(v.call(ah,ak)){aj++}}ag=ah=null;if(!aj){ah=["valueOf","toString","toLocaleString","propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"];q=function(an,ar){var aq=y.call(an)==Y,ap,ao;var am=!aq&&typeof an.constructor!="function"&&i[typeof an.hasOwnProperty]&&an.hasOwnProperty||v;for(ap in an){if(!(aq&&ap=="prototype")&&am.call(an,ap)){ar(ap)}}for(ao=ah.length;ap=ah[--ao];am.call(an,ap)&&ar(ap)){}}}else{if(aj==2){q=function(an,aq){var am={},ap=y.call(an)==Y,ao;for(ao in an){if(!(ap&&ao=="prototype")&&!v.call(am,ao)&&(am[ao]=1)&&v.call(an,ao)){aq(ao)}}}}else{q=function(an,aq){var ap=y.call(an)==Y,ao,am;for(ao in an){if(!(ap&&ao=="prototype")&&v.call(an,ao)&&!(am=ao==="constructor")){aq(ao)}}if(am||v.call(an,(ao="constructor"))){aq(ao)}}}}return q(ai,al)};if(!s("json-stringify")){var u={92:"\\\\",34:'\\"',8:"\\b",12:"\\f",10:"\\n",13:"\\r",9:"\\t"};var M="000000";var x=function(ag,ah){return(M+(ah||0)).slice(-ag)};var D="\\u00";var G=function(am){var ah='"',ak=0,al=am.length,ag=!J||al>10;var aj=ag&&(J?am.split(""):am);for(;ak-1/0&&ax<1/0){if(H){aC=w(ax/86400000);for(au=w(aC/365.2425)+1970-1;H(au+1,0)<=aC;au++){}for(aD=w((aC-H(au,0))/30.42);H(au,aD+1)<=aC;aD++){}aC=1+aC-H(au,aD);ao=(ax%86400000+86400000)%86400000;aA=w(ao/3600000)%24;ay=w(ao/60000)%60;av=w(ao/1000)%60;ar=ao%1000}else{au=ax.getUTCFullYear();aD=ax.getUTCMonth();aC=ax.getUTCDate();aA=ax.getUTCHours();ay=ax.getUTCMinutes();av=ax.getUTCSeconds();ar=ax.getUTCMilliseconds()}ax=(au<=0||au>=10000?(au<0?"-":"+")+x(6,au<0?-au:au):x(4,au))+"-"+x(2,aD+1)+"-"+x(2,aC)+"T"+x(2,aA)+":"+x(2,ay)+":"+x(2,av)+"."+x(3,ar)+"Z"}else{ax=null}}else{if(typeof ax.toJSON=="function"&&((ai!=R&&ai!=S&&ai!=I)||v.call(ax,"toJSON"))){ax=ax.toJSON(am)}}}if(ak){ax=ak.call(aE,am,ax)}if(ax===null){return"null"}ai=y.call(ax);if(ai==E){return""+ax}else{if(ai==R){return ax>-1/0&&ax<1/0?""+ax:"null"}else{if(ai==S){return G(""+ax)}}}if(typeof ax=="object"){for(aj=an.length;aj--;){if(an[aj]===ax){throw ae()}}an.push(ax);aw=[];az=ag;ag+=aB;if(ai==I){for(al=0,aj=ax.length;al0){for(ah="",aj>10&&(aj=10);ah.length=48&&ah<=57||ah>=97&&ah<=102||ah>=65&&ah<=70)){L()}}ak+=Q("0x"+al.slice(ai,K));break;default:L()}}else{if(ah==34){break}ah=al.charCodeAt(K);ai=K;while(ah>=32&&ah!=92&&ah!=34){ah=al.charCodeAt(++K)}ak+=al.slice(ai,K)}}}if(al.charCodeAt(K)==34){K++;return ak}L();default:ai=K;if(ah==45){am=true;ah=al.charCodeAt(++K)}if(ah>=48&&ah<=57){if(ah==48&&((ah=al.charCodeAt(K+1)),ah>=48&&ah<=57)){L()}am=false;for(;K=48&&ah<=57);K++){}if(al.charCodeAt(K)==46){ag=++K;for(;ag=48&&ah<=57);ag++){}if(ag==K){L()}K=ag}ah=al.charCodeAt(K);if(ah==101||ah==69){ah=al.charCodeAt(++K);if(ah==43||ah==45){K++}for(ag=K;ag=48&&ah<=57);ag++){}if(ag==K){L()}K=ag}return +al.slice(ai,K)}if(am){L()}if(al.slice(K,K+4)=="true"){K+=4;return true}else{if(al.slice(K,K+5)=="false"){K+=5;return false}else{if(al.slice(K,K+4)=="null"){K+=4;return null}}}L()}}return"$"};var aa=function(ah){var ag,ai;if(ah=="$"){L()}if(typeof ah=="string"){if((J?ah.charAt(0):ah[0])=="@"){return ah.slice(1)}if(ah=="["){ag=[];for(;;ai||(ai=true)){ah=C();if(ah=="]"){break}if(ai){if(ah==","){ah=C();if(ah=="]"){L()}}else{L()}}if(ah==","){L()}ag.push(aa(ah))}return ag}else{if(ah=="{"){ag={};for(;;ai||(ai=true)){ah=C();if(ah=="}"){break}if(ai){if(ah==","){ah=C();if(ah=="}"){L()}}else{L()}}if(ah==","||typeof ah!="string"||(J?ah.charAt(0):ah[0])!="@"||C()!=":"){L()}ag[ah.slice(1)]=aa(C())}return ag}}L()}return ah};var T=function(ai,ah,aj){var ag=A(ai,ah,aj);if(ag===P){delete ai[ah]}else{ai[ah]=ag}};var A=function(aj,ai,ak){var ah=aj[ai],ag;if(typeof ah=="object"&&ah){if(y.call(ah)==I){for(ag=ah.length;ag--;){T(ah,ag,ak)}}else{q(ah,function(al){T(ah,al,ak)})}}return ak.call(aj,ai,ah)};Z.parse=function(ai,aj){var ag,ah;K=0;ab=""+ai;ag=aa(C());if(C()!="$"){L()}K=ab=null;return aj&&y.call(aj)==Y?A((ah={},ah[""]=ag,ah),"",aj):ag}}}Z.runInContext=n;return Z}if(l&&!g){n(m,l)}else{var j=m.JSON,o=m.JSON3,h=false;var k=n(m,(m.JSON3={noConflict:function(){if(!h){h=true;m.JSON=j;m.JSON3=o;j=o=null}return k}}));m.JSON={parse:k.parse,stringify:k.stringify}}if(g){define(function(){return k})}}).call(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],4:[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;v0){return 2000}}return 16000}},{}],11:[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}},{}],12:[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}},{}],13:[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(typeof window==="undefined"){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(typeof p.async==="boolean"){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||s==="xhr")&&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(s==="jsonp"){j.call(t)}else{if(s==="beacon"){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":20,"./get-xhr-object":11,superagent:4}],14:[function(d,f,c){var b="undefined"!==typeof window?window:this;var h=b.Keen;var g=d("./utils/emitter-shim");function a(i){this.configure(i||{});a.trigger("client",this)}a.debug=false;a.enabled=true;a.loaded=true;a.version="3.4.0-rc4";g(a);g(a.prototype);a.prototype.configure=function(i){var j=i||{};if(j.host){j.host.replace(/.*?:\/\//g,"")}if(j.protocol&&j.protocol==="auto"){j.protocol=location.protocol.replace(/:/g,"")}this.config={projectId:j.projectId,writeKey:j.writeKey,readKey:j.readKey,masterKey:j.masterKey,requestType:j.requestType||"jsonp",host:j.host||"api.keen.io/3.0",protocol:j.protocol||"https",globalProperties:null};if(a.debug){this.on("error",a.log)}this.trigger("ready")};a.prototype.projectId=function(i){if(!arguments.length){return this.config.projectId}this.config.projectId=(i?String(i):null);return this};a.prototype.masterKey=function(i){if(!arguments.length){return this.config.masterKey}this.config.masterKey=(i?String(i):null);return this};a.prototype.readKey=function(i){if(!arguments.length){return this.config.readKey}this.config.readKey=(i?String(i):null);return this};a.prototype.writeKey=function(i){if(!arguments.length){return this.config.writeKey}this.config.writeKey=(i?String(i):null);return this};a.prototype.url=function(i){if(!this.projectId()){this.trigger("error","Client is missing projectId property");return}return this.config.protocol+"://"+this.config.host+"/projects/"+this.projectId()+i};a.log=function(i){if(a.debug&&typeof console=="object"){console.log("[Keen IO]",i)}};a.noConflict=function(){b.Keen=h;return a};a.ready=function(i){if(a.loaded){i()}else{a.once("ready",i)}};f.exports=a},{"./utils/emitter-shim":21}],15:[function(f,c,h){var p=f("../utils/json-shim");var g=f("superagent");var i=f("../index");var j=f("../utils/base64"),m=f("../utils/each"),n=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"),o=f("../helpers/superagent-handle-response");c.exports=function(x,A,B,t){var C=this,v=this.url("/events/"+encodeURIComponent(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&&n()==="browser"){g.get(z).use(k(q,{async:r})).end(w)}else{if(a()||n()==="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){o(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(p.stringify(r)),modified:new Date().getTime()});return(q.length2){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":8,"../helpers/get-xhr-object":11,"../helpers/superagent-handle-response":12,"../helpers/superagent-request-types":13,"../index":14,"../utils/each":20,superagent:4}],17:[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)}}},{}],18:[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 or 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":15}],19:[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}}}},{}],20:[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;h1)))/4)-x((ah-1901+ai)/100)+x((ah-1601+ai)/400)}}if(!(w=s.hasOwnProperty)){w=function(aj){var ah={},ai;if((ah.__proto__=null,ah.__proto__={toString:1},ah).toString!=z){w=function(am){var al=this.__proto__,ak=am in (this.__proto__=null,this);this.__proto__=al;return ak}}else{ai=ah.constructor;w=function(al){var ak=(this.constructor||ai).prototype;return al in this&&!(al in ak&&this[al]===ak[al])}}ah=null;return w.call(this,aj)}}r=function(aj,am){var ak=0,ah,ai,al;(ah=function(){this.valueOf=0}).prototype.valueOf=0;ai=new ah();for(al in ai){if(w.call(ai,al)){ak++}}ah=ai=null;if(!ak){ai=["valueOf","toString","toLocaleString","propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"];r=function(ao,at){var ar=z.call(ao)==Z,aq,ap;var an=!ar&&typeof ao.constructor!="function"&&j[typeof ao.hasOwnProperty]&&ao.hasOwnProperty||w;for(aq in ao){if(!(ar&&aq=="prototype")&&an.call(ao,aq)){at(aq)}}for(ap=ai.length;aq=ai[--ap];an.call(ao,aq)&&at(aq)){}}}else{if(ak==2){r=function(ao,ar){var an={},aq=z.call(ao)==Z,ap;for(ap in ao){if(!(aq&&ap=="prototype")&&!w.call(an,ap)&&(an[ap]=1)&&w.call(ao,ap)){ar(ap)}}}}else{r=function(ao,ar){var aq=z.call(ao)==Z,ap,an;for(ap in ao){if(!(aq&&ap=="prototype")&&w.call(ao,ap)&&!(an=ap==="constructor")){ar(ap)}}if(an||w.call(ao,(ap="constructor"))){ar(ap)}}}}return r(aj,am)};if(!t("json-stringify")){var v={92:"\\\\",34:'\\"',8:"\\b",12:"\\f",10:"\\n",13:"\\r",9:"\\t"};var N="000000";var y=function(ah,ai){return(N+(ai||0)).slice(-ah)};var E="\\u00";var H=function(an){var ai='"',al=0,am=an.length,ah=!K||am>10;var ak=ah&&(K?an.split(""):an);for(;al-1/0&&ay<1/0){if(I){aD=x(ay/86400000);for(av=x(aD/365.2425)+1970-1;I(av+1,0)<=aD;av++){}for(aE=x((aD-I(av,0))/30.42);I(av,aE+1)<=aD;aE++){}aD=1+aD-I(av,aE);ap=(ay%86400000+86400000)%86400000;aB=x(ap/3600000)%24;az=x(ap/60000)%60;aw=x(ap/1000)%60;at=ap%1000}else{av=ay.getUTCFullYear();aE=ay.getUTCMonth();aD=ay.getUTCDate();aB=ay.getUTCHours();az=ay.getUTCMinutes();aw=ay.getUTCSeconds();at=ay.getUTCMilliseconds()}ay=(av<=0||av>=10000?(av<0?"-":"+")+y(6,av<0?-av:av):y(4,av))+"-"+y(2,aE+1)+"-"+y(2,aD)+"T"+y(2,aB)+":"+y(2,az)+":"+y(2,aw)+"."+y(3,at)+"Z"}else{ay=null}}else{if(typeof ay.toJSON=="function"&&((aj!=S&&aj!=T&&aj!=J)||w.call(ay,"toJSON"))){ay=ay.toJSON(an)}}}if(al){ay=al.call(aF,an,ay)}if(ay===null){return"null"}aj=z.call(ay);if(aj==F){return""+ay}else{if(aj==S){return ay>-1/0&&ay<1/0?""+ay:"null"}else{if(aj==T){return H(""+ay)}}}if(typeof ay=="object"){for(ak=ao.length;ak--;){if(ao[ak]===ay){throw af()}}ao.push(ay);ax=[];aA=ah;ah+=aC;if(aj==J){for(am=0,ak=ay.length;am0){for(ai="",ak>10&&(ak=10);ai.length=48&&ai<=57||ai>=97&&ai<=102||ai>=65&&ai<=70)){M()}}al+=R("0x"+am.slice(aj,L));break;default:M()}}else{if(ai==34){break}ai=am.charCodeAt(L);aj=L;while(ai>=32&&ai!=92&&ai!=34){ai=am.charCodeAt(++L)}al+=am.slice(aj,L)}}}if(am.charCodeAt(L)==34){L++;return al}M();default:aj=L;if(ai==45){an=true;ai=am.charCodeAt(++L)}if(ai>=48&&ai<=57){if(ai==48&&((ai=am.charCodeAt(L+1)),ai>=48&&ai<=57)){M()}an=false;for(;L=48&&ai<=57);L++){}if(am.charCodeAt(L)==46){ah=++L;for(;ah=48&&ai<=57);ah++){}if(ah==L){M()}L=ah}ai=am.charCodeAt(L);if(ai==101||ai==69){ai=am.charCodeAt(++L);if(ai==43||ai==45){L++}for(ah=L;ah=48&&ai<=57);ah++){}if(ah==L){M()}L=ah}return +am.slice(aj,L)}if(an){M()}if(am.slice(L,L+4)=="true"){L+=4;return true}else{if(am.slice(L,L+5)=="false"){L+=5;return false}else{if(am.slice(L,L+4)=="null"){L+=4;return null}}}M()}}return"$"};var ab=function(ai){var ah,aj;if(ai=="$"){M()}if(typeof ai=="string"){if((K?ai.charAt(0):ai[0])=="@"){return ai.slice(1)}if(ai=="["){ah=[];for(;;aj||(aj=true)){ai=D();if(ai=="]"){break}if(aj){if(ai==","){ai=D();if(ai=="]"){M()}}else{M()}}if(ai==","){M()}ah.push(ab(ai))}return ah}else{if(ai=="{"){ah={};for(;;aj||(aj=true)){ai=D();if(ai=="}"){break}if(aj){if(ai==","){ai=D();if(ai=="}"){M()}}else{M()}}if(ai==","||typeof ai!="string"||(K?ai.charAt(0):ai[0])!="@"||D()!=":"){M()}ah[ai.slice(1)]=ab(D())}return ah}}M()}return ai};var U=function(aj,ai,ak){var ah=B(aj,ai,ak);if(ah===Q){delete aj[ai]}else{aj[ai]=ah}};var B=function(ak,aj,al){var ai=ak[aj],ah;if(typeof ai=="object"&&ai){if(z.call(ai)==J){for(ah=ai.length;ah--;){U(ai,ah,al)}}else{r(ai,function(am){U(ai,am,al)})}}return al.call(ak,aj,ai)};aa.parse=function(aj,ak){var ah,ai;L=0;ac=""+aj;ah=ab(D());if(D()!="$"){M()}L=ac=null;return ak&&z.call(ak)==Z?B((ai={},ai[""]=ah,ai),"",ak):ah}}}aa.runInContext=o;return aa}if(m&&!g){o(n,m)}else{var k=n.JSON,p=n.JSON3,h=false;var l=o(n,(n.JSON3={noConflict:function(){if(!h){h=true;n.JSON=k;n.JSON3=p;k=p=null}return l}}));n.JSON={parse:l.parse,stringify:l.stringify}}if(g){define(function(){return l})}}).call(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],4:[function(b,c,a){c.exports=function(g,j,h){var f=0;var d=g.length;var k=arguments.length==3?h:g[f++];while(f>1)+"px"})}for(;v',v)}n.addRule(".spin-vml","behavior:url(#default#VML)");f.prototype.lines=function(x,w){var v=w.scale*(w.length+w.width),D=w.scale*2*v;function C(){return k(u("group",{coordsize:D+" "+D,coordorigin:-v+" "+-v}),{width:D,height:D})}var y=-(w.width+w.length)*w.scale*2+"px",B=k(C(),{position:"absolute",top:y,left:y}),A;function z(F,E,G){m(B,m(k(C(),{rotation:360/w.lines*F+"deg",left:~~E}),m(k(u("roundrect",{arcsize:w.corners}),{width:v,height:w.scale*w.width,left:w.scale*w.radius,top:-w.scale*w.width>>1,filter:G}),u("fill",{color:r(w.color,F),opacity:w.opacity}),u("stroke",{opacity:0}))))}if(w.shadow){for(A=1;A<=w.lines;A++){z(A,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)")}}for(A=1;A<=w.lines;A++){z(A)}return m(x,B)};f.prototype.opacity=function(w,v,y,x){var z=w.firstChild;x=x.shadow&&x.lines||0;if(z&&v+x0){return 2000}}return 16000}},{}],13:[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}},{}],14:[function(b,c,a){c.exports=function(h,g,j){var f=j||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}},{}],15:[function(f,b,g){var o=f("superagent");var m=f("../utils/each"),a=f("./get-xhr-object");b.exports=function(p,q){return function(r){var s=r.constructor.prototype.end;if(typeof window==="undefined"){return}r.requestType=r.requestType||{};r.requestType.type=p;r.requestType.options=r.requestType.options||{async:true,success:{responseText:'{ "created": true }',status:201},error:{responseText:'{ "error_code": "ERROR", "message": "Request failed" }',status:404}};if(q){if(typeof q.async==="boolean"){r.requestType.options.async=q.async}if(q.success){extend(r.requestType.options.success,q.success)}if(q.error){extend(r.requestType.options.error,q.error)}}r.end=function(v){var u=this,t=(this.requestType)?this.requestType.type:"xhr",x,w;if(("GET"!==u.method||t==="xhr")&&u.requestType.options.async){s.call(u,v);return}x=u._query.join("&");w=u._timeout;u._callback=v||noop;if(w&&!u._timer){u._timer=setTimeout(function(){h.call(u)},w)}if(x){x=o.serializeObject(x);u.url+=~u.url.indexOf("?")?"&"+x:"?"+x}u.emit("request",u);if(!u.requestType.options.async){l.call(u)}else{if(t==="jsonp"){k.call(u)}else{if(t==="beacon"){j.call(u)}}}return u};return r}};function l(){var p=a();if(p){p.open("GET",this.url,false);p.send(null)}return this}function k(){var q=this,u=new Date().getTime(),p=document.createElement("script"),t=document.getElementsByTagName("head")[0],v="keenJSONPCallback",r=false;v+=u;while(v in window){v+="a"}window[v]=function(w){if(r===true){return}r=true;d.call(q,w);s()};p.src=q.url+"&jsonp="+v;t.appendChild(p);p.onreadystatechange=function(){if(r===false&&q.readyState==="loaded"){r=true;c.call(q);s()}};p.onerror=function(){if(r===false){r=true;c.call(q);s()}};function s(){window[v]=undefined;try{delete window[v]}catch(w){}t.removeChild(p)}}function j(){var q=this,p=document.createElement("img"),r=false;p.onload=function(){r=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(q)};p.onerror=function(){r=true;c.call(q)};p.src=q.url+"&c=clv1"}function d(q){var r=this.requestType.options["success"],p="";n.call(this,r);if(q){try{p=JSON.stringify(q)}catch(s){}}else{p=r.responseText}this.xhr.responseText=p;this.xhr.status=r.status;this.emit("end")}function c(){var p=this.requestType.options["error"];n.call(this,p);this.xhr.responseText=p.responseText;this.xhr.status=p.status;this.emit("end")}function h(){this.aborted=true;this.clearTimeout();this.emit("abort")}function n(p){this.xhr={getAllResponseHeaders:function(){return""},getResponseHeader:function(){return"application/json"},responseText:p.responseText,status:p.status};return this}},{"../utils/each":29,"./get-xhr-object":13,superagent:6}],16:[function(d,f,c){var b="undefined"!==typeof window?window:this;var h=b.Keen;var g=d("./utils/emitter-shim");function a(j){this.configure(j||{});a.trigger("client",this)}a.debug=false;a.enabled=true;a.loaded=true;a.version="3.4.0-rc4";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},{"./utils/emitter-shim":30}],17:[function(f,c,h){var q=f("../utils/json-shim");var g=f("superagent");var j=f("../index");var k=f("../utils/base64"),n=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"),l=f("../helpers/superagent-request-types"),p=f("../helpers/superagent-handle-response");c.exports=function(y,B,C,u){var D=this,w=this.url("/events/"+encodeURIComponent(y)),r=this.config.requestType,v={},t=C,s,A;s=("boolean"===typeof u)?u:true;if(!j.enabled){z.call(D,"Keen.enabled = false");return}if(!D.projectId()){z.call(D,"Missing projectId property");return}if(!D.writeKey()){z.call(D,"Missing writeKey property");return}if(!y||typeof y!=="string"){z.call(D,"Collection name must be a string");return}if(D.config.globalProperties){v=D.config.globalProperties(y)}n(B,function(F,E){v[E]=F});if(!a()&&"xhr"===r){r="jsonp"}if("xhr"!==r||!s){A=m.call(D,w,v)}if(A&&o()==="browser"){g.get(A).use(l(r,{async:s})).end(x)}else{if(a()||o()==="server"){g.post(w).set("Content-Type","application/json").set("Authorization",D.writeKey()).send(v).end(x)}else{D.trigger("error","Request not sent: URL length exceeds current browser limit, and XHR (POST) is not supported.")}}function x(F,E){p(F,E,t);t=C=null}function z(F){var E="Event not recorded: "+F;D.trigger("error",E);if(t){t.call(D,E,null);t=C=null}}return};function m(r,s){r+=d({api_key:this.writeKey(),data:k.encode(q.stringify(s)),modified:new Date().getTime()});return(r.length2){r.call(o,"Incorrect arguments provided to #addEvents method");return}if(typeof q!=="object"||q instanceof Array){r.call(o,"Request payload must be an object");return}if(o.config.globalProperties){j(q,function(t,u){j(t,function(v,w){var x=o.config.globalProperties(u);j(v,function(z,y){x[y]=z});p[u].push(x)})})}else{p=q}if(a()||k()==="server"){d.post(n).set("Content-Type","application/json").set("Authorization",o.writeKey()).send(p).end(function(u,t){l(u,t,m);m=s=null})}else{o.trigger("error","Events not recorded: XHR support is required for batch upload")}function r(u){var t="Events not recorded: "+u;o.trigger("error",t);if(m){m.call(o,t,null);m=s=null}}return}},{"../helpers/get-context":9,"../helpers/get-xhr-object":13,"../helpers/superagent-handle-response":14,"../helpers/superagent-request-types":15,"../index":16,"../utils/each":29,superagent:6}],19:[function(d,f,c){var h=d("superagent");var b=d("../helpers/get-query-string"),g=d("../helpers/superagent-handle-response"),a=d("../helpers/superagent-request-types");f.exports=function(k,n,m,o){var j=this.config.requestType,l=n||{};if(j==="beacon"){j="jsonp"}l.api_key=l.api_key||m;h.get(k+b(l)).use(a(j)).end(function(q,p){g(q,p,o);o=null})}},{"../helpers/get-query-string":10,"../helpers/superagent-handle-response":14,"../helpers/superagent-request-types":15,superagent:6}],20:[function(b,c,a){var f=b("superagent");var d=b("../helpers/superagent-handle-response");c.exports=function(g,j,h,k){f.post(g).set("Content-Type","application/json").set("Authorization",h).send(j||{}).end(function(m,l){d(m,l,k);k=null})}},{"../helpers/superagent-handle-response":14,superagent:6}],21:[function(b,d,a){var c=b("../request");d.exports=function(k,l){var h=[],g=l,j;if(!this.config.projectId||!this.config.projectId.length){f.call(this,"Missing projectId property")}if(!this.config.readKey||!this.config.readKey.length){f.call(this,"Missing readKey property")}function f(n){var m="Query not sent: "+n;this.trigger("error",m);if(g){g.call(this,m,null);g=l=null}}if(k instanceof Array){h=k}else{h.push(k)}j=new c(this,h,g).refresh();g=l=null;return j}},{"../request":25}],22:[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)}}},{}],23:[function(b,c,a){var d=b("./addEvent");c.exports=function(l,f,o,m,n){var p=l,k=(p.currentTarget)?p.currentTarget:(p.srcElement||p.target),g=m||500,h=false,r="",q,j;if(k.getAttribute!==void 0){r=k.getAttribute("target")}else{if(k.target){r=k.target}}if((r=="_blank"||r=="blank")&&!p.metaKey){j=window.open("about:blank");j.document.location=k.href}if(k.nodeName==="A"){q=function(){if(!h&&!p.metaKey&&(r!=="_blank"&&r!=="blank")){h=true;window.location=k.href}}}else{if(k.nodeName==="FORM"){q=function(){if(!h){h=true;k.submit()}}}else{this.trigger("error","#trackExternalLink method not attached to an or DOM element")}}if(n){q=function(){if(!h){h=true;n()}}}d.call(this,f,o,q);setTimeout(q,g);if(!p.metaKey){return false}}},{"./addEvent":17}],24:[function(c,a,d){var k=c("./utils/each"),h=c("./utils/extend"),g=c("./helpers/get-timezone-offset"),b=c("./helpers/get-query-string");var j=c("./utils/emitter-shim");function f(){this.configure.apply(this,arguments)}j(f.prototype);f.prototype.configure=function(l,m){this.analysis=l;this.params=this.params||{};this.set(m);if(this.params.timezone===void 0){this.params.timezone=g()}return this};f.prototype.set=function(m){var l=this;k(m,function(o,n){var p=n,q=o;if(n.match(new RegExp("[A-Z]"))){p=n.replace(/([A-Z])/g,function(r){return"_"+r.toLowerCase()})}l.params[p]=q;if(q instanceof Array){k(q,function(s,r){if(s instanceof Array==false&&typeof s==="object"){k(s,function(u,t){if(t.match(new RegExp("[A-Z]"))){var v=t.replace(/([A-Z])/g,function(w){return"_"+w.toLowerCase()});delete l.params[p][r][t];l.params[p][r][v]=u}})}})}});return l};f.prototype.get=function(m){var l=m;if(l.match(new RegExp("[A-Z]"))){l=l.replace(/([A-Z])/g,function(n){return"_"+n.toLowerCase()})}if(this.params){return this.params[l]||null}};f.prototype.addFilter=function(n,l,m){this.params.filters=this.params.filters||[];this.params.filters.push({property_name:n,operator:l,property_value:m});return this};a.exports=f},{"./helpers/get-query-string":10,"./helpers/get-timezone-offset":11,"./utils/each":29,"./utils/emitter-shim":30,"./utils/extend":31}],25:[function(c,b,d){var m=c("./utils/each"),k=c("./utils/extend"),h=c("./utils/sendQuery"),j=c("./utils/sendSavedQuery");var l=c("./utils/emitter-shim");var g=c("./");var f=c("./query");function a(o,p,q){var n=q;this.config={timeout:300*1000};this.configure(o,p,n);n=q=null}l(a.prototype);a.prototype.configure=function(o,p,q){var n=q;k(this,{client:o,queries:p,data:{},callback:n});n=q=null;return this};a.prototype.timeout=function(n){if(!arguments.length){return this.config.timeout}this.config.timeout=(!isNaN(parseInt(n))?parseInt(n):null);return this};a.prototype.refresh=function(){var p=this,n=0,o=[],r=false;var q=function(u,t,s){if(r){return}if(u){p.trigger("error",u);if(p.callback){p.callback(u,null)}r=true;return}o[s]=t;n++;if(n==p.queries.length&&!r){p.data=(p.queries.length==1)?o[0]:o;p.trigger("complete",null,p.data);if(p.callback){p.callback(null,p.data)}}};m(p.queries,function(v,t){var s=function(y,x){q(y,x,t)};var w="/queries";if(typeof v==="string"){w+="/saved/"+v+"/result";j.call(p,w,{},s)}else{if(v instanceof f){w+="/"+v.analysis;if(v.analysis==="saved"){w+="/"+v.params.query_name+"/result";j.call(p,w,{},s)}else{h.call(p,w,v.params,s)}}else{var u={statusText:"Bad Request",responseText:{message:"Error: Query "+(+t+1)+" of "+p.queries.length+" for project "+p.client.projectId()+" is not a valid request"}};p.trigger("error",u.responseText.message);if(p.callback){p.callback(u.responseText.message,null)}}}});return this};b.exports=a},{"./":16,"./query":24,"./utils/each":29,"./utils/emitter-shim":30,"./utils/extend":31,"./utils/sendQuery":34,"./utils/sendSavedQuery":35}],26:[function(c,d,b){var g=c("superagent");var a=c("./helpers/superagent-handle-response");function f(){var h=this;this.all=function(l){var j=h.url("/queries/saved");g.get(j).set("Content-Type","application/json").set("Authorization",h.masterKey()).end(k);function k(n,m){a(n,m,l);l=null}};this.get=function(l,m){var j=h.url("/queries/saved/"+l);g.get(j).set("Content-Type","application/json").set("Authorization",h.masterKey()).end(k);function k(o,n){a(o,n,m);m=null}};this.update=function(m,j,n){var k=h.url("/queries/saved/"+m);g.put(k).set("Content-Type","application/json").set("Authorization",h.masterKey()).send(j||{}).end(l);function l(p,o){a(p,o,n);n=null}};this.create=this.update;this.destroy=function(l,m){var j=h.url("/queries/saved/"+l);g.del(j).set("Content-Type","application/json").set("Authorization",h.masterKey()).end(k);function k(o,n){a(o,n,m);m=null}};return this}d.exports=f},{"./helpers/superagent-handle-response":14,superagent:6}],27:[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}}}},{}],28:[function(b,d,a){var c=b("./json-shim");d.exports=function(f){return c.parse(c.stringify(f))}},{"./json-shim":32}],29:[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;h0){this.parse.apply(this,arguments)}}b.defaults={delimeter:" -> "};o(b);o(b.prototype);b.parser=g("./utils/parsers")(b);b.prototype.input=function(q){if(!arguments.length){return this["data"]["input"]}this["data"]["input"]=(q?n(q):null);return this};b.prototype.output=function(q){if(!arguments.length){return this["data"].output}this["data"].output=(q instanceof Array?q:null);return this};b.prototype.method=function(q){if(!arguments.length){return this.meta.method}this.meta.method=(q?String(q):null);return this};b.prototype.schema=function(q){if(!arguments.length){return this.meta.schema}this.meta.schema=(q?q:null);return this};b.prototype.parse=function(r,s){var q;if(r){this.input(r)}if(s){this.schema(s)}this.output([[]]);if(this.meta.schema.select){this.method("select");q=m({records:"",select:true},this.schema());f.call(this,d(q))}else{if(this.meta.schema.unpack){this.method("unpack");q=m({records:"",unpack:{index:false,value:false,label:false}},this.schema());l.call(this,d(q))}}return this};function f(s){var t=this,u=s||{},v=[],w=[];var r,q;if(u.records===""||!u.records){r=[t.input()]}else{q=u.records.split(b.defaults.delimeter);r=h.apply(t,[t.input()].concat(q))[0]}p(u.select,function(y){v.push(y.path.split(b.defaults.delimeter))});if(v.length==0){p(r,function(y,z){var B=a(y);for(var A in B){if(B.hasOwnProperty(A)&&w.indexOf(A)==-1){w.push(A);v.push([A])}}})}var x=[[]];p(v,function(z,y){if(v.length==1){x[0].push("label","value")}else{x[0].push(z.join("."))}});p(r,function(y,z){var A=a(y);if(v.length==1){x.push([v.join("."),A[v.join(".")]])}else{x.push([]);p(v,function(C,B){var D=C.join(".");x[z+1].push(A[D])})}});t.output(x);t.format(u.select);return t}function l(z){var y=this,u=[];var s=(z.unpack.value)?z.unpack.value.path.split(b.defaults.delimeter):false,r=(z.unpack.label)?z.unpack.label.path.split(b.defaults.delimeter):false,t=(z.unpack.index)?z.unpack.index.path.split(b.defaults.delimeter):false;var v=(s[s.length-1]!=="")?s[s.length-1]:"Value",q=(r[r.length-1]!=="")?r[r.length-1]:"Label",x=(t[t.length-1]!=="")?t[t.length-1]:"Index";var w=(function(){var A;if(z.records==""){A=[y.input()]}else{A=h.apply(y,[y.input()].concat(z.records.split(b.defaults.delimeter)))}return A[0]})();if(w instanceof Array==false){w=[w]}p(w,function(A,B){var C=(r)?h.apply(y,[A].concat(r)):[];if(C){u=C}});p(w,function(B,C){var D=(s)?h.apply(y,[B].concat(s)):false,A=(t)?h.apply(y,[B].concat(t)):false;if(A){p(A,function(){y.data.output.push([])})}else{y.data.output.push([])}if(A){if(C==0){y.data.output[0].push(x);if(u.length>0){p(u,function(F,E){y.data.output[0].push(F)})}else{y.data.output[0].push(v)}}if(w.length0){y.data.output[E].push(A[E-1])}})}}else{y.data.output[C+1].push(A[0])}}if(!A&&u.length>0){if(C==0){y.data.output[0].push(q);y.data.output[0].push(v)}y.data.output[C+1].push(u[0])}if(!A&&u.length==0){y.data.output[0].push("")}if(D){if(w.length0){y.data.output[E].push(D[E-1])}})}}else{p(D,function(E){y.data.output[C+1].push(E)})}}else{p(y.data.output[0],function(E,F){var G=(A)?0:-1;if(F>G){y.data.output[C+1].push(null)}})}});y.format(z.unpack);return this}function d(q){p(q.unpack,function(t,s,r){if(t&&k(t,"string")){q.unpack[s]={path:q.unpack[s]}}});return q}function k(r,q){r=typeof(r);if(!q){return r!="undefined"}return r==q}function m(r,q){p(q,function(s,t){if(k(r[t],"object")&&k(s,"object")){r[t]=m(r[t],s)}else{if(s!==null){r[t]=s}}});return r}c.exports=b},{"../core/utils/clone":28,"../core/utils/each":29,"../core/utils/emitter-shim":30,"./utils/flatten":49,"./utils/parse":50,"./utils/parsers":51}],37:[function(b,c,a){var f=b("../core/utils/extend"),d=b("./dataset");f(d.prototype,b("./lib/append"));f(d.prototype,b("./lib/delete"));f(d.prototype,b("./lib/filter"));f(d.prototype,b("./lib/insert"));f(d.prototype,b("./lib/select"));f(d.prototype,b("./lib/set"));f(d.prototype,b("./lib/sort"));f(d.prototype,b("./lib/update"));f(d.prototype,b("./lib/analyses"));f(d.prototype,{format:b("./lib/format")});c.exports=d},{"../core/utils/extend":31,"./dataset":36,"./lib/analyses":38,"./lib/append":39,"./lib/delete":40,"./lib/filter":41,"./lib/format":42,"./lib/insert":43,"./lib/select":44,"./lib/set":45,"./lib/sort":46,"./lib/update":47}],38:[function(d,f,c){var g=d("../../core/utils/each"),a=["Average","Maximum","Minimum","Sum"],b={};b.average=function(h,n,j){var m=h.slice(n||0,(j?j+1:h.length)),k=0,l=null;g(m,function(p,o){if(typeof p==="number"&&!isNaN(parseFloat(p))){k+=parseFloat(p)}});return k/m.length};b.maximum=function(h,m,j){var l=h.slice(m||0,(j?j+1:h.length)),k=[];g(l,function(o,n){if(typeof o==="number"&&!isNaN(parseFloat(o))){k.push(parseFloat(o))}});return Math.max.apply(Math,k)};b.minimum=function(h,m,j){var l=h.slice(m||0,(j?j+1:h.length)),k=[];g(l,function(o,n){if(typeof o==="number"&&!isNaN(parseFloat(o))){k.push(parseFloat(o))}});return Math.min.apply(Math,k)};b.sum=function(h,m,j){var l=h.slice(m||0,(j?j+1:h.length)),k=0;g(l,function(o,n){if(typeof o==="number"&&!isNaN(parseFloat(o))){k+=parseFloat(o)}});return k};g(a,function(h,j){b["getColumn"+h]=b["getRow"+h]=function(k){return this[h.toLowerCase()](k,1)}});b.getColumnLabel=b.getRowIndex=function(h){return h[0]};f.exports=b},{"../../core/utils/each":29}],39:[function(d,f,c){var h=d("../../core/utils/each");var b=d("../utils/create-null-list");f.exports={appendColumn:g,appendRow:a};function g(n,k){var j=this,m=Array.prototype.slice.call(arguments,2),l=(n!==undefined)?n:null;if(typeof k==="function"){j.data.output[0].push(l);h(j.output(),function(q,p){var o;if(p>0){o=k.call(j,q,p);if(typeof o==="undefined"){o=null}j.data.output[p].push(o)}})}else{if(!k||k instanceof Array){k=k||[];if(k.length<=j.output().length-1){k=k.concat(b(j.output().length-1-k.length))}else{h(k,function(p,o){if(j.data.output.length-10){q=j.selectColumn(s);p=k.call(j,q,s);if(typeof p==="undefined"){p=null}l.push(p)}});j.data.output.push(l)}else{if(!k||k instanceof Array){k=k||[];if(k.length<=j.data.output[0].length-1){k=k.concat(b(j.data.output[0].length-1-k.length))}else{h(k,function(q,p){if(j.data.output[0].length-1-1){g(h.data.output,function(m,l){h.data.output[l].splice(j,1)})}return h}function b(j){var h=(typeof j==="number")?j:this.selectColumn(0).indexOf(j);if(h>-1){this.data.output.splice(h,1)}return this}},{"../../core/utils/each":29}],41:[function(c,d,b){var f=c("../../core/utils/each");d.exports={filterColumns:a,filterRows:g};function a(j){var h=this,k=new Array();f(h.data.output,function(m,l){k.push([])});f(h.data.output[0],function(l,m){var n=h.selectColumn(m);if(m==0||j.call(h,n,m)){f(n,function(o,p){k[p].push(o)})}});h.output(k);return h}function g(j){var h=this,k=[];f(h.output(),function(m,l){if(l==0||j.call(h,m,l)){k.push(m)}});h.output(k);return h}},{"../../core/utils/each":29}],42:[function(c,d,b){var f=c("../../core/utils/each");d.exports=function(h){var g=this;if(this.method()==="select"){f(g.output(),function(k,j){if(j==0){f(k,function(l,m){if(h[m]&&h[m].label){g.data.output[j][m]=h[m].label}})}else{f(k,function(l,m){g.data.output[j][m]=a(g.data.output[j][m],h[m])})}})}if(this.method()==="unpack"){if(h.index){f(g.output(),function(k,j){if(j==0){if(h.index.label){g.data.output[j][0]=h.index.label}}else{g.data.output[j][0]=a(g.data.output[j][0],h.index)}})}if(h.label){if(h.index){f(g.output(),function(k,j){f(k,function(l,m){if(j==0&&m>0){g.data.output[j][m]=a(g.data.output[j][m],h.label)}})})}else{f(g.output(),function(k,j){if(j>0){g.data.output[j][0]=a(g.data.output[j][0],h.label)}})}}if(h.value){if(h.index){f(g.output(),function(k,j){f(k,function(l,m){if(j>0&&m>0){g.data.output[j][m]=a(g.data.output[j][m],h.value)}})})}else{f(g.output(),function(k,j){f(k,function(l,m){if(j>0){g.data.output[j][m]=a(g.data.output[j][m],h.value)}})})}}}return g};function a(k,j){var g=k,h=j||{};if(h.replace){f(h.replace,function(m,l){if(g==l||String(g)==String(l)||parseFloat(g)==parseFloat(l)){g=m}})}if(h.type&&h.type=="date"){if(h.format&&moment&&moment(k).isValid()){g=moment(g).format(h.format)}else{g=new Date(g)}}if(h.type&&h.type=="string"){g=String(g)}if(h.type&&h.type=="number"&&!isNaN(parseFloat(g))){g=parseFloat(g)}return g}},{"../../core/utils/each":29}],43:[function(f,b,g){var j=f("../../core/utils/each");var h=f("../utils/create-null-list");var c=f("./append");var l=c.appendRow,d=c.appendColumn;b.exports={insertColumn:a,insertRow:k};function a(p,q,n){var m=this,o;o=(q!==undefined)?q:null;if(typeof n==="function"){m.data.output[0].splice(p,0,o);j(m.output(),function(t,s){var r;if(s>0){r=n.call(m,t,s);if(typeof r==="undefined"){r=null}m.data.output[s].splice(p,0,r)}})}else{if(!n||n instanceof Array){n=n||[];if(n.length<=m.output().length-1){n=n.concat(h(m.output().length-1-n.length))}else{j(n,function(s,r){if(m.data.output.length-10){t=m.selectColumn(v);s=n.call(m,t,v);if(typeof s==="undefined"){s=null}o.push(s)}});m.data.output.splice(q,0,o)}else{if(!n||n instanceof Array){n=n||[];if(n.length<=m.data.output[0].length-1){n=n.concat(h(m.data.output[0].length-1-n.length))}else{j(n,function(t,s){if(m.data.output[0].length-1-1&&"undefined"!==typeof this.data.output[0][j]){g(this.data.output,function(m,l){h.push(m[j])})}return h}function a(k){var h=new Array(),j=(typeof k==="number")?k:this.selectColumn(0).indexOf(k);if(j>-1&&"undefined"!==typeof this.data.output[j]){h=this.data.output[j]}return h}},{"../../core/utils/each":29}],45:[function(d,f,c){var g=d("../../core/utils/each");var b=d("./append");var a=d("./select");f.exports={set:h};function h(n,m){if(arguments.length<2||n.length<2){throw Error("Incorrect arguments provided for #set method")}var j="number"===typeof n[0]?n[0]:this.data.output[0].indexOf(n[0]),o="number"===typeof n[1]?n[1]:a.selectColumn.call(this,0).indexOf(n[1]);var l=a.selectColumn.call(this,n[0]),k=a.selectRow.call(this,n[1]);if(l.length<1){b.appendColumn.call(this,n[0]);j=this.data.output[0].length-1}if(k.length<1){b.appendRow.call(this,n[1]);o=this.data.output.length-1}this.data.output[o][j]=m;return this}},{"../../core/utils/each":29,"./append":39,"./select":44}],46:[function(d,f,c){var g=d("../../core/utils/each");f.exports={sortColumns:b,sortRows:a};function b(n,j){var h=this,k=this.output()[0].slice(1),m=[],o=[],l=j||this.getColumnLabel;g(k,function(p,q){m.push(h.selectColumn(q+1).slice(0))});m.sort(function(q,p){var r=l.call(h,q)>l.call(h,p);if(r){return(n==="asc"?1:-1)}else{if(!r){return(n==="asc"?-1:1)}else{return 0}}});g(m,function(p,q){h.deleteColumn(q+1).insertColumn(q+1,p[0],p.slice(1))});return h}function a(n,k){var j=this,l=this.output().slice(0,1),h=this.output().slice(1),m=k||this.getRowIndex;h.sort(function(p,o){var q=m.call(j,p)>m.call(j,o);if(q){return(n==="asc"?1:-1)}else{if(!q){return(n==="asc"?-1:1)}else{return 0}}});j.output(l.concat(h));return j}},{"../../core/utils/each":29}],47:[function(f,a,g){var k=f("../../core/utils/each");var h=f("../utils/create-null-list");var b=f("./append");var l=b.appendRow,d=b.appendColumn;a.exports={updateColumn:j,updateRow:c};function j(p,n){var m=this,o=(typeof p==="number")?p:this.data.output[0].indexOf(p);if(o>-1){if(typeof n==="function"){k(m.output(),function(s,r){var q;if(r>0){q=n.call(m,s[o],r,s);if(typeof q!=="undefined"){m.data.output[r][o]=q}}})}else{if(!n||n instanceof Array){n=n||[];if(n.length<=m.output().length-1){n=n.concat(h(m.output().length-1-n.length))}else{k(n,function(r,q){if(m.data.output.length-1-1){if(typeof n==="function"){k(m.output()[o],function(t,s){var r=m.selectColumn(s),q=n.call(m,t,s,r);if(typeof q!=="undefined"){m.data.output[o][s]=q}})}else{if(!n||n instanceof Array){n=n||[];if(n.length<=m.data.output[0].length-1){n=n.concat(h(m.data.output[0].length-1-n.length))}else{k(n,function(r,q){if(m.data.output[0].length-10){return f}};return g.apply(this,arguments)}},{"../../core/utils/each":29}],51:[function(f,c,k){var b;var q=f("../../core/utils/each"),a=f("./flatten");var r={metric:n,interval:j,"grouped-metric":p,"grouped-interval":s,"double-grouped-metric":h,"double-grouped-interval":g,funnel:o,list:l,extraction:d};c.exports=m;function m(t){b=t;return function(v){var u=Array.prototype.slice.call(arguments,1);if(!r[v]){throw"Requested parser does not exist"}else{return r[v].apply(this,u)}}}function n(){return function(t){var u=new b();u.data.input=t;u.parser={name:"metric"};return u.set(["Value","Result"],t.result)}}function j(){var t=Array.prototype.slice.call(arguments);return function(u){var v=new b();q(u.result,function(w,y){var x=t[0]&&t[0]==="timeframe.end"?w.timeframe.end:w.timeframe.start;v.set(["Result",x],w.value)});v.data.input=u;v.parser="interval";v.parser={name:"interval",options:t};return v}}function p(){return function(t){var u=new b();q(t.result,function(v,x){var w;q(v,function(z,y){if(y!=="result"){w=y}});u.set(["Result",String(v[w])],v.result)});u.data.input=t;u.parser={name:"grouped-metric"};return u}}function s(){var t=Array.prototype.slice.call(arguments);return function(u){var v=new b();q(u.result,function(w,y){var x=t[0]&&t[0]==="timeframe.end"?w.timeframe.end:w.timeframe.start;if(w.value.length){q(w.value,function(B,A){var z;q(B,function(D,C){if(C!=="result"){z=C}});v.set([String(B[z])||"",x],B.result)})}else{v.appendRow(x)}});v.data.input=u;v.parser={name:"grouped-interval",options:t};return v}}function h(){var t=Array.prototype.slice.call(arguments);if(!t[0]){throw"Requested parser requires a sequential list (array) of properties to target as a second argument"}return function(u){var v=new b();q(u.result,function(w,x){v.set(["Result",w[t[0][0]]+" "+w[t[0][1]]],w.result)});v.data.input=u;v.parser={name:"double-grouped-metric",options:t};return v}}function g(){var t=Array.prototype.slice.call(arguments);if(!t[0]){throw"Requested parser requires a sequential list (array) of properties to target as a second argument"}return function(u){var v=new b();q(u.result,function(w,y){var x=t[1]&&t[1]==="timeframe.end"?w.timeframe.end:w.timeframe.start;q(w.value,function(B,A){var z=String(B[t[0][0]])+" "+String(B[t[0][1]]);v.set([z,x],B.result)})});v.data.input=u;v.parser={name:"double-grouped-interval",options:t};return v}}function o(){return function(t){var u=new b();u.appendColumn("Step Value");q(t.result,function(w,v){u.appendRow(t.steps[v].event_collection,[w])});u.data.input=t;u.parser={name:"funnel"};return u}}function l(){return function(t){var u=new b();q(t.result,function(w,v){u.set(["Value",v+1],w)});u.data.input=t;u.parser={name:"list"};return u}}function d(){return function(t){var u=new b();q(t.result,function(v,w){q(a(v),function(y,x){u.set([x,w+1],y)})});u.deleteColumn(0);u.data.input=t;u.parser={name:"extraction"};return u}}},{"../../core/utils/each":29,"./flatten":49}],52:[function(b,c,a){ +(function(){var g=typeof define==="function"&&define.amd;var j={"function":true,object:true};var m=j[typeof a]&&a&&!a.nodeType&&a;var n=j[typeof window]&&window||this,f=m&&j[typeof c]&&c&&!c.nodeType&&typeof d=="object"&&d;if(f&&(f.global===f||f.window===f||f.self===f)){n=f}function o(ag,aa){ag||(ag=n.Object());aa||(aa=n.Object());var P=ag.Number||n.Number,W=ag.String||n.String,C=ag.Object||n.Object,X=ag.Date||n.Date,Y=ag.SyntaxError||n.SyntaxError,af=ag.TypeError||n.TypeError,O=ag.Math||n.Math,ad=ag.JSON||n.JSON;if(typeof ad=="object"&&ad){aa.stringify=ad.stringify;aa.parse=ad.parse}var s=C.prototype,z=s.toString,w,r,Q;var G=new X(-3509827334573292);try{G=G.getUTCFullYear()==-109252&&G.getUTCMonth()===0&&G.getUTCDate()===1&&G.getUTCHours()==10&&G.getUTCMinutes()==37&&G.getUTCSeconds()==6&&G.getUTCMilliseconds()==708}catch(A){}function t(ah){if(t[ah]!==Q){return t[ah]}var ai;if(ah=="bug-string-char-index"){ai="a"[0]!="a"}else{if(ah=="json"){ai=t("json-stringify")&&t("json-parse")}else{var ap,am='{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';if(ah=="json-stringify"){var an=aa.stringify,ao=typeof an=="function"&&G;if(ao){(ap=function(){return 1}).toJSON=ap;try{ao=an(0)==="0"&&an(new P())==="0"&&an(new W())=='""'&&an(z)===Q&&an(Q)===Q&&an()===Q&&an(ap)==="1"&&an([ap])=="[1]"&&an([Q])=="[null]"&&an(null)=="null"&&an([Q,z,null])=="[null,null,null]"&&an({a:[ap,true,false,null,"\x00\b\n\f\r\t"]})==am&&an(null,ap)==="1"&&an([1,2],null,1)=="[\n 1,\n 2\n]"&&an(new X(-8640000000000000))=='"-271821-04-20T00:00:00.000Z"'&&an(new X(8640000000000000))=='"+275760-09-13T00:00:00.000Z"'&&an(new X(-62198755200000))=='"-000001-01-01T00:00:00.000Z"'&&an(new X(-1))=='"1969-12-31T23:59:59.999Z"'}catch(aj){ao=false}}ai=ao}if(ah=="json-parse"){var al=aa.parse;if(typeof al=="function"){try{if(al("0")===0&&!al(false)){ap=al(am);var ak=ap.a.length==5&&ap.a[0]===1;if(ak){try{ak=!al('"\t"')}catch(aj){}if(ak){try{ak=al("01")!==1}catch(aj){}}if(ak){try{ak=al("1.")!==1}catch(aj){}}}}}catch(aj){ak=false}}ai=ak}}}return t[ah]=!!ai}if(!t("json")){var Z="[object Function]",V="[object Date]",S="[object Number]",T="[object String]",J="[object Array]",F="[object Boolean]";var K=t("bug-string-char-index");if(!G){var x=O.floor;var ae=[0,31,59,90,120,151,181,212,243,273,304,334];var I=function(ah,ai){return ae[ai]+365*(ah-1970)+x((ah-1969+(ai=+(ai>1)))/4)-x((ah-1901+ai)/100)+x((ah-1601+ai)/400)}}if(!(w=s.hasOwnProperty)){w=function(aj){var ah={},ai;if((ah.__proto__=null,ah.__proto__={toString:1},ah).toString!=z){w=function(am){var al=this.__proto__,ak=am in (this.__proto__=null,this);this.__proto__=al;return ak}}else{ai=ah.constructor;w=function(al){var ak=(this.constructor||ai).prototype;return al in this&&!(al in ak&&this[al]===ak[al])}}ah=null;return w.call(this,aj)}}r=function(aj,am){var ak=0,ah,ai,al;(ah=function(){this.valueOf=0}).prototype.valueOf=0;ai=new ah();for(al in ai){if(w.call(ai,al)){ak++}}ah=ai=null;if(!ak){ai=["valueOf","toString","toLocaleString","propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"];r=function(ao,at){var ar=z.call(ao)==Z,aq,ap;var an=!ar&&typeof ao.constructor!="function"&&j[typeof ao.hasOwnProperty]&&ao.hasOwnProperty||w;for(aq in ao){if(!(ar&&aq=="prototype")&&an.call(ao,aq)){at(aq)}}for(ap=ai.length;aq=ai[--ap];an.call(ao,aq)&&at(aq)){}}}else{if(ak==2){r=function(ao,ar){var an={},aq=z.call(ao)==Z,ap;for(ap in ao){if(!(aq&&ap=="prototype")&&!w.call(an,ap)&&(an[ap]=1)&&w.call(ao,ap)){ar(ap)}}}}else{r=function(ao,ar){var aq=z.call(ao)==Z,ap,an;for(ap in ao){if(!(aq&&ap=="prototype")&&w.call(ao,ap)&&!(an=ap==="constructor")){ar(ap)}}if(an||w.call(ao,(ap="constructor"))){ar(ap)}}}}return r(aj,am)};if(!t("json-stringify")){var v={92:"\\\\",34:'\\"',8:"\\b",12:"\\f",10:"\\n",13:"\\r",9:"\\t"};var N="000000";var y=function(ah,ai){return(N+(ai||0)).slice(-ah)};var E="\\u00";var H=function(an){var ai='"',al=0,am=an.length,ah=!K||am>10;var ak=ah&&(K?an.split(""):an);for(;al-1/0&&ay<1/0){if(I){aD=x(ay/86400000);for(av=x(aD/365.2425)+1970-1;I(av+1,0)<=aD;av++){}for(aE=x((aD-I(av,0))/30.42);I(av,aE+1)<=aD;aE++){}aD=1+aD-I(av,aE);ap=(ay%86400000+86400000)%86400000;aB=x(ap/3600000)%24;az=x(ap/60000)%60;aw=x(ap/1000)%60;at=ap%1000}else{av=ay.getUTCFullYear();aE=ay.getUTCMonth();aD=ay.getUTCDate();aB=ay.getUTCHours();az=ay.getUTCMinutes();aw=ay.getUTCSeconds();at=ay.getUTCMilliseconds()}ay=(av<=0||av>=10000?(av<0?"-":"+")+y(6,av<0?-av:av):y(4,av))+"-"+y(2,aE+1)+"-"+y(2,aD)+"T"+y(2,aB)+":"+y(2,az)+":"+y(2,aw)+"."+y(3,at)+"Z"}else{ay=null}}else{if(typeof ay.toJSON=="function"&&((aj!=S&&aj!=T&&aj!=J)||w.call(ay,"toJSON"))){ay=ay.toJSON(an)}}}if(al){ay=al.call(aF,an,ay)}if(ay===null){return"null"}aj=z.call(ay);if(aj==F){return""+ay}else{if(aj==S){return ay>-1/0&&ay<1/0?""+ay:"null"}else{if(aj==T){return H(""+ay)}}}if(typeof ay=="object"){for(ak=ao.length;ak--;){if(ao[ak]===ay){throw af()}}ao.push(ay);ax=[];aA=ah;ah+=aC;if(aj==J){for(am=0,ak=ay.length;am0){for(ai="",ak>10&&(ak=10);ai.length=48&&ai<=57||ai>=97&&ai<=102||ai>=65&&ai<=70)){M()}}al+=R("0x"+am.slice(aj,L));break;default:M()}}else{if(ai==34){break}ai=am.charCodeAt(L);aj=L;while(ai>=32&&ai!=92&&ai!=34){ai=am.charCodeAt(++L)}al+=am.slice(aj,L)}}}if(am.charCodeAt(L)==34){L++;return al}M();default:aj=L;if(ai==45){an=true;ai=am.charCodeAt(++L)}if(ai>=48&&ai<=57){if(ai==48&&((ai=am.charCodeAt(L+1)),ai>=48&&ai<=57)){M()}an=false;for(;L=48&&ai<=57);L++){}if(am.charCodeAt(L)==46){ah=++L;for(;ah=48&&ai<=57);ah++){}if(ah==L){M()}L=ah}ai=am.charCodeAt(L);if(ai==101||ai==69){ai=am.charCodeAt(++L);if(ai==43||ai==45){L++}for(ah=L;ah=48&&ai<=57);ah++){}if(ah==L){M()}L=ah}return +am.slice(aj,L)}if(an){M()}if(am.slice(L,L+4)=="true"){L+=4;return true}else{if(am.slice(L,L+5)=="false"){L+=5;return false}else{if(am.slice(L,L+4)=="null"){L+=4;return null}}}M()}}return"$"};var ab=function(ai){var ah,aj;if(ai=="$"){M()}if(typeof ai=="string"){if((K?ai.charAt(0):ai[0])=="@"){return ai.slice(1)}if(ai=="["){ah=[];for(;;aj||(aj=true)){ai=D();if(ai=="]"){break}if(aj){if(ai==","){ai=D();if(ai=="]"){M()}}else{M()}}if(ai==","){M()}ah.push(ab(ai))}return ah}else{if(ai=="{"){ah={};for(;;aj||(aj=true)){ai=D();if(ai=="}"){break}if(aj){if(ai==","){ai=D();if(ai=="}"){M()}}else{M()}}if(ai==","||typeof ai!="string"||(K?ai.charAt(0):ai[0])!="@"||D()!=":"){M()}ah[ai.slice(1)]=ab(D())}return ah}}M()}return ai};var U=function(aj,ai,ak){var ah=B(aj,ai,ak);if(ah===Q){delete aj[ai]}else{aj[ai]=ah}};var B=function(ak,aj,al){var ai=ak[aj],ah;if(typeof ai=="object"&&ai){if(z.call(ai)==J){for(ah=ai.length;ah--;){U(ai,ah,al)}}else{r(ai,function(am){U(ai,am,al)})}}return al.call(ak,aj,ai)};aa.parse=function(aj,ak){var ah,ai;L=0;ac=""+aj;ah=ab(D());if(D()!="$"){M()}L=ac=null;return ak&&z.call(ak)==Z?B((ai={},ai[""]=ah,ai),"",ak):ah}}}aa.runInContext=o;return aa}if(m&&!g){o(n,m)}else{var k=n.JSON,p=n.JSON3,h=false;var l=o(n,(n.JSON3={noConflict:function(){if(!h){h=true;n.JSON=k;n.JSON3=p;k=p=null}return l}}));n.JSON={parse:l.parse,stringify:l.stringify}}if(g){define(function(){return l})}}).call(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],4:[function(b,c,a){(function(d,f){if(typeof a=="object"){c.exports=f()}else{if(typeof define=="function"&&define.amd){define(f)}else{d.Spinner=f()}}}(this,function(){var j=["webkit","Moz","ms","O"],t={},s,n;function l(u,x){var v=document.createElement(u||"div"),w;for(w in x){v[w]=x[w]}return v}function m(v){for(var u=1,w=arguments.length;u>1)+"px"})}for(;v',v)}n.addRule(".spin-vml","behavior:url(#default#VML)");f.prototype.lines=function(x,w){var v=w.scale*(w.length+w.width),D=w.scale*2*v;function C(){return k(u("group",{coordsize:D+" "+D,coordorigin:-v+" "+-v}),{width:D,height:D})}var y=-(w.width+w.length)*w.scale*2+"px",B=k(C(),{position:"absolute",top:y,left:y}),A;function z(F,E,G){m(B,m(k(C(),{rotation:360/w.lines*F+"deg",left:~~E}),m(k(u("roundrect",{arcsize:w.corners}),{width:v,height:w.scale*w.width,left:w.scale*w.radius,top:-w.scale*w.width>>1,filter:G}),u("fill",{color:r(w.color,F),opacity:w.opacity}),u("stroke",{opacity:0}))))}if(w.shadow){for(A=1;A<=w.lines;A++){z(A,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)")}}for(A=1;A<=w.lines;A++){z(A)}return m(x,B)};f.prototype.opacity=function(w,v,y,x){var z=w.firstChild;x=x.shadow&&x.lines||0;if(z&&v+x0){return 2000}}return 16000}},{}],13:[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}},{}],14:[function(b,c,a){c.exports=function(h,g,j){var f=j||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}},{}],15:[function(f,b,g){var o=f("superagent");var m=f("../utils/each"),a=f("./get-xhr-object");b.exports=function(p,q){return function(r){var s=r.constructor.prototype.end;if(typeof window==="undefined"){return}r.requestType=r.requestType||{};r.requestType.type=p;r.requestType.options=r.requestType.options||{async:true,success:{responseText:'{ "created": true }',status:201},error:{responseText:'{ "error_code": "ERROR", "message": "Request failed" }',status:404}};if(q){if(typeof q.async==="boolean"){r.requestType.options.async=q.async}if(q.success){extend(r.requestType.options.success,q.success)}if(q.error){extend(r.requestType.options.error,q.error)}}r.end=function(v){var u=this,t=(this.requestType)?this.requestType.type:"xhr",x,w;if(("GET"!==u.method||t==="xhr")&&u.requestType.options.async){s.call(u,v);return}x=u._query.join("&");w=u._timeout;u._callback=v||noop;if(w&&!u._timer){u._timer=setTimeout(function(){h.call(u)},w)}if(x){x=o.serializeObject(x);u.url+=~u.url.indexOf("?")?"&"+x:"?"+x}u.emit("request",u);if(!u.requestType.options.async){l.call(u)}else{if(t==="jsonp"){k.call(u)}else{if(t==="beacon"){j.call(u)}}}return u};return r}};function l(){var p=a();if(p){p.open("GET",this.url,false);p.send(null)}return this}function k(){var q=this,u=new Date().getTime(),p=document.createElement("script"),t=document.getElementsByTagName("head")[0],v="keenJSONPCallback",r=false;v+=u;while(v in window){v+="a"}window[v]=function(w){if(r===true){return}r=true;d.call(q,w);s()};p.src=q.url+"&jsonp="+v;t.appendChild(p);p.onreadystatechange=function(){if(r===false&&q.readyState==="loaded"){r=true;c.call(q);s()}};p.onerror=function(){if(r===false){r=true;c.call(q);s()}};function s(){window[v]=undefined;try{delete window[v]}catch(w){}t.removeChild(p)}}function j(){var q=this,p=document.createElement("img"),r=false;p.onload=function(){r=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(q)};p.onerror=function(){r=true;c.call(q)};p.src=q.url+"&c=clv1"}function d(q){var r=this.requestType.options["success"],p="";n.call(this,r);if(q){try{p=JSON.stringify(q)}catch(s){}}else{p=r.responseText}this.xhr.responseText=p;this.xhr.status=r.status;this.emit("end")}function c(){var p=this.requestType.options["error"];n.call(this,p);this.xhr.responseText=p.responseText;this.xhr.status=p.status;this.emit("end")}function h(){this.aborted=true;this.clearTimeout();this.emit("abort")}function n(p){this.xhr={getAllResponseHeaders:function(){return""},getResponseHeader:function(){return"application/json"},responseText:p.responseText,status:p.status};return this}},{"../utils/each":29,"./get-xhr-object":13,superagent:5}],16:[function(d,f,c){var b="undefined"!==typeof window?window:this;var h=b.Keen;var g=d("./utils/emitter-shim");function a(j){this.configure(j||{});a.trigger("client",this)}a.debug=false;a.enabled=true;a.loaded=true;a.version="3.4.0-rc4";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},{"./utils/emitter-shim":30}],17:[function(f,c,h){var q=f("../utils/json-shim");var g=f("superagent");var j=f("../index");var k=f("../utils/base64"),n=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"),l=f("../helpers/superagent-request-types"),p=f("../helpers/superagent-handle-response");c.exports=function(y,B,C,u){var D=this,w=this.url("/events/"+encodeURIComponent(y)),r=this.config.requestType,v={},t=C,s,A;s=("boolean"===typeof u)?u:true;if(!j.enabled){z.call(D,"Keen.enabled = false");return}if(!D.projectId()){z.call(D,"Missing projectId property");return}if(!D.writeKey()){z.call(D,"Missing writeKey property");return}if(!y||typeof y!=="string"){z.call(D,"Collection name must be a string");return}if(D.config.globalProperties){v=D.config.globalProperties(y)}n(B,function(F,E){v[E]=F});if(!a()&&"xhr"===r){r="jsonp"}if("xhr"!==r||!s){A=m.call(D,w,v)}if(A&&o()==="browser"){g.get(A).use(l(r,{async:s})).end(x)}else{if(a()||o()==="server"){g.post(w).set("Content-Type","application/json").set("Authorization",D.writeKey()).send(v).end(x)}else{D.trigger("error","Request not sent: URL length exceeds current browser limit, and XHR (POST) is not supported.")}}function x(F,E){p(F,E,t);t=C=null}function z(F){var E="Event not recorded: "+F;D.trigger("error",E);if(t){t.call(D,E,null);t=C=null}}return};function m(r,s){r+=d({api_key:this.writeKey(),data:k.encode(q.stringify(s)),modified:new Date().getTime()});return(r.length2){r.call(o,"Incorrect arguments provided to #addEvents method");return}if(typeof q!=="object"||q instanceof Array){r.call(o,"Request payload must be an object");return}if(o.config.globalProperties){j(q,function(t,u){j(t,function(v,w){var x=o.config.globalProperties(u);j(v,function(z,y){x[y]=z});p[u].push(x)})})}else{p=q}if(a()||k()==="server"){d.post(n).set("Content-Type","application/json").set("Authorization",o.writeKey()).send(p).end(function(u,t){l(u,t,m);m=s=null})}else{o.trigger("error","Events not recorded: XHR support is required for batch upload")}function r(u){var t="Events not recorded: "+u;o.trigger("error",t);if(m){m.call(o,t,null);m=s=null}}return}},{"../helpers/get-context":9,"../helpers/get-xhr-object":13,"../helpers/superagent-handle-response":14,"../helpers/superagent-request-types":15,"../index":16,"../utils/each":29,superagent:5}],19:[function(d,f,c){var h=d("superagent");var b=d("../helpers/get-query-string"),g=d("../helpers/superagent-handle-response"),a=d("../helpers/superagent-request-types");f.exports=function(k,n,m,o){var j=this.config.requestType,l=n||{};if(j==="beacon"){j="jsonp"}l.api_key=l.api_key||m;h.get(k+b(l)).use(a(j)).end(function(q,p){g(q,p,o);o=null})}},{"../helpers/get-query-string":10,"../helpers/superagent-handle-response":14,"../helpers/superagent-request-types":15,superagent:5}],20:[function(b,c,a){var f=b("superagent");var d=b("../helpers/superagent-handle-response");c.exports=function(g,j,h,k){f.post(g).set("Content-Type","application/json").set("Authorization",h).send(j||{}).end(function(m,l){d(m,l,k);k=null})}},{"../helpers/superagent-handle-response":14,superagent:5}],21:[function(b,d,a){var c=b("../request");d.exports=function(k,l){var h=[],g=l,j;if(!this.config.projectId||!this.config.projectId.length){f.call(this,"Missing projectId property")}if(!this.config.readKey||!this.config.readKey.length){f.call(this,"Missing readKey property")}function f(n){var m="Query not sent: "+n;this.trigger("error",m);if(g){g.call(this,m,null);g=l=null}}if(k instanceof Array){h=k}else{h.push(k)}j=new c(this,h,g).refresh();g=l=null;return j}},{"../request":25}],22:[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)}}},{}],23:[function(b,c,a){var d=b("./addEvent");c.exports=function(l,f,o,m,n){var p=l,k=(p.currentTarget)?p.currentTarget:(p.srcElement||p.target),g=m||500,h=false,r="",q,j;if(k.getAttribute!==void 0){r=k.getAttribute("target")}else{if(k.target){r=k.target}}if((r=="_blank"||r=="blank")&&!p.metaKey){j=window.open("about:blank");j.document.location=k.href}if(k.nodeName==="A"){q=function(){if(!h&&!p.metaKey&&(r!=="_blank"&&r!=="blank")){h=true;window.location=k.href}}}else{if(k.nodeName==="FORM"){q=function(){if(!h){h=true;k.submit()}}}else{this.trigger("error","#trackExternalLink method not attached to an or DOM element")}}if(n){q=function(){if(!h){h=true;n()}}}d.call(this,f,o,q);setTimeout(q,g);if(!p.metaKey){return false}}},{"./addEvent":17}],24:[function(c,a,d){var k=c("./utils/each"),h=c("./utils/extend"),g=c("./helpers/get-timezone-offset"),b=c("./helpers/get-query-string");var j=c("./utils/emitter-shim");function f(){this.configure.apply(this,arguments)}j(f.prototype);f.prototype.configure=function(l,m){this.analysis=l;this.params=this.params||{};this.set(m);if(this.params.timezone===void 0){this.params.timezone=g()}return this};f.prototype.set=function(m){var l=this;k(m,function(o,n){var p=n,q=o;if(n.match(new RegExp("[A-Z]"))){p=n.replace(/([A-Z])/g,function(r){return"_"+r.toLowerCase()})}l.params[p]=q;if(q instanceof Array){k(q,function(s,r){if(s instanceof Array==false&&typeof s==="object"){k(s,function(u,t){if(t.match(new RegExp("[A-Z]"))){var v=t.replace(/([A-Z])/g,function(w){return"_"+w.toLowerCase()});delete l.params[p][r][t];l.params[p][r][v]=u}})}})}});return l};f.prototype.get=function(m){var l=m;if(l.match(new RegExp("[A-Z]"))){l=l.replace(/([A-Z])/g,function(n){return"_"+n.toLowerCase()})}if(this.params){return this.params[l]||null}};f.prototype.addFilter=function(n,l,m){this.params.filters=this.params.filters||[];this.params.filters.push({property_name:n,operator:l,property_value:m});return this};a.exports=f},{"./helpers/get-query-string":10,"./helpers/get-timezone-offset":11,"./utils/each":29,"./utils/emitter-shim":30,"./utils/extend":31}],25:[function(c,b,d){var m=c("./utils/each"),k=c("./utils/extend"),h=c("./utils/sendQuery"),j=c("./utils/sendSavedQuery");var l=c("./utils/emitter-shim");var g=c("./");var f=c("./query");function a(o,p,q){var n=q;this.config={timeout:300*1000};this.configure(o,p,n);n=q=null}l(a.prototype);a.prototype.configure=function(o,p,q){var n=q;k(this,{client:o,queries:p,data:{},callback:n});n=q=null;return this};a.prototype.timeout=function(n){if(!arguments.length){return this.config.timeout}this.config.timeout=(!isNaN(parseInt(n))?parseInt(n):null);return this};a.prototype.refresh=function(){var p=this,n=0,o=[],r=false;var q=function(u,t,s){if(r){return}if(u){p.trigger("error",u);if(p.callback){p.callback(u,null)}r=true;return}o[s]=t;n++;if(n==p.queries.length&&!r){p.data=(p.queries.length==1)?o[0]:o;p.trigger("complete",null,p.data);if(p.callback){p.callback(null,p.data)}}};m(p.queries,function(v,t){var s=function(y,x){q(y,x,t)};var w="/queries";if(typeof v==="string"){w+="/saved/"+v+"/result";j.call(p,w,{},s)}else{if(v instanceof f){w+="/"+v.analysis;if(v.analysis==="saved"){w+="/"+v.params.query_name+"/result";j.call(p,w,{},s)}else{h.call(p,w,v.params,s)}}else{var u={statusText:"Bad Request",responseText:{message:"Error: Query "+(+t+1)+" of "+p.queries.length+" for project "+p.client.projectId()+" is not a valid request"}};p.trigger("error",u.responseText.message);if(p.callback){p.callback(u.responseText.message,null)}}}});return this};b.exports=a},{"./":16,"./query":24,"./utils/each":29,"./utils/emitter-shim":30,"./utils/extend":31,"./utils/sendQuery":34,"./utils/sendSavedQuery":35}],26:[function(c,d,b){var g=c("superagent");var a=c("./helpers/superagent-handle-response");function f(){var h=this;this.all=function(l){var j=h.url("/queries/saved");g.get(j).set("Content-Type","application/json").set("Authorization",h.masterKey()).end(k);function k(n,m){a(n,m,l);l=null}};this.get=function(l,m){var j=h.url("/queries/saved/"+l);g.get(j).set("Content-Type","application/json").set("Authorization",h.masterKey()).end(k);function k(o,n){a(o,n,m);m=null}};this.update=function(m,j,n){var k=h.url("/queries/saved/"+m);g.put(k).set("Content-Type","application/json").set("Authorization",h.masterKey()).send(j||{}).end(l);function l(p,o){a(p,o,n);n=null}};this.create=this.update;this.destroy=function(l,m){var j=h.url("/queries/saved/"+l);g.del(j).set("Content-Type","application/json").set("Authorization",h.masterKey()).end(k);function k(o,n){a(o,n,m);m=null}};return this}d.exports=f},{"./helpers/superagent-handle-response":14,superagent:5}],27:[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}}}},{}],28:[function(b,d,a){var c=b("./json-shim");d.exports=function(f){return c.parse(c.stringify(f))}},{"./json-shim":32}],29:[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;h0){this.parse.apply(this,arguments)}}b.defaults={delimeter:" -> "};o(b);o(b.prototype);b.parser=g("./utils/parsers")(b);b.prototype.input=function(q){if(!arguments.length){return this["data"]["input"]}this["data"]["input"]=(q?n(q):null);return this};b.prototype.output=function(q){if(!arguments.length){return this["data"].output}this["data"].output=(q instanceof Array?q:null);return this};b.prototype.method=function(q){if(!arguments.length){return this.meta.method}this.meta.method=(q?String(q):null);return this};b.prototype.schema=function(q){if(!arguments.length){return this.meta.schema}this.meta.schema=(q?q:null);return this};b.prototype.parse=function(r,s){var q;if(r){this.input(r)}if(s){this.schema(s)}this.output([[]]);if(this.meta.schema.select){this.method("select");q=m({records:"",select:true},this.schema());f.call(this,d(q))}else{if(this.meta.schema.unpack){this.method("unpack");q=m({records:"",unpack:{index:false,value:false,label:false}},this.schema());l.call(this,d(q))}}return this};function f(s){var t=this,u=s||{},v=[],w=[];var r,q;if(u.records===""||!u.records){r=[t.input()]}else{q=u.records.split(b.defaults.delimeter);r=h.apply(t,[t.input()].concat(q))[0]}p(u.select,function(y){v.push(y.path.split(b.defaults.delimeter))});if(v.length==0){p(r,function(y,z){var B=a(y);for(var A in B){if(B.hasOwnProperty(A)&&w.indexOf(A)==-1){w.push(A);v.push([A])}}})}var x=[[]];p(v,function(z,y){if(v.length==1){x[0].push("label","value")}else{x[0].push(z.join("."))}});p(r,function(y,z){var A=a(y);if(v.length==1){x.push([v.join("."),A[v.join(".")]])}else{x.push([]);p(v,function(C,B){var D=C.join(".");x[z+1].push(A[D])})}});t.output(x);t.format(u.select);return t}function l(z){var y=this,u=[];var s=(z.unpack.value)?z.unpack.value.path.split(b.defaults.delimeter):false,r=(z.unpack.label)?z.unpack.label.path.split(b.defaults.delimeter):false,t=(z.unpack.index)?z.unpack.index.path.split(b.defaults.delimeter):false;var v=(s[s.length-1]!=="")?s[s.length-1]:"Value",q=(r[r.length-1]!=="")?r[r.length-1]:"Label",x=(t[t.length-1]!=="")?t[t.length-1]:"Index";var w=(function(){var A;if(z.records==""){A=[y.input()]}else{A=h.apply(y,[y.input()].concat(z.records.split(b.defaults.delimeter)))}return A[0]})();if(w instanceof Array==false){w=[w]}p(w,function(A,B){var C=(r)?h.apply(y,[A].concat(r)):[];if(C){u=C}});p(w,function(B,C){var D=(s)?h.apply(y,[B].concat(s)):false,A=(t)?h.apply(y,[B].concat(t)):false;if(A){p(A,function(){y.data.output.push([])})}else{y.data.output.push([])}if(A){if(C==0){y.data.output[0].push(x);if(u.length>0){p(u,function(F,E){y.data.output[0].push(F)})}else{y.data.output[0].push(v)}}if(w.length0){y.data.output[E].push(A[E-1])}})}}else{y.data.output[C+1].push(A[0])}}if(!A&&u.length>0){if(C==0){y.data.output[0].push(q);y.data.output[0].push(v)}y.data.output[C+1].push(u[0])}if(!A&&u.length==0){y.data.output[0].push("")}if(D){if(w.length0){y.data.output[E].push(D[E-1])}})}}else{p(D,function(E){y.data.output[C+1].push(E)})}}else{p(y.data.output[0],function(E,F){var G=(A)?0:-1;if(F>G){y.data.output[C+1].push(null)}})}});y.format(z.unpack);return this}function d(q){p(q.unpack,function(t,s,r){if(t&&k(t,"string")){q.unpack[s]={path:q.unpack[s]}}});return q}function k(r,q){r=typeof(r);if(!q){return r!="undefined"}return r==q}function m(r,q){p(q,function(s,t){if(k(r[t],"object")&&k(s,"object")){r[t]=m(r[t],s)}else{if(s!==null){r[t]=s}}});return r}c.exports=b},{"../core/utils/clone":28,"../core/utils/each":29,"../core/utils/emitter-shim":30,"./utils/flatten":49,"./utils/parse":50,"./utils/parsers":51}],37:[function(b,c,a){var f=b("../core/utils/extend"),d=b("./dataset");f(d.prototype,b("./lib/append"));f(d.prototype,b("./lib/delete"));f(d.prototype,b("./lib/filter"));f(d.prototype,b("./lib/insert"));f(d.prototype,b("./lib/select"));f(d.prototype,b("./lib/set"));f(d.prototype,b("./lib/sort"));f(d.prototype,b("./lib/update"));f(d.prototype,b("./lib/analyses"));f(d.prototype,{format:b("./lib/format")});c.exports=d},{"../core/utils/extend":31,"./dataset":36,"./lib/analyses":38,"./lib/append":39,"./lib/delete":40,"./lib/filter":41,"./lib/format":42,"./lib/insert":43,"./lib/select":44,"./lib/set":45,"./lib/sort":46,"./lib/update":47}],38:[function(d,f,c){var g=d("../../core/utils/each"),a=["Average","Maximum","Minimum","Sum"],b={};b.average=function(h,n,j){var m=h.slice(n||0,(j?j+1:h.length)),k=0,l=null;g(m,function(p,o){if(typeof p==="number"&&!isNaN(parseFloat(p))){k+=parseFloat(p)}});return k/m.length};b.maximum=function(h,m,j){var l=h.slice(m||0,(j?j+1:h.length)),k=[];g(l,function(o,n){if(typeof o==="number"&&!isNaN(parseFloat(o))){k.push(parseFloat(o))}});return Math.max.apply(Math,k)};b.minimum=function(h,m,j){var l=h.slice(m||0,(j?j+1:h.length)),k=[];g(l,function(o,n){if(typeof o==="number"&&!isNaN(parseFloat(o))){k.push(parseFloat(o))}});return Math.min.apply(Math,k)};b.sum=function(h,m,j){var l=h.slice(m||0,(j?j+1:h.length)),k=0;g(l,function(o,n){if(typeof o==="number"&&!isNaN(parseFloat(o))){k+=parseFloat(o)}});return k};g(a,function(h,j){b["getColumn"+h]=b["getRow"+h]=function(k){return this[h.toLowerCase()](k,1)}});b.getColumnLabel=b.getRowIndex=function(h){return h[0]};f.exports=b},{"../../core/utils/each":29}],39:[function(d,f,c){var h=d("../../core/utils/each");var b=d("../utils/create-null-list");f.exports={appendColumn:g,appendRow:a};function g(n,k){var j=this,m=Array.prototype.slice.call(arguments,2),l=(n!==undefined)?n:null;if(typeof k==="function"){j.data.output[0].push(l);h(j.output(),function(q,p){var o;if(p>0){o=k.call(j,q,p);if(typeof o==="undefined"){o=null}j.data.output[p].push(o)}})}else{if(!k||k instanceof Array){k=k||[];if(k.length<=j.output().length-1){k=k.concat(b(j.output().length-1-k.length))}else{h(k,function(p,o){if(j.data.output.length-10){q=j.selectColumn(s);p=k.call(j,q,s);if(typeof p==="undefined"){p=null}l.push(p)}});j.data.output.push(l)}else{if(!k||k instanceof Array){k=k||[];if(k.length<=j.data.output[0].length-1){k=k.concat(b(j.data.output[0].length-1-k.length))}else{h(k,function(q,p){if(j.data.output[0].length-1-1){g(h.data.output,function(m,l){h.data.output[l].splice(j,1)})}return h}function b(j){var h=(typeof j==="number")?j:this.selectColumn(0).indexOf(j);if(h>-1){this.data.output.splice(h,1)}return this}},{"../../core/utils/each":29}],41:[function(c,d,b){var f=c("../../core/utils/each");d.exports={filterColumns:a,filterRows:g};function a(j){var h=this,k=new Array();f(h.data.output,function(m,l){k.push([])});f(h.data.output[0],function(l,m){var n=h.selectColumn(m);if(m==0||j.call(h,n,m)){f(n,function(o,p){k[p].push(o)})}});h.output(k);return h}function g(j){var h=this,k=[];f(h.output(),function(m,l){if(l==0||j.call(h,m,l)){k.push(m)}});h.output(k);return h}},{"../../core/utils/each":29}],42:[function(c,d,b){var f=c("../../core/utils/each");d.exports=function(h){var g=this;if(this.method()==="select"){f(g.output(),function(k,j){if(j==0){f(k,function(l,m){if(h[m]&&h[m].label){g.data.output[j][m]=h[m].label}})}else{f(k,function(l,m){g.data.output[j][m]=a(g.data.output[j][m],h[m])})}})}if(this.method()==="unpack"){if(h.index){f(g.output(),function(k,j){if(j==0){if(h.index.label){g.data.output[j][0]=h.index.label}}else{g.data.output[j][0]=a(g.data.output[j][0],h.index)}})}if(h.label){if(h.index){f(g.output(),function(k,j){f(k,function(l,m){if(j==0&&m>0){g.data.output[j][m]=a(g.data.output[j][m],h.label)}})})}else{f(g.output(),function(k,j){if(j>0){g.data.output[j][0]=a(g.data.output[j][0],h.label)}})}}if(h.value){if(h.index){f(g.output(),function(k,j){f(k,function(l,m){if(j>0&&m>0){g.data.output[j][m]=a(g.data.output[j][m],h.value)}})})}else{f(g.output(),function(k,j){f(k,function(l,m){if(j>0){g.data.output[j][m]=a(g.data.output[j][m],h.value)}})})}}}return g};function a(k,j){var g=k,h=j||{};if(h.replace){f(h.replace,function(m,l){if(g==l||String(g)==String(l)||parseFloat(g)==parseFloat(l)){g=m}})}if(h.type&&h.type=="date"){if(h.format&&moment&&moment(k).isValid()){g=moment(g).format(h.format)}else{g=new Date(g)}}if(h.type&&h.type=="string"){g=String(g)}if(h.type&&h.type=="number"&&!isNaN(parseFloat(g))){g=parseFloat(g)}return g}},{"../../core/utils/each":29}],43:[function(f,b,g){var j=f("../../core/utils/each");var h=f("../utils/create-null-list");var c=f("./append");var l=c.appendRow,d=c.appendColumn;b.exports={insertColumn:a,insertRow:k};function a(p,q,n){var m=this,o;o=(q!==undefined)?q:null;if(typeof n==="function"){m.data.output[0].splice(p,0,o);j(m.output(),function(t,s){var r;if(s>0){r=n.call(m,t,s);if(typeof r==="undefined"){r=null}m.data.output[s].splice(p,0,r)}})}else{if(!n||n instanceof Array){n=n||[];if(n.length<=m.output().length-1){n=n.concat(h(m.output().length-1-n.length))}else{j(n,function(s,r){if(m.data.output.length-10){t=m.selectColumn(v);s=n.call(m,t,v);if(typeof s==="undefined"){s=null}o.push(s)}});m.data.output.splice(q,0,o)}else{if(!n||n instanceof Array){n=n||[];if(n.length<=m.data.output[0].length-1){n=n.concat(h(m.data.output[0].length-1-n.length))}else{j(n,function(t,s){if(m.data.output[0].length-1-1&&"undefined"!==typeof this.data.output[0][j]){g(this.data.output,function(m,l){h.push(m[j])})}return h}function a(k){var h=new Array(),j=(typeof k==="number")?k:this.selectColumn(0).indexOf(k);if(j>-1&&"undefined"!==typeof this.data.output[j]){h=this.data.output[j]}return h}},{"../../core/utils/each":29}],45:[function(d,f,c){var g=d("../../core/utils/each");var b=d("./append");var a=d("./select");f.exports={set:h};function h(n,m){if(arguments.length<2||n.length<2){throw Error("Incorrect arguments provided for #set method")}var j="number"===typeof n[0]?n[0]:this.data.output[0].indexOf(n[0]),o="number"===typeof n[1]?n[1]:a.selectColumn.call(this,0).indexOf(n[1]);var l=a.selectColumn.call(this,n[0]),k=a.selectRow.call(this,n[1]);if(l.length<1){b.appendColumn.call(this,n[0]);j=this.data.output[0].length-1}if(k.length<1){b.appendRow.call(this,n[1]);o=this.data.output.length-1}this.data.output[o][j]=m;return this}},{"../../core/utils/each":29,"./append":39,"./select":44}],46:[function(d,f,c){var g=d("../../core/utils/each");f.exports={sortColumns:b,sortRows:a};function b(n,j){var h=this,k=this.output()[0].slice(1),m=[],o=[],l=j||this.getColumnLabel;g(k,function(p,q){m.push(h.selectColumn(q+1).slice(0))});m.sort(function(q,p){var r=l.call(h,q)>l.call(h,p);if(r){return(n==="asc"?1:-1)}else{if(!r){return(n==="asc"?-1:1)}else{return 0}}});g(m,function(p,q){h.deleteColumn(q+1).insertColumn(q+1,p[0],p.slice(1))});return h}function a(n,k){var j=this,l=this.output().slice(0,1),h=this.output().slice(1),m=k||this.getRowIndex;h.sort(function(p,o){var q=m.call(j,p)>m.call(j,o);if(q){return(n==="asc"?1:-1)}else{if(!q){return(n==="asc"?-1:1)}else{return 0}}});j.output(l.concat(h));return j}},{"../../core/utils/each":29}],47:[function(f,a,g){var k=f("../../core/utils/each");var h=f("../utils/create-null-list");var b=f("./append");var l=b.appendRow,d=b.appendColumn;a.exports={updateColumn:j,updateRow:c};function j(p,n){var m=this,o=(typeof p==="number")?p:this.data.output[0].indexOf(p);if(o>-1){if(typeof n==="function"){k(m.output(),function(s,r){var q;if(r>0){q=n.call(m,s[o],r,s);if(typeof q!=="undefined"){m.data.output[r][o]=q}}})}else{if(!n||n instanceof Array){n=n||[];if(n.length<=m.output().length-1){n=n.concat(h(m.output().length-1-n.length))}else{k(n,function(r,q){if(m.data.output.length-1-1){if(typeof n==="function"){k(m.output()[o],function(t,s){var r=m.selectColumn(s),q=n.call(m,t,s,r);if(typeof q!=="undefined"){m.data.output[o][s]=q}})}else{if(!n||n instanceof Array){n=n||[];if(n.length<=m.data.output[0].length-1){n=n.concat(h(m.data.output[0].length-1-n.length))}else{k(n,function(r,q){if(m.data.output[0].length-10){return f}};return g.apply(this,arguments)}},{"../../core/utils/each":29}],51:[function(f,c,k){var b;var q=f("../../core/utils/each"),a=f("./flatten");var r={metric:n,interval:j,"grouped-metric":p,"grouped-interval":s,"double-grouped-metric":h,"double-grouped-interval":g,funnel:o,list:l,extraction:d};c.exports=m;function m(t){b=t;return function(v){var u=Array.prototype.slice.call(arguments,1);if(!r[v]){throw"Requested parser does not exist"}else{return r[v].apply(this,u)}}}function n(){return function(t){var u=new b();u.data.input=t;u.parser={name:"metric"};return u.set(["Value","Result"],t.result)}}function j(){var t=Array.prototype.slice.call(arguments);return function(u){var v=new b();q(u.result,function(w,y){var x=t[0]&&t[0]==="timeframe.end"?w.timeframe.end:w.timeframe.start;v.set(["Result",x],w.value)});v.data.input=u;v.parser="interval";v.parser={name:"interval",options:t};return v}}function p(){return function(t){var u=new b();q(t.result,function(v,x){var w;q(v,function(z,y){if(y!=="result"){w=y}});u.set(["Result",String(v[w])],v.result)});u.data.input=t;u.parser={name:"grouped-metric"};return u}}function s(){var t=Array.prototype.slice.call(arguments);return function(u){var v=new b();q(u.result,function(w,y){var x=t[0]&&t[0]==="timeframe.end"?w.timeframe.end:w.timeframe.start;if(w.value.length){q(w.value,function(B,A){var z;q(B,function(D,C){if(C!=="result"){z=C}});v.set([String(B[z])||"",x],B.result)})}else{v.appendRow(x)}});v.data.input=u;v.parser={name:"grouped-interval",options:t};return v}}function h(){var t=Array.prototype.slice.call(arguments);if(!t[0]){throw"Requested parser requires a sequential list (array) of properties to target as a second argument"}return function(u){var v=new b();q(u.result,function(w,x){v.set(["Result",w[t[0][0]]+" "+w[t[0][1]]],w.result)});v.data.input=u;v.parser={name:"double-grouped-metric",options:t};return v}}function g(){var t=Array.prototype.slice.call(arguments);if(!t[0]){throw"Requested parser requires a sequential list (array) of properties to target as a second argument"}return function(u){var v=new b();q(u.result,function(w,y){var x=t[1]&&t[1]==="timeframe.end"?w.timeframe.end:w.timeframe.start;q(w.value,function(B,A){var z=String(B[t[0][0]])+" "+String(B[t[0][1]]);v.set([z,x],B.result)})});v.data.input=u;v.parser={name:"double-grouped-interval",options:t};return v}}function o(){return function(t){var u=new b();u.appendColumn("Step Value");q(t.result,function(w,v){u.appendRow(t.steps[v].event_collection,[w])});u.data.input=t;u.parser={name:"funnel"};return u}}function l(){return function(t){var u=new b();q(t.result,function(w,v){u.set(["Value",v+1],w)});u.data.input=t;u.parser={name:"list"};return u}}function d(){return function(t){var u=new b();q(t.result,function(v,w){q(a(v),function(y,x){u.set([x,w+1],y)})});u.deleteColumn(0);u.data.input=t;u.parser={name:"extraction"};return u}}},{"../../core/utils/each":29,"./flatten":49}],52:[function(b,c,a){ /*! * ---------------------- * C3.js Adapter @@ -28,4 +28,4 @@ var g=c("../dataviz"),f=c("../../core/utils/each"),h=c("../../core/utils/extend" * Keen IO Adapter * ---------------------- */ -var g=d("../../core"),a=d("../dataviz");var j=d("../../core/utils/clone"),k=d("../../core/utils/each"),h=d("../../core/utils/extend"),c=d("../utils/prettyNumber");b.exports=function(){var l,o,n;g.Error={defaults:{backgroundColor:"",borderRadius:"4px",color:"#ccc",display:"block",fontFamily:"Helvetica Neue, Helvetica, Arial, sans-serif",fontSize:"21px",fontWeight:"light",textAlign:"center"}};g.Spinner.defaults={height:138,lines:10,length:8,width:3,radius:10,corners:1,rotate:0,direction:1,color:"#4d4d4d",speed:1.67,trail:60,shadow:false,hwaccel:false,className:"keen-spinner",zIndex:2000000000,top:"50%",left:"50%"};var m={singular:["metric"]};l={initialize:function(){var p=document.createElement("style"),q="#49c5b1";p.id="keen-widgets";p.type="text/css";p.innerHTML=" .keen-metric { \n background: "+q+"; \n border-radius: 4px; \n color: #fff; \n font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; \n padding: 10px 0; \n text-align: center; \n} .keen-metric-value { \n display: block; \n font-size: 84px; \n font-weight: 700; \n line-height: 84px; \n} .keen-metric-title { \n display: block; \n font-size: 24px; \n font-weight: 200; \n}";if(!document.getElementById(p.id)){document.body.appendChild(p)}},render:function(){var u=(this.colors().length==1)?this.colors()[0]:"#49c5b1",t=this.title()||"Result",v=this.data()[1][1]||0,r=this.width(),q=this.chartOptions()||{},s="",w="";var x={width:(r)?r+"px":"auto"};var p=v;if(typeof q.prettyNumber==="undefined"||q.prettyNumber==true){if(!isNaN(parseInt(v))){p=c(v)}}if(q.prefix){s=''+q.prefix+""}if(q.suffix){w=''+q.suffix+""}this.el().innerHTML='
'+s+p+w+''+t+"
"}};o={initialize:function(){},render:function(t,q){var r,s;var u=j(g.Error.defaults);var p=h(u,q);r=document.createElement("div");r.className="keen-error";k(p,function(w,v){r.style[v]=w});r.style.height=String(this.height()+"px");r.style.paddingTop=(this.height()/2-15)+"px";r.style.width=String(this.width()+"px");s=document.createElement("span");s.innerHTML=t||"Yikes! An error occurred!";r.appendChild(s);this.el().innerHTML="";this.el().appendChild(r)},destroy:function(){this.el().innerHTML=""}};n={initialize:function(){},render:function(){var q=document.createElement("div");var p=this.height()||g.Spinner.defaults.height;q.className="keen-loading";q.style.height=String(p+"px");q.style.position="relative";q.style.width=String(this.width()+"px");this.el().innerHTML="";this.el().appendChild(q);this.view._artifacts.spinner=new g.Spinner(g.Spinner.defaults).spin(q)},destroy:function(){this.view._artifacts.spinner.stop();this.view._artifacts.spinner=null}};g.Dataviz.register("keen-io",{metric:l,error:o,spinner:n},{capabilities:m})}},{"../../core":16,"../../core/utils/clone":28,"../../core/utils/each":29,"../../core/utils/extend":31,"../dataviz":56,"../utils/prettyNumber":95}],56:[function(f,d,g){var k=f("../core/utils/clone"),m=f("../core/utils/each"),j=f("../core/utils/extend"),a=f("./utils/loadScript"),n=f("./utils/loadStyle");var h=f("../core");var l=f("../core/utils/emitter-shim");var c=f("../dataset");function b(){this.dataset=new c();this.view={_prepared:false,_initialized:false,_rendered:false,_artifacts:{},adapter:{library:undefined,chartOptions:{},chartType:undefined,defaultChartType:undefined,dataType:undefined},attributes:k(b.defaults),defaults:k(b.defaults),el:undefined,loader:{library:"keen-io",chartType:"spinner"}};b.visuals.push(this)}j(b,{dataTypeMap:{singular:{library:"keen-io",chartType:"metric"},categorical:{library:"google",chartType:"piechart"},"cat-interval":{library:"google",chartType:"columnchart"},"cat-ordinal":{library:"google",chartType:"barchart"},chronological:{library:"google",chartType:"areachart"},"cat-chronological":{library:"google",chartType:"linechart"},extraction:{library:"google",chartType:"table"},nominal:{library:"google",chartType:"table"}},defaults:{colors:["#00bbde","#fe6672","#eeb058","#8a8ad6","#ff855c","#00cfbb","#5a9eed","#73d483","#c879bb","#0099b6","#d74d58","#cb9141","#6b6bb6","#d86945","#00aa99","#4281c9","#57b566","#ac5c9e","#27cceb","#ff818b","#f6bf71","#9b9be1","#ff9b79","#26dfcd","#73aff4","#87e096","#d88bcb"],indexBy:"timeframe.start",stacked:false},dependencies:{loading:0,loaded:0,urls:{}},libraries:{},visuals:[]});l(b);l(b.prototype);b.register=function(r,p,q){var o=this;var s=function(t){t.loaded++;if(t.loaded===t.loading){h.loaded=true;h.trigger("ready")}};b.libraries[r]=b.libraries[r]||{};m(p,function(u,t){b.libraries[r][t]=u});if(q&&q.capabilities){b.libraries[r]._defaults=b.libraries[r]._defaults||{};m(q.capabilities,function(t,u){b.libraries[r]._defaults[u]=t})}if(q&&q.dependencies){m(q.dependencies,function(v,u,w){var t=b.dependencies;if(!t.urls[v.url]){t.urls[v.url]=true;t.loading++;var x=v.type==="script"?a:n;x(v.url,function(){if(v.cb){v.cb.call(o,function(){s(t)})}else{s(t)}})}})}};b.find=function(q){if(!arguments.length){return b.visuals}var p=q.nodeName?q:document.querySelector(q),o;m(b.visuals,function(r){if(p==r.el()){o=r;return false}});if(o){return o}};d.exports=b},{"../core":16,"../core/utils/clone":28,"../core/utils/each":29,"../core/utils/emitter-shim":30,"../core/utils/extend":31,"../dataset":37,"./utils/loadScript":93,"./utils/loadStyle":94}],57:[function(b,d,a){var h=b("../../core/utils/clone"),g=b("../../core/utils/extend"),f=b("../dataviz"),c=b("../../core/request");d.exports=function(p,m,j){var l=h(f.defaults),o=new f(),n=new c(this,[p]),k=j||{};o.attributes(g(l,k)).el(m).prepare();n.refresh();n.on("complete",function(){o.parseRequest(this).call(function(){if(k.labels){this.labels(k.labels)}}).render()});n.on("error",function(q){o.error(q.message)});return o}},{"../../core/request":25,"../../core/utils/clone":28,"../../core/utils/extend":31,"../dataviz":56}],58:[function(b,c,a){var d=b("../dataviz"),f=b("../../core/utils/extend");c.exports=function(){var k=f({},d.dataTypeMap),h=this.dataType(),g=this.library(),j=this.chartType()||this.defaultChartType();if(!g&&k[h]){g=k[h].library}if(g&&!j&&h){j=d.libraries[g]._defaults[h][0]}if(g&&!j&&k[h]){j=k[h].chartType}if(g&&j&&d.libraries[g][j]){return d.libraries[g][j]}else{return{}}}},{"../../core/utils/extend":31,"../dataviz":56}],59:[function(b,c,a){c.exports=function(f){var h=f.queries[0].analysis.replace("_"," "),g=f.queries[0].get("event_collection"),d;d=h.replace(/\b./g,function(j){return j.toUpperCase()});if(g){d+=" - "+g}return d}},{}],60:[function(b,c,a){c.exports=function(g){var h=typeof g.params.interval==="string",f=typeof g.params.group_by==="string",j=g.params.group_by instanceof Array,d;if(!f&&!h){d="singular"}if(f&&!h){d="categorical"}if(h&&!f){d="chronological"}if(h&&f){d="cat-chronological"}if(!h&&j){d="categorical"}if(h&&j){d="cat-chronological"}if(g.analysis==="funnel"){d="cat-ordinal"}if(g.analysis==="extraction"){d="extraction"}if(g.analysis==="select_unique"){d="nominal"}return d}},{}],61:[function(b,c,a){var f=b("../core/utils/extend"),d=b("./dataviz");f(d.prototype,{adapter:b("./lib/adapter"),attributes:b("./lib/attributes"),call:b("./lib/call"),chartOptions:b("./lib/chartOptions"),chartType:b("./lib/chartType"),colorMapping:b("./lib/colorMapping"),colors:b("./lib/colors"),data:b("./lib/data"),dataType:b("./lib/dataType"),dateFormat:b("./lib/dateFormat"),defaultChartType:b("./lib/defaultChartType"),el:b("./lib/el"),height:b("./lib/height"),indexBy:b("./lib/indexBy"),labelMapping:b("./lib/labelMapping"),labels:b("./lib/labels"),library:b("./lib/library"),parseRawData:b("./lib/parseRawData"),parseRequest:b("./lib/parseRequest"),prepare:b("./lib/prepare"),sortGroups:b("./lib/sortGroups"),sortIntervals:b("./lib/sortIntervals"),stacked:b("./lib/stacked"),title:b("./lib/title"),width:b("./lib/width")});f(d.prototype,{destroy:b("./lib/actions/destroy"),error:b("./lib/actions/error"),initialize:b("./lib/actions/initialize"),render:b("./lib/actions/render"),update:b("./lib/actions/update")});c.exports=d},{"../core/utils/extend":31,"./dataviz":56,"./lib/actions/destroy":62,"./lib/actions/error":63,"./lib/actions/initialize":64,"./lib/actions/render":65,"./lib/actions/update":66,"./lib/adapter":67,"./lib/attributes":68,"./lib/call":69,"./lib/chartOptions":70,"./lib/chartType":71,"./lib/colorMapping":72,"./lib/colors":73,"./lib/data":74,"./lib/dataType":75,"./lib/dateFormat":76,"./lib/defaultChartType":77,"./lib/el":78,"./lib/height":79,"./lib/indexBy":80,"./lib/labelMapping":81,"./lib/labels":82,"./lib/library":83,"./lib/parseRawData":84,"./lib/parseRequest":85,"./lib/prepare":86,"./lib/sortGroups":87,"./lib/sortIntervals":88,"./lib/stacked":89,"./lib/title":90,"./lib/width":91}],62:[function(b,c,a){var d=b("../../helpers/getAdapterActions");c.exports=function(){var f=d.call(this);if(f.destroy){f.destroy.apply(this,arguments)}if(this.el()){this.el().innerHTML=""}this.view._prepared=false;this.view._initialized=false;this.view._rendered=false;this.view._artifacts={};return this}},{"../../helpers/getAdapterActions":58}],63:[function(b,c,a){var f=b("../../helpers/getAdapterActions"),d=b("../../dataviz");c.exports=function(){var g=f.call(this);if(this.el()){if(g.error){g.error.apply(this,arguments)}else{d.libraries["keen-io"]["error"].render.apply(this,arguments)}}else{this.emit("error","No DOM element provided")}return this}},{"../../dataviz":56,"../../helpers/getAdapterActions":58}],64:[function(b,c,a){var f=b("../../helpers/getAdapterActions"),d=b("../../dataviz");c.exports=function(){var h=f.call(this);var g=d.libraries[this.view.loader.library][this.view.loader.chartType];if(this.view._prepared){if(g.destroy){g.destroy.apply(this,arguments)}}else{if(this.el()){this.el().innerHTML=""}}if(h.initialize){h.initialize.apply(this,arguments)}else{this.error("Incorrect chartType");this.emit("error","Incorrect chartType")}this.view._initialized=true;return this}},{"../../dataviz":56,"../../helpers/getAdapterActions":58}],65:[function(c,d,b){var f=c("../../helpers/getAdapterActions"),a=c("../../utils/applyTransforms");d.exports=function(){var g=f.call(this);a.call(this);if(!this.view._initialized){this.initialize()}if(this.el()&&g.render){g.render.apply(this,arguments);this.view._rendered=true}return this}},{"../../helpers/getAdapterActions":58,"../../utils/applyTransforms":92}],66:[function(c,d,b){var f=c("../../helpers/getAdapterActions"),a=c("../../utils/applyTransforms");d.exports=function(){var g=f.call(this);a.call(this);if(g.update){g.update.apply(this,arguments)}else{if(g.render){this.render()}}return this}},{"../../helpers/getAdapterActions":58,"../../utils/applyTransforms":92}],67:[function(b,c,a){var d=b("../../core/utils/each");c.exports=function(g){if(!arguments.length){return this.view.adapter}var f=this;d(g,function(j,h){f.view.adapter[h]=(j?j:null)});return this}},{"../../core/utils/each":29}],68:[function(b,c,a){var d=b("../../core/utils/each");var f=b("./chartOptions");chartType=b("./chartType"),library=b("./library");c.exports=function(h){if(!arguments.length){return this.view.attributes}var g=this;d(h,function(k,j){if(j==="library"){library.call(g,k)}else{if(j==="chartType"){chartType.call(g,k)}else{if(j==="chartOptions"){f.call(g,k)}else{g.view.attributes[j]=k}}}});return this}},{"../../core/utils/each":29,"./chartOptions":70,"./chartType":71,"./library":83}],69:[function(b,c,a){c.exports=function(d){d.call(this);return this}},{}],70:[function(b,c,a){var d=b("../../core/utils/extend");c.exports=function(f){if(!arguments.length){return this.view.adapter.chartOptions}if(typeof f==="object"&&f!==null){d(this.view.adapter.chartOptions,f)}else{this.view.adapter.chartOptions={}}return this}},{"../../core/utils/extend":31}],71:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.adapter.chartType}this.view.adapter.chartType=(d?String(d):null);return this}},{}],72:[function(b,c,a){var d=b("../../core/utils/each");c.exports=function(g){if(!arguments.length){return this.view.attributes.colorMapping}this.view.attributes.colorMapping=(g?g:null);f.call(this);return this};function f(){var g=this,l=this.dataset.schema,m=this.dataset.output(),j=this.view.defaults.colors.slice(),h=this.colorMapping(),k=this.dataType()||"";if(h){if(k.indexOf("chronological")>-1||(l.unpack&&m[0].length>2)){d(m[0].slice(1),function(o,p){var n=h[o];if(n&&j[p]!==n){j.splice(p,0,n)}})}else{d(g.dataset.selectColumn(0).slice(1),function(o,p){var n=h[o];if(n&&j[p]!==n){j.splice(p,0,n)}})}g.view.attributes.colors=j}}},{"../../core/utils/each":29}],73:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.attributes.colors}this.view.attributes.colors=(d instanceof Array?d:null);this.view.defaults.colors=(d instanceof Array?d:null);return this}},{}],74:[function(b,d,a){var f=b("../../dataset"),c=b("../../core/request");d.exports=function(g){if(!arguments.length){return this.dataset.output()}if(g instanceof f){this.dataset=g}else{if(g instanceof c){this.parseRequest(g)}else{this.parseRawData(g)}}return this}},{"../../core/request":25,"../../dataset":37}],75:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.adapter.dataType}this.view.adapter.dataType=(d?String(d):null);return this}},{}],76:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.attributes.dateFormat}if(typeof d==="string"||typeof d==="function"){this.view.attributes.dateFormat=d}else{this.view.attributes.dateFormat=undefined}return this}},{}],77:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.adapter.defaultChartType}this.view.adapter.defaultChartType=(d?String(d):null);return this}},{}],78:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.el}this.view.el=d;return this}},{}],79:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.attributes["height"]}this.view.attributes["height"]=(!isNaN(parseInt(d))?parseInt(d):null);return this}},{}],80:[function(b,d,a){var f=b("../../dataset"),h=b("../dataviz"),g=b("../../core/utils/each");d.exports=function(j){if(!arguments.length){return this.view.attributes.indexBy}this.view.attributes.indexBy=(j?String(j):h.defaults.indexBy);c.call(this);return this};function c(){var k,j;if(this.dataset.output().length>1&&!isNaN(new Date(this.dataset.output()[1][0]).getTime())){if(this.dataset.parser&&this.dataset.parser.name&&this.dataset.parser.options){if(this.dataset.parser.options.length===1){k=f.parser(this.dataset.parser.name,this.indexBy());this.dataset.parser.options[0]=this.indexBy()}else{k=f.parser(this.dataset.parser.name,this.dataset.parser.options[0],this.indexBy());this.dataset.parser.options[1]=this.indexBy()}}else{if(this.dataset.output()[0].length===2){k=f.parser("interval",this.indexBy());this.dataset.parser={name:"interval",options:[this.indexBy()]}}else{k=f.parser("grouped-interval",this.indexBy());this.dataset.parser={name:"grouped-interval",options:[this.indexBy()]}}}this.dataset=k(this.dataset.input());this.dataset.updateColumn(0,function(l){return(typeof l==="string")?new Date(l):l})}}},{"../../core/utils/each":29,"../../dataset":37,"../dataviz":56}],81:[function(b,c,a){var f=b("../../core/utils/each");c.exports=function(g){if(!arguments.length){return this.view.attributes.labelMapping}this.view.attributes.labelMapping=(g?g:null);d.call(this);return this};function d(){var g=this,j=this.labelMapping(),h=this.dataType()||"";if(j){if(h.indexOf("chronological")>-1||(g.dataset.output()[0].length>2)){f(g.dataset.output()[0],function(l,k){if(k>0){g.dataset.data.output[0][k]=j[l]||l}})}else{if(g.dataset.output()[0].length===2){g.dataset.updateColumn(0,function(l,k){return j[l]||l})}}}}},{"../../core/utils/each":29}],82:[function(c,d,b){var f=c("../../core/utils/each");d.exports=function(h){if(!arguments.length){if(!this.view.attributes.labels||!this.view.attributes.labels.length){return g.call(this)}else{return this.view.attributes.labels}}else{this.view.attributes.labels=(h instanceof Array?h:null);a.call(this);return this}};function a(){var h=this,l=this.labels()||null,k=this.dataset.output(),j=this.dataType()||"";if(l){if(j.indexOf("chronological")>-1||(k[0].length>2)){f(k[0],function(m,n){if(n>0&&l[n-1]){h.dataset.data.output[0][n]=l[n-1]}})}else{f(k,function(n,m){if(m>0&&l[m-1]){h.dataset.data.output[m][0]=l[m-1]}})}}}function g(){var j=this.dataset.output(),h=this.dataType()||"",k;if(h.indexOf("chron")>-1||(j[0].length>2)){k=this.dataset.selectRow(0).slice(1)}else{k=this.dataset.selectColumn(0).slice(1)}return k}},{"../../core/utils/each":29}],83:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.adapter.library}this.view.adapter.library=(d?String(d):null);return this}},{}],84:[function(b,c,a){var d=b("../../dataset");var f=b("../../core/utils/extend");c.exports=function(j){var h,k=this.indexBy()?this.indexBy():"timestamp.start",m,g=[],l=(typeof j.query!=="undefined")?j.query:{};l=f({analysis_type:null,event_collection:null,filters:[],group_by:null,interval:null,timeframe:null,timezone:null},l);if(l.analysis_type==="funnel"){h="cat-ordinal";m="funnel"}else{if(l.analysis_type==="extraction"){h="extraction";m="extraction"}else{if(l.analysis_type==="select_unique"){if(!l.group_by&&!l.interval){h="nominal";m="list"}}else{if(l.analysis_type){if(!l.group_by&&!l.interval){h="singular";m="metric"}else{if(l.group_by&&!l.interval){if(l.group_by instanceof Array&&l.group_by.length>1){h="categorical";m="double-grouped-metric";g.push(l.group_by)}else{h="categorical";m="grouped-metric"}}else{if(l.interval&&!l.group_by){h="chronological";m="interval";g.push(k)}else{if(l.group_by&&l.interval){if(l.group_by instanceof Array&&l.group_by.length>1){h="cat-chronological";m="double-grouped-interval";g.push(l.group_by);g.push(k)}else{h="cat-chronological";m="grouped-interval";g.push(k)}}}}}}}}}if(!m){if(typeof j.result==="number"){h="singular";m="metric"}if(j.result instanceof Array&&j.result.length>0){if(j.result[0].timeframe&&(typeof j.result[0].value=="number"||j.result[0].value==null)){h="chronological";m="interval";g.push(k)}if(typeof j.result[0].result=="number"){h="categorical";m="grouped-metric"}if(j.result[0].value instanceof Array){h="cat-chronological";m="grouped-interval";g.push(k)}if(typeof j.result[0]=="number"&&typeof j.steps!=="undefined"){h="cat-ordinal";m="funnel"}if((typeof j.result[0]=="string"||typeof j.result[0]=="number")&&typeof j.steps==="undefined"){h="nominal";m="list"}if(h===void 0){h="extraction";m="extraction"}}}if(h){this.dataType(h)}this.dataset=d.parser.apply(this,[m].concat(g))(j);if(m.indexOf("interval")>-1){this.dataset.updateColumn(0,function(o,n){return new Date(o)})}return this}},{"../../core/utils/extend":31,"../../dataset":37}],85:[function(b,a,d){var f=b("../../core/query");var k=b("./dataType"),g=b("../../core/utils/extend"),c=b("../helpers/getDefaultTitle"),h=b("../helpers/getQueryDataType"),l=b("./parseRawData"),j=b("./title");a.exports=function(n){var m=n.data instanceof Array?n.data[0]:n.data;if(n.queries[0] instanceof f){m.query=g({analysis_type:n.queries[0].analysis},n.queries[0].params);k.call(this,h(n.queries[0]));this.view.defaults.title=c.call(this,n);if(!j.call(this)){j.call(this,this.view.defaults.title)}}l.call(this,m);return this}},{"../../core/query":24,"../../core/utils/extend":31,"../helpers/getDefaultTitle":59,"../helpers/getQueryDataType":60,"./dataType":75,"./parseRawData":84,"./title":90}],86:[function(b,c,a){var d=b("../dataviz");c.exports=function(){var f;if(this.view._rendered){this.destroy()}if(this.el()){this.el().innerHTML="";f=d.libraries[this.view.loader.library][this.view.loader.chartType];if(f.initialize){f.initialize.apply(this,arguments)}if(f.render){f.render.apply(this,arguments)}this.view._prepared=true}return this}},{"../dataviz":56}],87:[function(b,c,a){c.exports=function(f){if(!arguments.length){return this.view.attributes.sortGroups}this.view.attributes.sortGroups=(f?String(f):null);d.call(this);return this};function d(){var f=this.dataType();if(!this.sortGroups()){return}if((f&&f.indexOf("chronological")>-1)||this.data()[0].length>2){this.dataset.sortColumns(this.sortGroups(),this.dataset.getColumnSum)}else{if(f&&(f.indexOf("cat-")>-1||f.indexOf("categorical")>-1)){this.dataset.sortRows(this.sortGroups(),this.dataset.getRowSum)}}return}},{}],88:[function(b,c,a){c.exports=function(f){if(!arguments.length){return this.view.attributes.sortIntervals}this.view.attributes.sortIntervals=(f?String(f):null);d.call(this);return this};function d(){if(!this.sortIntervals()){return}this.dataset.sortRows(this.sortIntervals());return}},{}],89:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.attributes["stacked"]}this.view.attributes["stacked"]=d?true:false;return this}},{}],90:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.attributes["title"]}this.view.attributes["title"]=(d?String(d):null);return this}},{}],91:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.attributes["width"]}this.view.attributes["width"]=(!isNaN(parseInt(d))?parseInt(d):null);return this}},{}],92:[function(b,c,a){c.exports=function(){if(this.labelMapping()){this.labelMapping(this.labelMapping())}if(this.colorMapping()){this.colorMapping(this.colorMapping())}if(this.sortGroups()){this.sortGroups(this.sortGroups())}if(this.sortIntervals()){this.sortIntervals(this.sortIntervals())}}},{}],93:[function(b,c,a){c.exports=function(f,d){var j=document;var h;var g=j.head||j.getElementsByTagName("head");setTimeout(function(){if("item" in g){if(!g[0]){setTimeout(arguments.callee,25);return}g=g[0]}var k=j.createElement("script"),l=false;k.onload=k.onreadystatechange=function(){if((k.readyState&&k.readyState!=="complete"&&k.readyState!=="loaded")||l){return false}k.onload=k.onreadystatechange=null;l=true;d()};k.src=f;g.insertBefore(k,g.firstChild)},0);if(j.readyState===null&&j.addEventListener){j.readyState="loading";j.addEventListener("DOMContentLoaded",h=function(){j.removeEventListener("DOMContentLoaded",h,false);j.readyState="complete"},false)}}},{}],94:[function(b,c,a){c.exports=function(f,d){var g=document.createElement("link");g.setAttribute("rel","stylesheet");g.type="text/css";g.href=f;d();document.head.appendChild(g)}},{}],95:[function(b,c,a){c.exports=function(k){var d=Number(k),h=d.toPrecision(3),j="",f=["","k","M","B","T"];if(Number(h)==d&&String(d).length<=4){return String(d)}if(d>=1||d<=-1){if(d<0){d=-d;j="-"}return j+g(d,0)}else{return d.toPrecision(3)}function g(l,n){var l=String(l);var m=l.split(".");if(m.length>1){l=m[0];var p=m[1];if(l.length==2&&p.length>0){if(p.length>0){l=l+"."+p.charAt(0)}else{l+="0"}}else{if(l.length==1&&p.length>0){l=l+"."+p.charAt(0);if(p.length>1){l+=p.charAt(1)}else{l+="0"}}}}var o=l.length;if(l.split(".").length>1){o--}if(o<=3){return String(l)+f[n]}else{return g(Number(l)/1000,n+1)}}}},{}],96:[function(b,c,a){(function(d){(function(j){if(typeof define==="function"&&define.amd){define("keen",[],function(){return j()})}if(typeof a==="object"&&typeof c!=="undefined"){c.exports=j()}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=j()}})(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"),get:b("./core/lib/get"),post:b("./core/lib/post"),put:b("./core/lib/post"),run:b("./core/lib/run"),savedQueries:b("./core/saved-queries"),draw:b("./dataviz/extensions/draw")});f.Query=b("./core/query");f.Request=b("./core/request");f.Dataset=b("./dataset");f.Dataviz=b("./dataviz");f.Base64=b("./core/utils/base64");f.Spinner=b("spin.js");f.utils={domready:b("domready"),each:b("./core/utils/each"),extend:g,parseParams:b("./core/utils/parseParams"),prettyNumber:b("./dataviz/utils/prettyNumber")};b("./dataviz/adapters/keen-io")();b("./dataviz/adapters/google")();b("./dataviz/adapters/c3")();b("./dataviz/adapters/chartjs")();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":16,"./core/async":8,"./core/lib/addEvent":17,"./core/lib/addEvents":18,"./core/lib/get":19,"./core/lib/post":20,"./core/lib/run":21,"./core/lib/setGlobalProperties":22,"./core/lib/trackExternalLink":23,"./core/query":24,"./core/request":25,"./core/saved-queries":26,"./core/utils/base64":27,"./core/utils/each":29,"./core/utils/extend":31,"./core/utils/parseParams":33,"./dataset":37,"./dataviz":61,"./dataviz/adapters/c3":52,"./dataviz/adapters/chartjs":53,"./dataviz/adapters/google":54,"./dataviz/adapters/keen-io":55,"./dataviz/extensions/draw":57,"./dataviz/utils/prettyNumber":95,domready:2,"spin.js":5}]},{},[96]); \ No newline at end of file +var g=d("../../core"),a=d("../dataviz");var j=d("../../core/utils/clone"),k=d("../../core/utils/each"),h=d("../../core/utils/extend"),c=d("../utils/prettyNumber");b.exports=function(){var l,o,n;g.Error={defaults:{backgroundColor:"",borderRadius:"4px",color:"#ccc",display:"block",fontFamily:"Helvetica Neue, Helvetica, Arial, sans-serif",fontSize:"21px",fontWeight:"light",textAlign:"center"}};g.Spinner.defaults={height:138,lines:10,length:8,width:3,radius:10,corners:1,rotate:0,direction:1,color:"#4d4d4d",speed:1.67,trail:60,shadow:false,hwaccel:false,className:"keen-spinner",zIndex:2000000000,top:"50%",left:"50%"};var m={singular:["metric"]};l={initialize:function(){var p=document.createElement("style"),q="#49c5b1";p.id="keen-widgets";p.type="text/css";p.innerHTML=" .keen-metric { \n background: "+q+"; \n border-radius: 4px; \n color: #fff; \n font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; \n padding: 10px 0; \n text-align: center; \n} .keen-metric-value { \n display: block; \n font-size: 84px; \n font-weight: 700; \n line-height: 84px; \n} .keen-metric-title { \n display: block; \n font-size: 24px; \n font-weight: 200; \n}";if(!document.getElementById(p.id)){document.body.appendChild(p)}},render:function(){var u=(this.colors().length==1)?this.colors()[0]:"#49c5b1",t=this.title()||"Result",v=this.data()[1][1]||0,r=this.width(),q=this.chartOptions()||{},s="",w="";var x={width:(r)?r+"px":"auto"};var p=v;if(typeof q.prettyNumber==="undefined"||q.prettyNumber==true){if(!isNaN(parseInt(v))){p=c(v)}}if(q.prefix){s=''+q.prefix+""}if(q.suffix){w=''+q.suffix+""}this.el().innerHTML='
'+s+p+w+''+t+"
"}};o={initialize:function(){},render:function(t,q){var r,s;var u=j(g.Error.defaults);var p=h(u,q);r=document.createElement("div");r.className="keen-error";k(p,function(w,v){r.style[v]=w});r.style.height=String(this.height()+"px");r.style.paddingTop=(this.height()/2-15)+"px";r.style.width=String(this.width()+"px");s=document.createElement("span");s.innerHTML=t||"Yikes! An error occurred!";r.appendChild(s);this.el().innerHTML="";this.el().appendChild(r)},destroy:function(){this.el().innerHTML=""}};n={initialize:function(){},render:function(){var q=document.createElement("div");var p=this.height()||g.Spinner.defaults.height;q.className="keen-loading";q.style.height=String(p+"px");q.style.position="relative";q.style.width=String(this.width()+"px");this.el().innerHTML="";this.el().appendChild(q);this.view._artifacts.spinner=new g.Spinner(g.Spinner.defaults).spin(q)},destroy:function(){this.view._artifacts.spinner.stop();this.view._artifacts.spinner=null}};g.Dataviz.register("keen-io",{metric:l,error:o,spinner:n},{capabilities:m})}},{"../../core":16,"../../core/utils/clone":28,"../../core/utils/each":29,"../../core/utils/extend":31,"../dataviz":56,"../utils/prettyNumber":95}],56:[function(f,d,g){var k=f("../core/utils/clone"),m=f("../core/utils/each"),j=f("../core/utils/extend"),a=f("./utils/loadScript"),n=f("./utils/loadStyle");var h=f("../core");var l=f("../core/utils/emitter-shim");var c=f("../dataset");function b(){this.dataset=new c();this.view={_prepared:false,_initialized:false,_rendered:false,_artifacts:{},adapter:{library:undefined,chartOptions:{},chartType:undefined,defaultChartType:undefined,dataType:undefined},attributes:k(b.defaults),defaults:k(b.defaults),el:undefined,loader:{library:"keen-io",chartType:"spinner"}};b.visuals.push(this)}j(b,{dataTypeMap:{singular:{library:"keen-io",chartType:"metric"},categorical:{library:"google",chartType:"piechart"},"cat-interval":{library:"google",chartType:"columnchart"},"cat-ordinal":{library:"google",chartType:"barchart"},chronological:{library:"google",chartType:"areachart"},"cat-chronological":{library:"google",chartType:"linechart"},extraction:{library:"google",chartType:"table"},nominal:{library:"google",chartType:"table"}},defaults:{colors:["#00bbde","#fe6672","#eeb058","#8a8ad6","#ff855c","#00cfbb","#5a9eed","#73d483","#c879bb","#0099b6","#d74d58","#cb9141","#6b6bb6","#d86945","#00aa99","#4281c9","#57b566","#ac5c9e","#27cceb","#ff818b","#f6bf71","#9b9be1","#ff9b79","#26dfcd","#73aff4","#87e096","#d88bcb"],indexBy:"timeframe.start",stacked:false},dependencies:{loading:0,loaded:0,urls:{}},libraries:{},visuals:[]});l(b);l(b.prototype);b.register=function(r,p,q){var o=this;var s=function(t){t.loaded++;if(t.loaded===t.loading){h.loaded=true;h.trigger("ready")}};b.libraries[r]=b.libraries[r]||{};m(p,function(u,t){b.libraries[r][t]=u});if(q&&q.capabilities){b.libraries[r]._defaults=b.libraries[r]._defaults||{};m(q.capabilities,function(t,u){b.libraries[r]._defaults[u]=t})}if(q&&q.dependencies){m(q.dependencies,function(v,u,w){var t=b.dependencies;if(!t.urls[v.url]){t.urls[v.url]=true;t.loading++;var x=v.type==="script"?a:n;x(v.url,function(){if(v.cb){v.cb.call(o,function(){s(t)})}else{s(t)}})}})}};b.find=function(q){if(!arguments.length){return b.visuals}var p=q.nodeName?q:document.querySelector(q),o;m(b.visuals,function(r){if(p==r.el()){o=r;return false}});if(o){return o}};d.exports=b},{"../core":16,"../core/utils/clone":28,"../core/utils/each":29,"../core/utils/emitter-shim":30,"../core/utils/extend":31,"../dataset":37,"./utils/loadScript":93,"./utils/loadStyle":94}],57:[function(b,d,a){var h=b("../../core/utils/clone"),g=b("../../core/utils/extend"),f=b("../dataviz"),c=b("../../core/request");d.exports=function(p,m,j){var l=h(f.defaults),o=new f(),n=new c(this,[p]),k=j||{};o.attributes(g(l,k)).el(m).prepare();n.refresh();n.on("complete",function(){o.parseRequest(this).call(function(){if(k.labels){this.labels(k.labels)}}).render()});n.on("error",function(q){o.error(q.message)});return o}},{"../../core/request":25,"../../core/utils/clone":28,"../../core/utils/extend":31,"../dataviz":56}],58:[function(b,c,a){var d=b("../dataviz"),f=b("../../core/utils/extend");c.exports=function(){var k=f({},d.dataTypeMap),h=this.dataType(),g=this.library(),j=this.chartType()||this.defaultChartType();if(!g&&k[h]){g=k[h].library}if(g&&!j&&h){j=d.libraries[g]._defaults[h][0]}if(g&&!j&&k[h]){j=k[h].chartType}if(g&&j&&d.libraries[g][j]){return d.libraries[g][j]}else{return{}}}},{"../../core/utils/extend":31,"../dataviz":56}],59:[function(b,c,a){c.exports=function(f){var h=f.queries[0].analysis.replace("_"," "),g=f.queries[0].get("event_collection"),d;d=h.replace(/\b./g,function(j){return j.toUpperCase()});if(g){d+=" - "+g}return d}},{}],60:[function(b,c,a){c.exports=function(g){var h=typeof g.params.interval==="string",f=typeof g.params.group_by==="string",j=g.params.group_by instanceof Array,d;if(!f&&!h){d="singular"}if(f&&!h){d="categorical"}if(h&&!f){d="chronological"}if(h&&f){d="cat-chronological"}if(!h&&j){d="categorical"}if(h&&j){d="cat-chronological"}if(g.analysis==="funnel"){d="cat-ordinal"}if(g.analysis==="extraction"){d="extraction"}if(g.analysis==="select_unique"){d="nominal"}return d}},{}],61:[function(b,c,a){var f=b("../core/utils/extend"),d=b("./dataviz");f(d.prototype,{adapter:b("./lib/adapter"),attributes:b("./lib/attributes"),call:b("./lib/call"),chartOptions:b("./lib/chartOptions"),chartType:b("./lib/chartType"),colorMapping:b("./lib/colorMapping"),colors:b("./lib/colors"),data:b("./lib/data"),dataType:b("./lib/dataType"),dateFormat:b("./lib/dateFormat"),defaultChartType:b("./lib/defaultChartType"),el:b("./lib/el"),height:b("./lib/height"),indexBy:b("./lib/indexBy"),labelMapping:b("./lib/labelMapping"),labels:b("./lib/labels"),library:b("./lib/library"),parseRawData:b("./lib/parseRawData"),parseRequest:b("./lib/parseRequest"),prepare:b("./lib/prepare"),sortGroups:b("./lib/sortGroups"),sortIntervals:b("./lib/sortIntervals"),stacked:b("./lib/stacked"),title:b("./lib/title"),width:b("./lib/width")});f(d.prototype,{destroy:b("./lib/actions/destroy"),error:b("./lib/actions/error"),initialize:b("./lib/actions/initialize"),render:b("./lib/actions/render"),update:b("./lib/actions/update")});c.exports=d},{"../core/utils/extend":31,"./dataviz":56,"./lib/actions/destroy":62,"./lib/actions/error":63,"./lib/actions/initialize":64,"./lib/actions/render":65,"./lib/actions/update":66,"./lib/adapter":67,"./lib/attributes":68,"./lib/call":69,"./lib/chartOptions":70,"./lib/chartType":71,"./lib/colorMapping":72,"./lib/colors":73,"./lib/data":74,"./lib/dataType":75,"./lib/dateFormat":76,"./lib/defaultChartType":77,"./lib/el":78,"./lib/height":79,"./lib/indexBy":80,"./lib/labelMapping":81,"./lib/labels":82,"./lib/library":83,"./lib/parseRawData":84,"./lib/parseRequest":85,"./lib/prepare":86,"./lib/sortGroups":87,"./lib/sortIntervals":88,"./lib/stacked":89,"./lib/title":90,"./lib/width":91}],62:[function(b,c,a){var d=b("../../helpers/getAdapterActions");c.exports=function(){var f=d.call(this);if(f.destroy){f.destroy.apply(this,arguments)}if(this.el()){this.el().innerHTML=""}this.view._prepared=false;this.view._initialized=false;this.view._rendered=false;this.view._artifacts={};return this}},{"../../helpers/getAdapterActions":58}],63:[function(b,c,a){var f=b("../../helpers/getAdapterActions"),d=b("../../dataviz");c.exports=function(){var g=f.call(this);if(this.el()){if(g.error){g.error.apply(this,arguments)}else{d.libraries["keen-io"]["error"].render.apply(this,arguments)}}else{this.emit("error","No DOM element provided")}return this}},{"../../dataviz":56,"../../helpers/getAdapterActions":58}],64:[function(b,c,a){var f=b("../../helpers/getAdapterActions"),d=b("../../dataviz");c.exports=function(){var h=f.call(this);var g=d.libraries[this.view.loader.library][this.view.loader.chartType];if(this.view._prepared){if(g.destroy){g.destroy.apply(this,arguments)}}else{if(this.el()){this.el().innerHTML=""}}if(h.initialize){h.initialize.apply(this,arguments)}else{this.error("Incorrect chartType");this.emit("error","Incorrect chartType")}this.view._initialized=true;return this}},{"../../dataviz":56,"../../helpers/getAdapterActions":58}],65:[function(c,d,b){var f=c("../../helpers/getAdapterActions"),a=c("../../utils/applyTransforms");d.exports=function(){var g=f.call(this);a.call(this);if(!this.view._initialized){this.initialize()}if(this.el()&&g.render){g.render.apply(this,arguments);this.view._rendered=true}return this}},{"../../helpers/getAdapterActions":58,"../../utils/applyTransforms":92}],66:[function(c,d,b){var f=c("../../helpers/getAdapterActions"),a=c("../../utils/applyTransforms");d.exports=function(){var g=f.call(this);a.call(this);if(g.update){g.update.apply(this,arguments)}else{if(g.render){this.render()}}return this}},{"../../helpers/getAdapterActions":58,"../../utils/applyTransforms":92}],67:[function(b,c,a){var d=b("../../core/utils/each");c.exports=function(g){if(!arguments.length){return this.view.adapter}var f=this;d(g,function(j,h){f.view.adapter[h]=(j?j:null)});return this}},{"../../core/utils/each":29}],68:[function(b,c,a){var d=b("../../core/utils/each");var f=b("./chartOptions");chartType=b("./chartType"),library=b("./library");c.exports=function(h){if(!arguments.length){return this.view.attributes}var g=this;d(h,function(k,j){if(j==="library"){library.call(g,k)}else{if(j==="chartType"){chartType.call(g,k)}else{if(j==="chartOptions"){f.call(g,k)}else{g.view.attributes[j]=k}}}});return this}},{"../../core/utils/each":29,"./chartOptions":70,"./chartType":71,"./library":83}],69:[function(b,c,a){c.exports=function(d){d.call(this);return this}},{}],70:[function(b,c,a){var d=b("../../core/utils/extend");c.exports=function(f){if(!arguments.length){return this.view.adapter.chartOptions}if(typeof f==="object"&&f!==null){d(this.view.adapter.chartOptions,f)}else{this.view.adapter.chartOptions={}}return this}},{"../../core/utils/extend":31}],71:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.adapter.chartType}this.view.adapter.chartType=(d?String(d):null);return this}},{}],72:[function(b,c,a){var d=b("../../core/utils/each");c.exports=function(g){if(!arguments.length){return this.view.attributes.colorMapping}this.view.attributes.colorMapping=(g?g:null);f.call(this);return this};function f(){var g=this,l=this.dataset.schema,m=this.dataset.output(),j=this.view.defaults.colors.slice(),h=this.colorMapping(),k=this.dataType()||"";if(h){if(k.indexOf("chronological")>-1||(l.unpack&&m[0].length>2)){d(m[0].slice(1),function(o,p){var n=h[o];if(n&&j[p]!==n){j.splice(p,0,n)}})}else{d(g.dataset.selectColumn(0).slice(1),function(o,p){var n=h[o];if(n&&j[p]!==n){j.splice(p,0,n)}})}g.view.attributes.colors=j}}},{"../../core/utils/each":29}],73:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.attributes.colors}this.view.attributes.colors=(d instanceof Array?d:null);this.view.defaults.colors=(d instanceof Array?d:null);return this}},{}],74:[function(b,d,a){var f=b("../../dataset"),c=b("../../core/request");d.exports=function(g){if(!arguments.length){return this.dataset.output()}if(g instanceof f){this.dataset=g}else{if(g instanceof c){this.parseRequest(g)}else{this.parseRawData(g)}}return this}},{"../../core/request":25,"../../dataset":37}],75:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.adapter.dataType}this.view.adapter.dataType=(d?String(d):null);return this}},{}],76:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.attributes.dateFormat}if(typeof d==="string"||typeof d==="function"){this.view.attributes.dateFormat=d}else{this.view.attributes.dateFormat=undefined}return this}},{}],77:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.adapter.defaultChartType}this.view.adapter.defaultChartType=(d?String(d):null);return this}},{}],78:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.el}this.view.el=d;return this}},{}],79:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.attributes["height"]}this.view.attributes["height"]=(!isNaN(parseInt(d))?parseInt(d):null);return this}},{}],80:[function(b,d,a){var f=b("../../dataset"),h=b("../dataviz"),g=b("../../core/utils/each");d.exports=function(j){if(!arguments.length){return this.view.attributes.indexBy}this.view.attributes.indexBy=(j?String(j):h.defaults.indexBy);c.call(this);return this};function c(){var k,j;if(this.dataset.output().length>1&&!isNaN(new Date(this.dataset.output()[1][0]).getTime())){if(this.dataset.parser&&this.dataset.parser.name&&this.dataset.parser.options){if(this.dataset.parser.options.length===1){k=f.parser(this.dataset.parser.name,this.indexBy());this.dataset.parser.options[0]=this.indexBy()}else{k=f.parser(this.dataset.parser.name,this.dataset.parser.options[0],this.indexBy());this.dataset.parser.options[1]=this.indexBy()}}else{if(this.dataset.output()[0].length===2){k=f.parser("interval",this.indexBy());this.dataset.parser={name:"interval",options:[this.indexBy()]}}else{k=f.parser("grouped-interval",this.indexBy());this.dataset.parser={name:"grouped-interval",options:[this.indexBy()]}}}this.dataset=k(this.dataset.input());this.dataset.updateColumn(0,function(l){return(typeof l==="string")?new Date(l):l})}}},{"../../core/utils/each":29,"../../dataset":37,"../dataviz":56}],81:[function(b,c,a){var f=b("../../core/utils/each");c.exports=function(g){if(!arguments.length){return this.view.attributes.labelMapping}this.view.attributes.labelMapping=(g?g:null);d.call(this);return this};function d(){var g=this,j=this.labelMapping(),h=this.dataType()||"";if(j){if(h.indexOf("chronological")>-1||(g.dataset.output()[0].length>2)){f(g.dataset.output()[0],function(l,k){if(k>0){g.dataset.data.output[0][k]=j[l]||l}})}else{if(g.dataset.output()[0].length===2){g.dataset.updateColumn(0,function(l,k){return j[l]||l})}}}}},{"../../core/utils/each":29}],82:[function(c,d,b){var f=c("../../core/utils/each");d.exports=function(h){if(!arguments.length){if(!this.view.attributes.labels||!this.view.attributes.labels.length){return g.call(this)}else{return this.view.attributes.labels}}else{this.view.attributes.labels=(h instanceof Array?h:null);a.call(this);return this}};function a(){var h=this,l=this.labels()||null,k=this.dataset.output(),j=this.dataType()||"";if(l){if(j.indexOf("chronological")>-1||(k[0].length>2)){f(k[0],function(m,n){if(n>0&&l[n-1]){h.dataset.data.output[0][n]=l[n-1]}})}else{f(k,function(n,m){if(m>0&&l[m-1]){h.dataset.data.output[m][0]=l[m-1]}})}}}function g(){var j=this.dataset.output(),h=this.dataType()||"",k;if(h.indexOf("chron")>-1||(j[0].length>2)){k=this.dataset.selectRow(0).slice(1)}else{k=this.dataset.selectColumn(0).slice(1)}return k}},{"../../core/utils/each":29}],83:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.adapter.library}this.view.adapter.library=(d?String(d):null);return this}},{}],84:[function(b,c,a){var d=b("../../dataset");var f=b("../../core/utils/extend");c.exports=function(j){var h,k=this.indexBy()?this.indexBy():"timestamp.start",m,g=[],l=(typeof j.query!=="undefined")?j.query:{};l=f({analysis_type:null,event_collection:null,filters:[],group_by:null,interval:null,timeframe:null,timezone:null},l);if(l.analysis_type==="funnel"){h="cat-ordinal";m="funnel"}else{if(l.analysis_type==="extraction"){h="extraction";m="extraction"}else{if(l.analysis_type==="select_unique"){if(!l.group_by&&!l.interval){h="nominal";m="list"}}else{if(l.analysis_type){if(!l.group_by&&!l.interval){h="singular";m="metric"}else{if(l.group_by&&!l.interval){if(l.group_by instanceof Array&&l.group_by.length>1){h="categorical";m="double-grouped-metric";g.push(l.group_by)}else{h="categorical";m="grouped-metric"}}else{if(l.interval&&!l.group_by){h="chronological";m="interval";g.push(k)}else{if(l.group_by&&l.interval){if(l.group_by instanceof Array&&l.group_by.length>1){h="cat-chronological";m="double-grouped-interval";g.push(l.group_by);g.push(k)}else{h="cat-chronological";m="grouped-interval";g.push(k)}}}}}}}}}if(!m){if(typeof j.result==="number"){h="singular";m="metric"}if(j.result instanceof Array&&j.result.length>0){if(j.result[0].timeframe&&(typeof j.result[0].value=="number"||j.result[0].value==null)){h="chronological";m="interval";g.push(k)}if(typeof j.result[0].result=="number"){h="categorical";m="grouped-metric"}if(j.result[0].value instanceof Array){h="cat-chronological";m="grouped-interval";g.push(k)}if(typeof j.result[0]=="number"&&typeof j.steps!=="undefined"){h="cat-ordinal";m="funnel"}if((typeof j.result[0]=="string"||typeof j.result[0]=="number")&&typeof j.steps==="undefined"){h="nominal";m="list"}if(h===void 0){h="extraction";m="extraction"}}}if(h){this.dataType(h)}this.dataset=d.parser.apply(this,[m].concat(g))(j);if(m.indexOf("interval")>-1){this.dataset.updateColumn(0,function(o,n){return new Date(o)})}return this}},{"../../core/utils/extend":31,"../../dataset":37}],85:[function(b,a,d){var f=b("../../core/query");var k=b("./dataType"),g=b("../../core/utils/extend"),c=b("../helpers/getDefaultTitle"),h=b("../helpers/getQueryDataType"),l=b("./parseRawData"),j=b("./title");a.exports=function(n){var m=n.data instanceof Array?n.data[0]:n.data;if(n.queries[0] instanceof f){m.query=g({analysis_type:n.queries[0].analysis},n.queries[0].params);k.call(this,h(n.queries[0]));this.view.defaults.title=c.call(this,n);if(!j.call(this)){j.call(this,this.view.defaults.title)}}l.call(this,m);return this}},{"../../core/query":24,"../../core/utils/extend":31,"../helpers/getDefaultTitle":59,"../helpers/getQueryDataType":60,"./dataType":75,"./parseRawData":84,"./title":90}],86:[function(b,c,a){var d=b("../dataviz");c.exports=function(){var f;if(this.view._rendered){this.destroy()}if(this.el()){this.el().innerHTML="";f=d.libraries[this.view.loader.library][this.view.loader.chartType];if(f.initialize){f.initialize.apply(this,arguments)}if(f.render){f.render.apply(this,arguments)}this.view._prepared=true}return this}},{"../dataviz":56}],87:[function(b,c,a){c.exports=function(f){if(!arguments.length){return this.view.attributes.sortGroups}this.view.attributes.sortGroups=(f?String(f):null);d.call(this);return this};function d(){var f=this.dataType();if(!this.sortGroups()){return}if((f&&f.indexOf("chronological")>-1)||this.data()[0].length>2){this.dataset.sortColumns(this.sortGroups(),this.dataset.getColumnSum)}else{if(f&&(f.indexOf("cat-")>-1||f.indexOf("categorical")>-1)){this.dataset.sortRows(this.sortGroups(),this.dataset.getRowSum)}}return}},{}],88:[function(b,c,a){c.exports=function(f){if(!arguments.length){return this.view.attributes.sortIntervals}this.view.attributes.sortIntervals=(f?String(f):null);d.call(this);return this};function d(){if(!this.sortIntervals()){return}this.dataset.sortRows(this.sortIntervals());return}},{}],89:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.attributes["stacked"]}this.view.attributes["stacked"]=d?true:false;return this}},{}],90:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.attributes["title"]}this.view.attributes["title"]=(d?String(d):null);return this}},{}],91:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.attributes["width"]}this.view.attributes["width"]=(!isNaN(parseInt(d))?parseInt(d):null);return this}},{}],92:[function(b,c,a){c.exports=function(){if(this.labelMapping()){this.labelMapping(this.labelMapping())}if(this.colorMapping()){this.colorMapping(this.colorMapping())}if(this.sortGroups()){this.sortGroups(this.sortGroups())}if(this.sortIntervals()){this.sortIntervals(this.sortIntervals())}}},{}],93:[function(b,c,a){c.exports=function(f,d){var j=document;var h;var g=j.head||j.getElementsByTagName("head");setTimeout(function(){if("item" in g){if(!g[0]){setTimeout(arguments.callee,25);return}g=g[0]}var k=j.createElement("script"),l=false;k.onload=k.onreadystatechange=function(){if((k.readyState&&k.readyState!=="complete"&&k.readyState!=="loaded")||l){return false}k.onload=k.onreadystatechange=null;l=true;d()};k.src=f;g.insertBefore(k,g.firstChild)},0);if(j.readyState===null&&j.addEventListener){j.readyState="loading";j.addEventListener("DOMContentLoaded",h=function(){j.removeEventListener("DOMContentLoaded",h,false);j.readyState="complete"},false)}}},{}],94:[function(b,c,a){c.exports=function(f,d){var g=document.createElement("link");g.setAttribute("rel","stylesheet");g.type="text/css";g.href=f;d();document.head.appendChild(g)}},{}],95:[function(b,c,a){c.exports=function(k){var d=Number(k),h=d.toPrecision(3),j="",f=["","k","M","B","T"];if(Number(h)==d&&String(d).length<=4){return String(d)}if(d>=1||d<=-1){if(d<0){d=-d;j="-"}return j+g(d,0)}else{return d.toPrecision(3)}function g(l,n){var l=String(l);var m=l.split(".");if(m.length>1){l=m[0];var p=m[1];if(l.length==2&&p.length>0){if(p.length>0){l=l+"."+p.charAt(0)}else{l+="0"}}else{if(l.length==1&&p.length>0){l=l+"."+p.charAt(0);if(p.length>1){l+=p.charAt(1)}else{l+="0"}}}}var o=l.length;if(l.split(".").length>1){o--}if(o<=3){return String(l)+f[n]}else{return g(Number(l)/1000,n+1)}}}},{}],96:[function(b,c,a){(function(d){(function(j){if(typeof define==="function"&&define.amd){define("keen",[],function(){return j()})}if(typeof a==="object"&&typeof c!=="undefined"){c.exports=j()}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=j()}})(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"),get:b("./core/lib/get"),post:b("./core/lib/post"),put:b("./core/lib/post"),run:b("./core/lib/run"),savedQueries:b("./core/saved-queries"),draw:b("./dataviz/extensions/draw")});f.Query=b("./core/query");f.Request=b("./core/request");f.Dataset=b("./dataset");f.Dataviz=b("./dataviz");f.Base64=b("./core/utils/base64");f.Spinner=b("spin.js");f.utils={domready:b("domready"),each:b("./core/utils/each"),extend:g,parseParams:b("./core/utils/parseParams"),prettyNumber:b("./dataviz/utils/prettyNumber")};b("./dataviz/adapters/keen-io")();b("./dataviz/adapters/google")();b("./dataviz/adapters/c3")();b("./dataviz/adapters/chartjs")();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":16,"./core/async":8,"./core/lib/addEvent":17,"./core/lib/addEvents":18,"./core/lib/get":19,"./core/lib/post":20,"./core/lib/run":21,"./core/lib/setGlobalProperties":22,"./core/lib/trackExternalLink":23,"./core/query":24,"./core/request":25,"./core/saved-queries":26,"./core/utils/base64":27,"./core/utils/each":29,"./core/utils/extend":31,"./core/utils/parseParams":33,"./dataset":37,"./dataviz":61,"./dataviz/adapters/c3":52,"./dataviz/adapters/chartjs":53,"./dataviz/adapters/google":54,"./dataviz/adapters/keen-io":55,"./dataviz/extensions/draw":57,"./dataviz/utils/prettyNumber":95,domready:2,"spin.js":4}]},{},[96]); \ No newline at end of file diff --git a/docs/installation.md b/docs/installation.md index 67c9a9f..e36b2c3 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -38,7 +38,7 @@ Unlike the core `Keen` object and its tracking-related methods, `Keen.Query`, `K Keen.ready(function(){ // runs once library has loaded var query = new Keen.Query("count", { - eventCollection: "pageviews" + event_collection: "pageviews" }); // .. run query, visualize, etc. }); diff --git a/docs/query.md b/docs/query.md index 82a53b7..269f511 100644 --- a/docs/query.md +++ b/docs/query.md @@ -8,7 +8,7 @@ The `run` method is available on each configured client instance to run one or m ```javascript var your_analysis = new Keen.Query(analysisType, { - eventCollection: 'YOUR_EVENT_COLLECTION', // (required) + event_collection: 'YOUR_EVENT_COLLECTION', // (required) timeframe: "YOUR_TIMEFRAME" // (required) // ... additional parameters }); @@ -19,20 +19,20 @@ var your_analysis = new Keen.Query(analysisType, { ```javascript //Configure the client var client = new Keen({ - projectId: "your_project_id", - readKey: "your_read_key" + projectId: "your_project_id", + readKey: "your_read_key" }); Keen.ready(function(){ // Count the number of times case study pages were viewed var count = new Keen.Query("count", { - eventCollection: "pageviews", + event_collection: "pageviews", timeframe: { "start":"2015-07-01T07:00:00.000Z", "end":"2015-08-01T07:00:00.000Z" }, interval: "daily", - maxAge: 300, // activate query caching by assigning maxAge (an integer representing seconds) + max_age: 300, // activate query caching by assigning max_age (an integer representing seconds) filters: [ { "property_name" : "domain", @@ -66,7 +66,7 @@ Extractions let you pull the raw data out of Keen IO. Learn more about extracti ```javascript var extraction = new Keen.Query('extraction', { - eventCollection: "pageviews", + event_collection: "pageviews", timeframe: "today" }); ``` @@ -81,12 +81,12 @@ var extraction = new Keen.Query('extraction', { var funnel = new Keen.Query('funnel', { steps: [ { - eventCollection: "view_landing_page", - actorProperty: "user.id" + event_collection: "view_landing_page", + actor_property: "user.id" }, { - eventCollection: "signed_up", - actorProperty: "user.id" + event_collection: "signed_up", + actor_property: "user.id" }, ], timeframe: "this_6_months" @@ -101,16 +101,16 @@ Query results are also attached to the query object itself, and can be reference ```javascript var avg_revenue = new Keen.Query("average", { - eventCollection: "purchase", + event_collection: "purchase", timeframe: "this_14_days", - targetProperty: "price", - groupBy: "geo.country" + target_property: "price", + group_by: "geo.country" }); var max_revenue = new Keen.Query("maximum", { - eventCollection: "purchase", + event_collection: "purchase", timeframe: "this_14_days", - targetProperty: "price", - groupBy: "geo.country" + target_property: "price", + group_by: "geo.country" }); var mashup = client.run([avg_revenue, max_revenue], function(err, res){ @@ -132,17 +132,17 @@ mashup.refresh(); ``` ## Query Caching -Data sent to Keen is available for querying almost immediately. For use cases that don’t require up-to-the-second answers but require fast performance, query caching can be used to speed up a query. To include query caching as a feature, just add the `maxAge` query parameter to any other query parameters you’ve already specified. The first time your application makes a query specifying the max_age the answer will be calculated normally before it can be cached for future uses. +Data sent to Keen is available for querying almost immediately. For use cases that don’t require up-to-the-second answers but require fast performance, query caching can be used to speed up a query. To include query caching as a feature, just add the `max_age` query parameter to any other query parameters you’ve already specified. The first time your application makes a query specifying the max_age the answer will be calculated normally before it can be cached for future uses. ```javascript var count = new Keen.Query("count", { - eventCollection: "pageviews", + event_collection: "pageviews", timeframe: "this_14_days", - groupBy: "property", - maxAge: 300 // include maxAge as a query parameter to activate Query Caching + group_by: "property", + max_age: 300 // include max_age as a query parameter to activate Query Caching }); ``` -`maxAge` is an integer which represents seconds. The maximum value for `maxAge` is 129600 seconds or 36 hours. Read more about Query Caching in the Keen IO [Data Analysis Docs](https://keen.io/docs/data-analysis/caching/). +`max_age` is an integer which represents seconds. The maximum value for `max_age` is 129600 seconds or 36 hours. Read more about Query Caching in the Keen IO [Data Analysis Docs](https://keen.io/docs/data-analysis/caching/). **Tip:** If you want to speed up your queries but maintain freshness, you can cache a year-long query and combine the result with a normal query that calculates the most current day’s answer. diff --git a/docs/recipes.md b/docs/recipes.md index 0f36b99..8386a80 100644 --- a/docs/recipes.md +++ b/docs/recipes.md @@ -15,14 +15,14 @@ var interval = "daily" var timeframe = "last_30_days" var pageviews = new Keen.Query("count", { // first query - eventCollection: "pageviews", + event_collection: "pageviews", interval: interval, timeframe: timeframe }); var uniqueVisitors = new Keen.Query("count_unique", { // second query - eventCollection: "pageviews", - targetProperty: "uuid", + event_collection: "pageviews", + target_property: "uuid", interval: interval, timeframe: timeframe }); @@ -85,14 +85,14 @@ Keen.ready(function(){ var timeframe = "last_30_days" var posts = new Keen.Query("count", { // first query - eventCollection: "posts", + event_collection: "posts", interval: interval, timeframe: timeframe }); var uniquePosters= new Keen.Query("count_unique", { // second query - eventCollection: "posts", - targetProperty: "uuid", + event_collection: "posts", + target_property: "uuid", interval: interval, timeframe: timeframe }); @@ -174,7 +174,7 @@ Each data point on the line chart tells you what percentage of users who signed // Use an action that happen every session var step2CollectionName = "session_starts"; - var actorProperty = "player_id" ; + var actor_property = "player_id" ; // Number of days ago the user did step1 var retentionPeriod = 30; @@ -193,10 +193,10 @@ Each data point on the line chart tells you what percentage of users who signed }) .prepare(); - calculateRetention(daysInChart, step1CollectionName, step2CollectionName, retentionPeriod, actorProperty, div); + calculateRetention(daysInChart, step1CollectionName, step2CollectionName, retentionPeriod, actor_property, div); }); - function calculateRetention(daysInChart, step1CollectionName, step2CollectionName, retentionPeriod, actorProperty, div) { + function calculateRetention(daysInChart, step1CollectionName, step2CollectionName, retentionPeriod, actor_property, div) { var dataForLineChart = []; for (i=0; i < daysInChart; i++) { @@ -221,8 +221,8 @@ Each data point on the line chart tells you what percentage of users who signed // Funnel steps used for calculating retention var step1 = { - eventCollection: step1CollectionName, - actorProperty: actorProperty, + event_collection: step1CollectionName, + actor_property: actor_property, timeframe: { start: firstStepDate.toISOString().replace("Z","") + TIMEZONE_OFFSET, end: firstStepDateEnd.toISOString().replace("Z","") + TIMEZONE_OFFSET @@ -230,8 +230,8 @@ Each data point on the line chart tells you what percentage of users who signed }; var step2 = { - eventCollection: step2CollectionName, - actorProperty: actorProperty, + event_collection: step2CollectionName, + actor_property: actor_property, timeframe: { start: secondStepDate.toISOString().replace("Z","") + TIMEZONE_OFFSET, end: secondStepDateEnd.toISOString().replace("Z","") + TIMEZONE_OFFSET diff --git a/docs/visualization.md b/docs/visualization.md index 492b9b7..68d1d8f 100644 --- a/docs/visualization.md +++ b/docs/visualization.md @@ -16,9 +16,9 @@ client.draw(query, node, config); Keen.ready(function(){ var query = new Keen.Query("count", { - eventCollection: "pageviews", + event_collection: "pageviews", timeframe: "this_14_days", - groupBy: "visitor.geo.country", + group_by: "visitor.geo.country", interval: "daily" }); @@ -168,8 +168,8 @@ Area, bar, column and line charts all operate on the same underlying query/respo ```javascript var total_pageviews = new Keen.Query("count", { - eventCollection: "pageviews", - groupBy: "channel", + event_collection: "pageviews", + group_by: "channel", timeframe: "this_3_days", interval: "daily" }); @@ -259,7 +259,7 @@ Visualize single numeric query responses, such as a count, sum, average, etc. ```javascript var count = new Keen.Query("count", { - eventCollection: "pageviews", + event_collection: "pageviews", timeframe: "this_14_days" }); client.draw(count, document.getElementById("count-pageviews-metric"), { @@ -284,12 +284,12 @@ client.draw(count, document.getElementById("count-pageviews-metric"), { ![Pie chart](http://d26b395fwzu5fz.cloudfront.net/images/Keen-demo-piechart.png) -Pie charts can render `groupBy` queries that do not include an interval. +Pie charts can render `group_by` queries that do not include an interval. ```javascript var visitor_origins = new Keen.Query("count", { - eventCollection: "pageviews", - groupBy: "referrer", + event_collection: "pageviews", + group_by: "referrer", timeframe: "this_14_days" }); client.draw(visitor_origins, document.getElementById("count-pageviews-piechart"), { @@ -307,7 +307,7 @@ Tables can render any query response, including extractions. ```javascript var all = new Keen.Query("extraction", { - eventCollection: "pageviews", + event_collection: "pageviews", timeframe: "this_7_days" }); client.draw(all, document.getElementById("extract-pageviews-table"), { @@ -414,14 +414,14 @@ Here's an example that runs two queries, divides them, and then outputs the resu Keen.ready(function(){ var sessions_count = new Keen.Query("count_unique", { - eventCollection: "screen_view", // Use this collection because there is at least 1 screenview per session - targetProperty: "session.id", + event_collection: "screen_view", // Use this collection because there is at least 1 screenview per session + target_property: "session.id", timeframe: "last_7_days" }); var paid_sessions_count = new Keen.Query("count_unique", { // Find number of sessions with payments - eventCollection: "payment", - targetProperty: "session.id", + event_collection: "payment", + target_property: "session.id", timeframe: "last_7_days" }); @@ -464,14 +464,14 @@ Keen.ready(function(){ var timeframe = "last_30_days" var pageviews = new Keen.Query("count", { // first query - eventCollection: "pageviews", + event_collection: "pageviews", interval: interval, timeframe: timeframe }); var uniqueVisitors = new Keen.Query("count_unique", { // second query - eventCollection: "pageviews", - targetProperty: "uuid", + event_collection: "pageviews", + target_property: "uuid", interval: interval, timeframe: timeframe }); From 0d511252f4cd8ef4da073535da81585fc64bd7d6 Mon Sep 17 00:00:00 2001 From: dustinlarimer Date: Tue, 16 Feb 2016 20:58:17 -0800 Subject: [PATCH 02/10] Resolve #386, improve c3.js settings construction --- dist/keen.js | 25 +++++++++++-------------- dist/keen.min.js | 2 +- src/dataviz/adapters/c3.js | 27 +++++++++++++-------------- test/examples/dataviz/c3/index.html | 10 ++++++++-- 4 files changed, 33 insertions(+), 31 deletions(-) diff --git a/dist/keen.js b/dist/keen.js index d9284f8..24b4ef5 100644 --- a/dist/keen.js +++ b/dist/keen.js @@ -4314,20 +4314,17 @@ module.exports = function(){ }; }); function getSetupTemplate(type){ - var setup = { + var setup = extend({ axis: {}, - bindto: this.el(), - data: { - columns: [] - }, - color: { - pattern: this.colors() - }, - size: { - height: this.height(), - width: this.width() - } - }; + color: {}, + data: {}, + size: {} + }, this.chartOptions()); + setup.bindto = this.el(); + setup.color.pattern = this.colors(); + setup.data.columns = []; + setup.size.height = this.height(); + setup.size.width = this.width(); setup['data']['type'] = type; if (type === 'gauge') {} else if (type === 'pie' || type === 'donut') { @@ -4355,7 +4352,7 @@ module.exports = function(){ setup['axis']['y'] = { label: this.title() } } } - return extend(setup, this.chartOptions()); + return setup; } function _selfDestruct(){ if (this.view._artifacts['c3']) { diff --git a/dist/keen.min.js b/dist/keen.min.js index 54fd311..3626cd4 100644 --- a/dist/keen.min.js +++ b/dist/keen.min.js @@ -10,7 +10,7 @@ * C3.js Adapter * ---------------------- */ -var f=b("../dataviz"),d=b("../../core/utils/each"),g=b("../../core/utils/extend");c.exports=function(){var k={singular:["gauge"],categorical:["donut","pie"],"cat-interval":["area-step","step","bar","area","area-spline","spline","line"],"cat-ordinal":["bar","area","area-spline","spline","line","step","area-step"],chronological:["area","area-spline","spline","line","bar","step","area-step"],"cat-chronological":["line","spline","area","area-spline","bar","step","area-step"]};var l={};d(["gauge","donut","pie","bar","area","area-spline","spline","line","step","area-step"],function(o,n){l[o]={render:function(){var p=j.call(this,o);this.view._artifacts.c3=c3.generate(p);this.update()},update:function(){var p=this,q=[];if(o==="gauge"){p.view._artifacts.c3.load({columns:[[p.title(),p.data()[1][1]]]})}else{if(o==="pie"||o==="donut"){p.view._artifacts.c3.load({columns:p.dataset.data.output.slice(1)})}else{if(this.dataType().indexOf("chron")>-1){q.push(p.dataset.selectColumn(0));q[0][0]="x"}d(p.data()[0],function(s,r){if(r>0){q.push(p.dataset.selectColumn(r))}});if(p.stacked()){p.view._artifacts.c3.groups([p.labels()])}p.view._artifacts.c3.load({columns:q})}}},destroy:function(){m.call(this)}}});function j(o){var n={axis:{},bindto:this.el(),data:{columns:[]},color:{pattern:this.colors()},size:{height:this.height(),width:this.width()}};n.data["type"]=o;if(o==="gauge"){}else{if(o==="pie"||o==="donut"){n[o]={title:this.title()}}else{if(this.dataType().indexOf("chron")>-1){n.data["x"]="x";n.axis["x"]={type:"timeseries",tick:{format:this.dateFormat()||h(this.data()[1][0],this.data()[2][0])}}}else{if(this.dataType()==="cat-ordinal"){n.axis["x"]={type:"category",categories:this.labels()}}}if(this.title()){n.axis["y"]={label:this.title()}}}}return g(n,this.chartOptions())}function m(){if(this.view._artifacts.c3){this.view._artifacts.c3.destroy();this.view._artifacts.c3=null}}function h(p,o){var q=Math.abs(new Date(p).getTime()-new Date(o).getTime());var n=["Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec"];if(q>=2419200000){return function(s){var r=new Date(s);return n[r.getMonth()]+" "+r.getFullYear()}}else{if(q>=86400000){return function(s){var r=new Date(s);return n[r.getMonth()]+" "+r.getDate()}}else{if(q>=3600000){return"%I:%M %p"}else{return"%I:%M:%S %p"}}}}f.register("c3",l,{capabilities:k})}},{"../../core/utils/each":29,"../../core/utils/extend":31,"../dataviz":56}],53:[function(b,c,a){ +var f=b("../dataviz"),d=b("../../core/utils/each"),g=b("../../core/utils/extend");c.exports=function(){var k={singular:["gauge"],categorical:["donut","pie"],"cat-interval":["area-step","step","bar","area","area-spline","spline","line"],"cat-ordinal":["bar","area","area-spline","spline","line","step","area-step"],chronological:["area","area-spline","spline","line","bar","step","area-step"],"cat-chronological":["line","spline","area","area-spline","bar","step","area-step"]};var l={};d(["gauge","donut","pie","bar","area","area-spline","spline","line","step","area-step"],function(o,n){l[o]={render:function(){var p=j.call(this,o);this.view._artifacts.c3=c3.generate(p);this.update()},update:function(){var p=this,q=[];if(o==="gauge"){p.view._artifacts.c3.load({columns:[[p.title(),p.data()[1][1]]]})}else{if(o==="pie"||o==="donut"){p.view._artifacts.c3.load({columns:p.dataset.data.output.slice(1)})}else{if(this.dataType().indexOf("chron")>-1){q.push(p.dataset.selectColumn(0));q[0][0]="x"}d(p.data()[0],function(s,r){if(r>0){q.push(p.dataset.selectColumn(r))}});if(p.stacked()){p.view._artifacts.c3.groups([p.labels()])}p.view._artifacts.c3.load({columns:q})}}},destroy:function(){m.call(this)}}});function j(o){var n=g({axis:{},color:{},data:{},size:{}},this.chartOptions());n.bindto=this.el();n.color.pattern=this.colors();n.data.columns=[];n.size.height=this.height();n.size.width=this.width();n.data["type"]=o;if(o==="gauge"){}else{if(o==="pie"||o==="donut"){n[o]={title:this.title()}}else{if(this.dataType().indexOf("chron")>-1){n.data["x"]="x";n.axis["x"]={type:"timeseries",tick:{format:this.dateFormat()||h(this.data()[1][0],this.data()[2][0])}}}else{if(this.dataType()==="cat-ordinal"){n.axis["x"]={type:"category",categories:this.labels()}}}if(this.title()){n.axis["y"]={label:this.title()}}}}return n}function m(){if(this.view._artifacts.c3){this.view._artifacts.c3.destroy();this.view._artifacts.c3=null}}function h(p,o){var q=Math.abs(new Date(p).getTime()-new Date(o).getTime());var n=["Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec"];if(q>=2419200000){return function(s){var r=new Date(s);return n[r.getMonth()]+" "+r.getFullYear()}}else{if(q>=86400000){return function(s){var r=new Date(s);return n[r.getMonth()]+" "+r.getDate()}}else{if(q>=3600000){return"%I:%M %p"}else{return"%I:%M:%S %p"}}}}f.register("c3",l,{capabilities:k})}},{"../../core/utils/each":29,"../../core/utils/extend":31,"../dataviz":56}],53:[function(b,c,a){ /*! * ---------------------- * Chart.js Adapter diff --git a/src/dataviz/adapters/c3.js b/src/dataviz/adapters/c3.js index a4c737c..190f2a1 100644 --- a/src/dataviz/adapters/c3.js +++ b/src/dataviz/adapters/c3.js @@ -84,20 +84,19 @@ module.exports = function(){ }); function getSetupTemplate(type){ - var setup = { + var setup = extend({ axis: {}, - bindto: this.el(), - data: { - columns: [] - }, - color: { - pattern: this.colors() - }, - size: { - height: this.height(), - width: this.width() - } - }; + color: {}, + data: {}, + size: {} + }, this.chartOptions()); + + // Enforced options + setup.bindto = this.el(); + setup.color.pattern = this.colors(); + setup.data.columns = []; + setup.size.height = this.height(); + setup.size.width = this.width(); // Enforce type, sorry no overrides here setup['data']['type'] = type; @@ -128,7 +127,7 @@ module.exports = function(){ setup['axis']['y'] = { label: this.title() } } } - return extend(setup, this.chartOptions()); + return setup; } function _selfDestruct(){ diff --git a/test/examples/dataviz/c3/index.html b/test/examples/dataviz/c3/index.html index 3dec668..b6512a4 100644 --- a/test/examples/dataviz/c3/index.html +++ b/test/examples/dataviz/c3/index.html @@ -293,6 +293,7 @@

Saved Queries (auto-viz)

.parseRawData({ result: 79.1 }) .title('Percentage of awesome') .chartOptions({ + data: {} // gauge: { // label: { // format: function (value, ratio) { @@ -322,7 +323,7 @@

Saved Queries (auto-viz)

library: 'c3', chartType: 'donut', chartOptions: { - + data: {} } }); @@ -504,6 +505,7 @@

Saved Queries (auto-viz)

.labels(c3FunnelCats) .height(300) .chartOptions({ + data: {}, // Overriding `axis` below wipes out auto-categorization // axis: { // x: { @@ -543,7 +545,8 @@

Saved Queries (auto-viz)

type: 'category', categories: ['Chrome 19', 'Firefox 11', 'IE 9', 'Mobile Safari 5'] } - } + }, + data: {} } }); @@ -632,6 +635,7 @@

Saved Queries (auto-viz)

client.draw('total-clicks-this-12-months', document.getElementById('sq-metric'), { height: 200, chartOptions: { + data: {}, gauge: { min: 0, max: 200 @@ -654,6 +658,7 @@

Saved Queries (auto-viz)

height: 400, chartType: 'bar', chartOptions: { + data: {}, legend: { show: false } } }); @@ -661,6 +666,7 @@

Saved Queries (auto-viz)

client.draw('weekly-clicks-by-campaign-by-user-id', document.getElementById('sq-double-grouped-interval'), { height: 400, chartOptions: { + data: {}, legend: { show: false } } }); From d18ad6357a25fc93122c26733e77c6dea40b3351 Mon Sep 17 00:00:00 2001 From: dustinlarimer Date: Tue, 16 Feb 2016 21:09:48 -0800 Subject: [PATCH 03/10] Update docs to ref #341 for RequireJS usage of Google Charts API --- docs/installation.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/installation.md b/docs/installation.md index e36b2c3..54a3b81 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -81,3 +81,5 @@ require([ "keen" ], function(Keen) { var client = new Keen({ ... }); }); ``` + +This library uses the Google Charts API for data visualization, which imposes a few installation challenges for RequireJS usage. [Read this to learn more](https://github.com/keen/keen-js/issues/341#issuecomment-148039517). From 1b014530f0d9eb7e4886ef2139f28bb3f0d4bd25 Mon Sep 17 00:00:00 2001 From: dustinlarimer Date: Tue, 16 Feb 2016 21:23:45 -0800 Subject: [PATCH 04/10] Include fix from #372 for better metric handling --- dist/keen.js | 2 +- dist/keen.min.js | 2 +- src/dataviz/adapters/keen-io.js | 2 +- test/examples/dataviz/index.html | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/keen.js b/dist/keen.js index 24b4ef5..58a7d5b 100644 --- a/dist/keen.js +++ b/dist/keen.js @@ -4785,7 +4785,7 @@ module.exports = function(){ render: function(){ var bgColor = (this.colors().length == 1) ? this.colors()[0] : "#49c5b1", title = this.title() || "Result", - value = this.data()[1][1] || 0, + value = (this.data()[1] && this.data()[1][1]) ? this.data()[1][1] : 0, width = this.width(), opts = this.chartOptions() || {}, prefix = "", diff --git a/dist/keen.min.js b/dist/keen.min.js index 3626cd4..9e37e32 100644 --- a/dist/keen.min.js +++ b/dist/keen.min.js @@ -28,4 +28,4 @@ var g=c("../dataviz"),f=c("../../core/utils/each"),h=c("../../core/utils/extend" * Keen IO Adapter * ---------------------- */ -var g=d("../../core"),a=d("../dataviz");var j=d("../../core/utils/clone"),k=d("../../core/utils/each"),h=d("../../core/utils/extend"),c=d("../utils/prettyNumber");b.exports=function(){var l,o,n;g.Error={defaults:{backgroundColor:"",borderRadius:"4px",color:"#ccc",display:"block",fontFamily:"Helvetica Neue, Helvetica, Arial, sans-serif",fontSize:"21px",fontWeight:"light",textAlign:"center"}};g.Spinner.defaults={height:138,lines:10,length:8,width:3,radius:10,corners:1,rotate:0,direction:1,color:"#4d4d4d",speed:1.67,trail:60,shadow:false,hwaccel:false,className:"keen-spinner",zIndex:2000000000,top:"50%",left:"50%"};var m={singular:["metric"]};l={initialize:function(){var p=document.createElement("style"),q="#49c5b1";p.id="keen-widgets";p.type="text/css";p.innerHTML=" .keen-metric { \n background: "+q+"; \n border-radius: 4px; \n color: #fff; \n font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; \n padding: 10px 0; \n text-align: center; \n} .keen-metric-value { \n display: block; \n font-size: 84px; \n font-weight: 700; \n line-height: 84px; \n} .keen-metric-title { \n display: block; \n font-size: 24px; \n font-weight: 200; \n}";if(!document.getElementById(p.id)){document.body.appendChild(p)}},render:function(){var u=(this.colors().length==1)?this.colors()[0]:"#49c5b1",t=this.title()||"Result",v=this.data()[1][1]||0,r=this.width(),q=this.chartOptions()||{},s="",w="";var x={width:(r)?r+"px":"auto"};var p=v;if(typeof q.prettyNumber==="undefined"||q.prettyNumber==true){if(!isNaN(parseInt(v))){p=c(v)}}if(q.prefix){s=''+q.prefix+""}if(q.suffix){w=''+q.suffix+""}this.el().innerHTML='
'+s+p+w+''+t+"
"}};o={initialize:function(){},render:function(t,q){var r,s;var u=j(g.Error.defaults);var p=h(u,q);r=document.createElement("div");r.className="keen-error";k(p,function(w,v){r.style[v]=w});r.style.height=String(this.height()+"px");r.style.paddingTop=(this.height()/2-15)+"px";r.style.width=String(this.width()+"px");s=document.createElement("span");s.innerHTML=t||"Yikes! An error occurred!";r.appendChild(s);this.el().innerHTML="";this.el().appendChild(r)},destroy:function(){this.el().innerHTML=""}};n={initialize:function(){},render:function(){var q=document.createElement("div");var p=this.height()||g.Spinner.defaults.height;q.className="keen-loading";q.style.height=String(p+"px");q.style.position="relative";q.style.width=String(this.width()+"px");this.el().innerHTML="";this.el().appendChild(q);this.view._artifacts.spinner=new g.Spinner(g.Spinner.defaults).spin(q)},destroy:function(){this.view._artifacts.spinner.stop();this.view._artifacts.spinner=null}};g.Dataviz.register("keen-io",{metric:l,error:o,spinner:n},{capabilities:m})}},{"../../core":16,"../../core/utils/clone":28,"../../core/utils/each":29,"../../core/utils/extend":31,"../dataviz":56,"../utils/prettyNumber":95}],56:[function(f,d,g){var k=f("../core/utils/clone"),m=f("../core/utils/each"),j=f("../core/utils/extend"),a=f("./utils/loadScript"),n=f("./utils/loadStyle");var h=f("../core");var l=f("../core/utils/emitter-shim");var c=f("../dataset");function b(){this.dataset=new c();this.view={_prepared:false,_initialized:false,_rendered:false,_artifacts:{},adapter:{library:undefined,chartOptions:{},chartType:undefined,defaultChartType:undefined,dataType:undefined},attributes:k(b.defaults),defaults:k(b.defaults),el:undefined,loader:{library:"keen-io",chartType:"spinner"}};b.visuals.push(this)}j(b,{dataTypeMap:{singular:{library:"keen-io",chartType:"metric"},categorical:{library:"google",chartType:"piechart"},"cat-interval":{library:"google",chartType:"columnchart"},"cat-ordinal":{library:"google",chartType:"barchart"},chronological:{library:"google",chartType:"areachart"},"cat-chronological":{library:"google",chartType:"linechart"},extraction:{library:"google",chartType:"table"},nominal:{library:"google",chartType:"table"}},defaults:{colors:["#00bbde","#fe6672","#eeb058","#8a8ad6","#ff855c","#00cfbb","#5a9eed","#73d483","#c879bb","#0099b6","#d74d58","#cb9141","#6b6bb6","#d86945","#00aa99","#4281c9","#57b566","#ac5c9e","#27cceb","#ff818b","#f6bf71","#9b9be1","#ff9b79","#26dfcd","#73aff4","#87e096","#d88bcb"],indexBy:"timeframe.start",stacked:false},dependencies:{loading:0,loaded:0,urls:{}},libraries:{},visuals:[]});l(b);l(b.prototype);b.register=function(r,p,q){var o=this;var s=function(t){t.loaded++;if(t.loaded===t.loading){h.loaded=true;h.trigger("ready")}};b.libraries[r]=b.libraries[r]||{};m(p,function(u,t){b.libraries[r][t]=u});if(q&&q.capabilities){b.libraries[r]._defaults=b.libraries[r]._defaults||{};m(q.capabilities,function(t,u){b.libraries[r]._defaults[u]=t})}if(q&&q.dependencies){m(q.dependencies,function(v,u,w){var t=b.dependencies;if(!t.urls[v.url]){t.urls[v.url]=true;t.loading++;var x=v.type==="script"?a:n;x(v.url,function(){if(v.cb){v.cb.call(o,function(){s(t)})}else{s(t)}})}})}};b.find=function(q){if(!arguments.length){return b.visuals}var p=q.nodeName?q:document.querySelector(q),o;m(b.visuals,function(r){if(p==r.el()){o=r;return false}});if(o){return o}};d.exports=b},{"../core":16,"../core/utils/clone":28,"../core/utils/each":29,"../core/utils/emitter-shim":30,"../core/utils/extend":31,"../dataset":37,"./utils/loadScript":93,"./utils/loadStyle":94}],57:[function(b,d,a){var h=b("../../core/utils/clone"),g=b("../../core/utils/extend"),f=b("../dataviz"),c=b("../../core/request");d.exports=function(p,m,j){var l=h(f.defaults),o=new f(),n=new c(this,[p]),k=j||{};o.attributes(g(l,k)).el(m).prepare();n.refresh();n.on("complete",function(){o.parseRequest(this).call(function(){if(k.labels){this.labels(k.labels)}}).render()});n.on("error",function(q){o.error(q.message)});return o}},{"../../core/request":25,"../../core/utils/clone":28,"../../core/utils/extend":31,"../dataviz":56}],58:[function(b,c,a){var d=b("../dataviz"),f=b("../../core/utils/extend");c.exports=function(){var k=f({},d.dataTypeMap),h=this.dataType(),g=this.library(),j=this.chartType()||this.defaultChartType();if(!g&&k[h]){g=k[h].library}if(g&&!j&&h){j=d.libraries[g]._defaults[h][0]}if(g&&!j&&k[h]){j=k[h].chartType}if(g&&j&&d.libraries[g][j]){return d.libraries[g][j]}else{return{}}}},{"../../core/utils/extend":31,"../dataviz":56}],59:[function(b,c,a){c.exports=function(f){var h=f.queries[0].analysis.replace("_"," "),g=f.queries[0].get("event_collection"),d;d=h.replace(/\b./g,function(j){return j.toUpperCase()});if(g){d+=" - "+g}return d}},{}],60:[function(b,c,a){c.exports=function(g){var h=typeof g.params.interval==="string",f=typeof g.params.group_by==="string",j=g.params.group_by instanceof Array,d;if(!f&&!h){d="singular"}if(f&&!h){d="categorical"}if(h&&!f){d="chronological"}if(h&&f){d="cat-chronological"}if(!h&&j){d="categorical"}if(h&&j){d="cat-chronological"}if(g.analysis==="funnel"){d="cat-ordinal"}if(g.analysis==="extraction"){d="extraction"}if(g.analysis==="select_unique"){d="nominal"}return d}},{}],61:[function(b,c,a){var f=b("../core/utils/extend"),d=b("./dataviz");f(d.prototype,{adapter:b("./lib/adapter"),attributes:b("./lib/attributes"),call:b("./lib/call"),chartOptions:b("./lib/chartOptions"),chartType:b("./lib/chartType"),colorMapping:b("./lib/colorMapping"),colors:b("./lib/colors"),data:b("./lib/data"),dataType:b("./lib/dataType"),dateFormat:b("./lib/dateFormat"),defaultChartType:b("./lib/defaultChartType"),el:b("./lib/el"),height:b("./lib/height"),indexBy:b("./lib/indexBy"),labelMapping:b("./lib/labelMapping"),labels:b("./lib/labels"),library:b("./lib/library"),parseRawData:b("./lib/parseRawData"),parseRequest:b("./lib/parseRequest"),prepare:b("./lib/prepare"),sortGroups:b("./lib/sortGroups"),sortIntervals:b("./lib/sortIntervals"),stacked:b("./lib/stacked"),title:b("./lib/title"),width:b("./lib/width")});f(d.prototype,{destroy:b("./lib/actions/destroy"),error:b("./lib/actions/error"),initialize:b("./lib/actions/initialize"),render:b("./lib/actions/render"),update:b("./lib/actions/update")});c.exports=d},{"../core/utils/extend":31,"./dataviz":56,"./lib/actions/destroy":62,"./lib/actions/error":63,"./lib/actions/initialize":64,"./lib/actions/render":65,"./lib/actions/update":66,"./lib/adapter":67,"./lib/attributes":68,"./lib/call":69,"./lib/chartOptions":70,"./lib/chartType":71,"./lib/colorMapping":72,"./lib/colors":73,"./lib/data":74,"./lib/dataType":75,"./lib/dateFormat":76,"./lib/defaultChartType":77,"./lib/el":78,"./lib/height":79,"./lib/indexBy":80,"./lib/labelMapping":81,"./lib/labels":82,"./lib/library":83,"./lib/parseRawData":84,"./lib/parseRequest":85,"./lib/prepare":86,"./lib/sortGroups":87,"./lib/sortIntervals":88,"./lib/stacked":89,"./lib/title":90,"./lib/width":91}],62:[function(b,c,a){var d=b("../../helpers/getAdapterActions");c.exports=function(){var f=d.call(this);if(f.destroy){f.destroy.apply(this,arguments)}if(this.el()){this.el().innerHTML=""}this.view._prepared=false;this.view._initialized=false;this.view._rendered=false;this.view._artifacts={};return this}},{"../../helpers/getAdapterActions":58}],63:[function(b,c,a){var f=b("../../helpers/getAdapterActions"),d=b("../../dataviz");c.exports=function(){var g=f.call(this);if(this.el()){if(g.error){g.error.apply(this,arguments)}else{d.libraries["keen-io"]["error"].render.apply(this,arguments)}}else{this.emit("error","No DOM element provided")}return this}},{"../../dataviz":56,"../../helpers/getAdapterActions":58}],64:[function(b,c,a){var f=b("../../helpers/getAdapterActions"),d=b("../../dataviz");c.exports=function(){var h=f.call(this);var g=d.libraries[this.view.loader.library][this.view.loader.chartType];if(this.view._prepared){if(g.destroy){g.destroy.apply(this,arguments)}}else{if(this.el()){this.el().innerHTML=""}}if(h.initialize){h.initialize.apply(this,arguments)}else{this.error("Incorrect chartType");this.emit("error","Incorrect chartType")}this.view._initialized=true;return this}},{"../../dataviz":56,"../../helpers/getAdapterActions":58}],65:[function(c,d,b){var f=c("../../helpers/getAdapterActions"),a=c("../../utils/applyTransforms");d.exports=function(){var g=f.call(this);a.call(this);if(!this.view._initialized){this.initialize()}if(this.el()&&g.render){g.render.apply(this,arguments);this.view._rendered=true}return this}},{"../../helpers/getAdapterActions":58,"../../utils/applyTransforms":92}],66:[function(c,d,b){var f=c("../../helpers/getAdapterActions"),a=c("../../utils/applyTransforms");d.exports=function(){var g=f.call(this);a.call(this);if(g.update){g.update.apply(this,arguments)}else{if(g.render){this.render()}}return this}},{"../../helpers/getAdapterActions":58,"../../utils/applyTransforms":92}],67:[function(b,c,a){var d=b("../../core/utils/each");c.exports=function(g){if(!arguments.length){return this.view.adapter}var f=this;d(g,function(j,h){f.view.adapter[h]=(j?j:null)});return this}},{"../../core/utils/each":29}],68:[function(b,c,a){var d=b("../../core/utils/each");var f=b("./chartOptions");chartType=b("./chartType"),library=b("./library");c.exports=function(h){if(!arguments.length){return this.view.attributes}var g=this;d(h,function(k,j){if(j==="library"){library.call(g,k)}else{if(j==="chartType"){chartType.call(g,k)}else{if(j==="chartOptions"){f.call(g,k)}else{g.view.attributes[j]=k}}}});return this}},{"../../core/utils/each":29,"./chartOptions":70,"./chartType":71,"./library":83}],69:[function(b,c,a){c.exports=function(d){d.call(this);return this}},{}],70:[function(b,c,a){var d=b("../../core/utils/extend");c.exports=function(f){if(!arguments.length){return this.view.adapter.chartOptions}if(typeof f==="object"&&f!==null){d(this.view.adapter.chartOptions,f)}else{this.view.adapter.chartOptions={}}return this}},{"../../core/utils/extend":31}],71:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.adapter.chartType}this.view.adapter.chartType=(d?String(d):null);return this}},{}],72:[function(b,c,a){var d=b("../../core/utils/each");c.exports=function(g){if(!arguments.length){return this.view.attributes.colorMapping}this.view.attributes.colorMapping=(g?g:null);f.call(this);return this};function f(){var g=this,l=this.dataset.schema,m=this.dataset.output(),j=this.view.defaults.colors.slice(),h=this.colorMapping(),k=this.dataType()||"";if(h){if(k.indexOf("chronological")>-1||(l.unpack&&m[0].length>2)){d(m[0].slice(1),function(o,p){var n=h[o];if(n&&j[p]!==n){j.splice(p,0,n)}})}else{d(g.dataset.selectColumn(0).slice(1),function(o,p){var n=h[o];if(n&&j[p]!==n){j.splice(p,0,n)}})}g.view.attributes.colors=j}}},{"../../core/utils/each":29}],73:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.attributes.colors}this.view.attributes.colors=(d instanceof Array?d:null);this.view.defaults.colors=(d instanceof Array?d:null);return this}},{}],74:[function(b,d,a){var f=b("../../dataset"),c=b("../../core/request");d.exports=function(g){if(!arguments.length){return this.dataset.output()}if(g instanceof f){this.dataset=g}else{if(g instanceof c){this.parseRequest(g)}else{this.parseRawData(g)}}return this}},{"../../core/request":25,"../../dataset":37}],75:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.adapter.dataType}this.view.adapter.dataType=(d?String(d):null);return this}},{}],76:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.attributes.dateFormat}if(typeof d==="string"||typeof d==="function"){this.view.attributes.dateFormat=d}else{this.view.attributes.dateFormat=undefined}return this}},{}],77:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.adapter.defaultChartType}this.view.adapter.defaultChartType=(d?String(d):null);return this}},{}],78:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.el}this.view.el=d;return this}},{}],79:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.attributes["height"]}this.view.attributes["height"]=(!isNaN(parseInt(d))?parseInt(d):null);return this}},{}],80:[function(b,d,a){var f=b("../../dataset"),h=b("../dataviz"),g=b("../../core/utils/each");d.exports=function(j){if(!arguments.length){return this.view.attributes.indexBy}this.view.attributes.indexBy=(j?String(j):h.defaults.indexBy);c.call(this);return this};function c(){var k,j;if(this.dataset.output().length>1&&!isNaN(new Date(this.dataset.output()[1][0]).getTime())){if(this.dataset.parser&&this.dataset.parser.name&&this.dataset.parser.options){if(this.dataset.parser.options.length===1){k=f.parser(this.dataset.parser.name,this.indexBy());this.dataset.parser.options[0]=this.indexBy()}else{k=f.parser(this.dataset.parser.name,this.dataset.parser.options[0],this.indexBy());this.dataset.parser.options[1]=this.indexBy()}}else{if(this.dataset.output()[0].length===2){k=f.parser("interval",this.indexBy());this.dataset.parser={name:"interval",options:[this.indexBy()]}}else{k=f.parser("grouped-interval",this.indexBy());this.dataset.parser={name:"grouped-interval",options:[this.indexBy()]}}}this.dataset=k(this.dataset.input());this.dataset.updateColumn(0,function(l){return(typeof l==="string")?new Date(l):l})}}},{"../../core/utils/each":29,"../../dataset":37,"../dataviz":56}],81:[function(b,c,a){var f=b("../../core/utils/each");c.exports=function(g){if(!arguments.length){return this.view.attributes.labelMapping}this.view.attributes.labelMapping=(g?g:null);d.call(this);return this};function d(){var g=this,j=this.labelMapping(),h=this.dataType()||"";if(j){if(h.indexOf("chronological")>-1||(g.dataset.output()[0].length>2)){f(g.dataset.output()[0],function(l,k){if(k>0){g.dataset.data.output[0][k]=j[l]||l}})}else{if(g.dataset.output()[0].length===2){g.dataset.updateColumn(0,function(l,k){return j[l]||l})}}}}},{"../../core/utils/each":29}],82:[function(c,d,b){var f=c("../../core/utils/each");d.exports=function(h){if(!arguments.length){if(!this.view.attributes.labels||!this.view.attributes.labels.length){return g.call(this)}else{return this.view.attributes.labels}}else{this.view.attributes.labels=(h instanceof Array?h:null);a.call(this);return this}};function a(){var h=this,l=this.labels()||null,k=this.dataset.output(),j=this.dataType()||"";if(l){if(j.indexOf("chronological")>-1||(k[0].length>2)){f(k[0],function(m,n){if(n>0&&l[n-1]){h.dataset.data.output[0][n]=l[n-1]}})}else{f(k,function(n,m){if(m>0&&l[m-1]){h.dataset.data.output[m][0]=l[m-1]}})}}}function g(){var j=this.dataset.output(),h=this.dataType()||"",k;if(h.indexOf("chron")>-1||(j[0].length>2)){k=this.dataset.selectRow(0).slice(1)}else{k=this.dataset.selectColumn(0).slice(1)}return k}},{"../../core/utils/each":29}],83:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.adapter.library}this.view.adapter.library=(d?String(d):null);return this}},{}],84:[function(b,c,a){var d=b("../../dataset");var f=b("../../core/utils/extend");c.exports=function(j){var h,k=this.indexBy()?this.indexBy():"timestamp.start",m,g=[],l=(typeof j.query!=="undefined")?j.query:{};l=f({analysis_type:null,event_collection:null,filters:[],group_by:null,interval:null,timeframe:null,timezone:null},l);if(l.analysis_type==="funnel"){h="cat-ordinal";m="funnel"}else{if(l.analysis_type==="extraction"){h="extraction";m="extraction"}else{if(l.analysis_type==="select_unique"){if(!l.group_by&&!l.interval){h="nominal";m="list"}}else{if(l.analysis_type){if(!l.group_by&&!l.interval){h="singular";m="metric"}else{if(l.group_by&&!l.interval){if(l.group_by instanceof Array&&l.group_by.length>1){h="categorical";m="double-grouped-metric";g.push(l.group_by)}else{h="categorical";m="grouped-metric"}}else{if(l.interval&&!l.group_by){h="chronological";m="interval";g.push(k)}else{if(l.group_by&&l.interval){if(l.group_by instanceof Array&&l.group_by.length>1){h="cat-chronological";m="double-grouped-interval";g.push(l.group_by);g.push(k)}else{h="cat-chronological";m="grouped-interval";g.push(k)}}}}}}}}}if(!m){if(typeof j.result==="number"){h="singular";m="metric"}if(j.result instanceof Array&&j.result.length>0){if(j.result[0].timeframe&&(typeof j.result[0].value=="number"||j.result[0].value==null)){h="chronological";m="interval";g.push(k)}if(typeof j.result[0].result=="number"){h="categorical";m="grouped-metric"}if(j.result[0].value instanceof Array){h="cat-chronological";m="grouped-interval";g.push(k)}if(typeof j.result[0]=="number"&&typeof j.steps!=="undefined"){h="cat-ordinal";m="funnel"}if((typeof j.result[0]=="string"||typeof j.result[0]=="number")&&typeof j.steps==="undefined"){h="nominal";m="list"}if(h===void 0){h="extraction";m="extraction"}}}if(h){this.dataType(h)}this.dataset=d.parser.apply(this,[m].concat(g))(j);if(m.indexOf("interval")>-1){this.dataset.updateColumn(0,function(o,n){return new Date(o)})}return this}},{"../../core/utils/extend":31,"../../dataset":37}],85:[function(b,a,d){var f=b("../../core/query");var k=b("./dataType"),g=b("../../core/utils/extend"),c=b("../helpers/getDefaultTitle"),h=b("../helpers/getQueryDataType"),l=b("./parseRawData"),j=b("./title");a.exports=function(n){var m=n.data instanceof Array?n.data[0]:n.data;if(n.queries[0] instanceof f){m.query=g({analysis_type:n.queries[0].analysis},n.queries[0].params);k.call(this,h(n.queries[0]));this.view.defaults.title=c.call(this,n);if(!j.call(this)){j.call(this,this.view.defaults.title)}}l.call(this,m);return this}},{"../../core/query":24,"../../core/utils/extend":31,"../helpers/getDefaultTitle":59,"../helpers/getQueryDataType":60,"./dataType":75,"./parseRawData":84,"./title":90}],86:[function(b,c,a){var d=b("../dataviz");c.exports=function(){var f;if(this.view._rendered){this.destroy()}if(this.el()){this.el().innerHTML="";f=d.libraries[this.view.loader.library][this.view.loader.chartType];if(f.initialize){f.initialize.apply(this,arguments)}if(f.render){f.render.apply(this,arguments)}this.view._prepared=true}return this}},{"../dataviz":56}],87:[function(b,c,a){c.exports=function(f){if(!arguments.length){return this.view.attributes.sortGroups}this.view.attributes.sortGroups=(f?String(f):null);d.call(this);return this};function d(){var f=this.dataType();if(!this.sortGroups()){return}if((f&&f.indexOf("chronological")>-1)||this.data()[0].length>2){this.dataset.sortColumns(this.sortGroups(),this.dataset.getColumnSum)}else{if(f&&(f.indexOf("cat-")>-1||f.indexOf("categorical")>-1)){this.dataset.sortRows(this.sortGroups(),this.dataset.getRowSum)}}return}},{}],88:[function(b,c,a){c.exports=function(f){if(!arguments.length){return this.view.attributes.sortIntervals}this.view.attributes.sortIntervals=(f?String(f):null);d.call(this);return this};function d(){if(!this.sortIntervals()){return}this.dataset.sortRows(this.sortIntervals());return}},{}],89:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.attributes["stacked"]}this.view.attributes["stacked"]=d?true:false;return this}},{}],90:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.attributes["title"]}this.view.attributes["title"]=(d?String(d):null);return this}},{}],91:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.attributes["width"]}this.view.attributes["width"]=(!isNaN(parseInt(d))?parseInt(d):null);return this}},{}],92:[function(b,c,a){c.exports=function(){if(this.labelMapping()){this.labelMapping(this.labelMapping())}if(this.colorMapping()){this.colorMapping(this.colorMapping())}if(this.sortGroups()){this.sortGroups(this.sortGroups())}if(this.sortIntervals()){this.sortIntervals(this.sortIntervals())}}},{}],93:[function(b,c,a){c.exports=function(f,d){var j=document;var h;var g=j.head||j.getElementsByTagName("head");setTimeout(function(){if("item" in g){if(!g[0]){setTimeout(arguments.callee,25);return}g=g[0]}var k=j.createElement("script"),l=false;k.onload=k.onreadystatechange=function(){if((k.readyState&&k.readyState!=="complete"&&k.readyState!=="loaded")||l){return false}k.onload=k.onreadystatechange=null;l=true;d()};k.src=f;g.insertBefore(k,g.firstChild)},0);if(j.readyState===null&&j.addEventListener){j.readyState="loading";j.addEventListener("DOMContentLoaded",h=function(){j.removeEventListener("DOMContentLoaded",h,false);j.readyState="complete"},false)}}},{}],94:[function(b,c,a){c.exports=function(f,d){var g=document.createElement("link");g.setAttribute("rel","stylesheet");g.type="text/css";g.href=f;d();document.head.appendChild(g)}},{}],95:[function(b,c,a){c.exports=function(k){var d=Number(k),h=d.toPrecision(3),j="",f=["","k","M","B","T"];if(Number(h)==d&&String(d).length<=4){return String(d)}if(d>=1||d<=-1){if(d<0){d=-d;j="-"}return j+g(d,0)}else{return d.toPrecision(3)}function g(l,n){var l=String(l);var m=l.split(".");if(m.length>1){l=m[0];var p=m[1];if(l.length==2&&p.length>0){if(p.length>0){l=l+"."+p.charAt(0)}else{l+="0"}}else{if(l.length==1&&p.length>0){l=l+"."+p.charAt(0);if(p.length>1){l+=p.charAt(1)}else{l+="0"}}}}var o=l.length;if(l.split(".").length>1){o--}if(o<=3){return String(l)+f[n]}else{return g(Number(l)/1000,n+1)}}}},{}],96:[function(b,c,a){(function(d){(function(j){if(typeof define==="function"&&define.amd){define("keen",[],function(){return j()})}if(typeof a==="object"&&typeof c!=="undefined"){c.exports=j()}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=j()}})(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"),get:b("./core/lib/get"),post:b("./core/lib/post"),put:b("./core/lib/post"),run:b("./core/lib/run"),savedQueries:b("./core/saved-queries"),draw:b("./dataviz/extensions/draw")});f.Query=b("./core/query");f.Request=b("./core/request");f.Dataset=b("./dataset");f.Dataviz=b("./dataviz");f.Base64=b("./core/utils/base64");f.Spinner=b("spin.js");f.utils={domready:b("domready"),each:b("./core/utils/each"),extend:g,parseParams:b("./core/utils/parseParams"),prettyNumber:b("./dataviz/utils/prettyNumber")};b("./dataviz/adapters/keen-io")();b("./dataviz/adapters/google")();b("./dataviz/adapters/c3")();b("./dataviz/adapters/chartjs")();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":16,"./core/async":8,"./core/lib/addEvent":17,"./core/lib/addEvents":18,"./core/lib/get":19,"./core/lib/post":20,"./core/lib/run":21,"./core/lib/setGlobalProperties":22,"./core/lib/trackExternalLink":23,"./core/query":24,"./core/request":25,"./core/saved-queries":26,"./core/utils/base64":27,"./core/utils/each":29,"./core/utils/extend":31,"./core/utils/parseParams":33,"./dataset":37,"./dataviz":61,"./dataviz/adapters/c3":52,"./dataviz/adapters/chartjs":53,"./dataviz/adapters/google":54,"./dataviz/adapters/keen-io":55,"./dataviz/extensions/draw":57,"./dataviz/utils/prettyNumber":95,domready:2,"spin.js":4}]},{},[96]); \ No newline at end of file +var g=d("../../core"),a=d("../dataviz");var j=d("../../core/utils/clone"),k=d("../../core/utils/each"),h=d("../../core/utils/extend"),c=d("../utils/prettyNumber");b.exports=function(){var l,o,n;g.Error={defaults:{backgroundColor:"",borderRadius:"4px",color:"#ccc",display:"block",fontFamily:"Helvetica Neue, Helvetica, Arial, sans-serif",fontSize:"21px",fontWeight:"light",textAlign:"center"}};g.Spinner.defaults={height:138,lines:10,length:8,width:3,radius:10,corners:1,rotate:0,direction:1,color:"#4d4d4d",speed:1.67,trail:60,shadow:false,hwaccel:false,className:"keen-spinner",zIndex:2000000000,top:"50%",left:"50%"};var m={singular:["metric"]};l={initialize:function(){var p=document.createElement("style"),q="#49c5b1";p.id="keen-widgets";p.type="text/css";p.innerHTML=" .keen-metric { \n background: "+q+"; \n border-radius: 4px; \n color: #fff; \n font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; \n padding: 10px 0; \n text-align: center; \n} .keen-metric-value { \n display: block; \n font-size: 84px; \n font-weight: 700; \n line-height: 84px; \n} .keen-metric-title { \n display: block; \n font-size: 24px; \n font-weight: 200; \n}";if(!document.getElementById(p.id)){document.body.appendChild(p)}},render:function(){var u=(this.colors().length==1)?this.colors()[0]:"#49c5b1",t=this.title()||"Result",v=(this.data()[1]&&this.data()[1][1])?this.data()[1][1]:0,r=this.width(),q=this.chartOptions()||{},s="",w="";var x={width:(r)?r+"px":"auto"};var p=v;if(typeof q.prettyNumber==="undefined"||q.prettyNumber==true){if(!isNaN(parseInt(v))){p=c(v)}}if(q.prefix){s=''+q.prefix+""}if(q.suffix){w=''+q.suffix+""}this.el().innerHTML='
'+s+p+w+''+t+"
"}};o={initialize:function(){},render:function(t,q){var r,s;var u=j(g.Error.defaults);var p=h(u,q);r=document.createElement("div");r.className="keen-error";k(p,function(w,v){r.style[v]=w});r.style.height=String(this.height()+"px");r.style.paddingTop=(this.height()/2-15)+"px";r.style.width=String(this.width()+"px");s=document.createElement("span");s.innerHTML=t||"Yikes! An error occurred!";r.appendChild(s);this.el().innerHTML="";this.el().appendChild(r)},destroy:function(){this.el().innerHTML=""}};n={initialize:function(){},render:function(){var q=document.createElement("div");var p=this.height()||g.Spinner.defaults.height;q.className="keen-loading";q.style.height=String(p+"px");q.style.position="relative";q.style.width=String(this.width()+"px");this.el().innerHTML="";this.el().appendChild(q);this.view._artifacts.spinner=new g.Spinner(g.Spinner.defaults).spin(q)},destroy:function(){this.view._artifacts.spinner.stop();this.view._artifacts.spinner=null}};g.Dataviz.register("keen-io",{metric:l,error:o,spinner:n},{capabilities:m})}},{"../../core":16,"../../core/utils/clone":28,"../../core/utils/each":29,"../../core/utils/extend":31,"../dataviz":56,"../utils/prettyNumber":95}],56:[function(f,d,g){var k=f("../core/utils/clone"),m=f("../core/utils/each"),j=f("../core/utils/extend"),a=f("./utils/loadScript"),n=f("./utils/loadStyle");var h=f("../core");var l=f("../core/utils/emitter-shim");var c=f("../dataset");function b(){this.dataset=new c();this.view={_prepared:false,_initialized:false,_rendered:false,_artifacts:{},adapter:{library:undefined,chartOptions:{},chartType:undefined,defaultChartType:undefined,dataType:undefined},attributes:k(b.defaults),defaults:k(b.defaults),el:undefined,loader:{library:"keen-io",chartType:"spinner"}};b.visuals.push(this)}j(b,{dataTypeMap:{singular:{library:"keen-io",chartType:"metric"},categorical:{library:"google",chartType:"piechart"},"cat-interval":{library:"google",chartType:"columnchart"},"cat-ordinal":{library:"google",chartType:"barchart"},chronological:{library:"google",chartType:"areachart"},"cat-chronological":{library:"google",chartType:"linechart"},extraction:{library:"google",chartType:"table"},nominal:{library:"google",chartType:"table"}},defaults:{colors:["#00bbde","#fe6672","#eeb058","#8a8ad6","#ff855c","#00cfbb","#5a9eed","#73d483","#c879bb","#0099b6","#d74d58","#cb9141","#6b6bb6","#d86945","#00aa99","#4281c9","#57b566","#ac5c9e","#27cceb","#ff818b","#f6bf71","#9b9be1","#ff9b79","#26dfcd","#73aff4","#87e096","#d88bcb"],indexBy:"timeframe.start",stacked:false},dependencies:{loading:0,loaded:0,urls:{}},libraries:{},visuals:[]});l(b);l(b.prototype);b.register=function(r,p,q){var o=this;var s=function(t){t.loaded++;if(t.loaded===t.loading){h.loaded=true;h.trigger("ready")}};b.libraries[r]=b.libraries[r]||{};m(p,function(u,t){b.libraries[r][t]=u});if(q&&q.capabilities){b.libraries[r]._defaults=b.libraries[r]._defaults||{};m(q.capabilities,function(t,u){b.libraries[r]._defaults[u]=t})}if(q&&q.dependencies){m(q.dependencies,function(v,u,w){var t=b.dependencies;if(!t.urls[v.url]){t.urls[v.url]=true;t.loading++;var x=v.type==="script"?a:n;x(v.url,function(){if(v.cb){v.cb.call(o,function(){s(t)})}else{s(t)}})}})}};b.find=function(q){if(!arguments.length){return b.visuals}var p=q.nodeName?q:document.querySelector(q),o;m(b.visuals,function(r){if(p==r.el()){o=r;return false}});if(o){return o}};d.exports=b},{"../core":16,"../core/utils/clone":28,"../core/utils/each":29,"../core/utils/emitter-shim":30,"../core/utils/extend":31,"../dataset":37,"./utils/loadScript":93,"./utils/loadStyle":94}],57:[function(b,d,a){var h=b("../../core/utils/clone"),g=b("../../core/utils/extend"),f=b("../dataviz"),c=b("../../core/request");d.exports=function(p,m,j){var l=h(f.defaults),o=new f(),n=new c(this,[p]),k=j||{};o.attributes(g(l,k)).el(m).prepare();n.refresh();n.on("complete",function(){o.parseRequest(this).call(function(){if(k.labels){this.labels(k.labels)}}).render()});n.on("error",function(q){o.error(q.message)});return o}},{"../../core/request":25,"../../core/utils/clone":28,"../../core/utils/extend":31,"../dataviz":56}],58:[function(b,c,a){var d=b("../dataviz"),f=b("../../core/utils/extend");c.exports=function(){var k=f({},d.dataTypeMap),h=this.dataType(),g=this.library(),j=this.chartType()||this.defaultChartType();if(!g&&k[h]){g=k[h].library}if(g&&!j&&h){j=d.libraries[g]._defaults[h][0]}if(g&&!j&&k[h]){j=k[h].chartType}if(g&&j&&d.libraries[g][j]){return d.libraries[g][j]}else{return{}}}},{"../../core/utils/extend":31,"../dataviz":56}],59:[function(b,c,a){c.exports=function(f){var h=f.queries[0].analysis.replace("_"," "),g=f.queries[0].get("event_collection"),d;d=h.replace(/\b./g,function(j){return j.toUpperCase()});if(g){d+=" - "+g}return d}},{}],60:[function(b,c,a){c.exports=function(g){var h=typeof g.params.interval==="string",f=typeof g.params.group_by==="string",j=g.params.group_by instanceof Array,d;if(!f&&!h){d="singular"}if(f&&!h){d="categorical"}if(h&&!f){d="chronological"}if(h&&f){d="cat-chronological"}if(!h&&j){d="categorical"}if(h&&j){d="cat-chronological"}if(g.analysis==="funnel"){d="cat-ordinal"}if(g.analysis==="extraction"){d="extraction"}if(g.analysis==="select_unique"){d="nominal"}return d}},{}],61:[function(b,c,a){var f=b("../core/utils/extend"),d=b("./dataviz");f(d.prototype,{adapter:b("./lib/adapter"),attributes:b("./lib/attributes"),call:b("./lib/call"),chartOptions:b("./lib/chartOptions"),chartType:b("./lib/chartType"),colorMapping:b("./lib/colorMapping"),colors:b("./lib/colors"),data:b("./lib/data"),dataType:b("./lib/dataType"),dateFormat:b("./lib/dateFormat"),defaultChartType:b("./lib/defaultChartType"),el:b("./lib/el"),height:b("./lib/height"),indexBy:b("./lib/indexBy"),labelMapping:b("./lib/labelMapping"),labels:b("./lib/labels"),library:b("./lib/library"),parseRawData:b("./lib/parseRawData"),parseRequest:b("./lib/parseRequest"),prepare:b("./lib/prepare"),sortGroups:b("./lib/sortGroups"),sortIntervals:b("./lib/sortIntervals"),stacked:b("./lib/stacked"),title:b("./lib/title"),width:b("./lib/width")});f(d.prototype,{destroy:b("./lib/actions/destroy"),error:b("./lib/actions/error"),initialize:b("./lib/actions/initialize"),render:b("./lib/actions/render"),update:b("./lib/actions/update")});c.exports=d},{"../core/utils/extend":31,"./dataviz":56,"./lib/actions/destroy":62,"./lib/actions/error":63,"./lib/actions/initialize":64,"./lib/actions/render":65,"./lib/actions/update":66,"./lib/adapter":67,"./lib/attributes":68,"./lib/call":69,"./lib/chartOptions":70,"./lib/chartType":71,"./lib/colorMapping":72,"./lib/colors":73,"./lib/data":74,"./lib/dataType":75,"./lib/dateFormat":76,"./lib/defaultChartType":77,"./lib/el":78,"./lib/height":79,"./lib/indexBy":80,"./lib/labelMapping":81,"./lib/labels":82,"./lib/library":83,"./lib/parseRawData":84,"./lib/parseRequest":85,"./lib/prepare":86,"./lib/sortGroups":87,"./lib/sortIntervals":88,"./lib/stacked":89,"./lib/title":90,"./lib/width":91}],62:[function(b,c,a){var d=b("../../helpers/getAdapterActions");c.exports=function(){var f=d.call(this);if(f.destroy){f.destroy.apply(this,arguments)}if(this.el()){this.el().innerHTML=""}this.view._prepared=false;this.view._initialized=false;this.view._rendered=false;this.view._artifacts={};return this}},{"../../helpers/getAdapterActions":58}],63:[function(b,c,a){var f=b("../../helpers/getAdapterActions"),d=b("../../dataviz");c.exports=function(){var g=f.call(this);if(this.el()){if(g.error){g.error.apply(this,arguments)}else{d.libraries["keen-io"]["error"].render.apply(this,arguments)}}else{this.emit("error","No DOM element provided")}return this}},{"../../dataviz":56,"../../helpers/getAdapterActions":58}],64:[function(b,c,a){var f=b("../../helpers/getAdapterActions"),d=b("../../dataviz");c.exports=function(){var h=f.call(this);var g=d.libraries[this.view.loader.library][this.view.loader.chartType];if(this.view._prepared){if(g.destroy){g.destroy.apply(this,arguments)}}else{if(this.el()){this.el().innerHTML=""}}if(h.initialize){h.initialize.apply(this,arguments)}else{this.error("Incorrect chartType");this.emit("error","Incorrect chartType")}this.view._initialized=true;return this}},{"../../dataviz":56,"../../helpers/getAdapterActions":58}],65:[function(c,d,b){var f=c("../../helpers/getAdapterActions"),a=c("../../utils/applyTransforms");d.exports=function(){var g=f.call(this);a.call(this);if(!this.view._initialized){this.initialize()}if(this.el()&&g.render){g.render.apply(this,arguments);this.view._rendered=true}return this}},{"../../helpers/getAdapterActions":58,"../../utils/applyTransforms":92}],66:[function(c,d,b){var f=c("../../helpers/getAdapterActions"),a=c("../../utils/applyTransforms");d.exports=function(){var g=f.call(this);a.call(this);if(g.update){g.update.apply(this,arguments)}else{if(g.render){this.render()}}return this}},{"../../helpers/getAdapterActions":58,"../../utils/applyTransforms":92}],67:[function(b,c,a){var d=b("../../core/utils/each");c.exports=function(g){if(!arguments.length){return this.view.adapter}var f=this;d(g,function(j,h){f.view.adapter[h]=(j?j:null)});return this}},{"../../core/utils/each":29}],68:[function(b,c,a){var d=b("../../core/utils/each");var f=b("./chartOptions");chartType=b("./chartType"),library=b("./library");c.exports=function(h){if(!arguments.length){return this.view.attributes}var g=this;d(h,function(k,j){if(j==="library"){library.call(g,k)}else{if(j==="chartType"){chartType.call(g,k)}else{if(j==="chartOptions"){f.call(g,k)}else{g.view.attributes[j]=k}}}});return this}},{"../../core/utils/each":29,"./chartOptions":70,"./chartType":71,"./library":83}],69:[function(b,c,a){c.exports=function(d){d.call(this);return this}},{}],70:[function(b,c,a){var d=b("../../core/utils/extend");c.exports=function(f){if(!arguments.length){return this.view.adapter.chartOptions}if(typeof f==="object"&&f!==null){d(this.view.adapter.chartOptions,f)}else{this.view.adapter.chartOptions={}}return this}},{"../../core/utils/extend":31}],71:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.adapter.chartType}this.view.adapter.chartType=(d?String(d):null);return this}},{}],72:[function(b,c,a){var d=b("../../core/utils/each");c.exports=function(g){if(!arguments.length){return this.view.attributes.colorMapping}this.view.attributes.colorMapping=(g?g:null);f.call(this);return this};function f(){var g=this,l=this.dataset.schema,m=this.dataset.output(),j=this.view.defaults.colors.slice(),h=this.colorMapping(),k=this.dataType()||"";if(h){if(k.indexOf("chronological")>-1||(l.unpack&&m[0].length>2)){d(m[0].slice(1),function(o,p){var n=h[o];if(n&&j[p]!==n){j.splice(p,0,n)}})}else{d(g.dataset.selectColumn(0).slice(1),function(o,p){var n=h[o];if(n&&j[p]!==n){j.splice(p,0,n)}})}g.view.attributes.colors=j}}},{"../../core/utils/each":29}],73:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.attributes.colors}this.view.attributes.colors=(d instanceof Array?d:null);this.view.defaults.colors=(d instanceof Array?d:null);return this}},{}],74:[function(b,d,a){var f=b("../../dataset"),c=b("../../core/request");d.exports=function(g){if(!arguments.length){return this.dataset.output()}if(g instanceof f){this.dataset=g}else{if(g instanceof c){this.parseRequest(g)}else{this.parseRawData(g)}}return this}},{"../../core/request":25,"../../dataset":37}],75:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.adapter.dataType}this.view.adapter.dataType=(d?String(d):null);return this}},{}],76:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.attributes.dateFormat}if(typeof d==="string"||typeof d==="function"){this.view.attributes.dateFormat=d}else{this.view.attributes.dateFormat=undefined}return this}},{}],77:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.adapter.defaultChartType}this.view.adapter.defaultChartType=(d?String(d):null);return this}},{}],78:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.el}this.view.el=d;return this}},{}],79:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.attributes["height"]}this.view.attributes["height"]=(!isNaN(parseInt(d))?parseInt(d):null);return this}},{}],80:[function(b,d,a){var f=b("../../dataset"),h=b("../dataviz"),g=b("../../core/utils/each");d.exports=function(j){if(!arguments.length){return this.view.attributes.indexBy}this.view.attributes.indexBy=(j?String(j):h.defaults.indexBy);c.call(this);return this};function c(){var k,j;if(this.dataset.output().length>1&&!isNaN(new Date(this.dataset.output()[1][0]).getTime())){if(this.dataset.parser&&this.dataset.parser.name&&this.dataset.parser.options){if(this.dataset.parser.options.length===1){k=f.parser(this.dataset.parser.name,this.indexBy());this.dataset.parser.options[0]=this.indexBy()}else{k=f.parser(this.dataset.parser.name,this.dataset.parser.options[0],this.indexBy());this.dataset.parser.options[1]=this.indexBy()}}else{if(this.dataset.output()[0].length===2){k=f.parser("interval",this.indexBy());this.dataset.parser={name:"interval",options:[this.indexBy()]}}else{k=f.parser("grouped-interval",this.indexBy());this.dataset.parser={name:"grouped-interval",options:[this.indexBy()]}}}this.dataset=k(this.dataset.input());this.dataset.updateColumn(0,function(l){return(typeof l==="string")?new Date(l):l})}}},{"../../core/utils/each":29,"../../dataset":37,"../dataviz":56}],81:[function(b,c,a){var f=b("../../core/utils/each");c.exports=function(g){if(!arguments.length){return this.view.attributes.labelMapping}this.view.attributes.labelMapping=(g?g:null);d.call(this);return this};function d(){var g=this,j=this.labelMapping(),h=this.dataType()||"";if(j){if(h.indexOf("chronological")>-1||(g.dataset.output()[0].length>2)){f(g.dataset.output()[0],function(l,k){if(k>0){g.dataset.data.output[0][k]=j[l]||l}})}else{if(g.dataset.output()[0].length===2){g.dataset.updateColumn(0,function(l,k){return j[l]||l})}}}}},{"../../core/utils/each":29}],82:[function(c,d,b){var f=c("../../core/utils/each");d.exports=function(h){if(!arguments.length){if(!this.view.attributes.labels||!this.view.attributes.labels.length){return g.call(this)}else{return this.view.attributes.labels}}else{this.view.attributes.labels=(h instanceof Array?h:null);a.call(this);return this}};function a(){var h=this,l=this.labels()||null,k=this.dataset.output(),j=this.dataType()||"";if(l){if(j.indexOf("chronological")>-1||(k[0].length>2)){f(k[0],function(m,n){if(n>0&&l[n-1]){h.dataset.data.output[0][n]=l[n-1]}})}else{f(k,function(n,m){if(m>0&&l[m-1]){h.dataset.data.output[m][0]=l[m-1]}})}}}function g(){var j=this.dataset.output(),h=this.dataType()||"",k;if(h.indexOf("chron")>-1||(j[0].length>2)){k=this.dataset.selectRow(0).slice(1)}else{k=this.dataset.selectColumn(0).slice(1)}return k}},{"../../core/utils/each":29}],83:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.adapter.library}this.view.adapter.library=(d?String(d):null);return this}},{}],84:[function(b,c,a){var d=b("../../dataset");var f=b("../../core/utils/extend");c.exports=function(j){var h,k=this.indexBy()?this.indexBy():"timestamp.start",m,g=[],l=(typeof j.query!=="undefined")?j.query:{};l=f({analysis_type:null,event_collection:null,filters:[],group_by:null,interval:null,timeframe:null,timezone:null},l);if(l.analysis_type==="funnel"){h="cat-ordinal";m="funnel"}else{if(l.analysis_type==="extraction"){h="extraction";m="extraction"}else{if(l.analysis_type==="select_unique"){if(!l.group_by&&!l.interval){h="nominal";m="list"}}else{if(l.analysis_type){if(!l.group_by&&!l.interval){h="singular";m="metric"}else{if(l.group_by&&!l.interval){if(l.group_by instanceof Array&&l.group_by.length>1){h="categorical";m="double-grouped-metric";g.push(l.group_by)}else{h="categorical";m="grouped-metric"}}else{if(l.interval&&!l.group_by){h="chronological";m="interval";g.push(k)}else{if(l.group_by&&l.interval){if(l.group_by instanceof Array&&l.group_by.length>1){h="cat-chronological";m="double-grouped-interval";g.push(l.group_by);g.push(k)}else{h="cat-chronological";m="grouped-interval";g.push(k)}}}}}}}}}if(!m){if(typeof j.result==="number"){h="singular";m="metric"}if(j.result instanceof Array&&j.result.length>0){if(j.result[0].timeframe&&(typeof j.result[0].value=="number"||j.result[0].value==null)){h="chronological";m="interval";g.push(k)}if(typeof j.result[0].result=="number"){h="categorical";m="grouped-metric"}if(j.result[0].value instanceof Array){h="cat-chronological";m="grouped-interval";g.push(k)}if(typeof j.result[0]=="number"&&typeof j.steps!=="undefined"){h="cat-ordinal";m="funnel"}if((typeof j.result[0]=="string"||typeof j.result[0]=="number")&&typeof j.steps==="undefined"){h="nominal";m="list"}if(h===void 0){h="extraction";m="extraction"}}}if(h){this.dataType(h)}this.dataset=d.parser.apply(this,[m].concat(g))(j);if(m.indexOf("interval")>-1){this.dataset.updateColumn(0,function(o,n){return new Date(o)})}return this}},{"../../core/utils/extend":31,"../../dataset":37}],85:[function(b,a,d){var f=b("../../core/query");var k=b("./dataType"),g=b("../../core/utils/extend"),c=b("../helpers/getDefaultTitle"),h=b("../helpers/getQueryDataType"),l=b("./parseRawData"),j=b("./title");a.exports=function(n){var m=n.data instanceof Array?n.data[0]:n.data;if(n.queries[0] instanceof f){m.query=g({analysis_type:n.queries[0].analysis},n.queries[0].params);k.call(this,h(n.queries[0]));this.view.defaults.title=c.call(this,n);if(!j.call(this)){j.call(this,this.view.defaults.title)}}l.call(this,m);return this}},{"../../core/query":24,"../../core/utils/extend":31,"../helpers/getDefaultTitle":59,"../helpers/getQueryDataType":60,"./dataType":75,"./parseRawData":84,"./title":90}],86:[function(b,c,a){var d=b("../dataviz");c.exports=function(){var f;if(this.view._rendered){this.destroy()}if(this.el()){this.el().innerHTML="";f=d.libraries[this.view.loader.library][this.view.loader.chartType];if(f.initialize){f.initialize.apply(this,arguments)}if(f.render){f.render.apply(this,arguments)}this.view._prepared=true}return this}},{"../dataviz":56}],87:[function(b,c,a){c.exports=function(f){if(!arguments.length){return this.view.attributes.sortGroups}this.view.attributes.sortGroups=(f?String(f):null);d.call(this);return this};function d(){var f=this.dataType();if(!this.sortGroups()){return}if((f&&f.indexOf("chronological")>-1)||this.data()[0].length>2){this.dataset.sortColumns(this.sortGroups(),this.dataset.getColumnSum)}else{if(f&&(f.indexOf("cat-")>-1||f.indexOf("categorical")>-1)){this.dataset.sortRows(this.sortGroups(),this.dataset.getRowSum)}}return}},{}],88:[function(b,c,a){c.exports=function(f){if(!arguments.length){return this.view.attributes.sortIntervals}this.view.attributes.sortIntervals=(f?String(f):null);d.call(this);return this};function d(){if(!this.sortIntervals()){return}this.dataset.sortRows(this.sortIntervals());return}},{}],89:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.attributes["stacked"]}this.view.attributes["stacked"]=d?true:false;return this}},{}],90:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.attributes["title"]}this.view.attributes["title"]=(d?String(d):null);return this}},{}],91:[function(b,c,a){c.exports=function(d){if(!arguments.length){return this.view.attributes["width"]}this.view.attributes["width"]=(!isNaN(parseInt(d))?parseInt(d):null);return this}},{}],92:[function(b,c,a){c.exports=function(){if(this.labelMapping()){this.labelMapping(this.labelMapping())}if(this.colorMapping()){this.colorMapping(this.colorMapping())}if(this.sortGroups()){this.sortGroups(this.sortGroups())}if(this.sortIntervals()){this.sortIntervals(this.sortIntervals())}}},{}],93:[function(b,c,a){c.exports=function(f,d){var j=document;var h;var g=j.head||j.getElementsByTagName("head");setTimeout(function(){if("item" in g){if(!g[0]){setTimeout(arguments.callee,25);return}g=g[0]}var k=j.createElement("script"),l=false;k.onload=k.onreadystatechange=function(){if((k.readyState&&k.readyState!=="complete"&&k.readyState!=="loaded")||l){return false}k.onload=k.onreadystatechange=null;l=true;d()};k.src=f;g.insertBefore(k,g.firstChild)},0);if(j.readyState===null&&j.addEventListener){j.readyState="loading";j.addEventListener("DOMContentLoaded",h=function(){j.removeEventListener("DOMContentLoaded",h,false);j.readyState="complete"},false)}}},{}],94:[function(b,c,a){c.exports=function(f,d){var g=document.createElement("link");g.setAttribute("rel","stylesheet");g.type="text/css";g.href=f;d();document.head.appendChild(g)}},{}],95:[function(b,c,a){c.exports=function(k){var d=Number(k),h=d.toPrecision(3),j="",f=["","k","M","B","T"];if(Number(h)==d&&String(d).length<=4){return String(d)}if(d>=1||d<=-1){if(d<0){d=-d;j="-"}return j+g(d,0)}else{return d.toPrecision(3)}function g(l,n){var l=String(l);var m=l.split(".");if(m.length>1){l=m[0];var p=m[1];if(l.length==2&&p.length>0){if(p.length>0){l=l+"."+p.charAt(0)}else{l+="0"}}else{if(l.length==1&&p.length>0){l=l+"."+p.charAt(0);if(p.length>1){l+=p.charAt(1)}else{l+="0"}}}}var o=l.length;if(l.split(".").length>1){o--}if(o<=3){return String(l)+f[n]}else{return g(Number(l)/1000,n+1)}}}},{}],96:[function(b,c,a){(function(d){(function(j){if(typeof define==="function"&&define.amd){define("keen",[],function(){return j()})}if(typeof a==="object"&&typeof c!=="undefined"){c.exports=j()}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=j()}})(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"),get:b("./core/lib/get"),post:b("./core/lib/post"),put:b("./core/lib/post"),run:b("./core/lib/run"),savedQueries:b("./core/saved-queries"),draw:b("./dataviz/extensions/draw")});f.Query=b("./core/query");f.Request=b("./core/request");f.Dataset=b("./dataset");f.Dataviz=b("./dataviz");f.Base64=b("./core/utils/base64");f.Spinner=b("spin.js");f.utils={domready:b("domready"),each:b("./core/utils/each"),extend:g,parseParams:b("./core/utils/parseParams"),prettyNumber:b("./dataviz/utils/prettyNumber")};b("./dataviz/adapters/keen-io")();b("./dataviz/adapters/google")();b("./dataviz/adapters/c3")();b("./dataviz/adapters/chartjs")();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":16,"./core/async":8,"./core/lib/addEvent":17,"./core/lib/addEvents":18,"./core/lib/get":19,"./core/lib/post":20,"./core/lib/run":21,"./core/lib/setGlobalProperties":22,"./core/lib/trackExternalLink":23,"./core/query":24,"./core/request":25,"./core/saved-queries":26,"./core/utils/base64":27,"./core/utils/each":29,"./core/utils/extend":31,"./core/utils/parseParams":33,"./dataset":37,"./dataviz":61,"./dataviz/adapters/c3":52,"./dataviz/adapters/chartjs":53,"./dataviz/adapters/google":54,"./dataviz/adapters/keen-io":55,"./dataviz/extensions/draw":57,"./dataviz/utils/prettyNumber":95,domready:2,"spin.js":4}]},{},[96]); \ No newline at end of file diff --git a/src/dataviz/adapters/keen-io.js b/src/dataviz/adapters/keen-io.js index 4e0ba2b..b4fe770 100644 --- a/src/dataviz/adapters/keen-io.js +++ b/src/dataviz/adapters/keen-io.js @@ -73,7 +73,7 @@ module.exports = function(){ render: function(){ var bgColor = (this.colors().length == 1) ? this.colors()[0] : "#49c5b1", title = this.title() || "Result", - value = this.data()[1][1] || 0, + value = (this.data()[1] && this.data()[1][1]) ? this.data()[1][1] : 0, width = this.width(), opts = this.chartOptions() || {}, prefix = "", diff --git a/test/examples/dataviz/index.html b/test/examples/dataviz/index.html index 98f2350..090e60b 100644 --- a/test/examples/dataviz/index.html +++ b/test/examples/dataviz/index.html @@ -367,7 +367,7 @@

Funnels

* ------------------------------ */ - var drawn_metric = client.draw(metric, document.getElementById("1-1"), { + var drawn_metric = window.metric = client.draw(metric, document.getElementById("1-1"), { colors: ["#f35757"], height: 138, title: "Single Metric", From 99b061e6fdd440cb74438360eb1fa6b1803c8761 Mon Sep 17 00:00:00 2001 From: dustinlarimer Date: Tue, 16 Feb 2016 21:27:02 -0800 Subject: [PATCH 05/10] Include #298 for /docs/installation.md --- docs/installation.md | 53 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/docs/installation.md b/docs/installation.md index 54a3b81..559b0ba 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -63,7 +63,7 @@ If you only need to track events, replace the URLs in your installation with thi https://d26b395fwzu5fz.cloudfront.net/3.4.0-rc/keen-tracker.min.js ``` -## AMD/CommonJS +## AMD/RequireJS We want to make this library AMD/CommonJS-friendly, so if you run into any conflicts or bugs with specific loaders, please let us know by opening a new issue. @@ -83,3 +83,54 @@ require([ "keen" ], function(Keen) { ``` This library uses the Google Charts API for data visualization, which imposes a few installation challenges for RequireJS usage. [Read this to learn more](https://github.com/keen/keen-js/issues/341#issuecomment-148039517). + +## JSPM Installation + +In order to import keen-query and keen-tracker with JSPM, one has to define the following overrides in the package.json: + +```json + "dependencies": { + "keen": "github:keen/keen-js@3.2.5" + }, + "overrides": { + "github:keen/keen-js@3.2.5": { + "format": "global", + "main": "dist/keen-tracker.js", + "files": [ + "dist/keen-tracker.js", + "dist/keen-query.js" + ], + "shim": { + "dist/keen-tracker.": { + "exports": "Keen" + }, + "dist/keen-query": { + "exports": "Keen" + } + } + } + } +``` + +The main file will be `keen-tracker` and the secondary file will be `keen-query`. After running `jspm install`, you will be able to use the following statements to import Keen tracker and Keen query: + +```JavaScript +import Keen from 'keen'; +import KeenQuery from 'keen/dist/keen-query'; +``` + +You can use Keen straight away and for KeenQuery you need to call Keen.ready: + +```javascript +var client = new Keen({ + // ... +}); + +client.addEvent('event-collection', { + title: 'Some Event Property' +}); + +KeenQuery.ready(function() { + // Compose and run queries here +}); +``` From 1bde56d9bf402ec745e98b56c738503da3bf86c4 Mon Sep 17 00:00:00 2001 From: dustinlarimer Date: Wed, 17 Feb 2016 10:48:25 -0800 Subject: [PATCH 06/10] Provide failing test for new master key length --- test/unit/modules/server/scoped-keys-spec.js | 89 ++++++++++++-------- 1 file changed, 54 insertions(+), 35 deletions(-) diff --git a/test/unit/modules/server/scoped-keys-spec.js b/test/unit/modules/server/scoped-keys-spec.js index 06bf558..605ccaa 100644 --- a/test/unit/modules/server/scoped-keys-spec.js +++ b/test/unit/modules/server/scoped-keys-spec.js @@ -5,47 +5,66 @@ var Keen = require("../../../../src/server"), describe("Scoped Keys", function(){ - beforeEach(function() { - this.client = new Keen({ - projectId : keenHelper.projectId, - masterKey : keenHelper.masterKey - }); + beforeEach(function(){ + this.keyOptions = { + "allowed_operations": ["read"], + "filters": [ + { + "property_name": "purchase.amount", + "operator": "eq", + "property_value": 56 + }, + { + "property_name": "purchase.name", + "operator": "ne", + "property_value": "Barbie" + } + ] + }; }); - it("should encrypt a scoped key with given options", function() { + describe("New key validation", function(){ + + beforeEach(function(){ + this.apiKey = '78AFA8B8FF164C2429590C48F74C26165D37C8B95B5DFC71E498A32C57C9C38E'; + }); + + it("should encrypt an old scoped key with given options", function() { + // Encrypt a scoped key.. + var scopedKey = Keen.utils.encryptScopedKey(this.apiKey, this.keyOptions); + // ..then decrypt it + var decryptedOptions = Keen.utils.decryptScopedKey(this.apiKey, scopedKey); + expect(decryptedOptions).to.deep.equal(this.keyOptions); + }); + + it("should decrypt an old scoped key and return the correct options", function() { + var scopedKey = Keen.utils.encryptScopedKey(this.apiKey, this.keyOptions); + var decryptedOptions = Keen.utils.decryptScopedKey(this.apiKey, scopedKey); + expect(decryptedOptions).to.deep.equal(this.keyOptions); + }); - var options = { - "allowed_operations": ["read"], - "filters": [ { - "property_name": "purchase.amount", - "operator": "eq", - "property_value": 56 - }, { - "property_name": "purchase.name", - "operator": "ne", - "property_value": "Barbie" - }] - }; - // Encrypt a scoped key.. - var scopedKey = Keen.utils.encryptScopedKey(this.client.masterKey(), options); - // ..then decrypt it - var decryptedOptions = Keen.utils.decryptScopedKey(this.client.masterKey(), scopedKey); - expect(decryptedOptions).to.deep.equal(options); }); - it("should decrypt a scoped key and return the correct options", function() { + describe("Legacy key validation", function(){ + + beforeEach(function(){ + this.apiKey = 'FC135394DD08E3976870B7E7E83BDCD8'; + }); + + it("should encrypt an old scoped key with given options", function() { + // Encrypt a scoped key.. + var scopedKey = Keen.utils.encryptScopedKey(this.apiKey, this.keyOptions); + // ..then decrypt it + var decryptedOptions = Keen.utils.decryptScopedKey(this.apiKey, scopedKey); + expect(decryptedOptions).to.deep.equal(this.keyOptions); + }); + + it("should decrypt an old scoped key and return the correct options", function() { + var scopedKey = Keen.utils.encryptScopedKey(this.apiKey, this.keyOptions); + var decryptedOptions = Keen.utils.decryptScopedKey(this.apiKey, scopedKey); + expect(decryptedOptions).to.deep.equal(this.keyOptions); + }); - var apiKey = "f5d7c745ba4f437a82db02ca8b416556"; - var scopedKey = "7b8f357fa55e35efb2f7fa51a03ec2835c5537e57457c5a7c1c40c454fc00d5addef7ed911303fc2fa9648d3ae13e638192b86e90cd88657c9dc5cf03990cbf6eb2a7994513d34789bd25447f3dccaf5a3de3b9cacf6c11ded581e0506fca147ea32c13169787bbf8b4d3b8f2952bc0bea1beae3cfbbeaa1f421be2eac4cc223"; - var options = { - "filters": [{ - "property_name": "account_id", - "operator": "eq", - "property_value": "4d9a4c421d011c553e000001" - }] - }; - var decryptedOptions = Keen.utils.decryptScopedKey(apiKey, scopedKey); - expect(decryptedOptions).to.deep.equal(options); }); }); From a0baca6fcabe9297fdb37bf0af1f79294e8f4f78 Mon Sep 17 00:00:00 2001 From: dustinlarimer Date: Wed, 17 Feb 2016 14:33:03 -0800 Subject: [PATCH 07/10] Fix ##389: Use hex encoding for new master keys, update tests --- src/server/utils/decryptScopedKey.js | 15 ++-- src/server/utils/encryptScopedKey.js | 17 ++-- test/unit/modules/server/scoped-keys-spec.js | 84 +++++++++++++++----- 3 files changed, 83 insertions(+), 33 deletions(-) diff --git a/src/server/utils/decryptScopedKey.js b/src/server/utils/decryptScopedKey.js index d0016bd..cbbce69 100644 --- a/src/server/utils/decryptScopedKey.js +++ b/src/server/utils/decryptScopedKey.js @@ -2,15 +2,16 @@ var crypto = require('crypto'), json = require('../../core/utils/json-shim'); module.exports = function(apiKey, scopedKey) { - // key and iv must be 'binary' encoded strings or buffers. - var key = new Buffer(apiKey); - var iv = new Buffer(scopedKey.substring(0, 32), 'hex'); - var decipher = crypto.createDecipheriv('aes-256-cbc', key, iv); + var key, iv, decipher, cipherText, decoded; - var cipherText = new Buffer(scopedKey.substring(32, scopedKey.length), 'hex'); + key = apiKey.length === 64 ? new Buffer(apiKey, 'hex') : new Buffer(apiKey); + iv = new Buffer(scopedKey.substring(0, 32), 'hex'); + decipher = crypto.createDecipheriv('aes-256-cbc', key, iv); - var decoded = decipher.update(cipherText, 'hex', 'utf8'); - decoded += decipher.final('utf8'); + cipherText = new Buffer(scopedKey.substring(32, scopedKey.length), 'hex'); + + decoded = decipher.update(cipherText, 'hex', 'utf8'); + decoded += decipher.final('utf8'); return json.parse(decoded); }; diff --git a/src/server/utils/encryptScopedKey.js b/src/server/utils/encryptScopedKey.js index 0621f55..08d5b28 100644 --- a/src/server/utils/encryptScopedKey.js +++ b/src/server/utils/encryptScopedKey.js @@ -2,14 +2,15 @@ var crypto = require('crypto'), json = require('../../core/utils/json-shim'); module.exports = function(apiKey, data) { - // key and iv must be 'binary' encoded strings or buffers. - var key = new Buffer(apiKey); - var iv = crypto.randomBytes(16); - var cipher = crypto.createCipheriv('aes-256-cbc', key, iv); - - var output = iv.toString('hex'); - output += cipher.update(json.stringify(data), 'utf8', 'hex'); - output += cipher.final('hex'); + var key, iv, cipher, output; + + key = apiKey.length === 64 ? new Buffer(apiKey, 'hex') : new Buffer(apiKey); + iv = crypto.randomBytes(16); + cipher = crypto.createCipheriv('aes-256-cbc', key, iv); + + output = iv.toString('hex'); + output += cipher.update(json.stringify(data), 'utf8', 'hex'); + output += cipher.final('hex'); return output; }; diff --git a/test/unit/modules/server/scoped-keys-spec.js b/test/unit/modules/server/scoped-keys-spec.js index 605ccaa..3f088ca 100644 --- a/test/unit/modules/server/scoped-keys-spec.js +++ b/test/unit/modules/server/scoped-keys-spec.js @@ -6,38 +6,55 @@ var Keen = require("../../../../src/server"), describe("Scoped Keys", function(){ beforeEach(function(){ - this.keyOptions = { - "allowed_operations": ["read"], - "filters": [ - { - "property_name": "purchase.amount", - "operator": "eq", - "property_value": 56 - }, - { - "property_name": "purchase.name", - "operator": "ne", - "property_value": "Barbie" - } - ] - }; + this.client = new Keen({}); }); describe("New key validation", function(){ beforeEach(function(){ + this.projectId = '545178efe8759674b94a47d4'; this.apiKey = '78AFA8B8FF164C2429590C48F74C26165D37C8B95B5DFC71E498A32C57C9C38E'; + this.query = new Keen.Query('count', { + event_collection: 'Test', + timeframe: { + start: '2014-10-01', + end: '2014-11-01' + } + }); + this.keyOptions = { + "allowed_operations": ["read"], + "filters": [ + { + "property_name": "foo", + "operator": "exists", + "property_value": true + } + ] + }; }); - it("should encrypt an old scoped key with given options", function() { + it("should encrypt a scoped key with given options", function(done) { // Encrypt a scoped key.. var scopedKey = Keen.utils.encryptScopedKey(this.apiKey, this.keyOptions); // ..then decrypt it var decryptedOptions = Keen.utils.decryptScopedKey(this.apiKey, scopedKey); expect(decryptedOptions).to.deep.equal(this.keyOptions); + + // Apply and test scoped key + this.client + .projectId(this.projectId) + .readKey(scopedKey) + .run(this.query, function(err, res){ + if (err) { + done(err); + } + else { + done(); + } + }); }); - it("should decrypt an old scoped key and return the correct options", function() { + it("should decrypt a scoped key and return the correct options", function() { var scopedKey = Keen.utils.encryptScopedKey(this.apiKey, this.keyOptions); var decryptedOptions = Keen.utils.decryptScopedKey(this.apiKey, scopedKey); expect(decryptedOptions).to.deep.equal(this.keyOptions); @@ -48,15 +65,46 @@ describe("Scoped Keys", function(){ describe("Legacy key validation", function(){ beforeEach(function(){ + this.projectId = '52f00ec205cd66404b000000'; this.apiKey = 'FC135394DD08E3976870B7E7E83BDCD8'; + this.query = new Keen.Query('count', { + event_collection: 'click', + timeframe: { + start: '2015-01-01', + end: '2016-01-01' + } + }); + this.keyOptions = { + "allowed_operations": ["read"], + "filters": [ + { + "property_name": "page", + "operator": "exists", + "property_value": true + } + ] + }; }); - it("should encrypt an old scoped key with given options", function() { + it("should encrypt an old scoped key with given options", function(done) { // Encrypt a scoped key.. var scopedKey = Keen.utils.encryptScopedKey(this.apiKey, this.keyOptions); // ..then decrypt it var decryptedOptions = Keen.utils.decryptScopedKey(this.apiKey, scopedKey); expect(decryptedOptions).to.deep.equal(this.keyOptions); + + // Apply and test scoped key + this.client + .projectId(this.projectId) + .readKey(scopedKey) + .run(this.query, function(err, res){ + if (err) { + done(err); + } + else { + done(); + } + }); }); it("should decrypt an old scoped key and return the correct options", function() { From 7595bebbd19f34e7667a68034a9a99c7a58b944c Mon Sep 17 00:00:00 2001 From: dustinlarimer Date: Wed, 17 Feb 2016 14:59:12 -0800 Subject: [PATCH 08/10] Update CHANGELOG, README, commit built files --- CHANGELOG.md | 17 +++++++++++++++++ README.md | 8 ++++---- dist/keen-query.js | 2 +- dist/keen-query.min.js | 2 +- dist/keen-tracker.js | 2 +- dist/keen-tracker.min.js | 2 +- dist/keen.js | 2 +- dist/keen.min.js | 2 +- docs/README.md | 4 ++-- docs/installation.md | 8 ++++---- package.json | 2 +- 11 files changed, 34 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d9ac502..46b95ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,23 @@
# Unreleased --> + + +# New features, fixed scoped key generation + +**Fixed:** +* Scoped key generation support has been restored (#389): Recent improvements to scoped keys validation by the API invalidate keys generated by this and several other SDKs, resulting in an Invalid API Key Error. Newly generated scoped key could be successfully encrypted/decrypted, but cannot be used. This has been fixed. +* C3.js option construction how allows for more control of the `data` object passed in via `chartOptions` (#386) +* Fix Metric handling of empty results (#372) +* Fixed internal error handling when using unsupported `chartType` values (#382) + +**New:** +* Automatic parsing and visualization of multi-group-by queries (#326) +* `dateFormat` configuration option/method, which accepts a string or function that is used by the chosen underlying visualization suite (currently only supported by Google Charts and C3.js) (#381) +* Improved documentation for RequireJS and JSPM use (#298, #341) +* Removed all `camelCase` API parameters from docs (#387) to avoid common confusion + + # 3.3.0 Saved/Cached Queries and fixes diff --git a/README.md b/README.md index fd0c2f5..e6226e3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Keen IO JavaScript SDK (v3.4.0-rc) +# Keen IO JavaScript SDK (v3.4.0)