coveo.analytics
Advanced tools
Comparing version 2.0.1 to 2.1.0
@@ -1,2 +0,2 @@ | ||
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=18)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.search="search",e.click="click",e.custom="custom",e.view="view",e.collect="collect"}(t.EventType||(t.EventType={}))},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},a=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0});var s=n(9),u=n(10),c=n(0),l=n(2),p=n(3),f=n(12),d=n(13),h=n(6),v=n(7);t.Version="v15",t.Endpoints={default:"https://usageanalytics.coveo.com",production:"https://usageanalytics.coveo.com",hipaa:"https://usageanalyticshipaa.coveo.com"};var y=function(){function e(e){var t=this;if(!e)throw new Error("You have to pass options to this constructor");this.options=r(r({},this.defaultOptions),e);var n=this.options.token;this.cookieStorage=new l.CookieStorage,this.visitorId="",this.bufferedRequests=[],this.beforeSendHooks=[d.enhanceViewEvent,f.addDefaultValues],this.eventTypeMapping={},this.initVisitorId();var o={baseUrl:this.baseUrl,token:n,visitorIdProvider:this};this.analyticsBeaconClient=new s.AnalyticsBeaconClient(o),this.analyticsFetchClient=new u.AnalyticsFetchClient(o),window.addEventListener("beforeunload",(function(){return t.flushBufferWithBeacon()}))}return Object.defineProperty(e.prototype,"defaultOptions",{get:function(){return{endpoint:t.Endpoints.default,token:"",version:t.Version}},enumerable:!0,configurable:!0}),e.prototype.initVisitorId=function(){var e=this.visitorId||p.hasCookieStorage()&&this.cookieStorage.getItem("visitorId")||p.hasLocalStorage()&&localStorage.getItem("visitorId")||"";this.currentVisitorId=e||h.uuidv4()},Object.defineProperty(e.prototype,"currentVisitorId",{get:function(){return this.visitorId},set:function(e){this.visitorId=e,p.hasCookieStorage()&&this.cookieStorage.setItem("visitorId",e),p.hasLocalStorage()&&localStorage.setItem("visitorId",e)},enumerable:!0,configurable:!0}),e.prototype.sendEvent=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return o(this,void 0,void 0,(function(){var n,o,a,s,u,c,l,p,f,d,h=this;return i(this,(function(i){switch(i.label){case 0:return n=this.eventTypeMapping[e]||{},o=n.newEventType,a=void 0===o?e:o,s=n.variableLengthArgumentsNames,u=void 0===s?[]:s,c=n.addVisitorIdParameter,l=void 0!==c&&c,p=n.usesMeasurementProtocol,f=void 0!==p&&p,d=[function(e){return u.length>0?h.parseVariableArgumentsPayload(u,e):e[0]},function(e){return r({visitorId:l?h.visitorId:""},e)},function(t){return h.beforeSendHooks.reduce((function(t,n){return n(e,t)}),t)},function(e){return h.removeEmptyPayloadValues(e)},function(e){return h.validateParams(e)},function(e){return f?v.convertKeysToMeasurementProtocol(e):e},function(e){return f?h.removeUnknownParameters(e):e}].reduce((function(e,t){return t(e)}),t),this.bufferedRequests.push({eventType:a,payload:d,handled:!1}),[4,this.deferExecution()];case 1:return i.sent(),[4,this.sendFromBufferWithFetch()];case 2:return[2,i.sent()]}}))}))},e.prototype.deferExecution=function(){return new Promise((function(e){return setTimeout(e,0)}))},e.prototype.flushBufferWithBeacon=function(){for(;this.hasPendingRequests();){var e=this.bufferedRequests.pop(),t=e.eventType,n=e.payload;this.analyticsBeaconClient.sendEvent(t,n)}},e.prototype.sendFromBufferWithFetch=function(){return o(this,void 0,void 0,(function(){var e,t,n;return i(this,(function(r){return(e=this.bufferedRequests.shift())?(t=e.eventType,n=e.payload,[2,this.analyticsFetchClient.sendEvent(t,n)]):[2]}))}))},e.prototype.hasPendingRequests=function(){return this.bufferedRequests.length>0},e.prototype.sendSearchEvent=function(e){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.sendEvent(c.EventType.search,e)]}))}))},e.prototype.sendClickEvent=function(e){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.sendEvent(c.EventType.click,e)]}))}))},e.prototype.sendCustomEvent=function(e){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.sendEvent(c.EventType.custom,e)]}))}))},e.prototype.sendViewEvent=function(e){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.sendEvent(c.EventType.view,e)]}))}))},e.prototype.getVisit=function(){return o(this,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,fetch(this.baseUrl+"/analytics/visit")];case 1:return[4,t.sent().json()];case 2:return e=t.sent(),this.visitorId=e.visitorId,[2,e]}}))}))},e.prototype.getHealth=function(){return o(this,void 0,void 0,(function(){return i(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()]}}))}))},e.prototype.registerBeforeSendEventHook=function(e){this.beforeSendHooks.push(e)},e.prototype.addEventTypeMapping=function(e,t){this.eventTypeMapping[e]=t},e.prototype.parseVariableArgumentsPayload=function(e,t){for(var n={},o=0,i=t.length;o<i;o++){var a=t[o];if("string"==typeof a)n[e[o]]=a;else if("object"==typeof a)return r(r({},n),a)}return n},e.prototype.removeEmptyPayloadValues=function(e){return Object.keys(e).filter((function(t){return null!=(n=e[t])&&""!==n;var n})).reduce((function(t,n){var o;return r(r({},t),((o={})[n]=e[n],o))}),{})},e.prototype.removeUnknownParameters=function(e){return Object.keys(e).filter((function(e){if(v.isMeasurementProtocolKey(e))return!0;console.log(e,"is not processsed by coveoua")})).reduce((function(t,n){var o;return r(r({},t),((o={})[n]=e[n],o))}),{})},e.prototype.validateParams=function(e){var t=e.anonymizeIp,n=a(e,["anonymizeIp"]);return void 0!==t&&-1==["0","false","undefined","null","{}","[]",""].indexOf((""+t).toLowerCase())&&(n.anonymizeIp=1),n},Object.defineProperty(e.prototype,"baseUrl",{get:function(){var e=this.options,t=e.version;return e.endpoint+"/rest/"+t},enumerable:!0,configurable:!0}),e}();t.CoveoAnalyticsClient=y,t.default=y},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3),o=n(11);t.preferredStorage=null,t.getAvailableStorage=function(){return t.preferredStorage?t.preferredStorage:r.hasLocalStorage()?localStorage:r.hasCookieStorage()?new i:r.hasSessionStorage()?sessionStorage:new a};var i=function(){function e(){}return e.prototype.getItem=function(t){return o.Cookie.get(""+e.prefix+t)},e.prototype.removeItem=function(t){o.Cookie.erase(""+e.prefix+t)},e.prototype.setItem=function(t,n){o.Cookie.set(""+e.prefix+t,n)},e.prefix="coveo_",e}();t.CookieStorage=i;var a=function(){function e(){}return e.prototype.getItem=function(e){return null},e.prototype.removeItem=function(e){},e.prototype.setItem=function(e,t){},e}();t.NullStorage=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hasLocalStorage=function(){try{return"localStorage"in window&&null!==window.localStorage}catch(e){return!1}},t.hasSessionStorage=function(){try{return"sessionStorage"in window&&null!==window.sessionStorage}catch(e){return!1}},t.hasCookieStorage=function(){return navigator.cookieEnabled}},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},o=this&&this.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,o++)r[o]=i[a];return r};Object.defineProperty(t,"__esModule",{value:!0});var i=n(1),a=n(15),s=n(16),u=function(){function e(){this.plugins=new a.Plugins,this.params={}}return e.prototype.init=function(e,t){var n=this;if(!e)throw new Error("You must pass your token when you call 'init'");if("string"==typeof e?(t=t||i.Endpoints.default,this.client=new i.CoveoAnalyticsClient({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 s.EC({client:this.client})),this.client.registerBeforeSendEventHook((function(e,t){return r(r({},t),n.params)}))},e.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 i.CoveoAnalyticsClient({endpoint:e})},e.prototype.set=function(e,t){var n=this;"string"==typeof e?this.params[e]=t:Object.keys(e).map((function(t){n.params[t]=e[t]}))},e.prototype.send=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=t[0],i=t.slice(1);if(void 0===this.client)throw new Error("You must call init before sending an event");if(!r)throw new Error('You must provide an event type when calling "send".');return(e=this.client).sendEvent.apply(e,o([r.toLowerCase()],i))},e.prototype.onLoad=function(e){if(void 0===e)throw new Error("You must pass a function when you call 'onLoad'");e()},e.prototype.callPlugin=function(e,t){for(var n,r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];(n=this.plugins).execute.apply(n,o([e,t],r))},e.prototype.reset=function(){this.client=void 0,this.plugins=new a.Plugins,this.params={}},e}();t.CoveoUA=u,t.coveoua=new u,t.handleOneAnalyticsEvent=function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=/^(?:(\w+)\.)?(?:(\w+):)?(\w+)$/.exec(e),a=(i[1],i[2]),s=i[3],u=t.coveoua[s];if(a&&s)return t.coveoua.callPlugin.apply(t.coveoua,o([a,s],n));if(u)return u.apply(t.coveoua,n);var c=["init","set","send","onLoad","callPlugin"];throw new Error('The action "'+e+'" does not exist. Available actions: '+c.join(", ")+".")},t.default=t.handleOneAnalyticsEvent},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3),o=n(2);t.STORE_KEY="__coveo.analytics.history",t.MAX_NUMBER_OF_HISTORY_ELEMENTS=20,t.MIN_THRESHOLD_FOR_DUPLICATE_VALUE=6e4,t.MAX_VALUE_SIZE=75;var i=function(){function e(e){this.store=e||o.getAvailableStorage(),this.store instanceof o.CookieStorage||!r.hasCookieStorage()||(new o.CookieStorage).removeItem(t.STORE_KEY)}return e.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])},e.prototype.getHistory=function(){var e=this.getHistoryWithInternalTime();return this.stripInternalTime(e)},e.prototype.getHistoryWithInternalTime=function(){try{var e=this.store.getItem(t.STORE_KEY);return e?JSON.parse(e):[]}catch(e){return[]}},e.prototype.setHistory=function(e){try{this.store.setItem(t.STORE_KEY,JSON.stringify(e.slice(0,t.MAX_NUMBER_OF_HISTORY_ELEMENTS)))}catch(e){}},e.prototype.clear=function(){try{this.store.removeItem(t.STORE_KEY)}catch(e){}},e.prototype.getMostRecentElement=function(){var e=this.getHistoryWithInternalTime();return null!=e?e.sort((function(e,t){return(t.internalTime||0)-(e.internalTime||0)}))[0]:null},e.prototype.cropQueryElement=function(e){e.name&&"query"==e.name.toLowerCase()&&null!=e.value&&(e.value=e.value.slice(0,t.MAX_VALUE_SIZE))},e.prototype.isValidEntry=function(e){var n=this.getMostRecentElement();return!n||n.value!=e.value||(e.internalTime||0)-(n.internalTime||0)>t.MIN_THRESHOLD_FOR_DUPLICATE_VALUE},e.prototype.stripInternalTime=function(e){return e.map((function(e){return{name:e.name,time:e.time,value:e.value}}))},e}();t.HistoryStore=i,t.default=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uuidv4=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,t.uuidv4)};var r=function(e){if(void 0!==typeof crypto&&crypto.getRandomValues)return crypto.getRandomValues(e);for(var t=0,n=0;t<e.length;t++)0==(3&t)&&(n=4294967296*Math.random()),e[t]=n>>>((3&t)<<3)&255;return e}},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0});var o={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",price:"pr",quantity:"qt",coupon:"cc",position:"ps"},i={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",position:"ps",price:"pr"},a=r(r(r(r(r({},{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"});t.keysOf=Object.keys,t.convertKeysToMeasurementProtocol=function(e){return t.keysOf(e).reduce((function(t,n){var o,i=a[n]||n;return r(r({},t),((o={})[i]=e[n],o))}),{})},t.convertProductToMeasurementProtocol=function(e,n){return t.keysOf(e).reduce((function(t,i){var a,s="pr"+(n+1)+(o[i]||i);return r(r({},t),((a={})[s]=e[i],a))}),{})},t.convertImpressionListToMeasurementProtocol=function(e,t){var n=e.impressions.reduce((function(e,n,o){return r(r({},e),s(n,t,o))}),{});e.listName&&(n["il"+(t+1)+"nm"]=e.listName);return n};var s=function(e,n,o){return t.keysOf(e).reduce((function(t,a){var s,u="il"+(n+1)+"pi"+(o+1)+(i[a]||a);return r(r({},t),((s={})[u]=e[a],s))}),{})},u=t.keysOf(a).map((function(e){return a[e]})),c=t.keysOf(o).map((function(e){return o[e]})),l=t.keysOf(i).map((function(e){return i[e]})),p=c.join("|"),f=l.join("|"),d=new RegExp("^(pr[0-9]+)("+p+")$"),h=new RegExp("^((il[0-9]+pi[0-9]+)("+f+"))|(il[0-9]+nm)$");t.isMeasurementProtocolKey=function(e){return d.test(e)||h.test(e)||-1!=u.indexOf(e)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1);t.analytics=r;var o=n(14);t.donottrack=o;var i=n(5);t.history=i;var a=n(4);t.SimpleAnalytics=a;var s=n(2);t.storage=s;var u=n(1);t.CoveoAnalyticsClient=u.CoveoAnalyticsClient;var c=n(4);t.CoveoUA=c.CoveoUA,t.handleOneAnalyticsEvent=c.handleOneAnalyticsEvent},function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e){this.opts=e}return e.prototype.sendEvent=function(e,t){return r(this,void 0,void 0,(function(){var n,r,i,a,s,u,c,l,p;return o(this,(function(o){if(!navigator.sendBeacon)throw new Error('navigator.sendBeacon is not supported in this browser. Consider adding a polyfill like "sendbeacon-polyfill".');return n=this.opts,r=n.baseUrl,i=n.token,a=n.visitorIdProvider,s=this.getParsedRequestDataKey(e),u=s+"="+encodeURIComponent(JSON.stringify(t)),c=a.currentVisitorId,l=[i?"access_token="+i:"",c?"visitorId="+c:""].filter((function(e){return!!e})).join("&"),p=r+"/analytics/"+e+"?"+l,console.log('Sending beacon for "'+e+'" with: ',JSON.stringify(t)),navigator.sendBeacon(p,new Blob([u],{type:"application/x-www-form-urlencoded"})),[2]}))}))},e.prototype.getParsedRequestDataKey=function(e){return e+"Event"},e}();t.AnalyticsBeaconClient=i},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};Object.defineProperty(t,"__esModule",{value:!0});var a=n(0),s=function(){function e(e){this.opts=e}return e.prototype.sendEvent=function(e,t){return o(this,void 0,void 0,(function(){var n,r,o,a,s,u;return i(this,(function(i){switch(i.label){case 0:return n=this.opts,r=n.baseUrl,o=n.visitorIdProvider,a=this.shouldAppendVisitorId(e)?this.visitorIdParam:"",[4,fetch(r+"/analytics/"+e+a,{method:"POST",headers:this.getHeaders(),mode:"cors",body:JSON.stringify(t),credentials:"include"})];case 1:return(s=i.sent()).ok?[4,s.json()]:[3,3];case 2:return(u=i.sent()).visitorId&&(o.currentVisitorId=u.visitorId),[2,u];case 3:try{s.json()}catch(e){}throw console.error('An error has occured when sending the "'+e+'" event.',s,t),new Error('An error has occurred when sending the "'+e+'" event. Check the console logs for more details.')}}))}))},e.prototype.shouldAppendVisitorId=function(e){return-1!==[a.EventType.click,a.EventType.custom,a.EventType.search,a.EventType.view].indexOf(e)},Object.defineProperty(e.prototype,"visitorIdParam",{get:function(){var e=this.opts.visitorIdProvider.currentVisitorId;return e?"?visitor="+e:""},enumerable:!0,configurable:!0}),e.prototype.getHeaders=function(){var e=this.opts.token;return r(r({},e?{Authorization:"Bearer "+e}:{}),{"Content-Type":"application/json"})},e}();t.AnalyticsFetchClient=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){}return e.set=function(t,n,r){var o,i,a,s,u;r?((a=new Date).setTime(a.getTime()+r),s="; expires="+a.toGMTString()):s="",-1===(u=location.hostname).indexOf(".")?document.cookie=t+"="+n+s+"; path=/":((i=u.split(".")).shift(),o="."+i.join("."),document.cookie=t+"="+n+s+"; path=/; domain="+o,null!=e.get(t)&&e.get(t)==n||(o="."+u,document.cookie=t+"="+n+s+"; path=/; domain="+o))},e.get=function(e){for(var t=e+"=",n=document.cookie.split(";"),r=0;r<n.length;r++){var o=n[r];if(0==(o=o.replace(/^\s+/,"")).indexOf(t))return o.substring(t.length,o.length)}return null},e.erase=function(t){e.set(t,"",-1)},e}();t.Cookie=r},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0});var o=n(0),i=[o.EventType.click,o.EventType.custom,o.EventType.search,o.EventType.view];t.addDefaultValues=function(e,t){return-1!==i.indexOf(e)?r({language:document.documentElement.lang,userAgent:navigator.userAgent},t):t}},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0});var o=n(0),i=n(5);t.enhanceViewEvent=function(e,t){return e===o.EventType.view?(a(t.contentIdValue),r({location:window.location.toString(),referrer:document.referrer,title:document.title},t)):t};var a=function(e){var t=new i.HistoryStore,n={name:"PageView",value:e,time:JSON.stringify(new Date)};t.addElement(n)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.doNotTrack=[!0,"yes","1"].indexOf(navigator.doNotTrack||navigator.msDoNotTrack||window.doNotTrack),t.default=t.doNotTrack},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){this.plugins={}}return e.prototype.register=function(e,t){this.plugins[e]=t},e.prototype.execute=function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=this.plugins[e],i=o[t];return i.apply(o,n)},e}();t.Plugins=r},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},o=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),a=n(6),s=n(17),u=n(7);t.ECPluginEventTypes={pageview:"pageview",event:"event"};var c=Object.keys(t.ECPluginEventTypes).map((function(e){return t.ECPluginEventTypes[e]})),l=function(){function e(e){var t=e.client,n=e.uuidGenerator,r=void 0===n?a.uuidv4:n;this.products=[],this.impressions=[],this.actionData={},this.client=t,this.uuidGenerator=r,this.pageViewId=r(),this.lastLocation=s.getFormattedLocation(window.location),this.lastReferrer=document.referrer,this.addHooksForPageView(),this.addHooksForEvent(),this.addHooksForECEvents()}return e.prototype.addProduct=function(e){this.products.push(e)},e.prototype.addImpression=function(e){this.impressions.push(e)},e.prototype.setAction=function(e,t){this.action=e,this.actionData=t},e.prototype.clearData=function(){this.products=[],this.impressions=[],this.action=void 0,this.actionData={}},e.prototype.addHooksForECEvents=function(){var e=this;this.client.registerBeforeSendEventHook((function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var o=n[0];return-1!==c.indexOf(t)?e.addECDataToPayload(t,o):o}))},e.prototype.addHooksForPageView=function(){this.client.addEventTypeMapping(t.ECPluginEventTypes.pageview,{newEventType:i.EventType.collect,variableLengthArgumentsNames:["page"],addVisitorIdParameter:!0,usesMeasurementProtocol:!0})},e.prototype.addHooksForEvent=function(){this.client.addEventTypeMapping(t.ECPluginEventTypes.event,{newEventType:i.EventType.collect,variableLengthArgumentsNames:["eventCategory","eventAction","eventLabel","eventValue"],addVisitorIdParameter:!0,usesMeasurementProtocol:!0})},e.prototype.addECDataToPayload=function(e,t){var n=r(r(r(r({},this.getLocationInformation(e,t)),this.getDefaultContextInformation(e)),this.action?{action:this.action}:{}),this.actionData||{}),o=this.products.reduce((function(e,t,n){return r(r({},e),u.convertProductToMeasurementProtocol(t,n))}),{}),i=this.getImpressionsByList().reduce((function(e,t,n){return r(r({},e),u.convertImpressionListToMeasurementProtocol(t,n))}),{});return this.clearData(),r(r(r(r({},i),o),n),t)},e.prototype.getImpressionsByList=function(){return this.impressions.reduce((function(e,t){var n=t.list,r=o(t,["list"]),i=e.find((function(e){return e.listName===n}));return i?i.impressions.push(r):e.push({listName:n,impressions:[r]}),e}),[])},e.prototype.updateStateForNewPageView=function(e){if(this.hasSentFirstPageView&&(this.pageViewId=this.uuidGenerator(),this.lastReferrer=this.lastLocation),e.page){this.lastLocation=""+function(e){return e.split("/").slice(0,3).join("/")}(this.lastLocation)+e.page.replace(/^\/?(.*)$/,"/$1")}else this.lastLocation=s.getFormattedLocation(window.location);this.hasSentFirstPageView=!0},e.prototype.getLocationInformation=function(e,n){return e===t.ECPluginEventTypes.pageview&&this.updateStateForNewPageView(n),{referrer:this.lastReferrer,location:this.lastLocation}},e.prototype.getDefaultContextInformation=function(e){var t={hitType:e,pageViewId:this.pageViewId},n={title:document.title,encoding:document.characterSet},o={screenResolution:screen.width+"x"+screen.height,screenColor:screen.colorDepth+"-bit"},i={language:navigator.language,userAgent:navigator.userAgent},a={time:Date.now().toString(),eventId:this.uuidGenerator()};return r(r(r(r(r({},t),a),o),i),n)},e}();t.EC=l},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getFormattedLocation=function(e){return e.protocol+"//"+e.hostname+(0===e.pathname.indexOf("/")?e.pathname:"/"+e.pathname)+e.search}},function(e,t,n){"use strict";(function(e){var r=this&&this.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,o++)r[o]=i[a];return r};Object.defineProperty(t,"__esModule",{value:!0});var o=n(8),i=n(4);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 a=e.coveoua||i.default;(e.coveoua=i.default,e.coveoanalytics=o,a.q)&&r(a.q.filter((function(e){return"init"===e[0]})),a.q.filter((function(e){return"init"!==e[0]}))).forEach((function(e){return i.default.apply(void 0,e)}));t.default=a}).call(this,n(19))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n}]); | ||
//# sourceMappingURL=coveoua.js.map | ||
!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 h=function(){return(h=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function s(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function n(e,s,a,u){return new(a=a||Promise)(function(n,t){function r(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?n(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(r,o)}i((u=u.apply(e,s||[])).next())})}function v(n,r){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=r.call(n,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,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r}var r,e,o=(t.prototype.sendEvent=function(l,p){return n(this,void 0,void 0,function(){var t,n,r,o,i,s,a,u,c;return v(this,function(e){if(!navigator.sendBeacon)throw new Error('navigator.sendBeacon is not supported in this browser. Consider adding a polyfill like "sendbeacon-polyfill".');return t=this.opts,n=t.baseUrl,r=t.token,o=t.visitorIdProvider,i=this.getParsedRequestDataKey(l),s=i+"="+encodeURIComponent(JSON.stringify(p)),a=o.currentVisitorId,u=[r?"access_token="+r:"",a?"visitorId="+a:""].filter(function(e){return!!e}).join("&"),c=n+"/analytics/"+l+"?"+u,console.log('Sending beacon for "'+l+'" with: ',JSON.stringify(p)),navigator.sendBeacon(c,new Blob([s],{type:"application/x-www-form-urlencoded"})),[2]})})},t.prototype.getParsedRequestDataKey=function(e){return e+"Event"},t);function t(e){this.opts=e}(e=r=r||{}).search="search",e.click="click",e.custom="custom",e.view="view",e.collect="collect";var i=(u.prototype.sendEvent=function(a,u){return n(this,void 0,void 0,function(){var t,n,r,o,i,s;return v(this,function(e){switch(e.label){case 0:return t=this.opts,n=t.baseUrl,r=t.visitorIdProvider,o=this.shouldAppendVisitorId(a)?this.visitorIdParam:"",[4,fetch(n+"/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&&(r.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.')}})})},u.prototype.shouldAppendVisitorId=function(e){return-1!==[r.click,r.custom,r.search,r.view].indexOf(e)},Object.defineProperty(u.prototype,"visitorIdParam",{get:function(){var e=this.opts.visitorIdProvider.currentVisitorId;return e?"?visitor="+e:""},enumerable:!0,configurable:!0}),u.prototype.getHeaders=function(){var e=this.opts.token;return h(h({},e?{Authorization:"Bearer "+e}:{}),{"Content-Type":"application/json"})},u);function u(e){this.opts=e}function c(){try{return"localStorage"in window&&null!==window.localStorage}catch(e){return!1}}function l(){return navigator.cookieEnabled}var p=(d.set=function(e,t,n){var r,o,i,s,a;s=n?((i=new Date).setTime(i.getTime()+n),"; expires="+i.toGMTString()):"",-1===(a=location.hostname).indexOf(".")?document.cookie=e+"="+t+s+"; path=/":((o=a.split(".")).shift(),r="."+o.join("."),document.cookie=e+"="+t+s+"; path=/; domain="+r,null!=d.get(e)&&d.get(e)==t||(r="."+a,document.cookie=e+"="+t+s+"; path=/; domain="+r))},d.get=function(e){for(var t=e+"=",n=document.cookie.split(";"),r=0;r<n.length;r++){var o=n[r];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 f(){return c()?localStorage:l()?new y:function(){try{return"sessionStorage"in window&&null!==window.sessionStorage}catch(e){return}}()?sessionStorage:new m}var y=(g.prototype.getItem=function(e){return p.get(""+g.prefix+e)},g.prototype.removeItem=function(e){p.erase(""+g.prefix+e)},g.prototype.setItem=function(e,t){p.set(""+g.prefix+e,t)},g.prefix="coveo_",g);function g(){}var m=(w.prototype.getItem=function(e){return null},w.prototype.removeItem=function(e){},w.prototype.setItem=function(e,t){},w);function w(){}function b(e,t){return-1!==I.indexOf(e)?h({language:document.documentElement.lang,userAgent:navigator.userAgent},t):t}var E=Object.freeze({__proto__:null,preferredStorage:null,getAvailableStorage:f,CookieStorage:y,NullStorage:m}),I=[r.click,r.custom,r.search,r.view],S="__coveo.analytics.history",k=(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(S);return e?JSON.parse(e):[]}catch(e){return[]}},x.prototype.setHistory=function(e){try{this.store.setItem(S,JSON.stringify(e.slice(0,20)))}catch(e){}},x.prototype.clear=function(){try{this.store.removeItem(S)}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||f(),this.store instanceof y||!l()||(new y).removeItem(S)}function C(e,t){return e===r.view?(O(t.contentIdValue),h({location:window.location.toString(),referrer:document.referrer,title:document.title},t)):t}function P(t){return[function(e){return Y.test(e)},function(e){return Q.test(e)},function(e){return-1!==D.indexOf(e)},function(e){return"custom"===e}].some(function(e){return e(t)})}var T=Object.freeze({__proto__:null,STORE_KEY:S,MAX_NUMBER_OF_HISTORY_ELEMENTS:20,MIN_THRESHOLD_FOR_DUPLICATE_VALUE:6e4,MAX_VALUE_SIZE:75,HistoryStore:k,default:k}),O=function(e){var t=new k,n={name:"PageView",value:e,time:JSON.stringify(new Date)};t.addElement(n)},A=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,A)},V=function(e){if(crypto.getRandomValues)return crypto.getRandomValues(e);for(var t=0,n=0;t<e.length;t++)0==(3&t)&&(n=4294967296*Math.random()),e[t]=n>>>((3&t)<<3)&255;return e},R={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",price:"pr",quantity:"qt",coupon:"cc",position:"ps"},_={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"}),L=Object.keys,F=function(o,i,s){return L(o).reduce(function(e,t){var n,r="il"+(i+1)+"pi"+(s+1)+(_[t]||t);return h(h({},e),((n={})[r]=o[t],n))},{})},D=L(j).map(function(e){return j[e]}),N=L(R).map(function(e){return R[e]}),q=L(_).map(function(e){return _[e]}),H=a(N,["custom"]).join("|"),B=a(q,["custom"]).join("|"),M="(pr[0-9]+)",U="(il[0-9]+pi[0-9]+)",Y=new RegExp("^"+M+"("+H+")$"),Q=new RegExp("^("+U+"("+B+"))|(il[0-9]+nm)$"),z=new RegExp("^"+M+"custom$"),W=new RegExp("^"+U+"custom$"),$=function(r,o){return L(o).reduce(function(e,t){var n;return h(h({},e),((n={})[""+r+t]=o[t],n))},{})},G={default:"https://usageanalytics.coveo.com",production:"https://usageanalytics.coveo.com",hipaa:"https://usageanalyticshipaa.coveo.com"},J=(Object.defineProperty(K.prototype,"defaultOptions",{get:function(){return{endpoint:G.default,token:"",version:"v15"}},enumerable:!0,configurable:!0}),K.prototype.initVisitorId=function(){var e=this.visitorId||l()&&this.cookieStorage.getItem("visitorId")||c()&&localStorage.getItem("visitorId")||"";this.currentVisitorId=e||A()},Object.defineProperty(K.prototype,"currentVisitorId",{get:function(){return this.visitorId},set:function(e){this.visitorId=e,l()&&this.cookieStorage.setItem("visitorId",e),c()&&localStorage.setItem("visitorId",e)},enumerable:!0,configurable:!0}),K.prototype.sendEvent=function(d){for(var f=[],e=1;e<arguments.length;e++)f[e-1]=arguments[e];return n(this,void 0,void 0,function(){var t,n,r,o,i,s,a,u,c,l,p=this;return v(this,function(e){switch(e.label){case 0:return t=this.eventTypeMapping[d]||{},r=void 0===(n=t.newEventType)?d:n,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 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 c?L(o=e).reduce(function(e,t){var n,r=j[t]||t;return h(h({},e),((n={})[r]=o[t],n))},{}):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)},f),this.bufferedRequests.push({eventType:r,payload:l,handled:!1}),[4,this.deferExecution()];case 1:return e.sent(),[4,this.sendFromBufferWithFetch()];case 2:return[2,e.sent()]}})})},K.prototype.deferExecution=function(){return new Promise(function(e){return setTimeout(e,0)})},K.prototype.flushBufferWithBeacon=function(){for(;this.hasPendingRequests();){var e=this.bufferedRequests.pop(),t=e.eventType,n=e.payload;this.analyticsBeaconClient.sendEvent(t,n)}},K.prototype.sendFromBufferWithFetch=function(){return n(this,void 0,void 0,function(){var t,n,r;return v(this,function(e){return(t=this.bufferedRequests.shift())?(n=t.eventType,r=t.payload,[2,this.analyticsFetchClient.sendEvent(n,r)]):[2]})})},K.prototype.hasPendingRequests=function(){return 0<this.bufferedRequests.length},K.prototype.sendSearchEvent=function(t){return n(this,void 0,void 0,function(){return v(this,function(e){return[2,this.sendEvent(r.search,t)]})})},K.prototype.sendClickEvent=function(t){return n(this,void 0,void 0,function(){return v(this,function(e){return[2,this.sendEvent(r.click,t)]})})},K.prototype.sendCustomEvent=function(t){return n(this,void 0,void 0,function(){return v(this,function(e){return[2,this.sendEvent(r.custom,t)]})})},K.prototype.sendViewEvent=function(t){return n(this,void 0,void 0,function(){return v(this,function(e){return[2,this.sendEvent(r.view,t)]})})},K.prototype.getVisit=function(){return n(this,void 0,void 0,function(){var t;return v(this,function(e){switch(e.label){case 0:return[4,fetch(this.baseUrl+"/analytics/visit")];case 1:return[4,e.sent().json()];case 2:return t=e.sent(),this.visitorId=t.visitorId,[2,t]}})})},K.prototype.getHealth=function(){return n(this,void 0,void 0,function(){return v(this,function(e){switch(e.label){case 0:return[4,fetch(this.baseUrl+"/analytics/monitoring/health")];case 1:return[4,e.sent().json()];case 2:return[2,e.sent()]}})})},K.prototype.registerBeforeSendEventHook=function(e){this.beforeSendHooks.push(e)},K.prototype.addEventTypeMapping=function(e,t){this.eventTypeMapping[e]=t},K.prototype.parseVariableArgumentsPayload=function(e,t){for(var n={},r=0,o=t.length;r<o;r++){var i=t[r];if("string"==typeof i)n[e[r]]=i;else if("object"==typeof i)return h(h({},n),i)}return n},K.prototype.isKeyAllowedEmpty=function(e,t){var n;return-1!==((n={})[r.search]=["queryText"],(n[e]||[]).indexOf(t))},K.prototype.removeEmptyPayloadValues=function(r,n){var o=this;return Object.keys(r).filter(function(e){return o.isKeyAllowedEmpty(n,e)||null!=(t=r[e])&&""!==t;var t}).reduce(function(e,t){var n;return h(h({},e),((n={})[t]=r[t],n))},{})},K.prototype.removeUnknownParameters=function(r){return Object.keys(r).filter(function(e){if(P(e))return!0;console.log(e,"is not processed by coveoua")}).reduce(function(e,t){var n;return h(h({},e),((n={})[t]=r[t],n))},{})},K.prototype.processCustomParameters=function(e){var i,t=e.custom,n=s(e,["custom"]),r=L(i=n).reduce(function(e,t){var n,r=z.exec(t)||W.exec(t);if(r){var o=r[1];return h(h({},e),$(o,i[t]))}return h(h({},e),((n={})[t]=i[t],n))},{});return h(h({},t||{}),r)},K.prototype.validateParams=function(e){var t=e.anonymizeIp,n=s(e,["anonymizeIp"]);return void 0!==t&&-1==["0","false","undefined","null","{}","[]",""].indexOf((""+t).toLowerCase())&&(n.anonymizeIp=1),n},Object.defineProperty(K.prototype,"baseUrl",{get:function(){var e=this.options,t=e.version;return e.endpoint+"/rest/"+t},enumerable:!0,configurable:!0}),K);function K(e){var t=this;if(!e)throw new Error("You have to pass options to this constructor");this.options=h(h({},this.defaultOptions),e);var n=this.options.token;this.cookieStorage=new y,this.visitorId="",this.bufferedRequests=[],this.beforeSendHooks=[C,b],this.eventTypeMapping={},this.initVisitorId();var r={baseUrl:this.baseUrl,token:n,visitorIdProvider:this};this.analyticsBeaconClient=new o(r),this.analyticsFetchClient=new i(r),window.addEventListener("beforeunload",function(){return t.flushBufferWithBeacon()})}var X=Object.freeze({__proto__:null,Version:"v15",Endpoints:G,CoveoAnalyticsClient:J,default:J}),Z=[!0,"yes","1"].indexOf(navigator.doNotTrack||navigator.msDoNotTrack||window.doNotTrack),ee=Object.freeze({__proto__:null,doNotTrack:Z,default:Z}),te=(ne.prototype.register=function(e,t){this.plugins[e]=t},ne.prototype.execute=function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=this.plugins[e];return o[t].apply(o,n)},ne);function ne(){this.plugins={}}function re(e){return e.protocol+"//"+e.hostname+(0===e.pathname.indexOf("/")?e.pathname:"/"+e.pathname)+e.search}var oe={pageview:"pageview",event:"event"},ie=Object.keys(oe).map(function(e){return oe[e]}),se=(ae.prototype.addProduct=function(e){this.products.push(e)},ae.prototype.addImpression=function(e){this.impressions.push(e)},ae.prototype.setAction=function(e,t){this.action=e,this.actionData=t},ae.prototype.clearData=function(){this.products=[],this.impressions=[],this.action=void 0,this.actionData={}},ae.prototype.addHooksForECEvents=function(){var o=this;this.client.registerBeforeSendEventHook(function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=t[0];return-1!==ie.indexOf(e)?o.addECDataToPayload(e,r):r})},ae.prototype.addHooksForPageView=function(){this.client.addEventTypeMapping(oe.pageview,{newEventType:r.collect,variableLengthArgumentsNames:["page"],addVisitorIdParameter:!0,usesMeasurementProtocol:!0})},ae.prototype.addHooksForEvent=function(){this.client.addEventTypeMapping(oe.event,{newEventType:r.collect,variableLengthArgumentsNames:["eventCategory","eventAction","eventLabel","eventValue"],addVisitorIdParameter:!0,usesMeasurementProtocol:!0})},ae.prototype.addECDataToPayload=function(e,t){var n=h(h(h(h({},this.getLocationInformation(e,t)),this.getDefaultContextInformation(e)),this.action?{action:this.action}:{}),this.actionData||{}),r=this.products.reduce(function(e,t,n){return h(h({},e),(i=n,L(o=t).reduce(function(e,t){var n,r="pr"+(i+1)+(R[t]||t);return h(h({},e),((n={})[r]=o[t],n))},{})));var o,i},{}),o=this.getImpressionsByList().reduce(function(e,t,n){return h(h({},e),function(e,r){var t=e.impressions.reduce(function(e,t,n){return h(h({},e),F(t,r,n))},{});return e.listName&&(t["il"+(r+1)+"nm"]=e.listName),t}(t,n))},{});return this.clearData(),h(h(h(h({},o),r),n),t)},ae.prototype.getImpressionsByList=function(){return this.impressions.reduce(function(e,t){var n=t.list,r=s(t,["list"]),o=e.find(function(e){return e.listName===n});return o?o.impressions.push(r):e.push({listName:n,impressions:[r]}),e},[])},ae.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=re(window.location),this.hasSentFirstPageView=!0},ae.prototype.getLocationInformation=function(e,t){return e===oe.pageview&&this.updateStateForNewPageView(t),{referrer:this.lastReferrer,location:this.lastLocation}},ae.prototype.getDefaultContextInformation=function(e){var t={hitType:e,pageViewId:this.pageViewId},n={title:document.title,encoding:document.characterSet},r={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),r),o),n)},ae);function ae(e){var t=e.client,n=e.uuidGenerator,r=void 0===n?A:n;this.products=[],this.impressions=[],this.actionData={},this.client=t,this.uuidGenerator=r,this.pageViewId=r(),this.lastLocation=re(window.location),this.lastReferrer=document.referrer,this.addHooksForPageView(),this.addHooksForEvent(),this.addHooksForECEvents()}var ue=(ce.prototype.init=function(e,t){var n=this;if(!e)throw new Error("You must pass your token when you call 'init'");if("string"==typeof e?(t=t||G.default,this.client=new J({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 se({client:this.client})),this.client.registerBeforeSendEventHook(function(e,t){return h(h({},t),n.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 J({endpoint:e})},ce.prototype.set=function(t,e){var n=this;"string"==typeof t?this.params[t]=e:Object.keys(t).map(function(e){n.params[e]=t[e]})},ce.prototype.send=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=t[0],o=t.slice(1);if(void 0===this.client)throw new Error("You must call init before sending an event");if(!r)throw new Error('You must provide an event type when calling "send".');return(e=this.client).sendEvent.apply(e,a([r.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 n,r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];(n=this.plugins).execute.apply(n,a([e,t],r))},ce.prototype.reset=function(){this.client=void 0,this.plugins=new te,this.params={}},ce);function ce(){this.plugins=new te,this.params={}}function le(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=/^(?:(\w+)\.)?(?:(\w+):)?(\w+)$/.exec(e),o=(r[1],r[2]),i=r[3],s=he[i];if(o&&i)return he.callPlugin.apply(he,a([o,i],t));if(s)return s.apply(he,t);throw new Error('The action "'+e+'" does not exist. Available actions: '+["init","set","send","onLoad","callPlugin"].join(", ")+".")}var pe,de,fe,he=new ue,ve=Object.freeze({__proto__:null,CoveoUA:ue,coveoua:he,handleOneAnalyticsEvent:le,default:le});(fe=de=de||{}).interfaceLoad="interfaceLoad",fe.interfaceChange="interfaceChange",fe.didyoumeanAutomatic="didyoumeanAutomatic",fe.didyoumeanClick="didyoumeanClick",fe.resultsSort="resultsSort",fe.searchboxSubmit="searchboxSubmit",fe.searchboxClear="searchboxClear",fe.searchboxAsYouType="searchboxAsYouType",fe.breadcrumbFacet="breadcrumbFacet",fe.breadcrumbResetAll="breadcrumbResetAll",fe.documentQuickview="documentQuickview",fe.documentOpen="documentOpen",fe.omniboxAnalytics="omniboxAnalytics",fe.omniboxFromLink="omniboxFromLink",fe.triggerNotify="notify",fe.triggerExecute="execute",fe.triggerQuery="query",fe.triggerRedirect="redirect";var ye=((pe={})[de.triggerNotify]="queryPipelineTriggers",pe[de.triggerExecute]="queryPipelineTriggers",pe[de.triggerQuery]="queryPipelineTriggers",pe[de.triggerRedirect]="queryPipelineTriggers",pe),ge=(me.prototype.logInterfaceLoad=function(){return this.logSearchEvent(de.interfaceLoad)},me.prototype.logInterfaceChange=function(e){return this.logSearchEvent(de.interfaceChange,e)},me.prototype.logDidYouMeanAutomatic=function(){return this.logSearchEvent(de.didyoumeanAutomatic)},me.prototype.logDidYouMeanClick=function(){return this.logSearchEvent(de.didyoumeanClick)},me.prototype.logResultsSort=function(e){return this.logSearchEvent(de.resultsSort,e)},me.prototype.logSearchboxSubmit=function(){return this.logSearchEvent(de.searchboxSubmit)},me.prototype.logSearchboxClear=function(){return this.logSearchEvent(de.searchboxClear)},me.prototype.logSearchboxAsYouType=function(){return this.logSearchEvent(de.searchboxAsYouType)},me.prototype.logBreadcrumbFacet=function(e){return this.logSearchEvent(de.breadcrumbFacet,e)},me.prototype.logBreadcrumbResetAll=function(){return this.logSearchEvent(de.breadcrumbResetAll)},me.prototype.logDocumentQuickview=function(e,t){return this.logClickEvent(de.documentQuickview,e,t)},me.prototype.logDocumentOpen=function(e,t){return this.logClickEvent(de.documentOpen,e,t)},me.prototype.logOmniboxAnalytics=function(e){return this.logSearchEvent(de.omniboxAnalytics,e)},me.prototype.logOmniboxFromLink=function(e){return this.logSearchEvent(de.omniboxFromLink,e)},me.prototype.logTriggerNotify=function(e){return this.logCustomEvent(de.triggerNotify,e)},me.prototype.logTriggerExecute=function(e){return this.logCustomEvent(de.triggerExecute,e)},me.prototype.logTriggerQuery=function(){var e={query:this.provider.getSearchEventRequestPayload().queryText};return this.logCustomEvent(de.triggerQuery,e)},me.prototype.logTriggerRedirect=function(e){var t=h(h({},e),{query:this.provider.getSearchEventRequestPayload().queryText});return this.logCustomEvent(de.triggerRedirect,t)},me.prototype.logCustomEvent=function(e,t){var n=h(h({},this.provider.getBaseMetadata()),t),r={eventType:ye[e],eventValue:e,lastSearchQueryUid:this.provider.getSearchUID(),customData:n};return this.coveoAnalyticsClient.sendCustomEvent(r)},me.prototype.logSearchEvent=function(e,t){var n=h(h({},this.provider.getBaseMetadata()),t),r=h(h({},this.provider.getSearchEventRequestPayload()),{searchQueryUid:this.provider.getSearchUID(),customData:n,actionCause:e});return this.coveoAnalyticsClient.sendSearchEvent(r)},me.prototype.logClickEvent=function(e,t,n,r){var o=h(h(h({},this.provider.getBaseMetadata()),n),r),i=h(h({},t),{searchQueryUid:this.provider.getSearchUID(),actionCause:e,customData:o});return this.coveoAnalyticsClient.sendClickEvent(i)},me);function me(e,t){this.opts=e,this.provider=t,this.coveoAnalyticsClient=new J(e)}var we=Object.freeze({__proto__:null,analytics:X,donottrack:ee,history:T,SimpleAnalytics:ve,storage:E,CoveoAnalyticsClient:J,CoveoUA:ue,handleOneAnalyticsEvent:le,CoveoSearchPageClient:ge});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 be=self.coveoua||le;self.coveoua=le,self.coveoanalytics=we,be.q&&a(be.q.filter(function(e){return"init"===e[0]}),be.q.filter(function(e){return"init"!==e[0]})).forEach(function(e){return le.apply(void 0,e)});return be}); | ||
//# sourceMappingURL=coveoua.js.map |
@@ -60,4 +60,6 @@ import { AnyEventResponse, ClickEventRequest, ClickEventResponse, CustomEventRequest, CustomEventResponse, EventType, HealthResponse, SearchEventRequest, SearchEventResponse, ViewEventRequest, ViewEventResponse, VisitResponse, VariableArgumentsPayload } from '../events'; | ||
private parseVariableArgumentsPayload; | ||
private isKeyAllowedEmpty; | ||
private removeEmptyPayloadValues; | ||
private removeUnknownParameters; | ||
private processCustomParameters; | ||
private validateParams; | ||
@@ -64,0 +66,0 @@ private get baseUrl(); |
@@ -0,0 +0,0 @@ import { AnalyticsRequestClient, VisitorIdProvider } from './analyticsRequestClient'; |
@@ -0,0 +0,0 @@ import { AnalyticsRequestClient, VisitorIdProvider } from './analyticsRequestClient'; |
@@ -0,0 +0,0 @@ import { AnyEventResponse, IRequestPayload } from '../events'; |
export declare const uuidv4: (a?: string | number | undefined) => string; |
export declare const getFormattedLocation: (location: Location) => string; |
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"> & Required<Pick<import("../plugins/ec").ProductProperties, "name">> & Partial<Pick<import("../plugins/ec").ProductProperties, "id">>) | (Pick<import("../plugins/ec").ProductProperties, "brand" | "category" | "variant" | "price" | "quantity" | "coupon" | "position"> & Required<Pick<import("../plugins/ec").ProductProperties, "id">> & Partial<Pick<import("../plugins/ec").ProductProperties, "name">>), index: number) => {}; | ||
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) => { | ||
@@ -9,1 +9,6 @@ [name: string]: any; | ||
export declare const isMeasurementProtocolKey: (key: string) => boolean; | ||
export declare const convertCustomMeasurementProtocolKeys: (data: { | ||
[name: string]: string | { | ||
[name: string]: string; | ||
}; | ||
}) => {}; |
@@ -0,0 +0,0 @@ export declare class Cookie { |
@@ -0,0 +0,0 @@ export interface CoveoUAGlobal { |
@@ -8,2 +8,3 @@ import * as analytics from '../client/analytics'; | ||
export { CoveoUA, handleOneAnalyticsEvent } from './simpleanalytics'; | ||
export { CoveoSearchPageClient, SearchPageClientProvider } from '../searchPage/searchPageClient'; | ||
export { analytics, donottrack, history, SimpleAnalytics, storage }; |
@@ -0,0 +0,0 @@ export declare type UAPluginOptions = any[]; |
@@ -0,0 +0,0 @@ import { AnyEventResponse, SendEventArguments } from '../events'; |
export declare function hasLocalStorage(): boolean; | ||
export declare function hasSessionStorage(): boolean; | ||
export declare function hasCookieStorage(): boolean; |
export declare const doNotTrack: number; | ||
export default doNotTrack; |
@@ -18,3 +18,3 @@ export declare type IRequestPayload = Record<string, any>; | ||
userAgent?: string; | ||
customData?: any; | ||
customData?: Record<string, any>; | ||
anonymous?: boolean; | ||
@@ -41,3 +41,3 @@ username?: string; | ||
} | ||
export interface ClickEventRequest extends EventBaseRequest { | ||
export interface DocumentInformation { | ||
documentUri: string; | ||
@@ -49,9 +49,11 @@ documentUriHash: string; | ||
actionCause: string; | ||
searchQueryUid?: string; | ||
documentTitle?: string; | ||
documentUrl?: string; | ||
documentAuthor?: string; | ||
queryPipeline?: string; | ||
rankingModifier?: string; | ||
searchQueryUid: string; | ||
documentTitle: string; | ||
documentUrl: string; | ||
documentAuthor: string; | ||
queryPipeline: string; | ||
rankingModifier: string; | ||
} | ||
export interface ClickEventRequest extends EventBaseRequest, DocumentInformation { | ||
} | ||
export interface CustomEventRequest extends EventBaseRequest { | ||
@@ -58,0 +60,0 @@ eventType: string; |
@@ -0,0 +0,0 @@ import { WebStorage } from './storage'; |
import { AnalyticsClientSendEventHook } from '../client/analytics'; | ||
export declare const addDefaultValues: AnalyticsClientSendEventHook; |
import { AnalyticsClientSendEventHook } from '../client/analytics'; | ||
export declare const enhanceViewEvent: AnalyticsClientSendEventHook; |
@@ -10,2 +10,5 @@ import { AnalyticsClient } from '../client/analytics'; | ||
}[Keys]; | ||
export declare type CustomValues = { | ||
[key: string]: string | number | boolean; | ||
}; | ||
export interface ProductProperties { | ||
@@ -21,2 +24,3 @@ id?: string; | ||
position?: number; | ||
custom?: CustomValues; | ||
} | ||
@@ -33,2 +37,3 @@ export declare type Product = RequireAtLeastOne<ProductProperties, 'id' | 'name'>; | ||
price?: number; | ||
custom?: CustomValues; | ||
} | ||
@@ -35,0 +40,0 @@ export declare type Impression = RequireAtLeastOne<ImpressionProperties, 'id' | 'name'>; |
@@ -0,0 +0,0 @@ export declare let preferredStorage: WebStorage | null; |
@@ -1,2 +0,2 @@ | ||
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=8)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.search="search",e.click="click",e.custom="custom",e.view="view",e.collect="collect"}(t.EventType||(t.EventType={}))},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},a=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0});var s=n(9),u=n(10),c=n(0),l=n(2),p=n(3),f=n(12),d=n(13),h=n(6),v=n(7);t.Version="v15",t.Endpoints={default:"https://usageanalytics.coveo.com",production:"https://usageanalytics.coveo.com",hipaa:"https://usageanalyticshipaa.coveo.com"};var y=function(){function e(e){var t=this;if(!e)throw new Error("You have to pass options to this constructor");this.options=r(r({},this.defaultOptions),e);var n=this.options.token;this.cookieStorage=new l.CookieStorage,this.visitorId="",this.bufferedRequests=[],this.beforeSendHooks=[d.enhanceViewEvent,f.addDefaultValues],this.eventTypeMapping={},this.initVisitorId();var o={baseUrl:this.baseUrl,token:n,visitorIdProvider:this};this.analyticsBeaconClient=new s.AnalyticsBeaconClient(o),this.analyticsFetchClient=new u.AnalyticsFetchClient(o),window.addEventListener("beforeunload",(function(){return t.flushBufferWithBeacon()}))}return Object.defineProperty(e.prototype,"defaultOptions",{get:function(){return{endpoint:t.Endpoints.default,token:"",version:t.Version}},enumerable:!0,configurable:!0}),e.prototype.initVisitorId=function(){var e=this.visitorId||p.hasCookieStorage()&&this.cookieStorage.getItem("visitorId")||p.hasLocalStorage()&&localStorage.getItem("visitorId")||"";this.currentVisitorId=e||h.uuidv4()},Object.defineProperty(e.prototype,"currentVisitorId",{get:function(){return this.visitorId},set:function(e){this.visitorId=e,p.hasCookieStorage()&&this.cookieStorage.setItem("visitorId",e),p.hasLocalStorage()&&localStorage.setItem("visitorId",e)},enumerable:!0,configurable:!0}),e.prototype.sendEvent=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return o(this,void 0,void 0,(function(){var n,o,a,s,u,c,l,p,f,d,h=this;return i(this,(function(i){switch(i.label){case 0:return n=this.eventTypeMapping[e]||{},o=n.newEventType,a=void 0===o?e:o,s=n.variableLengthArgumentsNames,u=void 0===s?[]:s,c=n.addVisitorIdParameter,l=void 0!==c&&c,p=n.usesMeasurementProtocol,f=void 0!==p&&p,d=[function(e){return u.length>0?h.parseVariableArgumentsPayload(u,e):e[0]},function(e){return r({visitorId:l?h.visitorId:""},e)},function(t){return h.beforeSendHooks.reduce((function(t,n){return n(e,t)}),t)},function(e){return h.removeEmptyPayloadValues(e)},function(e){return h.validateParams(e)},function(e){return f?v.convertKeysToMeasurementProtocol(e):e},function(e){return f?h.removeUnknownParameters(e):e}].reduce((function(e,t){return t(e)}),t),this.bufferedRequests.push({eventType:a,payload:d,handled:!1}),[4,this.deferExecution()];case 1:return i.sent(),[4,this.sendFromBufferWithFetch()];case 2:return[2,i.sent()]}}))}))},e.prototype.deferExecution=function(){return new Promise((function(e){return setTimeout(e,0)}))},e.prototype.flushBufferWithBeacon=function(){for(;this.hasPendingRequests();){var e=this.bufferedRequests.pop(),t=e.eventType,n=e.payload;this.analyticsBeaconClient.sendEvent(t,n)}},e.prototype.sendFromBufferWithFetch=function(){return o(this,void 0,void 0,(function(){var e,t,n;return i(this,(function(r){return(e=this.bufferedRequests.shift())?(t=e.eventType,n=e.payload,[2,this.analyticsFetchClient.sendEvent(t,n)]):[2]}))}))},e.prototype.hasPendingRequests=function(){return this.bufferedRequests.length>0},e.prototype.sendSearchEvent=function(e){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.sendEvent(c.EventType.search,e)]}))}))},e.prototype.sendClickEvent=function(e){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.sendEvent(c.EventType.click,e)]}))}))},e.prototype.sendCustomEvent=function(e){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.sendEvent(c.EventType.custom,e)]}))}))},e.prototype.sendViewEvent=function(e){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.sendEvent(c.EventType.view,e)]}))}))},e.prototype.getVisit=function(){return o(this,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,fetch(this.baseUrl+"/analytics/visit")];case 1:return[4,t.sent().json()];case 2:return e=t.sent(),this.visitorId=e.visitorId,[2,e]}}))}))},e.prototype.getHealth=function(){return o(this,void 0,void 0,(function(){return i(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()]}}))}))},e.prototype.registerBeforeSendEventHook=function(e){this.beforeSendHooks.push(e)},e.prototype.addEventTypeMapping=function(e,t){this.eventTypeMapping[e]=t},e.prototype.parseVariableArgumentsPayload=function(e,t){for(var n={},o=0,i=t.length;o<i;o++){var a=t[o];if("string"==typeof a)n[e[o]]=a;else if("object"==typeof a)return r(r({},n),a)}return n},e.prototype.removeEmptyPayloadValues=function(e){return Object.keys(e).filter((function(t){return null!=(n=e[t])&&""!==n;var n})).reduce((function(t,n){var o;return r(r({},t),((o={})[n]=e[n],o))}),{})},e.prototype.removeUnknownParameters=function(e){return Object.keys(e).filter((function(e){if(v.isMeasurementProtocolKey(e))return!0;console.log(e,"is not processsed by coveoua")})).reduce((function(t,n){var o;return r(r({},t),((o={})[n]=e[n],o))}),{})},e.prototype.validateParams=function(e){var t=e.anonymizeIp,n=a(e,["anonymizeIp"]);return void 0!==t&&-1==["0","false","undefined","null","{}","[]",""].indexOf((""+t).toLowerCase())&&(n.anonymizeIp=1),n},Object.defineProperty(e.prototype,"baseUrl",{get:function(){var e=this.options,t=e.version;return e.endpoint+"/rest/"+t},enumerable:!0,configurable:!0}),e}();t.CoveoAnalyticsClient=y,t.default=y},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3),o=n(11);t.preferredStorage=null,t.getAvailableStorage=function(){return t.preferredStorage?t.preferredStorage:r.hasLocalStorage()?localStorage:r.hasCookieStorage()?new i:r.hasSessionStorage()?sessionStorage:new a};var i=function(){function e(){}return e.prototype.getItem=function(t){return o.Cookie.get(""+e.prefix+t)},e.prototype.removeItem=function(t){o.Cookie.erase(""+e.prefix+t)},e.prototype.setItem=function(t,n){o.Cookie.set(""+e.prefix+t,n)},e.prefix="coveo_",e}();t.CookieStorage=i;var a=function(){function e(){}return e.prototype.getItem=function(e){return null},e.prototype.removeItem=function(e){},e.prototype.setItem=function(e,t){},e}();t.NullStorage=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hasLocalStorage=function(){try{return"localStorage"in window&&null!==window.localStorage}catch(e){return!1}},t.hasSessionStorage=function(){try{return"sessionStorage"in window&&null!==window.sessionStorage}catch(e){return!1}},t.hasCookieStorage=function(){return navigator.cookieEnabled}},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},o=this&&this.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,o++)r[o]=i[a];return r};Object.defineProperty(t,"__esModule",{value:!0});var i=n(1),a=n(15),s=n(16),u=function(){function e(){this.plugins=new a.Plugins,this.params={}}return e.prototype.init=function(e,t){var n=this;if(!e)throw new Error("You must pass your token when you call 'init'");if("string"==typeof e?(t=t||i.Endpoints.default,this.client=new i.CoveoAnalyticsClient({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 s.EC({client:this.client})),this.client.registerBeforeSendEventHook((function(e,t){return r(r({},t),n.params)}))},e.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 i.CoveoAnalyticsClient({endpoint:e})},e.prototype.set=function(e,t){var n=this;"string"==typeof e?this.params[e]=t:Object.keys(e).map((function(t){n.params[t]=e[t]}))},e.prototype.send=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=t[0],i=t.slice(1);if(void 0===this.client)throw new Error("You must call init before sending an event");if(!r)throw new Error('You must provide an event type when calling "send".');return(e=this.client).sendEvent.apply(e,o([r.toLowerCase()],i))},e.prototype.onLoad=function(e){if(void 0===e)throw new Error("You must pass a function when you call 'onLoad'");e()},e.prototype.callPlugin=function(e,t){for(var n,r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];(n=this.plugins).execute.apply(n,o([e,t],r))},e.prototype.reset=function(){this.client=void 0,this.plugins=new a.Plugins,this.params={}},e}();t.CoveoUA=u,t.coveoua=new u,t.handleOneAnalyticsEvent=function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=/^(?:(\w+)\.)?(?:(\w+):)?(\w+)$/.exec(e),a=(i[1],i[2]),s=i[3],u=t.coveoua[s];if(a&&s)return t.coveoua.callPlugin.apply(t.coveoua,o([a,s],n));if(u)return u.apply(t.coveoua,n);var c=["init","set","send","onLoad","callPlugin"];throw new Error('The action "'+e+'" does not exist. Available actions: '+c.join(", ")+".")},t.default=t.handleOneAnalyticsEvent},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3),o=n(2);t.STORE_KEY="__coveo.analytics.history",t.MAX_NUMBER_OF_HISTORY_ELEMENTS=20,t.MIN_THRESHOLD_FOR_DUPLICATE_VALUE=6e4,t.MAX_VALUE_SIZE=75;var i=function(){function e(e){this.store=e||o.getAvailableStorage(),this.store instanceof o.CookieStorage||!r.hasCookieStorage()||(new o.CookieStorage).removeItem(t.STORE_KEY)}return e.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])},e.prototype.getHistory=function(){var e=this.getHistoryWithInternalTime();return this.stripInternalTime(e)},e.prototype.getHistoryWithInternalTime=function(){try{var e=this.store.getItem(t.STORE_KEY);return e?JSON.parse(e):[]}catch(e){return[]}},e.prototype.setHistory=function(e){try{this.store.setItem(t.STORE_KEY,JSON.stringify(e.slice(0,t.MAX_NUMBER_OF_HISTORY_ELEMENTS)))}catch(e){}},e.prototype.clear=function(){try{this.store.removeItem(t.STORE_KEY)}catch(e){}},e.prototype.getMostRecentElement=function(){var e=this.getHistoryWithInternalTime();return null!=e?e.sort((function(e,t){return(t.internalTime||0)-(e.internalTime||0)}))[0]:null},e.prototype.cropQueryElement=function(e){e.name&&"query"==e.name.toLowerCase()&&null!=e.value&&(e.value=e.value.slice(0,t.MAX_VALUE_SIZE))},e.prototype.isValidEntry=function(e){var n=this.getMostRecentElement();return!n||n.value!=e.value||(e.internalTime||0)-(n.internalTime||0)>t.MIN_THRESHOLD_FOR_DUPLICATE_VALUE},e.prototype.stripInternalTime=function(e){return e.map((function(e){return{name:e.name,time:e.time,value:e.value}}))},e}();t.HistoryStore=i,t.default=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uuidv4=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,t.uuidv4)};var r=function(e){if(void 0!==typeof crypto&&crypto.getRandomValues)return crypto.getRandomValues(e);for(var t=0,n=0;t<e.length;t++)0==(3&t)&&(n=4294967296*Math.random()),e[t]=n>>>((3&t)<<3)&255;return e}},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0});var o={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",price:"pr",quantity:"qt",coupon:"cc",position:"ps"},i={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",position:"ps",price:"pr"},a=r(r(r(r(r({},{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"});t.keysOf=Object.keys,t.convertKeysToMeasurementProtocol=function(e){return t.keysOf(e).reduce((function(t,n){var o,i=a[n]||n;return r(r({},t),((o={})[i]=e[n],o))}),{})},t.convertProductToMeasurementProtocol=function(e,n){return t.keysOf(e).reduce((function(t,i){var a,s="pr"+(n+1)+(o[i]||i);return r(r({},t),((a={})[s]=e[i],a))}),{})},t.convertImpressionListToMeasurementProtocol=function(e,t){var n=e.impressions.reduce((function(e,n,o){return r(r({},e),s(n,t,o))}),{});e.listName&&(n["il"+(t+1)+"nm"]=e.listName);return n};var s=function(e,n,o){return t.keysOf(e).reduce((function(t,a){var s,u="il"+(n+1)+"pi"+(o+1)+(i[a]||a);return r(r({},t),((s={})[u]=e[a],s))}),{})},u=t.keysOf(a).map((function(e){return a[e]})),c=t.keysOf(o).map((function(e){return o[e]})),l=t.keysOf(i).map((function(e){return i[e]})),p=c.join("|"),f=l.join("|"),d=new RegExp("^(pr[0-9]+)("+p+")$"),h=new RegExp("^((il[0-9]+pi[0-9]+)("+f+"))|(il[0-9]+nm)$");t.isMeasurementProtocolKey=function(e){return d.test(e)||h.test(e)||-1!=u.indexOf(e)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1);t.analytics=r;var o=n(14);t.donottrack=o;var i=n(5);t.history=i;var a=n(4);t.SimpleAnalytics=a;var s=n(2);t.storage=s;var u=n(1);t.CoveoAnalyticsClient=u.CoveoAnalyticsClient;var c=n(4);t.CoveoUA=c.CoveoUA,t.handleOneAnalyticsEvent=c.handleOneAnalyticsEvent},function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e){this.opts=e}return e.prototype.sendEvent=function(e,t){return r(this,void 0,void 0,(function(){var n,r,i,a,s,u,c,l,p;return o(this,(function(o){if(!navigator.sendBeacon)throw new Error('navigator.sendBeacon is not supported in this browser. Consider adding a polyfill like "sendbeacon-polyfill".');return n=this.opts,r=n.baseUrl,i=n.token,a=n.visitorIdProvider,s=this.getParsedRequestDataKey(e),u=s+"="+encodeURIComponent(JSON.stringify(t)),c=a.currentVisitorId,l=[i?"access_token="+i:"",c?"visitorId="+c:""].filter((function(e){return!!e})).join("&"),p=r+"/analytics/"+e+"?"+l,console.log('Sending beacon for "'+e+'" with: ',JSON.stringify(t)),navigator.sendBeacon(p,new Blob([u],{type:"application/x-www-form-urlencoded"})),[2]}))}))},e.prototype.getParsedRequestDataKey=function(e){return e+"Event"},e}();t.AnalyticsBeaconClient=i},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};Object.defineProperty(t,"__esModule",{value:!0});var a=n(0),s=function(){function e(e){this.opts=e}return e.prototype.sendEvent=function(e,t){return o(this,void 0,void 0,(function(){var n,r,o,a,s,u;return i(this,(function(i){switch(i.label){case 0:return n=this.opts,r=n.baseUrl,o=n.visitorIdProvider,a=this.shouldAppendVisitorId(e)?this.visitorIdParam:"",[4,fetch(r+"/analytics/"+e+a,{method:"POST",headers:this.getHeaders(),mode:"cors",body:JSON.stringify(t),credentials:"include"})];case 1:return(s=i.sent()).ok?[4,s.json()]:[3,3];case 2:return(u=i.sent()).visitorId&&(o.currentVisitorId=u.visitorId),[2,u];case 3:try{s.json()}catch(e){}throw console.error('An error has occured when sending the "'+e+'" event.',s,t),new Error('An error has occurred when sending the "'+e+'" event. Check the console logs for more details.')}}))}))},e.prototype.shouldAppendVisitorId=function(e){return-1!==[a.EventType.click,a.EventType.custom,a.EventType.search,a.EventType.view].indexOf(e)},Object.defineProperty(e.prototype,"visitorIdParam",{get:function(){var e=this.opts.visitorIdProvider.currentVisitorId;return e?"?visitor="+e:""},enumerable:!0,configurable:!0}),e.prototype.getHeaders=function(){var e=this.opts.token;return r(r({},e?{Authorization:"Bearer "+e}:{}),{"Content-Type":"application/json"})},e}();t.AnalyticsFetchClient=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){}return e.set=function(t,n,r){var o,i,a,s,u;r?((a=new Date).setTime(a.getTime()+r),s="; expires="+a.toGMTString()):s="",-1===(u=location.hostname).indexOf(".")?document.cookie=t+"="+n+s+"; path=/":((i=u.split(".")).shift(),o="."+i.join("."),document.cookie=t+"="+n+s+"; path=/; domain="+o,null!=e.get(t)&&e.get(t)==n||(o="."+u,document.cookie=t+"="+n+s+"; path=/; domain="+o))},e.get=function(e){for(var t=e+"=",n=document.cookie.split(";"),r=0;r<n.length;r++){var o=n[r];if(0==(o=o.replace(/^\s+/,"")).indexOf(t))return o.substring(t.length,o.length)}return null},e.erase=function(t){e.set(t,"",-1)},e}();t.Cookie=r},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0});var o=n(0),i=[o.EventType.click,o.EventType.custom,o.EventType.search,o.EventType.view];t.addDefaultValues=function(e,t){return-1!==i.indexOf(e)?r({language:document.documentElement.lang,userAgent:navigator.userAgent},t):t}},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0});var o=n(0),i=n(5);t.enhanceViewEvent=function(e,t){return e===o.EventType.view?(a(t.contentIdValue),r({location:window.location.toString(),referrer:document.referrer,title:document.title},t)):t};var a=function(e){var t=new i.HistoryStore,n={name:"PageView",value:e,time:JSON.stringify(new Date)};t.addElement(n)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.doNotTrack=[!0,"yes","1"].indexOf(navigator.doNotTrack||navigator.msDoNotTrack||window.doNotTrack),t.default=t.doNotTrack},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){this.plugins={}}return e.prototype.register=function(e,t){this.plugins[e]=t},e.prototype.execute=function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=this.plugins[e],i=o[t];return i.apply(o,n)},e}();t.Plugins=r},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},o=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),a=n(6),s=n(17),u=n(7);t.ECPluginEventTypes={pageview:"pageview",event:"event"};var c=Object.keys(t.ECPluginEventTypes).map((function(e){return t.ECPluginEventTypes[e]})),l=function(){function e(e){var t=e.client,n=e.uuidGenerator,r=void 0===n?a.uuidv4:n;this.products=[],this.impressions=[],this.actionData={},this.client=t,this.uuidGenerator=r,this.pageViewId=r(),this.lastLocation=s.getFormattedLocation(window.location),this.lastReferrer=document.referrer,this.addHooksForPageView(),this.addHooksForEvent(),this.addHooksForECEvents()}return e.prototype.addProduct=function(e){this.products.push(e)},e.prototype.addImpression=function(e){this.impressions.push(e)},e.prototype.setAction=function(e,t){this.action=e,this.actionData=t},e.prototype.clearData=function(){this.products=[],this.impressions=[],this.action=void 0,this.actionData={}},e.prototype.addHooksForECEvents=function(){var e=this;this.client.registerBeforeSendEventHook((function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var o=n[0];return-1!==c.indexOf(t)?e.addECDataToPayload(t,o):o}))},e.prototype.addHooksForPageView=function(){this.client.addEventTypeMapping(t.ECPluginEventTypes.pageview,{newEventType:i.EventType.collect,variableLengthArgumentsNames:["page"],addVisitorIdParameter:!0,usesMeasurementProtocol:!0})},e.prototype.addHooksForEvent=function(){this.client.addEventTypeMapping(t.ECPluginEventTypes.event,{newEventType:i.EventType.collect,variableLengthArgumentsNames:["eventCategory","eventAction","eventLabel","eventValue"],addVisitorIdParameter:!0,usesMeasurementProtocol:!0})},e.prototype.addECDataToPayload=function(e,t){var n=r(r(r(r({},this.getLocationInformation(e,t)),this.getDefaultContextInformation(e)),this.action?{action:this.action}:{}),this.actionData||{}),o=this.products.reduce((function(e,t,n){return r(r({},e),u.convertProductToMeasurementProtocol(t,n))}),{}),i=this.getImpressionsByList().reduce((function(e,t,n){return r(r({},e),u.convertImpressionListToMeasurementProtocol(t,n))}),{});return this.clearData(),r(r(r(r({},i),o),n),t)},e.prototype.getImpressionsByList=function(){return this.impressions.reduce((function(e,t){var n=t.list,r=o(t,["list"]),i=e.find((function(e){return e.listName===n}));return i?i.impressions.push(r):e.push({listName:n,impressions:[r]}),e}),[])},e.prototype.updateStateForNewPageView=function(e){if(this.hasSentFirstPageView&&(this.pageViewId=this.uuidGenerator(),this.lastReferrer=this.lastLocation),e.page){this.lastLocation=""+function(e){return e.split("/").slice(0,3).join("/")}(this.lastLocation)+e.page.replace(/^\/?(.*)$/,"/$1")}else this.lastLocation=s.getFormattedLocation(window.location);this.hasSentFirstPageView=!0},e.prototype.getLocationInformation=function(e,n){return e===t.ECPluginEventTypes.pageview&&this.updateStateForNewPageView(n),{referrer:this.lastReferrer,location:this.lastLocation}},e.prototype.getDefaultContextInformation=function(e){var t={hitType:e,pageViewId:this.pageViewId},n={title:document.title,encoding:document.characterSet},o={screenResolution:screen.width+"x"+screen.height,screenColor:screen.colorDepth+"-bit"},i={language:navigator.language,userAgent:navigator.userAgent},a={time:Date.now().toString(),eventId:this.uuidGenerator()};return r(r(r(r(r({},t),a),o),i),n)},e}();t.EC=l},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getFormattedLocation=function(e){return e.protocol+"//"+e.hostname+(0===e.pathname.indexOf("/")?e.pathname:"/"+e.pathname)+e.search}}]); | ||
//# sourceMappingURL=library.js.map | ||
!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 h=function(){return(h=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function s(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function n(e,s,a,u){return new(a=a||Promise)(function(n,t){function r(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?n(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(r,o)}i((u=u.apply(e,s||[])).next())})}function v(n,r){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=r.call(n,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,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r}var r,e,o=(t.prototype.sendEvent=function(l,p){return n(this,void 0,void 0,function(){var t,n,r,o,i,s,a,u,c;return v(this,function(e){if(!navigator.sendBeacon)throw new Error('navigator.sendBeacon is not supported in this browser. Consider adding a polyfill like "sendbeacon-polyfill".');return t=this.opts,n=t.baseUrl,r=t.token,o=t.visitorIdProvider,i=this.getParsedRequestDataKey(l),s=i+"="+encodeURIComponent(JSON.stringify(p)),a=o.currentVisitorId,u=[r?"access_token="+r:"",a?"visitorId="+a:""].filter(function(e){return!!e}).join("&"),c=n+"/analytics/"+l+"?"+u,console.log('Sending beacon for "'+l+'" with: ',JSON.stringify(p)),navigator.sendBeacon(c,new Blob([s],{type:"application/x-www-form-urlencoded"})),[2]})})},t.prototype.getParsedRequestDataKey=function(e){return e+"Event"},t);function t(e){this.opts=e}(e=r=r||{}).search="search",e.click="click",e.custom="custom",e.view="view",e.collect="collect";var i=(u.prototype.sendEvent=function(a,u){return n(this,void 0,void 0,function(){var t,n,r,o,i,s;return v(this,function(e){switch(e.label){case 0:return t=this.opts,n=t.baseUrl,r=t.visitorIdProvider,o=this.shouldAppendVisitorId(a)?this.visitorIdParam:"",[4,fetch(n+"/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&&(r.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.')}})})},u.prototype.shouldAppendVisitorId=function(e){return-1!==[r.click,r.custom,r.search,r.view].indexOf(e)},Object.defineProperty(u.prototype,"visitorIdParam",{get:function(){var e=this.opts.visitorIdProvider.currentVisitorId;return e?"?visitor="+e:""},enumerable:!0,configurable:!0}),u.prototype.getHeaders=function(){var e=this.opts.token;return h(h({},e?{Authorization:"Bearer "+e}:{}),{"Content-Type":"application/json"})},u);function u(e){this.opts=e}function c(){try{return"localStorage"in window&&null!==window.localStorage}catch(e){return!1}}function l(){return navigator.cookieEnabled}var p=(d.set=function(e,t,n){var r,o,i,s,a;s=n?((i=new Date).setTime(i.getTime()+n),"; expires="+i.toGMTString()):"",-1===(a=location.hostname).indexOf(".")?document.cookie=e+"="+t+s+"; path=/":((o=a.split(".")).shift(),r="."+o.join("."),document.cookie=e+"="+t+s+"; path=/; domain="+r,null!=d.get(e)&&d.get(e)==t||(r="."+a,document.cookie=e+"="+t+s+"; path=/; domain="+r))},d.get=function(e){for(var t=e+"=",n=document.cookie.split(";"),r=0;r<n.length;r++){var o=n[r];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 f(){return c()?localStorage:l()?new y:function(){try{return"sessionStorage"in window&&null!==window.sessionStorage}catch(e){return}}()?sessionStorage:new m}var y=(g.prototype.getItem=function(e){return p.get(""+g.prefix+e)},g.prototype.removeItem=function(e){p.erase(""+g.prefix+e)},g.prototype.setItem=function(e,t){p.set(""+g.prefix+e,t)},g.prefix="coveo_",g);function g(){}var m=(w.prototype.getItem=function(e){return null},w.prototype.removeItem=function(e){},w.prototype.setItem=function(e,t){},w);function w(){}function b(e,t){return-1!==I.indexOf(e)?h({language:document.documentElement.lang,userAgent:navigator.userAgent},t):t}var E=Object.freeze({__proto__:null,preferredStorage:null,getAvailableStorage:f,CookieStorage:y,NullStorage:m}),I=[r.click,r.custom,r.search,r.view],S="__coveo.analytics.history",k=(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(S);return e?JSON.parse(e):[]}catch(e){return[]}},x.prototype.setHistory=function(e){try{this.store.setItem(S,JSON.stringify(e.slice(0,20)))}catch(e){}},x.prototype.clear=function(){try{this.store.removeItem(S)}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||f(),this.store instanceof y||!l()||(new y).removeItem(S)}function C(e,t){return e===r.view?(O(t.contentIdValue),h({location:window.location.toString(),referrer:document.referrer,title:document.title},t)):t}function P(t){return[function(e){return Y.test(e)},function(e){return Q.test(e)},function(e){return-1!==D.indexOf(e)},function(e){return"custom"===e}].some(function(e){return e(t)})}var T=Object.freeze({__proto__:null,STORE_KEY:S,MAX_NUMBER_OF_HISTORY_ELEMENTS:20,MIN_THRESHOLD_FOR_DUPLICATE_VALUE:6e4,MAX_VALUE_SIZE:75,HistoryStore:k,default:k}),O=function(e){var t=new k,n={name:"PageView",value:e,time:JSON.stringify(new Date)};t.addElement(n)},A=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,A)},V=function(e){if(crypto.getRandomValues)return crypto.getRandomValues(e);for(var t=0,n=0;t<e.length;t++)0==(3&t)&&(n=4294967296*Math.random()),e[t]=n>>>((3&t)<<3)&255;return e},R={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",price:"pr",quantity:"qt",coupon:"cc",position:"ps"},_={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"}),L=Object.keys,F=function(o,i,s){return L(o).reduce(function(e,t){var n,r="il"+(i+1)+"pi"+(s+1)+(_[t]||t);return h(h({},e),((n={})[r]=o[t],n))},{})},D=L(j).map(function(e){return j[e]}),N=L(R).map(function(e){return R[e]}),q=L(_).map(function(e){return _[e]}),H=a(N,["custom"]).join("|"),B=a(q,["custom"]).join("|"),M="(pr[0-9]+)",U="(il[0-9]+pi[0-9]+)",Y=new RegExp("^"+M+"("+H+")$"),Q=new RegExp("^("+U+"("+B+"))|(il[0-9]+nm)$"),z=new RegExp("^"+M+"custom$"),W=new RegExp("^"+U+"custom$"),$=function(r,o){return L(o).reduce(function(e,t){var n;return h(h({},e),((n={})[""+r+t]=o[t],n))},{})},G={default:"https://usageanalytics.coveo.com",production:"https://usageanalytics.coveo.com",hipaa:"https://usageanalyticshipaa.coveo.com"},J=(Object.defineProperty(K.prototype,"defaultOptions",{get:function(){return{endpoint:G.default,token:"",version:"v15"}},enumerable:!0,configurable:!0}),K.prototype.initVisitorId=function(){var e=this.visitorId||l()&&this.cookieStorage.getItem("visitorId")||c()&&localStorage.getItem("visitorId")||"";this.currentVisitorId=e||A()},Object.defineProperty(K.prototype,"currentVisitorId",{get:function(){return this.visitorId},set:function(e){this.visitorId=e,l()&&this.cookieStorage.setItem("visitorId",e),c()&&localStorage.setItem("visitorId",e)},enumerable:!0,configurable:!0}),K.prototype.sendEvent=function(d){for(var f=[],e=1;e<arguments.length;e++)f[e-1]=arguments[e];return n(this,void 0,void 0,function(){var t,n,r,o,i,s,a,u,c,l,p=this;return v(this,function(e){switch(e.label){case 0:return t=this.eventTypeMapping[d]||{},r=void 0===(n=t.newEventType)?d:n,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 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 c?L(o=e).reduce(function(e,t){var n,r=j[t]||t;return h(h({},e),((n={})[r]=o[t],n))},{}):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)},f),this.bufferedRequests.push({eventType:r,payload:l,handled:!1}),[4,this.deferExecution()];case 1:return e.sent(),[4,this.sendFromBufferWithFetch()];case 2:return[2,e.sent()]}})})},K.prototype.deferExecution=function(){return new Promise(function(e){return setTimeout(e,0)})},K.prototype.flushBufferWithBeacon=function(){for(;this.hasPendingRequests();){var e=this.bufferedRequests.pop(),t=e.eventType,n=e.payload;this.analyticsBeaconClient.sendEvent(t,n)}},K.prototype.sendFromBufferWithFetch=function(){return n(this,void 0,void 0,function(){var t,n,r;return v(this,function(e){return(t=this.bufferedRequests.shift())?(n=t.eventType,r=t.payload,[2,this.analyticsFetchClient.sendEvent(n,r)]):[2]})})},K.prototype.hasPendingRequests=function(){return 0<this.bufferedRequests.length},K.prototype.sendSearchEvent=function(t){return n(this,void 0,void 0,function(){return v(this,function(e){return[2,this.sendEvent(r.search,t)]})})},K.prototype.sendClickEvent=function(t){return n(this,void 0,void 0,function(){return v(this,function(e){return[2,this.sendEvent(r.click,t)]})})},K.prototype.sendCustomEvent=function(t){return n(this,void 0,void 0,function(){return v(this,function(e){return[2,this.sendEvent(r.custom,t)]})})},K.prototype.sendViewEvent=function(t){return n(this,void 0,void 0,function(){return v(this,function(e){return[2,this.sendEvent(r.view,t)]})})},K.prototype.getVisit=function(){return n(this,void 0,void 0,function(){var t;return v(this,function(e){switch(e.label){case 0:return[4,fetch(this.baseUrl+"/analytics/visit")];case 1:return[4,e.sent().json()];case 2:return t=e.sent(),this.visitorId=t.visitorId,[2,t]}})})},K.prototype.getHealth=function(){return n(this,void 0,void 0,function(){return v(this,function(e){switch(e.label){case 0:return[4,fetch(this.baseUrl+"/analytics/monitoring/health")];case 1:return[4,e.sent().json()];case 2:return[2,e.sent()]}})})},K.prototype.registerBeforeSendEventHook=function(e){this.beforeSendHooks.push(e)},K.prototype.addEventTypeMapping=function(e,t){this.eventTypeMapping[e]=t},K.prototype.parseVariableArgumentsPayload=function(e,t){for(var n={},r=0,o=t.length;r<o;r++){var i=t[r];if("string"==typeof i)n[e[r]]=i;else if("object"==typeof i)return h(h({},n),i)}return n},K.prototype.isKeyAllowedEmpty=function(e,t){var n;return-1!==((n={})[r.search]=["queryText"],(n[e]||[]).indexOf(t))},K.prototype.removeEmptyPayloadValues=function(r,n){var o=this;return Object.keys(r).filter(function(e){return o.isKeyAllowedEmpty(n,e)||null!=(t=r[e])&&""!==t;var t}).reduce(function(e,t){var n;return h(h({},e),((n={})[t]=r[t],n))},{})},K.prototype.removeUnknownParameters=function(r){return Object.keys(r).filter(function(e){if(P(e))return!0;console.log(e,"is not processed by coveoua")}).reduce(function(e,t){var n;return h(h({},e),((n={})[t]=r[t],n))},{})},K.prototype.processCustomParameters=function(e){var i,t=e.custom,n=s(e,["custom"]),r=L(i=n).reduce(function(e,t){var n,r=z.exec(t)||W.exec(t);if(r){var o=r[1];return h(h({},e),$(o,i[t]))}return h(h({},e),((n={})[t]=i[t],n))},{});return h(h({},t||{}),r)},K.prototype.validateParams=function(e){var t=e.anonymizeIp,n=s(e,["anonymizeIp"]);return void 0!==t&&-1==["0","false","undefined","null","{}","[]",""].indexOf((""+t).toLowerCase())&&(n.anonymizeIp=1),n},Object.defineProperty(K.prototype,"baseUrl",{get:function(){var e=this.options,t=e.version;return e.endpoint+"/rest/"+t},enumerable:!0,configurable:!0}),K);function K(e){var t=this;if(!e)throw new Error("You have to pass options to this constructor");this.options=h(h({},this.defaultOptions),e);var n=this.options.token;this.cookieStorage=new y,this.visitorId="",this.bufferedRequests=[],this.beforeSendHooks=[C,b],this.eventTypeMapping={},this.initVisitorId();var r={baseUrl:this.baseUrl,token:n,visitorIdProvider:this};this.analyticsBeaconClient=new o(r),this.analyticsFetchClient=new i(r),window.addEventListener("beforeunload",function(){return t.flushBufferWithBeacon()})}var X=Object.freeze({__proto__:null,Version:"v15",Endpoints:G,CoveoAnalyticsClient:J,default:J}),Z=[!0,"yes","1"].indexOf(navigator.doNotTrack||navigator.msDoNotTrack||window.doNotTrack),ee=Object.freeze({__proto__:null,doNotTrack:Z,default:Z}),te=(ne.prototype.register=function(e,t){this.plugins[e]=t},ne.prototype.execute=function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=this.plugins[e];return o[t].apply(o,n)},ne);function ne(){this.plugins={}}function re(e){return e.protocol+"//"+e.hostname+(0===e.pathname.indexOf("/")?e.pathname:"/"+e.pathname)+e.search}var oe={pageview:"pageview",event:"event"},ie=Object.keys(oe).map(function(e){return oe[e]}),se=(ae.prototype.addProduct=function(e){this.products.push(e)},ae.prototype.addImpression=function(e){this.impressions.push(e)},ae.prototype.setAction=function(e,t){this.action=e,this.actionData=t},ae.prototype.clearData=function(){this.products=[],this.impressions=[],this.action=void 0,this.actionData={}},ae.prototype.addHooksForECEvents=function(){var o=this;this.client.registerBeforeSendEventHook(function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=t[0];return-1!==ie.indexOf(e)?o.addECDataToPayload(e,r):r})},ae.prototype.addHooksForPageView=function(){this.client.addEventTypeMapping(oe.pageview,{newEventType:r.collect,variableLengthArgumentsNames:["page"],addVisitorIdParameter:!0,usesMeasurementProtocol:!0})},ae.prototype.addHooksForEvent=function(){this.client.addEventTypeMapping(oe.event,{newEventType:r.collect,variableLengthArgumentsNames:["eventCategory","eventAction","eventLabel","eventValue"],addVisitorIdParameter:!0,usesMeasurementProtocol:!0})},ae.prototype.addECDataToPayload=function(e,t){var n=h(h(h(h({},this.getLocationInformation(e,t)),this.getDefaultContextInformation(e)),this.action?{action:this.action}:{}),this.actionData||{}),r=this.products.reduce(function(e,t,n){return h(h({},e),(i=n,L(o=t).reduce(function(e,t){var n,r="pr"+(i+1)+(R[t]||t);return h(h({},e),((n={})[r]=o[t],n))},{})));var o,i},{}),o=this.getImpressionsByList().reduce(function(e,t,n){return h(h({},e),function(e,r){var t=e.impressions.reduce(function(e,t,n){return h(h({},e),F(t,r,n))},{});return e.listName&&(t["il"+(r+1)+"nm"]=e.listName),t}(t,n))},{});return this.clearData(),h(h(h(h({},o),r),n),t)},ae.prototype.getImpressionsByList=function(){return this.impressions.reduce(function(e,t){var n=t.list,r=s(t,["list"]),o=e.find(function(e){return e.listName===n});return o?o.impressions.push(r):e.push({listName:n,impressions:[r]}),e},[])},ae.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=re(window.location),this.hasSentFirstPageView=!0},ae.prototype.getLocationInformation=function(e,t){return e===oe.pageview&&this.updateStateForNewPageView(t),{referrer:this.lastReferrer,location:this.lastLocation}},ae.prototype.getDefaultContextInformation=function(e){var t={hitType:e,pageViewId:this.pageViewId},n={title:document.title,encoding:document.characterSet},r={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),r),o),n)},ae);function ae(e){var t=e.client,n=e.uuidGenerator,r=void 0===n?A:n;this.products=[],this.impressions=[],this.actionData={},this.client=t,this.uuidGenerator=r,this.pageViewId=r(),this.lastLocation=re(window.location),this.lastReferrer=document.referrer,this.addHooksForPageView(),this.addHooksForEvent(),this.addHooksForECEvents()}var ue=(ce.prototype.init=function(e,t){var n=this;if(!e)throw new Error("You must pass your token when you call 'init'");if("string"==typeof e?(t=t||G.default,this.client=new J({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 se({client:this.client})),this.client.registerBeforeSendEventHook(function(e,t){return h(h({},t),n.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 J({endpoint:e})},ce.prototype.set=function(t,e){var n=this;"string"==typeof t?this.params[t]=e:Object.keys(t).map(function(e){n.params[e]=t[e]})},ce.prototype.send=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=t[0],o=t.slice(1);if(void 0===this.client)throw new Error("You must call init before sending an event");if(!r)throw new Error('You must provide an event type when calling "send".');return(e=this.client).sendEvent.apply(e,a([r.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 n,r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];(n=this.plugins).execute.apply(n,a([e,t],r))},ce.prototype.reset=function(){this.client=void 0,this.plugins=new te,this.params={}},ce);function ce(){this.plugins=new te,this.params={}}function le(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=/^(?:(\w+)\.)?(?:(\w+):)?(\w+)$/.exec(e),o=(r[1],r[2]),i=r[3],s=he[i];if(o&&i)return he.callPlugin.apply(he,a([o,i],t));if(s)return s.apply(he,t);throw new Error('The action "'+e+'" does not exist. Available actions: '+["init","set","send","onLoad","callPlugin"].join(", ")+".")}var pe,de,fe,he=new ue,ve=Object.freeze({__proto__:null,CoveoUA:ue,coveoua:he,handleOneAnalyticsEvent:le,default:le});(fe=de=de||{}).interfaceLoad="interfaceLoad",fe.interfaceChange="interfaceChange",fe.didyoumeanAutomatic="didyoumeanAutomatic",fe.didyoumeanClick="didyoumeanClick",fe.resultsSort="resultsSort",fe.searchboxSubmit="searchboxSubmit",fe.searchboxClear="searchboxClear",fe.searchboxAsYouType="searchboxAsYouType",fe.breadcrumbFacet="breadcrumbFacet",fe.breadcrumbResetAll="breadcrumbResetAll",fe.documentQuickview="documentQuickview",fe.documentOpen="documentOpen",fe.omniboxAnalytics="omniboxAnalytics",fe.omniboxFromLink="omniboxFromLink",fe.triggerNotify="notify",fe.triggerExecute="execute",fe.triggerQuery="query",fe.triggerRedirect="redirect";var ye=((pe={})[de.triggerNotify]="queryPipelineTriggers",pe[de.triggerExecute]="queryPipelineTriggers",pe[de.triggerQuery]="queryPipelineTriggers",pe[de.triggerRedirect]="queryPipelineTriggers",pe),ge=(me.prototype.logInterfaceLoad=function(){return this.logSearchEvent(de.interfaceLoad)},me.prototype.logInterfaceChange=function(e){return this.logSearchEvent(de.interfaceChange,e)},me.prototype.logDidYouMeanAutomatic=function(){return this.logSearchEvent(de.didyoumeanAutomatic)},me.prototype.logDidYouMeanClick=function(){return this.logSearchEvent(de.didyoumeanClick)},me.prototype.logResultsSort=function(e){return this.logSearchEvent(de.resultsSort,e)},me.prototype.logSearchboxSubmit=function(){return this.logSearchEvent(de.searchboxSubmit)},me.prototype.logSearchboxClear=function(){return this.logSearchEvent(de.searchboxClear)},me.prototype.logSearchboxAsYouType=function(){return this.logSearchEvent(de.searchboxAsYouType)},me.prototype.logBreadcrumbFacet=function(e){return this.logSearchEvent(de.breadcrumbFacet,e)},me.prototype.logBreadcrumbResetAll=function(){return this.logSearchEvent(de.breadcrumbResetAll)},me.prototype.logDocumentQuickview=function(e,t){return this.logClickEvent(de.documentQuickview,e,t)},me.prototype.logDocumentOpen=function(e,t){return this.logClickEvent(de.documentOpen,e,t)},me.prototype.logOmniboxAnalytics=function(e){return this.logSearchEvent(de.omniboxAnalytics,e)},me.prototype.logOmniboxFromLink=function(e){return this.logSearchEvent(de.omniboxFromLink,e)},me.prototype.logTriggerNotify=function(e){return this.logCustomEvent(de.triggerNotify,e)},me.prototype.logTriggerExecute=function(e){return this.logCustomEvent(de.triggerExecute,e)},me.prototype.logTriggerQuery=function(){var e={query:this.provider.getSearchEventRequestPayload().queryText};return this.logCustomEvent(de.triggerQuery,e)},me.prototype.logTriggerRedirect=function(e){var t=h(h({},e),{query:this.provider.getSearchEventRequestPayload().queryText});return this.logCustomEvent(de.triggerRedirect,t)},me.prototype.logCustomEvent=function(e,t){var n=h(h({},this.provider.getBaseMetadata()),t),r={eventType:ye[e],eventValue:e,lastSearchQueryUid:this.provider.getSearchUID(),customData:n};return this.coveoAnalyticsClient.sendCustomEvent(r)},me.prototype.logSearchEvent=function(e,t){var n=h(h({},this.provider.getBaseMetadata()),t),r=h(h({},this.provider.getSearchEventRequestPayload()),{searchQueryUid:this.provider.getSearchUID(),customData:n,actionCause:e});return this.coveoAnalyticsClient.sendSearchEvent(r)},me.prototype.logClickEvent=function(e,t,n,r){var o=h(h(h({},this.provider.getBaseMetadata()),n),r),i=h(h({},t),{searchQueryUid:this.provider.getSearchUID(),actionCause:e,customData:o});return this.coveoAnalyticsClient.sendClickEvent(i)},me);function me(e,t){this.opts=e,this.provider=t,this.coveoAnalyticsClient=new J(e)}var we=Object.freeze({__proto__:null,analytics:X,donottrack:ee,history:T,SimpleAnalytics:ve,storage:E,CoveoAnalyticsClient:J,CoveoUA:ue,handleOneAnalyticsEvent:le,CoveoSearchPageClient:ge});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 be=self.coveoua||le;self.coveoua=le,self.coveoanalytics=we,be.q&&a(be.q.filter(function(e){return"init"===e[0]}),be.q.filter(function(e){return"init"!==e[0]})).forEach(function(e){return le.apply(void 0,e)});return be}); | ||
//# sourceMappingURL=library.js.map |
{ | ||
"name": "coveo.analytics", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "📈 Coveo analytics client (node and browser compatible) ", | ||
"main": "dist/library.js", | ||
"module": "dist/library.es.js", | ||
"browser": "dist/coveoua.js", | ||
"types": "dist/definitions/coveoua/library.d.ts", | ||
"browser": "dist/coveoua.js", | ||
"scripts": { | ||
"lint": "prettier **/*.* --write", | ||
"build": "webpack", | ||
"start": "webpack-dev-server --port 9001 --mode development --watch --inline --hot", | ||
"build": "rollup -c", | ||
"start": "rollup -c -w --environment SERVE", | ||
"test": "jest --clearCache && jest --coverage", | ||
@@ -40,9 +41,10 @@ "clean": "rm -rf dist/* && rm -rf dist_test/* && rm -rf coverage/*" | ||
"prettier": "^1.19.1", | ||
"rollup": "^2.7.3", | ||
"rollup-plugin-serve": "^1.0.1", | ||
"rollup-plugin-terser": "^5.3.0", | ||
"rollup-plugin-typescript2": "^0.27.0", | ||
"rollup-plugin-uglify": "^6.0.4", | ||
"ts-jest": "^25.2.0", | ||
"ts-loader": "^4.5.0", | ||
"tsjs": "^1.0.3", | ||
"typescript": "^3.7.5", | ||
"webpack": "^4.41.5", | ||
"webpack-cli": "^3.3.10", | ||
"webpack-dev-server": "^3.10.2" | ||
"typescript": "^3.8.3" | ||
}, | ||
@@ -56,4 +58,3 @@ "files": [ | ||
], | ||
"dependencies": {}, | ||
"prettier": "tsjs/prettier-config" | ||
} |
@@ -146,2 +146,8 @@ # ![coveo.analytics](./assets/coveo.analytics.js.png) | ||
There are two ways to run your code locally: | ||
1. run `npm start` and open your browser on http://localhost:9001 | ||
2. run through VSCode debugger with the `Debug: Start Debugging` command, using the `Launch Chrome` configuration. | ||
To test out your changes, add a new function calls in the `public/index.html` file and check the payload in `Developer Console` of your browser | ||
### License | ||
@@ -148,0 +154,0 @@ |
@@ -137,2 +137,16 @@ import * as fetchMock from 'fetch-mock'; | ||
it('should not remove #queryText for search events even if empty', async () => { | ||
mockFetchRequestForEventType(EventType.search); | ||
await client.sendEvent(EventType.search, { | ||
queryText: "", | ||
}); | ||
const [body] = getParsedBodyCalls(); | ||
expect(body).toMatchObject({ | ||
queryText: "", | ||
}); | ||
}); | ||
describe('with event type mapping with variable arguments', () => { | ||
@@ -139,0 +153,0 @@ const specialEventType = '🌟special🌟'; |
@@ -25,3 +25,3 @@ import {AnalyticsBeaconClient} from './analyticsBeaconClient'; | ||
import {uuidv4} from './crypto'; | ||
import {convertKeysToMeasurementProtocol, isMeasurementProtocolKey} from './measurementProtocolMapper'; | ||
import {convertKeysToMeasurementProtocol, isMeasurementProtocolKey, convertCustomMeasurementProtocolKeys} from './measurementProtocolMapper'; | ||
@@ -161,3 +161,3 @@ export const Version = 'v15'; | ||
this.beforeSendHooks.reduce((newPayload, current) => current(eventType, newPayload), currentPayload); | ||
const cleanPayloadStep: ProcessPayloadStep = (currentPayload) => this.removeEmptyPayloadValues(currentPayload); | ||
const cleanPayloadStep: ProcessPayloadStep = (currentPayload) => this.removeEmptyPayloadValues(currentPayload, eventType); | ||
const validateParams: ProcessPayloadStep = (currentPayload) => this.validateParams(currentPayload); | ||
@@ -168,2 +168,4 @@ const processMeasurementProtocolConversionStep: ProcessPayloadStep = (currentPayload) => | ||
usesMeasurementProtocol ? this.removeUnknownParameters(currentPayload) : currentPayload; | ||
const processCustomParameters: ProcessPayloadStep = (currentPayload) => | ||
usesMeasurementProtocol ? this.processCustomParameters(currentPayload) : currentPayload; | ||
@@ -178,2 +180,3 @@ const payloadToSend = [ | ||
removeUnknownParameters, | ||
processCustomParameters, | ||
].reduce((payload, step) => step(payload), payload); | ||
@@ -267,6 +270,15 @@ | ||
private removeEmptyPayloadValues(payload: IRequestPayload): IRequestPayload { | ||
private isKeyAllowedEmpty(evtType: string, key: string) { | ||
const keysThatCanBeEmpty: Record<string, string[]> = { | ||
[EventType.search]: ['queryText'], | ||
}; | ||
const match = keysThatCanBeEmpty[evtType] || []; | ||
return match.indexOf(key) !== -1 | ||
} | ||
private removeEmptyPayloadValues(payload: IRequestPayload, eventType: string): IRequestPayload { | ||
const isNotEmptyValue = (value: any) => typeof value !== 'undefined' && value !== null && value !== ''; | ||
return Object.keys(payload) | ||
.filter((key) => isNotEmptyValue(payload[key])) | ||
.filter((key) => this.isKeyAllowedEmpty(eventType, key) || isNotEmptyValue(payload[key])) | ||
.reduce( | ||
@@ -287,3 +299,3 @@ (newPayload, key) => ({ | ||
} else { | ||
console.log(key, 'is not processsed by coveoua'); | ||
console.log(key, 'is not processed by coveoua'); | ||
} | ||
@@ -301,2 +313,13 @@ }) | ||
private processCustomParameters(payload: IRequestPayload): IRequestPayload { | ||
const {custom, ...rest} = payload; | ||
const newPayload = convertCustomMeasurementProtocolKeys(rest); | ||
return { | ||
...(custom || {}), | ||
...newPayload | ||
}; | ||
} | ||
private validateParams(payload: IRequestPayload): IRequestPayload { | ||
@@ -303,0 +326,0 @@ const {anonymizeIp, ...rest} = payload; |
@@ -146,13 +146,48 @@ import {EC, Product, ImpressionList, BaseImpression} from '../plugins/ec'; | ||
const productSubKeysMatchGroup = productKeysMappingValues.join('|'); | ||
const impressSubKeysMatchGroup = impressionKeysMappingValues.join('|'); | ||
const productKeyRegex = new RegExp(`^(pr[0-9]+)(${productSubKeysMatchGroup})$`); | ||
const impressionKeyRegex = new RegExp(`^((il[0-9]+pi[0-9]+)(${impressSubKeysMatchGroup}))|(il[0-9]+nm)$`); | ||
const productSubKeysMatchGroup = [...productKeysMappingValues, "custom"].join('|'); | ||
const impressionSubKeysMatchGroup = [...impressionKeysMappingValues, "custom"].join('|'); | ||
const productPrefixMatchGroup = "(pr[0-9]+)"; | ||
const impressionPrefixMatchGroup = "(il[0-9]+pi[0-9]+)"; | ||
const productKeyRegex = new RegExp(`^${productPrefixMatchGroup}(${productSubKeysMatchGroup})$`); | ||
const impressionKeyRegex = new RegExp(`^(${impressionPrefixMatchGroup}(${impressionSubKeysMatchGroup}))|(il[0-9]+nm)$`); | ||
const customProductKeyRegex = new RegExp(`^${productPrefixMatchGroup}custom$`); | ||
const customImpressionKeyRegex = new RegExp(`^${impressionPrefixMatchGroup}custom$`); | ||
const isProductKey = (key: string) => productKeyRegex.test(key); | ||
const isImpressionKey = (key: string) => impressionKeyRegex.test(key); | ||
const isKnownMeasurementProtocolKey = (key: string) => measurementProtocolKeysMappingValues.indexOf(key) !== -1 | ||
const isCustomKey = (key: string) => key === "custom"; | ||
export const isMeasurementProtocolKey = (key: string): boolean => { | ||
return ( | ||
productKeyRegex.test(key) || | ||
impressionKeyRegex.test(key) || | ||
measurementProtocolKeysMappingValues.indexOf(key) != -1 | ||
); | ||
return [ | ||
isProductKey, | ||
isImpressionKey, | ||
isKnownMeasurementProtocolKey, | ||
isCustomKey | ||
].some(test => test(key)); | ||
}; | ||
export const convertCustomMeasurementProtocolKeys = (data: {[name: string]: string | {[name:string] :string}}) => { | ||
return keysOf(data).reduce((all, current) => { | ||
const match = customProductKeyRegex.exec(current) || customImpressionKeyRegex.exec(current); | ||
if (match) { | ||
const originalKey = match[1]; | ||
return { | ||
...all, | ||
...convertCustomObject(originalKey, data[current] as {[name: string]: string}) | ||
} | ||
} else { | ||
return { | ||
...all, | ||
[current]: data[current] | ||
} | ||
} | ||
}, {}); | ||
} | ||
const convertCustomObject = (prefix: string, customData: {[name: string]: string}) => { | ||
return keysOf(customData).reduce((allCustom, currentCustomKey) => ({ | ||
...allCustom, | ||
[`${prefix}${currentCustomKey}`]: customData[currentCustomKey] | ||
}), {}); | ||
} |
import * as analytics from './library'; | ||
import handleOneAnalyticsEvent from './simpleanalytics'; | ||
declare const global: any; | ||
declare const self: any; | ||
@@ -29,8 +29,8 @@ const promise = (window as any)['Promise']; | ||
// on `window` in a browser | ||
const coveoua: CoveoUAGlobal = global.coveoua || handleOneAnalyticsEvent; | ||
const coveoua: CoveoUAGlobal = self.coveoua || handleOneAnalyticsEvent; | ||
// Replace the quick shim with the real thing. | ||
global.coveoua = handleOneAnalyticsEvent; | ||
self.coveoua = handleOneAnalyticsEvent; | ||
global.coveoanalytics = analytics; | ||
self.coveoanalytics = analytics; | ||
@@ -37,0 +37,0 @@ // On normal execution this library should be loaded after the snippet execution |
@@ -8,3 +8,4 @@ import * as analytics from '../client/analytics'; | ||
export {CoveoUA, handleOneAnalyticsEvent} from './simpleanalytics'; | ||
export {CoveoSearchPageClient,SearchPageClientProvider} from '../searchPage/searchPageClient' | ||
export {analytics, donottrack, history, SimpleAnalytics, storage}; |
@@ -28,3 +28,3 @@ export type IRequestPayload = Record<string, any>; | ||
userAgent?: string; | ||
customData?: any; | ||
customData?: Record<string, any>; | ||
anonymous?: boolean; | ||
@@ -54,3 +54,3 @@ username?: string; | ||
export interface ClickEventRequest extends EventBaseRequest { | ||
export interface DocumentInformation { | ||
documentUri: string; | ||
@@ -63,10 +63,12 @@ documentUriHash: string; | ||
searchQueryUid?: string; | ||
documentTitle?: string; | ||
documentUrl?: string; | ||
documentAuthor?: string; | ||
queryPipeline?: string; | ||
rankingModifier?: string; | ||
searchQueryUid: string; | ||
documentTitle: string; | ||
documentUrl: string; | ||
documentAuthor: string; | ||
queryPipeline: string; | ||
rankingModifier: string; | ||
} | ||
export interface ClickEventRequest extends EventBaseRequest, DocumentInformation {} | ||
export interface CustomEventRequest extends EventBaseRequest { | ||
@@ -73,0 +75,0 @@ eventType: string; |
@@ -83,2 +83,10 @@ import {EC, ECPluginEventTypes} from './ec'; | ||
it('should keep custom metadata in the product', () => { | ||
ec.addProduct({name: '🧀', price: 5.99, custom: {verycustom: 'value'}}); | ||
const result = executeRegisteredHook(ECPluginEventTypes.event, {}); | ||
expect(result).toEqual({...defaultResult, pr1nm: '🧀', pr1pr: 5.99, pr1custom: {verycustom: 'value'}}); | ||
}); | ||
it('should allow adding multiple products', () => { | ||
@@ -167,2 +175,15 @@ ec.addProduct({name: '🍟', price: 1.99}); | ||
it('should keep custom metadata in the impression', () => { | ||
ec.addImpression({name: '🧀', price: 5.99, custom: {verycustom: 'value'}}); | ||
const result = executeRegisteredHook(ECPluginEventTypes.event, {}); | ||
expect(result).toEqual({ | ||
...defaultResult, | ||
il1pi1nm: '🧀', | ||
il1pi1pr: 5.99, | ||
il1pi1custom: {verycustom: 'value'}, | ||
}); | ||
}); | ||
it('should allow adding multiple impressions', () => { | ||
@@ -169,0 +190,0 @@ ec.addImpression({name: '🍟', price: 1.99}); |
@@ -25,2 +25,6 @@ import {AnalyticsClient} from '../client/analytics'; | ||
export type CustomValues = { | ||
[key: string]: string | number | boolean; | ||
}; | ||
export interface ProductProperties { | ||
@@ -36,2 +40,3 @@ id?: string; | ||
position?: number; | ||
custom?: CustomValues; | ||
} | ||
@@ -50,2 +55,3 @@ | ||
price?: number; | ||
custom?: CustomValues; | ||
} | ||
@@ -52,0 +58,0 @@ |
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
Mixed license
License(Experimental) Package contains multiple licenses.
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
457181
60
3140
158
26
1
9