coveo.analytics
Advanced tools
Comparing version 2.13.0 to 2.14.0
@@ -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,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}(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 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}var p=[n.click,n.custom,n.search,n.view],f=(d.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!=d.get(e)&&d.get(e)==t||(n="."+a,document.cookie=e+"="+t+s+"; path=/; domain="+n))},d.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},d.erase=function(e){d.set(e,"",-1)},d);function d(){}function v(){return u()?localStorage:c()?new y:"undefined"!=typeof sessionStorage?sessionStorage:new b}var y=(m.prototype.getItem=function(e){return f.get(""+m.prefix+e)},m.prototype.removeItem=function(e){f.erase(""+m.prefix+e)},m.prototype.setItem=function(e,t){f.set(""+m.prefix+e,t)},m.prefix="coveo_",m);function m(){}var w=(E.prototype.getItem=function(e){return localStorage.getItem(e)||this.cookieStorage.getItem(e)},E.prototype.removeItem=function(e){this.cookieStorage.removeItem(e),localStorage.removeItem(e)},E.prototype.setItem=function(e,t){localStorage.setItem(e,t),this.cookieStorage.setItem(e,t)},E);function E(){this.cookieStorage=new y}var b=(S.prototype.getItem=function(e){return null},S.prototype.removeItem=function(e){},S.prototype.setItem=function(e,t){},S);function S(){}var I=Object.freeze({__proto__:null,preferredStorage:null,getAvailableStorage:v,CookieStorage:y,CookieAndLocalStorage:w,NullStorage:b}),C="__coveo.analytics.history",P=(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(C);return e?JSON.parse(e):[]}catch(e){return[]}},k.prototype.setHistory=function(e){try{this.store.setItem(C,JSON.stringify(e.slice(0,20)))}catch(e){}},k.prototype.clear=function(){try{this.store.removeItem(C)}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||v()}function x(t){return[function(e){return Q.test(e)},function(e){return z.test(e)},function(e){return-1!==N.indexOf(e)},function(e){return"custom"===e}].some(function(e){return e(t)})}var T=Object.freeze({__proto__:null,STORE_KEY:C,MAX_NUMBER_OF_HISTORY_ELEMENTS:20,MIN_THRESHOLD_FOR_DUPLICATE_VALUE:6e4,MAX_VALUE_SIZE:75,HistoryStore:P,default:P}),A=function(e){var t=new P,r={name:"PageView",value:e,time:JSON.stringify(new Date)};t.addElement(r)},O=function(e){return e?(Number(e)^R(new Uint8Array(1))[0]%16>>Number(e)/4).toString(16):(""+1e7+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,O)},R=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},L={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",price:"pr",quantity:"qt",coupon:"cc",position:"ps"},F={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",position:"ps",price:"pr"},V=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"}),q=Object.keys,j=function(o,i,s){return q(o).reduce(function(e,t){var r,n="il"+(i+1)+"pi"+(s+1)+(F[t]||t);return h(h({},e),((r={})[n]=o[t],r))},{})},N=q(V).map(function(e){return V[e]}),_=q(L).map(function(e){return L[e]}),U=q(F).map(function(e){return F[e]}),M=a(_,["custom"]).join("|"),B=a(U,["custom"]).join("|"),D="(pr[0-9]+)",H="(il[0-9]+pi[0-9]+)",Q=new RegExp("^"+D+"("+M+")$"),z=new RegExp("^("+H+"("+B+"))|(il[0-9]+nm)$"),Y=new RegExp("^"+D+"custom$"),W=new RegExp("^"+H+"custom$"),J=function(n,o){return q(o).reduce(function(e,t){var r;return h(h({},e),((r={})[""+n+t]=o[t],r))},{})},$=(G.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]})})},G.prototype.encodeForEventType=function(e,t){return this.isEventTypeLegacy(e)?this.encodeForLegacyType(e,t):this.encodeForFormUrlEncoded(h({access_token:this.opts.token},t))},G.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:"","discardVisitInfo=true"].filter(function(e){return!!e}).join("&")},G.prototype.isEventTypeLegacy=function(e){return-1!==[n.click,n.custom,n.search,n.view].indexOf(e)},G.prototype.encodeForLegacyType=function(e,t){return e+"Event="+encodeURIComponent(JSON.stringify(t))},G.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("&")},G.prototype.encodeValue=function(e){return"number"==typeof e||"string"==typeof e||"boolean"==typeof e?e:JSON.stringify(e)},G);function G(e){this.opts=e}var K=(X.prototype.sendEvent=function(e,t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,Promise.resolve()]})})},X);function X(){}var Z=function(e,t){u()&&c()?this.storage=new w:u()?this.storage=localStorage:(console.warn("BrowserRuntime detected no valid storage available.",this),this.storage=new b),this.beaconClient=new $(e),window.addEventListener("beforeunload",function(){return t()})},ee=function(){this.storage=new b,this.beaconClient=new K},te=function(){this.storage=new b,this.beaconClient=new K},re={default:"https://platform.cloud.coveo.com/rest/ua",production:"https://platform.cloud.coveo.com/rest/ua",hipaa:"https://platformhipaa.cloud.coveo.com/rest/ua"},ne=(Object.defineProperty(oe.prototype,"defaultOptions",{get:function(){return{endpoint:re.default,token:"",version:"v15",beforeSendHooks:[]}},enumerable:!0,configurable:!0}),oe.prototype.initRuntime=function(e){var t=this;return"undefined"!=typeof window&&"undefined"!=typeof document?new Z(e,function(){return t.flushBufferWithBeacon()}):new ee},Object.defineProperty(oe.prototype,"analyticsBeaconClient",{get:function(){return this.runtime.beaconClient},enumerable:!0,configurable:!0}),Object.defineProperty(oe.prototype,"storage",{get:function(){return this.runtime.storage},enumerable:!0,configurable:!0}),oe.prototype.initVisitorId=function(){var e=this.visitorId||this.storage.getItem("visitorId")||"";this.currentVisitorId=e||O()},Object.defineProperty(oe.prototype,"currentVisitorId",{get:function(){return this.visitorId},set:function(e){this.visitorId=e,this.storage.setItem("visitorId",e)},enumerable:!0,configurable:!0}),oe.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?q(o=e).reduce(function(e,t){var r,n=V[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()]}})})},oe.prototype.deferExecution=function(){return new Promise(function(e){return setTimeout(e,0)})},oe.prototype.flushBufferWithBeacon=function(){for(;this.hasPendingRequests();){var e=this.bufferedRequests.pop(),t=e.eventType,r=e.payload;this.analyticsBeaconClient.sendEvent(t,r)}},oe.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]})})},oe.prototype.hasPendingRequests=function(){return 0<this.bufferedRequests.length},oe.prototype.clear=function(){this.storage.removeItem("visitorId"),(new P).clear()},oe.prototype.sendSearchEvent=function(t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,this.sendEvent(n.search,t)]})})},oe.prototype.sendClickEvent=function(t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,this.sendEvent(n.click,t)]})})},oe.prototype.sendCustomEvent=function(t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,this.sendEvent(n.custom,t)]})})},oe.prototype.sendViewEvent=function(t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,this.sendEvent(n.view,t)]})})},oe.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]}})})},oe.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()]}})})},oe.prototype.registerBeforeSendEventHook=function(e){this.beforeSendHooks.push(e)},oe.prototype.addEventTypeMapping=function(e,t){this.eventTypeMapping[e]=t},oe.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},oe.prototype.isKeyAllowedEmpty=function(e,t){var r;return-1!==((r={})[n.search]=["queryText"],(r[e]||[]).indexOf(t))},oe.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))},{})},oe.prototype.removeUnknownParameters=function(n){return Object.keys(n).filter(function(e){if(x(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))},{})},oe.prototype.processCustomParameters=function(e){var i,t=e.custom,r=s(e,["custom"]),n=q(i=r).reduce(function(e,t){var r,n=Y.exec(t)||W.exec(t);if(n){var o=n[1];return h(h({},e),J(o,i[t]))}return h(h({},e),((r={})[t]=i[t],r))},{});return h(h({},t||{}),n)},oe.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},oe.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(oe.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}),oe);function oe(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=[function(e,t){return e===n.view?(A(t.contentIdValue),h({location:window.location.toString(),referrer:document.referrer,title:document.title},t)):t},function(e,t){return-1!==p.indexOf(e)?h({language:document.documentElement.lang,userAgent:navigator.userAgent},t):t}].concat(this.options.beforeSendHooks),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 ie=Object.freeze({__proto__:null,Version:"v15",Endpoints:re,CoveoAnalyticsClient:ne,default:ne}),se=i()?[!0,"yes","1"].indexOf(navigator.doNotTrack||navigator.msDoNotTrack||window.doNotTrack):0,ae=Object.freeze({__proto__:null,doNotTrack:se,default:se}),ue=(ce.prototype.register=function(e,t){this.plugins[e]=t},ce.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)},ce);function ce(){this.plugins={}}function le(e){return e.protocol+"//"+e.hostname+(0===e.pathname.indexOf("/")?e.pathname:"/"+e.pathname)+e.search}var pe={pageview:"pageview",event:"event"},fe=Object.keys(pe).map(function(e){return pe[e]}),de=(he.prototype.addProduct=function(e){this.products.push(e)},he.prototype.addImpression=function(e){this.impressions.push(e)},he.prototype.setAction=function(e,t){this.action=e,this.actionData=t},he.prototype.clearData=function(){this.products=[],this.impressions=[],this.action=void 0,this.actionData={}},he.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!==fe.indexOf(e)?o.addECDataToPayload(e,n):n})},he.prototype.addHooksForPageView=function(){this.client.addEventTypeMapping(pe.pageview,{newEventType:n.collect,variableLengthArgumentsNames:["page"],addVisitorIdParameter:!0,usesMeasurementProtocol:!0})},he.prototype.addHooksForEvent=function(){this.client.addEventTypeMapping(pe.event,{newEventType:n.collect,variableLengthArgumentsNames:["eventCategory","eventAction","eventLabel","eventValue"],addVisitorIdParameter:!0,usesMeasurementProtocol:!0})},he.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)},he.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,q(o=t).reduce(function(e,t){var r,n="pr"+(i+1)+(L[t]||t);return h(h({},e),((r={})[n]=o[t],r))},{})));var o,i},{})},he.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),j(t,n,r))},{});return e.listName&&(t["il"+(n+1)+"nm"]=e.listName),t}(t,r))},{})},he.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},he.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},he.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},[])},he.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=le(window.location),this.hasSentFirstPageView=!0},he.prototype.getLocationInformation=function(e,t){return e===pe.pageview&&this.updateStateForNewPageView(t),{referrer:this.lastReferrer,location:this.lastLocation}},he.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)},he);function he(e){var t=e.client,r=e.uuidGenerator,n=void 0===r?O:r;this.products=[],this.impressions=[],this.actionData={},this.client=t,this.uuidGenerator=n,this.pageViewId=n(),this.lastLocation=le(window.location),this.lastReferrer=document.referrer,this.addHooksForPageView(),this.addHooksForEvent(),this.addHooksForECEvents()}var ge=(ve.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||re.default,this.client=new ne({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 de({client:this.client})),this.client.registerBeforeSendEventHook(function(e,t){return h(h({},t),r.params)})},ve.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 ne({endpoint:e})},ve.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]})},ve.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))},ve.prototype.onLoad=function(e){if(void 0===e)throw new Error("You must pass a function when you call 'onLoad'");e()},ve.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))},ve.prototype.reset=function(){this.client=void 0,this.plugins=new ue,this.params={}},ve);function ve(){this.plugins=new ue,this.params={}}function ye(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=be[i];if(o&&i)return be.callPlugin.apply(be,a([o,i],t));if(s)return s.apply(be,t);throw new Error('The action "'+e+'" does not exist. Available actions: '+["init","set","send","onLoad","callPlugin"].join(", ")+".")}var me,we,Ee,be=new ge,Se=Object.freeze({__proto__:null,CoveoUA:ge,coveoua:be,handleOneAnalyticsEvent:ye,default:ye});(Ee=we=we||{}).interfaceLoad="interfaceLoad",Ee.interfaceChange="interfaceChange",Ee.didyoumeanAutomatic="didyoumeanAutomatic",Ee.didyoumeanClick="didyoumeanClick",Ee.resultsSort="resultsSort",Ee.searchboxSubmit="searchboxSubmit",Ee.searchboxClear="searchboxClear",Ee.searchboxAsYouType="searchboxAsYouType",Ee.breadcrumbFacet="breadcrumbFacet",Ee.breadcrumbResetAll="breadcrumbResetAll",Ee.documentQuickview="documentQuickview",Ee.documentOpen="documentOpen",Ee.omniboxAnalytics="omniboxAnalytics",Ee.omniboxFromLink="omniboxFromLink",Ee.triggerNotify="notify",Ee.triggerExecute="execute",Ee.triggerQuery="query",Ee.triggerRedirect="redirect",Ee.pagerResize="pagerResize",Ee.pagerNumber="pagerNumber",Ee.pagerNext="pagerNext",Ee.pagerPrevious="pagerPrevious",Ee.pagerScrolling="pagerScrolling",Ee.facetClearAll="facetClearAll",Ee.facetSearch="facetSearch",Ee.facetSelect="facetSelect",Ee.facetSelectAll="facetSelectAll",Ee.facetDeselect="facetDeselect",Ee.facetExclude="facetExclude",Ee.facetUnexclude="facetUnexclude",Ee.facetUpdateSort="facetUpdateSort",Ee.facetShowMore="showMoreFacetResults",Ee.facetShowLess="showLessFacetResults",Ee.queryError="query",Ee.queryErrorBack="errorBack",Ee.queryErrorClear="errorClearQuery",Ee.queryErrorRetry="errorRetry",Ee.recommendation="recommendation",Ee.recommendationInterfaceLoad="recommendationInterfaceLoad";var Ie=((me={})[we.triggerNotify]="queryPipelineTriggers",me[we.triggerExecute]="queryPipelineTriggers",me[we.triggerQuery]="queryPipelineTriggers",me[we.triggerRedirect]="queryPipelineTriggers",me[we.queryError]="errors",me[we.queryErrorBack]="errors",me[we.queryErrorClear]="errors",me[we.queryErrorRetry]="errors",me[we.pagerNext]="getMoreResults",me[we.pagerPrevious]="getMoreResults",me[we.pagerNumber]="getMoreResults",me[we.pagerResize]="getMoreResults",me[we.pagerScrolling]="getMoreResults",me[we.facetSearch]="facet",me[we.facetShowLess]="facet",me[we.facetShowMore]="facet",me[we.recommendation]="recommendation",me),Ce=(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 te,this.currentVisitorId=""}function ke(e){var r,t=e.map(function(e){return e.replace(/;/g,"")});return function e(t){var r=t.join(";");return r.length<=256?r:e(t.slice(1))}((r="",t.filter(function(e){var t=e!==r;return r=e,t})))}function xe(e){var t="string"==typeof e.partialQueries?e.partialQueries:ke(e.partialQueries),r="string"==typeof e.suggestions?e.suggestions:ke(e.suggestions);return h(h({},e),{partialQueries:t,suggestions:r})}var Te=(Ae.prototype.disable=function(){this.coveoAnalyticsClient instanceof ne&&this.coveoAnalyticsClient.clear(),this.coveoAnalyticsClient=new Ce},Ae.prototype.enable=function(){this.coveoAnalyticsClient=new ne(this.opts)},Ae.prototype.logInterfaceLoad=function(){return this.logSearchEvent(we.interfaceLoad)},Ae.prototype.logRecommendationInterfaceLoad=function(){return this.logSearchEvent(we.recommendationInterfaceLoad)},Ae.prototype.logRecommendation=function(){return this.logCustomEvent(we.recommendation)},Ae.prototype.logFetchMoreResults=function(){return this.logCustomEvent(we.pagerScrolling,{type:"getMoreResults"})},Ae.prototype.logInterfaceChange=function(e){return this.logSearchEvent(we.interfaceChange,e)},Ae.prototype.logDidYouMeanAutomatic=function(){return this.logSearchEvent(we.didyoumeanAutomatic)},Ae.prototype.logDidYouMeanClick=function(){return this.logSearchEvent(we.didyoumeanClick)},Ae.prototype.logResultsSort=function(e){return this.logSearchEvent(we.resultsSort,e)},Ae.prototype.logSearchboxSubmit=function(){return this.logSearchEvent(we.searchboxSubmit)},Ae.prototype.logSearchboxClear=function(){return this.logSearchEvent(we.searchboxClear)},Ae.prototype.logSearchboxAsYouType=function(){return this.logSearchEvent(we.searchboxAsYouType)},Ae.prototype.logBreadcrumbFacet=function(e){return this.logSearchEvent(we.breadcrumbFacet,e)},Ae.prototype.logBreadcrumbResetAll=function(){return this.logSearchEvent(we.breadcrumbResetAll)},Ae.prototype.logDocumentQuickview=function(e,t){return this.logClickEvent(we.documentQuickview,e,t)},Ae.prototype.logDocumentOpen=function(e,t){return this.logClickEvent(we.documentOpen,e,t)},Ae.prototype.logOmniboxAnalytics=function(e){return this.logSearchEvent(we.omniboxAnalytics,xe(e))},Ae.prototype.logOmniboxFromLink=function(e){return this.logSearchEvent(we.omniboxFromLink,xe(e))},Ae.prototype.logTriggerNotify=function(e){return this.logCustomEvent(we.triggerNotify,e)},Ae.prototype.logTriggerExecute=function(e){return this.logCustomEvent(we.triggerExecute,e)},Ae.prototype.logTriggerQuery=function(){var e={query:this.provider.getSearchEventRequestPayload().queryText};return this.logCustomEvent(we.triggerQuery,e)},Ae.prototype.logTriggerRedirect=function(e){var t=h(h({},e),{query:this.provider.getSearchEventRequestPayload().queryText});return this.logCustomEvent(we.triggerRedirect,t)},Ae.prototype.logPagerResize=function(e){return this.logCustomEvent(we.pagerResize,e)},Ae.prototype.logPagerNumber=function(e){return this.logCustomEvent(we.pagerNumber,e)},Ae.prototype.logPagerNext=function(e){return this.logCustomEvent(we.pagerNext,e)},Ae.prototype.logPagerPrevious=function(e){return this.logCustomEvent(we.pagerPrevious,e)},Ae.prototype.logPagerScrolling=function(){return this.logCustomEvent(we.pagerScrolling)},Ae.prototype.logFacetClearAll=function(e){return this.logSearchEvent(we.facetClearAll,e)},Ae.prototype.logFacetSearch=function(e){return this.logSearchEvent(we.facetSearch,e)},Ae.prototype.logFacetSelect=function(e){return this.logSearchEvent(we.facetSelect,e)},Ae.prototype.logFacetDeselect=function(e){return this.logSearchEvent(we.facetDeselect,e)},Ae.prototype.logFacetExclude=function(e){return this.logSearchEvent(we.facetExclude,e)},Ae.prototype.logFacetUnexclude=function(e){return this.logSearchEvent(we.facetUnexclude,e)},Ae.prototype.logFacetSelectAll=function(e){return this.logSearchEvent(we.facetSelectAll,e)},Ae.prototype.logFacetUpdateSort=function(e){return this.logSearchEvent(we.facetUpdateSort,e)},Ae.prototype.logFacetShowMore=function(e){return this.logCustomEvent(we.facetShowMore,e)},Ae.prototype.logFacetShowLess=function(e){return this.logCustomEvent(we.facetShowLess,e)},Ae.prototype.logQueryError=function(e){return this.logCustomEvent(we.queryError,e)},Ae.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(we.queryErrorBack)];case 1:return e.sent(),[2,this.logSearchEvent(we.queryErrorBack)]}})})},Ae.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(we.queryErrorRetry)];case 1:return e.sent(),[2,this.logSearchEvent(we.queryErrorRetry)]}})})},Ae.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(we.queryErrorClear)];case 1:return e.sent(),[2,this.logSearchEvent(we.queryErrorClear)]}})})},Ae.prototype.logCustomEvent=function(e,t){var r=h(h({},this.provider.getBaseMetadata()),t),n=h(h({},this.getOrigins()),{eventType:Ie[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 Ce:new ne(e)}var Oe=Object.freeze({__proto__:null,analytics:ie,donottrack:ae,history:T,SimpleAnalytics:Se,storage:I,CoveoAnalyticsClient:ne,CoveoUA:ge,handleOneAnalyticsEvent:ye,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||ye;self.coveoua=ye,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 ye.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,c){return new(a=a||Promise)(function(r,t){function n(e){try{i(c.next(e))}catch(e){t(e)}}function o(e){try{i(c.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((c=c.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,c){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(c),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,c),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 c(){return"undefined"!=typeof localStorage}function u(){return i()&&navigator.cookieEnabled}function l(){return"undefined"!=typeof crypto&&void 0!==crypto.getRandomValues}var p=[n.click,n.custom,n.search,n.view],d=(f.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!=f.get(e)&&f.get(e)==t||(n="."+a,document.cookie=e+"="+t+s+"; path=/; domain="+n))},f.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},f.erase=function(e){f.set(e,"",-1)},f);function f(){}function v(){return c()?localStorage:u()?new y:"undefined"!=typeof sessionStorage?sessionStorage:new b}var y=(m.prototype.getItem=function(e){return d.get(""+m.prefix+e)},m.prototype.removeItem=function(e){d.erase(""+m.prefix+e)},m.prototype.setItem=function(e,t){d.set(""+m.prefix+e,t)},m.prefix="coveo_",m);function m(){}var w=(E.prototype.getItem=function(e){return localStorage.getItem(e)||this.cookieStorage.getItem(e)},E.prototype.removeItem=function(e){this.cookieStorage.removeItem(e),localStorage.removeItem(e)},E.prototype.setItem=function(e,t){localStorage.setItem(e,t),this.cookieStorage.setItem(e,t)},E);function E(){this.cookieStorage=new y}var b=(S.prototype.getItem=function(e){return null},S.prototype.removeItem=function(e){},S.prototype.setItem=function(e,t){},S);function S(){}var I=Object.freeze({__proto__:null,preferredStorage:null,getAvailableStorage:v,CookieStorage:y,CookieAndLocalStorage:w,NullStorage:b}),C="__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(C);return e?JSON.parse(e):[]}catch(e){return[]}},P.prototype.setHistory=function(e){try{this.store.setItem(C,JSON.stringify(e.slice(0,20)))}catch(e){}},P.prototype.clear=function(){try{this.store.removeItem(C)}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||v()}function x(t){return[function(e){return W.test(e)},function(e){return _.test(e)},function(e){return G.test(e)},function(e){return-1!==M.indexOf(e)},function(e){return"custom"===e}].some(function(e){return e(t)})}var T=Object.freeze({__proto__:null,STORE_KEY:C,MAX_NUMBER_OF_HISTORY_ELEMENTS:20,MIN_THRESHOLD_FOR_DUPLICATE_VALUE:6e4,MAX_VALUE_SIZE:75,HistoryStore:k,default:k}),A=function(e){var t=new k,r={name:"PageView",value:e,time:JSON.stringify(new Date)};t.addElement(r)},O=function(e){return e?(Number(e)^R(new Uint8Array(1))[0]%16>>Number(e)/4).toString(16):(""+1e7+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,O)},R=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=Object.keys,L={id:"svc_ticket_id",subject:"svc_ticket_subject",description:"svc_ticket_description",category:"svc_ticket_category",productId:"svc_ticket_product_id",custom:"svc_ticket_custom"},F=a(V(L).map(function(e){return L[e]})).join("|"),_=new RegExp("^("+F+"$)"),D={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"},q=h(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"}),{svcAction:"svc_action",svcActionData:"svc_action_data"}),N=function(o,i,s,a){return V(o).reduce(function(e,t){var r,n="il"+(i+1)+a+(s+1)+(j[t]||t);return h(h({},e),((r={})[n]=o[t],r))},{})},M=V(q).map(function(e){return q[e]}),U=V(D).map(function(e){return D[e]}),H=V(j).map(function(e){return j[e]}),B=a(U,["custom"]).join("|"),Q=a(H,["custom"]).join("|"),z="(pr[0-9]+)",Y="(il[0-9]+pi[0-9]+)",W=new RegExp("^"+z+"("+B+")$"),G=new RegExp("^("+Y+"("+Q+"))|(il[0-9]+nm)$"),$=new RegExp("^"+z+"custom$"),J=new RegExp("^"+Y+"custom$"),K=function(n,o){return V(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:"","discardVisitInfo=true"].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()&&u()?this.storage=new w:c()?this.storage=localStorage:(console.warn("BrowserRuntime detected no valid storage available.",this),this.storage=new b),this.beaconClient=new X(e),window.addEventListener("beforeunload",function(){return t()})},ne=function(){this.storage=new b,this.beaconClient=new ee},oe=function(){this.storage=new b,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",beforeSendHooks:[]}},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||O()},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(d){for(var f=[],e=1;e<arguments.length;e++)f[e-1]=arguments[e];return r(this,void 0,void 0,function(){var t,r,n,o,i,s,a,c,u,l,p=this;return g(this,function(e){switch(e.label){case 0:return t=this.eventTypeMapping[d]||{},n=void 0===(r=t.newEventType)?d:r,i=void 0===(o=t.variableLengthArgumentsNames)?[]:o,a=void 0!==(s=t.addVisitorIdParameter)&&s,u=void 0!==(c=t.usesMeasurementProtocol)&&c,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 u?p.ensureAnonymousUserWhenUsingApiKey(e):e},function(e){return p.beforeSendHooks.reduce(function(e,t){return t(d,e)},e)},function(e){return p.removeEmptyPayloadValues(e,d)},function(e){return p.validateParams(e)},function(e){return u?V(o=e).reduce(function(e,t){var r,n=q[t]||t;return h(h({},e),((r={})[n]=o[t],r))},{}):e;var o},function(e){return u?p.removeUnknownParameters(e):e},function(e){return u?p.processCustomParameters(e):e}].reduce(function(e,t){return t(e)},f),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(x(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=this.lowercaseKeys(t),o=V(i=r).reduce(function(e,t){var r,n=$.exec(t)||J.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({},n),o)},ae.prototype.lowercaseKeys=function(n){return Object.keys(n||{}).reduce(function(e,t){var r;return h(h({},e),((r={})[t.toLowerCase()]=n[t],r))},{})},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=[function(e,t){return e===n.view?(A(t.contentIdValue),h({location:window.location.toString(),referrer:document.referrer,title:document.title},t)):t},function(e,t){return-1!==p.indexOf(e)?h({language:document.documentElement.lang,userAgent:navigator.userAgent},t):t}].concat(this.options.beforeSendHooks),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 ce=Object.freeze({__proto__:null,Version:"v15",Endpoints:ie,CoveoAnalyticsClient:se,default:se}),ue=i()?[!0,"yes","1"].indexOf(navigator.doNotTrack||navigator.msDoNotTrack||window.doNotTrack):0,le=Object.freeze({__proto__:null,doNotTrack:ue,default:ue}),pe=(de.prototype.register=function(e,t){this.plugins[e]=t},de.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)},de);function de(){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"},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,V(o=t).reduce(function(e,t){var r,n="pr"+(i+1)+(D[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,o){var t=e.impressions.reduce(function(e,t,r){return h(h({},e),N(t,n,r,o))},{});return e.listName&&(t["il"+(n+1)+"nm"]=e.listName),t}(t,r,"pi"))},{})},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=fe(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?O: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 me={pageview:"pageview",event:"event"},we=Object.keys(me).map(function(e){return me[e]}),Ee=(be.prototype.setTicket=function(e){this.ticket=e},be.prototype.addImpression=function(e){this.impressions.push(e)},be.prototype.setAction=function(e,t){this.action=e,this.actionData=t},be.prototype.clearData=function(){this.ticket={},this.impressions=[],this.action=void 0,this.actionData={}},be.prototype.addHooksForSVCEvents=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!==we.indexOf(e)?o.addSVCDataToPayload(e,n):n})},be.prototype.addHooksForPageView=function(){this.client.addEventTypeMapping(me.pageview,{newEventType:n.collect,variableLengthArgumentsNames:["page"],addVisitorIdParameter:!0,usesMeasurementProtocol:!0})},be.prototype.addHooksForEvent=function(){this.client.addEventTypeMapping(me.event,{newEventType:n.collect,variableLengthArgumentsNames:["eventCategory","eventAction","eventLabel","eventValue"],addVisitorIdParameter:!0,usesMeasurementProtocol:!0})},be.prototype.addSVCDataToPayload=function(e,t){var r,n=h(h(h(h({},this.getLocationInformation(e,t)),this.getDefaultContextInformation(e)),this.action?{svcAction:this.action}:{}),0<Object.keys(null!==(r=this.actionData)&&void 0!==r?r:{}).length?{svcActionData:this.actionData}:{}),o=this.getTicketPayload();return this.clearData(),h(h(h({},o),n),t)},be.prototype.getTicketPayload=function(){return o=this.ticket,V(o).filter(function(e){return void 0!==o[e]}).reduce(function(e,t){var r,n=L[t]||t;return h(h({},e),((r={})[n]=o[t],r))},{});var o},be.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},be.prototype.getLocationInformation=function(e,t){return e===me.pageview&&this.updateStateForNewPageView(t),{referrer:this.lastReferrer,location:this.lastLocation}},be.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)},be);function be(e){var t=e.client,r=e.uuidGenerator,n=void 0===r?O:r;this.ticket={},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.addHooksForSVCEvents()}var Se=(Ie.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.plugins.register("svc",new Ee({client:this.client})),this.client.registerBeforeSendEventHook(function(e,t){return h(h({},t),r.params)})},Ie.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})},Ie.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]})},Ie.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))},Ie.prototype.onLoad=function(e){if(void 0===e)throw new Error("You must pass a function when you call 'onLoad'");e()},Ie.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))},Ie.prototype.reset=function(){this.client=void 0,this.plugins=new pe,this.params={}},Ie);function Ie(){this.plugins=new pe,this.params={}}function Ce(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=Te[i];if(o&&i)return Te.callPlugin.apply(Te,a([o,i],t));if(s)return s.apply(Te,t);throw new Error('The action "'+e+'" does not exist. Available actions: '+["init","set","send","onLoad","callPlugin"].join(", ")+".")}var ke,Pe,xe,Te=new Se,Ae=Object.freeze({__proto__:null,CoveoUA:Se,coveoua:Te,handleOneAnalyticsEvent:Ce,default:Ce});(xe=Pe=Pe||{}).interfaceLoad="interfaceLoad",xe.interfaceChange="interfaceChange",xe.didyoumeanAutomatic="didyoumeanAutomatic",xe.didyoumeanClick="didyoumeanClick",xe.resultsSort="resultsSort",xe.searchboxSubmit="searchboxSubmit",xe.searchboxClear="searchboxClear",xe.searchboxAsYouType="searchboxAsYouType",xe.breadcrumbFacet="breadcrumbFacet",xe.breadcrumbResetAll="breadcrumbResetAll",xe.documentQuickview="documentQuickview",xe.documentOpen="documentOpen",xe.omniboxAnalytics="omniboxAnalytics",xe.omniboxFromLink="omniboxFromLink",xe.triggerNotify="notify",xe.triggerExecute="execute",xe.triggerQuery="query",xe.triggerRedirect="redirect",xe.pagerResize="pagerResize",xe.pagerNumber="pagerNumber",xe.pagerNext="pagerNext",xe.pagerPrevious="pagerPrevious",xe.pagerScrolling="pagerScrolling",xe.facetClearAll="facetClearAll",xe.facetSearch="facetSearch",xe.facetSelect="facetSelect",xe.facetSelectAll="facetSelectAll",xe.facetDeselect="facetDeselect",xe.facetExclude="facetExclude",xe.facetUnexclude="facetUnexclude",xe.facetUpdateSort="facetUpdateSort",xe.facetShowMore="showMoreFacetResults",xe.facetShowLess="showLessFacetResults",xe.queryError="query",xe.queryErrorBack="errorBack",xe.queryErrorClear="errorClearQuery",xe.queryErrorRetry="errorRetry",xe.recommendation="recommendation",xe.recommendationInterfaceLoad="recommendationInterfaceLoad";var Oe=((ke={})[Pe.triggerNotify]="queryPipelineTriggers",ke[Pe.triggerExecute]="queryPipelineTriggers",ke[Pe.triggerQuery]="queryPipelineTriggers",ke[Pe.triggerRedirect]="queryPipelineTriggers",ke[Pe.queryError]="errors",ke[Pe.queryErrorBack]="errors",ke[Pe.queryErrorClear]="errors",ke[Pe.queryErrorRetry]="errors",ke[Pe.pagerNext]="getMoreResults",ke[Pe.pagerPrevious]="getMoreResults",ke[Pe.pagerNumber]="getMoreResults",ke[Pe.pagerResize]="getMoreResults",ke[Pe.pagerScrolling]="getMoreResults",ke[Pe.facetSearch]="facet",ke[Pe.facetShowLess]="facet",ke[Pe.facetShowMore]="facet",ke[Pe.recommendation]="recommendation",ke),Re=(Ve.prototype.sendEvent=function(){return Promise.resolve()},Ve.prototype.sendSearchEvent=function(){return Promise.resolve()},Ve.prototype.sendClickEvent=function(){return Promise.resolve()},Ve.prototype.sendCustomEvent=function(){return Promise.resolve()},Ve.prototype.sendViewEvent=function(){return Promise.resolve()},Ve.prototype.getVisit=function(){return Promise.resolve({id:"",visitorId:""})},Ve.prototype.getHealth=function(){return Promise.resolve({status:""})},Ve.prototype.registerBeforeSendEventHook=function(){},Ve.prototype.addEventTypeMapping=function(){},Ve);function Ve(){this.runtime=new oe,this.currentVisitorId=""}function Le(e){var r,t=e.map(function(e){return e.replace(/;/g,"")});return function e(t){var r=t.join(";");return r.length<=256?r:e(t.slice(1))}((r="",t.filter(function(e){var t=e!==r;return r=e,t})))}function Fe(e){var t="string"==typeof e.partialQueries?e.partialQueries:Le(e.partialQueries),r="string"==typeof e.suggestions?e.suggestions:Le(e.suggestions);return h(h({},e),{partialQueries:t,suggestions:r})}var _e=(De.prototype.disable=function(){this.coveoAnalyticsClient instanceof se&&this.coveoAnalyticsClient.clear(),this.coveoAnalyticsClient=new Re},De.prototype.enable=function(){this.coveoAnalyticsClient=new se(this.opts)},De.prototype.logInterfaceLoad=function(){return this.logSearchEvent(Pe.interfaceLoad)},De.prototype.logRecommendationInterfaceLoad=function(){return this.logSearchEvent(Pe.recommendationInterfaceLoad)},De.prototype.logRecommendation=function(){return this.logCustomEvent(Pe.recommendation)},De.prototype.logFetchMoreResults=function(){return this.logCustomEvent(Pe.pagerScrolling,{type:"getMoreResults"})},De.prototype.logInterfaceChange=function(e){return this.logSearchEvent(Pe.interfaceChange,e)},De.prototype.logDidYouMeanAutomatic=function(){return this.logSearchEvent(Pe.didyoumeanAutomatic)},De.prototype.logDidYouMeanClick=function(){return this.logSearchEvent(Pe.didyoumeanClick)},De.prototype.logResultsSort=function(e){return this.logSearchEvent(Pe.resultsSort,e)},De.prototype.logSearchboxSubmit=function(){return this.logSearchEvent(Pe.searchboxSubmit)},De.prototype.logSearchboxClear=function(){return this.logSearchEvent(Pe.searchboxClear)},De.prototype.logSearchboxAsYouType=function(){return this.logSearchEvent(Pe.searchboxAsYouType)},De.prototype.logBreadcrumbFacet=function(e){return this.logSearchEvent(Pe.breadcrumbFacet,e)},De.prototype.logBreadcrumbResetAll=function(){return this.logSearchEvent(Pe.breadcrumbResetAll)},De.prototype.logDocumentQuickview=function(e,t){return this.logClickEvent(Pe.documentQuickview,e,t)},De.prototype.logDocumentOpen=function(e,t){return this.logClickEvent(Pe.documentOpen,e,t)},De.prototype.logOmniboxAnalytics=function(e){return this.logSearchEvent(Pe.omniboxAnalytics,Fe(e))},De.prototype.logOmniboxFromLink=function(e){return this.logSearchEvent(Pe.omniboxFromLink,Fe(e))},De.prototype.logTriggerNotify=function(e){return this.logCustomEvent(Pe.triggerNotify,e)},De.prototype.logTriggerExecute=function(e){return this.logCustomEvent(Pe.triggerExecute,e)},De.prototype.logTriggerQuery=function(){var e={query:this.provider.getSearchEventRequestPayload().queryText};return this.logCustomEvent(Pe.triggerQuery,e)},De.prototype.logTriggerRedirect=function(e){var t=h(h({},e),{query:this.provider.getSearchEventRequestPayload().queryText});return this.logCustomEvent(Pe.triggerRedirect,t)},De.prototype.logPagerResize=function(e){return this.logCustomEvent(Pe.pagerResize,e)},De.prototype.logPagerNumber=function(e){return this.logCustomEvent(Pe.pagerNumber,e)},De.prototype.logPagerNext=function(e){return this.logCustomEvent(Pe.pagerNext,e)},De.prototype.logPagerPrevious=function(e){return this.logCustomEvent(Pe.pagerPrevious,e)},De.prototype.logPagerScrolling=function(){return this.logCustomEvent(Pe.pagerScrolling)},De.prototype.logFacetClearAll=function(e){return this.logSearchEvent(Pe.facetClearAll,e)},De.prototype.logFacetSearch=function(e){return this.logSearchEvent(Pe.facetSearch,e)},De.prototype.logFacetSelect=function(e){return this.logSearchEvent(Pe.facetSelect,e)},De.prototype.logFacetDeselect=function(e){return this.logSearchEvent(Pe.facetDeselect,e)},De.prototype.logFacetExclude=function(e){return this.logSearchEvent(Pe.facetExclude,e)},De.prototype.logFacetUnexclude=function(e){return this.logSearchEvent(Pe.facetUnexclude,e)},De.prototype.logFacetSelectAll=function(e){return this.logSearchEvent(Pe.facetSelectAll,e)},De.prototype.logFacetUpdateSort=function(e){return this.logSearchEvent(Pe.facetUpdateSort,e)},De.prototype.logFacetShowMore=function(e){return this.logCustomEvent(Pe.facetShowMore,e)},De.prototype.logFacetShowLess=function(e){return this.logCustomEvent(Pe.facetShowLess,e)},De.prototype.logQueryError=function(e){return this.logCustomEvent(Pe.queryError,e)},De.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(Pe.queryErrorBack)];case 1:return e.sent(),[2,this.logSearchEvent(Pe.queryErrorBack)]}})})},De.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(Pe.queryErrorRetry)];case 1:return e.sent(),[2,this.logSearchEvent(Pe.queryErrorRetry)]}})})},De.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(Pe.queryErrorClear)];case 1:return e.sent(),[2,this.logSearchEvent(Pe.queryErrorClear)]}})})},De.prototype.logCustomEvent=function(e,t){var r=h(h({},this.provider.getBaseMetadata()),t),n=h(h({},this.getOrigins()),{eventType:Oe[e],eventValue:e,lastSearchQueryUid:this.provider.getSearchUID(),customData:r});return this.coveoAnalyticsClient.sendCustomEvent(n)},De.prototype.logCustomEventWithType=function(e,t,r){var n=h(h({},this.provider.getBaseMetadata()),r),o=h(h({},this.getOrigins()),{eventType:t,eventValue:e,lastSearchQueryUid:this.provider.getSearchUID(),customData:n});return this.coveoAnalyticsClient.sendCustomEvent(o)},De.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)},De.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)},De.prototype.getOrigins=function(){return{originLevel1:this.provider.getOriginLevel1(),originLevel2:this.provider.getOriginLevel2(),originLevel3:this.provider.getOriginLevel3()}},De);function De(e,t){this.opts=e,this.provider=t,this.coveoAnalyticsClient=!1===e.enableAnalytics?new Re:new se(e)}var je=Object.freeze({__proto__:null,analytics:ce,donottrack:le,history:T,SimpleAnalytics:Ae,storage:I,CoveoAnalyticsClient:se,CoveoUA:Se,handleOneAnalyticsEvent:Ce,CoveoSearchPageClient:_e});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 qe=self.coveoua||Ce;self.coveoua=Ce,self.coveoanalytics=je,qe.q&&a(qe.q.filter(function(e){return"init"===e[0]}),qe.q.filter(function(e){return"init"!==e[0]})).forEach(function(e){return Ce.apply(void 0,e)});return self.coveoua}); | ||
//# sourceMappingURL=coveoua.js.map |
@@ -71,2 +71,3 @@ import { AnyEventResponse, ClickEventRequest, ClickEventResponse, CustomEventRequest, CustomEventResponse, EventType, HealthResponse, SearchEventRequest, SearchEventResponse, ViewEventRequest, ViewEventResponse, VisitResponse, VariableArgumentsPayload } from '../events'; | ||
private processCustomParameters; | ||
private lowercaseKeys; | ||
private validateParams; | ||
@@ -73,0 +74,0 @@ private ensureAnonymousUserWhenUsingApiKey; |
import { ImpressionList } from '../plugins/ec'; | ||
export declare const keysOf: <T>(o: T) => Extract<keyof T, string>[]; | ||
export declare const convertKeysToMeasurementProtocol: (params: any) => {}; | ||
export declare const convertProductToMeasurementProtocol: (product: (Pick<import("../plugins/ec").ProductProperties, "brand" | "category" | "variant" | "price" | "quantity" | "coupon" | "position" | "custom"> & Required<Pick<import("../plugins/ec").ProductProperties, "id">> & Partial<Pick<import("../plugins/ec").ProductProperties, "name">>) | (Pick<import("../plugins/ec").ProductProperties, "brand" | "category" | "variant" | "price" | "quantity" | "coupon" | "position" | "custom"> & Required<Pick<import("../plugins/ec").ProductProperties, "name">> & Partial<Pick<import("../plugins/ec").ProductProperties, "id">>), index: number) => {}; | ||
export declare const convertImpressionListToMeasurementProtocol: (impressionList: ImpressionList, listIndex: number) => { | ||
export declare const convertImpressionListToMeasurementProtocol: (impressionList: ImpressionList, listIndex: number, prefix: string) => { | ||
[name: string]: any; | ||
@@ -7,0 +6,0 @@ }; |
@@ -64,2 +64,3 @@ import { ClientOptions, AnalyticsClient } from '../client/analytics'; | ||
logCustomEvent(event: SearchPageEvents, metadata?: Record<string, any>): Promise<void | import("../events").CustomEventResponse>; | ||
logCustomEventWithType(eventValue: string, eventType: string, metadata?: Record<string, any>): Promise<void | import("../events").CustomEventResponse>; | ||
logSearchEvent(event: SearchPageEvents, metadata?: Record<string, any>): Promise<void | import("../events").SearchEventResponse>; | ||
@@ -66,0 +67,0 @@ logClickEvent(event: SearchPageEvents, info: PartialDocumentInformation, identifier: DocumentIdentifier, metadata?: Record<string, any>): Promise<void | import("../events").ClickEventResponse>; |
@@ -347,2 +347,21 @@ /*! ***************************************************************************** | ||
const keysOf = Object.keys; | ||
const ticketKeysMapping = { | ||
id: 'svc_ticket_id', | ||
subject: 'svc_ticket_subject', | ||
description: 'svc_ticket_description', | ||
category: 'svc_ticket_category', | ||
productId: 'svc_ticket_product_id', | ||
custom: 'svc_ticket_custom', | ||
}; | ||
const ticketKeysMappingValues = keysOf(ticketKeysMapping).map((key) => ticketKeysMapping[key]); | ||
const ticketSubKeysMatchGroup = [...ticketKeysMappingValues].join('|'); | ||
const ticketKeyRegex = new RegExp(`^(${ticketSubKeysMatchGroup}$)`); | ||
const svcActionsKeysMapping = { | ||
svcAction: 'svc_action', | ||
svcActionData: 'svc_action_data', | ||
}; | ||
const isTicketKey = (key) => ticketKeyRegex.test(key); | ||
const globalParamKeysMapping = { | ||
@@ -411,4 +430,3 @@ anonymizeIp: 'aip', | ||
}; | ||
const measurementProtocolKeysMapping = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, eventKeysMapping), productActionsKeysMapping), transactionActionsKeysMapping), contextInformationMapping), globalParamKeysMapping); | ||
const keysOf = Object.keys; | ||
const measurementProtocolKeysMapping = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, eventKeysMapping), productActionsKeysMapping), transactionActionsKeysMapping), contextInformationMapping), globalParamKeysMapping), svcActionsKeysMapping); | ||
const convertKeysToMeasurementProtocol = (params) => { | ||
@@ -436,3 +454,3 @@ return keysOf(params).reduce((mappedKeys, key) => { | ||
const isMeasurementProtocolKey = (key) => { | ||
return [isProductKey, isImpressionKey, isKnownMeasurementProtocolKey, isCustomKey].some((test) => test(key)); | ||
return [isProductKey, isTicketKey, isImpressionKey, isKnownMeasurementProtocolKey, isCustomKey].some((test) => test(key)); | ||
}; | ||
@@ -746,5 +764,10 @@ const convertCustomMeasurementProtocolKeys = (data) => { | ||
const { custom } = payload, rest = __rest(payload, ["custom"]); | ||
const lowercasedCustom = this.lowercaseKeys(custom); | ||
const newPayload = convertCustomMeasurementProtocolKeys(rest); | ||
return Object.assign(Object.assign({}, (custom || {})), newPayload); | ||
return Object.assign(Object.assign({}, lowercasedCustom), newPayload); | ||
} | ||
lowercaseKeys(custom) { | ||
const keys = Object.keys(custom || {}); | ||
return keys.reduce((all, key) => (Object.assign(Object.assign({}, all), { [key.toLowerCase()]: custom[key] })), {}); | ||
} | ||
validateParams(payload) { | ||
@@ -1056,2 +1079,8 @@ const { anonymizeIp } = payload, rest = __rest(payload, ["anonymizeIp"]); | ||
} | ||
logCustomEventWithType(eventValue, eventType, metadata) { | ||
const customData = Object.assign(Object.assign({}, this.provider.getBaseMetadata()), metadata); | ||
const payload = Object.assign(Object.assign({}, this.getOrigins()), { eventType, | ||
eventValue, lastSearchQueryUid: this.provider.getSearchUID(), customData }); | ||
return this.coveoAnalyticsClient.sendCustomEvent(payload); | ||
} | ||
logSearchEvent(event, metadata) { | ||
@@ -1058,0 +1087,0 @@ const customData = Object.assign(Object.assign({}, this.provider.getBaseMetadata()), metadata); |
@@ -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,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}var f=[n.click,n.custom,n.search,n.view],d=(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 c()?localStorage:l()?new m:"undefined"!=typeof sessionStorage?sessionStorage:new S}var m=(E.prototype.getItem=function(e){return d.get(""+E.prefix+e)},E.prototype.removeItem=function(e){d.erase(""+E.prefix+e)},E.prototype.setItem=function(e,t){d.set(""+E.prefix+e,t)},E.prefix="coveo_",E);function E(){}var w=(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:w,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 A(t){return[function(e){return z.test(e)},function(e){return Y.test(e)},function(e){return-1!==U.indexOf(e)},function(e){return"custom"===e}].some(function(e){return e(t)})}var T=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}),O=function(e){var t=new x,r={name:"PageView",value:e,time:JSON.stringify(new Date)};t.addElement(r)},R=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,R)},L=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},F={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",price:"pr",quantity:"qt",coupon:"cc",position:"ps"},V={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"}),q=Object.keys,N=function(o,i,s){return q(o).reduce(function(e,t){var r,n="il"+(i+1)+"pi"+(s+1)+(V[t]||t);return h(h({},e),((r={})[n]=o[t],r))},{})},U=q(j).map(function(e){return j[e]}),_=q(F).map(function(e){return F[e]}),M=q(V).map(function(e){return V[e]}),B=a(_,["custom"]).join("|"),D=a(M,["custom"]).join("|"),H="(pr[0-9]+)",Q="(il[0-9]+pi[0-9]+)",z=new RegExp("^"+H+"("+B+")$"),Y=new RegExp("^("+Q+"("+D+"))|(il[0-9]+nm)$"),W=new RegExp("^"+H+"custom$"),J=new RegExp("^"+Q+"custom$"),$=function(n,o){return q(o).reduce(function(e,t){var r;return h(h({},e),((r={})[""+n+t]=o[t],r))},{})},G=(K.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]})})},K.prototype.encodeForEventType=function(e,t){return this.isEventTypeLegacy(e)?this.encodeForLegacyType(e,t):this.encodeForFormUrlEncoded(h({access_token:this.opts.token},t))},K.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:"","discardVisitInfo=true"].filter(function(e){return!!e}).join("&")},K.prototype.isEventTypeLegacy=function(e){return-1!==[n.click,n.custom,n.search,n.view].indexOf(e)},K.prototype.encodeForLegacyType=function(e,t){return e+"Event="+encodeURIComponent(JSON.stringify(t))},K.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("&")},K.prototype.encodeValue=function(e){return"number"==typeof e||"string"==typeof e||"boolean"==typeof e?e:JSON.stringify(e)},K);function K(e){this.opts=e}var X=(Z.prototype.sendEvent=function(e,t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,Promise.resolve()]})})},Z);function Z(){}var ee=function(e,t){c()&&l()?this.storage=new w:c()?this.storage=localStorage:(console.warn("BrowserRuntime detected no valid storage available.",this),this.storage=new S),this.beaconClient=new G(e),window.addEventListener("beforeunload",function(){return t()})},te=function(){this.storage=new S,this.beaconClient=new X},re=function(){this.storage=new S,this.beaconClient=new X},ne={default:"https://platform.cloud.coveo.com/rest/ua",production:"https://platform.cloud.coveo.com/rest/ua",hipaa:"https://platformhipaa.cloud.coveo.com/rest/ua"},oe=(Object.defineProperty(ie.prototype,"defaultOptions",{get:function(){return{endpoint:ne.default,token:"",version:"v15",beforeSendHooks:[]}},enumerable:!0,configurable:!0}),ie.prototype.initRuntime=function(e){var t=this;return"undefined"!=typeof window&&"undefined"!=typeof document?new ee(e,function(){return t.flushBufferWithBeacon()}):new te},Object.defineProperty(ie.prototype,"analyticsBeaconClient",{get:function(){return this.runtime.beaconClient},enumerable:!0,configurable:!0}),Object.defineProperty(ie.prototype,"storage",{get:function(){return this.runtime.storage},enumerable:!0,configurable:!0}),ie.prototype.initVisitorId=function(){var e=this.visitorId||this.storage.getItem("visitorId")||"";this.currentVisitorId=e||R()},Object.defineProperty(ie.prototype,"currentVisitorId",{get:function(){return this.visitorId},set:function(e){this.visitorId=e,this.storage.setItem("visitorId",e)},enumerable:!0,configurable:!0}),ie.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?q(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()]}})})},ie.prototype.deferExecution=function(){return new Promise(function(e){return setTimeout(e,0)})},ie.prototype.flushBufferWithBeacon=function(){for(;this.hasPendingRequests();){var e=this.bufferedRequests.pop(),t=e.eventType,r=e.payload;this.analyticsBeaconClient.sendEvent(t,r)}},ie.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]})})},ie.prototype.hasPendingRequests=function(){return 0<this.bufferedRequests.length},ie.prototype.clear=function(){this.storage.removeItem("visitorId"),(new x).clear()},ie.prototype.sendSearchEvent=function(t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,this.sendEvent(n.search,t)]})})},ie.prototype.sendClickEvent=function(t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,this.sendEvent(n.click,t)]})})},ie.prototype.sendCustomEvent=function(t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,this.sendEvent(n.custom,t)]})})},ie.prototype.sendViewEvent=function(t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,this.sendEvent(n.view,t)]})})},ie.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]}})})},ie.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()]}})})},ie.prototype.registerBeforeSendEventHook=function(e){this.beforeSendHooks.push(e)},ie.prototype.addEventTypeMapping=function(e,t){this.eventTypeMapping[e]=t},ie.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},ie.prototype.isKeyAllowedEmpty=function(e,t){var r;return-1!==((r={})[n.search]=["queryText"],(r[e]||[]).indexOf(t))},ie.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))},{})},ie.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))},{})},ie.prototype.processCustomParameters=function(e){var i,t=e.custom,r=s(e,["custom"]),n=q(i=r).reduce(function(e,t){var r,n=W.exec(t)||J.exec(t);if(n){var o=n[1];return h(h({},e),$(o,i[t]))}return h(h({},e),((r={})[t]=i[t],r))},{});return h(h({},t||{}),n)},ie.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},ie.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(ie.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}),ie);function ie(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=[function(e,t){return e===n.view?(O(t.contentIdValue),h({location:window.location.toString(),referrer:document.referrer,title:document.title},t)):t},function(e,t){return-1!==f.indexOf(e)?h({language:document.documentElement.lang,userAgent:navigator.userAgent},t):t}].concat(this.options.beforeSendHooks),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 se=Object.freeze({__proto__:null,Version:"v15",Endpoints:ne,CoveoAnalyticsClient:oe,default:oe}),ae=u()?[!0,"yes","1"].indexOf(navigator.doNotTrack||navigator.msDoNotTrack||window.doNotTrack):0,ue=Object.freeze({__proto__:null,doNotTrack:ae,default:ae}),ce=(le.prototype.register=function(e,t){this.plugins[e]=t},le.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)},le);function le(){this.plugins={}}function pe(e){return e.protocol+"//"+e.hostname+(0===e.pathname.indexOf("/")?e.pathname:"/"+e.pathname)+e.search}var fe={pageview:"pageview",event:"event"},de=Object.keys(fe).map(function(e){return fe[e]}),he=(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!==de.indexOf(e)?o.addECDataToPayload(e,n):n})},ge.prototype.addHooksForPageView=function(){this.client.addEventTypeMapping(fe.pageview,{newEventType:n.collect,variableLengthArgumentsNames:["page"],addVisitorIdParameter:!0,usesMeasurementProtocol:!0})},ge.prototype.addHooksForEvent=function(){this.client.addEventTypeMapping(fe.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,q(o=t).reduce(function(e,t){var r,n="pr"+(i+1)+(F[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),N(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=pe(window.location),this.hasSentFirstPageView=!0},ge.prototype.getLocationInformation=function(e,t){return e===fe.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?R:r;this.products=[],this.impressions=[],this.actionData={},this.client=t,this.uuidGenerator=n,this.pageViewId=n(),this.lastLocation=pe(window.location),this.lastReferrer=document.referrer,this.addHooksForPageView(),this.addHooksForEvent(),this.addHooksForECEvents()}var ve=(ye.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||ne.default,this.client=new oe({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 he({client:this.client})),this.client.registerBeforeSendEventHook(function(e,t){return h(h({},t),r.params)})},ye.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 oe({endpoint:e})},ye.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]})},ye.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))},ye.prototype.onLoad=function(e){if(void 0===e)throw new Error("You must pass a function when you call 'onLoad'");e()},ye.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))},ye.prototype.reset=function(){this.client=void 0,this.plugins=new ce,this.params={}},ye);function ye(){this.plugins=new ce,this.params={}}function me(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=Se[i];if(o&&i)return Se.callPlugin.apply(Se,a([o,i],t));if(s)return s.apply(Se,t);throw new Error('The action "'+e+'" does not exist. Available actions: '+["init","set","send","onLoad","callPlugin"].join(", ")+".")}var Ee,we,be,Se=new ve,Ie=Object.freeze({__proto__:null,CoveoUA:ve,coveoua:Se,handleOneAnalyticsEvent:me,default:me});(be=we=we||{}).interfaceLoad="interfaceLoad",be.interfaceChange="interfaceChange",be.didyoumeanAutomatic="didyoumeanAutomatic",be.didyoumeanClick="didyoumeanClick",be.resultsSort="resultsSort",be.searchboxSubmit="searchboxSubmit",be.searchboxClear="searchboxClear",be.searchboxAsYouType="searchboxAsYouType",be.breadcrumbFacet="breadcrumbFacet",be.breadcrumbResetAll="breadcrumbResetAll",be.documentQuickview="documentQuickview",be.documentOpen="documentOpen",be.omniboxAnalytics="omniboxAnalytics",be.omniboxFromLink="omniboxFromLink",be.triggerNotify="notify",be.triggerExecute="execute",be.triggerQuery="query",be.triggerRedirect="redirect",be.pagerResize="pagerResize",be.pagerNumber="pagerNumber",be.pagerNext="pagerNext",be.pagerPrevious="pagerPrevious",be.pagerScrolling="pagerScrolling",be.facetClearAll="facetClearAll",be.facetSearch="facetSearch",be.facetSelect="facetSelect",be.facetSelectAll="facetSelectAll",be.facetDeselect="facetDeselect",be.facetExclude="facetExclude",be.facetUnexclude="facetUnexclude",be.facetUpdateSort="facetUpdateSort",be.facetShowMore="showMoreFacetResults",be.facetShowLess="showLessFacetResults",be.queryError="query",be.queryErrorBack="errorBack",be.queryErrorClear="errorClearQuery",be.queryErrorRetry="errorRetry",be.recommendation="recommendation",be.recommendationInterfaceLoad="recommendationInterfaceLoad";var Ce=((Ee={})[we.triggerNotify]="queryPipelineTriggers",Ee[we.triggerExecute]="queryPipelineTriggers",Ee[we.triggerQuery]="queryPipelineTriggers",Ee[we.triggerRedirect]="queryPipelineTriggers",Ee[we.queryError]="errors",Ee[we.queryErrorBack]="errors",Ee[we.queryErrorClear]="errors",Ee[we.queryErrorRetry]="errors",Ee[we.pagerNext]="getMoreResults",Ee[we.pagerPrevious]="getMoreResults",Ee[we.pagerNumber]="getMoreResults",Ee[we.pagerResize]="getMoreResults",Ee[we.pagerScrolling]="getMoreResults",Ee[we.facetSearch]="facet",Ee[we.facetShowLess]="facet",Ee[we.facetShowMore]="facet",Ee[we.recommendation]="recommendation",Ee),Pe=(xe.prototype.sendEvent=function(){return Promise.resolve()},xe.prototype.sendSearchEvent=function(){return Promise.resolve()},xe.prototype.sendClickEvent=function(){return Promise.resolve()},xe.prototype.sendCustomEvent=function(){return Promise.resolve()},xe.prototype.sendViewEvent=function(){return Promise.resolve()},xe.prototype.getVisit=function(){return Promise.resolve({id:"",visitorId:""})},xe.prototype.getHealth=function(){return Promise.resolve({status:""})},xe.prototype.registerBeforeSendEventHook=function(){},xe.prototype.addEventTypeMapping=function(){},xe);function xe(){this.runtime=new re,this.currentVisitorId=""}function ke(e){var r,t=e.map(function(e){return e.replace(/;/g,"")});return function e(t){var r=t.join(";");return r.length<=256?r:e(t.slice(1))}((r="",t.filter(function(e){var t=e!==r;return r=e,t})))}function Ae(e){var t="string"==typeof e.partialQueries?e.partialQueries:ke(e.partialQueries),r="string"==typeof e.suggestions?e.suggestions:ke(e.suggestions);return h(h({},e),{partialQueries:t,suggestions:r})}var Te=(Oe.prototype.disable=function(){this.coveoAnalyticsClient instanceof oe&&this.coveoAnalyticsClient.clear(),this.coveoAnalyticsClient=new Pe},Oe.prototype.enable=function(){this.coveoAnalyticsClient=new oe(this.opts)},Oe.prototype.logInterfaceLoad=function(){return this.logSearchEvent(we.interfaceLoad)},Oe.prototype.logRecommendationInterfaceLoad=function(){return this.logSearchEvent(we.recommendationInterfaceLoad)},Oe.prototype.logRecommendation=function(){return this.logCustomEvent(we.recommendation)},Oe.prototype.logFetchMoreResults=function(){return this.logCustomEvent(we.pagerScrolling,{type:"getMoreResults"})},Oe.prototype.logInterfaceChange=function(e){return this.logSearchEvent(we.interfaceChange,e)},Oe.prototype.logDidYouMeanAutomatic=function(){return this.logSearchEvent(we.didyoumeanAutomatic)},Oe.prototype.logDidYouMeanClick=function(){return this.logSearchEvent(we.didyoumeanClick)},Oe.prototype.logResultsSort=function(e){return this.logSearchEvent(we.resultsSort,e)},Oe.prototype.logSearchboxSubmit=function(){return this.logSearchEvent(we.searchboxSubmit)},Oe.prototype.logSearchboxClear=function(){return this.logSearchEvent(we.searchboxClear)},Oe.prototype.logSearchboxAsYouType=function(){return this.logSearchEvent(we.searchboxAsYouType)},Oe.prototype.logBreadcrumbFacet=function(e){return this.logSearchEvent(we.breadcrumbFacet,e)},Oe.prototype.logBreadcrumbResetAll=function(){return this.logSearchEvent(we.breadcrumbResetAll)},Oe.prototype.logDocumentQuickview=function(e,t){return this.logClickEvent(we.documentQuickview,e,t)},Oe.prototype.logDocumentOpen=function(e,t){return this.logClickEvent(we.documentOpen,e,t)},Oe.prototype.logOmniboxAnalytics=function(e){return this.logSearchEvent(we.omniboxAnalytics,Ae(e))},Oe.prototype.logOmniboxFromLink=function(e){return this.logSearchEvent(we.omniboxFromLink,Ae(e))},Oe.prototype.logTriggerNotify=function(e){return this.logCustomEvent(we.triggerNotify,e)},Oe.prototype.logTriggerExecute=function(e){return this.logCustomEvent(we.triggerExecute,e)},Oe.prototype.logTriggerQuery=function(){var e={query:this.provider.getSearchEventRequestPayload().queryText};return this.logCustomEvent(we.triggerQuery,e)},Oe.prototype.logTriggerRedirect=function(e){var t=h(h({},e),{query:this.provider.getSearchEventRequestPayload().queryText});return this.logCustomEvent(we.triggerRedirect,t)},Oe.prototype.logPagerResize=function(e){return this.logCustomEvent(we.pagerResize,e)},Oe.prototype.logPagerNumber=function(e){return this.logCustomEvent(we.pagerNumber,e)},Oe.prototype.logPagerNext=function(e){return this.logCustomEvent(we.pagerNext,e)},Oe.prototype.logPagerPrevious=function(e){return this.logCustomEvent(we.pagerPrevious,e)},Oe.prototype.logPagerScrolling=function(){return this.logCustomEvent(we.pagerScrolling)},Oe.prototype.logFacetClearAll=function(e){return this.logSearchEvent(we.facetClearAll,e)},Oe.prototype.logFacetSearch=function(e){return this.logSearchEvent(we.facetSearch,e)},Oe.prototype.logFacetSelect=function(e){return this.logSearchEvent(we.facetSelect,e)},Oe.prototype.logFacetDeselect=function(e){return this.logSearchEvent(we.facetDeselect,e)},Oe.prototype.logFacetExclude=function(e){return this.logSearchEvent(we.facetExclude,e)},Oe.prototype.logFacetUnexclude=function(e){return this.logSearchEvent(we.facetUnexclude,e)},Oe.prototype.logFacetSelectAll=function(e){return this.logSearchEvent(we.facetSelectAll,e)},Oe.prototype.logFacetUpdateSort=function(e){return this.logSearchEvent(we.facetUpdateSort,e)},Oe.prototype.logFacetShowMore=function(e){return this.logCustomEvent(we.facetShowMore,e)},Oe.prototype.logFacetShowLess=function(e){return this.logCustomEvent(we.facetShowLess,e)},Oe.prototype.logQueryError=function(e){return this.logCustomEvent(we.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(we.queryErrorBack)];case 1:return e.sent(),[2,this.logSearchEvent(we.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(we.queryErrorRetry)];case 1:return e.sent(),[2,this.logSearchEvent(we.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(we.queryErrorClear)];case 1:return e.sent(),[2,this.logSearchEvent(we.queryErrorClear)]}})})},Oe.prototype.logCustomEvent=function(e,t){var r=h(h({},this.provider.getBaseMetadata()),t),n=h(h({},this.getOrigins()),{eventType:Ce[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 Pe:new oe(e)}e.CoveoAnalyticsClient=oe,e.CoveoSearchPageClient=Te,e.CoveoUA=ve,e.SimpleAnalytics=Ie,e.analytics=se,e.donottrack=ue,e.handleOneAnalyticsEvent=me,e.history=T,e.storage=C,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,c){return new(a=a||Promise)(function(r,t){function n(e){try{i(c.next(e))}catch(e){t(e)}}function o(e){try{i(c.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((c=c.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,c){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(c),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,c),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 c(){return"undefined"!=typeof navigator}function u(){return"undefined"!=typeof localStorage}function l(){return c()&&navigator.cookieEnabled}function p(){return"undefined"!=typeof crypto&&void 0!==crypto.getRandomValues}var d=[n.click,n.custom,n.search,n.view],f=(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:l()?new m:"undefined"!=typeof sessionStorage?sessionStorage:new S}var m=(w.prototype.getItem=function(e){return f.get(""+w.prefix+e)},w.prototype.removeItem=function(e){f.erase(""+w.prefix+e)},w.prototype.setItem=function(e,t){f.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}),k="__coveo.analytics.history",P=(x.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])},x.prototype.getHistory=function(){var e=this.getHistoryWithInternalTime();return this.stripInternalTime(e)},x.prototype.getHistoryWithInternalTime=function(){try{var e=this.store.getItem(k);return e?JSON.parse(e):[]}catch(e){return[]}},x.prototype.setHistory=function(e){try{this.store.setItem(k,JSON.stringify(e.slice(0,20)))}catch(e){}},x.prototype.clear=function(){try{this.store.removeItem(k)}catch(e){}},x.prototype.getMostRecentElement=function(){var e=this.getHistoryWithInternalTime();return null==e?null:e.sort(function(e,t){return(t.internalTime||0)-(e.internalTime||0)})[0]},x.prototype.cropQueryElement=function(e){e.name&&"query"==e.name.toLowerCase()&&null!=e.value&&(e.value=e.value.slice(0,75))},x.prototype.isValidEntry=function(e){var t=this.getMostRecentElement();return!t||t.value!=e.value||6e4<(e.internalTime||0)-(t.internalTime||0)},x.prototype.stripInternalTime=function(e){return e.map(function(e){return{name:e.name,time:e.time,value:e.value}})},x);function x(e){this.store=e||y()}function A(t){return[function(e){return G.test(e)},function(e){return D.test(e)},function(e){return $.test(e)},function(e){return-1!==U.indexOf(e)},function(e){return"custom"===e}].some(function(e){return e(t)})}var T=Object.freeze({__proto__:null,STORE_KEY:k,MAX_NUMBER_OF_HISTORY_ELEMENTS:20,MIN_THRESHOLD_FOR_DUPLICATE_VALUE:6e4,MAX_VALUE_SIZE:75,HistoryStore:P,default:P}),O=function(e){var t=new P,r={name:"PageView",value:e,time:JSON.stringify(new Date)};t.addElement(r)},R=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,R)},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},L=Object.keys,F={id:"svc_ticket_id",subject:"svc_ticket_subject",description:"svc_ticket_description",category:"svc_ticket_category",productId:"svc_ticket_product_id",custom:"svc_ticket_custom"},_=a(L(F).map(function(e){return F[e]})).join("|"),D=new RegExp("^("+_+"$)"),j={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",price:"pr",quantity:"qt",coupon:"cc",position:"ps"},N={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",position:"ps",price:"pr"},M=h(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"}),{svcAction:"svc_action",svcActionData:"svc_action_data"}),q=function(o,i,s,a){return L(o).reduce(function(e,t){var r,n="il"+(i+1)+a+(s+1)+(N[t]||t);return h(h({},e),((r={})[n]=o[t],r))},{})},U=L(M).map(function(e){return M[e]}),H=L(j).map(function(e){return j[e]}),B=L(N).map(function(e){return N[e]}),Q=a(H,["custom"]).join("|"),z=a(B,["custom"]).join("|"),Y="(pr[0-9]+)",W="(il[0-9]+pi[0-9]+)",G=new RegExp("^"+Y+"("+Q+")$"),$=new RegExp("^("+W+"("+z+"))|(il[0-9]+nm)$"),J=new RegExp("^"+Y+"custom$"),K=new RegExp("^"+W+"custom$"),X=function(n,o){return L(o).reduce(function(e,t){var r;return h(h({},e),((r={})[""+n+t]=o[t],r))},{})},Z=(ee.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]})})},ee.prototype.encodeForEventType=function(e,t){return this.isEventTypeLegacy(e)?this.encodeForLegacyType(e,t):this.encodeForFormUrlEncoded(h({access_token:this.opts.token},t))},ee.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:"","discardVisitInfo=true"].filter(function(e){return!!e}).join("&")},ee.prototype.isEventTypeLegacy=function(e){return-1!==[n.click,n.custom,n.search,n.view].indexOf(e)},ee.prototype.encodeForLegacyType=function(e,t){return e+"Event="+encodeURIComponent(JSON.stringify(t))},ee.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("&")},ee.prototype.encodeValue=function(e){return"number"==typeof e||"string"==typeof e||"boolean"==typeof e?e:JSON.stringify(e)},ee);function ee(e){this.opts=e}var te=(re.prototype.sendEvent=function(e,t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,Promise.resolve()]})})},re);function re(){}var ne=function(e,t){u()&&l()?this.storage=new E:u()?this.storage=localStorage:(console.warn("BrowserRuntime detected no valid storage available.",this),this.storage=new S),this.beaconClient=new Z(e),window.addEventListener("beforeunload",function(){return t()})},oe=function(){this.storage=new S,this.beaconClient=new te},ie=function(){this.storage=new S,this.beaconClient=new te},se={default:"https://platform.cloud.coveo.com/rest/ua",production:"https://platform.cloud.coveo.com/rest/ua",hipaa:"https://platformhipaa.cloud.coveo.com/rest/ua"},ae=(Object.defineProperty(ce.prototype,"defaultOptions",{get:function(){return{endpoint:se.default,token:"",version:"v15",beforeSendHooks:[]}},enumerable:!0,configurable:!0}),ce.prototype.initRuntime=function(e){var t=this;return"undefined"!=typeof window&&"undefined"!=typeof document?new ne(e,function(){return t.flushBufferWithBeacon()}):new oe},Object.defineProperty(ce.prototype,"analyticsBeaconClient",{get:function(){return this.runtime.beaconClient},enumerable:!0,configurable:!0}),Object.defineProperty(ce.prototype,"storage",{get:function(){return this.runtime.storage},enumerable:!0,configurable:!0}),ce.prototype.initVisitorId=function(){var e=this.visitorId||this.storage.getItem("visitorId")||"";this.currentVisitorId=e||R()},Object.defineProperty(ce.prototype,"currentVisitorId",{get:function(){return this.visitorId},set:function(e){this.visitorId=e,this.storage.setItem("visitorId",e)},enumerable:!0,configurable:!0}),ce.prototype.sendEvent=function(d){for(var f=[],e=1;e<arguments.length;e++)f[e-1]=arguments[e];return r(this,void 0,void 0,function(){var t,r,n,o,i,s,a,c,u,l,p=this;return g(this,function(e){switch(e.label){case 0:return t=this.eventTypeMapping[d]||{},n=void 0===(r=t.newEventType)?d:r,i=void 0===(o=t.variableLengthArgumentsNames)?[]:o,a=void 0!==(s=t.addVisitorIdParameter)&&s,u=void 0!==(c=t.usesMeasurementProtocol)&&c,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 u?p.ensureAnonymousUserWhenUsingApiKey(e):e},function(e){return p.beforeSendHooks.reduce(function(e,t){return t(d,e)},e)},function(e){return p.removeEmptyPayloadValues(e,d)},function(e){return p.validateParams(e)},function(e){return u?L(o=e).reduce(function(e,t){var r,n=M[t]||t;return h(h({},e),((r={})[n]=o[t],r))},{}):e;var o},function(e){return u?p.removeUnknownParameters(e):e},function(e){return u?p.processCustomParameters(e):e}].reduce(function(e,t){return t(e)},f),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()]}})})},ce.prototype.deferExecution=function(){return new Promise(function(e){return setTimeout(e,0)})},ce.prototype.flushBufferWithBeacon=function(){for(;this.hasPendingRequests();){var e=this.bufferedRequests.pop(),t=e.eventType,r=e.payload;this.analyticsBeaconClient.sendEvent(t,r)}},ce.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]})})},ce.prototype.hasPendingRequests=function(){return 0<this.bufferedRequests.length},ce.prototype.clear=function(){this.storage.removeItem("visitorId"),(new P).clear()},ce.prototype.sendSearchEvent=function(t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,this.sendEvent(n.search,t)]})})},ce.prototype.sendClickEvent=function(t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,this.sendEvent(n.click,t)]})})},ce.prototype.sendCustomEvent=function(t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,this.sendEvent(n.custom,t)]})})},ce.prototype.sendViewEvent=function(t){return r(this,void 0,void 0,function(){return g(this,function(e){return[2,this.sendEvent(n.view,t)]})})},ce.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]}})})},ce.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()]}})})},ce.prototype.registerBeforeSendEventHook=function(e){this.beforeSendHooks.push(e)},ce.prototype.addEventTypeMapping=function(e,t){this.eventTypeMapping[e]=t},ce.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},ce.prototype.isKeyAllowedEmpty=function(e,t){var r;return-1!==((r={})[n.search]=["queryText"],(r[e]||[]).indexOf(t))},ce.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))},{})},ce.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))},{})},ce.prototype.processCustomParameters=function(e){var i,t=e.custom,r=s(e,["custom"]),n=this.lowercaseKeys(t),o=L(i=r).reduce(function(e,t){var r,n=J.exec(t)||K.exec(t);if(n){var o=n[1];return h(h({},e),X(o,i[t]))}return h(h({},e),((r={})[t]=i[t],r))},{});return h(h({},n),o)},ce.prototype.lowercaseKeys=function(n){return Object.keys(n||{}).reduce(function(e,t){var r;return h(h({},e),((r={})[t.toLowerCase()]=n[t],r))},{})},ce.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},ce.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(ce.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}),ce);function ce(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=[function(e,t){return e===n.view?(O(t.contentIdValue),h({location:window.location.toString(),referrer:document.referrer,title:document.title},t)):t},function(e,t){return-1!==d.indexOf(e)?h({language:document.documentElement.lang,userAgent:navigator.userAgent},t):t}].concat(this.options.beforeSendHooks),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:se,CoveoAnalyticsClient:ae,default:ae}),le=c()?[!0,"yes","1"].indexOf(navigator.doNotTrack||navigator.msDoNotTrack||window.doNotTrack):0,pe=Object.freeze({__proto__:null,doNotTrack:le,default:le}),de=(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 ge={pageview:"pageview",event:"event"},ve=Object.keys(ge).map(function(e){return ge[e]}),ye=(me.prototype.addProduct=function(e){this.products.push(e)},me.prototype.addImpression=function(e){this.impressions.push(e)},me.prototype.setAction=function(e,t){this.action=e,this.actionData=t},me.prototype.clearData=function(){this.products=[],this.impressions=[],this.action=void 0,this.actionData={}},me.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!==ve.indexOf(e)?o.addECDataToPayload(e,n):n})},me.prototype.addHooksForPageView=function(){this.client.addEventTypeMapping(ge.pageview,{newEventType:n.collect,variableLengthArgumentsNames:["page"],addVisitorIdParameter:!0,usesMeasurementProtocol:!0})},me.prototype.addHooksForEvent=function(){this.client.addEventTypeMapping(ge.event,{newEventType:n.collect,variableLengthArgumentsNames:["eventCategory","eventAction","eventLabel","eventValue"],addVisitorIdParameter:!0,usesMeasurementProtocol:!0})},me.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)},me.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,L(o=t).reduce(function(e,t){var r,n="pr"+(i+1)+(j[t]||t);return h(h({},e),((r={})[n]=o[t],r))},{})));var o,i},{})},me.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,o){var t=e.impressions.reduce(function(e,t,r){return h(h({},e),q(t,n,r,o))},{});return e.listName&&(t["il"+(n+1)+"nm"]=e.listName),t}(t,r,"pi"))},{})},me.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},me.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},me.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},[])},me.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},me.prototype.getLocationInformation=function(e,t){return e===ge.pageview&&this.updateStateForNewPageView(t),{referrer:this.lastReferrer,location:this.lastLocation}},me.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)},me);function me(e){var t=e.client,r=e.uuidGenerator,n=void 0===r?R: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 we={pageview:"pageview",event:"event"},Ee=Object.keys(we).map(function(e){return we[e]}),be=(Se.prototype.setTicket=function(e){this.ticket=e},Se.prototype.addImpression=function(e){this.impressions.push(e)},Se.prototype.setAction=function(e,t){this.action=e,this.actionData=t},Se.prototype.clearData=function(){this.ticket={},this.impressions=[],this.action=void 0,this.actionData={}},Se.prototype.addHooksForSVCEvents=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!==Ee.indexOf(e)?o.addSVCDataToPayload(e,n):n})},Se.prototype.addHooksForPageView=function(){this.client.addEventTypeMapping(we.pageview,{newEventType:n.collect,variableLengthArgumentsNames:["page"],addVisitorIdParameter:!0,usesMeasurementProtocol:!0})},Se.prototype.addHooksForEvent=function(){this.client.addEventTypeMapping(we.event,{newEventType:n.collect,variableLengthArgumentsNames:["eventCategory","eventAction","eventLabel","eventValue"],addVisitorIdParameter:!0,usesMeasurementProtocol:!0})},Se.prototype.addSVCDataToPayload=function(e,t){var r,n=h(h(h(h({},this.getLocationInformation(e,t)),this.getDefaultContextInformation(e)),this.action?{svcAction:this.action}:{}),0<Object.keys(null!==(r=this.actionData)&&void 0!==r?r:{}).length?{svcActionData:this.actionData}:{}),o=this.getTicketPayload();return this.clearData(),h(h(h({},o),n),t)},Se.prototype.getTicketPayload=function(){return o=this.ticket,L(o).filter(function(e){return void 0!==o[e]}).reduce(function(e,t){var r,n=F[t]||t;return h(h({},e),((r={})[n]=o[t],r))},{});var o},Se.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},Se.prototype.getLocationInformation=function(e,t){return e===we.pageview&&this.updateStateForNewPageView(t),{referrer:this.lastReferrer,location:this.lastLocation}},Se.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)},Se);function Se(e){var t=e.client,r=e.uuidGenerator,n=void 0===r?R:r;this.ticket={},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.addHooksForSVCEvents()}var Ie=(Ce.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||se.default,this.client=new ae({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 ye({client:this.client})),this.plugins.register("svc",new be({client:this.client})),this.client.registerBeforeSendEventHook(function(e,t){return h(h({},t),r.params)})},Ce.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 ae({endpoint:e})},Ce.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]})},Ce.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))},Ce.prototype.onLoad=function(e){if(void 0===e)throw new Error("You must pass a function when you call 'onLoad'");e()},Ce.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))},Ce.prototype.reset=function(){this.client=void 0,this.plugins=new de,this.params={}},Ce);function Ce(){this.plugins=new de,this.params={}}function ke(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=Te[i];if(o&&i)return Te.callPlugin.apply(Te,a([o,i],t));if(s)return s.apply(Te,t);throw new Error('The action "'+e+'" does not exist. Available actions: '+["init","set","send","onLoad","callPlugin"].join(", ")+".")}var Pe,xe,Ae,Te=new Ie,Oe=Object.freeze({__proto__:null,CoveoUA:Ie,coveoua:Te,handleOneAnalyticsEvent:ke,default:ke});(Ae=xe=xe||{}).interfaceLoad="interfaceLoad",Ae.interfaceChange="interfaceChange",Ae.didyoumeanAutomatic="didyoumeanAutomatic",Ae.didyoumeanClick="didyoumeanClick",Ae.resultsSort="resultsSort",Ae.searchboxSubmit="searchboxSubmit",Ae.searchboxClear="searchboxClear",Ae.searchboxAsYouType="searchboxAsYouType",Ae.breadcrumbFacet="breadcrumbFacet",Ae.breadcrumbResetAll="breadcrumbResetAll",Ae.documentQuickview="documentQuickview",Ae.documentOpen="documentOpen",Ae.omniboxAnalytics="omniboxAnalytics",Ae.omniboxFromLink="omniboxFromLink",Ae.triggerNotify="notify",Ae.triggerExecute="execute",Ae.triggerQuery="query",Ae.triggerRedirect="redirect",Ae.pagerResize="pagerResize",Ae.pagerNumber="pagerNumber",Ae.pagerNext="pagerNext",Ae.pagerPrevious="pagerPrevious",Ae.pagerScrolling="pagerScrolling",Ae.facetClearAll="facetClearAll",Ae.facetSearch="facetSearch",Ae.facetSelect="facetSelect",Ae.facetSelectAll="facetSelectAll",Ae.facetDeselect="facetDeselect",Ae.facetExclude="facetExclude",Ae.facetUnexclude="facetUnexclude",Ae.facetUpdateSort="facetUpdateSort",Ae.facetShowMore="showMoreFacetResults",Ae.facetShowLess="showLessFacetResults",Ae.queryError="query",Ae.queryErrorBack="errorBack",Ae.queryErrorClear="errorClearQuery",Ae.queryErrorRetry="errorRetry",Ae.recommendation="recommendation",Ae.recommendationInterfaceLoad="recommendationInterfaceLoad";var Re=((Pe={})[xe.triggerNotify]="queryPipelineTriggers",Pe[xe.triggerExecute]="queryPipelineTriggers",Pe[xe.triggerQuery]="queryPipelineTriggers",Pe[xe.triggerRedirect]="queryPipelineTriggers",Pe[xe.queryError]="errors",Pe[xe.queryErrorBack]="errors",Pe[xe.queryErrorClear]="errors",Pe[xe.queryErrorRetry]="errors",Pe[xe.pagerNext]="getMoreResults",Pe[xe.pagerPrevious]="getMoreResults",Pe[xe.pagerNumber]="getMoreResults",Pe[xe.pagerResize]="getMoreResults",Pe[xe.pagerScrolling]="getMoreResults",Pe[xe.facetSearch]="facet",Pe[xe.facetShowLess]="facet",Pe[xe.facetShowMore]="facet",Pe[xe.recommendation]="recommendation",Pe),Ve=(Le.prototype.sendEvent=function(){return Promise.resolve()},Le.prototype.sendSearchEvent=function(){return Promise.resolve()},Le.prototype.sendClickEvent=function(){return Promise.resolve()},Le.prototype.sendCustomEvent=function(){return Promise.resolve()},Le.prototype.sendViewEvent=function(){return Promise.resolve()},Le.prototype.getVisit=function(){return Promise.resolve({id:"",visitorId:""})},Le.prototype.getHealth=function(){return Promise.resolve({status:""})},Le.prototype.registerBeforeSendEventHook=function(){},Le.prototype.addEventTypeMapping=function(){},Le);function Le(){this.runtime=new ie,this.currentVisitorId=""}function Fe(e){var r,t=e.map(function(e){return e.replace(/;/g,"")});return function e(t){var r=t.join(";");return r.length<=256?r:e(t.slice(1))}((r="",t.filter(function(e){var t=e!==r;return r=e,t})))}function _e(e){var t="string"==typeof e.partialQueries?e.partialQueries:Fe(e.partialQueries),r="string"==typeof e.suggestions?e.suggestions:Fe(e.suggestions);return h(h({},e),{partialQueries:t,suggestions:r})}var De=(je.prototype.disable=function(){this.coveoAnalyticsClient instanceof ae&&this.coveoAnalyticsClient.clear(),this.coveoAnalyticsClient=new Ve},je.prototype.enable=function(){this.coveoAnalyticsClient=new ae(this.opts)},je.prototype.logInterfaceLoad=function(){return this.logSearchEvent(xe.interfaceLoad)},je.prototype.logRecommendationInterfaceLoad=function(){return this.logSearchEvent(xe.recommendationInterfaceLoad)},je.prototype.logRecommendation=function(){return this.logCustomEvent(xe.recommendation)},je.prototype.logFetchMoreResults=function(){return this.logCustomEvent(xe.pagerScrolling,{type:"getMoreResults"})},je.prototype.logInterfaceChange=function(e){return this.logSearchEvent(xe.interfaceChange,e)},je.prototype.logDidYouMeanAutomatic=function(){return this.logSearchEvent(xe.didyoumeanAutomatic)},je.prototype.logDidYouMeanClick=function(){return this.logSearchEvent(xe.didyoumeanClick)},je.prototype.logResultsSort=function(e){return this.logSearchEvent(xe.resultsSort,e)},je.prototype.logSearchboxSubmit=function(){return this.logSearchEvent(xe.searchboxSubmit)},je.prototype.logSearchboxClear=function(){return this.logSearchEvent(xe.searchboxClear)},je.prototype.logSearchboxAsYouType=function(){return this.logSearchEvent(xe.searchboxAsYouType)},je.prototype.logBreadcrumbFacet=function(e){return this.logSearchEvent(xe.breadcrumbFacet,e)},je.prototype.logBreadcrumbResetAll=function(){return this.logSearchEvent(xe.breadcrumbResetAll)},je.prototype.logDocumentQuickview=function(e,t){return this.logClickEvent(xe.documentQuickview,e,t)},je.prototype.logDocumentOpen=function(e,t){return this.logClickEvent(xe.documentOpen,e,t)},je.prototype.logOmniboxAnalytics=function(e){return this.logSearchEvent(xe.omniboxAnalytics,_e(e))},je.prototype.logOmniboxFromLink=function(e){return this.logSearchEvent(xe.omniboxFromLink,_e(e))},je.prototype.logTriggerNotify=function(e){return this.logCustomEvent(xe.triggerNotify,e)},je.prototype.logTriggerExecute=function(e){return this.logCustomEvent(xe.triggerExecute,e)},je.prototype.logTriggerQuery=function(){var e={query:this.provider.getSearchEventRequestPayload().queryText};return this.logCustomEvent(xe.triggerQuery,e)},je.prototype.logTriggerRedirect=function(e){var t=h(h({},e),{query:this.provider.getSearchEventRequestPayload().queryText});return this.logCustomEvent(xe.triggerRedirect,t)},je.prototype.logPagerResize=function(e){return this.logCustomEvent(xe.pagerResize,e)},je.prototype.logPagerNumber=function(e){return this.logCustomEvent(xe.pagerNumber,e)},je.prototype.logPagerNext=function(e){return this.logCustomEvent(xe.pagerNext,e)},je.prototype.logPagerPrevious=function(e){return this.logCustomEvent(xe.pagerPrevious,e)},je.prototype.logPagerScrolling=function(){return this.logCustomEvent(xe.pagerScrolling)},je.prototype.logFacetClearAll=function(e){return this.logSearchEvent(xe.facetClearAll,e)},je.prototype.logFacetSearch=function(e){return this.logSearchEvent(xe.facetSearch,e)},je.prototype.logFacetSelect=function(e){return this.logSearchEvent(xe.facetSelect,e)},je.prototype.logFacetDeselect=function(e){return this.logSearchEvent(xe.facetDeselect,e)},je.prototype.logFacetExclude=function(e){return this.logSearchEvent(xe.facetExclude,e)},je.prototype.logFacetUnexclude=function(e){return this.logSearchEvent(xe.facetUnexclude,e)},je.prototype.logFacetSelectAll=function(e){return this.logSearchEvent(xe.facetSelectAll,e)},je.prototype.logFacetUpdateSort=function(e){return this.logSearchEvent(xe.facetUpdateSort,e)},je.prototype.logFacetShowMore=function(e){return this.logCustomEvent(xe.facetShowMore,e)},je.prototype.logFacetShowLess=function(e){return this.logCustomEvent(xe.facetShowLess,e)},je.prototype.logQueryError=function(e){return this.logCustomEvent(xe.queryError,e)},je.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(xe.queryErrorBack)];case 1:return e.sent(),[2,this.logSearchEvent(xe.queryErrorBack)]}})})},je.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(xe.queryErrorRetry)];case 1:return e.sent(),[2,this.logSearchEvent(xe.queryErrorRetry)]}})})},je.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(xe.queryErrorClear)];case 1:return e.sent(),[2,this.logSearchEvent(xe.queryErrorClear)]}})})},je.prototype.logCustomEvent=function(e,t){var r=h(h({},this.provider.getBaseMetadata()),t),n=h(h({},this.getOrigins()),{eventType:Re[e],eventValue:e,lastSearchQueryUid:this.provider.getSearchUID(),customData:r});return this.coveoAnalyticsClient.sendCustomEvent(n)},je.prototype.logCustomEventWithType=function(e,t,r){var n=h(h({},this.provider.getBaseMetadata()),r),o=h(h({},this.getOrigins()),{eventType:t,eventValue:e,lastSearchQueryUid:this.provider.getSearchUID(),customData:n});return this.coveoAnalyticsClient.sendCustomEvent(o)},je.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)},je.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)},je.prototype.getOrigins=function(){return{originLevel1:this.provider.getOriginLevel1(),originLevel2:this.provider.getOriginLevel2(),originLevel3:this.provider.getOriginLevel3()}},je);function je(e,t){this.opts=e,this.provider=t,this.coveoAnalyticsClient=!1===e.enableAnalytics?new Ve:new ae(e)}e.CoveoAnalyticsClient=ae,e.CoveoSearchPageClient=De,e.CoveoUA=Ie,e.SimpleAnalytics=Oe,e.analytics=ue,e.donottrack=pe,e.handleOneAnalyticsEvent=ke,e.history=T,e.storage=C,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=library.js.map |
{ | ||
"name": "coveo.analytics", | ||
"version": "2.13.0", | ||
"version": "2.14.0", | ||
"description": "📈 Coveo analytics client (node and browser compatible) ", | ||
@@ -5,0 +5,0 @@ "main": "dist/library.js", |
@@ -333,6 +333,8 @@ import {IAnalyticsBeaconClientOptions} from './analyticsBeaconClient'; | ||
const lowercasedCustom = this.lowercaseKeys(custom); | ||
const newPayload = convertCustomMeasurementProtocolKeys(rest); | ||
return { | ||
...(custom || {}), | ||
...lowercasedCustom, | ||
...newPayload, | ||
@@ -342,2 +344,14 @@ }; | ||
private lowercaseKeys(custom: any) { | ||
const keys = Object.keys(custom || {}); | ||
return keys.reduce( | ||
(all, key) => ({ | ||
...all, | ||
[key.toLowerCase()]: custom[key], | ||
}), | ||
{} | ||
); | ||
} | ||
private validateParams(payload: IRequestPayload): IRequestPayload { | ||
@@ -344,0 +358,0 @@ const {anonymizeIp, ...rest} = payload; |
import {EC, Product, ImpressionList, BaseImpression} from '../plugins/ec'; | ||
import {isTicketKey, svcActionsKeysMapping} from './coveoServiceMeasurementProtocolMapper'; | ||
import {keysOf} from './utils'; | ||
@@ -82,8 +84,5 @@ const globalParamKeysMapping: {[name: string]: string} = { | ||
...globalParamKeysMapping, | ||
...svcActionsKeysMapping, | ||
}; | ||
// Object.keys returns `string[]` this adds types | ||
// see https://github.com/microsoft/TypeScript/pull/12253#issuecomment-393954723 | ||
export const keysOf = Object.keys as <T>(o: T) => Extract<keyof T, string>[]; | ||
export const convertKeysToMeasurementProtocol = (params: any) => { | ||
@@ -109,3 +108,7 @@ return keysOf(params).reduce((mappedKeys, key) => { | ||
export const convertImpressionListToMeasurementProtocol = (impressionList: ImpressionList, listIndex: number) => { | ||
export const convertImpressionListToMeasurementProtocol = ( | ||
impressionList: ImpressionList, | ||
listIndex: number, | ||
prefix: string | ||
) => { | ||
const payload: {[name: string]: any} = impressionList.impressions.reduce( | ||
@@ -115,3 +118,3 @@ (mappedImpressions, impression, productIndex) => { | ||
...mappedImpressions, | ||
...convertImpressionToMeasurementProtocol(impression, listIndex, productIndex), | ||
...convertImpressionToMeasurementProtocol(impression, listIndex, productIndex, prefix), | ||
}; | ||
@@ -132,6 +135,7 @@ }, | ||
listIndex: number, | ||
productIndex: number | ||
productIndex: number, | ||
prefix: string | ||
) => { | ||
return keysOf(impression).reduce((mappedImpression, key) => { | ||
const newKey = `il${listIndex + 1}pi${productIndex + 1}${impressionKeysMapping[key] || key}`; | ||
const newKey = `il${listIndex + 1}${prefix}${productIndex + 1}${impressionKeysMapping[key] || key}`; | ||
return { | ||
@@ -165,3 +169,5 @@ ...mappedImpression, | ||
export const isMeasurementProtocolKey = (key: string): boolean => { | ||
return [isProductKey, isImpressionKey, isKnownMeasurementProtocolKey, isCustomKey].some((test) => test(key)); | ||
return [isProductKey, isTicketKey, isImpressionKey, isKnownMeasurementProtocolKey, isCustomKey].some((test) => | ||
test(key) | ||
); | ||
}; | ||
@@ -168,0 +174,0 @@ |
@@ -5,2 +5,3 @@ import {AnyEventResponse, SendEventArguments, VariableArgumentsPayload} from '../events'; | ||
import {EC} from '../plugins/ec'; | ||
import {SVC} from '../plugins/svc'; | ||
@@ -36,2 +37,3 @@ export type AvailableActions = keyof CoveoUA; | ||
this.plugins.register('ec', new EC({client: this.client})); | ||
this.plugins.register('svc', new SVC({client: this.client})); | ||
this.client.registerBeforeSendEventHook((eventType, payload) => ({ | ||
@@ -38,0 +40,0 @@ ...payload, |
@@ -178,3 +178,3 @@ import {AnalyticsClient} from '../client/analytics'; | ||
...newPayload, | ||
...convertImpressionListToMeasurementProtocol(impressionList, index), | ||
...convertImpressionListToMeasurementProtocol(impressionList, index, 'pi'), | ||
}; | ||
@@ -181,0 +181,0 @@ }, {}); |
@@ -100,2 +100,14 @@ import * as fetchMock from 'fetch-mock'; | ||
const expectMatchCustomEventWithTypePayload = (eventValue: string, eventType: string, meta = {}) => { | ||
const [, {body}] = fetchMock.lastCall(); | ||
const customData = {foo: 'bar', ...meta}; | ||
expect(JSON.parse(body.toString())).toMatchObject({ | ||
eventValue, | ||
eventType, | ||
lastSearchQueryUid: 'my-uid', | ||
customData, | ||
...expectOrigins(), | ||
}); | ||
}; | ||
it('should send proper payload for #interfaceLoad', async () => { | ||
@@ -383,2 +395,7 @@ await client.logInterfaceLoad(); | ||
it('should send proper payload for #logCustomEventWithType', async () => { | ||
await client.logCustomEventWithType('foo', 'bar', {buzz: 'bazz'}); | ||
expectMatchCustomEventWithTypePayload('foo', 'bar', {buzz: 'bazz'}); | ||
}); | ||
it('should enable analytics tracking by default', () => { | ||
@@ -385,0 +402,0 @@ const c = new CoveoSearchPageClient({}, provider); |
@@ -238,2 +238,15 @@ import CoveoAnalyticsClient, {ClientOptions, AnalyticsClient} from '../client/analytics'; | ||
public logCustomEventWithType(eventValue: string, eventType: string, metadata?: Record<string, any>) { | ||
const customData = {...this.provider.getBaseMetadata(), ...metadata}; | ||
const payload: CustomEventRequest = { | ||
...this.getOrigins(), | ||
eventType, | ||
eventValue, | ||
lastSearchQueryUid: this.provider.getSearchUID(), | ||
customData, | ||
}; | ||
return this.coveoAnalyticsClient.sendCustomEvent(payload); | ||
} | ||
public logSearchEvent(event: SearchPageEvents, metadata?: Record<string, any>) { | ||
@@ -240,0 +253,0 @@ const customData = {...this.provider.getBaseMetadata(), ...metadata}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
660688
80
5857