coveo.analytics
Advanced tools
Comparing version 0.0.17 to 0.1.0
@@ -0,1 +1,3 @@ | ||
import { SearchEventRequest, SearchEventResponse, ClickEventRequest, ClickEventResponse, CustomEventRequest, CustomEventResponse, ViewEventRequest, ViewEventResponse, VisitResponse, HealthResponse } from './events'; | ||
import { AnalyticsClient } from './analyticsclient'; | ||
export declare const Version: string; | ||
@@ -9,6 +11,6 @@ export declare const Endpoints: { | ||
export interface ClientOptions { | ||
token: string; | ||
token?: string; | ||
endpoint?: string; | ||
} | ||
export declare class Client { | ||
export declare class Client implements AnalyticsClient { | ||
private endpoint; | ||
@@ -24,78 +26,4 @@ private token; | ||
getHealth(): Promise<HealthResponse>; | ||
protected getHeaders(): any; | ||
} | ||
export interface EventBaseRequest { | ||
language?: string; | ||
userAgent?: string; | ||
customData?: any; | ||
anonymous?: boolean; | ||
username?: string; | ||
userDisplayName?: any; | ||
splitTestRunName?: string; | ||
splitTestRunVersion?: string; | ||
originLevel1?: string; | ||
originLevel2?: string; | ||
originLevel3?: string; | ||
} | ||
export interface SearchDocument { | ||
documentUri: string; | ||
documentUriHash: string; | ||
} | ||
export interface SearchEventRequest extends EventBaseRequest { | ||
searchQueryUid: string; | ||
queryText: string; | ||
actionCause: string; | ||
responseTime: number; | ||
advancedQuery?: string; | ||
numberOfResults?: number; | ||
contextual?: boolean; | ||
results?: SearchDocument[]; | ||
queryPipeline?: string; | ||
userGroups?: string[]; | ||
} | ||
export interface ClickEventRequest extends EventBaseRequest { | ||
documentUri: string; | ||
documentUriHash: string; | ||
collectionName: string; | ||
sourceName: string; | ||
documentPosition: number; | ||
actionCause: string; | ||
searchQueryUid?: string; | ||
documentTitle?: string; | ||
documentUrl?: string; | ||
documentAuthor?: string; | ||
queryPipeline?: string; | ||
rankingModifier?: string; | ||
} | ||
export interface CustomEventRequest extends EventBaseRequest { | ||
eventType: string; | ||
eventValue: string; | ||
lastSearchQueryUid?: string; | ||
} | ||
export interface ViewEventRequest extends EventBaseRequest { | ||
location: string; | ||
referrer?: string; | ||
title?: string; | ||
} | ||
export interface DefaultEventResponse { | ||
raw: IResponse; | ||
visitId: string; | ||
visitorId: string; | ||
} | ||
export interface SearchEventResponse extends DefaultEventResponse { | ||
} | ||
export interface ClickEventResponse extends DefaultEventResponse { | ||
} | ||
export interface CustomEventResponse extends DefaultEventResponse { | ||
} | ||
export interface ViewEventResponse extends DefaultEventResponse { | ||
} | ||
export interface VisitResponse { | ||
raw: IResponse; | ||
id: string; | ||
visitorId: string; | ||
} | ||
export interface HealthResponse { | ||
raw: IResponse; | ||
status: string; | ||
} | ||
export default Client; |
@@ -21,5 +21,2 @@ "use strict"; | ||
} | ||
if (typeof opts.token === 'undefined') { | ||
throw new Error('You have to pass opts.token'); | ||
} | ||
this.endpoint = opts.endpoint || exports.Endpoints.default; | ||
@@ -31,5 +28,3 @@ this.token = opts.token; | ||
method: 'POST', | ||
headers: { | ||
Authorization: "Bearer " + this.token, | ||
'content-type': 'application/json' }, | ||
headers: this.getHeaders(), | ||
mode: 'cors', | ||
@@ -62,2 +57,11 @@ body: JSON.stringify(request) | ||
}; | ||
Client.prototype.getHeaders = function () { | ||
var headers = { | ||
'Content-Type': "application/json" | ||
}; | ||
if (this.token) { | ||
headers['Authorization'] = "Bearer " + this.token; | ||
} | ||
return headers; | ||
}; | ||
return Client; | ||
@@ -64,0 +68,0 @@ }()); |
@@ -11,7 +11,9 @@ "use strict"; | ||
var store = new history_1.HistoryStore(); | ||
store.addElement({ | ||
type: 'view', | ||
uri: document.location.toString(), | ||
var historyElement = { | ||
name: 'PageView', | ||
value: document.location.toString(), | ||
time: JSON.stringify(new Date()), | ||
title: document.title | ||
}); | ||
}; | ||
store.addElement(historyElement); | ||
} | ||
@@ -18,0 +20,0 @@ global.coveoua = simpleanalytics_1.default; |
@@ -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;a.addElement({type:"view",uri:document.location.toString(),title:document.title})}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(e=e||r.Endpoints["default"],"undefined"==typeof t)throw new Error("You must pass your token when you call 'init'");this.client=new r.Client({token:t,endpoint:e})},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");if("undefined"==typeof t.token)throw new Error("You have to pass opts.token");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:{Authorization:"Bearer "+this.token,"content-type":"application/json"},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}();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(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){/*! | ||
* @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]&&D(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,j(t,e))},"Settle: "+(t._label||" unknown promise"));!r&&o&&(r=!0,j(t,o))},t)}function O(t,e){e._state===lt?P(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?P(t,e):a(n)?T(t,e,n):P(t,e)}function A(t,e){t===e?j(t,g()):s(e)?x(t,e,E(e)):P(t,e)}function k(t){t._onerror&&t._onerror(t._result),B(t)}function P(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(k,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 I(){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 j(e,_())}else o=r,s=!0;e._state!==ft||(c&&s?A(e,o):u?j(e,i):t===lt?P(e,o):t===ht&&j(e,o))}function M(t,e){try{e(function(e){A(t,e)},function(e){j(t,e)})}catch(n){j(t,n)}}function U(){return yt++}function D(t){t[ct]=yt++,t._state=void 0,t._result=void 0,t._subscribers=[]}function N(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]=U(),this._result=this._state=void 0,this._subscribers=[],b!==t&&("function"!=typeof t&&Y(),this instanceof V?M(this,t):q())}function G(t,e){this._instanceConstructor=t,this.promise=new t(b),this.promise[ct]||D(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))):j(this.promise,K())}function K(){return new Error("Array Methods must be provided an Array")}function X(){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 J;J=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var z,W,$,Q=J,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 I,dt=new I,yt=0,vt=N,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&&P(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=X,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;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}]); | ||
//# sourceMappingURL=coveoua.js.map |
@@ -12,8 +12,10 @@ import { WebStorage } from './storage'; | ||
} | ||
export declare type HistoryElement = HistoryViewElement | any; | ||
export interface HistoryViewElement { | ||
type: string; | ||
uri: string; | ||
export interface HistoryElement { | ||
name: string; | ||
value: string; | ||
time: string; | ||
} | ||
export interface HistoryViewElement extends HistoryElement { | ||
title?: string; | ||
} | ||
export default HistoryStore; |
@@ -41,4 +41,5 @@ "use strict"; | ||
exports.HistoryStore = HistoryStore; | ||
; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = HistoryStore; | ||
//# sourceMappingURL=history.js.map |
@@ -0,4 +1,5 @@ | ||
import AnalyticsClient from './analyticsclient'; | ||
export declare class SimpleAPI { | ||
private client; | ||
init(token: string, endpoint: string): void; | ||
init(token: string | AnalyticsClient, endpoint: string): void; | ||
send(event: EventType, customData: any): void; | ||
@@ -5,0 +6,0 @@ } |
@@ -8,10 +8,18 @@ "use strict"; | ||
SimpleAPI.prototype.init = function (token, endpoint) { | ||
endpoint = endpoint || analytics.Endpoints.default; | ||
if (typeof token === 'undefined') { | ||
throw new Error("You must pass your token when you call 'init'"); | ||
} | ||
this.client = new analytics.Client({ | ||
token: token, | ||
endpoint: endpoint | ||
}); | ||
if (typeof token === 'string') { | ||
endpoint = endpoint || analytics.Endpoints.default; | ||
this.client = new analytics.Client({ | ||
token: token, | ||
endpoint: endpoint | ||
}); | ||
} | ||
else if (typeof token === 'object' && typeof token.sendEvent !== 'undefined') { | ||
this.client = token; | ||
} | ||
else { | ||
throw new Error("You must pass either your token or a valid object when you call 'init'"); | ||
} | ||
}; | ||
@@ -18,0 +26,0 @@ SimpleAPI.prototype.send = function (event, customData) { |
{ | ||
"name": "coveo.analytics", | ||
"version": "0.0.17", | ||
"version": "0.1.0", | ||
"description": "π Coveo analytics client (node and browser compatible) ", | ||
@@ -23,3 +23,3 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"ava": "0.14.0", | ||
"ava": "0.15.1", | ||
"body-parser": "1.15.1", | ||
@@ -31,3 +31,3 @@ "coveralls": "2.11.9", | ||
"isomorphic-fetch": "2.2.1", | ||
"jsdom": "9.1.0", | ||
"jsdom": "9.2.0", | ||
"nyc": "6.4.4", | ||
@@ -40,3 +40,3 @@ "sinon": "1.17.3", | ||
"typings": "1.0.4", | ||
"webpack": "1.13.0" | ||
"webpack": "1.13.1" | ||
}, | ||
@@ -43,0 +43,0 @@ "dependencies": {}, |
@@ -0,1 +1,10 @@ | ||
import { | ||
SearchEventRequest, SearchEventResponse, | ||
ClickEventRequest, ClickEventResponse, | ||
CustomEventRequest, CustomEventResponse, | ||
ViewEventRequest, ViewEventResponse, | ||
VisitResponse, HealthResponse | ||
} from './events'; | ||
import { AnalyticsClient } from './analyticsclient'; | ||
export const Version = 'v15'; | ||
@@ -11,3 +20,3 @@ | ||
export interface ClientOptions { | ||
token: string; | ||
token?: string; | ||
endpoint?: string; | ||
@@ -23,3 +32,3 @@ }; | ||
export class Client { | ||
export class Client implements AnalyticsClient { | ||
private endpoint: string; | ||
@@ -32,5 +41,2 @@ private token: string; | ||
} | ||
if (typeof opts.token === 'undefined') { | ||
throw new Error('You have to pass opts.token'); | ||
} | ||
@@ -41,8 +47,6 @@ this.endpoint = opts.endpoint || Endpoints.default; | ||
sendEvent( eventType: string, request: any): Promise<IResponse> { | ||
sendEvent(eventType: string, request: any): Promise<IResponse> { | ||
return fetch(`${this.endpoint}/analytics/${eventType}`, { | ||
method: 'POST', | ||
headers: { | ||
Authorization: `Bearer ${this.token}`, | ||
'content-type' : 'application/json'}, | ||
headers: this.getHeaders(), | ||
mode: 'cors', | ||
@@ -56,8 +60,11 @@ body: JSON.stringify(request) | ||
} | ||
sendClickEvent(request: ClickEventRequest): Promise<ClickEventResponse> { | ||
return this.sendEvent('click', request).then(defaultResponseTransformer); | ||
} | ||
sendCustomEvent(request: CustomEventRequest): Promise<CustomEventResponse> { | ||
return this.sendEvent('custom', request).then(defaultResponseTransformer); | ||
} | ||
sendViewEvent(request: ViewEventRequest): Promise<ViewEventResponse> { | ||
@@ -67,2 +74,3 @@ if (request.referrer === '') { delete request.referrer; } | ||
} | ||
getVisit(): Promise<VisitResponse> { | ||
@@ -72,2 +80,3 @@ return fetch(this.endpoint + '/analytics/visit') | ||
} | ||
getHealth(): Promise<HealthResponse> { | ||
@@ -77,86 +86,14 @@ return fetch(this.endpoint + '/analytics/monitoring/health') | ||
} | ||
} | ||
export interface EventBaseRequest { | ||
language?: string; | ||
userAgent?: string; | ||
customData?: any; | ||
anonymous?: boolean; | ||
username?: string; | ||
userDisplayName?: any; | ||
splitTestRunName?: string; | ||
splitTestRunVersion?: string; | ||
originLevel1?: string; | ||
originLevel2?: string; | ||
originLevel3?: string; | ||
protected getHeaders(): any { | ||
var headers: any = { | ||
'Content-Type': `application/json` | ||
}; | ||
if (this.token) { | ||
headers['Authorization'] = `Bearer ${this.token}`; | ||
} | ||
return headers; | ||
} | ||
} | ||
export interface SearchDocument { | ||
documentUri: string; | ||
documentUriHash: string; | ||
} | ||
export interface SearchEventRequest extends EventBaseRequest { | ||
searchQueryUid: string; | ||
queryText: string; | ||
actionCause: string; | ||
responseTime: number; | ||
advancedQuery?: string; | ||
numberOfResults?: number; | ||
contextual?: boolean; | ||
results?: SearchDocument[]; | ||
queryPipeline?: string; | ||
userGroups?: string[]; | ||
} | ||
export interface ClickEventRequest extends EventBaseRequest { | ||
documentUri: string; | ||
documentUriHash: string; | ||
collectionName: string; | ||
sourceName: string; | ||
documentPosition: number; | ||
actionCause: string; | ||
searchQueryUid?: string; | ||
documentTitle?: string; | ||
documentUrl?: string; | ||
documentAuthor?: string; | ||
queryPipeline?: string; | ||
rankingModifier?: string; | ||
} | ||
export interface CustomEventRequest extends EventBaseRequest { | ||
eventType: string; | ||
eventValue: string; | ||
lastSearchQueryUid?: string; | ||
} | ||
export interface ViewEventRequest extends EventBaseRequest { | ||
location: string; | ||
referrer?: string; | ||
title?: string; | ||
} | ||
export interface DefaultEventResponse { | ||
raw: IResponse; | ||
visitId: string; | ||
visitorId: string; | ||
} | ||
export interface SearchEventResponse extends DefaultEventResponse {} | ||
export interface ClickEventResponse extends DefaultEventResponse {} | ||
export interface CustomEventResponse extends DefaultEventResponse {} | ||
export interface ViewEventResponse extends DefaultEventResponse {} | ||
export interface VisitResponse { | ||
raw: IResponse; | ||
id: string; | ||
visitorId: string; | ||
} | ||
export interface HealthResponse { | ||
raw: IResponse; | ||
status: string; | ||
} | ||
export default Client; |
import SimpleAnalytics from './simpleanalytics'; | ||
import * as analytics from './index'; | ||
import { HistoryStore } from './history'; | ||
import { HistoryStore, HistoryViewElement } from './history'; | ||
@@ -32,7 +32,9 @@ declare const global: any; | ||
const store = new HistoryStore(); | ||
store.addElement({ | ||
type: 'view', | ||
uri: document.location.toString(), | ||
let historyElement: HistoryViewElement = { | ||
name: 'PageView', | ||
value: document.location.toString(), | ||
time: JSON.stringify(new Date()), | ||
title: document.title | ||
}); | ||
}; | ||
store.addElement(historyElement); | ||
} | ||
@@ -39,0 +41,0 @@ |
@@ -44,7 +44,9 @@ import {WebStorage, getAvailableStorage} from './storage'; | ||
export type HistoryElement = HistoryViewElement |Β any; | ||
export interface HistoryElement { | ||
name: string; | ||
value: string; | ||
time: string; | ||
}; | ||
export interface HistoryViewElement { | ||
type: string; | ||
uri: string; | ||
export interface HistoryViewElement extends HistoryElement { | ||
title?: string; | ||
@@ -51,0 +53,0 @@ } |
@@ -0,1 +1,2 @@ | ||
import AnalyticsClient from './analyticsclient'; | ||
import * as analytics from './analytics'; | ||
@@ -6,3 +7,3 @@ import objectAssign from './objectassign'; | ||
export class SimpleAPI { | ||
private client: analytics.Client; | ||
private client: AnalyticsClient; | ||
@@ -13,12 +14,17 @@ // init initializes a new SimpleAPI client. | ||
// usage analytics production endpoint | ||
init(token: string, endpoint: string ): void { | ||
endpoint = endpoint || analytics.Endpoints.default; | ||
init(token: string | AnalyticsClient, endpoint: string): void { | ||
if (typeof token === 'undefined') { | ||
throw new Error(`You must pass your token when you call 'init'`); | ||
} | ||
this.client = new analytics.Client({ | ||
token: token, | ||
endpoint: endpoint | ||
}); | ||
if (typeof token === 'string') { | ||
endpoint = endpoint || analytics.Endpoints.default; | ||
this.client = new analytics.Client({ | ||
token: token, | ||
endpoint: endpoint | ||
}); | ||
} else if (typeof token === 'object' && typeof token.sendEvent !== 'undefined') { | ||
this.client = token; | ||
} else { | ||
throw new Error(`You must pass either your token or a valid object when you call 'init'`); | ||
} | ||
} | ||
@@ -25,0 +31,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
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
233458
52
1088