Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

coveo.analytics

Package Overview
Dependencies
Maintainers
3
Versions
259
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coveo.analytics - npm Package Compare versions

Comparing version 2.6.0 to 2.8.0

2

dist/coveoua.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).coveoua=t()}(this,function(){"use strict";var n,e,d=function(){return(d=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function s(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}function r(e,s,a,u){return new(a=a||Promise)(function(r,t){function n(e){try{i(u.next(e))}catch(e){t(e)}}function o(e){try{i(u.throw(e))}catch(e){t(e)}}function i(e){var t;e.done?r(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(n,o)}i((u=u.apply(e,s||[])).next())})}function g(r,n){var o,i,s,e,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return e={next:t(0),throw:t(1),return:t(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(o)throw new TypeError("Generator is already executing.");for(;a;)try{if(o=1,i&&(s=2&t[0]?i.return:t[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,t[1])).done)return s;switch(i=0,s&&(t=[2&t[0],s.value]),t[0]){case 0:case 1:s=t;break;case 4:return a.label++,{value:t[1],done:!1};case 5:a.label++,i=t[1],t=[0];continue;case 7:t=a.ops.pop(),a.trys.pop();continue;default:if(!(s=0<(s=a.trys).length&&s[s.length-1])&&(6===t[0]||2===t[0])){a=0;continue}if(3===t[0]&&(!s||t[1]>s[0]&&t[1]<s[3])){a.label=t[1];break}if(6===t[0]&&a.label<s[1]){a.label=s[1],s=t;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(t);break}s[2]&&a.ops.pop(),a.trys.pop();continue}t=n.call(r,a)}catch(e){t=[6,e],i=0}finally{o=s=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}}function a(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,o++)n[o]=i[s];return n}(e=n=n||{}).search="search",e.click="click",e.custom="custom",e.view="view",e.collect="collect";var o=(t.prototype.sendEvent=function(a,u){return r(this,void 0,void 0,function(){var t,r,n,o,i,s;return g(this,function(e){switch(e.label){case 0:return t=this.opts,r=t.baseUrl,n=t.visitorIdProvider,o=this.shouldAppendVisitorId(a)?this.visitorIdParam:"",[4,fetch(r+"/analytics/"+a+o,{method:"POST",headers:this.getHeaders(),mode:"cors",body:JSON.stringify(u),credentials:"include"})];case 1:return(i=e.sent()).ok?[4,i.json()]:[3,3];case 2:return(s=e.sent()).visitorId&&(n.currentVisitorId=s.visitorId),[2,s];case 3:try{i.json()}catch(e){}throw console.error('An error has occured when sending the "'+a+'" event.',i,u),new Error('An error has occurred when sending the "'+a+'" event. Check the console logs for more details.')}})})},t.prototype.shouldAppendVisitorId=function(e){return-1!==[n.click,n.custom,n.search,n.view].indexOf(e)},Object.defineProperty(t.prototype,"visitorIdParam",{get:function(){var e=this.opts.visitorIdProvider.currentVisitorId;return e?"?visitor="+e:""},enumerable:!0,configurable:!0}),t.prototype.getHeaders=function(){var e=this.opts.token;return d(d({},e?{Authorization:"Bearer "+e}:{}),{"Content-Type":"application/json"})},t);function t(e){this.opts=e}function i(){return"undefined"!=typeof navigator}function u(){return"undefined"!=typeof localStorage}function c(){return i()&&navigator.cookieEnabled}function l(){return"undefined"!=typeof crypto&&void 0!==crypto.getRandomValues}function p(e,t){return-1!==f.indexOf(e)?d({language:document.documentElement.lang,userAgent:navigator.userAgent},t):t}var f=[n.click,n.custom,n.search,n.view],h=(v.set=function(e,t,r){var n,o,i,s,a;s=r?((i=new Date).setTime(i.getTime()+r),"; expires="+i.toGMTString()):"",-1===(a=location.hostname).indexOf(".")?document.cookie=e+"="+t+s+"; path=/":((o=a.split(".")).shift(),n="."+o.join("."),document.cookie=e+"="+t+s+"; path=/; domain="+n,null!=v.get(e)&&v.get(e)==t||(n="."+a,document.cookie=e+"="+t+s+"; path=/; domain="+n))},v.get=function(e){for(var t=e+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){var o=r[n];if(0==(o=o.replace(/^\s+/,"")).indexOf(t))return o.substring(t.length,o.length)}return null},v.erase=function(e){v.set(e,"",-1)},v);function v(){}function y(){return u()?localStorage:c()?new m:"undefined"!=typeof sessionStorage?sessionStorage:new S}var m=(w.prototype.getItem=function(e){return h.get(""+w.prefix+e)},w.prototype.removeItem=function(e){h.erase(""+w.prefix+e)},w.prototype.setItem=function(e,t){h.set(""+w.prefix+e,t)},w.prefix="coveo_",w);function w(){}var E=(b.prototype.getItem=function(e){return localStorage.getItem(e)||this.cookieStorage.getItem(e)},b.prototype.removeItem=function(e){this.cookieStorage.removeItem(e),localStorage.removeItem(e)},b.prototype.setItem=function(e,t){localStorage.setItem(e,t),this.cookieStorage.setItem(e,t)},b);function b(){this.cookieStorage=new m}var S=(C.prototype.getItem=function(e){return null},C.prototype.removeItem=function(e){},C.prototype.setItem=function(e,t){},C);function C(){}var I=Object.freeze({__proto__:null,preferredStorage:null,getAvailableStorage:y,CookieStorage:m,CookieAndLocalStorage:E,NullStorage:S}),x="__coveo.analytics.history",k=(P.prototype.addElement=function(e){e.internalTime=(new Date).getTime(),this.cropQueryElement(e);var t=this.getHistoryWithInternalTime();null!=t?this.isValidEntry(e)&&this.setHistory([e].concat(t)):this.setHistory([e])},P.prototype.getHistory=function(){var e=this.getHistoryWithInternalTime();return this.stripInternalTime(e)},P.prototype.getHistoryWithInternalTime=function(){try{var e=this.store.getItem(x);return e?JSON.parse(e):[]}catch(e){return[]}},P.prototype.setHistory=function(e){try{this.store.setItem(x,JSON.stringify(e.slice(0,20)))}catch(e){}},P.prototype.clear=function(){try{this.store.removeItem(x)}catch(e){}},P.prototype.getMostRecentElement=function(){var e=this.getHistoryWithInternalTime();return null==e?null:e.sort(function(e,t){return(t.internalTime||0)-(e.internalTime||0)})[0]},P.prototype.cropQueryElement=function(e){e.name&&"query"==e.name.toLowerCase()&&null!=e.value&&(e.value=e.value.slice(0,75))},P.prototype.isValidEntry=function(e){var t=this.getMostRecentElement();return!t||t.value!=e.value||6e4<(e.internalTime||0)-(t.internalTime||0)},P.prototype.stripInternalTime=function(e){return e.map(function(e){return{name:e.name,time:e.time,value:e.value}})},P);function P(e){this.store=e||y(),this.store instanceof m||!c()||(new m).removeItem(x)}function A(e,t){return e===n.view?(R(t.contentIdValue),d({location:window.location.toString(),referrer:document.referrer,title:document.title},t)):t}function T(t){return[function(e){return Y.test(e)},function(e){return W.test(e)},function(e){return-1!==U.indexOf(e)},function(e){return"custom"===e}].some(function(e){return e(t)})}var O=Object.freeze({__proto__:null,STORE_KEY:x,MAX_NUMBER_OF_HISTORY_ELEMENTS:20,MIN_THRESHOLD_FOR_DUPLICATE_VALUE:6e4,MAX_VALUE_SIZE:75,HistoryStore:k,default:k}),R=function(e){var t=new k,r={name:"PageView",value:e,time:JSON.stringify(new Date)};t.addElement(r)},F=function(e){return e?(Number(e)^L(new Uint8Array(1))[0]%16>>Number(e)/4).toString(16):(""+1e7+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,F)},L=function(e){if(l())return crypto.getRandomValues(e);for(var t=0,r=0;t<e.length;t++)0==(3&t)&&(r=4294967296*Math.random()),e[t]=r>>>((3&t)<<3)&255;return e},V={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",price:"pr",quantity:"qt",coupon:"cc",position:"ps"},q={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",position:"ps",price:"pr"},j=d(d(d(d(d({},{eventCategory:"ec",eventAction:"ea",eventLabel:"el",eventValue:"ev",page:"dp",visitorId:"cid",clientId:"cid",userId:"uid",currencyCode:"cu"}),{action:"pa",list:"pal",listSource:"pls"}),{id:"ti",revenue:"tr",tax:"tt",shipping:"ts",coupon:"tcc",affiliation:"ta",step:"cos",option:"col"}),{hitType:"t",pageViewId:"pid",encoding:"de",location:"dl",referrer:"dr",screenColor:"sd",screenResolution:"sr",title:"dt",userAgent:"ua",language:"ul",eventId:"z",time:"tm"}),{anonymizeIp:"aip"}),N=Object.keys,_=function(o,i,s){return N(o).reduce(function(e,t){var r,n="il"+(i+1)+"pi"+(s+1)+(q[t]||t);return d(d({},e),((r={})[n]=o[t],r))},{})},U=N(j).map(function(e){return j[e]}),M=N(V).map(function(e){return V[e]}),B=N(q).map(function(e){return q[e]}),D=a(M,["custom"]).join("|"),H=a(B,["custom"]).join("|"),Q="(pr[0-9]+)",z="(il[0-9]+pi[0-9]+)",Y=new RegExp("^"+Q+"("+D+")$"),W=new RegExp("^("+z+"("+H+"))|(il[0-9]+nm)$"),J=new RegExp("^"+Q+"custom$"),$=new RegExp("^"+z+"custom$"),G=function(n,o){return N(o).reduce(function(e,t){var r;return d(d({},e),((r={})[""+n+t]=o[t],r))},{})},K=(X.prototype.sendEvent=function(i,s){return r(this,void 0,void 0,function(){var t,r,n,o;return g(this,function(e){if(!navigator.sendBeacon)throw new Error('navigator.sendBeacon is not supported in this browser. Consider adding a polyfill like "sendbeacon-polyfill".');return t=this.opts.baseUrl,r=this.encodeForEventType(i,s),n=this.getQueryParamsForEventType(i),o=t+"/analytics/"+i+"?"+n,console.log('Sending beacon for "'+i+'" with: ',JSON.stringify(s)),navigator.sendBeacon(o,new Blob([r],{type:"application/x-www-form-urlencoded"})),[2]})})},X.prototype.encodeForEventType=function(e,t){return this.isEventTypeLegacy(e)?this.encodeForLegacyType(e,t):this.encodeForFormUrlEncoded(d({access_token:this.opts.token},t))},X.prototype.getQueryParamsForEventType=function(e){var t=this.opts,r=t.token,n=t.visitorIdProvider.currentVisitorId;return[r&&this.isEventTypeLegacy(e)?"access_token="+r:"",n?"visitorId="+n:""].filter(function(e){return!!e}).join("&")},X.prototype.isEventTypeLegacy=function(e){return-1!==[n.click,n.custom,n.search,n.view].indexOf(e)},X.prototype.encodeForLegacyType=function(e,t){return e+"Event="+encodeURIComponent(JSON.stringify(t))},X.prototype.encodeForFormUrlEncoded=function(t){var r=this;return Object.keys(t).filter(function(e){return!!t[e]}).map(function(e){return encodeURIComponent(e)+"="+encodeURIComponent(r.encodeValue(t[e]))}).join("&")},X.prototype.encodeValue=function(e){return"number"==typeof e||"string"==typeof e||"boolean"==typeof e?e:JSON.stringify(e)},X);function X(e){this.opts=e}var Z=(ee.prototype.sendEvent=function(e,t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,Promise.resolve()]})})},ee);function ee(){}var te=function(e,t){u()&&c()?this.storage=new E:u()?this.storage=localStorage:(console.warn("BrowserRuntime detected no valid storage available.",this),this.storage=new S),this.beaconClient=new K(e),window.addEventListener("beforeunload",function(){return t()})},re=function(){this.storage=new S,this.beaconClient=new Z},ne=function(){this.storage=new S,this.beaconClient=new Z},oe={default:"https://platform.cloud.coveo.com/rest/ua",production:"https://platform.cloud.coveo.com/rest/ua",hipaa:"https://platformhipaa.cloud.coveo.com/rest/ua"},ie=(Object.defineProperty(se.prototype,"defaultOptions",{get:function(){return{endpoint:oe.default,token:"",version:"v15"}},enumerable:!0,configurable:!0}),se.prototype.initRuntime=function(e){var t=this;return"undefined"!=typeof window&&"undefined"!=typeof document?new te(e,function(){return t.flushBufferWithBeacon()}):new re},Object.defineProperty(se.prototype,"analyticsBeaconClient",{get:function(){return this.runtime.beaconClient},enumerable:!0,configurable:!0}),Object.defineProperty(se.prototype,"storage",{get:function(){return this.runtime.storage},enumerable:!0,configurable:!0}),se.prototype.initVisitorId=function(){var e=this.visitorId||this.storage.getItem("visitorId")||"";this.currentVisitorId=e||F()},Object.defineProperty(se.prototype,"currentVisitorId",{get:function(){return this.visitorId},set:function(e){this.visitorId=e,this.storage.setItem("visitorId",e)},enumerable:!0,configurable:!0}),se.prototype.sendEvent=function(f){for(var h=[],e=1;e<arguments.length;e++)h[e-1]=arguments[e];return r(this,void 0,void 0,function(){var t,r,n,o,i,s,a,u,c,l,p=this;return g(this,function(e){switch(e.label){case 0:return t=this.eventTypeMapping[f]||{},n=void 0===(r=t.newEventType)?f:r,i=void 0===(o=t.variableLengthArgumentsNames)?[]:o,a=void 0!==(s=t.addVisitorIdParameter)&&s,c=void 0!==(u=t.usesMeasurementProtocol)&&u,l=[function(e){return 0<i.length?p.parseVariableArgumentsPayload(i,e):e[0]},function(e){return d({visitorId:a?p.visitorId:""},e)},function(e){return c?p.ensureAnonymousUserWhenUsingApiKey(e):e},function(e){return p.beforeSendHooks.reduce(function(e,t){return t(f,e)},e)},function(e){return p.removeEmptyPayloadValues(e,f)},function(e){return p.validateParams(e)},function(e){return c?N(o=e).reduce(function(e,t){var r,n=j[t]||t;return d(d({},e),((r={})[n]=o[t],r))},{}):e;var o},function(e){return c?p.removeUnknownParameters(e):e},function(e){return c?p.processCustomParameters(e):e}].reduce(function(e,t){return t(e)},h),this.bufferedRequests.push({eventType:n,payload:l,handled:!1}),[4,this.deferExecution()];case 1:return e.sent(),[4,this.sendFromBufferWithFetch()];case 2:return[2,e.sent()]}})})},se.prototype.deferExecution=function(){return new Promise(function(e){return setTimeout(e,0)})},se.prototype.flushBufferWithBeacon=function(){for(;this.hasPendingRequests();){var e=this.bufferedRequests.pop(),t=e.eventType,r=e.payload;this.analyticsBeaconClient.sendEvent(t,r)}},se.prototype.sendFromBufferWithFetch=function(){return r(this,void 0,void 0,function(){var t,r,n;return g(this,function(e){return(t=this.bufferedRequests.shift())?(r=t.eventType,n=t.payload,[2,this.analyticsFetchClient.sendEvent(r,n)]):[2]})})},se.prototype.hasPendingRequests=function(){return 0<this.bufferedRequests.length},se.prototype.clear=function(){this.storage.removeItem("visitorId"),(new k).clear()},se.prototype.sendSearchEvent=function(t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,this.sendEvent(n.search,t)]})})},se.prototype.sendClickEvent=function(t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,this.sendEvent(n.click,t)]})})},se.prototype.sendCustomEvent=function(t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,this.sendEvent(n.custom,t)]})})},se.prototype.sendViewEvent=function(t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,this.sendEvent(n.view,t)]})})},se.prototype.getVisit=function(){return r(this,void 0,void 0,function(){var t;return g(this,function(e){switch(e.label){case 0:return[4,fetch(this.baseUrl+"/analytics/visit")];case 1:return[4,e.sent().json()];case 2:return t=e.sent(),this.visitorId=t.visitorId,[2,t]}})})},se.prototype.getHealth=function(){return r(this,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,fetch(this.baseUrl+"/analytics/monitoring/health")];case 1:return[4,e.sent().json()];case 2:return[2,e.sent()]}})})},se.prototype.registerBeforeSendEventHook=function(e){this.beforeSendHooks.push(e)},se.prototype.addEventTypeMapping=function(e,t){this.eventTypeMapping[e]=t},se.prototype.parseVariableArgumentsPayload=function(e,t){for(var r={},n=0,o=t.length;n<o;n++){var i=t[n];if("string"==typeof i)r[e[n]]=i;else if("object"==typeof i)return d(d({},r),i)}return r},se.prototype.isKeyAllowedEmpty=function(e,t){var r;return-1!==((r={})[n.search]=["queryText"],(r[e]||[]).indexOf(t))},se.prototype.removeEmptyPayloadValues=function(n,r){var o=this;return Object.keys(n).filter(function(e){return o.isKeyAllowedEmpty(r,e)||null!=(t=n[e])&&""!==t;var t}).reduce(function(e,t){var r;return d(d({},e),((r={})[t]=n[t],r))},{})},se.prototype.removeUnknownParameters=function(n){return Object.keys(n).filter(function(e){if(T(e))return!0;console.log(e,"is not processed by coveoua")}).reduce(function(e,t){var r;return d(d({},e),((r={})[t]=n[t],r))},{})},se.prototype.processCustomParameters=function(e){var i,t=e.custom,r=s(e,["custom"]),n=N(i=r).reduce(function(e,t){var r,n=J.exec(t)||$.exec(t);if(n){var o=n[1];return d(d({},e),G(o,i[t]))}return d(d({},e),((r={})[t]=i[t],r))},{});return d(d({},t||{}),n)},se.prototype.validateParams=function(e){var t=e.anonymizeIp,r=s(e,["anonymizeIp"]);return void 0!==t&&-1==["0","false","undefined","null","{}","[]",""].indexOf((""+t).toLowerCase())&&(r.anonymizeIp=1),r},se.prototype.ensureAnonymousUserWhenUsingApiKey=function(e){var t,r=e.userId,n=s(e,["userId"]);return null!=(t=this.options.token)&&t.startsWith("xx")&&!r?(n.userId="anonymous",n):e},Object.defineProperty(se.prototype,"baseUrl",{get:function(){var e=this.options,t=e.version,r=e.endpoint,n=-1!==r.indexOf(".cloud.coveo.com");return r+(n?"":"/rest")+"/"+t},enumerable:!0,configurable:!0}),se);function se(e){if(!e)throw new Error("You have to pass options to this constructor");this.options=d(d({},this.defaultOptions),e),this.visitorId="",this.bufferedRequests=[],this.beforeSendHooks=[A,p],this.eventTypeMapping={};var t={baseUrl:this.baseUrl,token:this.options.token,visitorIdProvider:this};this.runtime=this.initRuntime(t),this.analyticsFetchClient=new o(t),this.initVisitorId()}var ae=Object.freeze({__proto__:null,Version:"v15",Endpoints:oe,CoveoAnalyticsClient:ie,default:ie}),ue=i()?[!0,"yes","1"].indexOf(navigator.doNotTrack||navigator.msDoNotTrack||window.doNotTrack):0,ce=Object.freeze({__proto__:null,doNotTrack:ue,default:ue}),le=(pe.prototype.register=function(e,t){this.plugins[e]=t},pe.prototype.execute=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var o=this.plugins[e];return o[t].apply(o,r)},pe);function pe(){this.plugins={}}function fe(e){return e.protocol+"//"+e.hostname+(0===e.pathname.indexOf("/")?e.pathname:"/"+e.pathname)+e.search}var he={pageview:"pageview",event:"event"},de=Object.keys(he).map(function(e){return he[e]}),ge=(ve.prototype.addProduct=function(e){this.products.push(e)},ve.prototype.addImpression=function(e){this.impressions.push(e)},ve.prototype.setAction=function(e,t){this.action=e,this.actionData=t},ve.prototype.clearData=function(){this.products=[],this.impressions=[],this.action=void 0,this.actionData={}},ve.prototype.addHooksForECEvents=function(){var o=this;this.client.registerBeforeSendEventHook(function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var n=t[0];return-1!==de.indexOf(e)?o.addECDataToPayload(e,n):n})},ve.prototype.addHooksForPageView=function(){this.client.addEventTypeMapping(he.pageview,{newEventType:n.collect,variableLengthArgumentsNames:["page"],addVisitorIdParameter:!0,usesMeasurementProtocol:!0})},ve.prototype.addHooksForEvent=function(){this.client.addEventTypeMapping(he.event,{newEventType:n.collect,variableLengthArgumentsNames:["eventCategory","eventAction","eventLabel","eventValue"],addVisitorIdParameter:!0,usesMeasurementProtocol:!0})},ve.prototype.addECDataToPayload=function(e,t){var r=d(d(d(d({},this.getLocationInformation(e,t)),this.getDefaultContextInformation(e)),this.action?{action:this.action}:{}),this.actionData||{}),n=this.products.reduce(function(e,t,r){return d(d({},e),(i=r,N(o=t).reduce(function(e,t){var r,n="pr"+(i+1)+(V[t]||t);return d(d({},e),((r={})[n]=o[t],r))},{})));var o,i},{}),o=this.getImpressionsByList().reduce(function(e,t,r){return d(d({},e),function(e,n){var t=e.impressions.reduce(function(e,t,r){return d(d({},e),_(t,n,r))},{});return e.listName&&(t["il"+(n+1)+"nm"]=e.listName),t}(t,r))},{});return this.clearData(),d(d(d(d({},o),n),r),t)},ve.prototype.getImpressionsByList=function(){return this.impressions.reduce(function(e,t){var r=t.list,n=s(t,["list"]),o=e.find(function(e){return e.listName===r});return o?o.impressions.push(n):e.push({listName:r,impressions:[n]}),e},[])},ve.prototype.updateStateForNewPageView=function(e){this.hasSentFirstPageView&&(this.pageViewId=this.uuidGenerator(),this.lastReferrer=this.lastLocation),e.page?this.lastLocation=""+this.lastLocation.split("/").slice(0,3).join("/")+e.page.replace(/^\/?(.*)$/,"/$1"):this.lastLocation=fe(window.location),this.hasSentFirstPageView=!0},ve.prototype.getLocationInformation=function(e,t){return e===he.pageview&&this.updateStateForNewPageView(t),{referrer:this.lastReferrer,location:this.lastLocation}},ve.prototype.getDefaultContextInformation=function(e){var t={hitType:e,pageViewId:this.pageViewId},r={title:document.title,encoding:document.characterSet},n={screenResolution:screen.width+"x"+screen.height,screenColor:screen.colorDepth+"-bit"},o={language:navigator.language,userAgent:navigator.userAgent},i={time:Date.now().toString(),eventId:this.uuidGenerator()};return d(d(d(d(d({},t),i),n),o),r)},ve);function ve(e){var t=e.client,r=e.uuidGenerator,n=void 0===r?F:r;this.products=[],this.impressions=[],this.actionData={},this.client=t,this.uuidGenerator=n,this.pageViewId=n(),this.lastLocation=fe(window.location),this.lastReferrer=document.referrer,this.addHooksForPageView(),this.addHooksForEvent(),this.addHooksForECEvents()}var ye=(me.prototype.init=function(e,t){var r=this;if(!e)throw new Error("You must pass your token when you call 'init'");if("string"==typeof e?(t=t||oe.default,this.client=new ie({token:e,endpoint:t})):"object"==typeof e&&void 0!==e.sendEvent&&(this.client=e),!this.client)throw new Error("You must pass either your token or a valid object when you call 'init'");this.plugins.register("ec",new ge({client:this.client})),this.client.registerBeforeSendEventHook(function(e,t){return d(d({},t),r.params)})},me.prototype.initForProxy=function(e){if(!e)throw new Error("You must pass your endpoint when you call 'initForProxy'");if("string"!=typeof e)throw new Error("You must pass a string as the endpoint parameter when you call 'initForProxy'");this.client=new ie({endpoint:e})},me.prototype.set=function(t,e){var r=this;"string"==typeof t?this.params[t]=e:Object.keys(t).map(function(e){r.params[e]=t[e]})},me.prototype.send=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=t[0],o=t.slice(1);if(void 0===this.client)throw new Error("You must call init before sending an event");if(!n)throw new Error('You must provide an event type when calling "send".');return(e=this.client).sendEvent.apply(e,a([n.toLowerCase()],o))},me.prototype.onLoad=function(e){if(void 0===e)throw new Error("You must pass a function when you call 'onLoad'");e()},me.prototype.callPlugin=function(e,t){for(var r,n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];(r=this.plugins).execute.apply(r,a([e,t],n))},me.prototype.reset=function(){this.client=void 0,this.plugins=new le,this.params={}},me);function me(){this.plugins=new le,this.params={}}function we(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var n=/^(?:(\w+)\.)?(?:(\w+):)?(\w+)$/.exec(e),o=(n[1],n[2]),i=n[3],s=Ce[i];if(o&&i)return Ce.callPlugin.apply(Ce,a([o,i],t));if(s)return s.apply(Ce,t);throw new Error('The action "'+e+'" does not exist. Available actions: '+["init","set","send","onLoad","callPlugin"].join(", ")+".")}var Ee,be,Se,Ce=new ye,Ie=Object.freeze({__proto__:null,CoveoUA:ye,coveoua:Ce,handleOneAnalyticsEvent:we,default:we});(Se=be=be||{}).interfaceLoad="interfaceLoad",Se.interfaceChange="interfaceChange",Se.didyoumeanAutomatic="didyoumeanAutomatic",Se.didyoumeanClick="didyoumeanClick",Se.resultsSort="resultsSort",Se.searchboxSubmit="searchboxSubmit",Se.searchboxClear="searchboxClear",Se.searchboxAsYouType="searchboxAsYouType",Se.breadcrumbFacet="breadcrumbFacet",Se.breadcrumbResetAll="breadcrumbResetAll",Se.documentQuickview="documentQuickview",Se.documentOpen="documentOpen",Se.omniboxAnalytics="omniboxAnalytics",Se.omniboxFromLink="omniboxFromLink",Se.triggerNotify="notify",Se.triggerExecute="execute",Se.triggerQuery="query",Se.triggerRedirect="redirect",Se.pagerResize="pagerResize",Se.pagerNumber="pagerNumber",Se.pagerNext="pagerNext",Se.pagerPrevious="pagerPrevious",Se.pagerScrolling="pagerScrolling",Se.facetClearAll="facetClearAll",Se.facetSearch="facetSearch",Se.facetSelect="facetSelect",Se.facetSelectAll="facetSelectAll",Se.facetDeselect="facetDeselect",Se.facetExclude="facetExclude",Se.facetUnexclude="facetUnexclude",Se.facetUpdateSort="facetUpdateSort",Se.facetShowMore="showMoreFacetResults",Se.facetShowLess="showLessFacetResults",Se.queryError="query",Se.queryErrorBack="errorBack",Se.queryErrorClear="errorClearQuery",Se.queryErrorRetry="errorRetry";var xe=((Ee={})[be.triggerNotify]="queryPipelineTriggers",Ee[be.triggerExecute]="queryPipelineTriggers",Ee[be.triggerQuery]="queryPipelineTriggers",Ee[be.triggerRedirect]="queryPipelineTriggers",Ee[be.queryError]="errors",Ee[be.queryErrorBack]="errors",Ee[be.queryErrorClear]="errors",Ee[be.queryErrorRetry]="errors",Ee[be.pagerNext]="getMoreResults",Ee[be.pagerPrevious]="getMoreResults",Ee[be.pagerNumber]="getMoreResults",Ee[be.pagerResize]="getMoreResults",Ee[be.pagerScrolling]="getMoreResults",Ee[be.facetSearch]="facet",Ee[be.facetShowLess]="facet",Ee[be.facetShowMore]="facet",Ee),ke=(Pe.prototype.sendEvent=function(){return Promise.resolve()},Pe.prototype.sendSearchEvent=function(){return Promise.resolve()},Pe.prototype.sendClickEvent=function(){return Promise.resolve()},Pe.prototype.sendCustomEvent=function(){return Promise.resolve()},Pe.prototype.sendViewEvent=function(){return Promise.resolve()},Pe.prototype.getVisit=function(){return Promise.resolve({id:"",visitorId:""})},Pe.prototype.getHealth=function(){return Promise.resolve({status:""})},Pe.prototype.registerBeforeSendEventHook=function(){},Pe.prototype.addEventTypeMapping=function(){},Pe);function Pe(){this.runtime=new ne}var Ae=(Te.prototype.disable=function(){this.coveoAnalyticsClient instanceof ie&&this.coveoAnalyticsClient.clear(),this.coveoAnalyticsClient=new ke},Te.prototype.enable=function(){this.coveoAnalyticsClient=new ie(this.opts)},Te.prototype.logInterfaceLoad=function(){return this.logSearchEvent(be.interfaceLoad)},Te.prototype.logInterfaceChange=function(e){return this.logSearchEvent(be.interfaceChange,e)},Te.prototype.logDidYouMeanAutomatic=function(){return this.logSearchEvent(be.didyoumeanAutomatic)},Te.prototype.logDidYouMeanClick=function(){return this.logSearchEvent(be.didyoumeanClick)},Te.prototype.logResultsSort=function(e){return this.logSearchEvent(be.resultsSort,e)},Te.prototype.logSearchboxSubmit=function(){return this.logSearchEvent(be.searchboxSubmit)},Te.prototype.logSearchboxClear=function(){return this.logSearchEvent(be.searchboxClear)},Te.prototype.logSearchboxAsYouType=function(){return this.logSearchEvent(be.searchboxAsYouType)},Te.prototype.logBreadcrumbFacet=function(e){return this.logSearchEvent(be.breadcrumbFacet,e)},Te.prototype.logBreadcrumbResetAll=function(){return this.logSearchEvent(be.breadcrumbResetAll)},Te.prototype.logDocumentQuickview=function(e,t){return this.logClickEvent(be.documentQuickview,e,t)},Te.prototype.logDocumentOpen=function(e,t){return this.logClickEvent(be.documentOpen,e,t)},Te.prototype.logOmniboxAnalytics=function(e){return this.logSearchEvent(be.omniboxAnalytics,e)},Te.prototype.logOmniboxFromLink=function(e){return this.logSearchEvent(be.omniboxFromLink,e)},Te.prototype.logTriggerNotify=function(e){return this.logCustomEvent(be.triggerNotify,e)},Te.prototype.logTriggerExecute=function(e){return this.logCustomEvent(be.triggerExecute,e)},Te.prototype.logTriggerQuery=function(){var e={query:this.provider.getSearchEventRequestPayload().queryText};return this.logCustomEvent(be.triggerQuery,e)},Te.prototype.logTriggerRedirect=function(e){var t=d(d({},e),{query:this.provider.getSearchEventRequestPayload().queryText});return this.logCustomEvent(be.triggerRedirect,t)},Te.prototype.logPagerResize=function(e){return this.logCustomEvent(be.pagerResize,e)},Te.prototype.logPagerNumber=function(e){return this.logCustomEvent(be.pagerNumber,e)},Te.prototype.logPagerNext=function(e){return this.logCustomEvent(be.pagerNext,e)},Te.prototype.logPagerPrevious=function(e){return this.logCustomEvent(be.pagerPrevious,e)},Te.prototype.logPagerScrolling=function(){return this.logCustomEvent(be.pagerScrolling)},Te.prototype.logFacetClearAll=function(e){return this.logSearchEvent(be.facetClearAll,e)},Te.prototype.logFacetSearch=function(e){return this.logSearchEvent(be.facetSearch,e)},Te.prototype.logFacetSelect=function(e){return this.logSearchEvent(be.facetSelect,e)},Te.prototype.logFacetDeselect=function(e){return this.logSearchEvent(be.facetDeselect,e)},Te.prototype.logFacetExclude=function(e){return this.logSearchEvent(be.facetExclude,e)},Te.prototype.logFacetUnexclude=function(e){return this.logSearchEvent(be.facetUnexclude,e)},Te.prototype.logFacetSelectAll=function(e){return this.logSearchEvent(be.facetSelectAll,e)},Te.prototype.logFacetUpdateSort=function(e){return this.logSearchEvent(be.facetUpdateSort,e)},Te.prototype.logFacetShowMore=function(e){return this.logCustomEvent(be.facetShowMore,e)},Te.prototype.logFacetShowLess=function(e){return this.logCustomEvent(be.facetShowLess,e)},Te.prototype.logQueryError=function(e){return this.logCustomEvent(be.queryError,e)},Te.prototype.logQueryErrorBack=function(){return r(this,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,this.logCustomEvent(be.queryErrorBack)];case 1:return e.sent(),[2,this.logSearchEvent(be.queryErrorBack)]}})})},Te.prototype.logQueryErrorRetry=function(){return r(this,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,this.logCustomEvent(be.queryErrorRetry)];case 1:return e.sent(),[2,this.logSearchEvent(be.queryErrorRetry)]}})})},Te.prototype.logQueryErrorClear=function(){return r(this,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,this.logCustomEvent(be.queryErrorClear)];case 1:return e.sent(),[2,this.logSearchEvent(be.queryErrorClear)]}})})},Te.prototype.logCustomEvent=function(e,t){var r=d(d({},this.provider.getBaseMetadata()),t),n=d(d({},this.getOrigins()),{eventType:xe[e],eventValue:e,lastSearchQueryUid:this.provider.getSearchUID(),customData:r});return this.coveoAnalyticsClient.sendCustomEvent(n)},Te.prototype.logSearchEvent=function(e,t){var r=d(d({},this.provider.getBaseMetadata()),t),n=d(d(d({},this.provider.getSearchEventRequestPayload()),this.getOrigins()),{searchQueryUid:this.provider.getSearchUID(),queryPipeline:this.provider.getPipeline(),customData:r,actionCause:e});return this.coveoAnalyticsClient.sendSearchEvent(n)},Te.prototype.logClickEvent=function(e,t,r,n){var o=d(d(d({},this.provider.getBaseMetadata()),r),n),i=d(d(d({},t),this.getOrigins()),{searchQueryUid:this.provider.getSearchUID(),queryPipeline:this.provider.getPipeline(),actionCause:e,customData:o});return this.coveoAnalyticsClient.sendClickEvent(i)},Te.prototype.getOrigins=function(){return{originLevel1:this.provider.getOriginLevel1(),originLevel2:this.provider.getOriginLevel2(),originLevel3:this.provider.getOriginLevel3()}},Te);function Te(e,t){this.opts=e,this.provider=t,this.coveoAnalyticsClient=!1===e.enableAnalytics?new ke:new ie(e)}var Oe=Object.freeze({__proto__:null,analytics:ae,donottrack:ce,history:O,SimpleAnalytics:Ie,storage:I,CoveoAnalyticsClient:ie,CoveoUA:ye,handleOneAnalyticsEvent:we,CoveoSearchPageClient:Ae});window.Promise instanceof Function||console.error('This script uses window.Promise which is not supported in your browser. Consider adding a polyfill like "es6-promise".'),window.fetch instanceof Function||console.error('This script uses window.fetch which is not supported in your browser. Consider adding a polyfill like "fetch".');var Re=self.coveoua||we;self.coveoua=we,self.coveoanalytics=Oe,Re.q&&a(Re.q.filter(function(e){return"init"===e[0]}),Re.q.filter(function(e){return"init"!==e[0]})).forEach(function(e){return we.apply(void 0,e)});return self.coveoua});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).coveoua=t()}(this,function(){"use strict";var n,e,h=function(){return(h=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function s(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}function r(e,s,a,u){return new(a=a||Promise)(function(r,t){function n(e){try{i(u.next(e))}catch(e){t(e)}}function o(e){try{i(u.throw(e))}catch(e){t(e)}}function i(e){var t;e.done?r(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(n,o)}i((u=u.apply(e,s||[])).next())})}function v(r,n){var o,i,s,e,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return e={next:t(0),throw:t(1),return:t(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(o)throw new TypeError("Generator is already executing.");for(;a;)try{if(o=1,i&&(s=2&t[0]?i.return:t[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,t[1])).done)return s;switch(i=0,s&&(t=[2&t[0],s.value]),t[0]){case 0:case 1:s=t;break;case 4:return a.label++,{value:t[1],done:!1};case 5:a.label++,i=t[1],t=[0];continue;case 7:t=a.ops.pop(),a.trys.pop();continue;default:if(!(s=0<(s=a.trys).length&&s[s.length-1])&&(6===t[0]||2===t[0])){a=0;continue}if(3===t[0]&&(!s||t[1]>s[0]&&t[1]<s[3])){a.label=t[1];break}if(6===t[0]&&a.label<s[1]){a.label=s[1],s=t;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(t);break}s[2]&&a.ops.pop(),a.trys.pop();continue}t=n.call(r,a)}catch(e){t=[6,e],i=0}finally{o=s=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}}function a(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,o++)n[o]=i[s];return n}(e=n=n||{}).search="search",e.click="click",e.custom="custom",e.view="view",e.collect="collect";var o=(t.prototype.sendEvent=function(a,u){return r(this,void 0,void 0,function(){var t,r,n,o,i,s;return v(this,function(e){switch(e.label){case 0:return t=this.opts,r=t.baseUrl,n=t.visitorIdProvider,o=this.shouldAppendVisitorId(a)?this.visitorIdParam:"",[4,fetch(r+"/analytics/"+a+o,{method:"POST",headers:this.getHeaders(),mode:"cors",body:JSON.stringify(u),credentials:"include"})];case 1:return(i=e.sent()).ok?[4,i.json()]:[3,3];case 2:return(s=e.sent()).visitorId&&(n.currentVisitorId=s.visitorId),[2,s];case 3:try{i.json()}catch(e){}throw console.error('An error has occured when sending the "'+a+'" event.',i,u),new Error('An error has occurred when sending the "'+a+'" event. Check the console logs for more details.')}})})},t.prototype.shouldAppendVisitorId=function(e){return-1!==[n.click,n.custom,n.search,n.view].indexOf(e)},Object.defineProperty(t.prototype,"visitorIdParam",{get:function(){var e=this.opts.visitorIdProvider.currentVisitorId;return e?"?visitor="+e:""},enumerable:!0,configurable:!0}),t.prototype.getHeaders=function(){var e=this.opts.token;return h(h({},e?{Authorization:"Bearer "+e}:{}),{"Content-Type":"application/json"})},t);function t(e){this.opts=e}function i(){return"undefined"!=typeof navigator}function u(){return"undefined"!=typeof localStorage}function c(){return i()&&navigator.cookieEnabled}function l(){return"undefined"!=typeof crypto&&void 0!==crypto.getRandomValues}function p(e,t){return-1!==f.indexOf(e)?h({language:document.documentElement.lang,userAgent:navigator.userAgent},t):t}var f=[n.click,n.custom,n.search,n.view],d=(g.set=function(e,t,r){var n,o,i,s,a;s=r?((i=new Date).setTime(i.getTime()+r),"; expires="+i.toGMTString()):"",-1===(a=location.hostname).indexOf(".")?document.cookie=e+"="+t+s+"; path=/":((o=a.split(".")).shift(),n="."+o.join("."),document.cookie=e+"="+t+s+"; path=/; domain="+n,null!=g.get(e)&&g.get(e)==t||(n="."+a,document.cookie=e+"="+t+s+"; path=/; domain="+n))},g.get=function(e){for(var t=e+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){var o=r[n];if(0==(o=o.replace(/^\s+/,"")).indexOf(t))return o.substring(t.length,o.length)}return null},g.erase=function(e){g.set(e,"",-1)},g);function g(){}function y(){return u()?localStorage:c()?new m:"undefined"!=typeof sessionStorage?sessionStorage:new S}var m=(w.prototype.getItem=function(e){return d.get(""+w.prefix+e)},w.prototype.removeItem=function(e){d.erase(""+w.prefix+e)},w.prototype.setItem=function(e,t){d.set(""+w.prefix+e,t)},w.prefix="coveo_",w);function w(){}var E=(b.prototype.getItem=function(e){return localStorage.getItem(e)||this.cookieStorage.getItem(e)},b.prototype.removeItem=function(e){this.cookieStorage.removeItem(e),localStorage.removeItem(e)},b.prototype.setItem=function(e,t){localStorage.setItem(e,t),this.cookieStorage.setItem(e,t)},b);function b(){this.cookieStorage=new m}var S=(I.prototype.getItem=function(e){return null},I.prototype.removeItem=function(e){},I.prototype.setItem=function(e,t){},I);function I(){}var C=Object.freeze({__proto__:null,preferredStorage:null,getAvailableStorage:y,CookieStorage:m,CookieAndLocalStorage:E,NullStorage:S}),P="__coveo.analytics.history",x=(k.prototype.addElement=function(e){e.internalTime=(new Date).getTime(),this.cropQueryElement(e);var t=this.getHistoryWithInternalTime();null!=t?this.isValidEntry(e)&&this.setHistory([e].concat(t)):this.setHistory([e])},k.prototype.getHistory=function(){var e=this.getHistoryWithInternalTime();return this.stripInternalTime(e)},k.prototype.getHistoryWithInternalTime=function(){try{var e=this.store.getItem(P);return e?JSON.parse(e):[]}catch(e){return[]}},k.prototype.setHistory=function(e){try{this.store.setItem(P,JSON.stringify(e.slice(0,20)))}catch(e){}},k.prototype.clear=function(){try{this.store.removeItem(P)}catch(e){}},k.prototype.getMostRecentElement=function(){var e=this.getHistoryWithInternalTime();return null==e?null:e.sort(function(e,t){return(t.internalTime||0)-(e.internalTime||0)})[0]},k.prototype.cropQueryElement=function(e){e.name&&"query"==e.name.toLowerCase()&&null!=e.value&&(e.value=e.value.slice(0,75))},k.prototype.isValidEntry=function(e){var t=this.getMostRecentElement();return!t||t.value!=e.value||6e4<(e.internalTime||0)-(t.internalTime||0)},k.prototype.stripInternalTime=function(e){return e.map(function(e){return{name:e.name,time:e.time,value:e.value}})},k);function k(e){this.store=e||y()}function T(e,t){return e===n.view?(R(t.contentIdValue),h({location:window.location.toString(),referrer:document.referrer,title:document.title},t)):t}function A(t){return[function(e){return Y.test(e)},function(e){return W.test(e)},function(e){return-1!==U.indexOf(e)},function(e){return"custom"===e}].some(function(e){return e(t)})}var O=Object.freeze({__proto__:null,STORE_KEY:P,MAX_NUMBER_OF_HISTORY_ELEMENTS:20,MIN_THRESHOLD_FOR_DUPLICATE_VALUE:6e4,MAX_VALUE_SIZE:75,HistoryStore:x,default:x}),R=function(e){var t=new x,r={name:"PageView",value:e,time:JSON.stringify(new Date)};t.addElement(r)},F=function(e){return e?(Number(e)^L(new Uint8Array(1))[0]%16>>Number(e)/4).toString(16):(""+1e7+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,F)},L=function(e){if(l())return crypto.getRandomValues(e);for(var t=0,r=0;t<e.length;t++)0==(3&t)&&(r=4294967296*Math.random()),e[t]=r>>>((3&t)<<3)&255;return e},V={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",price:"pr",quantity:"qt",coupon:"cc",position:"ps"},q={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",position:"ps",price:"pr"},j=h(h(h(h(h({},{eventCategory:"ec",eventAction:"ea",eventLabel:"el",eventValue:"ev",page:"dp",visitorId:"cid",clientId:"cid",userId:"uid",currencyCode:"cu"}),{action:"pa",list:"pal",listSource:"pls"}),{id:"ti",revenue:"tr",tax:"tt",shipping:"ts",coupon:"tcc",affiliation:"ta",step:"cos",option:"col"}),{hitType:"t",pageViewId:"pid",encoding:"de",location:"dl",referrer:"dr",screenColor:"sd",screenResolution:"sr",title:"dt",userAgent:"ua",language:"ul",eventId:"z",time:"tm"}),{anonymizeIp:"aip"}),N=Object.keys,_=function(o,i,s){return N(o).reduce(function(e,t){var r,n="il"+(i+1)+"pi"+(s+1)+(q[t]||t);return h(h({},e),((r={})[n]=o[t],r))},{})},U=N(j).map(function(e){return j[e]}),B=N(V).map(function(e){return V[e]}),M=N(q).map(function(e){return q[e]}),D=a(B,["custom"]).join("|"),H=a(M,["custom"]).join("|"),Q="(pr[0-9]+)",z="(il[0-9]+pi[0-9]+)",Y=new RegExp("^"+Q+"("+D+")$"),W=new RegExp("^("+z+"("+H+"))|(il[0-9]+nm)$"),J=new RegExp("^"+Q+"custom$"),$=new RegExp("^"+z+"custom$"),G=function(n,o){return N(o).reduce(function(e,t){var r;return h(h({},e),((r={})[""+n+t]=o[t],r))},{})},K=(X.prototype.sendEvent=function(i,s){return r(this,void 0,void 0,function(){var t,r,n,o;return v(this,function(e){if(!navigator.sendBeacon)throw new Error('navigator.sendBeacon is not supported in this browser. Consider adding a polyfill like "sendbeacon-polyfill".');return t=this.opts.baseUrl,r=this.encodeForEventType(i,s),n=this.getQueryParamsForEventType(i),o=t+"/analytics/"+i+"?"+n,console.log('Sending beacon for "'+i+'" with: ',JSON.stringify(s)),navigator.sendBeacon(o,new Blob([r],{type:"application/x-www-form-urlencoded"})),[2]})})},X.prototype.encodeForEventType=function(e,t){return this.isEventTypeLegacy(e)?this.encodeForLegacyType(e,t):this.encodeForFormUrlEncoded(h({access_token:this.opts.token},t))},X.prototype.getQueryParamsForEventType=function(e){var t=this.opts,r=t.token,n=t.visitorIdProvider.currentVisitorId;return[r&&this.isEventTypeLegacy(e)?"access_token="+r:"",n?"visitorId="+n:""].filter(function(e){return!!e}).join("&")},X.prototype.isEventTypeLegacy=function(e){return-1!==[n.click,n.custom,n.search,n.view].indexOf(e)},X.prototype.encodeForLegacyType=function(e,t){return e+"Event="+encodeURIComponent(JSON.stringify(t))},X.prototype.encodeForFormUrlEncoded=function(t){var r=this;return Object.keys(t).filter(function(e){return!!t[e]}).map(function(e){return encodeURIComponent(e)+"="+encodeURIComponent(r.encodeValue(t[e]))}).join("&")},X.prototype.encodeValue=function(e){return"number"==typeof e||"string"==typeof e||"boolean"==typeof e?e:JSON.stringify(e)},X);function X(e){this.opts=e}var Z=(ee.prototype.sendEvent=function(e,t){return r(this,void 0,void 0,function(){return v(this,function(e){return[2,Promise.resolve()]})})},ee);function ee(){}var te=function(e,t){u()&&c()?this.storage=new E:u()?this.storage=localStorage:(console.warn("BrowserRuntime detected no valid storage available.",this),this.storage=new S),this.beaconClient=new K(e),window.addEventListener("beforeunload",function(){return t()})},re=function(){this.storage=new S,this.beaconClient=new Z},ne=function(){this.storage=new S,this.beaconClient=new Z},oe={default:"https://platform.cloud.coveo.com/rest/ua",production:"https://platform.cloud.coveo.com/rest/ua",hipaa:"https://platformhipaa.cloud.coveo.com/rest/ua"},ie=(Object.defineProperty(se.prototype,"defaultOptions",{get:function(){return{endpoint:oe.default,token:"",version:"v15"}},enumerable:!0,configurable:!0}),se.prototype.initRuntime=function(e){var t=this;return"undefined"!=typeof window&&"undefined"!=typeof document?new te(e,function(){return t.flushBufferWithBeacon()}):new re},Object.defineProperty(se.prototype,"analyticsBeaconClient",{get:function(){return this.runtime.beaconClient},enumerable:!0,configurable:!0}),Object.defineProperty(se.prototype,"storage",{get:function(){return this.runtime.storage},enumerable:!0,configurable:!0}),se.prototype.initVisitorId=function(){var e=this.visitorId||this.storage.getItem("visitorId")||"";this.currentVisitorId=e||F()},Object.defineProperty(se.prototype,"currentVisitorId",{get:function(){return this.visitorId},set:function(e){this.visitorId=e,this.storage.setItem("visitorId",e)},enumerable:!0,configurable:!0}),se.prototype.sendEvent=function(f){for(var d=[],e=1;e<arguments.length;e++)d[e-1]=arguments[e];return r(this,void 0,void 0,function(){var t,r,n,o,i,s,a,u,c,l,p=this;return v(this,function(e){switch(e.label){case 0:return t=this.eventTypeMapping[f]||{},n=void 0===(r=t.newEventType)?f:r,i=void 0===(o=t.variableLengthArgumentsNames)?[]:o,a=void 0!==(s=t.addVisitorIdParameter)&&s,c=void 0!==(u=t.usesMeasurementProtocol)&&u,l=[function(e){return 0<i.length?p.parseVariableArgumentsPayload(i,e):e[0]},function(e){return h({visitorId:a?p.visitorId:""},e)},function(e){return c?p.ensureAnonymousUserWhenUsingApiKey(e):e},function(e){return p.beforeSendHooks.reduce(function(e,t){return t(f,e)},e)},function(e){return p.removeEmptyPayloadValues(e,f)},function(e){return p.validateParams(e)},function(e){return c?N(o=e).reduce(function(e,t){var r,n=j[t]||t;return h(h({},e),((r={})[n]=o[t],r))},{}):e;var o},function(e){return c?p.removeUnknownParameters(e):e},function(e){return c?p.processCustomParameters(e):e}].reduce(function(e,t){return t(e)},d),this.bufferedRequests.push({eventType:n,payload:l,handled:!1}),[4,this.deferExecution()];case 1:return e.sent(),[4,this.sendFromBufferWithFetch()];case 2:return[2,e.sent()]}})})},se.prototype.deferExecution=function(){return new Promise(function(e){return setTimeout(e,0)})},se.prototype.flushBufferWithBeacon=function(){for(;this.hasPendingRequests();){var e=this.bufferedRequests.pop(),t=e.eventType,r=e.payload;this.analyticsBeaconClient.sendEvent(t,r)}},se.prototype.sendFromBufferWithFetch=function(){return r(this,void 0,void 0,function(){var t,r,n;return v(this,function(e){return(t=this.bufferedRequests.shift())?(r=t.eventType,n=t.payload,[2,this.analyticsFetchClient.sendEvent(r,n)]):[2]})})},se.prototype.hasPendingRequests=function(){return 0<this.bufferedRequests.length},se.prototype.clear=function(){this.storage.removeItem("visitorId"),(new x).clear()},se.prototype.sendSearchEvent=function(t){return r(this,void 0,void 0,function(){return v(this,function(e){return[2,this.sendEvent(n.search,t)]})})},se.prototype.sendClickEvent=function(t){return r(this,void 0,void 0,function(){return v(this,function(e){return[2,this.sendEvent(n.click,t)]})})},se.prototype.sendCustomEvent=function(t){return r(this,void 0,void 0,function(){return v(this,function(e){return[2,this.sendEvent(n.custom,t)]})})},se.prototype.sendViewEvent=function(t){return r(this,void 0,void 0,function(){return v(this,function(e){return[2,this.sendEvent(n.view,t)]})})},se.prototype.getVisit=function(){return r(this,void 0,void 0,function(){var t;return v(this,function(e){switch(e.label){case 0:return[4,fetch(this.baseUrl+"/analytics/visit")];case 1:return[4,e.sent().json()];case 2:return t=e.sent(),this.visitorId=t.visitorId,[2,t]}})})},se.prototype.getHealth=function(){return r(this,void 0,void 0,function(){return v(this,function(e){switch(e.label){case 0:return[4,fetch(this.baseUrl+"/analytics/monitoring/health")];case 1:return[4,e.sent().json()];case 2:return[2,e.sent()]}})})},se.prototype.registerBeforeSendEventHook=function(e){this.beforeSendHooks.push(e)},se.prototype.addEventTypeMapping=function(e,t){this.eventTypeMapping[e]=t},se.prototype.parseVariableArgumentsPayload=function(e,t){for(var r={},n=0,o=t.length;n<o;n++){var i=t[n];if("string"==typeof i)r[e[n]]=i;else if("object"==typeof i)return h(h({},r),i)}return r},se.prototype.isKeyAllowedEmpty=function(e,t){var r;return-1!==((r={})[n.search]=["queryText"],(r[e]||[]).indexOf(t))},se.prototype.removeEmptyPayloadValues=function(n,r){var o=this;return Object.keys(n).filter(function(e){return o.isKeyAllowedEmpty(r,e)||null!=(t=n[e])&&""!==t;var t}).reduce(function(e,t){var r;return h(h({},e),((r={})[t]=n[t],r))},{})},se.prototype.removeUnknownParameters=function(n){return Object.keys(n).filter(function(e){if(A(e))return!0;console.log(e,"is not processed by coveoua")}).reduce(function(e,t){var r;return h(h({},e),((r={})[t]=n[t],r))},{})},se.prototype.processCustomParameters=function(e){var i,t=e.custom,r=s(e,["custom"]),n=N(i=r).reduce(function(e,t){var r,n=J.exec(t)||$.exec(t);if(n){var o=n[1];return h(h({},e),G(o,i[t]))}return h(h({},e),((r={})[t]=i[t],r))},{});return h(h({},t||{}),n)},se.prototype.validateParams=function(e){var t=e.anonymizeIp,r=s(e,["anonymizeIp"]);return void 0!==t&&-1==["0","false","undefined","null","{}","[]",""].indexOf((""+t).toLowerCase())&&(r.anonymizeIp=1),r},se.prototype.ensureAnonymousUserWhenUsingApiKey=function(e){var t,r=e.userId,n=s(e,["userId"]);return null!=(t=this.options.token)&&t.startsWith("xx")&&!r?(n.userId="anonymous",n):e},Object.defineProperty(se.prototype,"baseUrl",{get:function(){var e=this.options,t=e.version,r=e.endpoint,n=-1!==r.indexOf(".cloud.coveo.com");return r+(n?"":"/rest")+"/"+t},enumerable:!0,configurable:!0}),se);function se(e){if(!e)throw new Error("You have to pass options to this constructor");this.options=h(h({},this.defaultOptions),e),this.visitorId="",this.bufferedRequests=[],this.beforeSendHooks=[T,p],this.eventTypeMapping={};var t={baseUrl:this.baseUrl,token:this.options.token,visitorIdProvider:this};this.runtime=this.initRuntime(t),this.analyticsFetchClient=new o(t),this.initVisitorId()}var ae=Object.freeze({__proto__:null,Version:"v15",Endpoints:oe,CoveoAnalyticsClient:ie,default:ie}),ue=i()?[!0,"yes","1"].indexOf(navigator.doNotTrack||navigator.msDoNotTrack||window.doNotTrack):0,ce=Object.freeze({__proto__:null,doNotTrack:ue,default:ue}),le=(pe.prototype.register=function(e,t){this.plugins[e]=t},pe.prototype.execute=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var o=this.plugins[e];return o[t].apply(o,r)},pe);function pe(){this.plugins={}}function fe(e){return e.protocol+"//"+e.hostname+(0===e.pathname.indexOf("/")?e.pathname:"/"+e.pathname)+e.search}var de={pageview:"pageview",event:"event"},he=Object.keys(de).map(function(e){return de[e]}),ve=(ge.prototype.addProduct=function(e){this.products.push(e)},ge.prototype.addImpression=function(e){this.impressions.push(e)},ge.prototype.setAction=function(e,t){this.action=e,this.actionData=t},ge.prototype.clearData=function(){this.products=[],this.impressions=[],this.action=void 0,this.actionData={}},ge.prototype.addHooksForECEvents=function(){var o=this;this.client.registerBeforeSendEventHook(function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var n=t[0];return-1!==he.indexOf(e)?o.addECDataToPayload(e,n):n})},ge.prototype.addHooksForPageView=function(){this.client.addEventTypeMapping(de.pageview,{newEventType:n.collect,variableLengthArgumentsNames:["page"],addVisitorIdParameter:!0,usesMeasurementProtocol:!0})},ge.prototype.addHooksForEvent=function(){this.client.addEventTypeMapping(de.event,{newEventType:n.collect,variableLengthArgumentsNames:["eventCategory","eventAction","eventLabel","eventValue"],addVisitorIdParameter:!0,usesMeasurementProtocol:!0})},ge.prototype.addECDataToPayload=function(e,t){var r=h(h(h(h({},this.getLocationInformation(e,t)),this.getDefaultContextInformation(e)),this.action?{action:this.action}:{}),this.actionData||{}),n=this.getProductPayload(),o=this.getImpressionPayload();return this.clearData(),h(h(h(h({},o),n),r),t)},ge.prototype.getProductPayload=function(){var t=this;return this.products.map(function(e){return t.assureProductValidity(e)}).reduce(function(e,t,r){return h(h({},e),(i=r,N(o=t).reduce(function(e,t){var r,n="pr"+(i+1)+(V[t]||t);return h(h({},e),((r={})[n]=o[t],r))},{})));var o,i},{})},ge.prototype.getImpressionPayload=function(){var n=this;return this.getImpressionsByList().map(function(e){var t=e.impressions,r=s(e,["impressions"]);return h(h({},r),{impressions:t.map(function(e){return n.assureBaseImpressionValidity(e)})})}).reduce(function(e,t,r){return h(h({},e),function(e,n){var t=e.impressions.reduce(function(e,t,r){return h(h({},e),_(t,n,r))},{});return e.listName&&(t["il"+(n+1)+"nm"]=e.listName),t}(t,r))},{})},ge.prototype.assureProductValidity=function(e){var t=e.position,r=s(e,["position"]);return void 0!==t&&t<1?(console.warn("The position for product '"+(e.name||e.id)+"' must be greater than 0 when provided."),r):e},ge.prototype.assureBaseImpressionValidity=function(e){var t=e.position,r=s(e,["position"]);return void 0!==t&&t<1?(console.warn("The position for impression '"+(e.name||e.id)+"' must be greater than 0 when provided."),r):e},ge.prototype.getImpressionsByList=function(){return this.impressions.reduce(function(e,t){var r=t.list,n=s(t,["list"]),o=e.find(function(e){return e.listName===r});return o?o.impressions.push(n):e.push({listName:r,impressions:[n]}),e},[])},ge.prototype.updateStateForNewPageView=function(e){this.hasSentFirstPageView&&(this.pageViewId=this.uuidGenerator(),this.lastReferrer=this.lastLocation),e.page?this.lastLocation=""+this.lastLocation.split("/").slice(0,3).join("/")+e.page.replace(/^\/?(.*)$/,"/$1"):this.lastLocation=fe(window.location),this.hasSentFirstPageView=!0},ge.prototype.getLocationInformation=function(e,t){return e===de.pageview&&this.updateStateForNewPageView(t),{referrer:this.lastReferrer,location:this.lastLocation}},ge.prototype.getDefaultContextInformation=function(e){var t={hitType:e,pageViewId:this.pageViewId},r={title:document.title,encoding:document.characterSet},n={screenResolution:screen.width+"x"+screen.height,screenColor:screen.colorDepth+"-bit"},o={language:navigator.language,userAgent:navigator.userAgent},i={time:Date.now().toString(),eventId:this.uuidGenerator()};return h(h(h(h(h({},t),i),n),o),r)},ge);function ge(e){var t=e.client,r=e.uuidGenerator,n=void 0===r?F:r;this.products=[],this.impressions=[],this.actionData={},this.client=t,this.uuidGenerator=n,this.pageViewId=n(),this.lastLocation=fe(window.location),this.lastReferrer=document.referrer,this.addHooksForPageView(),this.addHooksForEvent(),this.addHooksForECEvents()}var ye=(me.prototype.init=function(e,t){var r=this;if(!e)throw new Error("You must pass your token when you call 'init'");if("string"==typeof e?(t=t||oe.default,this.client=new ie({token:e,endpoint:t})):"object"==typeof e&&void 0!==e.sendEvent&&(this.client=e),!this.client)throw new Error("You must pass either your token or a valid object when you call 'init'");this.plugins.register("ec",new ve({client:this.client})),this.client.registerBeforeSendEventHook(function(e,t){return h(h({},t),r.params)})},me.prototype.initForProxy=function(e){if(!e)throw new Error("You must pass your endpoint when you call 'initForProxy'");if("string"!=typeof e)throw new Error("You must pass a string as the endpoint parameter when you call 'initForProxy'");this.client=new ie({endpoint:e})},me.prototype.set=function(t,e){var r=this;"string"==typeof t?this.params[t]=e:Object.keys(t).map(function(e){r.params[e]=t[e]})},me.prototype.send=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=t[0],o=t.slice(1);if(void 0===this.client)throw new Error("You must call init before sending an event");if(!n)throw new Error('You must provide an event type when calling "send".');return(e=this.client).sendEvent.apply(e,a([n.toLowerCase()],o))},me.prototype.onLoad=function(e){if(void 0===e)throw new Error("You must pass a function when you call 'onLoad'");e()},me.prototype.callPlugin=function(e,t){for(var r,n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];(r=this.plugins).execute.apply(r,a([e,t],n))},me.prototype.reset=function(){this.client=void 0,this.plugins=new le,this.params={}},me);function me(){this.plugins=new le,this.params={}}function we(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var n=/^(?:(\w+)\.)?(?:(\w+):)?(\w+)$/.exec(e),o=(n[1],n[2]),i=n[3],s=Ie[i];if(o&&i)return Ie.callPlugin.apply(Ie,a([o,i],t));if(s)return s.apply(Ie,t);throw new Error('The action "'+e+'" does not exist. Available actions: '+["init","set","send","onLoad","callPlugin"].join(", ")+".")}var Ee,be,Se,Ie=new ye,Ce=Object.freeze({__proto__:null,CoveoUA:ye,coveoua:Ie,handleOneAnalyticsEvent:we,default:we});(Se=be=be||{}).interfaceLoad="interfaceLoad",Se.interfaceChange="interfaceChange",Se.didyoumeanAutomatic="didyoumeanAutomatic",Se.didyoumeanClick="didyoumeanClick",Se.resultsSort="resultsSort",Se.searchboxSubmit="searchboxSubmit",Se.searchboxClear="searchboxClear",Se.searchboxAsYouType="searchboxAsYouType",Se.breadcrumbFacet="breadcrumbFacet",Se.breadcrumbResetAll="breadcrumbResetAll",Se.documentQuickview="documentQuickview",Se.documentOpen="documentOpen",Se.omniboxAnalytics="omniboxAnalytics",Se.omniboxFromLink="omniboxFromLink",Se.triggerNotify="notify",Se.triggerExecute="execute",Se.triggerQuery="query",Se.triggerRedirect="redirect",Se.pagerResize="pagerResize",Se.pagerNumber="pagerNumber",Se.pagerNext="pagerNext",Se.pagerPrevious="pagerPrevious",Se.pagerScrolling="pagerScrolling",Se.facetClearAll="facetClearAll",Se.facetSearch="facetSearch",Se.facetSelect="facetSelect",Se.facetSelectAll="facetSelectAll",Se.facetDeselect="facetDeselect",Se.facetExclude="facetExclude",Se.facetUnexclude="facetUnexclude",Se.facetUpdateSort="facetUpdateSort",Se.facetShowMore="showMoreFacetResults",Se.facetShowLess="showLessFacetResults",Se.queryError="query",Se.queryErrorBack="errorBack",Se.queryErrorClear="errorClearQuery",Se.queryErrorRetry="errorRetry";var Pe=((Ee={})[be.triggerNotify]="queryPipelineTriggers",Ee[be.triggerExecute]="queryPipelineTriggers",Ee[be.triggerQuery]="queryPipelineTriggers",Ee[be.triggerRedirect]="queryPipelineTriggers",Ee[be.queryError]="errors",Ee[be.queryErrorBack]="errors",Ee[be.queryErrorClear]="errors",Ee[be.queryErrorRetry]="errors",Ee[be.pagerNext]="getMoreResults",Ee[be.pagerPrevious]="getMoreResults",Ee[be.pagerNumber]="getMoreResults",Ee[be.pagerResize]="getMoreResults",Ee[be.pagerScrolling]="getMoreResults",Ee[be.facetSearch]="facet",Ee[be.facetShowLess]="facet",Ee[be.facetShowMore]="facet",Ee),xe=(ke.prototype.sendEvent=function(){return Promise.resolve()},ke.prototype.sendSearchEvent=function(){return Promise.resolve()},ke.prototype.sendClickEvent=function(){return Promise.resolve()},ke.prototype.sendCustomEvent=function(){return Promise.resolve()},ke.prototype.sendViewEvent=function(){return Promise.resolve()},ke.prototype.getVisit=function(){return Promise.resolve({id:"",visitorId:""})},ke.prototype.getHealth=function(){return Promise.resolve({status:""})},ke.prototype.registerBeforeSendEventHook=function(){},ke.prototype.addEventTypeMapping=function(){},ke);function ke(){this.runtime=new ne,this.currentVisitorId=""}var Te=(Ae.prototype.disable=function(){this.coveoAnalyticsClient instanceof ie&&this.coveoAnalyticsClient.clear(),this.coveoAnalyticsClient=new xe},Ae.prototype.enable=function(){this.coveoAnalyticsClient=new ie(this.opts)},Ae.prototype.logInterfaceLoad=function(){return this.logSearchEvent(be.interfaceLoad)},Ae.prototype.logInterfaceChange=function(e){return this.logSearchEvent(be.interfaceChange,e)},Ae.prototype.logDidYouMeanAutomatic=function(){return this.logSearchEvent(be.didyoumeanAutomatic)},Ae.prototype.logDidYouMeanClick=function(){return this.logSearchEvent(be.didyoumeanClick)},Ae.prototype.logResultsSort=function(e){return this.logSearchEvent(be.resultsSort,e)},Ae.prototype.logSearchboxSubmit=function(){return this.logSearchEvent(be.searchboxSubmit)},Ae.prototype.logSearchboxClear=function(){return this.logSearchEvent(be.searchboxClear)},Ae.prototype.logSearchboxAsYouType=function(){return this.logSearchEvent(be.searchboxAsYouType)},Ae.prototype.logBreadcrumbFacet=function(e){return this.logSearchEvent(be.breadcrumbFacet,e)},Ae.prototype.logBreadcrumbResetAll=function(){return this.logSearchEvent(be.breadcrumbResetAll)},Ae.prototype.logDocumentQuickview=function(e,t){return this.logClickEvent(be.documentQuickview,e,t)},Ae.prototype.logDocumentOpen=function(e,t){return this.logClickEvent(be.documentOpen,e,t)},Ae.prototype.logOmniboxAnalytics=function(e){return this.logSearchEvent(be.omniboxAnalytics,e)},Ae.prototype.logOmniboxFromLink=function(e){return this.logSearchEvent(be.omniboxFromLink,e)},Ae.prototype.logTriggerNotify=function(e){return this.logCustomEvent(be.triggerNotify,e)},Ae.prototype.logTriggerExecute=function(e){return this.logCustomEvent(be.triggerExecute,e)},Ae.prototype.logTriggerQuery=function(){var e={query:this.provider.getSearchEventRequestPayload().queryText};return this.logCustomEvent(be.triggerQuery,e)},Ae.prototype.logTriggerRedirect=function(e){var t=h(h({},e),{query:this.provider.getSearchEventRequestPayload().queryText});return this.logCustomEvent(be.triggerRedirect,t)},Ae.prototype.logPagerResize=function(e){return this.logCustomEvent(be.pagerResize,e)},Ae.prototype.logPagerNumber=function(e){return this.logCustomEvent(be.pagerNumber,e)},Ae.prototype.logPagerNext=function(e){return this.logCustomEvent(be.pagerNext,e)},Ae.prototype.logPagerPrevious=function(e){return this.logCustomEvent(be.pagerPrevious,e)},Ae.prototype.logPagerScrolling=function(){return this.logCustomEvent(be.pagerScrolling)},Ae.prototype.logFacetClearAll=function(e){return this.logSearchEvent(be.facetClearAll,e)},Ae.prototype.logFacetSearch=function(e){return this.logSearchEvent(be.facetSearch,e)},Ae.prototype.logFacetSelect=function(e){return this.logSearchEvent(be.facetSelect,e)},Ae.prototype.logFacetDeselect=function(e){return this.logSearchEvent(be.facetDeselect,e)},Ae.prototype.logFacetExclude=function(e){return this.logSearchEvent(be.facetExclude,e)},Ae.prototype.logFacetUnexclude=function(e){return this.logSearchEvent(be.facetUnexclude,e)},Ae.prototype.logFacetSelectAll=function(e){return this.logSearchEvent(be.facetSelectAll,e)},Ae.prototype.logFacetUpdateSort=function(e){return this.logSearchEvent(be.facetUpdateSort,e)},Ae.prototype.logFacetShowMore=function(e){return this.logCustomEvent(be.facetShowMore,e)},Ae.prototype.logFacetShowLess=function(e){return this.logCustomEvent(be.facetShowLess,e)},Ae.prototype.logQueryError=function(e){return this.logCustomEvent(be.queryError,e)},Ae.prototype.logQueryErrorBack=function(){return r(this,void 0,void 0,function(){return v(this,function(e){switch(e.label){case 0:return[4,this.logCustomEvent(be.queryErrorBack)];case 1:return e.sent(),[2,this.logSearchEvent(be.queryErrorBack)]}})})},Ae.prototype.logQueryErrorRetry=function(){return r(this,void 0,void 0,function(){return v(this,function(e){switch(e.label){case 0:return[4,this.logCustomEvent(be.queryErrorRetry)];case 1:return e.sent(),[2,this.logSearchEvent(be.queryErrorRetry)]}})})},Ae.prototype.logQueryErrorClear=function(){return r(this,void 0,void 0,function(){return v(this,function(e){switch(e.label){case 0:return[4,this.logCustomEvent(be.queryErrorClear)];case 1:return e.sent(),[2,this.logSearchEvent(be.queryErrorClear)]}})})},Ae.prototype.logCustomEvent=function(e,t){var r=h(h({},this.provider.getBaseMetadata()),t),n=h(h({},this.getOrigins()),{eventType:Pe[e],eventValue:e,lastSearchQueryUid:this.provider.getSearchUID(),customData:r});return this.coveoAnalyticsClient.sendCustomEvent(n)},Ae.prototype.logSearchEvent=function(e,t){var r=h(h({},this.provider.getBaseMetadata()),t),n=h(h(h({},this.provider.getSearchEventRequestPayload()),this.getOrigins()),{searchQueryUid:this.provider.getSearchUID(),queryPipeline:this.provider.getPipeline(),customData:r,actionCause:e});return this.coveoAnalyticsClient.sendSearchEvent(n)},Ae.prototype.logClickEvent=function(e,t,r,n){var o=h(h(h({},this.provider.getBaseMetadata()),r),n),i=h(h(h({},t),this.getOrigins()),{searchQueryUid:this.provider.getSearchUID(),queryPipeline:this.provider.getPipeline(),actionCause:e,customData:o});return this.coveoAnalyticsClient.sendClickEvent(i)},Ae.prototype.getOrigins=function(){return{originLevel1:this.provider.getOriginLevel1(),originLevel2:this.provider.getOriginLevel2(),originLevel3:this.provider.getOriginLevel3()}},Ae);function Ae(e,t){this.opts=e,this.provider=t,this.coveoAnalyticsClient=!1===e.enableAnalytics?new xe:new ie(e)}var Oe=Object.freeze({__proto__:null,analytics:ae,donottrack:ce,history:O,SimpleAnalytics:Ce,storage:C,CoveoAnalyticsClient:ie,CoveoUA:ye,handleOneAnalyticsEvent:we,CoveoSearchPageClient:Te});window.Promise instanceof Function||console.error('This script uses window.Promise which is not supported in your browser. Consider adding a polyfill like "es6-promise".'),window.fetch instanceof Function||console.error('This script uses window.fetch which is not supported in your browser. Consider adding a polyfill like "fetch".');var Re=self.coveoua||we;self.coveoua=we,self.coveoanalytics=Oe,Re.q&&a(Re.q.filter(function(e){return"init"===e[0]}),Re.q.filter(function(e){return"init"!==e[0]})).forEach(function(e){return we.apply(void 0,e)});return self.coveoua});
//# sourceMappingURL=coveoua.js.map

@@ -33,2 +33,3 @@ import { AnyEventResponse, ClickEventRequest, ClickEventResponse, CustomEventRequest, CustomEventResponse, EventType, HealthResponse, SearchEventRequest, SearchEventResponse, ViewEventRequest, ViewEventResponse, VisitResponse, VariableArgumentsPayload } from '../events';

runtime: IRuntimeEnvironment;
readonly currentVisitorId: string;
}

@@ -35,0 +36,0 @@ export declare class CoveoAnalyticsClient implements AnalyticsClient, VisitorIdProvider {

@@ -15,2 +15,3 @@ import { AnalyticsClient } from './analytics';

runtime: NoopRuntime;
currentVisitorId: string;
}

@@ -66,2 +66,6 @@ import { AnalyticsClient } from '../client/analytics';

private addECDataToPayload;
private getProductPayload;
private getImpressionPayload;
private assureProductValidity;
private assureBaseImpressionValidity;
private getImpressionsByList;

@@ -68,0 +72,0 @@ private updateStateForNewPageView;

@@ -15,3 +15,3 @@ /*! *****************************************************************************

***************************************************************************** */
function e(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}function t(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{c(n.next(e))}catch(e){o(e)}}function a(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))}var r;!function(e){e.search="search",e.click="click",e.custom="custom",e.view="view",e.collect="collect"}(r||(r={}));class n{constructor(e){this.opts=e}sendEvent(e,r){return t(this,void 0,void 0,(function*(){const{baseUrl:t,visitorIdProvider:n}=this.opts,i=this.shouldAppendVisitorId(e)?this.visitorIdParam:"",o=yield fetch(`${t}/analytics/${e}${i}`,{method:"POST",headers:this.getHeaders(),mode:"cors",body:JSON.stringify(r),credentials:"include"});if(o.ok){const e=yield o.json();return e.visitorId&&(n.currentVisitorId=e.visitorId),e}try{o.json()}catch(e){}throw console.error(`An error has occured when sending the "${e}" event.`,o,r),new Error(`An error has occurred when sending the "${e}" event. Check the console logs for more details.`)}))}shouldAppendVisitorId(e){return-1!==[r.click,r.custom,r.search,r.view].indexOf(e)}get visitorIdParam(){const{visitorIdProvider:e}=this.opts,t=e.currentVisitorId;return t?"?visitor="+t:""}getHeaders(){const{token:e}=this.opts;return Object.assign(Object.assign({},e?{Authorization:"Bearer "+e}:{}),{"Content-Type":"application/json"})}}function i(){return"undefined"!=typeof localStorage}function o(){return"undefined"!=typeof navigator&&navigator.cookieEnabled}function s(){return"undefined"!=typeof crypto&&void 0!==crypto.getRandomValues}const a=[r.click,r.custom,r.search,r.view],c=(e,t)=>-1!==a.indexOf(e)?Object.assign({language:document.documentElement.lang,userAgent:navigator.userAgent},t):t;class l{static set(e,t,r){var n,i,o,s,a;r?((o=new Date).setTime(o.getTime()+r),s="; expires="+o.toGMTString()):s="",-1===(a=location.hostname).indexOf(".")?document.cookie=e+"="+t+s+"; path=/":((i=a.split(".")).shift(),n="."+i.join("."),document.cookie=e+"="+t+s+"; path=/; domain="+n,null!=l.get(e)&&l.get(e)==t||(n="."+a,document.cookie=e+"="+t+s+"; path=/; domain="+n))}static get(e){for(var t=e+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){var i=r[n];if(0==(i=i.replace(/^\s+/,"")).indexOf(t))return i.substring(t.length,i.length)}return null}static erase(e){l.set(e,"",-1)}}function u(){return i()?localStorage:o()?new g:"undefined"!=typeof sessionStorage?sessionStorage:new h}class g{getItem(e){return l.get(`${g.prefix}${e}`)}removeItem(e){l.erase(`${g.prefix}${e}`)}setItem(e,t){l.set(`${g.prefix}${e}`,t)}}g.prefix="coveo_";class d{constructor(){this.cookieStorage=new g}getItem(e){return localStorage.getItem(e)||this.cookieStorage.getItem(e)}removeItem(e){this.cookieStorage.removeItem(e),localStorage.removeItem(e)}setItem(e,t){localStorage.setItem(e,t),this.cookieStorage.setItem(e,t)}}class h{getItem(e){return null}removeItem(e){}setItem(e,t){}}const v="__coveo.analytics.history";class m{constructor(e){this.store=e||u(),this.store instanceof g||!o()||(new g).removeItem(v)}addElement(e){e.internalTime=(new Date).getTime(),this.cropQueryElement(e);let t=this.getHistoryWithInternalTime();null!=t?this.isValidEntry(e)&&this.setHistory([e].concat(t)):this.setHistory([e])}getHistory(){const e=this.getHistoryWithInternalTime();return this.stripInternalTime(e)}getHistoryWithInternalTime(){try{const e=this.store.getItem(v);return e?JSON.parse(e):[]}catch(e){return[]}}setHistory(e){try{this.store.setItem(v,JSON.stringify(e.slice(0,20)))}catch(e){}}clear(){try{this.store.removeItem(v)}catch(e){}}getMostRecentElement(){let e=this.getHistoryWithInternalTime();if(null!=e){return e.sort((e,t)=>(t.internalTime||0)-(e.internalTime||0))[0]}return null}cropQueryElement(e){e.name&&"query"==e.name.toLowerCase()&&null!=e.value&&(e.value=e.value.slice(0,75))}isValidEntry(e){let t=this.getMostRecentElement();return!t||t.value!=e.value||(e.internalTime||0)-(t.internalTime||0)>6e4}stripInternalTime(e){return e.map(e=>{const{name:t,time:r,value:n}=e;return{name:t,time:r,value:n}})}}const p=(e,t)=>e===r.view?(y(t.contentIdValue),Object.assign({location:window.location.toString(),referrer:document.referrer,title:document.title},t)):t,y=e=>{const t=new m,r={name:"PageView",value:e,time:JSON.stringify(new Date)};t.addElement(r)},f=e=>e?(Number(e)^b(new Uint8Array(1))[0]%16>>Number(e)/4).toString(16):"10000000-1000-4000-8000-100000000000".replace(/[018]/g,f),b=e=>{if(s())return crypto.getRandomValues(e);for(var t=0,r=0;t<e.length;t++)0==(3&t)&&(r=4294967296*Math.random()),e[t]=r>>>((3&t)<<3)&255;return e},E={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",price:"pr",quantity:"qt",coupon:"cc",position:"ps"},S={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",position:"ps",price:"pr"},O=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},{eventCategory:"ec",eventAction:"ea",eventLabel:"el",eventValue:"ev",page:"dp",visitorId:"cid",clientId:"cid",userId:"uid",currencyCode:"cu"}),{action:"pa",list:"pal",listSource:"pls"}),{id:"ti",revenue:"tr",tax:"tt",shipping:"ts",coupon:"tcc",affiliation:"ta",step:"cos",option:"col"}),{hitType:"t",pageViewId:"pid",encoding:"de",location:"dl",referrer:"dr",screenColor:"sd",screenResolution:"sr",title:"dt",userAgent:"ua",language:"ul",eventId:"z",time:"tm"}),{anonymizeIp:"aip"}),w=Object.keys,I=w(O).map(e=>O[e]),C=w(E).map(e=>E[e]),x=w(S).map(e=>S[e]),j=[...C,"custom"].join("|"),k=[...x,"custom"].join("|"),P=new RegExp(`^(pr[0-9]+)(${j})$`),T=new RegExp(`^((il[0-9]+pi[0-9]+)(${k}))|(il[0-9]+nm)$`),A=new RegExp("^(pr[0-9]+)custom$"),R=new RegExp("^(il[0-9]+pi[0-9]+)custom$"),q=e=>P.test(e),F=e=>T.test(e),U=e=>-1!==I.indexOf(e),V=e=>"custom"===e,$=(e,t)=>w(t).reduce((r,n)=>Object.assign(Object.assign({},r),{[`${e}${n}`]:t[n]}),{});class L{constructor(e){this.opts=e}sendEvent(e,r){return t(this,void 0,void 0,(function*(){if(!navigator.sendBeacon)throw new Error('navigator.sendBeacon is not supported in this browser. Consider adding a polyfill like "sendbeacon-polyfill".');const{baseUrl:t}=this.opts,n=this.encodeForEventType(e,r),i=this.getQueryParamsForEventType(e),o=`${t}/analytics/${e}?${i}`;console.log(`Sending beacon for "${e}" with: `,JSON.stringify(r)),navigator.sendBeacon(o,new Blob([n],{type:"application/x-www-form-urlencoded"}))}))}encodeForEventType(e,t){return this.isEventTypeLegacy(e)?this.encodeForLegacyType(e,t):this.encodeForFormUrlEncoded(Object.assign({access_token:this.opts.token},t))}getQueryParamsForEventType(e){const{token:t,visitorIdProvider:r}=this.opts,n=r.currentVisitorId;return[t&&this.isEventTypeLegacy(e)?"access_token="+t:"",n?"visitorId="+n:""].filter(e=>!!e).join("&")}isEventTypeLegacy(e){return-1!==[r.click,r.custom,r.search,r.view].indexOf(e)}encodeForLegacyType(e,t){return`${e}Event=${encodeURIComponent(JSON.stringify(t))}`}encodeForFormUrlEncoded(e){return Object.keys(e).filter(t=>!!e[t]).map(t=>`${encodeURIComponent(t)}=${encodeURIComponent(this.encodeValue(e[t]))}`).join("&")}encodeValue(e){return"number"==typeof e||"string"==typeof e||"boolean"==typeof e?e:JSON.stringify(e)}}class B{sendEvent(e,r){return t(this,void 0,void 0,(function*(){return Promise.resolve()}))}}class M{constructor(e,t){i()&&o()?this.storage=new d:i()?this.storage=localStorage:(console.warn("BrowserRuntime detected no valid storage available.",this),this.storage=new h),this.beaconClient=new L(e),window.addEventListener("beforeunload",()=>t())}}class N{constructor(){this.storage=new h,this.beaconClient=new B}}class Q{constructor(){this.storage=new h,this.beaconClient=new B}}const D="https://platform.cloud.coveo.com/rest/ua";class H{constructor(e){if(!e)throw new Error("You have to pass options to this constructor");this.options=Object.assign(Object.assign({},this.defaultOptions),e),this.visitorId="",this.bufferedRequests=[],this.beforeSendHooks=[p,c],this.eventTypeMapping={};const t={baseUrl:this.baseUrl,token:this.options.token,visitorIdProvider:this};this.runtime=this.initRuntime(t),this.analyticsFetchClient=new n(t),this.initVisitorId()}get defaultOptions(){return{endpoint:D,token:"",version:"v15"}}initRuntime(e){return"undefined"!=typeof window&&"undefined"!=typeof document?new M(e,()=>this.flushBufferWithBeacon()):new N}get analyticsBeaconClient(){return this.runtime.beaconClient}get storage(){return this.runtime.storage}initVisitorId(){const e=this.visitorId||this.storage.getItem("visitorId")||"";this.currentVisitorId=e||f()}get currentVisitorId(){return this.visitorId}set currentVisitorId(e){this.visitorId=e,this.storage.setItem("visitorId",e)}sendEvent(e,...r){return t(this,void 0,void 0,(function*(){const{newEventType:t=e,variableLengthArgumentsNames:n=[],addVisitorIdParameter:i=!1,usesMeasurementProtocol:o=!1}=this.eventTypeMapping[e]||{},s=[e=>n.length>0?this.parseVariableArgumentsPayload(n,e):e[0],e=>Object.assign({visitorId:i?this.visitorId:""},e),e=>o?this.ensureAnonymousUserWhenUsingApiKey(e):e,t=>this.beforeSendHooks.reduce((t,r)=>r(e,t),t),t=>this.removeEmptyPayloadValues(t,e),e=>this.validateParams(e),e=>{return o?w(t=e).reduce((e,r)=>{const n=O[r]||r;return Object.assign(Object.assign({},e),{[n]:t[r]})},{}):e;var t},e=>o?this.removeUnknownParameters(e):e,e=>o?this.processCustomParameters(e):e].reduce((e,t)=>t(e),r);return this.bufferedRequests.push({eventType:t,payload:s,handled:!1}),yield this.deferExecution(),yield this.sendFromBufferWithFetch()}))}deferExecution(){return new Promise(e=>setTimeout(e,0))}flushBufferWithBeacon(){for(;this.hasPendingRequests();){const{eventType:e,payload:t}=this.bufferedRequests.pop();this.analyticsBeaconClient.sendEvent(e,t)}}sendFromBufferWithFetch(){return t(this,void 0,void 0,(function*(){const e=this.bufferedRequests.shift();if(e){const{eventType:t,payload:r}=e;return this.analyticsFetchClient.sendEvent(t,r)}}))}hasPendingRequests(){return this.bufferedRequests.length>0}clear(){this.storage.removeItem("visitorId"),(new m).clear()}sendSearchEvent(e){return t(this,void 0,void 0,(function*(){return this.sendEvent(r.search,e)}))}sendClickEvent(e){return t(this,void 0,void 0,(function*(){return this.sendEvent(r.click,e)}))}sendCustomEvent(e){return t(this,void 0,void 0,(function*(){return this.sendEvent(r.custom,e)}))}sendViewEvent(e){return t(this,void 0,void 0,(function*(){return this.sendEvent(r.view,e)}))}getVisit(){return t(this,void 0,void 0,(function*(){const e=yield fetch(this.baseUrl+"/analytics/visit"),t=yield e.json();return this.visitorId=t.visitorId,t}))}getHealth(){return t(this,void 0,void 0,(function*(){const e=yield fetch(this.baseUrl+"/analytics/monitoring/health");return yield e.json()}))}registerBeforeSendEventHook(e){this.beforeSendHooks.push(e)}addEventTypeMapping(e,t){this.eventTypeMapping[e]=t}parseVariableArgumentsPayload(e,t){const r={};for(let n=0,i=t.length;n<i;n++){const i=t[n];if("string"==typeof i)r[e[n]]=i;else if("object"==typeof i)return Object.assign(Object.assign({},r),i)}return r}isKeyAllowedEmpty(e,t){return-1!==({[r.search]:["queryText"]}[e]||[]).indexOf(t)}removeEmptyPayloadValues(e,t){return Object.keys(e).filter(r=>{return this.isKeyAllowedEmpty(t,r)||null!=(n=e[r])&&""!==n;var n}).reduce((t,r)=>Object.assign(Object.assign({},t),{[r]:e[r]}),{})}removeUnknownParameters(e){return Object.keys(e).filter(e=>{if((e=>[q,F,U,V].some(t=>t(e)))(e))return!0;console.log(e,"is not processed by coveoua")}).reduce((t,r)=>Object.assign(Object.assign({},t),{[r]:e[r]}),{})}processCustomParameters(t){const{custom:r}=t,n=e(t,["custom"]),i=w(o=n).reduce((e,t)=>{const r=A.exec(t)||R.exec(t);if(r){const n=r[1];return Object.assign(Object.assign({},e),$(n,o[t]))}return Object.assign(Object.assign({},e),{[t]:o[t]})},{});var o;return Object.assign(Object.assign({},r||{}),i)}validateParams(t){const{anonymizeIp:r}=t,n=e(t,["anonymizeIp"]);return void 0!==r&&-1==["0","false","undefined","null","{}","[]",""].indexOf((""+r).toLowerCase())&&(n.anonymizeIp=1),n}ensureAnonymousUserWhenUsingApiKey(t){const{userId:r}=t,n=e(t,["userId"]);return(null==(i=this.options.token)?void 0:i.startsWith("xx"))&&!r?(n.userId="anonymous",n):t;var i}get baseUrl(){const{version:e,endpoint:t}=this.options,r=-1!==t.indexOf(".cloud.coveo.com");return`${t}${r?"":"/rest"}/${e}`}}var z;!function(e){e.interfaceLoad="interfaceLoad",e.interfaceChange="interfaceChange",e.didyoumeanAutomatic="didyoumeanAutomatic",e.didyoumeanClick="didyoumeanClick",e.resultsSort="resultsSort",e.searchboxSubmit="searchboxSubmit",e.searchboxClear="searchboxClear",e.searchboxAsYouType="searchboxAsYouType",e.breadcrumbFacet="breadcrumbFacet",e.breadcrumbResetAll="breadcrumbResetAll",e.documentQuickview="documentQuickview",e.documentOpen="documentOpen",e.omniboxAnalytics="omniboxAnalytics",e.omniboxFromLink="omniboxFromLink",e.triggerNotify="notify",e.triggerExecute="execute",e.triggerQuery="query",e.triggerRedirect="redirect",e.pagerResize="pagerResize",e.pagerNumber="pagerNumber",e.pagerNext="pagerNext",e.pagerPrevious="pagerPrevious",e.pagerScrolling="pagerScrolling",e.facetClearAll="facetClearAll",e.facetSearch="facetSearch",e.facetSelect="facetSelect",e.facetSelectAll="facetSelectAll",e.facetDeselect="facetDeselect",e.facetExclude="facetExclude",e.facetUnexclude="facetUnexclude",e.facetUpdateSort="facetUpdateSort",e.facetShowMore="showMoreFacetResults",e.facetShowLess="showLessFacetResults",e.queryError="query",e.queryErrorBack="errorBack",e.queryErrorClear="errorClearQuery",e.queryErrorRetry="errorRetry"}(z||(z={}));const W={[z.triggerNotify]:"queryPipelineTriggers",[z.triggerExecute]:"queryPipelineTriggers",[z.triggerQuery]:"queryPipelineTriggers",[z.triggerRedirect]:"queryPipelineTriggers",[z.queryError]:"errors",[z.queryErrorBack]:"errors",[z.queryErrorClear]:"errors",[z.queryErrorRetry]:"errors",[z.pagerNext]:"getMoreResults",[z.pagerPrevious]:"getMoreResults",[z.pagerNumber]:"getMoreResults",[z.pagerResize]:"getMoreResults",[z.pagerScrolling]:"getMoreResults",[z.facetSearch]:"facet",[z.facetShowLess]:"facet",[z.facetShowMore]:"facet"};class J{constructor(){this.runtime=new Q}sendEvent(){return Promise.resolve()}sendSearchEvent(){return Promise.resolve()}sendClickEvent(){return Promise.resolve()}sendCustomEvent(){return Promise.resolve()}sendViewEvent(){return Promise.resolve()}getVisit(){return Promise.resolve({id:"",visitorId:""})}getHealth(){return Promise.resolve({status:""})}registerBeforeSendEventHook(){}addEventTypeMapping(){}}class Y{constructor(e,t){this.opts=e,this.provider=t,this.coveoAnalyticsClient=!1===e.enableAnalytics?new J:new H(e)}disable(){this.coveoAnalyticsClient instanceof H&&this.coveoAnalyticsClient.clear(),this.coveoAnalyticsClient=new J}enable(){this.coveoAnalyticsClient=new H(this.opts)}logInterfaceLoad(){return this.logSearchEvent(z.interfaceLoad)}logInterfaceChange(e){return this.logSearchEvent(z.interfaceChange,e)}logDidYouMeanAutomatic(){return this.logSearchEvent(z.didyoumeanAutomatic)}logDidYouMeanClick(){return this.logSearchEvent(z.didyoumeanClick)}logResultsSort(e){return this.logSearchEvent(z.resultsSort,e)}logSearchboxSubmit(){return this.logSearchEvent(z.searchboxSubmit)}logSearchboxClear(){return this.logSearchEvent(z.searchboxClear)}logSearchboxAsYouType(){return this.logSearchEvent(z.searchboxAsYouType)}logBreadcrumbFacet(e){return this.logSearchEvent(z.breadcrumbFacet,e)}logBreadcrumbResetAll(){return this.logSearchEvent(z.breadcrumbResetAll)}logDocumentQuickview(e,t){return this.logClickEvent(z.documentQuickview,e,t)}logDocumentOpen(e,t){return this.logClickEvent(z.documentOpen,e,t)}logOmniboxAnalytics(e){return this.logSearchEvent(z.omniboxAnalytics,e)}logOmniboxFromLink(e){return this.logSearchEvent(z.omniboxFromLink,e)}logTriggerNotify(e){return this.logCustomEvent(z.triggerNotify,e)}logTriggerExecute(e){return this.logCustomEvent(z.triggerExecute,e)}logTriggerQuery(){const e={query:this.provider.getSearchEventRequestPayload().queryText};return this.logCustomEvent(z.triggerQuery,e)}logTriggerRedirect(e){const t=Object.assign(Object.assign({},e),{query:this.provider.getSearchEventRequestPayload().queryText});return this.logCustomEvent(z.triggerRedirect,t)}logPagerResize(e){return this.logCustomEvent(z.pagerResize,e)}logPagerNumber(e){return this.logCustomEvent(z.pagerNumber,e)}logPagerNext(e){return this.logCustomEvent(z.pagerNext,e)}logPagerPrevious(e){return this.logCustomEvent(z.pagerPrevious,e)}logPagerScrolling(){return this.logCustomEvent(z.pagerScrolling)}logFacetClearAll(e){return this.logSearchEvent(z.facetClearAll,e)}logFacetSearch(e){return this.logSearchEvent(z.facetSearch,e)}logFacetSelect(e){return this.logSearchEvent(z.facetSelect,e)}logFacetDeselect(e){return this.logSearchEvent(z.facetDeselect,e)}logFacetExclude(e){return this.logSearchEvent(z.facetExclude,e)}logFacetUnexclude(e){return this.logSearchEvent(z.facetUnexclude,e)}logFacetSelectAll(e){return this.logSearchEvent(z.facetSelectAll,e)}logFacetUpdateSort(e){return this.logSearchEvent(z.facetUpdateSort,e)}logFacetShowMore(e){return this.logCustomEvent(z.facetShowMore,e)}logFacetShowLess(e){return this.logCustomEvent(z.facetShowLess,e)}logQueryError(e){return this.logCustomEvent(z.queryError,e)}logQueryErrorBack(){return t(this,void 0,void 0,(function*(){return yield this.logCustomEvent(z.queryErrorBack),this.logSearchEvent(z.queryErrorBack)}))}logQueryErrorRetry(){return t(this,void 0,void 0,(function*(){return yield this.logCustomEvent(z.queryErrorRetry),this.logSearchEvent(z.queryErrorRetry)}))}logQueryErrorClear(){return t(this,void 0,void 0,(function*(){return yield this.logCustomEvent(z.queryErrorClear),this.logSearchEvent(z.queryErrorClear)}))}logCustomEvent(e,t){const r=Object.assign(Object.assign({},this.provider.getBaseMetadata()),t),n=Object.assign(Object.assign({},this.getOrigins()),{eventType:W[e],eventValue:e,lastSearchQueryUid:this.provider.getSearchUID(),customData:r});return this.coveoAnalyticsClient.sendCustomEvent(n)}logSearchEvent(e,t){const r=Object.assign(Object.assign({},this.provider.getBaseMetadata()),t),n=Object.assign(Object.assign(Object.assign({},this.provider.getSearchEventRequestPayload()),this.getOrigins()),{searchQueryUid:this.provider.getSearchUID(),queryPipeline:this.provider.getPipeline(),customData:r,actionCause:e});return this.coveoAnalyticsClient.sendSearchEvent(n)}logClickEvent(e,t,r,n){const i=Object.assign(Object.assign(Object.assign({},this.provider.getBaseMetadata()),r),n),o=Object.assign(Object.assign(Object.assign({},t),this.getOrigins()),{searchQueryUid:this.provider.getSearchUID(),queryPipeline:this.provider.getPipeline(),actionCause:e,customData:i});return this.coveoAnalyticsClient.sendClickEvent(o)}getOrigins(){return{originLevel1:this.provider.getOriginLevel1(),originLevel2:this.provider.getOriginLevel2(),originLevel3:this.provider.getOriginLevel3()}}}export{H as CoveoAnalyticsClient,Y as CoveoSearchPageClient};
function e(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}function t(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{c(n.next(e))}catch(e){o(e)}}function a(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))}var r;!function(e){e.search="search",e.click="click",e.custom="custom",e.view="view",e.collect="collect"}(r||(r={}));class n{constructor(e){this.opts=e}sendEvent(e,r){return t(this,void 0,void 0,(function*(){const{baseUrl:t,visitorIdProvider:n}=this.opts,i=this.shouldAppendVisitorId(e)?this.visitorIdParam:"",o=yield fetch(`${t}/analytics/${e}${i}`,{method:"POST",headers:this.getHeaders(),mode:"cors",body:JSON.stringify(r),credentials:"include"});if(o.ok){const e=yield o.json();return e.visitorId&&(n.currentVisitorId=e.visitorId),e}try{o.json()}catch(e){}throw console.error(`An error has occured when sending the "${e}" event.`,o,r),new Error(`An error has occurred when sending the "${e}" event. Check the console logs for more details.`)}))}shouldAppendVisitorId(e){return-1!==[r.click,r.custom,r.search,r.view].indexOf(e)}get visitorIdParam(){const{visitorIdProvider:e}=this.opts,t=e.currentVisitorId;return t?"?visitor="+t:""}getHeaders(){const{token:e}=this.opts;return Object.assign(Object.assign({},e?{Authorization:"Bearer "+e}:{}),{"Content-Type":"application/json"})}}function i(){return"undefined"!=typeof localStorage}function o(){return"undefined"!=typeof navigator&&navigator.cookieEnabled}function s(){return"undefined"!=typeof crypto&&void 0!==crypto.getRandomValues}const a=[r.click,r.custom,r.search,r.view],c=(e,t)=>-1!==a.indexOf(e)?Object.assign({language:document.documentElement.lang,userAgent:navigator.userAgent},t):t;class l{static set(e,t,r){var n,i,o,s,a;r?((o=new Date).setTime(o.getTime()+r),s="; expires="+o.toGMTString()):s="",-1===(a=location.hostname).indexOf(".")?document.cookie=e+"="+t+s+"; path=/":((i=a.split(".")).shift(),n="."+i.join("."),document.cookie=e+"="+t+s+"; path=/; domain="+n,null!=l.get(e)&&l.get(e)==t||(n="."+a,document.cookie=e+"="+t+s+"; path=/; domain="+n))}static get(e){for(var t=e+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){var i=r[n];if(0==(i=i.replace(/^\s+/,"")).indexOf(t))return i.substring(t.length,i.length)}return null}static erase(e){l.set(e,"",-1)}}function u(){return i()?localStorage:o()?new g:"undefined"!=typeof sessionStorage?sessionStorage:new h}class g{getItem(e){return l.get(`${g.prefix}${e}`)}removeItem(e){l.erase(`${g.prefix}${e}`)}setItem(e,t){l.set(`${g.prefix}${e}`,t)}}g.prefix="coveo_";class d{constructor(){this.cookieStorage=new g}getItem(e){return localStorage.getItem(e)||this.cookieStorage.getItem(e)}removeItem(e){this.cookieStorage.removeItem(e),localStorage.removeItem(e)}setItem(e,t){localStorage.setItem(e,t),this.cookieStorage.setItem(e,t)}}class h{getItem(e){return null}removeItem(e){}setItem(e,t){}}const v="__coveo.analytics.history";class m{constructor(e){this.store=e||u()}addElement(e){e.internalTime=(new Date).getTime(),this.cropQueryElement(e);let t=this.getHistoryWithInternalTime();null!=t?this.isValidEntry(e)&&this.setHistory([e].concat(t)):this.setHistory([e])}getHistory(){const e=this.getHistoryWithInternalTime();return this.stripInternalTime(e)}getHistoryWithInternalTime(){try{const e=this.store.getItem(v);return e?JSON.parse(e):[]}catch(e){return[]}}setHistory(e){try{this.store.setItem(v,JSON.stringify(e.slice(0,20)))}catch(e){}}clear(){try{this.store.removeItem(v)}catch(e){}}getMostRecentElement(){let e=this.getHistoryWithInternalTime();if(null!=e){return e.sort((e,t)=>(t.internalTime||0)-(e.internalTime||0))[0]}return null}cropQueryElement(e){e.name&&"query"==e.name.toLowerCase()&&null!=e.value&&(e.value=e.value.slice(0,75))}isValidEntry(e){let t=this.getMostRecentElement();return!t||t.value!=e.value||(e.internalTime||0)-(t.internalTime||0)>6e4}stripInternalTime(e){return e.map(e=>{const{name:t,time:r,value:n}=e;return{name:t,time:r,value:n}})}}const p=(e,t)=>e===r.view?(y(t.contentIdValue),Object.assign({location:window.location.toString(),referrer:document.referrer,title:document.title},t)):t,y=e=>{const t=new m,r={name:"PageView",value:e,time:JSON.stringify(new Date)};t.addElement(r)},f=e=>e?(Number(e)^b(new Uint8Array(1))[0]%16>>Number(e)/4).toString(16):"10000000-1000-4000-8000-100000000000".replace(/[018]/g,f),b=e=>{if(s())return crypto.getRandomValues(e);for(var t=0,r=0;t<e.length;t++)0==(3&t)&&(r=4294967296*Math.random()),e[t]=r>>>((3&t)<<3)&255;return e},E={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",price:"pr",quantity:"qt",coupon:"cc",position:"ps"},S={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",position:"ps",price:"pr"},O=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},{eventCategory:"ec",eventAction:"ea",eventLabel:"el",eventValue:"ev",page:"dp",visitorId:"cid",clientId:"cid",userId:"uid",currencyCode:"cu"}),{action:"pa",list:"pal",listSource:"pls"}),{id:"ti",revenue:"tr",tax:"tt",shipping:"ts",coupon:"tcc",affiliation:"ta",step:"cos",option:"col"}),{hitType:"t",pageViewId:"pid",encoding:"de",location:"dl",referrer:"dr",screenColor:"sd",screenResolution:"sr",title:"dt",userAgent:"ua",language:"ul",eventId:"z",time:"tm"}),{anonymizeIp:"aip"}),w=Object.keys,I=w(O).map(e=>O[e]),C=w(E).map(e=>E[e]),x=w(S).map(e=>S[e]),j=[...C,"custom"].join("|"),k=[...x,"custom"].join("|"),P=new RegExp(`^(pr[0-9]+)(${j})$`),T=new RegExp(`^((il[0-9]+pi[0-9]+)(${k}))|(il[0-9]+nm)$`),A=new RegExp("^(pr[0-9]+)custom$"),R=new RegExp("^(il[0-9]+pi[0-9]+)custom$"),q=e=>P.test(e),F=e=>T.test(e),U=e=>-1!==I.indexOf(e),V=e=>"custom"===e,$=(e,t)=>w(t).reduce((r,n)=>Object.assign(Object.assign({},r),{[`${e}${n}`]:t[n]}),{});class L{constructor(e){this.opts=e}sendEvent(e,r){return t(this,void 0,void 0,(function*(){if(!navigator.sendBeacon)throw new Error('navigator.sendBeacon is not supported in this browser. Consider adding a polyfill like "sendbeacon-polyfill".');const{baseUrl:t}=this.opts,n=this.encodeForEventType(e,r),i=this.getQueryParamsForEventType(e),o=`${t}/analytics/${e}?${i}`;console.log(`Sending beacon for "${e}" with: `,JSON.stringify(r)),navigator.sendBeacon(o,new Blob([n],{type:"application/x-www-form-urlencoded"}))}))}encodeForEventType(e,t){return this.isEventTypeLegacy(e)?this.encodeForLegacyType(e,t):this.encodeForFormUrlEncoded(Object.assign({access_token:this.opts.token},t))}getQueryParamsForEventType(e){const{token:t,visitorIdProvider:r}=this.opts,n=r.currentVisitorId;return[t&&this.isEventTypeLegacy(e)?"access_token="+t:"",n?"visitorId="+n:""].filter(e=>!!e).join("&")}isEventTypeLegacy(e){return-1!==[r.click,r.custom,r.search,r.view].indexOf(e)}encodeForLegacyType(e,t){return`${e}Event=${encodeURIComponent(JSON.stringify(t))}`}encodeForFormUrlEncoded(e){return Object.keys(e).filter(t=>!!e[t]).map(t=>`${encodeURIComponent(t)}=${encodeURIComponent(this.encodeValue(e[t]))}`).join("&")}encodeValue(e){return"number"==typeof e||"string"==typeof e||"boolean"==typeof e?e:JSON.stringify(e)}}class B{sendEvent(e,r){return t(this,void 0,void 0,(function*(){return Promise.resolve()}))}}class M{constructor(e,t){i()&&o()?this.storage=new d:i()?this.storage=localStorage:(console.warn("BrowserRuntime detected no valid storage available.",this),this.storage=new h),this.beaconClient=new L(e),window.addEventListener("beforeunload",()=>t())}}class N{constructor(){this.storage=new h,this.beaconClient=new B}}class Q{constructor(){this.storage=new h,this.beaconClient=new B}}const D="https://platform.cloud.coveo.com/rest/ua";class H{constructor(e){if(!e)throw new Error("You have to pass options to this constructor");this.options=Object.assign(Object.assign({},this.defaultOptions),e),this.visitorId="",this.bufferedRequests=[],this.beforeSendHooks=[p,c],this.eventTypeMapping={};const t={baseUrl:this.baseUrl,token:this.options.token,visitorIdProvider:this};this.runtime=this.initRuntime(t),this.analyticsFetchClient=new n(t),this.initVisitorId()}get defaultOptions(){return{endpoint:D,token:"",version:"v15"}}initRuntime(e){return"undefined"!=typeof window&&"undefined"!=typeof document?new M(e,()=>this.flushBufferWithBeacon()):new N}get analyticsBeaconClient(){return this.runtime.beaconClient}get storage(){return this.runtime.storage}initVisitorId(){const e=this.visitorId||this.storage.getItem("visitorId")||"";this.currentVisitorId=e||f()}get currentVisitorId(){return this.visitorId}set currentVisitorId(e){this.visitorId=e,this.storage.setItem("visitorId",e)}sendEvent(e,...r){return t(this,void 0,void 0,(function*(){const{newEventType:t=e,variableLengthArgumentsNames:n=[],addVisitorIdParameter:i=!1,usesMeasurementProtocol:o=!1}=this.eventTypeMapping[e]||{},s=[e=>n.length>0?this.parseVariableArgumentsPayload(n,e):e[0],e=>Object.assign({visitorId:i?this.visitorId:""},e),e=>o?this.ensureAnonymousUserWhenUsingApiKey(e):e,t=>this.beforeSendHooks.reduce((t,r)=>r(e,t),t),t=>this.removeEmptyPayloadValues(t,e),e=>this.validateParams(e),e=>{return o?w(t=e).reduce((e,r)=>{const n=O[r]||r;return Object.assign(Object.assign({},e),{[n]:t[r]})},{}):e;var t},e=>o?this.removeUnknownParameters(e):e,e=>o?this.processCustomParameters(e):e].reduce((e,t)=>t(e),r);return this.bufferedRequests.push({eventType:t,payload:s,handled:!1}),yield this.deferExecution(),yield this.sendFromBufferWithFetch()}))}deferExecution(){return new Promise(e=>setTimeout(e,0))}flushBufferWithBeacon(){for(;this.hasPendingRequests();){const{eventType:e,payload:t}=this.bufferedRequests.pop();this.analyticsBeaconClient.sendEvent(e,t)}}sendFromBufferWithFetch(){return t(this,void 0,void 0,(function*(){const e=this.bufferedRequests.shift();if(e){const{eventType:t,payload:r}=e;return this.analyticsFetchClient.sendEvent(t,r)}}))}hasPendingRequests(){return this.bufferedRequests.length>0}clear(){this.storage.removeItem("visitorId"),(new m).clear()}sendSearchEvent(e){return t(this,void 0,void 0,(function*(){return this.sendEvent(r.search,e)}))}sendClickEvent(e){return t(this,void 0,void 0,(function*(){return this.sendEvent(r.click,e)}))}sendCustomEvent(e){return t(this,void 0,void 0,(function*(){return this.sendEvent(r.custom,e)}))}sendViewEvent(e){return t(this,void 0,void 0,(function*(){return this.sendEvent(r.view,e)}))}getVisit(){return t(this,void 0,void 0,(function*(){const e=yield fetch(this.baseUrl+"/analytics/visit"),t=yield e.json();return this.visitorId=t.visitorId,t}))}getHealth(){return t(this,void 0,void 0,(function*(){const e=yield fetch(this.baseUrl+"/analytics/monitoring/health");return yield e.json()}))}registerBeforeSendEventHook(e){this.beforeSendHooks.push(e)}addEventTypeMapping(e,t){this.eventTypeMapping[e]=t}parseVariableArgumentsPayload(e,t){const r={};for(let n=0,i=t.length;n<i;n++){const i=t[n];if("string"==typeof i)r[e[n]]=i;else if("object"==typeof i)return Object.assign(Object.assign({},r),i)}return r}isKeyAllowedEmpty(e,t){return-1!==({[r.search]:["queryText"]}[e]||[]).indexOf(t)}removeEmptyPayloadValues(e,t){return Object.keys(e).filter(r=>{return this.isKeyAllowedEmpty(t,r)||null!=(n=e[r])&&""!==n;var n}).reduce((t,r)=>Object.assign(Object.assign({},t),{[r]:e[r]}),{})}removeUnknownParameters(e){return Object.keys(e).filter(e=>{if((e=>[q,F,U,V].some(t=>t(e)))(e))return!0;console.log(e,"is not processed by coveoua")}).reduce((t,r)=>Object.assign(Object.assign({},t),{[r]:e[r]}),{})}processCustomParameters(t){const{custom:r}=t,n=e(t,["custom"]),i=w(o=n).reduce((e,t)=>{const r=A.exec(t)||R.exec(t);if(r){const n=r[1];return Object.assign(Object.assign({},e),$(n,o[t]))}return Object.assign(Object.assign({},e),{[t]:o[t]})},{});var o;return Object.assign(Object.assign({},r||{}),i)}validateParams(t){const{anonymizeIp:r}=t,n=e(t,["anonymizeIp"]);return void 0!==r&&-1==["0","false","undefined","null","{}","[]",""].indexOf((""+r).toLowerCase())&&(n.anonymizeIp=1),n}ensureAnonymousUserWhenUsingApiKey(t){const{userId:r}=t,n=e(t,["userId"]);return(null==(i=this.options.token)?void 0:i.startsWith("xx"))&&!r?(n.userId="anonymous",n):t;var i}get baseUrl(){const{version:e,endpoint:t}=this.options,r=-1!==t.indexOf(".cloud.coveo.com");return`${t}${r?"":"/rest"}/${e}`}}var z;!function(e){e.interfaceLoad="interfaceLoad",e.interfaceChange="interfaceChange",e.didyoumeanAutomatic="didyoumeanAutomatic",e.didyoumeanClick="didyoumeanClick",e.resultsSort="resultsSort",e.searchboxSubmit="searchboxSubmit",e.searchboxClear="searchboxClear",e.searchboxAsYouType="searchboxAsYouType",e.breadcrumbFacet="breadcrumbFacet",e.breadcrumbResetAll="breadcrumbResetAll",e.documentQuickview="documentQuickview",e.documentOpen="documentOpen",e.omniboxAnalytics="omniboxAnalytics",e.omniboxFromLink="omniboxFromLink",e.triggerNotify="notify",e.triggerExecute="execute",e.triggerQuery="query",e.triggerRedirect="redirect",e.pagerResize="pagerResize",e.pagerNumber="pagerNumber",e.pagerNext="pagerNext",e.pagerPrevious="pagerPrevious",e.pagerScrolling="pagerScrolling",e.facetClearAll="facetClearAll",e.facetSearch="facetSearch",e.facetSelect="facetSelect",e.facetSelectAll="facetSelectAll",e.facetDeselect="facetDeselect",e.facetExclude="facetExclude",e.facetUnexclude="facetUnexclude",e.facetUpdateSort="facetUpdateSort",e.facetShowMore="showMoreFacetResults",e.facetShowLess="showLessFacetResults",e.queryError="query",e.queryErrorBack="errorBack",e.queryErrorClear="errorClearQuery",e.queryErrorRetry="errorRetry"}(z||(z={}));const W={[z.triggerNotify]:"queryPipelineTriggers",[z.triggerExecute]:"queryPipelineTriggers",[z.triggerQuery]:"queryPipelineTriggers",[z.triggerRedirect]:"queryPipelineTriggers",[z.queryError]:"errors",[z.queryErrorBack]:"errors",[z.queryErrorClear]:"errors",[z.queryErrorRetry]:"errors",[z.pagerNext]:"getMoreResults",[z.pagerPrevious]:"getMoreResults",[z.pagerNumber]:"getMoreResults",[z.pagerResize]:"getMoreResults",[z.pagerScrolling]:"getMoreResults",[z.facetSearch]:"facet",[z.facetShowLess]:"facet",[z.facetShowMore]:"facet"};class J{constructor(){this.runtime=new Q,this.currentVisitorId=""}sendEvent(){return Promise.resolve()}sendSearchEvent(){return Promise.resolve()}sendClickEvent(){return Promise.resolve()}sendCustomEvent(){return Promise.resolve()}sendViewEvent(){return Promise.resolve()}getVisit(){return Promise.resolve({id:"",visitorId:""})}getHealth(){return Promise.resolve({status:""})}registerBeforeSendEventHook(){}addEventTypeMapping(){}}class Y{constructor(e,t){this.opts=e,this.provider=t,this.coveoAnalyticsClient=!1===e.enableAnalytics?new J:new H(e)}disable(){this.coveoAnalyticsClient instanceof H&&this.coveoAnalyticsClient.clear(),this.coveoAnalyticsClient=new J}enable(){this.coveoAnalyticsClient=new H(this.opts)}logInterfaceLoad(){return this.logSearchEvent(z.interfaceLoad)}logInterfaceChange(e){return this.logSearchEvent(z.interfaceChange,e)}logDidYouMeanAutomatic(){return this.logSearchEvent(z.didyoumeanAutomatic)}logDidYouMeanClick(){return this.logSearchEvent(z.didyoumeanClick)}logResultsSort(e){return this.logSearchEvent(z.resultsSort,e)}logSearchboxSubmit(){return this.logSearchEvent(z.searchboxSubmit)}logSearchboxClear(){return this.logSearchEvent(z.searchboxClear)}logSearchboxAsYouType(){return this.logSearchEvent(z.searchboxAsYouType)}logBreadcrumbFacet(e){return this.logSearchEvent(z.breadcrumbFacet,e)}logBreadcrumbResetAll(){return this.logSearchEvent(z.breadcrumbResetAll)}logDocumentQuickview(e,t){return this.logClickEvent(z.documentQuickview,e,t)}logDocumentOpen(e,t){return this.logClickEvent(z.documentOpen,e,t)}logOmniboxAnalytics(e){return this.logSearchEvent(z.omniboxAnalytics,e)}logOmniboxFromLink(e){return this.logSearchEvent(z.omniboxFromLink,e)}logTriggerNotify(e){return this.logCustomEvent(z.triggerNotify,e)}logTriggerExecute(e){return this.logCustomEvent(z.triggerExecute,e)}logTriggerQuery(){const e={query:this.provider.getSearchEventRequestPayload().queryText};return this.logCustomEvent(z.triggerQuery,e)}logTriggerRedirect(e){const t=Object.assign(Object.assign({},e),{query:this.provider.getSearchEventRequestPayload().queryText});return this.logCustomEvent(z.triggerRedirect,t)}logPagerResize(e){return this.logCustomEvent(z.pagerResize,e)}logPagerNumber(e){return this.logCustomEvent(z.pagerNumber,e)}logPagerNext(e){return this.logCustomEvent(z.pagerNext,e)}logPagerPrevious(e){return this.logCustomEvent(z.pagerPrevious,e)}logPagerScrolling(){return this.logCustomEvent(z.pagerScrolling)}logFacetClearAll(e){return this.logSearchEvent(z.facetClearAll,e)}logFacetSearch(e){return this.logSearchEvent(z.facetSearch,e)}logFacetSelect(e){return this.logSearchEvent(z.facetSelect,e)}logFacetDeselect(e){return this.logSearchEvent(z.facetDeselect,e)}logFacetExclude(e){return this.logSearchEvent(z.facetExclude,e)}logFacetUnexclude(e){return this.logSearchEvent(z.facetUnexclude,e)}logFacetSelectAll(e){return this.logSearchEvent(z.facetSelectAll,e)}logFacetUpdateSort(e){return this.logSearchEvent(z.facetUpdateSort,e)}logFacetShowMore(e){return this.logCustomEvent(z.facetShowMore,e)}logFacetShowLess(e){return this.logCustomEvent(z.facetShowLess,e)}logQueryError(e){return this.logCustomEvent(z.queryError,e)}logQueryErrorBack(){return t(this,void 0,void 0,(function*(){return yield this.logCustomEvent(z.queryErrorBack),this.logSearchEvent(z.queryErrorBack)}))}logQueryErrorRetry(){return t(this,void 0,void 0,(function*(){return yield this.logCustomEvent(z.queryErrorRetry),this.logSearchEvent(z.queryErrorRetry)}))}logQueryErrorClear(){return t(this,void 0,void 0,(function*(){return yield this.logCustomEvent(z.queryErrorClear),this.logSearchEvent(z.queryErrorClear)}))}logCustomEvent(e,t){const r=Object.assign(Object.assign({},this.provider.getBaseMetadata()),t),n=Object.assign(Object.assign({},this.getOrigins()),{eventType:W[e],eventValue:e,lastSearchQueryUid:this.provider.getSearchUID(),customData:r});return this.coveoAnalyticsClient.sendCustomEvent(n)}logSearchEvent(e,t){const r=Object.assign(Object.assign({},this.provider.getBaseMetadata()),t),n=Object.assign(Object.assign(Object.assign({},this.provider.getSearchEventRequestPayload()),this.getOrigins()),{searchQueryUid:this.provider.getSearchUID(),queryPipeline:this.provider.getPipeline(),customData:r,actionCause:e});return this.coveoAnalyticsClient.sendSearchEvent(n)}logClickEvent(e,t,r,n){const i=Object.assign(Object.assign(Object.assign({},this.provider.getBaseMetadata()),r),n),o=Object.assign(Object.assign(Object.assign({},t),this.getOrigins()),{searchQueryUid:this.provider.getSearchUID(),queryPipeline:this.provider.getPipeline(),actionCause:e,customData:i});return this.coveoAnalyticsClient.sendClickEvent(o)}getOrigins(){return{originLevel1:this.provider.getOriginLevel1(),originLevel2:this.provider.getOriginLevel2(),originLevel3:this.provider.getOriginLevel3()}}}export{H as CoveoAnalyticsClient,Y as CoveoSearchPageClient};
//# sourceMappingURL=library.es.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).coveoua={})}(this,function(e){"use strict";var n,t,d=function(){return(d=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function s(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}function r(e,s,a,u){return new(a=a||Promise)(function(r,t){function n(e){try{i(u.next(e))}catch(e){t(e)}}function o(e){try{i(u.throw(e))}catch(e){t(e)}}function i(e){var t;e.done?r(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(n,o)}i((u=u.apply(e,s||[])).next())})}function g(r,n){var o,i,s,e,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return e={next:t(0),throw:t(1),return:t(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(o)throw new TypeError("Generator is already executing.");for(;a;)try{if(o=1,i&&(s=2&t[0]?i.return:t[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,t[1])).done)return s;switch(i=0,s&&(t=[2&t[0],s.value]),t[0]){case 0:case 1:s=t;break;case 4:return a.label++,{value:t[1],done:!1};case 5:a.label++,i=t[1],t=[0];continue;case 7:t=a.ops.pop(),a.trys.pop();continue;default:if(!(s=0<(s=a.trys).length&&s[s.length-1])&&(6===t[0]||2===t[0])){a=0;continue}if(3===t[0]&&(!s||t[1]>s[0]&&t[1]<s[3])){a.label=t[1];break}if(6===t[0]&&a.label<s[1]){a.label=s[1],s=t;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(t);break}s[2]&&a.ops.pop(),a.trys.pop();continue}t=n.call(r,a)}catch(e){t=[6,e],i=0}finally{o=s=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}}function a(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,o++)n[o]=i[s];return n}(t=n=n||{}).search="search",t.click="click",t.custom="custom",t.view="view",t.collect="collect";var o=(i.prototype.sendEvent=function(a,u){return r(this,void 0,void 0,function(){var t,r,n,o,i,s;return g(this,function(e){switch(e.label){case 0:return t=this.opts,r=t.baseUrl,n=t.visitorIdProvider,o=this.shouldAppendVisitorId(a)?this.visitorIdParam:"",[4,fetch(r+"/analytics/"+a+o,{method:"POST",headers:this.getHeaders(),mode:"cors",body:JSON.stringify(u),credentials:"include"})];case 1:return(i=e.sent()).ok?[4,i.json()]:[3,3];case 2:return(s=e.sent()).visitorId&&(n.currentVisitorId=s.visitorId),[2,s];case 3:try{i.json()}catch(e){}throw console.error('An error has occured when sending the "'+a+'" event.',i,u),new Error('An error has occurred when sending the "'+a+'" event. Check the console logs for more details.')}})})},i.prototype.shouldAppendVisitorId=function(e){return-1!==[n.click,n.custom,n.search,n.view].indexOf(e)},Object.defineProperty(i.prototype,"visitorIdParam",{get:function(){var e=this.opts.visitorIdProvider.currentVisitorId;return e?"?visitor="+e:""},enumerable:!0,configurable:!0}),i.prototype.getHeaders=function(){var e=this.opts.token;return d(d({},e?{Authorization:"Bearer "+e}:{}),{"Content-Type":"application/json"})},i);function i(e){this.opts=e}function u(){return"undefined"!=typeof navigator}function c(){return"undefined"!=typeof localStorage}function l(){return u()&&navigator.cookieEnabled}function p(){return"undefined"!=typeof crypto&&void 0!==crypto.getRandomValues}function f(e,t){return-1!==h.indexOf(e)?d({language:document.documentElement.lang,userAgent:navigator.userAgent},t):t}var h=[n.click,n.custom,n.search,n.view],v=(y.set=function(e,t,r){var n,o,i,s,a;s=r?((i=new Date).setTime(i.getTime()+r),"; expires="+i.toGMTString()):"",-1===(a=location.hostname).indexOf(".")?document.cookie=e+"="+t+s+"; path=/":((o=a.split(".")).shift(),n="."+o.join("."),document.cookie=e+"="+t+s+"; path=/; domain="+n,null!=y.get(e)&&y.get(e)==t||(n="."+a,document.cookie=e+"="+t+s+"; path=/; domain="+n))},y.get=function(e){for(var t=e+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){var o=r[n];if(0==(o=o.replace(/^\s+/,"")).indexOf(t))return o.substring(t.length,o.length)}return null},y.erase=function(e){y.set(e,"",-1)},y);function y(){}function m(){return c()?localStorage:l()?new E:"undefined"!=typeof sessionStorage?sessionStorage:new I}var E=(w.prototype.getItem=function(e){return v.get(""+w.prefix+e)},w.prototype.removeItem=function(e){v.erase(""+w.prefix+e)},w.prototype.setItem=function(e,t){v.set(""+w.prefix+e,t)},w.prefix="coveo_",w);function w(){}var b=(S.prototype.getItem=function(e){return localStorage.getItem(e)||this.cookieStorage.getItem(e)},S.prototype.removeItem=function(e){this.cookieStorage.removeItem(e),localStorage.removeItem(e)},S.prototype.setItem=function(e,t){localStorage.setItem(e,t),this.cookieStorage.setItem(e,t)},S);function S(){this.cookieStorage=new E}var I=(C.prototype.getItem=function(e){return null},C.prototype.removeItem=function(e){},C.prototype.setItem=function(e,t){},C);function C(){}var x=Object.freeze({__proto__:null,preferredStorage:null,getAvailableStorage:m,CookieStorage:E,CookieAndLocalStorage:b,NullStorage:I}),P="__coveo.analytics.history",k=(A.prototype.addElement=function(e){e.internalTime=(new Date).getTime(),this.cropQueryElement(e);var t=this.getHistoryWithInternalTime();null!=t?this.isValidEntry(e)&&this.setHistory([e].concat(t)):this.setHistory([e])},A.prototype.getHistory=function(){var e=this.getHistoryWithInternalTime();return this.stripInternalTime(e)},A.prototype.getHistoryWithInternalTime=function(){try{var e=this.store.getItem(P);return e?JSON.parse(e):[]}catch(e){return[]}},A.prototype.setHistory=function(e){try{this.store.setItem(P,JSON.stringify(e.slice(0,20)))}catch(e){}},A.prototype.clear=function(){try{this.store.removeItem(P)}catch(e){}},A.prototype.getMostRecentElement=function(){var e=this.getHistoryWithInternalTime();return null==e?null:e.sort(function(e,t){return(t.internalTime||0)-(e.internalTime||0)})[0]},A.prototype.cropQueryElement=function(e){e.name&&"query"==e.name.toLowerCase()&&null!=e.value&&(e.value=e.value.slice(0,75))},A.prototype.isValidEntry=function(e){var t=this.getMostRecentElement();return!t||t.value!=e.value||6e4<(e.internalTime||0)-(t.internalTime||0)},A.prototype.stripInternalTime=function(e){return e.map(function(e){return{name:e.name,time:e.time,value:e.value}})},A);function A(e){this.store=e||m(),this.store instanceof E||!l()||(new E).removeItem(P)}function O(e,t){return e===n.view?(L(t.contentIdValue),d({location:window.location.toString(),referrer:document.referrer,title:document.title},t)):t}function T(t){return[function(e){return W.test(e)},function(e){return J.test(e)},function(e){return-1!==M.indexOf(e)},function(e){return"custom"===e}].some(function(e){return e(t)})}var R=Object.freeze({__proto__:null,STORE_KEY:P,MAX_NUMBER_OF_HISTORY_ELEMENTS:20,MIN_THRESHOLD_FOR_DUPLICATE_VALUE:6e4,MAX_VALUE_SIZE:75,HistoryStore:k,default:k}),L=function(e){var t=new k,r={name:"PageView",value:e,time:JSON.stringify(new Date)};t.addElement(r)},F=function(e){return e?(Number(e)^V(new Uint8Array(1))[0]%16>>Number(e)/4).toString(16):(""+1e7+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,F)},V=function(e){if(p())return crypto.getRandomValues(e);for(var t=0,r=0;t<e.length;t++)0==(3&t)&&(r=4294967296*Math.random()),e[t]=r>>>((3&t)<<3)&255;return e},q={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",price:"pr",quantity:"qt",coupon:"cc",position:"ps"},j={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",position:"ps",price:"pr"},N=d(d(d(d(d({},{eventCategory:"ec",eventAction:"ea",eventLabel:"el",eventValue:"ev",page:"dp",visitorId:"cid",clientId:"cid",userId:"uid",currencyCode:"cu"}),{action:"pa",list:"pal",listSource:"pls"}),{id:"ti",revenue:"tr",tax:"tt",shipping:"ts",coupon:"tcc",affiliation:"ta",step:"cos",option:"col"}),{hitType:"t",pageViewId:"pid",encoding:"de",location:"dl",referrer:"dr",screenColor:"sd",screenResolution:"sr",title:"dt",userAgent:"ua",language:"ul",eventId:"z",time:"tm"}),{anonymizeIp:"aip"}),U=Object.keys,_=function(o,i,s){return U(o).reduce(function(e,t){var r,n="il"+(i+1)+"pi"+(s+1)+(j[t]||t);return d(d({},e),((r={})[n]=o[t],r))},{})},M=U(N).map(function(e){return N[e]}),B=U(q).map(function(e){return q[e]}),D=U(j).map(function(e){return j[e]}),H=a(B,["custom"]).join("|"),Q=a(D,["custom"]).join("|"),z="(pr[0-9]+)",Y="(il[0-9]+pi[0-9]+)",W=new RegExp("^"+z+"("+H+")$"),J=new RegExp("^("+Y+"("+Q+"))|(il[0-9]+nm)$"),$=new RegExp("^"+z+"custom$"),G=new RegExp("^"+Y+"custom$"),K=function(n,o){return U(o).reduce(function(e,t){var r;return d(d({},e),((r={})[""+n+t]=o[t],r))},{})},X=(Z.prototype.sendEvent=function(i,s){return r(this,void 0,void 0,function(){var t,r,n,o;return g(this,function(e){if(!navigator.sendBeacon)throw new Error('navigator.sendBeacon is not supported in this browser. Consider adding a polyfill like "sendbeacon-polyfill".');return t=this.opts.baseUrl,r=this.encodeForEventType(i,s),n=this.getQueryParamsForEventType(i),o=t+"/analytics/"+i+"?"+n,console.log('Sending beacon for "'+i+'" with: ',JSON.stringify(s)),navigator.sendBeacon(o,new Blob([r],{type:"application/x-www-form-urlencoded"})),[2]})})},Z.prototype.encodeForEventType=function(e,t){return this.isEventTypeLegacy(e)?this.encodeForLegacyType(e,t):this.encodeForFormUrlEncoded(d({access_token:this.opts.token},t))},Z.prototype.getQueryParamsForEventType=function(e){var t=this.opts,r=t.token,n=t.visitorIdProvider.currentVisitorId;return[r&&this.isEventTypeLegacy(e)?"access_token="+r:"",n?"visitorId="+n:""].filter(function(e){return!!e}).join("&")},Z.prototype.isEventTypeLegacy=function(e){return-1!==[n.click,n.custom,n.search,n.view].indexOf(e)},Z.prototype.encodeForLegacyType=function(e,t){return e+"Event="+encodeURIComponent(JSON.stringify(t))},Z.prototype.encodeForFormUrlEncoded=function(t){var r=this;return Object.keys(t).filter(function(e){return!!t[e]}).map(function(e){return encodeURIComponent(e)+"="+encodeURIComponent(r.encodeValue(t[e]))}).join("&")},Z.prototype.encodeValue=function(e){return"number"==typeof e||"string"==typeof e||"boolean"==typeof e?e:JSON.stringify(e)},Z);function Z(e){this.opts=e}var ee=(te.prototype.sendEvent=function(e,t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,Promise.resolve()]})})},te);function te(){}var re=function(e,t){c()&&l()?this.storage=new b:c()?this.storage=localStorage:(console.warn("BrowserRuntime detected no valid storage available.",this),this.storage=new I),this.beaconClient=new X(e),window.addEventListener("beforeunload",function(){return t()})},ne=function(){this.storage=new I,this.beaconClient=new ee},oe=function(){this.storage=new I,this.beaconClient=new ee},ie={default:"https://platform.cloud.coveo.com/rest/ua",production:"https://platform.cloud.coveo.com/rest/ua",hipaa:"https://platformhipaa.cloud.coveo.com/rest/ua"},se=(Object.defineProperty(ae.prototype,"defaultOptions",{get:function(){return{endpoint:ie.default,token:"",version:"v15"}},enumerable:!0,configurable:!0}),ae.prototype.initRuntime=function(e){var t=this;return"undefined"!=typeof window&&"undefined"!=typeof document?new re(e,function(){return t.flushBufferWithBeacon()}):new ne},Object.defineProperty(ae.prototype,"analyticsBeaconClient",{get:function(){return this.runtime.beaconClient},enumerable:!0,configurable:!0}),Object.defineProperty(ae.prototype,"storage",{get:function(){return this.runtime.storage},enumerable:!0,configurable:!0}),ae.prototype.initVisitorId=function(){var e=this.visitorId||this.storage.getItem("visitorId")||"";this.currentVisitorId=e||F()},Object.defineProperty(ae.prototype,"currentVisitorId",{get:function(){return this.visitorId},set:function(e){this.visitorId=e,this.storage.setItem("visitorId",e)},enumerable:!0,configurable:!0}),ae.prototype.sendEvent=function(f){for(var h=[],e=1;e<arguments.length;e++)h[e-1]=arguments[e];return r(this,void 0,void 0,function(){var t,r,n,o,i,s,a,u,c,l,p=this;return g(this,function(e){switch(e.label){case 0:return t=this.eventTypeMapping[f]||{},n=void 0===(r=t.newEventType)?f:r,i=void 0===(o=t.variableLengthArgumentsNames)?[]:o,a=void 0!==(s=t.addVisitorIdParameter)&&s,c=void 0!==(u=t.usesMeasurementProtocol)&&u,l=[function(e){return 0<i.length?p.parseVariableArgumentsPayload(i,e):e[0]},function(e){return d({visitorId:a?p.visitorId:""},e)},function(e){return c?p.ensureAnonymousUserWhenUsingApiKey(e):e},function(e){return p.beforeSendHooks.reduce(function(e,t){return t(f,e)},e)},function(e){return p.removeEmptyPayloadValues(e,f)},function(e){return p.validateParams(e)},function(e){return c?U(o=e).reduce(function(e,t){var r,n=N[t]||t;return d(d({},e),((r={})[n]=o[t],r))},{}):e;var o},function(e){return c?p.removeUnknownParameters(e):e},function(e){return c?p.processCustomParameters(e):e}].reduce(function(e,t){return t(e)},h),this.bufferedRequests.push({eventType:n,payload:l,handled:!1}),[4,this.deferExecution()];case 1:return e.sent(),[4,this.sendFromBufferWithFetch()];case 2:return[2,e.sent()]}})})},ae.prototype.deferExecution=function(){return new Promise(function(e){return setTimeout(e,0)})},ae.prototype.flushBufferWithBeacon=function(){for(;this.hasPendingRequests();){var e=this.bufferedRequests.pop(),t=e.eventType,r=e.payload;this.analyticsBeaconClient.sendEvent(t,r)}},ae.prototype.sendFromBufferWithFetch=function(){return r(this,void 0,void 0,function(){var t,r,n;return g(this,function(e){return(t=this.bufferedRequests.shift())?(r=t.eventType,n=t.payload,[2,this.analyticsFetchClient.sendEvent(r,n)]):[2]})})},ae.prototype.hasPendingRequests=function(){return 0<this.bufferedRequests.length},ae.prototype.clear=function(){this.storage.removeItem("visitorId"),(new k).clear()},ae.prototype.sendSearchEvent=function(t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,this.sendEvent(n.search,t)]})})},ae.prototype.sendClickEvent=function(t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,this.sendEvent(n.click,t)]})})},ae.prototype.sendCustomEvent=function(t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,this.sendEvent(n.custom,t)]})})},ae.prototype.sendViewEvent=function(t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,this.sendEvent(n.view,t)]})})},ae.prototype.getVisit=function(){return r(this,void 0,void 0,function(){var t;return g(this,function(e){switch(e.label){case 0:return[4,fetch(this.baseUrl+"/analytics/visit")];case 1:return[4,e.sent().json()];case 2:return t=e.sent(),this.visitorId=t.visitorId,[2,t]}})})},ae.prototype.getHealth=function(){return r(this,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,fetch(this.baseUrl+"/analytics/monitoring/health")];case 1:return[4,e.sent().json()];case 2:return[2,e.sent()]}})})},ae.prototype.registerBeforeSendEventHook=function(e){this.beforeSendHooks.push(e)},ae.prototype.addEventTypeMapping=function(e,t){this.eventTypeMapping[e]=t},ae.prototype.parseVariableArgumentsPayload=function(e,t){for(var r={},n=0,o=t.length;n<o;n++){var i=t[n];if("string"==typeof i)r[e[n]]=i;else if("object"==typeof i)return d(d({},r),i)}return r},ae.prototype.isKeyAllowedEmpty=function(e,t){var r;return-1!==((r={})[n.search]=["queryText"],(r[e]||[]).indexOf(t))},ae.prototype.removeEmptyPayloadValues=function(n,r){var o=this;return Object.keys(n).filter(function(e){return o.isKeyAllowedEmpty(r,e)||null!=(t=n[e])&&""!==t;var t}).reduce(function(e,t){var r;return d(d({},e),((r={})[t]=n[t],r))},{})},ae.prototype.removeUnknownParameters=function(n){return Object.keys(n).filter(function(e){if(T(e))return!0;console.log(e,"is not processed by coveoua")}).reduce(function(e,t){var r;return d(d({},e),((r={})[t]=n[t],r))},{})},ae.prototype.processCustomParameters=function(e){var i,t=e.custom,r=s(e,["custom"]),n=U(i=r).reduce(function(e,t){var r,n=$.exec(t)||G.exec(t);if(n){var o=n[1];return d(d({},e),K(o,i[t]))}return d(d({},e),((r={})[t]=i[t],r))},{});return d(d({},t||{}),n)},ae.prototype.validateParams=function(e){var t=e.anonymizeIp,r=s(e,["anonymizeIp"]);return void 0!==t&&-1==["0","false","undefined","null","{}","[]",""].indexOf((""+t).toLowerCase())&&(r.anonymizeIp=1),r},ae.prototype.ensureAnonymousUserWhenUsingApiKey=function(e){var t,r=e.userId,n=s(e,["userId"]);return null!=(t=this.options.token)&&t.startsWith("xx")&&!r?(n.userId="anonymous",n):e},Object.defineProperty(ae.prototype,"baseUrl",{get:function(){var e=this.options,t=e.version,r=e.endpoint,n=-1!==r.indexOf(".cloud.coveo.com");return r+(n?"":"/rest")+"/"+t},enumerable:!0,configurable:!0}),ae);function ae(e){if(!e)throw new Error("You have to pass options to this constructor");this.options=d(d({},this.defaultOptions),e),this.visitorId="",this.bufferedRequests=[],this.beforeSendHooks=[O,f],this.eventTypeMapping={};var t={baseUrl:this.baseUrl,token:this.options.token,visitorIdProvider:this};this.runtime=this.initRuntime(t),this.analyticsFetchClient=new o(t),this.initVisitorId()}var ue=Object.freeze({__proto__:null,Version:"v15",Endpoints:ie,CoveoAnalyticsClient:se,default:se}),ce=u()?[!0,"yes","1"].indexOf(navigator.doNotTrack||navigator.msDoNotTrack||window.doNotTrack):0,le=Object.freeze({__proto__:null,doNotTrack:ce,default:ce}),pe=(fe.prototype.register=function(e,t){this.plugins[e]=t},fe.prototype.execute=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var o=this.plugins[e];return o[t].apply(o,r)},fe);function fe(){this.plugins={}}function he(e){return e.protocol+"//"+e.hostname+(0===e.pathname.indexOf("/")?e.pathname:"/"+e.pathname)+e.search}var de={pageview:"pageview",event:"event"},ge=Object.keys(de).map(function(e){return de[e]}),ve=(ye.prototype.addProduct=function(e){this.products.push(e)},ye.prototype.addImpression=function(e){this.impressions.push(e)},ye.prototype.setAction=function(e,t){this.action=e,this.actionData=t},ye.prototype.clearData=function(){this.products=[],this.impressions=[],this.action=void 0,this.actionData={}},ye.prototype.addHooksForECEvents=function(){var o=this;this.client.registerBeforeSendEventHook(function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var n=t[0];return-1!==ge.indexOf(e)?o.addECDataToPayload(e,n):n})},ye.prototype.addHooksForPageView=function(){this.client.addEventTypeMapping(de.pageview,{newEventType:n.collect,variableLengthArgumentsNames:["page"],addVisitorIdParameter:!0,usesMeasurementProtocol:!0})},ye.prototype.addHooksForEvent=function(){this.client.addEventTypeMapping(de.event,{newEventType:n.collect,variableLengthArgumentsNames:["eventCategory","eventAction","eventLabel","eventValue"],addVisitorIdParameter:!0,usesMeasurementProtocol:!0})},ye.prototype.addECDataToPayload=function(e,t){var r=d(d(d(d({},this.getLocationInformation(e,t)),this.getDefaultContextInformation(e)),this.action?{action:this.action}:{}),this.actionData||{}),n=this.products.reduce(function(e,t,r){return d(d({},e),(i=r,U(o=t).reduce(function(e,t){var r,n="pr"+(i+1)+(q[t]||t);return d(d({},e),((r={})[n]=o[t],r))},{})));var o,i},{}),o=this.getImpressionsByList().reduce(function(e,t,r){return d(d({},e),function(e,n){var t=e.impressions.reduce(function(e,t,r){return d(d({},e),_(t,n,r))},{});return e.listName&&(t["il"+(n+1)+"nm"]=e.listName),t}(t,r))},{});return this.clearData(),d(d(d(d({},o),n),r),t)},ye.prototype.getImpressionsByList=function(){return this.impressions.reduce(function(e,t){var r=t.list,n=s(t,["list"]),o=e.find(function(e){return e.listName===r});return o?o.impressions.push(n):e.push({listName:r,impressions:[n]}),e},[])},ye.prototype.updateStateForNewPageView=function(e){this.hasSentFirstPageView&&(this.pageViewId=this.uuidGenerator(),this.lastReferrer=this.lastLocation),e.page?this.lastLocation=""+this.lastLocation.split("/").slice(0,3).join("/")+e.page.replace(/^\/?(.*)$/,"/$1"):this.lastLocation=he(window.location),this.hasSentFirstPageView=!0},ye.prototype.getLocationInformation=function(e,t){return e===de.pageview&&this.updateStateForNewPageView(t),{referrer:this.lastReferrer,location:this.lastLocation}},ye.prototype.getDefaultContextInformation=function(e){var t={hitType:e,pageViewId:this.pageViewId},r={title:document.title,encoding:document.characterSet},n={screenResolution:screen.width+"x"+screen.height,screenColor:screen.colorDepth+"-bit"},o={language:navigator.language,userAgent:navigator.userAgent},i={time:Date.now().toString(),eventId:this.uuidGenerator()};return d(d(d(d(d({},t),i),n),o),r)},ye);function ye(e){var t=e.client,r=e.uuidGenerator,n=void 0===r?F:r;this.products=[],this.impressions=[],this.actionData={},this.client=t,this.uuidGenerator=n,this.pageViewId=n(),this.lastLocation=he(window.location),this.lastReferrer=document.referrer,this.addHooksForPageView(),this.addHooksForEvent(),this.addHooksForECEvents()}var me=(Ee.prototype.init=function(e,t){var r=this;if(!e)throw new Error("You must pass your token when you call 'init'");if("string"==typeof e?(t=t||ie.default,this.client=new se({token:e,endpoint:t})):"object"==typeof e&&void 0!==e.sendEvent&&(this.client=e),!this.client)throw new Error("You must pass either your token or a valid object when you call 'init'");this.plugins.register("ec",new ve({client:this.client})),this.client.registerBeforeSendEventHook(function(e,t){return d(d({},t),r.params)})},Ee.prototype.initForProxy=function(e){if(!e)throw new Error("You must pass your endpoint when you call 'initForProxy'");if("string"!=typeof e)throw new Error("You must pass a string as the endpoint parameter when you call 'initForProxy'");this.client=new se({endpoint:e})},Ee.prototype.set=function(t,e){var r=this;"string"==typeof t?this.params[t]=e:Object.keys(t).map(function(e){r.params[e]=t[e]})},Ee.prototype.send=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=t[0],o=t.slice(1);if(void 0===this.client)throw new Error("You must call init before sending an event");if(!n)throw new Error('You must provide an event type when calling "send".');return(e=this.client).sendEvent.apply(e,a([n.toLowerCase()],o))},Ee.prototype.onLoad=function(e){if(void 0===e)throw new Error("You must pass a function when you call 'onLoad'");e()},Ee.prototype.callPlugin=function(e,t){for(var r,n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];(r=this.plugins).execute.apply(r,a([e,t],n))},Ee.prototype.reset=function(){this.client=void 0,this.plugins=new pe,this.params={}},Ee);function Ee(){this.plugins=new pe,this.params={}}function we(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var n=/^(?:(\w+)\.)?(?:(\w+):)?(\w+)$/.exec(e),o=(n[1],n[2]),i=n[3],s=Ce[i];if(o&&i)return Ce.callPlugin.apply(Ce,a([o,i],t));if(s)return s.apply(Ce,t);throw new Error('The action "'+e+'" does not exist. Available actions: '+["init","set","send","onLoad","callPlugin"].join(", ")+".")}var be,Se,Ie,Ce=new me,xe=Object.freeze({__proto__:null,CoveoUA:me,coveoua:Ce,handleOneAnalyticsEvent:we,default:we});(Ie=Se=Se||{}).interfaceLoad="interfaceLoad",Ie.interfaceChange="interfaceChange",Ie.didyoumeanAutomatic="didyoumeanAutomatic",Ie.didyoumeanClick="didyoumeanClick",Ie.resultsSort="resultsSort",Ie.searchboxSubmit="searchboxSubmit",Ie.searchboxClear="searchboxClear",Ie.searchboxAsYouType="searchboxAsYouType",Ie.breadcrumbFacet="breadcrumbFacet",Ie.breadcrumbResetAll="breadcrumbResetAll",Ie.documentQuickview="documentQuickview",Ie.documentOpen="documentOpen",Ie.omniboxAnalytics="omniboxAnalytics",Ie.omniboxFromLink="omniboxFromLink",Ie.triggerNotify="notify",Ie.triggerExecute="execute",Ie.triggerQuery="query",Ie.triggerRedirect="redirect",Ie.pagerResize="pagerResize",Ie.pagerNumber="pagerNumber",Ie.pagerNext="pagerNext",Ie.pagerPrevious="pagerPrevious",Ie.pagerScrolling="pagerScrolling",Ie.facetClearAll="facetClearAll",Ie.facetSearch="facetSearch",Ie.facetSelect="facetSelect",Ie.facetSelectAll="facetSelectAll",Ie.facetDeselect="facetDeselect",Ie.facetExclude="facetExclude",Ie.facetUnexclude="facetUnexclude",Ie.facetUpdateSort="facetUpdateSort",Ie.facetShowMore="showMoreFacetResults",Ie.facetShowLess="showLessFacetResults",Ie.queryError="query",Ie.queryErrorBack="errorBack",Ie.queryErrorClear="errorClearQuery",Ie.queryErrorRetry="errorRetry";var Pe=((be={})[Se.triggerNotify]="queryPipelineTriggers",be[Se.triggerExecute]="queryPipelineTriggers",be[Se.triggerQuery]="queryPipelineTriggers",be[Se.triggerRedirect]="queryPipelineTriggers",be[Se.queryError]="errors",be[Se.queryErrorBack]="errors",be[Se.queryErrorClear]="errors",be[Se.queryErrorRetry]="errors",be[Se.pagerNext]="getMoreResults",be[Se.pagerPrevious]="getMoreResults",be[Se.pagerNumber]="getMoreResults",be[Se.pagerResize]="getMoreResults",be[Se.pagerScrolling]="getMoreResults",be[Se.facetSearch]="facet",be[Se.facetShowLess]="facet",be[Se.facetShowMore]="facet",be),ke=(Ae.prototype.sendEvent=function(){return Promise.resolve()},Ae.prototype.sendSearchEvent=function(){return Promise.resolve()},Ae.prototype.sendClickEvent=function(){return Promise.resolve()},Ae.prototype.sendCustomEvent=function(){return Promise.resolve()},Ae.prototype.sendViewEvent=function(){return Promise.resolve()},Ae.prototype.getVisit=function(){return Promise.resolve({id:"",visitorId:""})},Ae.prototype.getHealth=function(){return Promise.resolve({status:""})},Ae.prototype.registerBeforeSendEventHook=function(){},Ae.prototype.addEventTypeMapping=function(){},Ae);function Ae(){this.runtime=new oe}var Oe=(Te.prototype.disable=function(){this.coveoAnalyticsClient instanceof se&&this.coveoAnalyticsClient.clear(),this.coveoAnalyticsClient=new ke},Te.prototype.enable=function(){this.coveoAnalyticsClient=new se(this.opts)},Te.prototype.logInterfaceLoad=function(){return this.logSearchEvent(Se.interfaceLoad)},Te.prototype.logInterfaceChange=function(e){return this.logSearchEvent(Se.interfaceChange,e)},Te.prototype.logDidYouMeanAutomatic=function(){return this.logSearchEvent(Se.didyoumeanAutomatic)},Te.prototype.logDidYouMeanClick=function(){return this.logSearchEvent(Se.didyoumeanClick)},Te.prototype.logResultsSort=function(e){return this.logSearchEvent(Se.resultsSort,e)},Te.prototype.logSearchboxSubmit=function(){return this.logSearchEvent(Se.searchboxSubmit)},Te.prototype.logSearchboxClear=function(){return this.logSearchEvent(Se.searchboxClear)},Te.prototype.logSearchboxAsYouType=function(){return this.logSearchEvent(Se.searchboxAsYouType)},Te.prototype.logBreadcrumbFacet=function(e){return this.logSearchEvent(Se.breadcrumbFacet,e)},Te.prototype.logBreadcrumbResetAll=function(){return this.logSearchEvent(Se.breadcrumbResetAll)},Te.prototype.logDocumentQuickview=function(e,t){return this.logClickEvent(Se.documentQuickview,e,t)},Te.prototype.logDocumentOpen=function(e,t){return this.logClickEvent(Se.documentOpen,e,t)},Te.prototype.logOmniboxAnalytics=function(e){return this.logSearchEvent(Se.omniboxAnalytics,e)},Te.prototype.logOmniboxFromLink=function(e){return this.logSearchEvent(Se.omniboxFromLink,e)},Te.prototype.logTriggerNotify=function(e){return this.logCustomEvent(Se.triggerNotify,e)},Te.prototype.logTriggerExecute=function(e){return this.logCustomEvent(Se.triggerExecute,e)},Te.prototype.logTriggerQuery=function(){var e={query:this.provider.getSearchEventRequestPayload().queryText};return this.logCustomEvent(Se.triggerQuery,e)},Te.prototype.logTriggerRedirect=function(e){var t=d(d({},e),{query:this.provider.getSearchEventRequestPayload().queryText});return this.logCustomEvent(Se.triggerRedirect,t)},Te.prototype.logPagerResize=function(e){return this.logCustomEvent(Se.pagerResize,e)},Te.prototype.logPagerNumber=function(e){return this.logCustomEvent(Se.pagerNumber,e)},Te.prototype.logPagerNext=function(e){return this.logCustomEvent(Se.pagerNext,e)},Te.prototype.logPagerPrevious=function(e){return this.logCustomEvent(Se.pagerPrevious,e)},Te.prototype.logPagerScrolling=function(){return this.logCustomEvent(Se.pagerScrolling)},Te.prototype.logFacetClearAll=function(e){return this.logSearchEvent(Se.facetClearAll,e)},Te.prototype.logFacetSearch=function(e){return this.logSearchEvent(Se.facetSearch,e)},Te.prototype.logFacetSelect=function(e){return this.logSearchEvent(Se.facetSelect,e)},Te.prototype.logFacetDeselect=function(e){return this.logSearchEvent(Se.facetDeselect,e)},Te.prototype.logFacetExclude=function(e){return this.logSearchEvent(Se.facetExclude,e)},Te.prototype.logFacetUnexclude=function(e){return this.logSearchEvent(Se.facetUnexclude,e)},Te.prototype.logFacetSelectAll=function(e){return this.logSearchEvent(Se.facetSelectAll,e)},Te.prototype.logFacetUpdateSort=function(e){return this.logSearchEvent(Se.facetUpdateSort,e)},Te.prototype.logFacetShowMore=function(e){return this.logCustomEvent(Se.facetShowMore,e)},Te.prototype.logFacetShowLess=function(e){return this.logCustomEvent(Se.facetShowLess,e)},Te.prototype.logQueryError=function(e){return this.logCustomEvent(Se.queryError,e)},Te.prototype.logQueryErrorBack=function(){return r(this,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,this.logCustomEvent(Se.queryErrorBack)];case 1:return e.sent(),[2,this.logSearchEvent(Se.queryErrorBack)]}})})},Te.prototype.logQueryErrorRetry=function(){return r(this,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,this.logCustomEvent(Se.queryErrorRetry)];case 1:return e.sent(),[2,this.logSearchEvent(Se.queryErrorRetry)]}})})},Te.prototype.logQueryErrorClear=function(){return r(this,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,this.logCustomEvent(Se.queryErrorClear)];case 1:return e.sent(),[2,this.logSearchEvent(Se.queryErrorClear)]}})})},Te.prototype.logCustomEvent=function(e,t){var r=d(d({},this.provider.getBaseMetadata()),t),n=d(d({},this.getOrigins()),{eventType:Pe[e],eventValue:e,lastSearchQueryUid:this.provider.getSearchUID(),customData:r});return this.coveoAnalyticsClient.sendCustomEvent(n)},Te.prototype.logSearchEvent=function(e,t){var r=d(d({},this.provider.getBaseMetadata()),t),n=d(d(d({},this.provider.getSearchEventRequestPayload()),this.getOrigins()),{searchQueryUid:this.provider.getSearchUID(),queryPipeline:this.provider.getPipeline(),customData:r,actionCause:e});return this.coveoAnalyticsClient.sendSearchEvent(n)},Te.prototype.logClickEvent=function(e,t,r,n){var o=d(d(d({},this.provider.getBaseMetadata()),r),n),i=d(d(d({},t),this.getOrigins()),{searchQueryUid:this.provider.getSearchUID(),queryPipeline:this.provider.getPipeline(),actionCause:e,customData:o});return this.coveoAnalyticsClient.sendClickEvent(i)},Te.prototype.getOrigins=function(){return{originLevel1:this.provider.getOriginLevel1(),originLevel2:this.provider.getOriginLevel2(),originLevel3:this.provider.getOriginLevel3()}},Te);function Te(e,t){this.opts=e,this.provider=t,this.coveoAnalyticsClient=!1===e.enableAnalytics?new ke:new se(e)}e.CoveoAnalyticsClient=se,e.CoveoSearchPageClient=Oe,e.CoveoUA=me,e.SimpleAnalytics=xe,e.analytics=ue,e.donottrack=le,e.handleOneAnalyticsEvent=we,e.history=R,e.storage=x,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).coveoua={})}(this,function(e){"use strict";var n,t,h=function(){return(h=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function s(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}function r(e,s,a,u){return new(a=a||Promise)(function(r,t){function n(e){try{i(u.next(e))}catch(e){t(e)}}function o(e){try{i(u.throw(e))}catch(e){t(e)}}function i(e){var t;e.done?r(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(n,o)}i((u=u.apply(e,s||[])).next())})}function g(r,n){var o,i,s,e,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return e={next:t(0),throw:t(1),return:t(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function t(t){return function(e){return function(t){if(o)throw new TypeError("Generator is already executing.");for(;a;)try{if(o=1,i&&(s=2&t[0]?i.return:t[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,t[1])).done)return s;switch(i=0,s&&(t=[2&t[0],s.value]),t[0]){case 0:case 1:s=t;break;case 4:return a.label++,{value:t[1],done:!1};case 5:a.label++,i=t[1],t=[0];continue;case 7:t=a.ops.pop(),a.trys.pop();continue;default:if(!(s=0<(s=a.trys).length&&s[s.length-1])&&(6===t[0]||2===t[0])){a=0;continue}if(3===t[0]&&(!s||t[1]>s[0]&&t[1]<s[3])){a.label=t[1];break}if(6===t[0]&&a.label<s[1]){a.label=s[1],s=t;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(t);break}s[2]&&a.ops.pop(),a.trys.pop();continue}t=n.call(r,a)}catch(e){t=[6,e],i=0}finally{o=s=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}}function a(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,o++)n[o]=i[s];return n}(t=n=n||{}).search="search",t.click="click",t.custom="custom",t.view="view",t.collect="collect";var o=(i.prototype.sendEvent=function(a,u){return r(this,void 0,void 0,function(){var t,r,n,o,i,s;return g(this,function(e){switch(e.label){case 0:return t=this.opts,r=t.baseUrl,n=t.visitorIdProvider,o=this.shouldAppendVisitorId(a)?this.visitorIdParam:"",[4,fetch(r+"/analytics/"+a+o,{method:"POST",headers:this.getHeaders(),mode:"cors",body:JSON.stringify(u),credentials:"include"})];case 1:return(i=e.sent()).ok?[4,i.json()]:[3,3];case 2:return(s=e.sent()).visitorId&&(n.currentVisitorId=s.visitorId),[2,s];case 3:try{i.json()}catch(e){}throw console.error('An error has occured when sending the "'+a+'" event.',i,u),new Error('An error has occurred when sending the "'+a+'" event. Check the console logs for more details.')}})})},i.prototype.shouldAppendVisitorId=function(e){return-1!==[n.click,n.custom,n.search,n.view].indexOf(e)},Object.defineProperty(i.prototype,"visitorIdParam",{get:function(){var e=this.opts.visitorIdProvider.currentVisitorId;return e?"?visitor="+e:""},enumerable:!0,configurable:!0}),i.prototype.getHeaders=function(){var e=this.opts.token;return h(h({},e?{Authorization:"Bearer "+e}:{}),{"Content-Type":"application/json"})},i);function i(e){this.opts=e}function u(){return"undefined"!=typeof navigator}function c(){return"undefined"!=typeof localStorage}function l(){return u()&&navigator.cookieEnabled}function p(){return"undefined"!=typeof crypto&&void 0!==crypto.getRandomValues}function f(e,t){return-1!==d.indexOf(e)?h({language:document.documentElement.lang,userAgent:navigator.userAgent},t):t}var d=[n.click,n.custom,n.search,n.view],v=(y.set=function(e,t,r){var n,o,i,s,a;s=r?((i=new Date).setTime(i.getTime()+r),"; expires="+i.toGMTString()):"",-1===(a=location.hostname).indexOf(".")?document.cookie=e+"="+t+s+"; path=/":((o=a.split(".")).shift(),n="."+o.join("."),document.cookie=e+"="+t+s+"; path=/; domain="+n,null!=y.get(e)&&y.get(e)==t||(n="."+a,document.cookie=e+"="+t+s+"; path=/; domain="+n))},y.get=function(e){for(var t=e+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){var o=r[n];if(0==(o=o.replace(/^\s+/,"")).indexOf(t))return o.substring(t.length,o.length)}return null},y.erase=function(e){y.set(e,"",-1)},y);function y(){}function m(){return c()?localStorage:l()?new E:"undefined"!=typeof sessionStorage?sessionStorage:new I}var E=(w.prototype.getItem=function(e){return v.get(""+w.prefix+e)},w.prototype.removeItem=function(e){v.erase(""+w.prefix+e)},w.prototype.setItem=function(e,t){v.set(""+w.prefix+e,t)},w.prefix="coveo_",w);function w(){}var b=(S.prototype.getItem=function(e){return localStorage.getItem(e)||this.cookieStorage.getItem(e)},S.prototype.removeItem=function(e){this.cookieStorage.removeItem(e),localStorage.removeItem(e)},S.prototype.setItem=function(e,t){localStorage.setItem(e,t),this.cookieStorage.setItem(e,t)},S);function S(){this.cookieStorage=new E}var I=(C.prototype.getItem=function(e){return null},C.prototype.removeItem=function(e){},C.prototype.setItem=function(e,t){},C);function C(){}var P=Object.freeze({__proto__:null,preferredStorage:null,getAvailableStorage:m,CookieStorage:E,CookieAndLocalStorage:b,NullStorage:I}),x="__coveo.analytics.history",k=(A.prototype.addElement=function(e){e.internalTime=(new Date).getTime(),this.cropQueryElement(e);var t=this.getHistoryWithInternalTime();null!=t?this.isValidEntry(e)&&this.setHistory([e].concat(t)):this.setHistory([e])},A.prototype.getHistory=function(){var e=this.getHistoryWithInternalTime();return this.stripInternalTime(e)},A.prototype.getHistoryWithInternalTime=function(){try{var e=this.store.getItem(x);return e?JSON.parse(e):[]}catch(e){return[]}},A.prototype.setHistory=function(e){try{this.store.setItem(x,JSON.stringify(e.slice(0,20)))}catch(e){}},A.prototype.clear=function(){try{this.store.removeItem(x)}catch(e){}},A.prototype.getMostRecentElement=function(){var e=this.getHistoryWithInternalTime();return null==e?null:e.sort(function(e,t){return(t.internalTime||0)-(e.internalTime||0)})[0]},A.prototype.cropQueryElement=function(e){e.name&&"query"==e.name.toLowerCase()&&null!=e.value&&(e.value=e.value.slice(0,75))},A.prototype.isValidEntry=function(e){var t=this.getMostRecentElement();return!t||t.value!=e.value||6e4<(e.internalTime||0)-(t.internalTime||0)},A.prototype.stripInternalTime=function(e){return e.map(function(e){return{name:e.name,time:e.time,value:e.value}})},A);function A(e){this.store=e||m()}function T(e,t){return e===n.view?(L(t.contentIdValue),h({location:window.location.toString(),referrer:document.referrer,title:document.title},t)):t}function O(t){return[function(e){return W.test(e)},function(e){return J.test(e)},function(e){return-1!==M.indexOf(e)},function(e){return"custom"===e}].some(function(e){return e(t)})}var R=Object.freeze({__proto__:null,STORE_KEY:x,MAX_NUMBER_OF_HISTORY_ELEMENTS:20,MIN_THRESHOLD_FOR_DUPLICATE_VALUE:6e4,MAX_VALUE_SIZE:75,HistoryStore:k,default:k}),L=function(e){var t=new k,r={name:"PageView",value:e,time:JSON.stringify(new Date)};t.addElement(r)},F=function(e){return e?(Number(e)^V(new Uint8Array(1))[0]%16>>Number(e)/4).toString(16):(""+1e7+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,F)},V=function(e){if(p())return crypto.getRandomValues(e);for(var t=0,r=0;t<e.length;t++)0==(3&t)&&(r=4294967296*Math.random()),e[t]=r>>>((3&t)<<3)&255;return e},q={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",price:"pr",quantity:"qt",coupon:"cc",position:"ps"},j={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",position:"ps",price:"pr"},N=h(h(h(h(h({},{eventCategory:"ec",eventAction:"ea",eventLabel:"el",eventValue:"ev",page:"dp",visitorId:"cid",clientId:"cid",userId:"uid",currencyCode:"cu"}),{action:"pa",list:"pal",listSource:"pls"}),{id:"ti",revenue:"tr",tax:"tt",shipping:"ts",coupon:"tcc",affiliation:"ta",step:"cos",option:"col"}),{hitType:"t",pageViewId:"pid",encoding:"de",location:"dl",referrer:"dr",screenColor:"sd",screenResolution:"sr",title:"dt",userAgent:"ua",language:"ul",eventId:"z",time:"tm"}),{anonymizeIp:"aip"}),U=Object.keys,_=function(o,i,s){return U(o).reduce(function(e,t){var r,n="il"+(i+1)+"pi"+(s+1)+(j[t]||t);return h(h({},e),((r={})[n]=o[t],r))},{})},M=U(N).map(function(e){return N[e]}),B=U(q).map(function(e){return q[e]}),D=U(j).map(function(e){return j[e]}),H=a(B,["custom"]).join("|"),Q=a(D,["custom"]).join("|"),z="(pr[0-9]+)",Y="(il[0-9]+pi[0-9]+)",W=new RegExp("^"+z+"("+H+")$"),J=new RegExp("^("+Y+"("+Q+"))|(il[0-9]+nm)$"),$=new RegExp("^"+z+"custom$"),G=new RegExp("^"+Y+"custom$"),K=function(n,o){return U(o).reduce(function(e,t){var r;return h(h({},e),((r={})[""+n+t]=o[t],r))},{})},X=(Z.prototype.sendEvent=function(i,s){return r(this,void 0,void 0,function(){var t,r,n,o;return g(this,function(e){if(!navigator.sendBeacon)throw new Error('navigator.sendBeacon is not supported in this browser. Consider adding a polyfill like "sendbeacon-polyfill".');return t=this.opts.baseUrl,r=this.encodeForEventType(i,s),n=this.getQueryParamsForEventType(i),o=t+"/analytics/"+i+"?"+n,console.log('Sending beacon for "'+i+'" with: ',JSON.stringify(s)),navigator.sendBeacon(o,new Blob([r],{type:"application/x-www-form-urlencoded"})),[2]})})},Z.prototype.encodeForEventType=function(e,t){return this.isEventTypeLegacy(e)?this.encodeForLegacyType(e,t):this.encodeForFormUrlEncoded(h({access_token:this.opts.token},t))},Z.prototype.getQueryParamsForEventType=function(e){var t=this.opts,r=t.token,n=t.visitorIdProvider.currentVisitorId;return[r&&this.isEventTypeLegacy(e)?"access_token="+r:"",n?"visitorId="+n:""].filter(function(e){return!!e}).join("&")},Z.prototype.isEventTypeLegacy=function(e){return-1!==[n.click,n.custom,n.search,n.view].indexOf(e)},Z.prototype.encodeForLegacyType=function(e,t){return e+"Event="+encodeURIComponent(JSON.stringify(t))},Z.prototype.encodeForFormUrlEncoded=function(t){var r=this;return Object.keys(t).filter(function(e){return!!t[e]}).map(function(e){return encodeURIComponent(e)+"="+encodeURIComponent(r.encodeValue(t[e]))}).join("&")},Z.prototype.encodeValue=function(e){return"number"==typeof e||"string"==typeof e||"boolean"==typeof e?e:JSON.stringify(e)},Z);function Z(e){this.opts=e}var ee=(te.prototype.sendEvent=function(e,t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,Promise.resolve()]})})},te);function te(){}var re=function(e,t){c()&&l()?this.storage=new b:c()?this.storage=localStorage:(console.warn("BrowserRuntime detected no valid storage available.",this),this.storage=new I),this.beaconClient=new X(e),window.addEventListener("beforeunload",function(){return t()})},ne=function(){this.storage=new I,this.beaconClient=new ee},oe=function(){this.storage=new I,this.beaconClient=new ee},ie={default:"https://platform.cloud.coveo.com/rest/ua",production:"https://platform.cloud.coveo.com/rest/ua",hipaa:"https://platformhipaa.cloud.coveo.com/rest/ua"},se=(Object.defineProperty(ae.prototype,"defaultOptions",{get:function(){return{endpoint:ie.default,token:"",version:"v15"}},enumerable:!0,configurable:!0}),ae.prototype.initRuntime=function(e){var t=this;return"undefined"!=typeof window&&"undefined"!=typeof document?new re(e,function(){return t.flushBufferWithBeacon()}):new ne},Object.defineProperty(ae.prototype,"analyticsBeaconClient",{get:function(){return this.runtime.beaconClient},enumerable:!0,configurable:!0}),Object.defineProperty(ae.prototype,"storage",{get:function(){return this.runtime.storage},enumerable:!0,configurable:!0}),ae.prototype.initVisitorId=function(){var e=this.visitorId||this.storage.getItem("visitorId")||"";this.currentVisitorId=e||F()},Object.defineProperty(ae.prototype,"currentVisitorId",{get:function(){return this.visitorId},set:function(e){this.visitorId=e,this.storage.setItem("visitorId",e)},enumerable:!0,configurable:!0}),ae.prototype.sendEvent=function(f){for(var d=[],e=1;e<arguments.length;e++)d[e-1]=arguments[e];return r(this,void 0,void 0,function(){var t,r,n,o,i,s,a,u,c,l,p=this;return g(this,function(e){switch(e.label){case 0:return t=this.eventTypeMapping[f]||{},n=void 0===(r=t.newEventType)?f:r,i=void 0===(o=t.variableLengthArgumentsNames)?[]:o,a=void 0!==(s=t.addVisitorIdParameter)&&s,c=void 0!==(u=t.usesMeasurementProtocol)&&u,l=[function(e){return 0<i.length?p.parseVariableArgumentsPayload(i,e):e[0]},function(e){return h({visitorId:a?p.visitorId:""},e)},function(e){return c?p.ensureAnonymousUserWhenUsingApiKey(e):e},function(e){return p.beforeSendHooks.reduce(function(e,t){return t(f,e)},e)},function(e){return p.removeEmptyPayloadValues(e,f)},function(e){return p.validateParams(e)},function(e){return c?U(o=e).reduce(function(e,t){var r,n=N[t]||t;return h(h({},e),((r={})[n]=o[t],r))},{}):e;var o},function(e){return c?p.removeUnknownParameters(e):e},function(e){return c?p.processCustomParameters(e):e}].reduce(function(e,t){return t(e)},d),this.bufferedRequests.push({eventType:n,payload:l,handled:!1}),[4,this.deferExecution()];case 1:return e.sent(),[4,this.sendFromBufferWithFetch()];case 2:return[2,e.sent()]}})})},ae.prototype.deferExecution=function(){return new Promise(function(e){return setTimeout(e,0)})},ae.prototype.flushBufferWithBeacon=function(){for(;this.hasPendingRequests();){var e=this.bufferedRequests.pop(),t=e.eventType,r=e.payload;this.analyticsBeaconClient.sendEvent(t,r)}},ae.prototype.sendFromBufferWithFetch=function(){return r(this,void 0,void 0,function(){var t,r,n;return g(this,function(e){return(t=this.bufferedRequests.shift())?(r=t.eventType,n=t.payload,[2,this.analyticsFetchClient.sendEvent(r,n)]):[2]})})},ae.prototype.hasPendingRequests=function(){return 0<this.bufferedRequests.length},ae.prototype.clear=function(){this.storage.removeItem("visitorId"),(new k).clear()},ae.prototype.sendSearchEvent=function(t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,this.sendEvent(n.search,t)]})})},ae.prototype.sendClickEvent=function(t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,this.sendEvent(n.click,t)]})})},ae.prototype.sendCustomEvent=function(t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,this.sendEvent(n.custom,t)]})})},ae.prototype.sendViewEvent=function(t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,this.sendEvent(n.view,t)]})})},ae.prototype.getVisit=function(){return r(this,void 0,void 0,function(){var t;return g(this,function(e){switch(e.label){case 0:return[4,fetch(this.baseUrl+"/analytics/visit")];case 1:return[4,e.sent().json()];case 2:return t=e.sent(),this.visitorId=t.visitorId,[2,t]}})})},ae.prototype.getHealth=function(){return r(this,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,fetch(this.baseUrl+"/analytics/monitoring/health")];case 1:return[4,e.sent().json()];case 2:return[2,e.sent()]}})})},ae.prototype.registerBeforeSendEventHook=function(e){this.beforeSendHooks.push(e)},ae.prototype.addEventTypeMapping=function(e,t){this.eventTypeMapping[e]=t},ae.prototype.parseVariableArgumentsPayload=function(e,t){for(var r={},n=0,o=t.length;n<o;n++){var i=t[n];if("string"==typeof i)r[e[n]]=i;else if("object"==typeof i)return h(h({},r),i)}return r},ae.prototype.isKeyAllowedEmpty=function(e,t){var r;return-1!==((r={})[n.search]=["queryText"],(r[e]||[]).indexOf(t))},ae.prototype.removeEmptyPayloadValues=function(n,r){var o=this;return Object.keys(n).filter(function(e){return o.isKeyAllowedEmpty(r,e)||null!=(t=n[e])&&""!==t;var t}).reduce(function(e,t){var r;return h(h({},e),((r={})[t]=n[t],r))},{})},ae.prototype.removeUnknownParameters=function(n){return Object.keys(n).filter(function(e){if(O(e))return!0;console.log(e,"is not processed by coveoua")}).reduce(function(e,t){var r;return h(h({},e),((r={})[t]=n[t],r))},{})},ae.prototype.processCustomParameters=function(e){var i,t=e.custom,r=s(e,["custom"]),n=U(i=r).reduce(function(e,t){var r,n=$.exec(t)||G.exec(t);if(n){var o=n[1];return h(h({},e),K(o,i[t]))}return h(h({},e),((r={})[t]=i[t],r))},{});return h(h({},t||{}),n)},ae.prototype.validateParams=function(e){var t=e.anonymizeIp,r=s(e,["anonymizeIp"]);return void 0!==t&&-1==["0","false","undefined","null","{}","[]",""].indexOf((""+t).toLowerCase())&&(r.anonymizeIp=1),r},ae.prototype.ensureAnonymousUserWhenUsingApiKey=function(e){var t,r=e.userId,n=s(e,["userId"]);return null!=(t=this.options.token)&&t.startsWith("xx")&&!r?(n.userId="anonymous",n):e},Object.defineProperty(ae.prototype,"baseUrl",{get:function(){var e=this.options,t=e.version,r=e.endpoint,n=-1!==r.indexOf(".cloud.coveo.com");return r+(n?"":"/rest")+"/"+t},enumerable:!0,configurable:!0}),ae);function ae(e){if(!e)throw new Error("You have to pass options to this constructor");this.options=h(h({},this.defaultOptions),e),this.visitorId="",this.bufferedRequests=[],this.beforeSendHooks=[T,f],this.eventTypeMapping={};var t={baseUrl:this.baseUrl,token:this.options.token,visitorIdProvider:this};this.runtime=this.initRuntime(t),this.analyticsFetchClient=new o(t),this.initVisitorId()}var ue=Object.freeze({__proto__:null,Version:"v15",Endpoints:ie,CoveoAnalyticsClient:se,default:se}),ce=u()?[!0,"yes","1"].indexOf(navigator.doNotTrack||navigator.msDoNotTrack||window.doNotTrack):0,le=Object.freeze({__proto__:null,doNotTrack:ce,default:ce}),pe=(fe.prototype.register=function(e,t){this.plugins[e]=t},fe.prototype.execute=function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var o=this.plugins[e];return o[t].apply(o,r)},fe);function fe(){this.plugins={}}function de(e){return e.protocol+"//"+e.hostname+(0===e.pathname.indexOf("/")?e.pathname:"/"+e.pathname)+e.search}var he={pageview:"pageview",event:"event"},ge=Object.keys(he).map(function(e){return he[e]}),ve=(ye.prototype.addProduct=function(e){this.products.push(e)},ye.prototype.addImpression=function(e){this.impressions.push(e)},ye.prototype.setAction=function(e,t){this.action=e,this.actionData=t},ye.prototype.clearData=function(){this.products=[],this.impressions=[],this.action=void 0,this.actionData={}},ye.prototype.addHooksForECEvents=function(){var o=this;this.client.registerBeforeSendEventHook(function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var n=t[0];return-1!==ge.indexOf(e)?o.addECDataToPayload(e,n):n})},ye.prototype.addHooksForPageView=function(){this.client.addEventTypeMapping(he.pageview,{newEventType:n.collect,variableLengthArgumentsNames:["page"],addVisitorIdParameter:!0,usesMeasurementProtocol:!0})},ye.prototype.addHooksForEvent=function(){this.client.addEventTypeMapping(he.event,{newEventType:n.collect,variableLengthArgumentsNames:["eventCategory","eventAction","eventLabel","eventValue"],addVisitorIdParameter:!0,usesMeasurementProtocol:!0})},ye.prototype.addECDataToPayload=function(e,t){var r=h(h(h(h({},this.getLocationInformation(e,t)),this.getDefaultContextInformation(e)),this.action?{action:this.action}:{}),this.actionData||{}),n=this.getProductPayload(),o=this.getImpressionPayload();return this.clearData(),h(h(h(h({},o),n),r),t)},ye.prototype.getProductPayload=function(){var t=this;return this.products.map(function(e){return t.assureProductValidity(e)}).reduce(function(e,t,r){return h(h({},e),(i=r,U(o=t).reduce(function(e,t){var r,n="pr"+(i+1)+(q[t]||t);return h(h({},e),((r={})[n]=o[t],r))},{})));var o,i},{})},ye.prototype.getImpressionPayload=function(){var n=this;return this.getImpressionsByList().map(function(e){var t=e.impressions,r=s(e,["impressions"]);return h(h({},r),{impressions:t.map(function(e){return n.assureBaseImpressionValidity(e)})})}).reduce(function(e,t,r){return h(h({},e),function(e,n){var t=e.impressions.reduce(function(e,t,r){return h(h({},e),_(t,n,r))},{});return e.listName&&(t["il"+(n+1)+"nm"]=e.listName),t}(t,r))},{})},ye.prototype.assureProductValidity=function(e){var t=e.position,r=s(e,["position"]);return void 0!==t&&t<1?(console.warn("The position for product '"+(e.name||e.id)+"' must be greater than 0 when provided."),r):e},ye.prototype.assureBaseImpressionValidity=function(e){var t=e.position,r=s(e,["position"]);return void 0!==t&&t<1?(console.warn("The position for impression '"+(e.name||e.id)+"' must be greater than 0 when provided."),r):e},ye.prototype.getImpressionsByList=function(){return this.impressions.reduce(function(e,t){var r=t.list,n=s(t,["list"]),o=e.find(function(e){return e.listName===r});return o?o.impressions.push(n):e.push({listName:r,impressions:[n]}),e},[])},ye.prototype.updateStateForNewPageView=function(e){this.hasSentFirstPageView&&(this.pageViewId=this.uuidGenerator(),this.lastReferrer=this.lastLocation),e.page?this.lastLocation=""+this.lastLocation.split("/").slice(0,3).join("/")+e.page.replace(/^\/?(.*)$/,"/$1"):this.lastLocation=de(window.location),this.hasSentFirstPageView=!0},ye.prototype.getLocationInformation=function(e,t){return e===he.pageview&&this.updateStateForNewPageView(t),{referrer:this.lastReferrer,location:this.lastLocation}},ye.prototype.getDefaultContextInformation=function(e){var t={hitType:e,pageViewId:this.pageViewId},r={title:document.title,encoding:document.characterSet},n={screenResolution:screen.width+"x"+screen.height,screenColor:screen.colorDepth+"-bit"},o={language:navigator.language,userAgent:navigator.userAgent},i={time:Date.now().toString(),eventId:this.uuidGenerator()};return h(h(h(h(h({},t),i),n),o),r)},ye);function ye(e){var t=e.client,r=e.uuidGenerator,n=void 0===r?F:r;this.products=[],this.impressions=[],this.actionData={},this.client=t,this.uuidGenerator=n,this.pageViewId=n(),this.lastLocation=de(window.location),this.lastReferrer=document.referrer,this.addHooksForPageView(),this.addHooksForEvent(),this.addHooksForECEvents()}var me=(Ee.prototype.init=function(e,t){var r=this;if(!e)throw new Error("You must pass your token when you call 'init'");if("string"==typeof e?(t=t||ie.default,this.client=new se({token:e,endpoint:t})):"object"==typeof e&&void 0!==e.sendEvent&&(this.client=e),!this.client)throw new Error("You must pass either your token or a valid object when you call 'init'");this.plugins.register("ec",new ve({client:this.client})),this.client.registerBeforeSendEventHook(function(e,t){return h(h({},t),r.params)})},Ee.prototype.initForProxy=function(e){if(!e)throw new Error("You must pass your endpoint when you call 'initForProxy'");if("string"!=typeof e)throw new Error("You must pass a string as the endpoint parameter when you call 'initForProxy'");this.client=new se({endpoint:e})},Ee.prototype.set=function(t,e){var r=this;"string"==typeof t?this.params[t]=e:Object.keys(t).map(function(e){r.params[e]=t[e]})},Ee.prototype.send=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=t[0],o=t.slice(1);if(void 0===this.client)throw new Error("You must call init before sending an event");if(!n)throw new Error('You must provide an event type when calling "send".');return(e=this.client).sendEvent.apply(e,a([n.toLowerCase()],o))},Ee.prototype.onLoad=function(e){if(void 0===e)throw new Error("You must pass a function when you call 'onLoad'");e()},Ee.prototype.callPlugin=function(e,t){for(var r,n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];(r=this.plugins).execute.apply(r,a([e,t],n))},Ee.prototype.reset=function(){this.client=void 0,this.plugins=new pe,this.params={}},Ee);function Ee(){this.plugins=new pe,this.params={}}function we(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var n=/^(?:(\w+)\.)?(?:(\w+):)?(\w+)$/.exec(e),o=(n[1],n[2]),i=n[3],s=Ce[i];if(o&&i)return Ce.callPlugin.apply(Ce,a([o,i],t));if(s)return s.apply(Ce,t);throw new Error('The action "'+e+'" does not exist. Available actions: '+["init","set","send","onLoad","callPlugin"].join(", ")+".")}var be,Se,Ie,Ce=new me,Pe=Object.freeze({__proto__:null,CoveoUA:me,coveoua:Ce,handleOneAnalyticsEvent:we,default:we});(Ie=Se=Se||{}).interfaceLoad="interfaceLoad",Ie.interfaceChange="interfaceChange",Ie.didyoumeanAutomatic="didyoumeanAutomatic",Ie.didyoumeanClick="didyoumeanClick",Ie.resultsSort="resultsSort",Ie.searchboxSubmit="searchboxSubmit",Ie.searchboxClear="searchboxClear",Ie.searchboxAsYouType="searchboxAsYouType",Ie.breadcrumbFacet="breadcrumbFacet",Ie.breadcrumbResetAll="breadcrumbResetAll",Ie.documentQuickview="documentQuickview",Ie.documentOpen="documentOpen",Ie.omniboxAnalytics="omniboxAnalytics",Ie.omniboxFromLink="omniboxFromLink",Ie.triggerNotify="notify",Ie.triggerExecute="execute",Ie.triggerQuery="query",Ie.triggerRedirect="redirect",Ie.pagerResize="pagerResize",Ie.pagerNumber="pagerNumber",Ie.pagerNext="pagerNext",Ie.pagerPrevious="pagerPrevious",Ie.pagerScrolling="pagerScrolling",Ie.facetClearAll="facetClearAll",Ie.facetSearch="facetSearch",Ie.facetSelect="facetSelect",Ie.facetSelectAll="facetSelectAll",Ie.facetDeselect="facetDeselect",Ie.facetExclude="facetExclude",Ie.facetUnexclude="facetUnexclude",Ie.facetUpdateSort="facetUpdateSort",Ie.facetShowMore="showMoreFacetResults",Ie.facetShowLess="showLessFacetResults",Ie.queryError="query",Ie.queryErrorBack="errorBack",Ie.queryErrorClear="errorClearQuery",Ie.queryErrorRetry="errorRetry";var xe=((be={})[Se.triggerNotify]="queryPipelineTriggers",be[Se.triggerExecute]="queryPipelineTriggers",be[Se.triggerQuery]="queryPipelineTriggers",be[Se.triggerRedirect]="queryPipelineTriggers",be[Se.queryError]="errors",be[Se.queryErrorBack]="errors",be[Se.queryErrorClear]="errors",be[Se.queryErrorRetry]="errors",be[Se.pagerNext]="getMoreResults",be[Se.pagerPrevious]="getMoreResults",be[Se.pagerNumber]="getMoreResults",be[Se.pagerResize]="getMoreResults",be[Se.pagerScrolling]="getMoreResults",be[Se.facetSearch]="facet",be[Se.facetShowLess]="facet",be[Se.facetShowMore]="facet",be),ke=(Ae.prototype.sendEvent=function(){return Promise.resolve()},Ae.prototype.sendSearchEvent=function(){return Promise.resolve()},Ae.prototype.sendClickEvent=function(){return Promise.resolve()},Ae.prototype.sendCustomEvent=function(){return Promise.resolve()},Ae.prototype.sendViewEvent=function(){return Promise.resolve()},Ae.prototype.getVisit=function(){return Promise.resolve({id:"",visitorId:""})},Ae.prototype.getHealth=function(){return Promise.resolve({status:""})},Ae.prototype.registerBeforeSendEventHook=function(){},Ae.prototype.addEventTypeMapping=function(){},Ae);function Ae(){this.runtime=new oe,this.currentVisitorId=""}var Te=(Oe.prototype.disable=function(){this.coveoAnalyticsClient instanceof se&&this.coveoAnalyticsClient.clear(),this.coveoAnalyticsClient=new ke},Oe.prototype.enable=function(){this.coveoAnalyticsClient=new se(this.opts)},Oe.prototype.logInterfaceLoad=function(){return this.logSearchEvent(Se.interfaceLoad)},Oe.prototype.logInterfaceChange=function(e){return this.logSearchEvent(Se.interfaceChange,e)},Oe.prototype.logDidYouMeanAutomatic=function(){return this.logSearchEvent(Se.didyoumeanAutomatic)},Oe.prototype.logDidYouMeanClick=function(){return this.logSearchEvent(Se.didyoumeanClick)},Oe.prototype.logResultsSort=function(e){return this.logSearchEvent(Se.resultsSort,e)},Oe.prototype.logSearchboxSubmit=function(){return this.logSearchEvent(Se.searchboxSubmit)},Oe.prototype.logSearchboxClear=function(){return this.logSearchEvent(Se.searchboxClear)},Oe.prototype.logSearchboxAsYouType=function(){return this.logSearchEvent(Se.searchboxAsYouType)},Oe.prototype.logBreadcrumbFacet=function(e){return this.logSearchEvent(Se.breadcrumbFacet,e)},Oe.prototype.logBreadcrumbResetAll=function(){return this.logSearchEvent(Se.breadcrumbResetAll)},Oe.prototype.logDocumentQuickview=function(e,t){return this.logClickEvent(Se.documentQuickview,e,t)},Oe.prototype.logDocumentOpen=function(e,t){return this.logClickEvent(Se.documentOpen,e,t)},Oe.prototype.logOmniboxAnalytics=function(e){return this.logSearchEvent(Se.omniboxAnalytics,e)},Oe.prototype.logOmniboxFromLink=function(e){return this.logSearchEvent(Se.omniboxFromLink,e)},Oe.prototype.logTriggerNotify=function(e){return this.logCustomEvent(Se.triggerNotify,e)},Oe.prototype.logTriggerExecute=function(e){return this.logCustomEvent(Se.triggerExecute,e)},Oe.prototype.logTriggerQuery=function(){var e={query:this.provider.getSearchEventRequestPayload().queryText};return this.logCustomEvent(Se.triggerQuery,e)},Oe.prototype.logTriggerRedirect=function(e){var t=h(h({},e),{query:this.provider.getSearchEventRequestPayload().queryText});return this.logCustomEvent(Se.triggerRedirect,t)},Oe.prototype.logPagerResize=function(e){return this.logCustomEvent(Se.pagerResize,e)},Oe.prototype.logPagerNumber=function(e){return this.logCustomEvent(Se.pagerNumber,e)},Oe.prototype.logPagerNext=function(e){return this.logCustomEvent(Se.pagerNext,e)},Oe.prototype.logPagerPrevious=function(e){return this.logCustomEvent(Se.pagerPrevious,e)},Oe.prototype.logPagerScrolling=function(){return this.logCustomEvent(Se.pagerScrolling)},Oe.prototype.logFacetClearAll=function(e){return this.logSearchEvent(Se.facetClearAll,e)},Oe.prototype.logFacetSearch=function(e){return this.logSearchEvent(Se.facetSearch,e)},Oe.prototype.logFacetSelect=function(e){return this.logSearchEvent(Se.facetSelect,e)},Oe.prototype.logFacetDeselect=function(e){return this.logSearchEvent(Se.facetDeselect,e)},Oe.prototype.logFacetExclude=function(e){return this.logSearchEvent(Se.facetExclude,e)},Oe.prototype.logFacetUnexclude=function(e){return this.logSearchEvent(Se.facetUnexclude,e)},Oe.prototype.logFacetSelectAll=function(e){return this.logSearchEvent(Se.facetSelectAll,e)},Oe.prototype.logFacetUpdateSort=function(e){return this.logSearchEvent(Se.facetUpdateSort,e)},Oe.prototype.logFacetShowMore=function(e){return this.logCustomEvent(Se.facetShowMore,e)},Oe.prototype.logFacetShowLess=function(e){return this.logCustomEvent(Se.facetShowLess,e)},Oe.prototype.logQueryError=function(e){return this.logCustomEvent(Se.queryError,e)},Oe.prototype.logQueryErrorBack=function(){return r(this,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,this.logCustomEvent(Se.queryErrorBack)];case 1:return e.sent(),[2,this.logSearchEvent(Se.queryErrorBack)]}})})},Oe.prototype.logQueryErrorRetry=function(){return r(this,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,this.logCustomEvent(Se.queryErrorRetry)];case 1:return e.sent(),[2,this.logSearchEvent(Se.queryErrorRetry)]}})})},Oe.prototype.logQueryErrorClear=function(){return r(this,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,this.logCustomEvent(Se.queryErrorClear)];case 1:return e.sent(),[2,this.logSearchEvent(Se.queryErrorClear)]}})})},Oe.prototype.logCustomEvent=function(e,t){var r=h(h({},this.provider.getBaseMetadata()),t),n=h(h({},this.getOrigins()),{eventType:xe[e],eventValue:e,lastSearchQueryUid:this.provider.getSearchUID(),customData:r});return this.coveoAnalyticsClient.sendCustomEvent(n)},Oe.prototype.logSearchEvent=function(e,t){var r=h(h({},this.provider.getBaseMetadata()),t),n=h(h(h({},this.provider.getSearchEventRequestPayload()),this.getOrigins()),{searchQueryUid:this.provider.getSearchUID(),queryPipeline:this.provider.getPipeline(),customData:r,actionCause:e});return this.coveoAnalyticsClient.sendSearchEvent(n)},Oe.prototype.logClickEvent=function(e,t,r,n){var o=h(h(h({},this.provider.getBaseMetadata()),r),n),i=h(h(h({},t),this.getOrigins()),{searchQueryUid:this.provider.getSearchUID(),queryPipeline:this.provider.getPipeline(),actionCause:e,customData:o});return this.coveoAnalyticsClient.sendClickEvent(i)},Oe.prototype.getOrigins=function(){return{originLevel1:this.provider.getOriginLevel1(),originLevel2:this.provider.getOriginLevel2(),originLevel3:this.provider.getOriginLevel3()}},Oe);function Oe(e,t){this.opts=e,this.provider=t,this.coveoAnalyticsClient=!1===e.enableAnalytics?new ke:new se(e)}e.CoveoAnalyticsClient=se,e.CoveoSearchPageClient=Te,e.CoveoUA=me,e.SimpleAnalytics=Pe,e.analytics=ue,e.donottrack=le,e.handleOneAnalyticsEvent=we,e.history=R,e.storage=P,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=library.js.map
{
"name": "coveo.analytics",
"version": "2.6.0",
"version": "2.8.0",
"description": "📈 Coveo analytics client (node and browser compatible) ",

@@ -5,0 +5,0 @@ "main": "dist/library.js",

@@ -11,69 +11,67 @@ # ![coveo.analytics](./assets/coveo.analytics.js.png)

This project provides 2 ways to interact with the the Coveo Usage Analytics service.
This project provides 2 ways to interact with the Coveo Usage Analytics service.
- A JavaScript browser client
- A code snippet to add in websites pages
- A JavaScript browser client
- A code snippet to add in website pages
## Usage (Web analytics)
This JavaScript client project provides a code snippet that website administrators can easily add to website pages to track `pageview` events. The `pageview` events are stored in a Coveo Usage Analytics table which content currently cannot be viewed in Usage Analytics reports and the visit browser to prevent performance degradation.
This JavaScript client provides a code snippet that can easily be added to website pages to track events. The `pageview` events are stored in a Coveo Usage Analytics table which content currently cannot be viewed in Usage Analytics reports and the visit browser to prevent performance degradation.
Initially, the `pageview` events data will be used exclusively by the Coveo Reveal Recommendations feature (see [Recommendations Feature](https://onlinehelp.coveo.com/en/cloud/coveo_reveal_features.htm#Recommendations)). It is recommended that you start pushing `pageview` events to the Coveo Usage Analytics service as soon as possible so that you get relevant items recommended.
Initially, the `pageview` events data will be used exclusively by the Coveo ML Event Recommendations (ER) Feature (see [Event Recommendations (ER) Feature](https://docs.coveo.com/en/1671/coveo-machine-learning/coveo-machine-learning-features#ER)). It is recommended that you start sending `pageview` events to the Coveo Usage Analytics service as soon as possible so that you get relevant items recommended.
On top of `pageview` events, generic and commerce events can also be tracked. See [Tracking Commerce Events](https://docs.coveo.com/en/3188/coveo-solutions/tracking-commerce-events).
**Note: This Coveo code snippet is similar to the Google analytics one (analytics.js).**
### Pushing Coveo Analytics Pageview Events for Recommendations
### Sending Coveo Analytics Page View Events for Recommendations
1. Get an API key.
You need a Coveo Cloud API key that has the permission to write to the Usage Analytics service.
You need a Coveo Cloud API key which has the [**Push** access level on the **Analytics Data** domain](https://docs.coveo.com/en/1707/cloud-v2-administrators/privilege-reference#analytics-data-domain) to send events (see [User Authentication](https://docs.coveo.com/en/3188/coveo-solutions/tracking-commerce-events#user-authentication)).
- For [Coveo Cloud V1](https://cloud.coveo.com/), contact [Coveo Support](https://coveocommunity.force.com/) and ask to create an API key with the **Write UA** scope.
Create an API key from the [administration console](https://platform.cloud.coveo.com/admin/#/organization/api-access/) selecting the **Push** option box for the **Analytics Data** domain (see [Adding and Managing API Keys](https://docs.coveo.com/en/1718/cloud-v2-administrators/adding-and-managing-api-keys)).
- For [Coveo Cloud V2](https://platform.cloud.coveo.com/), create an API key from the [administration console](https://platform.cloud.coveo.com/admin/#/organization/api-access/) selecting the **Edit** check box for the **Analytics data** privilege (see [API Access - Page](http://www.coveo.com/go?dest=ccv2ac&context=27)).
2. Add the code snippet to all your website pages.
Ask an administrator to add a code snippet like the following to all pages of your websites:
Add a code snippet like the following to all pages of your websites:
```html
<script>
(function(c,o,v,e,O,u,a){
a='coveoua';c[a]=c[a]||function(){(c[a].q=c[a].q|| []).push(arguments)};
c[a].t=Date.now();u=o.createElement(v);u.async=1;u.src=e;
O=o.getElementsByTagName(v)[0];O.parentNode.insertBefore(u,O)
})(window,document,'script','https://static.cloud.coveo.com/coveo.analytics.js/1.0/coveoua.js')
```html
<script>
(function(c,o,v,e,O,u,a){
a='coveoua';c[a]=c[a]||function(){(c[a].q=c[a].q|| []).push(arguments)};
c[a].t=Date.now();u=o.createElement(v);u.async=1;u.src=e;
O=o.getElementsByTagName(v)[0];O.parentNode.insertBefore(u,O)
})(window,document,'script','https://static.cloud.coveo.com/coveo.analytics.js/2/coveoua.js')
// Replace "2" in the script url with the latest release
coveoua('init', <COVEO_API_KEY>); // Replace <COVEO_API_KEY> with your real key
coveoua('send', 'view', {
contentIdKey: '@permanentid',
contentIdValue: <PERMANENT_ID_VALUE>, // Replace <PERMANENT_ID_VALUE> with a unique value from your page.
contentType: 'product', // Optional
// ... more information ...
});
</script>
```
The code snippet must contain `contentIdKey` and `contentIdValue` in order to identify items in the Coveo index. When you want to recommend specific types of content, you also need to add a `contentType` parameter value.
coveoua('init', 'YOUR_API_KEY'); // Replace YOUR_API_KEY with your real key
coveoua('send', 'view', {
contentIdKey: '@permanentid',
contentIdValue: 'PERMANENT_ID_VALUE', // Replace PERMANENT_ID_VALUE with a unique value from your page.
contentType: 'product', // Optional
// ... more information ...
});
</script>
```
| Key | Value |
| -------------- | ------------------------------------------------------------------- |
| contentIdKey | The Coveo index field name that will be used to identify the item. |
| contentIdValue | The Coveo index field value that will be used to identify the item. |
| contentType | [Optional] The type of the item to be tracked (e.g., 'Article'). |
Make sure you replace `YOUR_API_KEY` by the API key you got in the previous step.
**Note: Do not copy the `coveoua.js` file as it can be updated anytime and you could experience compatibility issues.**
The code snippet must contain `contentIdKey` and `contentIdValue` in order to identify items in the Coveo index. When you want to recommend specific types of content, you also need to add a `contentType` parameter value.
3. Validate `pageview` events are sent to the Coveo Usage Analytics service
| Key | Value |
| -------------- | ------------------------------------------------------------------- |
| contentIdKey | The Coveo index field name that will be used to identify the item. |
| contentIdValue | The Coveo index field value that will be used to identify the item. |
| contentType | [Optional] The type of the item to be tracked (e.g., 'Article'). |
a. In a web browser such as Chrome, navigate to a website page to which you added the code snippet.
**Note: Do not copy the\_ `coveoua.js` \_file as it can be updated anytime and you could experience compatibility issues.**
b. In the browser developer tool, go the the **Network** tab.
3. Validate pageview events are pushed to the Coveo Usage Analytics service
c. Reload the page, in the **Name** panel, ensure that you see a **view** event sent to Coveo analytics.
a. In a web browser such as Chrome, navigate to a website page to which you added the code snippet.
### Sending Any Coveo Analytics Events
b. In the browser developer tool, go the the **Network** tab.
c. Reload the page, in the **Name** panel, ensure that you see a **view** event sent to Coveo analytics.
### Pushing Any Coveo Analytics Event
Add the code snippet to all your website pages.

@@ -83,9 +81,8 @@

<script>
(function(c,o,v,e,O,u,a){
a='coveoua';c[a]=c[a]||function(){(c[a].q=c[a].q|| []).push(arguments)};
c[a].t=Date.now();u=o.createElement(v);u.async=1;u.src=e;
O=o.getElementsByTagName(v)[0];O.parentNode.insertBefore(u,O)
})(window,document,'script','https://static.cloud.coveo.com/coveo.analytics.js/1.0/coveoua.js')
coveoua('init', 'YOUR_API_KEY'); // Replace YOUR_API_KEY with your real key
(function(c,o,v,e,O,u,a){
a='coveoua';c[a]=c[a]||function(){(c[a].q=c[a].q|| []).push(arguments)};
c[a].t=Date.now();u=o.createElement(v);u.async=1;u.src=e;
O=o.getElementsByTagName(v)[0];O.parentNode.insertBefore(u,O)
})(window,document,'script','https://static.cloud.coveo.com/coveo.analytics.js/2/coveoua.js') // Replace "2" in the script url with the latest release
coveoua('init', <COVEO_API_KEY>); // Replace <COVEO_API_KEY> with your real key
</script>

@@ -96,3 +93,3 @@ ```

```html
```js
coveoua('send', 'click', { ... });

@@ -103,5 +100,39 @@ ```

### Sending Commerce Events
Add the code snippet to all your website pages.
```html
<script>
(function(c,o,v,e,O,u,a){
a='coveoua';c[a]=c[a]||function(){(c[a].q=c[a].q|| []).push(arguments)};
c[a].t=Date.now();u=o.createElement(v);u.async=1;u.src=e;
O=o.getElementsByTagName(v)[0];O.parentNode.insertBefore(u,O)
})(window,document,'script','https://static.cloud.coveo.com/coveo.analytics.js/2/coveoua.js') // Replace "2" in the script url with the latest release
coveoua('init', <COVEO_API_KEY>); // Replace <COVEO_API_KEY> with your real key
</script>
```
To send commerce events, call `coveoua` with the event name. Here is how an [addition to the cart interaction](https://docs.coveo.com/en/3188/coveo-solutions/tracking-commerce-events#measuring-an-addition-to-the-cart) is measured:
1. First use the `ec:addProduct` command to include the relevant product data in the event you’re about to send
```js
coveoua('ec:addProduct', <PRODUCT_DATA>);
```
2. Then use the `ec:setAction` command to specify that the action done on this data is an addition to the cart:
```js
coveoua('ec:setAction', 'add');
```
3. Finally, use the `send` command to send the event to Coveo Usage Analytics.
```js
coveoua('send', 'event');
```
Refer to the [**Tracking Commerce Events** page](https://docs.coveo.com/en/3188/coveo-solutions/tracking-commerce-events) to see how to measure [a product details view](https://docs.coveo.com/en/3188/coveo-solutions/tracking-commerce-events#measuring-a-product-details-view), [an addition to the cart](https://docs.coveo.com/en/3188/coveo-solutions/tracking-commerce-events#measuring-an-addition-to-the-cart), [a removal from the cart](https://docs.coveo.com/en/3188/coveo-solutions/tracking-commerce-events#measuring-a-removal-from-the-cart), [a purchase](https://docs.coveo.com/en/3188/coveo-solutions/tracking-commerce-events#measuring-purchases) or [an event on a search-driven listing-page](https://docs.coveo.com/en/3188/coveo-solutions/tracking-commerce-events#measuring-events-on-a-search-driven-listing-page) in more details.
All supported actions are also listed in the [**Possible Actions** section of the **Tracking Commerce Events** page](https://docs.coveo.com/en/3188/coveo-solutions/tracking-commerce-events#possible-actions).
### Usage (for developers)
You have to provide your own `fetch` API compatible libraries in the global environment (see [Isomorphic TypeScript, fetch, promises, ava and coverage](http://source.coveo.com/2016/05/11/isomorphic-typescript-ava-w-coverage/)).
You need to provide your own `fetch` API compatible libraries in the global environment (see [Isomorphic TypeScript, fetch, promises, ava and coverage](https://source.coveo.com/2016/05/11/isomorphic-typescript-ava-w-coverage/)).

@@ -127,16 +158,18 @@ ```bash

There are 3 available storage you can use to store view events client side.
There are 3 available storage types you can use to store view events client side.
- Cookie storage, which supports top level domain storage. This means that events from a.foo.com will be available from b.foo.com.
Cookies have the limitation of not being able to store a lot of data, especially if your page view that are stored are long.
- Cookie storage, which supports top level domain storage. This means that events from a.foo.com will be available from b.foo.com. Cookies have the limitation of not being able to store a lot of data, especially if your stored page views are long.
- Local storage, which allows to store much more information client side, but has the drawback of not being able to acess data
across multiple top level domain.
- Local storage, which allows to store much more information client side, but has the drawback of not being able to access data across multiple top level domains.
- Session storage, which has roughly the same limitation and capability as Local storage, except that it is cleared when the web browser tab is closed.
- Session storage, which has roughly the same limitation and capability as Local storage, except that it is cleared when the web browser tab is closed.
By default, the local storage option will automatically be chosen as the default storage, unless specified manually.
By default, the local storage option will automatically be chosen as the default storage, unless manually specified.
### Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md)
#### Setup
```bash

@@ -146,13 +179,20 @@ git clone

npm run build
# code code code
npm run test
# open pull request
```
There are two ways to run your code locally:
1. run `npm start` and open your browser on http://localhost:9001
2. run through VSCode debugger with the `Debug: Start Debugging` command, using the `Launch Chrome` configuration.
#### Running the project
To test out your changes, add a new function calls in the `public/index.html` file and check the payload in `Developer Console` of your browser
There are two ways to run your code locally:
1. run `npm start` and open your browser on http://localhost:9001
2. run through VSCode debugger with the `Debug: Start Debugging` command, using the `Launch Chrome` configuration.
To test out your changes, add `coveoua` function calls in the `public/index.html` file and check the payload in the `Developer Console` section of your browser.
#### Running tests
```bash
npm run test
```
### License

@@ -162,3 +202,3 @@

[![forthebadge](http://forthebadge.com/images/badges/built-with-love.svg)](http://forthebadge.com)
[![coveo](./assets/by-coveo.png)](http://www.coveo.com)
[![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://forthebadge.com)
[![coveo](./assets/by-coveo.png)](https://www.coveo.com)

@@ -66,2 +66,3 @@ import {IAnalyticsBeaconClientOptions} from './analyticsBeaconClient';

runtime: IRuntimeEnvironment;
readonly currentVisitorId: string;
}

@@ -268,3 +269,3 @@

this.eventTypeMapping[eventType] = eventConfig;
}
}

@@ -271,0 +272,0 @@ private parseVariableArgumentsPayload(fieldsOrder: string[], payload: VariableArgumentsPayload) {

@@ -38,2 +38,3 @@ import {AnalyticsClient} from './analytics';

runtime = new NoopRuntime();
currentVisitorId='';
}

@@ -1,3 +0,2 @@

import * as detector from './detector';
import {CookieStorage, getAvailableStorage, WebStorage} from './storage';
import {getAvailableStorage, WebStorage} from './storage';

@@ -13,7 +12,2 @@ export const STORE_KEY: string = '__coveo.analytics.history';

this.store = store || getAvailableStorage();
// cleanup any old cookie that we might have added
// eg : we used cookies before, but switched to local storage
if (!(this.store instanceof CookieStorage) && detector.hasCookieStorage()) {
new CookieStorage().removeItem(STORE_KEY);
}
}

@@ -20,0 +14,0 @@

@@ -121,2 +121,88 @@ import {EC, ECPluginEventTypes} from './ec';

});
describe('when the position is invalid', () => {
it('should warn when executing hook on added product', () => {
jest.spyOn(console, 'warn').mockImplementation();
const aProductWithATooSmallPosition = {
name: 'A product with a too small position',
position: 0
};
ec.addProduct(aProductWithATooSmallPosition)
expect(console.warn).not.toHaveBeenCalled();
executeRegisteredHook(ECPluginEventTypes.event, {});
expect(console.warn).toHaveBeenCalledWith(
`The position for product '${aProductWithATooSmallPosition.name}' must be greater than 0 when provided.`
);
expect(console.warn).toHaveBeenCalledTimes(1);
});
it('should remove the position when executing hook on added product', () => {
jest.spyOn(console, 'warn').mockImplementation();
ec.addProduct({
name: 'A product with a too small position',
position: 0
});
const result = executeRegisteredHook(ECPluginEventTypes.event, {});
const positionProperty = 'il1pi1ps';
expect(result).not.toHaveProperty(positionProperty);
});
it('should warn first using the product name then the id', () => {
jest.spyOn(console, 'warn').mockImplementation();
const aProductWithANameAndId = {
name: 'A product with a name and id',
id: 'A product id',
position: 0,
};
const aProductWithOnlyAnId = {
id: 'A product id',
position: 0,
};
ec.addProduct(aProductWithANameAndId);
ec.addProduct(aProductWithOnlyAnId);
executeRegisteredHook(ECPluginEventTypes.event, {});
expect(console.warn).toHaveBeenNthCalledWith(1,
`The position for product '${aProductWithANameAndId.name}' must be greater than 0 when provided.`
);
expect(console.warn).toHaveBeenNthCalledWith(2,
`The position for product '${aProductWithOnlyAnId.id}' must be greater than 0 when provided.`
);
});
it('should tolerate an absent position', () => {
jest.spyOn(console, 'warn').mockImplementation();
ec.addProduct({
name: 'A product with no position',
});
const undefinedPosition = undefined as any;
ec.addProduct({
name: 'A product with an undefined position',
position: undefinedPosition
});
const result = executeRegisteredHook(ECPluginEventTypes.event, {});
expect(console.warn).not.toHaveBeenCalled();
const firstPositionProperty = 'il1pi1ps';
expect(result).not.toHaveProperty(firstPositionProperty);
const secondPositionProperty = 'il1pi2ps';
expect(result).toHaveProperty(secondPositionProperty, undefinedPosition);
});
});
});

@@ -241,2 +327,88 @@

});
describe('when the position is invalid', () => {
it('should warn when executing hook on added impression', () => {
jest.spyOn(console, 'warn').mockImplementation();
const anImpression = {
name: 'An impression with a too small position',
position: 0
};
ec.addImpression(anImpression)
expect(console.warn).not.toHaveBeenCalled();
executeRegisteredHook(ECPluginEventTypes.event, {});
expect(console.warn).toHaveBeenCalledWith(
`The position for impression '${anImpression.name}' must be greater than 0 when provided.`
);
expect(console.warn).toHaveBeenCalledTimes(1);
});
it('should remove the position when executing hook on added impression', () => {
jest.spyOn(console, 'warn').mockImplementation();
ec.addImpression({
name: 'An impression with a too small position',
position: 0
});
const result = executeRegisteredHook(ECPluginEventTypes.event, {});
const positionProperty = 'il1pi1ps';
expect(result).not.toHaveProperty(positionProperty);
});
it('should warn first using the impression name then the id', () => {
jest.spyOn(console, 'warn').mockImplementation();
const anImpressionWithANameAndId = {
name: 'An impression with a name and id',
id: 'An id',
position: 0,
};
const anImpressionWithOnlyAnId = {
id: 'An id',
position: 0,
};
ec.addImpression(anImpressionWithANameAndId);
ec.addImpression(anImpressionWithOnlyAnId);
executeRegisteredHook(ECPluginEventTypes.event, {});
expect(console.warn).toHaveBeenNthCalledWith(1,
`The position for impression '${anImpressionWithANameAndId.name}' must be greater than 0 when provided.`
);
expect(console.warn).toHaveBeenNthCalledWith(2,
`The position for impression '${anImpressionWithOnlyAnId.id}' must be greater than 0 when provided.`
);
});
it('should tolerate an absent position', () => {
jest.spyOn(console, 'warn').mockImplementation();
ec.addImpression({
name: 'An impression with no position',
});
const undefinedPosition = undefined as any;
ec.addImpression({
name: 'An impression with an undefined position',
position: undefinedPosition
});
const result = executeRegisteredHook(ECPluginEventTypes.event, {});
expect(console.warn).not.toHaveBeenCalled();
const firstPositionProperty = 'il1pi1ps';
expect(result).not.toHaveProperty(firstPositionProperty);
const secondPositionProperty = 'il1pi2ps';
expect(result).toHaveProperty(secondPositionProperty, undefinedPosition);
});
});
});

@@ -243,0 +415,0 @@

@@ -139,17 +139,5 @@ import {AnalyticsClient} from '../client/analytics';

const productPayload = this.products.reduce((newPayload, product, index) => {
return {
...newPayload,
...convertProductToMeasurementProtocol(product, index),
};
}, {});
const productPayload = this.getProductPayload();
const impressionPayload = this.getImpressionPayload();
const impressionsByList = this.getImpressionsByList();
const impressionPayload = impressionsByList.reduce((newPayload, impressionList, index) => {
return {
...newPayload,
...convertImpressionListToMeasurementProtocol(impressionList, index),
};
}, {});
this.clearData();

@@ -165,2 +153,53 @@

private getProductPayload() {
return this.products
.map((product) => this.assureProductValidity(product))
.reduce((newPayload, product, index) => {
return {
...newPayload,
...convertProductToMeasurementProtocol(product, index),
};
}, {});
}
private getImpressionPayload() {
const impressionsByList = this.getImpressionsByList();
return impressionsByList
.map(({impressions, ...rest}) => ({
...rest,
impressions: impressions
.map((baseImpression) => this.assureBaseImpressionValidity(baseImpression))
}) as ImpressionList)
.reduce((newPayload, impressionList, index) => {
return {
...newPayload,
...convertImpressionListToMeasurementProtocol(impressionList, index),
};
}, {});
}
private assureProductValidity(product: Product) {
const {position, ...productRest} = product;
if (position !== undefined && position < 1) {
console.warn(`The position for product '${product.name || product.id}' must be greater `
+ `than 0 when provided.`);
return productRest;
}
return product;
}
private assureBaseImpressionValidity(baseImpression: BaseImpression) {
const {position, ...baseImpressionRest} = baseImpression;
if (position !== undefined && position < 1) {
console.warn(`The position for impression '${baseImpression.name || baseImpression.id}'`
+ ` must be greater than 0 when provided.`);
return baseImpressionRest;
}
return baseImpression;
}
private getImpressionsByList() {

@@ -167,0 +206,0 @@ return this.impressions.reduce((lists, impression) => {

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc