//////////////////////////////////////////// ;(function (packageFunction) { /* istanbul ignore next */ var p = window.AmazonUIPageJS || window.P; /* istanbul ignore next */ var attribute = p._namespace || p.attributeErrors; /* istanbul ignore next */ var namespacedP = attribute ? attribute("CPSContextJSBuzzWrapper", "") : p; /* istanbul ignore next */ if (namespacedP.guardFatal) { namespacedP.guardFatal(packageFunction)(namespacedP, window); } else { namespacedP.execute(function () { packageFunction(namespacedP, window); }); } }(function(P, window, undefined){ // BEGIN ASSET CPSContextJSBuzzWrapper - 1.0 ///////////////////////// // BEGIN FILE placeholder.js ///////////////////////// /* Full source (including license, if applicable) included below. */ /****** Empty place holder file as required by Buzz */ ///////////////////////// // END FILE placeholder.js ///////////////////////// ///////////////////////// // BEGIN FILE app.js ///////////////////////// /* Full source (including license, if applicable) included below. */ "use strict";var t,e=function(){function t(t){this.clientIdentifier=t}return t.prototype.publishContextEventsToSushi=function(t,e,n){var i=this,o={events:[]};o.events=e.map((function(t){return{data:t}}));try{if(n)return void this.useNavigatorSendBeacon(t,o)}catch(t){this.publishToCSM("errorSendingEventToSushiUsingSendBeacon-".concat(this.clientIdentifier))}try{var r={method:"POST",headers:{"Content-Type":"application/json"},keepalive:!0,body:JSON.stringify(o)};fetch(t,r).then((function(t){200!==t.status&&i.publishToCSM("".concat(t.status,"-errorSendingEventToSushi-").concat(i.clientIdentifier))})).catch((function(t){i.publishToCSM("errorSendingEventToSushi-".concat(i.clientIdentifier))}))}catch(t){console.warn("Error serializing and sending data to sushi. "+t.message),this.publishToCSM("errorSendingEventToSushi-".concat(this.clientIdentifier))}},t.prototype.useNavigatorSendBeacon=function(t,e){navigator.sendBeacon(t,JSON.stringify(e))},t.prototype.publishContextEventToSushi=function(t,e,n){this.publishContextEventsToSushi(t,[e],n)},t.prototype.publishToCSM=function(t){var e=window.ue;e&&e.count&&e.count(t,1)},t}(),n=new Uint8Array(16);function i(){if(!t&&!(t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return t(n)}var o=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function r(t){return"string"==typeof t&&o.test(t)}for(var s=[],a=0;a<256;++a)s.push((a+256).toString(16).substr(1));function c(t,e,n){var o=(t=t||{}).random||(t.rng||i)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,e){n=n||0;for(var a=0;a<16;++a)e[n+a]=o[a];return e}return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(s[t[e+0]]+s[t[e+1]]+s[t[e+2]]+s[t[e+3]]+"-"+s[t[e+4]]+s[t[e+5]]+"-"+s[t[e+6]]+s[t[e+7]]+"-"+s[t[e+8]]+s[t[e+9]]+"-"+s[t[e+10]]+s[t[e+11]]+s[t[e+12]]+s[t[e+13]]+s[t[e+14]]+s[t[e+15]]).toLowerCase();if(!r(n))throw TypeError("Stringified UUID is invalid");return n}(o)}var u=["customerId","marketplaceId","locale","timestamp","eventCategory","eventType","eventData"],l=function(){function t(t,e){this.metricsCollector=t,this.clientIdentifier=e}return t.prototype.publishContextToSushi=function(t,e,n){if(t)if(0!==Object.keys(e).length&&this.isValidEvent(e)){"1"===(null==e?void 0:e.customerId)?this.metricsCollector.publishToCSM("unauthContextEvent-".concat(this.clientIdentifier)):this.metricsCollector.publishToCSM("authContextEvent-".concat(this.clientIdentifier));var i={customerId:e.customerId,sessionId:e.sessionId,marketplaceId:e.marketplaceId,locale:e.locale,timestamp:e.timestamp,eventCategory:e.eventCategory,eventType:e.eventType,eventData:e.eventData,eventId:e.eventId||c()};this.metricsCollector.publishContextEventToSushi(t,i,n)}else this.metricsCollector.publishToCSM("invalidContextEvent-".concat(this.clientIdentifier));else this.metricsCollector.publishToCSM("invalidSushiEndpoint-".concat(this.clientIdentifier))},t.prototype.isValidEvent=function(t){return u.every((function(e){var n=e;return null!==t[n]&&""!==t[n]}))},t}();P&&P.AUI_BUILD_DATE&&(P.register("MetricsCollector",(function(){return e})),P.register("ContextPublisher",(function(){return l}))); //# sourceMappingURL=index.js.map ///////////////////////// // END FILE app.js ///////////////////////// // END ASSET CPSContextJSBuzzWrapper - 1.0 })); ////////////////////////////////////////////