coveo.analytics
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -13,2 +13,3 @@ import { SearchEventRequest, SearchEventResponse, ClickEventRequest, ClickEventResponse, CustomEventRequest, CustomEventResponse, ViewEventRequest, ViewEventResponse, VisitResponse, HealthResponse } from './events'; | ||
endpoint?: string; | ||
version?: string; | ||
} | ||
@@ -18,2 +19,3 @@ export declare class Client implements AnalyticsClient { | ||
private token; | ||
private version; | ||
constructor(opts: ClientOptions); | ||
@@ -27,4 +29,5 @@ sendEvent(eventType: string, request: any): Promise<IResponse>; | ||
getHealth(): Promise<HealthResponse>; | ||
protected getRestEndpoint(): string; | ||
protected getHeaders(): any; | ||
} | ||
export default Client; |
"use strict"; | ||
exports.Version = 'v15'; | ||
exports.Endpoints = { | ||
default: 'https://usageanalytics.coveo.com/rest/' + exports.Version, | ||
production: 'https://usageanalytics.coveo.com/rest/' + exports.Version, | ||
dev: 'https://usageanalyticsdev.coveo.com/rest/' + exports.Version, | ||
staging: 'https://usageanalyticsstaging.coveo.com/rest/' + exports.Version | ||
default: 'https://usageanalytics.coveo.com', | ||
production: 'https://usageanalytics.coveo.com', | ||
dev: 'https://usageanalyticsdev.coveo.com', | ||
staging: 'https://usageanalyticsstaging.coveo.com' | ||
}; | ||
@@ -23,9 +23,11 @@ ; | ||
this.token = opts.token; | ||
this.version = opts.version || exports.Version; | ||
} | ||
Client.prototype.sendEvent = function (eventType, request) { | ||
return fetch(this.endpoint + "/analytics/" + eventType, { | ||
return fetch(this.getRestEndpoint() + "/analytics/" + eventType, { | ||
method: 'POST', | ||
headers: this.getHeaders(), | ||
mode: 'cors', | ||
body: JSON.stringify(request) | ||
body: JSON.stringify(request), | ||
credentials: 'include' | ||
}); | ||
@@ -49,9 +51,12 @@ }; | ||
Client.prototype.getVisit = function () { | ||
return fetch(this.endpoint + '/analytics/visit') | ||
return fetch(this.getRestEndpoint() + "/analytics/visit") | ||
.then(defaultResponseTransformer); | ||
}; | ||
Client.prototype.getHealth = function () { | ||
return fetch(this.endpoint + '/analytics/monitoring/health') | ||
return fetch(this.getRestEndpoint() + "/analytics/monitoring/health") | ||
.then(defaultResponseTransformer); | ||
}; | ||
Client.prototype.getRestEndpoint = function () { | ||
return this.endpoint + "/rest/" + this.version; | ||
}; | ||
Client.prototype.getHeaders = function () { | ||
@@ -58,0 +63,0 @@ var headers = { |
@@ -1,2 +0,2 @@ | ||
!function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){(function(t){"use strict";var r=n(1),o=n(10),i=n(11),s=t.coveoua||{};if(s.q&&s.q.forEach(function(t){return r["default"].apply(void 0,t)}),!s.disableAutoHistory){var a=new i.HistoryStore,u={name:"PageView",value:document.location.toString(),time:JSON.stringify(new Date),title:document.title};a.addElement(u)}t.coveoua=r["default"],t.coveoanalytics=o,Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=s}).call(e,function(){return this}())},function(t,e,n){"use strict";var r=n(2),o=n(9),i=function(){function t(){}return t.prototype.init=function(t,e){if("undefined"==typeof t)throw new Error("You must pass your token when you call 'init'");if("string"==typeof t)e=e||r.Endpoints["default"],this.client=new r.Client({token:t,endpoint:e});else{if("object"!=typeof t||"undefined"==typeof t.sendEvent)throw new Error("You must pass either your token or a valid object when you call 'init'");this.client=t}},t.prototype.send=function(t,e){if("undefined"==typeof this.client)throw new Error("You must call init before sending an event");switch(e=o["default"]({},{hash:window.location.hash},e),t){case"pageview":return void this.client.sendViewEvent({location:window.location.toString(),referrer:document.referrer,language:navigator.language,title:document.title,customData:e});default:throw new Error("Event type: '"+t+"' not implemented")}},t}();e.SimpleAPI=i;var s=new i;e.SimpleAnalytics=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=s[t];return r?r.apply(s,e):void 0},Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=e.SimpleAnalytics},function(t,e,n){(function(t){"use strict";function n(t){return t.json().then(function(e){return e.raw=t,e})}e.Version="v15",e.Endpoints={"default":"https://usageanalytics.coveo.com/rest/"+e.Version,production:"https://usageanalytics.coveo.com/rest/"+e.Version,dev:"https://usageanalyticsdev.coveo.com/rest/"+e.Version,staging:"https://usageanalyticsstaging.coveo.com/rest/"+e.Version};var r=function(){function r(t){if("undefined"==typeof t)throw new Error("You have to pass options to this constructor");this.endpoint=t.endpoint||e.Endpoints["default"],this.token=t.token}return r.prototype.sendEvent=function(e,n){return t(this.endpoint+"/analytics/"+e,{method:"POST",headers:this.getHeaders(),mode:"cors",body:JSON.stringify(n)})},r.prototype.sendSearchEvent=function(t){return this.sendEvent("search",t).then(n)},r.prototype.sendClickEvent=function(t){return this.sendEvent("click",t).then(n)},r.prototype.sendCustomEvent=function(t){return this.sendEvent("custom",t).then(n)},r.prototype.sendViewEvent=function(t){return""===t.referrer&&delete t.referrer,this.sendEvent("view",t).then(n)},r.prototype.getVisit=function(){return t(this.endpoint+"/analytics/visit").then(n)},r.prototype.getHealth=function(){return t(this.endpoint+"/analytics/monitoring/health").then(n)},r.prototype.getHeaders=function(){var t={"Content-Type":"application/json"};return this.token&&(t.Authorization="Bearer "+this.token),t},r}();e.Client=r,Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r}).call(e,n(3))},function(t,e,n){(function(e){!function(t){"use strict";function n(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function r(t){return"string"!=typeof t&&(t=String(t)),t}function o(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return v.iterable&&(e[Symbol.iterator]=function(){return e}),e}function i(t){this.map={},t instanceof i?t.forEach(function(t,e){this.append(e,t)},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function s(t){return t.bodyUsed?e.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function a(t){return new e(function(e,n){t.onload=function(){e(t.result)},t.onerror=function(){n(t.error)}})}function u(t){var e=new FileReader;return e.readAsArrayBuffer(t),a(e)}function c(t){var e=new FileReader;return e.readAsText(t),a(e)}function f(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t,"string"==typeof t)this._bodyText=t;else if(v.blob&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(v.formData&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(v.searchParams&&URLSearchParams.prototype.isPrototypeOf(t))this._bodyText=t.toString();else if(t){if(!v.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(t))throw new Error("unsupported BodyInit type")}else this._bodyText="";this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):v.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},v.blob?(this.blob=function(){var t=s(this);if(t)return t;if(this._bodyBlob)return e.resolve(this._bodyBlob);if(this._bodyFormData)throw new Error("could not read FormData body as blob");return e.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this.blob().then(u)},this.text=function(){var t=s(this);if(t)return t;if(this._bodyBlob)return c(this._bodyBlob);if(this._bodyFormData)throw new Error("could not read FormData body as text");return e.resolve(this._bodyText)}):this.text=function(){var t=s(this);return t?t:e.resolve(this._bodyText)},v.formData&&(this.formData=function(){return this.text().then(p)}),this.json=function(){return this.text().then(JSON.parse)},this}function l(t){var e=t.toUpperCase();return m.indexOf(e)>-1?e:t}function h(t,e){e=e||{};var n=e.body;if(h.prototype.isPrototypeOf(t)){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new i(t.headers)),this.method=t.method,this.mode=t.mode,n||(n=t._bodyInit,t.bodyUsed=!0)}else this.url=t;if(this.credentials=e.credentials||this.credentials||"omit",!e.headers&&this.headers||(this.headers=new i(e.headers)),this.method=l(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(n)}function p(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var n=t.split("="),r=n.shift().replace(/\+/g," "),o=n.join("=").replace(/\+/g," ");e.append(decodeURIComponent(r),decodeURIComponent(o))}}),e}function d(t){var e=new i,n=(t.getAllResponseHeaders()||"").trim().split("\n");return n.forEach(function(t){var n=t.trim().split(":"),r=n.shift().trim(),o=n.join(":").trim();e.append(r,o)}),e}function y(t,e){e||(e={}),this.type="default",this.status=e.status,this.ok=this.status>=200&&this.status<300,this.statusText=e.statusText,this.headers=e.headers instanceof i?e.headers:new i(e.headers),this.url=e.url||"",this._initBody(t)}if(!t.fetch){var v={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};i.prototype.append=function(t,e){t=n(t),e=r(e);var o=this.map[t];o||(o=[],this.map[t]=o),o.push(e)},i.prototype["delete"]=function(t){delete this.map[n(t)]},i.prototype.get=function(t){var e=this.map[n(t)];return e?e[0]:null},i.prototype.getAll=function(t){return this.map[n(t)]||[]},i.prototype.has=function(t){return this.map.hasOwnProperty(n(t))},i.prototype.set=function(t,e){this.map[n(t)]=[r(e)]},i.prototype.forEach=function(t,e){Object.getOwnPropertyNames(this.map).forEach(function(n){this.map[n].forEach(function(r){t.call(e,r,n,this)},this)},this)},i.prototype.keys=function(){var t=[];return this.forEach(function(e,n){t.push(n)}),o(t)},i.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),o(t)},i.prototype.entries=function(){var t=[];return this.forEach(function(e,n){t.push([n,e])}),o(t)},v.iterable&&(i.prototype[Symbol.iterator]=i.prototype.entries);var m=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];h.prototype.clone=function(){return new h(this)},f.call(h.prototype),f.call(y.prototype),y.prototype.clone=function(){return new y(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new i(this.headers),url:this.url})},y.error=function(){var t=new y(null,{status:0,statusText:""});return t.type="error",t};var w=[301,302,303,307,308];y.redirect=function(t,e){if(-1===w.indexOf(e))throw new RangeError("Invalid status code");return new y(null,{status:e,headers:{location:t}})},t.Headers=i,t.Request=h,t.Response=y,t.fetch=function(t,n){return new e(function(e,r){function o(){return"responseURL"in s?s.responseURL:/^X-Request-URL:/m.test(s.getAllResponseHeaders())?s.getResponseHeader("X-Request-URL"):void 0}var i;i=h.prototype.isPrototypeOf(t)&&!n?t:new h(t,n);var s=new XMLHttpRequest;s.onload=function(){var t={status:s.status,statusText:s.statusText,headers:d(s),url:o()},n="response"in s?s.response:s.responseText;e(new y(n,t))},s.onerror=function(){r(new TypeError("Network request failed"))},s.ontimeout=function(){r(new TypeError("Network request failed"))},s.open(i.method,i.url,!0),"include"===i.credentials&&(s.withCredentials=!0),"responseType"in s&&v.blob&&(s.responseType="blob"),i.headers.forEach(function(t,e){s.setRequestHeader(e,t)}),s.send("undefined"==typeof i._bodyInit?null:i._bodyInit)})},t.fetch.polyfill=!0}}("undefined"!=typeof self?self:this),t.exports=self.fetch}).call(e,n(4))},function(t,e,n){var r;(function(t,o,i){/*! | ||
!function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){(function(t){"use strict";var r=n(1),o=n(11),i=n(12),s=t.coveoua||{};if(s.q&&s.q.forEach(function(t){return r["default"].apply(void 0,t)}),!s.disableAutoHistory){var a=new i.HistoryStore,u={name:"PageView",value:document.location.toString(),time:JSON.stringify(new Date),title:document.title};a.addElement(u)}t.coveoua=r["default"],t.coveoanalytics=o,Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=s}).call(e,function(){return this}())},function(t,e,n){"use strict";var r=n(2),o=n(9),i=n(10),s=function(){function t(){}return t.prototype.init=function(t,e){if("undefined"==typeof t)throw new Error("You must pass your token when you call 'init'");if("string"==typeof t)e=e||r.Endpoints["default"],this.client=new r.Client({token:t,endpoint:e});else{if("object"!=typeof t||"undefined"==typeof t.sendEvent)throw new Error("You must pass either your token or a valid object when you call 'init'");this.client=t}},t.prototype.send=function(t,e){if("undefined"==typeof this.client)throw new Error("You must call init before sending an event");switch(e=o["default"]({},{hash:window.location.hash},e),t){case"pageview":return void this.client.sendViewEvent({location:window.location.toString(),referrer:document.referrer,language:navigator.language,title:document.title,contentIdKey:i.popFromObject(e,"contentIdKey"),contentIdValue:i.popFromObject(e,"contentIdValue"),contentType:i.popFromObject(e,"contentType"),customData:e});default:throw new Error("Event type: '"+t+"' not implemented")}},t}();e.SimpleAPI=s;var a=new s;e.SimpleAnalytics=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=a[t];if(r)return r.apply(a,e)},Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=e.SimpleAnalytics},function(t,e,n){(function(t){"use strict";function n(t){return t.json().then(function(e){return e.raw=t,e})}e.Version="v15",e.Endpoints={"default":"https://usageanalytics.coveo.com",production:"https://usageanalytics.coveo.com",dev:"https://usageanalyticsdev.coveo.com",staging:"https://usageanalyticsstaging.coveo.com"};var r=function(){function r(t){if("undefined"==typeof t)throw new Error("You have to pass options to this constructor");this.endpoint=t.endpoint||e.Endpoints["default"],this.token=t.token,this.version=t.version||e.Version}return r.prototype.sendEvent=function(e,n){return t(this.getRestEndpoint()+"/analytics/"+e,{method:"POST",headers:this.getHeaders(),mode:"cors",body:JSON.stringify(n),credentials:"include"})},r.prototype.sendSearchEvent=function(t){return this.sendEvent("search",t).then(n)},r.prototype.sendClickEvent=function(t){return this.sendEvent("click",t).then(n)},r.prototype.sendCustomEvent=function(t){return this.sendEvent("custom",t).then(n)},r.prototype.sendViewEvent=function(t){return""===t.referrer&&delete t.referrer,this.sendEvent("view",t).then(n)},r.prototype.getVisit=function(){return t(this.getRestEndpoint()+"/analytics/visit").then(n)},r.prototype.getHealth=function(){return t(this.getRestEndpoint()+"/analytics/monitoring/health").then(n)},r.prototype.getRestEndpoint=function(){return this.endpoint+"/rest/"+this.version},r.prototype.getHeaders=function(){var t={"Content-Type":"application/json"};return this.token&&(t.Authorization="Bearer "+this.token),t},r}();e.Client=r,Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r}).call(e,n(3))},function(t,e,n){(function(e){!function(t){"use strict";function n(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function r(t){return"string"!=typeof t&&(t=String(t)),t}function o(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return v.iterable&&(e[Symbol.iterator]=function(){return e}),e}function i(t){this.map={},t instanceof i?t.forEach(function(t,e){this.append(e,t)},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function s(t){return t.bodyUsed?e.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function a(t){return new e(function(e,n){t.onload=function(){e(t.result)},t.onerror=function(){n(t.error)}})}function u(t){var e=new FileReader;return e.readAsArrayBuffer(t),a(e)}function c(t){var e=new FileReader;return e.readAsText(t),a(e)}function f(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t,"string"==typeof t)this._bodyText=t;else if(v.blob&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(v.formData&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(v.searchParams&&URLSearchParams.prototype.isPrototypeOf(t))this._bodyText=t.toString();else if(t){if(!v.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(t))throw new Error("unsupported BodyInit type")}else this._bodyText="";this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):v.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},v.blob?(this.blob=function(){var t=s(this);if(t)return t;if(this._bodyBlob)return e.resolve(this._bodyBlob);if(this._bodyFormData)throw new Error("could not read FormData body as blob");return e.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this.blob().then(u)},this.text=function(){var t=s(this);if(t)return t;if(this._bodyBlob)return c(this._bodyBlob);if(this._bodyFormData)throw new Error("could not read FormData body as text");return e.resolve(this._bodyText)}):this.text=function(){var t=s(this);return t?t:e.resolve(this._bodyText)},v.formData&&(this.formData=function(){return this.text().then(p)}),this.json=function(){return this.text().then(JSON.parse)},this}function l(t){var e=t.toUpperCase();return m.indexOf(e)>-1?e:t}function h(t,e){e=e||{};var n=e.body;if(h.prototype.isPrototypeOf(t)){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new i(t.headers)),this.method=t.method,this.mode=t.mode,n||(n=t._bodyInit,t.bodyUsed=!0)}else this.url=t;if(this.credentials=e.credentials||this.credentials||"omit",!e.headers&&this.headers||(this.headers=new i(e.headers)),this.method=l(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(n)}function p(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var n=t.split("="),r=n.shift().replace(/\+/g," "),o=n.join("=").replace(/\+/g," ");e.append(decodeURIComponent(r),decodeURIComponent(o))}}),e}function d(t){var e=new i,n=(t.getAllResponseHeaders()||"").trim().split("\n");return n.forEach(function(t){var n=t.trim().split(":"),r=n.shift().trim(),o=n.join(":").trim();e.append(r,o)}),e}function y(t,e){e||(e={}),this.type="default",this.status=e.status,this.ok=this.status>=200&&this.status<300,this.statusText=e.statusText,this.headers=e.headers instanceof i?e.headers:new i(e.headers),this.url=e.url||"",this._initBody(t)}if(!t.fetch){var v={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};i.prototype.append=function(t,e){t=n(t),e=r(e);var o=this.map[t];o||(o=[],this.map[t]=o),o.push(e)},i.prototype["delete"]=function(t){delete this.map[n(t)]},i.prototype.get=function(t){var e=this.map[n(t)];return e?e[0]:null},i.prototype.getAll=function(t){return this.map[n(t)]||[]},i.prototype.has=function(t){return this.map.hasOwnProperty(n(t))},i.prototype.set=function(t,e){this.map[n(t)]=[r(e)]},i.prototype.forEach=function(t,e){Object.getOwnPropertyNames(this.map).forEach(function(n){this.map[n].forEach(function(r){t.call(e,r,n,this)},this)},this)},i.prototype.keys=function(){var t=[];return this.forEach(function(e,n){t.push(n)}),o(t)},i.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),o(t)},i.prototype.entries=function(){var t=[];return this.forEach(function(e,n){t.push([n,e])}),o(t)},v.iterable&&(i.prototype[Symbol.iterator]=i.prototype.entries);var m=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];h.prototype.clone=function(){return new h(this)},f.call(h.prototype),f.call(y.prototype),y.prototype.clone=function(){return new y(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new i(this.headers),url:this.url})},y.error=function(){var t=new y(null,{status:0,statusText:""});return t.type="error",t};var w=[301,302,303,307,308];y.redirect=function(t,e){if(w.indexOf(e)===-1)throw new RangeError("Invalid status code");return new y(null,{status:e,headers:{location:t}})},t.Headers=i,t.Request=h,t.Response=y,t.fetch=function(t,n){return new e(function(e,r){function o(){return"responseURL"in s?s.responseURL:/^X-Request-URL:/m.test(s.getAllResponseHeaders())?s.getResponseHeader("X-Request-URL"):void 0}var i;i=h.prototype.isPrototypeOf(t)&&!n?t:new h(t,n);var s=new XMLHttpRequest;s.onload=function(){var t={status:s.status,statusText:s.statusText,headers:d(s),url:o()},n="response"in s?s.response:s.responseText;e(new y(n,t))},s.onerror=function(){r(new TypeError("Network request failed"))},s.ontimeout=function(){r(new TypeError("Network request failed"))},s.open(i.method,i.url,!0),"include"===i.credentials&&(s.withCredentials=!0),"responseType"in s&&v.blob&&(s.responseType="blob"),i.headers.forEach(function(t,e){s.setRequestHeader(e,t)}),s.send("undefined"==typeof i._bodyInit?null:i._bodyInit)})},t.fetch.polyfill=!0}}("undefined"!=typeof self?self:this),t.exports=self.fetch}).call(e,n(4))},function(t,e,n){var r;(function(t,o,i){/*! | ||
* @overview es6-promise - a tiny implementation of Promises/A+. | ||
@@ -8,3 +8,3 @@ * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) | ||
*/ | ||
(function(){"use strict";function s(t){return"function"==typeof t||"object"==typeof t&&null!==t}function a(t){return"function"==typeof t}function u(t){W=t}function c(t){tt=t}function f(){return function(){t.nextTick(y)}}function l(){return function(){z(y)}}function h(){var t=0,e=new rt(y),n=document.createTextNode("");return e.observe(n,{characterData:!0}),function(){n.data=t=++t%2}}function p(){var t=new MessageChannel;return t.port1.onmessage=y,function(){t.port2.postMessage(0)}}function d(){return function(){setTimeout(y,1)}}function y(){for(var t=0;Z>t;t+=2){var e=st[t],n=st[t+1];e(n),st[t]=void 0,st[t+1]=void 0}Z=0}function v(){try{var t=n(7);return z=t.runOnLoop||t.runOnContext,l()}catch(e){return d()}}function m(t,e){var n=this,r=new this.constructor(b);void 0===r[ct]&&N(r);var o=n._state;if(o){var i=arguments[o-1];tt(function(){H(o,r,i,n._result)})}else R(n,r,t,e);return r}function w(t){var e=this;if(t&&"object"==typeof t&&t.constructor===e)return t;var n=new e(b);return A(n,t),n}function b(){}function g(){return new TypeError("You cannot resolve a promise with itself")}function _(){return new TypeError("A promises callback cannot return that same promise.")}function E(t){try{return t.then}catch(e){return pt.error=e,pt}}function S(t,e,n,r){try{t.call(e,n,r)}catch(o){return o}}function T(t,e,n){tt(function(t){var r=!1,o=S(n,e,function(n){r||(r=!0,e!==n?A(t,n):k(t,n))},function(e){r||(r=!0,j(t,e))},"Settle: "+(t._label||" unknown promise"));!r&&o&&(r=!0,j(t,o))},t)}function O(t,e){e._state===lt?k(t,e._result):e._state===ht?j(t,e._result):R(e,void 0,function(e){A(t,e)},function(e){j(t,e)})}function x(t,e,n){e.constructor===t.constructor&&n===at&&constructor.resolve===ut?O(t,e):n===pt?j(t,pt.error):void 0===n?k(t,e):a(n)?T(t,e,n):k(t,e)}function A(t,e){t===e?j(t,g()):s(e)?x(t,e,E(e)):k(t,e)}function P(t){t._onerror&&t._onerror(t._result),B(t)}function k(t,e){t._state===ft&&(t._result=e,t._state=lt,0!==t._subscribers.length&&tt(B,t))}function j(t,e){t._state===ft&&(t._state=ht,t._result=e,tt(P,t))}function R(t,e,n,r){var o=t._subscribers,i=o.length;t._onerror=null,o[i]=e,o[i+lt]=n,o[i+ht]=r,0===i&&t._state&&tt(B,t)}function B(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var r,o,i=t._result,s=0;s<e.length;s+=3)r=e[s],o=e[s+n],r?H(n,r,o,i):o(i);t._subscribers.length=0}}function C(){this.error=null}function I(t,e){try{return t(e)}catch(n){return dt.error=n,dt}}function H(t,e,n,r){var o,i,s,u,c=a(n);if(c){if(o=I(n,r),o===dt?(u=!0,i=o.error,o=null):s=!0,e===o)return void j(e,_())}else o=r,s=!0;e._state!==ft||(c&&s?A(e,o):u?j(e,i):t===lt?k(e,o):t===ht&&j(e,o))}function D(t,e){try{e(function(e){A(t,e)},function(e){j(t,e)})}catch(n){j(t,n)}}function M(){return yt++}function N(t){t[ct]=yt++,t._state=void 0,t._result=void 0,t._subscribers=[]}function U(t){return new gt(this,t).promise}function L(t){var e=this;return new e(Q(t)?function(n,r){for(var o=t.length,i=0;o>i;i++)e.resolve(t[i]).then(n,r)}:function(t,e){e(new TypeError("You must pass an array to race."))})}function F(t){var e=this,n=new e(b);return j(n,t),n}function Y(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function q(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function V(t){this[ct]=M(),this._result=this._state=void 0,this._subscribers=[],b!==t&&("function"!=typeof t&&Y(),this instanceof V?D(this,t):q())}function G(t,e){this._instanceConstructor=t,this.promise=new t(b),this.promise[ct]||N(this.promise),Q(e)?(this._input=e,this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?k(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&k(this.promise,this._result))):j(this.promise,J())}function J(){return new Error("Array Methods must be provided an Array")}function K(){var t;if("undefined"!=typeof o)t=o;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var n=t.Promise;n&&"[object Promise]"===Object.prototype.toString.call(n.resolve())&&!n.cast||(t.Promise=bt)}var X;X=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var z,W,$,Q=X,Z=0,tt=function(t,e){st[Z]=t,st[Z+1]=e,Z+=2,2===Z&&(W?W(y):$())},et="undefined"!=typeof window?window:void 0,nt=et||{},rt=nt.MutationObserver||nt.WebKitMutationObserver,ot="undefined"==typeof self&&"undefined"!=typeof t&&"[object process]"==={}.toString.call(t),it="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,st=new Array(1e3);$=ot?f():rt?h():it?p():void 0===et?v():d();var at=m,ut=w,ct=Math.random().toString(36).substring(16),ft=void 0,lt=1,ht=2,pt=new C,dt=new C,yt=0,vt=U,mt=L,wt=F,bt=V;V.all=vt,V.race=mt,V.resolve=ut,V.reject=wt,V._setScheduler=u,V._setAsap=c,V._asap=tt,V.prototype={constructor:V,then:at,"catch":function(t){return this.then(null,t)}};var gt=G;G.prototype._enumerate=function(){for(var t=this.length,e=this._input,n=0;this._state===ft&&t>n;n++)this._eachEntry(e[n],n)},G.prototype._eachEntry=function(t,e){var n=this._instanceConstructor,r=n.resolve;if(r===ut){var o=E(t);if(o===at&&t._state!==ft)this._settledAt(t._state,e,t._result);else if("function"!=typeof o)this._remaining--,this._result[e]=t;else if(n===bt){var i=new n(b);x(i,t,o),this._willSettleAt(i,e)}else this._willSettleAt(new n(function(e){e(t)}),e)}else this._willSettleAt(r(t),e)},G.prototype._settledAt=function(t,e,n){var r=this.promise;r._state===ft&&(this._remaining--,t===ht?j(r,n):this._result[e]=n),0===this._remaining&&k(r,this._result)},G.prototype._willSettleAt=function(t,e){var n=this;R(t,void 0,function(t){n._settledAt(lt,e,t)},function(t){n._settledAt(ht,e,t)})};var _t=K,Et={Promise:bt,polyfill:_t};n(8).amd?(r=function(){return Et}.call(e,n,e,i),!(void 0!==r&&(i.exports=r))):"undefined"!=typeof i&&i.exports?i.exports=Et:"undefined"!=typeof this&&(this.ES6Promise=Et),_t()}).call(this)}).call(e,n(5),function(){return this}(),n(6)(t))},function(t,e){function n(){c&&s&&(c=!1,s.length?u=s.concat(u):f=-1,u.length&&r())}function r(){if(!c){var t=setTimeout(n);c=!0;for(var e=u.length;e;){for(s=u,u=[];++f<e;)s&&s[f].run();f=-1,e=u.length}s=null,c=!1,clearTimeout(t)}}function o(t,e){this.fun=t,this.array=e}function i(){}var s,a=t.exports={},u=[],c=!1,f=-1;a.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];u.push(new o(t,e)),1!==u.length||c||setTimeout(r,0)},o.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=i,a.addListener=i,a.once=i,a.off=i,a.removeListener=i,a.removeAllListeners=i,a.emit=i,a.binding=function(t){throw new Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(t){throw new Error("process.chdir is not supported")},a.umask=function(){return 0}},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children=[],t.webpackPolyfill=1),t}},function(t,e){},function(t,e){t.exports=function(){throw new Error("define cannot be used indirect")}},function(t,e){"use strict";var n=Object.prototype.hasOwnProperty,r=Object.getOwnPropertySymbols,o=Object.prototype.propertyIsEnumerable,i=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];if(void 0===t||null===t)throw new TypeError("Cannot convert undefined or null to object");var s=Object(t);return e.forEach(function(t){var e=Object(t);for(var i in e)n.call(e,i)&&(s[i]=e[i]);if(r){var a=r(e);a.forEach(function(t){o.call(e,t)&&(s[t]=e[t])})}}),s};e.assign="function"==typeof Object.assign?Object.assign:i,Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=e.assign},function(t,e,n){"use strict";var r=n(2);e.analytics=r;var o=n(1);e.SimpleAnalytics=o;var i=n(11);e.history=i;var s=n(15);e.donottrack=s},function(t,e,n){"use strict";var r=n(12);e.STORE_KEY="__coveo.analytics.history",e.MAX_NUMBER_OF_HISTORY_ELEMENTS=20;var o=function(){function t(t){this.store=t||r.getAvailableStorage()}return t.prototype.addElement=function(t){null!=this.getHistory()?this.setHistory([t].concat(this.getHistory())):this.setHistory([t])},t.prototype.getHistory=function(){try{return JSON.parse(this.store.getItem(e.STORE_KEY))}catch(t){return[]}},t.prototype.setHistory=function(t){try{this.store.setItem(e.STORE_KEY,JSON.stringify(t.slice(0,e.MAX_NUMBER_OF_HISTORY_ELEMENTS)))}catch(n){}},t.prototype.clear=function(){try{this.store.removeItem(e.STORE_KEY)}catch(t){}},t}();e.HistoryStore=o,Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=o},function(t,e,n){"use strict";function r(){return o.hasCookieStorage()?new s:o.hasSessionStorage()?sessionStorage:o.hasLocalStorage()?localStorage:new a}var o=n(13),i=n(14);e.getAvailableStorage=r;var s=function(){function t(){}return t.prototype.getItem=function(t){return i.Cookie.get(t)},t.prototype.removeItem=function(t){i.Cookie.erase(t)},t.prototype.setItem=function(t,e){i.Cookie.set(t,e)},t}();e.CookieStorage=s;var a=function(){function t(){}return t.prototype.getItem=function(t){return""},t.prototype.removeItem=function(t){},t.prototype.setItem=function(t,e){},t}();e.NullStorage=a},function(t,e){"use strict";function n(){try{return"localStorage"in window&&null!==window.localStorage}catch(t){return!1}}function r(){try{return"sessionStorage"in window&&null!==window.sessionStorage}catch(t){return!1}}function o(){return navigator.cookieEnabled}e.hasLocalStorage=n,e.hasSessionStorage=r,e.hasCookieStorage=o},function(t,e){"use strict";var n=function(){function t(){}return t.set=function(e,n,r){var o,i,s,a,u;r?(s=new Date,s.setTime(s.getTime()+r),a="; expires="+s.toGMTString()):a="",u=location.hostname,-1===u.indexOf(".")?document.cookie=e+"="+n+a+"; path=/":(i=u.split("."),i.shift(),o="."+i.join("."),document.cookie=e+"="+n+a+"; path=/; domain="+o,null!=t.get(e)&&t.get(e)==n||(o="."+u,document.cookie=e+"="+n+a+"; path=/; domain="+o))},t.get=function(t){for(var e=t+"=",n=document.cookie.split(";"),r=0;r<n.length;r++){var o=n[r];if(o=o.replace(/^\s+/,""),0==o.indexOf(e))return o.substring(e.length,o.length)}return null},t.erase=function(e){t.set(e,"",-1)},t}();e.Cookie=n},function(t,e){"use strict";e.doNotTrack=[!0,"yes","1"].indexOf(navigator.doNotTrack||navigator.msDoNotTrack||window.doNotTrack),Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=e.doNotTrack}]); | ||
(function(){"use strict";function s(t){return"function"==typeof t||"object"==typeof t&&null!==t}function a(t){return"function"==typeof t}function u(t){W=t}function c(t){tt=t}function f(){return function(){t.nextTick(y)}}function l(){return function(){z(y)}}function h(){var t=0,e=new rt(y),n=document.createTextNode("");return e.observe(n,{characterData:!0}),function(){n.data=t=++t%2}}function p(){var t=new MessageChannel;return t.port1.onmessage=y,function(){t.port2.postMessage(0)}}function d(){return function(){setTimeout(y,1)}}function y(){for(var t=0;t<Z;t+=2){var e=st[t],n=st[t+1];e(n),st[t]=void 0,st[t+1]=void 0}Z=0}function v(){try{var t=n(7);return z=t.runOnLoop||t.runOnContext,l()}catch(e){return d()}}function m(t,e){var n=this,r=new this.constructor(b);void 0===r[ct]&&M(r);var o=n._state;if(o){var i=arguments[o-1];tt(function(){H(o,r,i,n._result)})}else R(n,r,t,e);return r}function w(t){var e=this;if(t&&"object"==typeof t&&t.constructor===e)return t;var n=new e(b);return A(n,t),n}function b(){}function g(){return new TypeError("You cannot resolve a promise with itself")}function _(){return new TypeError("A promises callback cannot return that same promise.")}function E(t){try{return t.then}catch(e){return pt.error=e,pt}}function S(t,e,n,r){try{t.call(e,n,r)}catch(o){return o}}function T(t,e,n){tt(function(t){var r=!1,o=S(n,e,function(n){r||(r=!0,e!==n?A(t,n):P(t,n))},function(e){r||(r=!0,k(t,e))},"Settle: "+(t._label||" unknown promise"));!r&&o&&(r=!0,k(t,o))},t)}function O(t,e){e._state===lt?P(t,e._result):e._state===ht?k(t,e._result):R(e,void 0,function(e){A(t,e)},function(e){k(t,e)})}function x(t,e,n){e.constructor===t.constructor&&n===at&&constructor.resolve===ut?O(t,e):n===pt?k(t,pt.error):void 0===n?P(t,e):a(n)?T(t,e,n):P(t,e)}function A(t,e){t===e?k(t,g()):s(e)?x(t,e,E(e)):P(t,e)}function j(t){t._onerror&&t._onerror(t._result),I(t)}function P(t,e){t._state===ft&&(t._result=e,t._state=lt,0!==t._subscribers.length&&tt(I,t))}function k(t,e){t._state===ft&&(t._state=ht,t._result=e,tt(j,t))}function R(t,e,n,r){var o=t._subscribers,i=o.length;t._onerror=null,o[i]=e,o[i+lt]=n,o[i+ht]=r,0===i&&t._state&&tt(I,t)}function I(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var r,o,i=t._result,s=0;s<e.length;s+=3)r=e[s],o=e[s+n],r?H(n,r,o,i):o(i);t._subscribers.length=0}}function B(){this.error=null}function C(t,e){try{return t(e)}catch(n){return dt.error=n,dt}}function H(t,e,n,r){var o,i,s,u,c=a(n);if(c){if(o=C(n,r),o===dt?(u=!0,i=o.error,o=null):s=!0,e===o)return void k(e,_())}else o=r,s=!0;e._state!==ft||(c&&s?A(e,o):u?k(e,i):t===lt?P(e,o):t===ht&&k(e,o))}function D(t,e){try{e(function(e){A(t,e)},function(e){k(t,e)})}catch(n){k(t,n)}}function F(){return yt++}function M(t){t[ct]=yt++,t._state=void 0,t._result=void 0,t._subscribers=[]}function N(t){return new gt(this,t).promise}function U(t){var e=this;return new e(Q(t)?function(n,r){for(var o=t.length,i=0;i<o;i++)e.resolve(t[i]).then(n,r)}:function(t,e){e(new TypeError("You must pass an array to race."))})}function L(t){var e=this,n=new e(b);return k(n,t),n}function Y(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function q(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function V(t){this[ct]=F(),this._result=this._state=void 0,this._subscribers=[],b!==t&&("function"!=typeof t&&Y(),this instanceof V?D(this,t):q())}function K(t,e){this._instanceConstructor=t,this.promise=new t(b),this.promise[ct]||M(this.promise),Q(e)?(this._input=e,this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?P(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&P(this.promise,this._result))):k(this.promise,G())}function G(){return new Error("Array Methods must be provided an Array")}function J(){var t;if("undefined"!=typeof o)t=o;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var n=t.Promise;n&&"[object Promise]"===Object.prototype.toString.call(n.resolve())&&!n.cast||(t.Promise=bt)}var X;X=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var z,W,$,Q=X,Z=0,tt=function(t,e){st[Z]=t,st[Z+1]=e,Z+=2,2===Z&&(W?W(y):$())},et="undefined"!=typeof window?window:void 0,nt=et||{},rt=nt.MutationObserver||nt.WebKitMutationObserver,ot="undefined"==typeof self&&"undefined"!=typeof t&&"[object process]"==={}.toString.call(t),it="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,st=new Array(1e3);$=ot?f():rt?h():it?p():void 0===et?v():d();var at=m,ut=w,ct=Math.random().toString(36).substring(16),ft=void 0,lt=1,ht=2,pt=new B,dt=new B,yt=0,vt=N,mt=U,wt=L,bt=V;V.all=vt,V.race=mt,V.resolve=ut,V.reject=wt,V._setScheduler=u,V._setAsap=c,V._asap=tt,V.prototype={constructor:V,then:at,"catch":function(t){return this.then(null,t)}};var gt=K;K.prototype._enumerate=function(){for(var t=this.length,e=this._input,n=0;this._state===ft&&n<t;n++)this._eachEntry(e[n],n)},K.prototype._eachEntry=function(t,e){var n=this._instanceConstructor,r=n.resolve;if(r===ut){var o=E(t);if(o===at&&t._state!==ft)this._settledAt(t._state,e,t._result);else if("function"!=typeof o)this._remaining--,this._result[e]=t;else if(n===bt){var i=new n(b);x(i,t,o),this._willSettleAt(i,e)}else this._willSettleAt(new n(function(e){e(t)}),e)}else this._willSettleAt(r(t),e)},K.prototype._settledAt=function(t,e,n){var r=this.promise;r._state===ft&&(this._remaining--,t===ht?k(r,n):this._result[e]=n),0===this._remaining&&P(r,this._result)},K.prototype._willSettleAt=function(t,e){var n=this;R(t,void 0,function(t){n._settledAt(lt,e,t)},function(t){n._settledAt(ht,e,t)})};var _t=J,Et={Promise:bt,polyfill:_t};n(8).amd?(r=function(){return Et}.call(e,n,e,i),!(void 0!==r&&(i.exports=r))):"undefined"!=typeof i&&i.exports?i.exports=Et:"undefined"!=typeof this&&(this.ES6Promise=Et),_t()}).call(this)}).call(e,n(5),function(){return this}(),n(6)(t))},function(t,e){function n(){l&&c&&(l=!1,c.length?f=c.concat(f):h=-1,f.length&&r())}function r(){if(!l){var t=s(n);l=!0;for(var e=f.length;e;){for(c=f,f=[];++h<e;)c&&c[h].run();h=-1,e=f.length}c=null,l=!1,a(t)}}function o(t,e){this.fun=t,this.array=e}function i(){}var s,a,u=t.exports={};!function(){try{s=setTimeout}catch(t){s=function(){throw new Error("setTimeout is not defined")}}try{a=clearTimeout}catch(t){a=function(){throw new Error("clearTimeout is not defined")}}}();var c,f=[],l=!1,h=-1;u.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];f.push(new o(t,e)),1!==f.length||l||s(r,0)},o.prototype.run=function(){this.fun.apply(null,this.array)},u.title="browser",u.browser=!0,u.env={},u.argv=[],u.version="",u.versions={},u.on=i,u.addListener=i,u.once=i,u.off=i,u.removeListener=i,u.removeAllListeners=i,u.emit=i,u.binding=function(t){throw new Error("process.binding is not supported")},u.cwd=function(){return"/"},u.chdir=function(t){throw new Error("process.chdir is not supported")},u.umask=function(){return 0}},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children=[],t.webpackPolyfill=1),t}},function(t,e){},function(t,e){t.exports=function(){throw new Error("define cannot be used indirect")}},function(t,e){"use strict";var n=Object.prototype.hasOwnProperty,r=Object.getOwnPropertySymbols,o=Object.prototype.propertyIsEnumerable,i=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];if(void 0===t||null===t)throw new TypeError("Cannot convert undefined or null to object");var s=Object(t);return e.forEach(function(t){var e=Object(t);for(var i in e)n.call(e,i)&&(s[i]=e[i]);if(r){var a=r(e);a.forEach(function(t){o.call(e,t)&&(s[t]=e[t])})}}),s};e.assign="function"==typeof Object.assign?Object.assign:i,Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=e.assign},function(t,e){"use strict";function n(t,e){if(t){var n=t[e];return delete t[e],n}}e.popFromObject=n},function(t,e,n){"use strict";var r=n(2);e.analytics=r;var o=n(1);e.SimpleAnalytics=o;var i=n(12);e.history=i;var s=n(16);e.donottrack=s},function(t,e,n){"use strict";var r=n(13);e.STORE_KEY="__coveo.analytics.history",e.MAX_NUMBER_OF_HISTORY_ELEMENTS=20;var o=function(){function t(t){this.store=t||r.getAvailableStorage()}return t.prototype.addElement=function(t){null!=this.getHistory()?this.setHistory([t].concat(this.getHistory())):this.setHistory([t])},t.prototype.getHistory=function(){try{return JSON.parse(this.store.getItem(e.STORE_KEY))}catch(t){return[]}},t.prototype.setHistory=function(t){try{this.store.setItem(e.STORE_KEY,JSON.stringify(t.slice(0,e.MAX_NUMBER_OF_HISTORY_ELEMENTS)))}catch(n){}},t.prototype.clear=function(){try{this.store.removeItem(e.STORE_KEY)}catch(t){}},t}();e.HistoryStore=o,Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=o},function(t,e,n){"use strict";function r(){return o.hasCookieStorage()?new s:o.hasSessionStorage()?sessionStorage:o.hasLocalStorage()?localStorage:new a}var o=n(14),i=n(15);e.getAvailableStorage=r;var s=function(){function t(){}return t.prototype.getItem=function(t){return i.Cookie.get(t)},t.prototype.removeItem=function(t){i.Cookie.erase(t)},t.prototype.setItem=function(t,e){i.Cookie.set(t,e)},t}();e.CookieStorage=s;var a=function(){function t(){}return t.prototype.getItem=function(t){return""},t.prototype.removeItem=function(t){},t.prototype.setItem=function(t,e){},t}();e.NullStorage=a},function(t,e){"use strict";function n(){try{return"localStorage"in window&&null!==window.localStorage}catch(t){return!1}}function r(){try{return"sessionStorage"in window&&null!==window.sessionStorage}catch(t){return!1}}function o(){return navigator.cookieEnabled}e.hasLocalStorage=n,e.hasSessionStorage=r,e.hasCookieStorage=o},function(t,e){"use strict";var n=function(){function t(){}return t.set=function(e,n,r){var o,i,s,a,u;r?(s=new Date,s.setTime(s.getTime()+r),a="; expires="+s.toGMTString()):a="",u=location.hostname,u.indexOf(".")===-1?document.cookie=e+"="+n+a+"; path=/":(i=u.split("."),i.shift(),o="."+i.join("."),document.cookie=e+"="+n+a+"; path=/; domain="+o,null!=t.get(e)&&t.get(e)==n||(o="."+u,document.cookie=e+"="+n+a+"; path=/; domain="+o))},t.get=function(t){for(var e=t+"=",n=document.cookie.split(";"),r=0;r<n.length;r++){var o=n[r];if(o=o.replace(/^\s+/,""),0==o.indexOf(e))return o.substring(e.length,o.length)}return null},t.erase=function(e){t.set(e,"",-1)},t}();e.Cookie=n},function(t,e){"use strict";e.doNotTrack=[!0,"yes","1"].indexOf(navigator.doNotTrack||navigator.msDoNotTrack||window.doNotTrack),Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=e.doNotTrack}]); | ||
//# sourceMappingURL=coveoua.js.map |
@@ -53,2 +53,5 @@ export interface SearchDocument { | ||
title?: string; | ||
contentIdKey?: string; | ||
contentIdValue?: string; | ||
contentType?: string; | ||
} | ||
@@ -55,0 +58,0 @@ export interface DefaultEventResponse { |
"use strict"; | ||
var analytics = require('./analytics'); | ||
var objectassign_1 = require('./objectassign'); | ||
var utils_1 = require('./utils'); | ||
var SimpleAPI = (function () { | ||
@@ -39,2 +40,5 @@ function SimpleAPI() { | ||
title: document.title, | ||
contentIdKey: utils_1.popFromObject(customData, 'contentIdKey'), | ||
contentIdValue: utils_1.popFromObject(customData, 'contentIdValue'), | ||
contentType: utils_1.popFromObject(customData, 'contentType'), | ||
customData: customData | ||
@@ -41,0 +45,0 @@ }); |
{ | ||
"name": "coveo.analytics", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "📈 Coveo analytics client (node and browser compatible) ", | ||
@@ -23,3 +23,3 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"ava": "0.15.1", | ||
"ava": "0.15.2", | ||
"body-parser": "1.15.1", | ||
@@ -29,12 +29,12 @@ "coveralls": "2.11.9", | ||
"exports-loader": "0.6.3", | ||
"express": "4.13.4", | ||
"express": "4.14.0", | ||
"isomorphic-fetch": "2.2.1", | ||
"jsdom": "9.2.0", | ||
"nyc": "6.4.4", | ||
"jsdom": "9.2.1", | ||
"nyc": "6.6.1", | ||
"sinon": "1.17.3", | ||
"ts-loader": "0.8.2", | ||
"tslint": "3.10.2", | ||
"tslint": "3.11.0", | ||
"tslint-loader": "2.1.4", | ||
"typescript": "1.8.10", | ||
"typings": "1.0.4", | ||
"typings": "1.3.0", | ||
"webpack": "1.13.1" | ||
@@ -41,0 +41,0 @@ }, |
@@ -13,6 +13,6 @@ import { | ||
export const Endpoints = { | ||
default: 'https://usageanalytics.coveo.com/rest/' + Version, | ||
production: 'https://usageanalytics.coveo.com/rest/' + Version, | ||
dev: 'https://usageanalyticsdev.coveo.com/rest/' + Version, | ||
staging: 'https://usageanalyticsstaging.coveo.com/rest/' + Version | ||
default: 'https://usageanalytics.coveo.com', | ||
production: 'https://usageanalytics.coveo.com', | ||
dev: 'https://usageanalyticsdev.coveo.com', | ||
staging: 'https://usageanalyticsstaging.coveo.com' | ||
}; | ||
@@ -23,2 +23,3 @@ | ||
endpoint?: string; | ||
version?: string; | ||
}; | ||
@@ -36,2 +37,3 @@ | ||
private token: string; | ||
private version: string; | ||
@@ -45,10 +47,12 @@ constructor(opts: ClientOptions) { | ||
this.token = opts.token; | ||
this.version = opts.version || Version; | ||
} | ||
sendEvent(eventType: string, request: any): Promise<IResponse> { | ||
return fetch(`${this.endpoint}/analytics/${eventType}`, { | ||
return fetch(`${this.getRestEndpoint()}/analytics/${eventType}`, { | ||
method: 'POST', | ||
headers: this.getHeaders(), | ||
mode: 'cors', | ||
body: JSON.stringify(request) | ||
body: JSON.stringify(request), | ||
credentials: 'include' | ||
}); | ||
@@ -75,3 +79,3 @@ } | ||
getVisit(): Promise<VisitResponse> { | ||
return fetch(this.endpoint + '/analytics/visit') | ||
return fetch(`${this.getRestEndpoint()}/analytics/visit`) | ||
.then(defaultResponseTransformer); | ||
@@ -81,6 +85,10 @@ } | ||
getHealth(): Promise<HealthResponse> { | ||
return fetch(this.endpoint + '/analytics/monitoring/health') | ||
return fetch(`${this.getRestEndpoint()}/analytics/monitoring/health`) | ||
.then(defaultResponseTransformer); | ||
} | ||
protected getRestEndpoint(): string { | ||
return `${this.endpoint}/rest/${this.version}`; | ||
} | ||
protected getHeaders(): any { | ||
@@ -87,0 +95,0 @@ var headers: any = { |
@@ -60,2 +60,5 @@ export interface SearchDocument { | ||
title?: string; | ||
contentIdKey?: string; | ||
contentIdValue?: string; | ||
contentType?: string; | ||
} | ||
@@ -62,0 +65,0 @@ |
import AnalyticsClient from './analyticsclient'; | ||
import * as analytics from './analytics'; | ||
import objectAssign from './objectassign'; | ||
import {popFromObject} from './utils'; | ||
@@ -46,2 +47,5 @@ // SimpleAPI mimics the GoogleAnalytics API. | ||
title: document.title, | ||
contentIdKey: popFromObject(customData, 'contentIdKey'), | ||
contentIdValue: popFromObject(customData, 'contentIdValue'), | ||
contentType: popFromObject(customData, 'contentType'), | ||
customData: customData | ||
@@ -48,0 +52,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
239837
56
1136
3