From 5bec987a224e699b4a618c74466016643e020884 Mon Sep 17 00:00:00 2001 From: Ian Storm Taylor Date: Mon, 28 Oct 2013 11:35:42 -0700 Subject: [PATCH] add Evergage --- History.md | 4 + analytics.js | 160 +++++++++++++-- analytics.min.js | 8 +- bower.json | 2 +- component.json | 2 +- lib/analytics.js | 2 +- lib/integrations/evergage.js | 73 +++---- package.json | 2 +- test/integrations/evergage.js | 353 +++++++++++++++++----------------- 9 files changed, 365 insertions(+), 241 deletions(-) diff --git a/History.md b/History.md index a5644cdd6..e0df47481 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,7 @@ +0.18.1 - October 28, 2013 +------------------------- +* add [Evergage](http://evergage.com), by [@glajchs](https://github.com/glajchs) + 0.18.0 - October 24, 2013 ------------------------- * add event emitter diff --git a/analytics.js b/analytics.js index b3ac1650c..44239b3eb 100644 --- a/analytics.js +++ b/analytics.js @@ -907,15 +907,15 @@ exports.parse = function(url){ a.href = url; return { href: a.href, - host: a.host, - port: a.port, + host: a.host || location.host, + port: ('0' === a.port || '' === a.port) ? location.port : a.port, hash: a.hash, - hostname: a.hostname, - pathname: a.pathname, - protocol: a.protocol, + hostname: a.hostname || location.hostname, + pathname: a.pathname.charAt(0) != '/' ? '/' + a.pathname : a.pathname, + protocol: !a.protocol || ':' == a.protocol ? location.protocol : a.protocol, search: a.search, query: a.search.slice(1) - } + }; }; /** @@ -927,9 +927,7 @@ exports.parse = function(url){ */ exports.isAbsolute = function(url){ - if (0 == url.indexOf('//')) return true; - if (~url.indexOf('://')) return true; - return false; + return 0 == url.indexOf('//') || !!~url.indexOf('://'); }; /** @@ -941,7 +939,7 @@ exports.isAbsolute = function(url){ */ exports.isRelative = function(url){ - return ! exports.isAbsolute(url); + return !exports.isAbsolute(url); }; /** @@ -954,9 +952,9 @@ exports.isRelative = function(url){ exports.isCrossDomain = function(url){ url = exports.parse(url); - return url.hostname != location.hostname - || url.port != location.port - || url.protocol != location.protocol; + return url.hostname !== location.hostname + || url.port !== location.port + || url.protocol !== location.protocol; }; }); require.register("ianstormtaylor-callback/index.js", function(exports, require, module){ @@ -2226,10 +2224,10 @@ module.exports = function loadScript (options, callback) { }); require.register("segmentio-new-date/lib/index.js", function(exports, require, module){ -var is = require('is'); -var isodate = require('isodate'); -var milliseconds = require('./milliseconds'); -var seconds = require('./seconds'); +var is = require('is') + , isodate = require('isodate') + , milliseconds = require('./milliseconds') + , seconds = require('./seconds'); /** @@ -2240,8 +2238,8 @@ var seconds = require('./seconds'); */ module.exports = function newDate (val) { - if (is.date(val)) return val; if (is.number(val)) return new Date(toMs(val)); + if (is.date(val)) return new Date(val.getTime()); // firefox woulda floored // date strings if (isodate.is(val)) return isodate.parse(val); @@ -2929,7 +2927,7 @@ module.exports = exports = Analytics; */ exports.VERSION = -Analytics.prototype.VERSION = '0.18.0'; +Analytics.prototype.VERSION = '0.18.1'; /** @@ -3625,6 +3623,7 @@ var integrations = [ 'comscore', 'crazy-egg', 'customerio', + 'evergage', 'errorception', 'foxmetrics', 'gauges', @@ -5053,6 +5052,129 @@ function convertDate (date) { return Math.floor(date.getTime() / 1000); } }); +require.register("analytics/lib/integrations/evergage.js", function(exports, require, module){ + +var alias = require('alias'); +var each = require('each'); +var integration = require('../integration'); +var load = require('load-script'); + + +/** + * Expose `Evergage` integration. + */ + +var Evergage = module.exports = integration('Evergage'); + + +/** + * Default options. + */ + +Evergage.prototype.defaults = { + // your Evergage account name as seen in accountName.evergage.com (required) + account: null, + // your Evergage dataset ID, not dataset label (required) + dataset: null +}; + + +/** + * Initialize. + * + * @param {Object} options + * @param {Function} ready + */ + +Evergage.prototype.initialize = function (options, ready) { + var account = options.account; + var dataset = options.dataset; + + window._aaq = window._aaq || []; + push('setEvergageAccount', account); + push('setDataset', dataset); + push('setUseSiteConfig', true); + ready(); + + load('//cdn.evergage.com/beacon/' + account + '/' + dataset + '/scripts/evergage.min.js'); +}; + + +/** + * Identify. + * + * @param {String} id (optional) + * @param {Object} traits (optional) + * @param {Object} options (optional) + */ + +Evergage.prototype.identify = function (id, traits, options) { + if (!id) return; + push('setUser', id); + + alias(traits, { + name: 'userName', + email: 'userEmail' + }); + + each(traits, function (key, value) { + push('setUserField', key, value, 'page'); + }); +}; + + +/** + * Group. + * + * @param {String} id + * @param {Object} properties (optional) + * @param {Object} options (optional) + */ + +Evergage.prototype.group = function (id, properties, options) { + if (!id) return; + push('setCompany', id); + each(properties, function(key, value) { + push('setAccountField', key, value, 'page'); + }); +}; + + +/** + * Track. + * + * @param {String} event + * @param {Object} properties (optional) + * @param {Object} options (optional) + */ + +Evergage.prototype.track = function (event, properties, options) { + push('trackAction', event, properties); +}; + + +/** + * Pageview. + * + * @param {String} url (optional) + */ + +Evergage.prototype.pageview = function (url) { + window.Evergage.init(true); +}; + + +/** + * Helper to push onto the Evergage queue. + * + * @param {Mixed} args... + */ + +function push (args) { + args = [].slice.call(arguments); + window._aaq.push(args); +} +}); require.register("analytics/lib/integrations/errorception.js", function(exports, require, module){ var callback = require('callback') diff --git a/analytics.min.js b/analytics.min.js index 2dc5a9d35..8f01be62a 100644 --- a/analytics.min.js +++ b/analytics.min.js @@ -1,4 +1,4 @@ -(function(){function require(path,parent,orig){var resolved=require.resolve(path);if(null==resolved){orig=orig||path;parent=parent||"root";var err=new Error('Failed to require "'+orig+'" from "'+parent+'"');err.path=orig;err.parent=parent;err.require=true;throw err}var module=require.modules[resolved];if(!module.exports){module.exports={};module.client=module.component=true;module.call(this,module.exports,require.relative(resolved),module)}return module.exports}require.modules={};require.aliases={};require.resolve=function(path){if(path.charAt(0)==="/")path=path.slice(1);var paths=[path,path+".js",path+".json",path+"/index.js",path+"/index.json"];for(var i=0;i0){if(!compare(arguments[i],arguments[--i]))return false}return true};function compare(a,b,memos){if(a===b)return true;var fnA=types[type(a)];if(fnA!==types[type(b)])return false;return fnA?fnA(a,b,memos):false}var types={};types.number=function(a){return a!==a};types["function"]=function(a,b,memos){return a.toString()===b.toString()&&types.object(a,b,memos)&&compare(a.prototype,b.prototype)};types.date=function(a,b){return+a===+b};types.regexp=function(a,b){return a.toString()===b.toString()};types.element=function(a,b){return a.outerHTML===b.outerHTML};types.textnode=function(a,b){return a.textContent===b.textContent};function memoGaurd(fn){return function(a,b,memos){if(!memos)return fn(a,b,[]);var i=memos.length,memo;while(memo=memos[--i]){if(memo[0]===a&&memo[1]===b)return true}return fn(a,b,memos)}}types["arguments"]=types.array=memoGaurd(compareArrays);function compareArrays(a,b,memos){var i=a.length;if(i!==b.length)return false;memos.push([a,b]);while(i--){if(!compare(a[i],b[i],memos))return false}return true}types.object=memoGaurd(compareObjects);function compareObjects(a,b,memos){var ka=getEnumerableProperties(a);var kb=getEnumerableProperties(b);var i=ka.length;if(i!==kb.length)return false;ka.sort();kb.sort();while(i--)if(ka[i]!==kb[i])return false;memos.push([a,b]);i=ka.length;while(i--){var key=ka[i];if(!compare(a[key],b[key],memos))return false}return true}function getEnumerableProperties(object){var result=[];for(var k in object)if(k!=="constructor"){result.push(k)}return result}module.exports.compare=compare});require.register("segmentio-after/index.js",function(exports,require,module){module.exports=function after(times,func){if(times<=0)return func();return function(){if(--times<1){return func.apply(this,arguments)}}}});require.register("segmentio-alias/index.js",function(exports,require,module){var type=require("type");module.exports=alias;function alias(obj,method){switch(type(method)){case"object":return aliasByDictionary(obj,method);case"function":return aliasByFunction(obj,method)}}function aliasByDictionary(obj,aliases){for(var key in aliases){if(undefined===obj[key])continue;obj[aliases[key]]=obj[key];delete obj[key]}}function aliasByFunction(obj,convert){for(var key in obj){obj[convert(key)]=obj[key];delete obj[key]}}});require.register("segmentio-canonical/index.js",function(exports,require,module){module.exports=function canonical(){var tags=document.getElementsByTagName("link");for(var i=0,tag;tag=tags[i];i++){if("canonical"==tag.getAttribute("rel"))return tag.getAttribute("href")}}});require.register("segmentio-convert-dates/index.js",function(exports,require,module){var is=require("is");module.exports=convertDates;function convertDates(obj,convert){for(var key in obj){var val=obj[key];if(is.date(val))obj[key]=convert(val);if(is.object(val))convertDates(val,convert)}}});require.register("segmentio-extend/index.js",function(exports,require,module){module.exports=function extend(object){var args=Array.prototype.slice.call(arguments,1);for(var i=0,source;source=args[i];i++){if(!source)continue;for(var property in source){object[property]=source[property]}}return object}});require.register("segmentio-is-email/index.js",function(exports,require,module){module.exports=isEmail;var matcher=/.+\@.+\..+/;function isEmail(string){return matcher.test(string)}});require.register("segmentio-is-meta/index.js",function(exports,require,module){module.exports=function isMeta(e){if(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)return true;var which=e.which,button=e.button;if(!which&&button!==undefined){return!button&1&&!button&2&&button&4}else if(which===2){return true}return false}});require.register("segmentio-isodate/index.js",function(exports,require,module){var matcher=/^(\d{4})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:([ T])(\d{2}):?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?)?$/;exports.parse=function(iso){var numericKeys=[1,5,6,7,8,11,12];var arr=matcher.exec(iso);var offset=0;if(!arr)return new Date(iso);for(var i=0,val;val=numericKeys[i];i++){arr[val]=parseInt(arr[val],10)||0}arr[2]=parseInt(arr[2],10)||1;arr[3]=parseInt(arr[3],10)||1;arr[2]--;if(arr[8])arr[8]=(arr[8]+"00").substring(0,3);if(arr[4]==" "){offset=(new Date).getTimezoneOffset()}else if(arr[9]!=="Z"&&arr[10]){offset=arr[11]*60+arr[12];if("+"==arr[10])offset=0-offset}var millis=Date.UTC(arr[1],arr[2],arr[3],arr[5],arr[6]+offset,arr[7],arr[8]);return new Date(millis)};exports.is=function(string,strict){if(strict&&false===/^\d{4}-\d{2}-\d{2}/.test(string))return false;return matcher.test(string)}});require.register("segmentio-isodate-traverse/index.js",function(exports,require,module){var clone=require("clone"),each=require("each"),is=require("is"),isodate=require("isodate");module.exports=traverse;function traverse(obj,strict){obj=clone(obj);if(strict===undefined)strict=true;each(obj,function(key,val){if(isodate.is(val,strict)){obj[key]=isodate.parse(val)}else if(is.object(val)){obj[key]=traverse(val)}});return obj}});require.register("component-json-fallback/index.js",function(exports,require,module){var JSON={};(function(){"use strict";function f(n){return n<10?"0"+n:n}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf()}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key)}if(typeof rep==="function"){value=rep.call(holder,key,value)}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;idocument.w=window');storageContainer.close();storageOwner=storageContainer.w.frames[0].document;storage=storageOwner.createElement("div")}catch(e){storage=doc.createElement("div");storageOwner=doc.body}function withIEStorage(storeFunction){return function(){var args=Array.prototype.slice.call(arguments,0);args.unshift(storage);storageOwner.appendChild(storage);storage.addBehavior("#default#userData");storage.load(localStorageName);var result=storeFunction.apply(store,args);storageOwner.removeChild(storage);return result}}var forbiddenCharsRegex=new RegExp("[!\"#$%&'()*+,/\\\\:;<=>?@[\\]^`{|}~]","g");function ieKeyFix(key){return key.replace(forbiddenCharsRegex,"___")}store.set=withIEStorage(function(storage,key,val){key=ieKeyFix(key);if(val===undefined){return store.remove(key)}storage.setAttribute(key,store.serialize(val));storage.save(localStorageName);return val});store.get=withIEStorage(function(storage,key){key=ieKeyFix(key);return store.deserialize(storage.getAttribute(key))});store.remove=withIEStorage(function(storage,key){key=ieKeyFix(key);storage.removeAttribute(key);storage.save(localStorageName)});store.clear=withIEStorage(function(storage){var attributes=storage.XMLDocument.documentElement.attributes;storage.load(localStorageName);for(var i=0,attr;attr=attributes[i];i++){storage.removeAttribute(attr.name)}storage.save(localStorageName)});store.getAll=withIEStorage(function(storage){var attributes=storage.XMLDocument.documentElement.attributes;var ret={};for(var i=0,attr;attr=attributes[i];++i){var key=ieKeyFix(attr.name);ret[attr.name]=store.deserialize(storage.getAttribute(key))}return ret})}try{store.set(namespace,namespace);if(store.get(namespace)!=namespace){store.disabled=true}store.remove(namespace)}catch(e){store.disabled=true}store.enabled=!store.disabled;if(typeof module!="undefined"&&module.exports){module.exports=store}else if(typeof define==="function"&&define.amd){define(store)}else{win.store=store}})(this.window||global)});require.register("segmentio-to-unix-timestamp/index.js",function(exports,require,module){module.exports=toUnixTimestamp;function toUnixTimestamp(date){return Math.floor(date.getTime()/1e3)}});require.register("segmentio-top-domain/index.js",function(exports,require,module){var url=require("url");module.exports=function(urlStr){var host=url.parse(urlStr).hostname,topLevel=host.match(/[a-z0-9][a-z0-9\-]*[a-z0-9]\.[a-z\.]{2,6}$/i);return topLevel?topLevel[0]:host}});require.register("timoxley-next-tick/index.js",function(exports,require,module){"use strict";if(typeof setImmediate=="function"){module.exports=function(f){setImmediate(f)}}else if(typeof process!="undefined"&&typeof process.nextTick=="function"){module.exports=process.nextTick}else if(typeof window=="undefined"||window.ActiveXObject||!window.postMessage){module.exports=function(f){setTimeout(f)}}else{var q=[];window.addEventListener("message",function(){var i=0;while(i=hour)return(ms/hour).toFixed(1)+"h";if(ms>=min)return(ms/min).toFixed(1)+"m";if(ms>=sec)return(ms/sec|0)+"s";return ms+"ms"};debug.enabled=function(name){for(var i=0,len=debug.skips.length;i<",i," onl"+'oad="var d=',g,";d.getElementsByTagName('head')[0].",j,"(d.",h,"('script')).",k,"='",l,"//",a.l,"'",'"',">"].join("")}var i="body",m=d[i];if(!m){return setTimeout(ld,100)}a.P(1);var j="appendChild",h="createElement",k="src",n=d[h]("div"),v=n[j](d[h](z)),b=d[h]("iframe"),g="document",e="domain",o;n.style.display="none";m.insertBefore(n,m.firstChild).id=z;b.frameBorder="0";b.id=z+"-loader";if(/MSIE[ ]+6/.test(navigator.userAgent)){b.src="javascript:false"}b.allowTransparency="true";v[j](b);try{b.contentWindow[g].open()}catch(w){c[e]=d[e];o="javascript:var d="+g+".open();d.domain='"+d.domain+"';";b[k]=o+"void(0);"}try{var t=b.contentWindow[g];t.write(p());t.close()}catch(x){b[k]=o+'d.write("'+p().replace(/"/g,String.fromCharCode(92)+'"')+'");d.close();'}a.P(2)};ld()};nt()}({loader:"static.olark.com/jsclient/loader0.js",name:"olark",methods:["configure","extend","declare","identify"]});window.olark.identify(options.siteId);callback.async(ready);var self=this;box("onExpand",function(){self._open=true});box("onShrink",function(){self._open=false})};Olark.prototype.identify=function(id,traits,options){if(!this.options.identify)return;if(id)traits.id=id;visitor("updateCustomFields",traits);if(traits.email)visitor("updateEmailAddress",{emailAddress:traits.email});if(traits.phone)visitor("updatePhoneNumber",{phoneNumber:traits.phone});var name=traits.firstName;if(traits.lastName)name+=" "+traits.lastName;if(traits.name)name=traits.name;if(name)visitor("updateFullName",{fullName:name});var nickname=name||traits.email||traits.username||id;if(name&&traits.email)nickname+=" ("+traits.email+")";if(nickname)chat("updateVisitorNickname",{snippet:nickname})};Olark.prototype.track=function(event,properties,options){if(!this.options.track||!this._open)return;chat("sendNotificationToOperator",{body:'visitor triggered "'+event+'"'})};Olark.prototype.pageview=function(url){if(!this.options.pageview||!this._open)return;url||(url=window.location.href);chat("sendNotificationToOperator",{body:"looking at "+url})};function box(action,value){window.olark("api.box."+action,value)}function visitor(action,value){window.olark("api.visitor."+action,value)}function chat(action,value){window.olark("api.chat."+action,value)}});require.register("analytics/lib/integrations/optimizely.js",function(exports,require,module){var bind=require("bind"),callback=require("callback"),each=require("each"),integration=require("../integration"),load=require("load-script"),tick=require("next-tick");var Optimizely=module.exports=integration("Optimizely");Optimizely.prototype.defaults={variations:true};Optimizely.prototype.initialize=function(options,ready){window.optimizely=window.optimizely||[];callback.async(ready);if(options.variations)tick(bind(this,this.replay))};Optimizely.prototype.track=function(event,properties,options){if(properties.revenue)properties.revenue=properties.revenue*100;window.optimizely.push(["trackEvent",event,properties])};Optimizely.prototype.replay=function(){var data=window.optimizely.data;if(!data)return;var experiments=data.experiments;var map=data.state.variationNamesMap;var traits={};each(map,function(experimentId,variation){var experiment=experiments[experimentId].name;traits["Experiment: "+experiment]=variation});this.analytics.identify(traits)}});require.register("analytics/lib/integrations/perfect-audience.js",function(exports,require,module){var integration=require("../integration"),load=require("load-script");var PerfectAudience=module.exports=integration("Perfect Audience");PerfectAudience.prototype.key="siteId";PerfectAudience.prototype.defaults={siteId:""};PerfectAudience.prototype.initialize=function(options,ready){window._pa||(window._pa={});load("//tag.perfectaudience.com/serve/"+options.siteId+".js",ready)};PerfectAudience.prototype.track=function(event,properties,options){window._pa.track(event,properties)}});require.register("analytics/lib/integrations/pingdom.js",function(exports,require,module){var date=require("load-date"),integration=require("../integration"),load=require("load-script");var Pingdom=module.exports=integration("Pingdom");Pingdom.prototype.key="id";Pingdom.prototype.defaults={id:""};Pingdom.prototype.initialize=function(options,ready){window._prum=[["id",options.id],["mark","firstbyte",date.getTime()]];load("//rum-static.pingdom.net/prum.min.js",ready)}});require.register("analytics/lib/integrations/preact.js",function(exports,require,module){var alias=require("alias"),callback=require("callback"),convertDates=require("convert-dates"),integration=require("../integration"),load=require("load-script");var Preact=module.exports=integration("Preact");Preact.prototype.key="projectCode";Preact.prototype.defaults={projectCode:""};Preact.prototype.initialize=function(options,ready){window._lnq||(window._lnq=[]);window._lnq.push(["_setCode",options.projectCode]);callback.async(ready);load("//d2bbvl6dq48fa6.cloudfront.net/js/ln-2.4.min.js")};Preact.prototype.identify=function(id,traits,options){if(!id)return;convertDates(traits,convertDate);alias(traits,{created:"created_at"});window._lnq.push(["_setPersonData",{name:traits.name,email:traits.email,uid:id,properties:traits}])};Preact.prototype.group=function(id,properties,options){if(!id)return;properties.id=id;window._lnq.push(["_setAccount",properties])};Preact.prototype.track=function(event,properties,options){var special={};special.name=event;if(properties.revenue){special.revenue=properties.revenue*100;delete properties.revenue}if(properties.note){special.note=properties.note;delete properties.note}window._lnq.push(["_logEvent",special,properties])};function convertDate(date){return Math.floor(date/1e3)}});require.register("analytics/lib/integrations/qualaroo.js",function(exports,require,module){var callback=require("callback"),integration=require("../integration"),load=require("load-script");var Qualaroo=module.exports=integration("Qualaroo");Qualaroo.prototype.defaults={customerId:"",siteToken:"",track:false};Qualaroo.prototype.initialize=function(options,ready){window._kiq||(window._kiq=[]);callback.async(ready);var path=options.customerId+"/"+options.siteToken;load("//s3.amazonaws.com/ki.js/"+path+".js")};Qualaroo.prototype.identify=function(id,traits,options){if(traits.email)id=traits.email;if(id)window._kiq.push(["identify",id]);if(traits)window._kiq.push(["set",traits])};Qualaroo.prototype.track=function(event,properties,options){if(!this.options.track)return;var traits={};traits["Triggered: "+event]=true;this.identify(null,traits)}});require.register("analytics/lib/integrations/quantcast.js",function(exports,require,module){var integration=require("../integration"),load=require("load-script");var Quantcast=module.exports=integration("Quantcast");Quantcast.prototype.key="pCode";Quantcast.prototype.defaults={pCode:null};Quantcast.prototype.initialize=function(options,ready){window._qevents||(window._qevents=[]);window._qevents.push({qacct:options.pCode});load({http:"http://edge.quantserve.com/quant.js",https:"https://secure.quantserve.com/quant.js"},ready)}});require.register("analytics/lib/integrations/rollbar.js",function(exports,require,module){var callback=require("callback"),clone=require("clone"),extend=require("extend"),integration=require("../integration"),load=require("load-script"),onError=require("on-error");var Rollbar=module.exports=integration("Rollbar");Rollbar.prototype.key="accessToken";Rollbar.prototype.defaults={accessToken:"",identify:true};Rollbar.prototype.initialize=function(options,ready){window._rollbar=window._rollbar||window._ratchet||[options.accessToken,clone(options)];onError(function(){window._rollbar.push(arguments)});callback.async(ready);load("//d37gvrvc0wt4s1.cloudfront.net/js/1/rollbar.min.js")};Rollbar.prototype.identify=function(id,traits,options){if(!this.options.identify)return;if(id)traits.id=id;var rollbar=window._rollbar;var params=rollbar.shift?rollbar[1]=rollbar[1]||{}:rollbar.extraParams=rollbar.extraParams||{};params.person=params.person||{};extend(params.person,traits)}});require.register("analytics/lib/integrations/sentry.js",function(exports,require,module){var integration=require("../integration"),load=require("load-script");var Sentry=module.exports=integration("Sentry");Sentry.prototype.key="config";Sentry.prototype.defaults={config:""};Sentry.prototype.initialize=function(options,ready){load("//d3nslu0hdya83q.cloudfront.net/dist/1.0/raven.min.js",function(){window.Raven.config(options.config).install();ready()})};Sentry.prototype.identify=function(id,traits,options){if(id)traits.id=id;window.Raven.setUser(traits)}});require.register("analytics/lib/integrations/snapengage.js",function(exports,require,module){var integration=require("../integration"),load=require("load-script");var SnapEngage=module.exports=integration("SnapEngage");SnapEngage.prototype.key="apiKey";SnapEngage.prototype.defaults={apiKey:""};SnapEngage.prototype.initialize=function(options,ready){load("//commondatastorage.googleapis.com/code.snapengage.com/js/"+options.apiKey+".js",ready)};SnapEngage.prototype.identify=function(id,traits,options){if(!traits.email)return;window.SnapABug.setUserEmail(traits.email)}});require.register("analytics/lib/integrations/spinnakr.js",function(exports,require,module){var integration=require("../integration"),load=require("load-script");var Spinnakr=module.exports=integration("Spinnakr");Spinnakr.prototype.key="siteId";Spinnakr.prototype.defaults={siteId:""};Spinnakr.prototype.initialize=function(options,ready){window._spinnakr_site_id=options.siteId;load("//d3ojzyhbolvoi5.cloudfront.net/js/so.js",ready)}});require.register("analytics/lib/integrations/tapstream.js",function(exports,require,module){var callback=require("callback"),integration=require("../integration"),load=require("load-script"),slug=require("slug");var Tapstream=module.exports=integration("Tapstream");Tapstream.prototype.key="accountName";Tapstream.prototype.defaults={accountName:"",initialPageview:true};Tapstream.prototype.initialize=function(options,ready){window._tsq=window._tsq||[];window._tsq.push(["setAccountName",options.accountName]);if(options.initialPageview)this.pageview();load("//cdn.tapstream.com/static/js/tapstream.js");callback.async(ready)};Tapstream.prototype.track=function(event,properties,options){event=slug(event);window._tsq.push(["fireHit",event,[]])};Tapstream.prototype.pageview=function(url){var event=slug("Loaded a Page");window._tsq.push(["fireHit",event,[url]])}});require.register("analytics/lib/integrations/trakio.js",function(exports,require,module){var alias=require("alias"),callback=require("callback"),clone=require("clone"),integration=require("../integration"),load=require("load-script");var Trakio=module.exports=integration("trak.io");Trakio.prototype.key="token";Trakio.prototype.defaults={initialPageview:true,pageview:true,token:""};Trakio.prototype.initialize=function(options,ready){window.trak=window.trak||[];window.trak.io=window.trak.io||{};window.trak.io.load=function(e){load("//d29p64779x43zo.cloudfront.net/v1/trak.io.min.js");var r=function(e){return function(){window.trak.push([e].concat(Array.prototype.slice.call(arguments,0)))}},i=["initialize","identify","track","alias","channel","source","host","protocol","page_view"];for(var s=0;s0){if(!compare(arguments[i],arguments[--i]))return false}return true};function compare(a,b,memos){if(a===b)return true;var fnA=types[type(a)];if(fnA!==types[type(b)])return false;return fnA?fnA(a,b,memos):false}var types={};types.number=function(a){return a!==a};types["function"]=function(a,b,memos){return a.toString()===b.toString()&&types.object(a,b,memos)&&compare(a.prototype,b.prototype)};types.date=function(a,b){return+a===+b};types.regexp=function(a,b){return a.toString()===b.toString()};types.element=function(a,b){return a.outerHTML===b.outerHTML};types.textnode=function(a,b){return a.textContent===b.textContent};function memoGaurd(fn){return function(a,b,memos){if(!memos)return fn(a,b,[]);var i=memos.length,memo;while(memo=memos[--i]){if(memo[0]===a&&memo[1]===b)return true}return fn(a,b,memos)}}types["arguments"]=types.array=memoGaurd(compareArrays);function compareArrays(a,b,memos){var i=a.length;if(i!==b.length)return false;memos.push([a,b]);while(i--){if(!compare(a[i],b[i],memos))return false}return true}types.object=memoGaurd(compareObjects);function compareObjects(a,b,memos){var ka=getEnumerableProperties(a);var kb=getEnumerableProperties(b);var i=ka.length;if(i!==kb.length)return false;ka.sort();kb.sort();while(i--)if(ka[i]!==kb[i])return false;memos.push([a,b]);i=ka.length;while(i--){var key=ka[i];if(!compare(a[key],b[key],memos))return false}return true}function getEnumerableProperties(object){var result=[];for(var k in object)if(k!=="constructor"){result.push(k)}return result}module.exports.compare=compare});require.register("segmentio-after/index.js",function(exports,require,module){module.exports=function after(times,func){if(times<=0)return func();return function(){if(--times<1){return func.apply(this,arguments)}}}});require.register("segmentio-alias/index.js",function(exports,require,module){var type=require("type");module.exports=alias;function alias(obj,method){switch(type(method)){case"object":return aliasByDictionary(obj,method);case"function":return aliasByFunction(obj,method)}}function aliasByDictionary(obj,aliases){for(var key in aliases){if(undefined===obj[key])continue;obj[aliases[key]]=obj[key];delete obj[key]}}function aliasByFunction(obj,convert){for(var key in obj){obj[convert(key)]=obj[key];delete obj[key]}}});require.register("segmentio-canonical/index.js",function(exports,require,module){module.exports=function canonical(){var tags=document.getElementsByTagName("link");for(var i=0,tag;tag=tags[i];i++){if("canonical"==tag.getAttribute("rel"))return tag.getAttribute("href")}}});require.register("segmentio-convert-dates/index.js",function(exports,require,module){var is=require("is");module.exports=convertDates;function convertDates(obj,convert){for(var key in obj){var val=obj[key];if(is.date(val))obj[key]=convert(val);if(is.object(val))convertDates(val,convert)}}});require.register("segmentio-extend/index.js",function(exports,require,module){module.exports=function extend(object){var args=Array.prototype.slice.call(arguments,1);for(var i=0,source;source=args[i];i++){if(!source)continue;for(var property in source){object[property]=source[property]}}return object}});require.register("segmentio-is-email/index.js",function(exports,require,module){module.exports=isEmail;var matcher=/.+\@.+\..+/;function isEmail(string){return matcher.test(string)}});require.register("segmentio-is-meta/index.js",function(exports,require,module){module.exports=function isMeta(e){if(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)return true;var which=e.which,button=e.button;if(!which&&button!==undefined){return!button&1&&!button&2&&button&4}else if(which===2){return true}return false}});require.register("segmentio-isodate/index.js",function(exports,require,module){var matcher=/^(\d{4})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:([ T])(\d{2}):?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?)?$/;exports.parse=function(iso){var numericKeys=[1,5,6,7,8,11,12];var arr=matcher.exec(iso);var offset=0;if(!arr)return new Date(iso);for(var i=0,val;val=numericKeys[i];i++){arr[val]=parseInt(arr[val],10)||0}arr[2]=parseInt(arr[2],10)||1;arr[3]=parseInt(arr[3],10)||1;arr[2]--;if(arr[8])arr[8]=(arr[8]+"00").substring(0,3);if(arr[4]==" "){offset=(new Date).getTimezoneOffset()}else if(arr[9]!=="Z"&&arr[10]){offset=arr[11]*60+arr[12];if("+"==arr[10])offset=0-offset}var millis=Date.UTC(arr[1],arr[2],arr[3],arr[5],arr[6]+offset,arr[7],arr[8]);return new Date(millis)};exports.is=function(string,strict){if(strict&&false===/^\d{4}-\d{2}-\d{2}/.test(string))return false;return matcher.test(string)}});require.register("segmentio-isodate-traverse/index.js",function(exports,require,module){var clone=require("clone"),each=require("each"),is=require("is"),isodate=require("isodate");module.exports=traverse;function traverse(obj,strict){obj=clone(obj);if(strict===undefined)strict=true;each(obj,function(key,val){if(isodate.is(val,strict)){obj[key]=isodate.parse(val)}else if(is.object(val)){obj[key]=traverse(val)}});return obj}});require.register("component-json-fallback/index.js",function(exports,require,module){var JSON={};(function(){"use strict";function f(n){return n<10?"0"+n:n}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf()}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key)}if(typeof rep==="function"){value=rep.call(holder,key,value)}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;idocument.w=window');storageContainer.close();storageOwner=storageContainer.w.frames[0].document;storage=storageOwner.createElement("div")}catch(e){storage=doc.createElement("div");storageOwner=doc.body}function withIEStorage(storeFunction){return function(){var args=Array.prototype.slice.call(arguments,0);args.unshift(storage);storageOwner.appendChild(storage);storage.addBehavior("#default#userData");storage.load(localStorageName);var result=storeFunction.apply(store,args);storageOwner.removeChild(storage);return result}}var forbiddenCharsRegex=new RegExp("[!\"#$%&'()*+,/\\\\:;<=>?@[\\]^`{|}~]","g");function ieKeyFix(key){return key.replace(forbiddenCharsRegex,"___")}store.set=withIEStorage(function(storage,key,val){key=ieKeyFix(key);if(val===undefined){return store.remove(key)}storage.setAttribute(key,store.serialize(val));storage.save(localStorageName);return val});store.get=withIEStorage(function(storage,key){key=ieKeyFix(key);return store.deserialize(storage.getAttribute(key))});store.remove=withIEStorage(function(storage,key){key=ieKeyFix(key);storage.removeAttribute(key);storage.save(localStorageName)});store.clear=withIEStorage(function(storage){var attributes=storage.XMLDocument.documentElement.attributes;storage.load(localStorageName);for(var i=0,attr;attr=attributes[i];i++){storage.removeAttribute(attr.name)}storage.save(localStorageName)});store.getAll=withIEStorage(function(storage){var attributes=storage.XMLDocument.documentElement.attributes;var ret={};for(var i=0,attr;attr=attributes[i];++i){var key=ieKeyFix(attr.name);ret[attr.name]=store.deserialize(storage.getAttribute(key))}return ret})}try{store.set(namespace,namespace);if(store.get(namespace)!=namespace){store.disabled=true}store.remove(namespace)}catch(e){store.disabled=true}store.enabled=!store.disabled;if(typeof module!="undefined"&&module.exports){module.exports=store}else if(typeof define==="function"&&define.amd){define(store)}else{win.store=store}})(this.window||global)});require.register("segmentio-to-unix-timestamp/index.js",function(exports,require,module){module.exports=toUnixTimestamp;function toUnixTimestamp(date){return Math.floor(date.getTime()/1e3)}});require.register("segmentio-top-domain/index.js",function(exports,require,module){var url=require("url");module.exports=function(urlStr){var host=url.parse(urlStr).hostname,topLevel=host.match(/[a-z0-9][a-z0-9\-]*[a-z0-9]\.[a-z\.]{2,6}$/i);return topLevel?topLevel[0]:host}});require.register("timoxley-next-tick/index.js",function(exports,require,module){"use strict";if(typeof setImmediate=="function"){module.exports=function(f){setImmediate(f)}}else if(typeof process!="undefined"&&typeof process.nextTick=="function"){module.exports=process.nextTick}else if(typeof window=="undefined"||window.ActiveXObject||!window.postMessage){module.exports=function(f){setTimeout(f)}}else{var q=[];window.addEventListener("message",function(){var i=0;while(i=hour)return(ms/hour).toFixed(1)+"h";if(ms>=min)return(ms/min).toFixed(1)+"m";if(ms>=sec)return(ms/sec|0)+"s";return ms+"ms"};debug.enabled=function(name){for(var i=0,len=debug.skips.length;i<",i," onl"+'oad="var d=',g,";d.getElementsByTagName('head')[0].",j,"(d.",h,"('script')).",k,"='",l,"//",a.l,"'",'"',">"].join("")}var i="body",m=d[i];if(!m){return setTimeout(ld,100)}a.P(1);var j="appendChild",h="createElement",k="src",n=d[h]("div"),v=n[j](d[h](z)),b=d[h]("iframe"),g="document",e="domain",o;n.style.display="none";m.insertBefore(n,m.firstChild).id=z;b.frameBorder="0";b.id=z+"-loader";if(/MSIE[ ]+6/.test(navigator.userAgent)){b.src="javascript:false"}b.allowTransparency="true";v[j](b);try{b.contentWindow[g].open()}catch(w){c[e]=d[e];o="javascript:var d="+g+".open();d.domain='"+d.domain+"';";b[k]=o+"void(0);"}try{var t=b.contentWindow[g];t.write(p());t.close()}catch(x){b[k]=o+'d.write("'+p().replace(/"/g,String.fromCharCode(92)+'"')+'");d.close();'}a.P(2)};ld()};nt()}({loader:"static.olark.com/jsclient/loader0.js",name:"olark",methods:["configure","extend","declare","identify"]});window.olark.identify(options.siteId);callback.async(ready);var self=this;box("onExpand",function(){self._open=true});box("onShrink",function(){self._open=false})};Olark.prototype.identify=function(id,traits,options){if(!this.options.identify)return;if(id)traits.id=id;visitor("updateCustomFields",traits);if(traits.email)visitor("updateEmailAddress",{emailAddress:traits.email});if(traits.phone)visitor("updatePhoneNumber",{phoneNumber:traits.phone});var name=traits.firstName;if(traits.lastName)name+=" "+traits.lastName;if(traits.name)name=traits.name;if(name)visitor("updateFullName",{fullName:name});var nickname=name||traits.email||traits.username||id;if(name&&traits.email)nickname+=" ("+traits.email+")";if(nickname)chat("updateVisitorNickname",{snippet:nickname})};Olark.prototype.track=function(event,properties,options){if(!this.options.track||!this._open)return;chat("sendNotificationToOperator",{body:'visitor triggered "'+event+'"'})};Olark.prototype.pageview=function(url){if(!this.options.pageview||!this._open)return;url||(url=window.location.href);chat("sendNotificationToOperator",{body:"looking at "+url})};function box(action,value){window.olark("api.box."+action,value)}function visitor(action,value){window.olark("api.visitor."+action,value)}function chat(action,value){window.olark("api.chat."+action,value)}});require.register("analytics/lib/integrations/optimizely.js",function(exports,require,module){var bind=require("bind"),callback=require("callback"),each=require("each"),integration=require("../integration"),load=require("load-script"),tick=require("next-tick");var Optimizely=module.exports=integration("Optimizely");Optimizely.prototype.defaults={variations:true};Optimizely.prototype.initialize=function(options,ready){window.optimizely=window.optimizely||[];callback.async(ready);if(options.variations)tick(bind(this,this.replay))};Optimizely.prototype.track=function(event,properties,options){if(properties.revenue)properties.revenue=properties.revenue*100;window.optimizely.push(["trackEvent",event,properties])};Optimizely.prototype.replay=function(){var data=window.optimizely.data;if(!data)return;var experiments=data.experiments;var map=data.state.variationNamesMap;var traits={};each(map,function(experimentId,variation){var experiment=experiments[experimentId].name;traits["Experiment: "+experiment]=variation});this.analytics.identify(traits)}});require.register("analytics/lib/integrations/perfect-audience.js",function(exports,require,module){var integration=require("../integration"),load=require("load-script");var PerfectAudience=module.exports=integration("Perfect Audience");PerfectAudience.prototype.key="siteId";PerfectAudience.prototype.defaults={siteId:""};PerfectAudience.prototype.initialize=function(options,ready){window._pa||(window._pa={});load("//tag.perfectaudience.com/serve/"+options.siteId+".js",ready)};PerfectAudience.prototype.track=function(event,properties,options){window._pa.track(event,properties)}});require.register("analytics/lib/integrations/pingdom.js",function(exports,require,module){var date=require("load-date"),integration=require("../integration"),load=require("load-script");var Pingdom=module.exports=integration("Pingdom");Pingdom.prototype.key="id";Pingdom.prototype.defaults={id:""};Pingdom.prototype.initialize=function(options,ready){window._prum=[["id",options.id],["mark","firstbyte",date.getTime()]];load("//rum-static.pingdom.net/prum.min.js",ready)}});require.register("analytics/lib/integrations/preact.js",function(exports,require,module){var alias=require("alias"),callback=require("callback"),convertDates=require("convert-dates"),integration=require("../integration"),load=require("load-script");var Preact=module.exports=integration("Preact");Preact.prototype.key="projectCode";Preact.prototype.defaults={projectCode:""};Preact.prototype.initialize=function(options,ready){window._lnq||(window._lnq=[]);window._lnq.push(["_setCode",options.projectCode]);callback.async(ready);load("//d2bbvl6dq48fa6.cloudfront.net/js/ln-2.4.min.js")};Preact.prototype.identify=function(id,traits,options){if(!id)return;convertDates(traits,convertDate);alias(traits,{created:"created_at"});window._lnq.push(["_setPersonData",{name:traits.name,email:traits.email,uid:id,properties:traits}])};Preact.prototype.group=function(id,properties,options){if(!id)return;properties.id=id;window._lnq.push(["_setAccount",properties])};Preact.prototype.track=function(event,properties,options){var special={};special.name=event;if(properties.revenue){special.revenue=properties.revenue*100;delete properties.revenue}if(properties.note){special.note=properties.note;delete properties.note}window._lnq.push(["_logEvent",special,properties])};function convertDate(date){return Math.floor(date/1e3)}});require.register("analytics/lib/integrations/qualaroo.js",function(exports,require,module){var callback=require("callback"),integration=require("../integration"),load=require("load-script");var Qualaroo=module.exports=integration("Qualaroo");Qualaroo.prototype.defaults={customerId:"",siteToken:"",track:false};Qualaroo.prototype.initialize=function(options,ready){window._kiq||(window._kiq=[]);callback.async(ready);var path=options.customerId+"/"+options.siteToken;load("//s3.amazonaws.com/ki.js/"+path+".js")};Qualaroo.prototype.identify=function(id,traits,options){if(traits.email)id=traits.email;if(id)window._kiq.push(["identify",id]);if(traits)window._kiq.push(["set",traits])};Qualaroo.prototype.track=function(event,properties,options){if(!this.options.track)return;var traits={};traits["Triggered: "+event]=true;this.identify(null,traits)}});require.register("analytics/lib/integrations/quantcast.js",function(exports,require,module){var integration=require("../integration"),load=require("load-script");var Quantcast=module.exports=integration("Quantcast");Quantcast.prototype.key="pCode";Quantcast.prototype.defaults={pCode:null};Quantcast.prototype.initialize=function(options,ready){window._qevents||(window._qevents=[]);window._qevents.push({qacct:options.pCode});load({http:"http://edge.quantserve.com/quant.js",https:"https://secure.quantserve.com/quant.js"},ready)}});require.register("analytics/lib/integrations/rollbar.js",function(exports,require,module){var callback=require("callback"),clone=require("clone"),extend=require("extend"),integration=require("../integration"),load=require("load-script"),onError=require("on-error");var Rollbar=module.exports=integration("Rollbar");Rollbar.prototype.key="accessToken";Rollbar.prototype.defaults={accessToken:"",identify:true};Rollbar.prototype.initialize=function(options,ready){window._rollbar=window._rollbar||window._ratchet||[options.accessToken,clone(options)];onError(function(){window._rollbar.push(arguments)});callback.async(ready);load("//d37gvrvc0wt4s1.cloudfront.net/js/1/rollbar.min.js")};Rollbar.prototype.identify=function(id,traits,options){if(!this.options.identify)return;if(id)traits.id=id;var rollbar=window._rollbar;var params=rollbar.shift?rollbar[1]=rollbar[1]||{}:rollbar.extraParams=rollbar.extraParams||{};params.person=params.person||{};extend(params.person,traits)}});require.register("analytics/lib/integrations/sentry.js",function(exports,require,module){var integration=require("../integration"),load=require("load-script");var Sentry=module.exports=integration("Sentry");Sentry.prototype.key="config";Sentry.prototype.defaults={config:""};Sentry.prototype.initialize=function(options,ready){load("//d3nslu0hdya83q.cloudfront.net/dist/1.0/raven.min.js",function(){window.Raven.config(options.config).install();ready()})};Sentry.prototype.identify=function(id,traits,options){if(id)traits.id=id;window.Raven.setUser(traits)}});require.register("analytics/lib/integrations/snapengage.js",function(exports,require,module){var integration=require("../integration"),load=require("load-script");var SnapEngage=module.exports=integration("SnapEngage");SnapEngage.prototype.key="apiKey";SnapEngage.prototype.defaults={apiKey:""};SnapEngage.prototype.initialize=function(options,ready){load("//commondatastorage.googleapis.com/code.snapengage.com/js/"+options.apiKey+".js",ready)};SnapEngage.prototype.identify=function(id,traits,options){if(!traits.email)return;window.SnapABug.setUserEmail(traits.email)}});require.register("analytics/lib/integrations/spinnakr.js",function(exports,require,module){var integration=require("../integration"),load=require("load-script");var Spinnakr=module.exports=integration("Spinnakr");Spinnakr.prototype.key="siteId";Spinnakr.prototype.defaults={siteId:""};Spinnakr.prototype.initialize=function(options,ready){window._spinnakr_site_id=options.siteId;load("//d3ojzyhbolvoi5.cloudfront.net/js/so.js",ready)}});require.register("analytics/lib/integrations/tapstream.js",function(exports,require,module){var callback=require("callback"),integration=require("../integration"),load=require("load-script"),slug=require("slug");var Tapstream=module.exports=integration("Tapstream");Tapstream.prototype.key="accountName";Tapstream.prototype.defaults={accountName:"",initialPageview:true};Tapstream.prototype.initialize=function(options,ready){window._tsq=window._tsq||[];window._tsq.push(["setAccountName",options.accountName]);if(options.initialPageview)this.pageview();load("//cdn.tapstream.com/static/js/tapstream.js");callback.async(ready)};Tapstream.prototype.track=function(event,properties,options){event=slug(event);window._tsq.push(["fireHit",event,[]])};Tapstream.prototype.pageview=function(url){var event=slug("Loaded a Page");window._tsq.push(["fireHit",event,[url]])}});require.register("analytics/lib/integrations/trakio.js",function(exports,require,module){var alias=require("alias"),callback=require("callback"),clone=require("clone"),integration=require("../integration"),load=require("load-script");var Trakio=module.exports=integration("trak.io");Trakio.prototype.key="token";Trakio.prototype.defaults={initialPageview:true,pageview:true,token:""};Trakio.prototype.initialize=function(options,ready){window.trak=window.trak||[];window.trak.io=window.trak.io||{};window.trak.io.load=function(e){load("//d29p64779x43zo.cloudfront.net/v1/trak.io.min.js");var r=function(e){return function(){window.trak.push([e].concat(Array.prototype.slice.call(arguments,0)))}},i=["initialize","identify","track","alias","channel","source","host","protocol","page_view"];for(var s=0;s", "description": "The hassle-free way to integrate analytics into any web application.", "license": "MIT", diff --git a/test/integrations/evergage.js b/test/integrations/evergage.js index 12a7ef32d..d9ee7918f 100644 --- a/test/integrations/evergage.js +++ b/test/integrations/evergage.js @@ -1,184 +1,175 @@ describe('Evergage', function () { -var analytics = window.analytics || require('analytics') - , sinon = require('sinon') - , when = require('when') - , assert = require('assert'); - -var settings = { - account : 'segmentiotest', - dataset : 'segio_b2b_anon', - minified : false, - loggingLevel : 'NONE' -}; - -before(function (done) { - // setup a stub to listen on - window._aaq = []; - - this.timeout(3000); - this.spy = sinon.spy(); - analytics.ready(this.spy); - analytics.initialize({ 'Evergage': settings }); - this.integration = analytics._integrations['Evergage']; - this.options = this.integration.options; - var stub = window._aaq.push; - when(function () { return window._aaq.push != stub; }, done); -}); - -describe('#name', function () { - it('Evergage', function () { - assert(this.integration.name == 'Evergage'); - }); -}); - -describe('#defaults', function () { - it('account', function () { - assert(this.integration.defaults.account === null); - }); - - it('dataset', function () { - assert(this.integration.defaults.dataset === null); - }); - - it('loggingLevel', function () { - assert(this.integration.defaults.loggingLevel === 'NONE'); - }); - - it('minified', function () { - assert(this.integration.defaults.minified === true); - }); -}); - -describe('#initialize', function () { - it('should call ready', function () { - assert(this.spy.called); - }); - - it('should store options', function () { - assert(this.options.account == settings.account); - assert(this.options.dataset == settings.dataset); - assert(this.options.loggingLevel == settings.loggingLevel); - assert(this.options.minified == settings.minified); - }); - - it('should define a global tracker', function () { - assert('object' == typeof window.Evergage); - }); - - it('should show a message', function (done) { - when(function () { return ajq('.evergage-qtip').length && ajq('.evergage-qtip').css('opacity') == 1; }, done); - }); - - it('should track a pageview with the canonical url'); - - after(function() { - window.Evergage.hideAllMessages(); - }) -}); - -describe('#identify', function () { - beforeEach(function () { - analytics.user().reset(); - this.stub = sinon.stub(window._aaq, 'push'); - }); - - afterEach(function () { - this.stub.restore(); - }); - - it('should send an id', function () { - analytics.identify('id'); - assert(this.stub.calledWith(['setUser', 'id'])); - }); - - it('shouldn\'t send just traits', function () { - analytics.identify({ trait: true }); - assert(!this.stub.called); - }); - - it('should send an id and traits', function () { - analytics.identify('id', { trait: true }); - assert(this.stub.calledWith(['setUserField', 'trait', true, 'page'])); - assert(this.stub.calledWith(['setUser', 'id'])); - }); - - it('should send an email', function () { - analytics.identify('id', { email: 'name@example.com' }); - assert(this.stub.calledWith(['setUserField', 'userEmail', 'name@example.com', 'page'])); - assert(this.stub.calledWith(['setUser', 'id'])); - }); - - it('should send a name', function () { - analytics.identify('id', { name: 'name' }); - assert(this.stub.calledWith(['setUserField', 'userName', 'name', 'page'])); - assert(this.stub.calledWith(['setUser', 'id'])); - }); -}); - -describe('#group', function () { - beforeEach(function () { - this.stub = sinon.stub(window._aaq, 'push'); - analytics.group().reset(); - }); - - afterEach(function () { - this.stub.restore(); - }); - - it('should send an id', function () { - analytics.group('id'); - assert(this.stub.calledWith(['setCompany', 'id'])); - }); - - it('should send properties', function () { - analytics.group({ property: true }); - assert(this.stub.calledWith(['setAccountField', 'property', true, 'page'])); - // Analytics.js now always caches the group id and always sends it - // assert(!this.stub.calledWith(['setCompany', 'id'])); - }); - - it('should send an id and properties', function () { - analytics.group('id', { property: true }); - assert(this.stub.calledWith(['setAccountField', 'property', true, 'page'])); - assert(this.stub.calledWith(['setCompany', 'id'])); - }); -}); - -describe('#track', function () { - beforeEach(function () { - this.stub = sinon.stub(window._aaq, 'push'); - }); - - afterEach(function () { - this.stub.restore(); - }); - - it('should send an event', function () { - analytics.track('event'); - assert(this.stub.calledWith(['trackAction', 'event', {}])); - }); - - it('should send an event and properties', function () { - analytics.track('event', { property: true }); - assert(this.stub.calledWith(['trackAction', 'event', { property: true }])); - }); -}); - -describe('#pageview', function () { - beforeEach(function () { - this.stub = sinon.stub(window.Evergage, 'init'); - }); - - afterEach(function () { - this.stub.restore(); - }); - - it('should call pageview', function () { - analytics.pageview(); - assert(this.stub.calledWith(true)); - }); -}); - -}); + var analytics = window.analytics || require('analytics'); + var assert = require('assert'); + var jquery = require('jquery'); + var sinon = require('sinon'); + var when = require('when'); + + var settings = { + account: 'segmentiotest', + dataset: 'segio_b2b_anon', + minified: false, + loggingLevel: 'NONE' + }; + + before(function (done) { + this.timeout(3000); + this.spy = sinon.spy(); + analytics.ready(this.spy); + analytics.initialize({ 'Evergage': settings }); + this.integration = analytics._integrations['Evergage']; + this.options = this.integration.options; + var stub = window._aaq.push; + when(function () { return window._aaq.push != stub; }, done); + }); + + describe('#name', function () { + it('Evergage', function () { + assert(this.integration.name == 'Evergage'); + }); + }); + + describe('#defaults', function () { + it('account', function () { + assert(this.integration.defaults.account === null); + }); + + it('dataset', function () { + assert(this.integration.defaults.dataset === null); + }); + }); + + describe('#initialize', function () { + it('should call ready', function () { + assert(this.spy.called); + }); + + it('should store options', function () { + assert(this.options.account == settings.account); + assert(this.options.dataset == settings.dataset); + }); + + it('should define a global tracker', function () { + assert('object' == typeof window.Evergage); + }); + + it('should show a message', function (done) { + when(function () { + return ( + jquery('.evergage-qtip').length && + jquery('.evergage-qtip').css('opacity') == 1 + ); + }, done); + }); + + it('should track a pageview with the canonical url'); + + after(function() { + window.Evergage.hideAllMessages(); + }); + }); + + describe('#identify', function () { + beforeEach(function () { + analytics.user().reset(); + this.stub = sinon.stub(window._aaq, 'push'); + }); + + afterEach(function () { + this.stub.restore(); + }); + + it('should send an id', function () { + analytics.identify('id'); + assert(this.stub.calledWith(['setUser', 'id'])); + }); + + it('should not send just traits', function () { + analytics.identify({ trait: true }); + assert(!this.stub.called); + }); + + it('should send an id and traits', function () { + analytics.identify('id', { trait: true }); + assert(this.stub.calledWith(['setUserField', 'trait', true, 'page'])); + assert(this.stub.calledWith(['setUser', 'id'])); + }); + + it('should send an email', function () { + analytics.identify('id', { email: 'name@example.com' }); + assert(this.stub.calledWith(['setUserField', 'userEmail', 'name@example.com', 'page'])); + assert(this.stub.calledWith(['setUser', 'id'])); + }); + + it('should send a name', function () { + analytics.identify('id', { name: 'name' }); + assert(this.stub.calledWith(['setUserField', 'userName', 'name', 'page'])); + assert(this.stub.calledWith(['setUser', 'id'])); + }); + }); + + describe('#group', function () { + beforeEach(function () { + this.stub = sinon.stub(window._aaq, 'push'); + analytics.group().reset(); + }); + + afterEach(function () { + this.stub.restore(); + }); + + it('should send an id', function () { + analytics.group('id'); + assert(this.stub.calledWith(['setCompany', 'id'])); + }); + + it('should not send just properties', function () { + analytics.group({ property: true }); + assert(!this.stub.called); + }); + + it('should send an id and properties', function () { + analytics.group('id', { property: true }); + assert(this.stub.calledWith(['setAccountField', 'property', true, 'page'])); + assert(this.stub.calledWith(['setCompany', 'id'])); + }); + }); + + describe('#track', function () { + beforeEach(function () { + this.stub = sinon.stub(window._aaq, 'push'); + }); + + afterEach(function () { + this.stub.restore(); + }); + + it('should send an event', function () { + analytics.track('event'); + assert(this.stub.calledWith(['trackAction', 'event', {}])); + }); + + it('should send an event and properties', function () { + analytics.track('event', { property: true }); + assert(this.stub.calledWith(['trackAction', 'event', { property: true }])); + }); + }); + + describe('#pageview', function () { + beforeEach(function () { + this.stub = sinon.stub(window.Evergage, 'init'); + }); + + afterEach(function () { + this.stub.restore(); + }); + + it('should call pageview', function () { + analytics.pageview(); + assert(this.stub.calledWith(true)); + }); + }); + +}); \ No newline at end of file