@datadog/browser-logs
Advanced tools
Comparing version 4.25.0 to 4.26.0
@@ -1,1 +0,1 @@ | ||
!function(){"use strict";var e={log:"log",debug:"debug",info:"info",warn:"warn",error:"error"},t=function(n){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];Object.prototype.hasOwnProperty.call(e,n)||(n=e.log),t[n].apply(t,r)};function n(e,n){return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];try{return e.apply(void 0,r)}catch(e){t.error(n,e)}}}t.debug=console.debug.bind(console),t.log=console.log.bind(console),t.info=console.info.bind(console),t.warn=console.warn.bind(console),t.error=console.error.bind(console);var r,o=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))},i=!1;function s(e){i=e}function a(e,t,n){var o=n.value;n.value=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=r?u(o):o;return n.apply(this,e)}}function u(e){return function(){return c(e,this,arguments)}}function c(t,n,o){try{return t.apply(n,o)}catch(t){if(f(e.error,t),r)try{r(t)}catch(t){f(e.error,t)}}}function f(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];i&&t.apply(void 0,o([e,"[MONITOR]"],n,!1))}var l=1e3,d=6e4;function p(e,t,n){var r,o,i=!n||void 0===n.leading||n.leading,s=!n||void 0===n.trailing||n.trailing,a=!1;return{throttled:function(){for(var n=[],u=0;u<arguments.length;u++)n[u]=arguments[u];a?r=n:(i?e.apply(void 0,n):r=n,a=!0,o=setTimeout((function(){s&&r&&e.apply(void 0,r),a=!1,r=void 0}),t))},cancel:function(){clearTimeout(o),a=!1,r=void 0}}}function v(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return t.forEach((function(t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})),e}function g(e){return e?(parseInt(e,10)^16*Math.random()>>parseInt(e,10)/4).toString(16):"".concat(1e7,"-").concat(1e3,"-").concat(4e3,"-").concat(8e3,"-").concat(1e11).replace(/[018]/g,g)}function h(e){return 0!==e&&100*Math.random()<=e}function y(){}function m(e,t,n){if("object"!=typeof e||null===e)return JSON.stringify(e);var r=b(Object.prototype),o=b(Array.prototype),i=b(Object.getPrototypeOf(e)),s=b(e);try{return JSON.stringify(e,t,n)}catch(e){return"<error: unable to serialize object>"}finally{r(),o(),i(),s()}}function b(e){var t=e,n=t.toJSON;return n?(delete t.toJSON,function(){t.toJSON=n}):y}function w(e,t){return-1!==e.indexOf(t)}function C(e){if(Array.from)return Array.from(e);var t=[];if(e instanceof Set)e.forEach((function(e){return t.push(e)}));else for(var n=0;n<e.length;n++)t.push(e[n]);return t}function k(e){return function(e){return"number"==typeof e}(e)&&e>=0&&e<=100}function x(e){return Object.keys(e).map((function(t){return e[t]}))}function S(e){return 0===Object.keys(e).length}function E(e,t){return e.slice(0,t.length)===t}function R(){if("object"==typeof globalThis)return globalThis;Object.defineProperty(Object.prototype,"_dd_temp_",{get:function(){return this},configurable:!0});var e=_dd_temp_;return delete Object.prototype._dd_temp_,"object"!=typeof e&&(e="object"==typeof self?self:"object"==typeof window?window:{}),e}function T(e,t,n){void 0===n&&(n="");var r=e.charCodeAt(t-1),o=r>=55296&&r<=56319?t+1:t;return e.length<=o?e:"".concat(e.slice(0,o)).concat(n)}function _(e,t,n,r){return L(e,[t],n,r)}function L(e,t,n,r){var o=void 0===r?{}:r,i=o.once,s=o.capture,a=o.passive,c=u(i?function(e){l(),n(e)}:n),f=a?{capture:s,passive:a}:s;t.forEach((function(t){return e.addEventListener(t,c,f)}));var l=function(){return t.forEach((function(t){return e.removeEventListener(t,c,f)}))};return{stop:l}}function O(e){return null===e?"null":Array.isArray(e)?"array":typeof e}function B(e,t,n){if(void 0===n&&(n=function(){if("undefined"!=typeof WeakSet){var e=new WeakSet;return{hasAlreadyBeenSeen:function(t){var n=e.has(t);return n||e.add(t),n}}}var t=[];return{hasAlreadyBeenSeen:function(e){var n=t.indexOf(e)>=0;return n||t.push(e),n}}}()),void 0===t)return e;if("object"!=typeof t||null===t)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){var r=t.flags||[t.global?"g":"",t.ignoreCase?"i":"",t.multiline?"m":"",t.sticky?"y":"",t.unicode?"u":""].join("");return new RegExp(t.source,r)}if(!n.hasAlreadyBeenSeen(t)){if(Array.isArray(t)){for(var o=Array.isArray(e)?e:[],i=0;i<t.length;++i)o[i]=B(o[i],t[i],n);return o}var s="object"===O(e)?e:{};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(s[a]=B(s[a],t[a],n));return s}}function M(e){return B(void 0,e)}function P(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];for(var r=0,o=t;r<o.length;r++){var i=o[r];null!=i&&(e=B(e,i))}return e}function q(){var e={};return{get:function(){return e},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},set:function(t){e=t},getContext:function(){return M(e)},setContext:function(t){e=M(t)},setContextProperty:function(t,n){e[t]=M(n)},removeContextProperty:function(t){delete e[t]},clearContext:function(){e={}}}}var I,A=function(){function e(){this.buffer=[]}return e.prototype.add=function(e){this.buffer.push(e)>500&&this.buffer.splice(0,1)},e.prototype.drain=function(){this.buffer.forEach((function(e){return e()})),this.buffer.length=0},e}();function U(){return(new Date).getTime()}function j(){return U()}function D(){return performance.now()}function F(){return{relative:D(),timeStamp:j()}}function N(e,t){return t-e}function H(){return void 0===I&&(I=performance.timing.navigationStart),I}function G(){var e=R().DatadogEventBridge;if(e)return{getAllowedWebViewHosts:function(){return JSON.parse(e.getAllowedWebViewHosts())},send:function(t,n){e.send(JSON.stringify({eventType:t,event:n}))}}}function z(e){var t;void 0===e&&(e=null===(t=R().location)||void 0===t?void 0:t.hostname);var n=G();return!!n&&n.getAllowedWebViewHosts().some((function(t){return e===t||(n=e,r=".".concat(t),n.slice(-r.length)===r);var n,r}))}function V(e){var t=v({},e);return["id","name","email"].forEach((function(e){e in t&&(t[e]=String(t[e]))})),t}var $,J,W;function X(e,t,n,r){var o=new Date;o.setTime(o.getTime()+n);var i="expires=".concat(o.toUTCString()),s=r&&r.crossSite?"none":"strict",a=r&&r.domain?";domain=".concat(r.domain):"",u=r&&r.secure?";secure":"";document.cookie="".concat(e,"=").concat(t,";").concat(i,";path=/;samesite=").concat(s).concat(a).concat(u)}function Y(e){return function(e,t){var n=new RegExp("(?:^|;)\\s*".concat(t,"\\s*=\\s*([^;]+)")).exec(e);return n?n[1]:void 0}(document.cookie,e)}function K(e,t){X(e,"",0,t)}function Q(){return J||new Set}function Z(e){return ee(e,function(e){if(e.origin)return e.origin;var t=e.host.replace(/(:80|:443)$/,"");return"".concat(e.protocol,"//").concat(t)}(window.location)).href}function ee(e,t){if(function(){if(void 0!==W)return W;try{var e=new URL("http://test/path");return W="http://test/path"===e.href}catch(e){W=!1}return W}())return void 0!==t?new URL(e,t):new URL(e);if(void 0===t&&!/:/.test(e))throw new Error("Invalid URL: '".concat(e,"'"));var n=document,r=n.createElement("a");if(void 0!==t){var o=(n=document.implementation.createHTMLDocument("")).createElement("base");o.href=t,n.head.appendChild(o),n.body.appendChild(r)}return r.href=e,r}var te="datadoghq.com",ne={logs:"logs",rum:"rum",sessionReplay:"session-replay"},re={logs:"logs",rum:"rum",sessionReplay:"replay"};function oe(e,t,n){var r=e.site,o=void 0===r?te:r,i=e.clientToken,s=o.split("."),a=s.pop(),u="".concat(ne[t],".browser-intake-").concat(s.join("-"),".").concat(a),c="https://".concat(u,"/api/v2/").concat(re[t]),f=e.proxyUrl&&Z(e.proxyUrl);return{build:function(e){var r=["sdk_version:".concat("4.25.0")].concat(n);e&&r.push("retry_count:".concat(e.count),"retry_after:".concat(e.lastFailureStatus));var o="ddsource=browser"+"&ddtags=".concat(encodeURIComponent(r.join(",")))+"&dd-api-key=".concat(i)+"&dd-evp-origin-version=".concat(encodeURIComponent("4.25.0"))+"&dd-evp-origin=browser"+"&dd-request-id=".concat(g());"rum"===t&&(o+="&batch_time=".concat(j()));var s="".concat(c,"?").concat(o);return f?"".concat(f,"?ddforward=").concat(encodeURIComponent(s)):s},buildIntakeUrl:function(){return f?"".concat(f,"?ddforward"):c},endpointType:t}}var ie=/[^a-z0-9_:./-]/;function se(e,n){var r=200-e.length-1;(n.length>r||ie.test(n))&&t.warn("".concat(e," value doesn't meet tag requirements and will be sanitized"));var o=n.replace(/,/g,"_");return"".concat(e,":").concat(o)}function ae(e){var t=function(e){var t=e.env,n=e.service,r=e.version,o=e.datacenter,i=[];return t&&i.push(se("env",t)),n&&i.push(se("service",n)),r&&i.push(se("version",r)),o&&i.push(se("datacenter",o)),i}(e),n=function(e,t){return{logsEndpointBuilder:oe(e,"logs",t),rumEndpointBuilder:oe(e,"rum",t),sessionReplayEndpointBuilder:oe(e,"sessionReplay",t)}}(e,t),r=x(n).map((function(e){return e.buildIntakeUrl()})),o=function(e,t,n){if(!e.replica)return;var r=v({},e,{site:te,clientToken:e.replica.clientToken}),o={logsEndpointBuilder:oe(r,"logs",n),rumEndpointBuilder:oe(r,"rum",n)};return t.push.apply(t,x(o).map((function(e){return e.buildIntakeUrl()}))),v({applicationId:e.replica.applicationId},o)}(e,r,t);return v({isIntakeUrl:function(e){return r.some((function(t){return 0===e.indexOf(t)}))},replica:o,site:e.site||te},n)}function ue(e){var r,o,i;if(e&&e.clientToken)if(void 0===e.sampleRate||k(e.sampleRate))if(void 0===e.telemetrySampleRate||k(e.telemetrySampleRate)){var s;if(void 0===e.telemetryConfigurationSampleRate||k(e.telemetryConfigurationSampleRate))return s=e.enableExperimentalFeatures,Array.isArray(s)&&(J||(J=new Set(s)),s.filter((function(e){return"string"==typeof e})).forEach((function(e){w(e,"-")&&t.warn("please use snake case for '".concat(e,"'")),J.add(e)}))),v({beforeSend:e.beforeSend&&n(e.beforeSend,"beforeSend threw an error:"),cookieOptions:ce(e),sampleRate:null!==(r=e.sampleRate)&&void 0!==r?r:100,telemetrySampleRate:null!==(o=e.telemetrySampleRate)&&void 0!==o?o:20,telemetryConfigurationSampleRate:null!==(i=e.telemetryConfigurationSampleRate)&&void 0!==i?i:5,service:e.service,silentMultipleInit:!!e.silentMultipleInit,batchBytesLimit:16384,eventRateLimiterThreshold:3e3,maxTelemetryEventsPerPage:15,flushTimeout:3e4,batchMessagesLimit:50,messageBytesLimit:262144},ae(e));t.error("Telemetry Configuration Sample Rate should be a number between 0 and 100")}else t.error("Telemetry Sample Rate should be a number between 0 and 100");else t.error("Sample Rate should be a number between 0 and 100");else t.error("Client Token is not configured, we will not send any data.")}function ce(e){var t={};return t.secure=function(e){return!!e.useSecureSessionCookie||!!e.useCrossSiteSessionCookie}(e),t.crossSite=!!e.useCrossSiteSessionCookie,e.trackSessionAcrossSubdomains&&(t.domain=function(){if(void 0===$){for(var e="dd_site_test_".concat(g()),t=window.location.hostname.split("."),n=t.pop();t.length&&!Y(e);)n="".concat(t.pop(),".").concat(n),X(e,"test",l,{domain:n});K(e,{domain:n}),$=n}return $}()),t}var fe="?";function le(e){var t=[],n=we(e,"stack"),r=String(e);return n&&E(n,r)&&(n=n.slice(r.length)),n&&n.split("\n").forEach((function(e){var n=function(e){var t=ve.exec(e);if(!t)return;var n=t[2]&&0===t[2].indexOf("native"),r=t[2]&&0===t[2].indexOf("eval"),o=ge.exec(t[2]);r&&o&&(t[2]=o[1],t[3]=o[2],t[4]=o[3]);return{args:n?[t[2]]:[],column:t[4]?+t[4]:void 0,func:t[1]||fe,line:t[3]?+t[3]:void 0,url:n?void 0:t[2]}}(e)||function(e){var t=he.exec(e);if(!t)return;return{args:[],column:t[3]?+t[3]:void 0,func:fe,line:t[2]?+t[2]:void 0,url:t[1]}}(e)||function(e){var t=ye.exec(e);if(!t)return;return{args:[],column:t[4]?+t[4]:void 0,func:t[1]||fe,line:+t[3],url:t[2]}}(e)||function(e){var t=me.exec(e);if(!t)return;var n=t[3]&&t[3].indexOf(" > eval")>-1,r=be.exec(t[3]);n&&r&&(t[3]=r[1],t[4]=r[2],t[5]=void 0);return{args:t[2]?t[2].split(","):[],column:t[5]?+t[5]:void 0,func:t[1]||fe,line:t[4]?+t[4]:void 0,url:t[3]}}(e);n&&(!n.func&&n.line&&(n.func=fe),t.push(n))})),{message:we(e,"message"),name:we(e,"name"),stack:t}}var de="((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\\w+\\.|\\/).*?)",pe="(?::(\\d+))",ve=new RegExp("^\\s*at (.*?) ?\\(".concat(de).concat(pe,"?").concat(pe,"?\\)?\\s*$"),"i"),ge=new RegExp("\\((\\S*)".concat(pe).concat(pe,"\\)"));var he=new RegExp("^\\s*at ?".concat(de).concat(pe,"?").concat(pe,"??\\s*$"),"i");var ye=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;var me=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|capacitor|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i,be=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;function we(e,t){if("object"==typeof e&&e&&t in e){var n=e[t];return"string"==typeof n?n:void 0}}var Ce="agent",ke="console",xe="logger",Se="network",Ee="source",Re="report";function Te(e){var t=_e(e);return e.stack.forEach((function(e){var n="?"===e.func?"<anonymous>":e.func,r=e.args&&e.args.length>0?"(".concat(e.args.join(", "),")"):"",o=e.line?":".concat(e.line):"",i=e.line&&e.column?":".concat(e.column):"";t+="\n at ".concat(n).concat(r," @ ").concat(e.url).concat(o).concat(i)})),t}function _e(e){return"".concat(e.name||"Error",": ").concat(e.message)}function Le(){var e,t=new Error;if(!t.stack)try{throw t}catch(e){}return c((function(){var n=le(t);n.stack=n.stack.slice(2),e=Te(n)})),e}function Oe(e,t){for(var n=e,r=[];(null==n?void 0:n.cause)instanceof Error&&r.length<10;){var o=le(n.cause);r.push({message:n.cause.message,source:t,type:null==o?void 0:o.name,stack:o&&Te(o)}),n=n.cause}return r.length?r:void 0}var Be=function(){function e(e){this.onFirstSubscribe=e,this.observers=[]}return e.prototype.subscribe=function(e){var t=this;return!this.observers.length&&this.onFirstSubscribe&&(this.onLastUnsubscribe=this.onFirstSubscribe()||void 0),this.observers.push(e),{unsubscribe:function(){t.observers=t.observers.filter((function(t){return e!==t})),!t.observers.length&&t.onLastUnsubscribe&&t.onLastUnsubscribe()}}},e.prototype.notify=function(e){this.observers.forEach((function(t){return t(e)}))},e}();function Me(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=new Be((function(){var t=e.map((function(e){return e.subscribe((function(e){return n.notify(e)}))}));return function(){return t.forEach((function(e){return e.unsubscribe()}))}}));return n}var Pe={intervention:"intervention",deprecation:"deprecation",cspViolation:"csp_violation"};function qe(e){var t,n=[];w(e,Pe.cspViolation)&&n.push(t=new Be((function(){var e=u((function(e){t.notify(function(e){var t=Pe.cspViolation,n="'".concat(e.blockedURI,"' blocked by '").concat(e.effectiveDirective,"' directive");return{type:Pe.cspViolation,subtype:e.effectiveDirective,message:"".concat(t,": ").concat(n),stack:Ie(e.effectiveDirective,e.originalPolicy?"".concat(n,' of the policy "').concat(T(e.originalPolicy,100,"..."),'"'):"no policy",e.sourceFile,e.lineNumber,e.columnNumber)}}(e))}));return _(document,"securitypolicyviolation",e).stop})));var r=e.filter((function(e){return e!==Pe.cspViolation}));return r.length&&n.push(function(e){var t=new Be((function(){if(window.ReportingObserver){var n=u((function(e){return e.forEach((function(e){t.notify(function(e){var t=e.type,n=e.body;return{type:t,subtype:n.id,message:"".concat(t,": ").concat(n.message),stack:Ie(n.id,n.message,n.sourceFile,n.lineNumber,n.columnNumber)}}(e))}))})),r=new window.ReportingObserver(n,{types:e,buffered:!0});return r.observe(),function(){r.disconnect()}}}));return t}(r)),Me.apply(void 0,n)}function Ie(e,t,n,r,o){return n&&Te({name:e,message:t,stack:[{func:"?",url:n,line:r,column:o}]})}function Ae(e,n,r){return void 0===e?[]:"all"===e||Array.isArray(e)&&e.every((function(e){return w(n,e)}))?"all"===e?n:(o=e,i=new Set,o.forEach((function(e){return i.add(e)})),C(i)):void t.error("".concat(r,' should be "all" or an array with allowed values "').concat(n.join('", "'),'"'));var o,i}var Ue=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},je={debug:"debug",error:"error",info:"info",warn:"warn"},De="console",Fe="http",Ne=Object.keys(je),He=function(){function e(e,t,n,r,o){void 0===n&&(n=Fe),void 0===r&&(r=je.debug),void 0===o&&(o={}),this.handleLogStrategy=e,this.handlerType=n,this.level=r,this.contextManager=q(),this.contextManager.set(v({},o,t?{logger:{name:t}}:void 0))}return e.prototype.log=function(e,t,n){void 0===n&&(n=je.info),this.handleLogStrategy({message:e,context:M(t),status:n},this)},e.prototype.debug=function(e,t){this.log(e,t,je.debug)},e.prototype.info=function(e,t){this.log(e,t,je.info)},e.prototype.warn=function(e,t){this.log(e,t,je.warn)},e.prototype.error=function(e,t){var n={error:{origin:xe}};this.log(e,P(n,t),je.error)},e.prototype.setContext=function(e){this.contextManager.set(e)},e.prototype.getContext=function(){return this.contextManager.get()},e.prototype.addContext=function(e,t){this.contextManager.add(e,t)},e.prototype.removeContext=function(e){this.contextManager.remove(e)},e.prototype.setHandler=function(e){this.handlerType=e},e.prototype.getHandler=function(){return this.handlerType},e.prototype.setLevel=function(e){this.level=e},e.prototype.getLevel=function(){return this.level},Ue([a],e.prototype,"log",null),e}();function Ge(){return Boolean(window._DATADOG_SYNTHETICS_INJECTS_RUM||Y("datadog-synthetics-injects-rum"))}function ze(){var e=window._DATADOG_SYNTHETICS_RESULT_ID||Y("datadog-synthetics-result-id");return"string"==typeof e?e:void 0}var Ve,$e="log",Je="configuration",We=["https://www.datadoghq-browser-agent.com","https://www.datad0g-browser-agent.com","http://localhost","<anonymous>"],Xe=["ddog-gov.com"],Ye={maxEventsPerPage:0,sentEventCount:0,telemetryEnabled:!1,telemetryConfigurationEnabled:!1};function Ke(e,t){var n,o=new Be;return Ye.telemetryEnabled=h(t.telemetrySampleRate),Ye.telemetryConfigurationEnabled=Ye.telemetryEnabled&&h(t.telemetryConfigurationSampleRate),Ve=function(r){!w(Xe,t.site)&&Ye.telemetryEnabled&&o.notify(function(e,t){return P({type:"telemetry",date:j(),service:e,version:"4.25.0",source:"browser",_dd:{format_version:2},telemetry:t,experimental_features:C(Q())},void 0!==n?n():{})}(e,r))},r=Qe,v(Ye,{maxEventsPerPage:t.maxTelemetryEventsPerPage,sentEventCount:0}),{setContextProvider:function(e){n=e},observable:o}}function Qe(e){Ze(v({type:$e,status:"error"},function(e){if(e instanceof Error){var t=le(e);return{error:{kind:t.name,stack:Te(et(t))},message:t.message}}return{error:{stack:"Not an instance of error"},message:"Uncaught ".concat(m(e))}}(e)))}function Ze(e){Ve&&Ye.sentEventCount<Ye.maxEventsPerPage&&(Ye.sentEventCount+=1,Ve(e))}function et(e){return e.stack=e.stack.filter((function(e){return!e.url||We.some((function(t){return E(e.url,t)}))})),e}var tt=/[^\u0000-\u007F]/,nt=function(){function e(e,t,n,r,o,i){var s=this;this.request=e,this.batchMessagesLimit=t,this.batchBytesLimit=n,this.messageBytesLimit=r,this.flushTimeout=o,this.pageExitObservable=i,this.pushOnlyBuffer=[],this.upsertBuffer={},this.bufferBytesCount=0,this.bufferMessagesCount=0,i.subscribe((function(){return s.flush(s.request.sendOnExit)})),this.flushPeriodically()}return e.prototype.add=function(e){this.addOrUpdate(e)},e.prototype.upsert=function(e,t){this.addOrUpdate(e,t)},e.prototype.flush=function(e){if(void 0===e&&(e=this.request.send),0!==this.bufferMessagesCount){var t=this.pushOnlyBuffer.concat(x(this.upsertBuffer)),n=this.bufferBytesCount;this.pushOnlyBuffer=[],this.upsertBuffer={},this.bufferBytesCount=0,this.bufferMessagesCount=0,e({data:t.join("\n"),bytesCount:n})}},e.prototype.computeBytesCount=function(e){return tt.test(e)?void 0!==window.TextEncoder?(new TextEncoder).encode(e).length:new Blob([e]).size:e.length},e.prototype.addOrUpdate=function(e,n){var r=this.process(e),o=r.processedMessage,i=r.messageBytesCount;i>=this.messageBytesLimit?t.warn("Discarded a message whose size was bigger than the maximum allowed size ".concat(this.messageBytesLimit,"KB.")):(this.hasMessageFor(n)&&this.remove(n),this.willReachedBytesLimitWith(i)&&this.flush(),this.push(o,i,n),this.isFull()&&this.flush())},e.prototype.process=function(e){var t=m(e);return{processedMessage:t,messageBytesCount:this.computeBytesCount(t)}},e.prototype.push=function(e,t,n){this.bufferMessagesCount>0&&(this.bufferBytesCount+=1),void 0!==n?this.upsertBuffer[n]=e:this.pushOnlyBuffer.push(e),this.bufferBytesCount+=t,this.bufferMessagesCount+=1},e.prototype.remove=function(e){var t=this.upsertBuffer[e];delete this.upsertBuffer[e];var n=this.computeBytesCount(t);this.bufferBytesCount-=n,this.bufferMessagesCount-=1,this.bufferMessagesCount>0&&(this.bufferBytesCount-=1)},e.prototype.hasMessageFor=function(e){return void 0!==e&&void 0!==this.upsertBuffer[e]},e.prototype.willReachedBytesLimitWith=function(e){return this.bufferBytesCount+e+1>=this.batchBytesLimit},e.prototype.isFull=function(){return this.bufferMessagesCount===this.batchMessagesLimit||this.bufferBytesCount>=this.batchBytesLimit},e.prototype.flushPeriodically=function(){var e=this;setTimeout(u((function(){e.flush(),e.flushPeriodically()})),this.flushTimeout)},e}(),rt=3145728;function ot(e,t,n,r,o){0===t.transportStatus&&0===t.queuedPayloads.size()&&t.bandwidthMonitor.canHandle(e)?st(e,t,n,{onSuccess:function(){return at(0,t,n,r,o)},onFailure:function(){t.queuedPayloads.enqueue(e),it(t,n,r,o)}}):t.queuedPayloads.enqueue(e)}function it(e,t,n,r){2===e.transportStatus&&setTimeout(u((function(){st(e.queuedPayloads.first(),e,t,{onSuccess:function(){e.queuedPayloads.dequeue(),e.currentBackoffTime=1e3,at(1,e,t,n,r)},onFailure:function(){e.currentBackoffTime=Math.min(6e4,2*e.currentBackoffTime),it(e,t,n,r)}})})),e.currentBackoffTime)}function st(e,t,n,r){var o=r.onSuccess,i=r.onFailure;t.bandwidthMonitor.add(e),n(e,(function(n){t.bandwidthMonitor.remove(e),!function(e){return 0===e.status||408===e.status||429===e.status||e.status>=500}(n)?(t.transportStatus=0,o()):(t.transportStatus=t.bandwidthMonitor.ongoingRequestCount>0?1:2,e.retry={count:e.retry?e.retry.count+1:1,lastFailureStatus:n.status},i())}))}function at(e,t,n,r,o){0===e&&t.queuedPayloads.isFull()&&!t.queueFullReported&&(o({message:"Reached max ".concat(r," events size queued for upload: ").concat(3,"MiB"),source:Ce,startClocks:F()}),t.queueFullReported=!0);var i=t.queuedPayloads;for(t.queuedPayloads=ut();i.size()>0;)ot(i.dequeue(),t,n,r,o)}function ut(){var e=[];return{bytesCount:0,enqueue:function(t){this.isFull()||(e.push(t),this.bytesCount+=t.bytesCount)},first:function(){return e[0]},dequeue:function(){var t=e.shift();return t&&(this.bytesCount-=t.bytesCount),t},size:function(){return e.length},isFull:function(){return this.bytesCount>=rt}}}function ct(e,t,n){var r={transportStatus:0,currentBackoffTime:1e3,bandwidthMonitor:{ongoingRequestCount:0,ongoingByteCount:0,canHandle:function(e){return 0===this.ongoingRequestCount||this.ongoingByteCount+e.bytesCount<=81920&&this.ongoingRequestCount<32},add:function(e){this.ongoingRequestCount+=1,this.ongoingByteCount+=e.bytesCount},remove:function(e){this.ongoingRequestCount-=1,this.ongoingByteCount-=e.bytesCount}},queuedPayloads:ut(),queueFullReported:!1},o=function(n,r){return function(e,t,n,r){var o=n.data,i=n.bytesCount,s=n.retry,a=e.build(s);(function(){try{return window.Request&&"keepalive"in new Request("http://a")}catch(e){return!1}})()&&i<t?fetch(a,{method:"POST",body:o,keepalive:!0}).then(u((function(e){return null==r?void 0:r({status:e.status})})),u((function(){lt(a,o,r)}))):lt(a,o,r)}(e,t,n,r)};return{send:function(t){ot(t,r,o,e.endpointType,n)},sendOnExit:function(n){!function(e,t,n){var r=n.data,o=n.bytesCount,i=e.build();if(navigator.sendBeacon&&o<t)try{if(navigator.sendBeacon(i,r))return}catch(e){!function(e){ft||(ft=!0,Qe(e))}(e)}lt(i,r)}(e,t,n)}}}var ft=!1;function lt(e,t,n){var r=new XMLHttpRequest,o=u((function(){r.removeEventListener("loadend",o),null==n||n({status:r.status})}));r.open("POST",e,!0),r.addEventListener("loadend",o),r.send(t)}function dt(e,t,n,r,o){var i,s=a(t);function a(t){return new nt(ct(t,e.batchBytesLimit,n),e.batchMessagesLimit,e.batchBytesLimit,e.messageBytesLimit,e.flushTimeout,r)}return o&&(i=a(o)),{add:function(e,t){void 0===t&&(t=!0),s.add(e),i&&t&&i.add(e)}}}var pt=1/0,vt=function(){function e(e){var t=this;this.expireDelay=e,this.entries=[],this.clearOldContextsInterval=setInterval((function(){return t.clearOldContexts()}),6e4)}return e.prototype.add=function(e,t){var n=this,r={context:e,startTime:t,endTime:pt,remove:function(){var e=n.entries.indexOf(r);e>=0&&n.entries.splice(e,1)},close:function(e){r.endTime=e}};return this.entries.unshift(r),r},e.prototype.find=function(e){void 0===e&&(e=pt);for(var t=0,n=this.entries;t<n.length;t++){var r=n[t];if(r.startTime<=e){if(e<=r.endTime)return r.context;break}}},e.prototype.closeActive=function(e){var t=this.entries[0];t&&t.endTime===pt&&t.close(e)},e.prototype.findAll=function(e){return void 0===e&&(e=pt),this.entries.filter((function(t){return t.startTime<=e&&e<=t.endTime})).map((function(e){return e.context}))},e.prototype.reset=function(){this.entries=[]},e.prototype.stop=function(){clearInterval(this.clearOldContextsInterval)},e.prototype.clearOldContexts=function(){for(var e=D()-this.expireDelay;this.entries.length>0&&this.entries[this.entries.length-1].endTime<e;)this.entries.pop()},e}();var gt,ht=144e5,yt=9e5,mt=/^([a-z]+)=([a-z0-9-]+)$/,bt="&",wt="_dd_s",Ct=[];function kt(e,t){var n;if(void 0===t&&(t=0),gt||(gt=e),e===gt)if(t>=100)Et();else{var r,o=_t();if(xt()){if(o.lock)return void St(e,t);if(r=g(),o.lock=r,Tt(o,e.options),(o=_t()).lock!==r)return void St(e,t)}var i=e.process(o);if(xt()&&(o=_t()).lock!==r)St(e,t);else{if(i&&Rt(i,e.options),xt()&&(!i||!Lt(i))){if((o=_t()).lock!==r)return void St(e,t);delete o.lock,Tt(o,e.options),i=o}null===(n=e.after)||void 0===n||n.call(e,i||o),Et()}}else Ct.push(e)}function xt(){return!!window.chrome||/HeadlessChrome/.test(window.navigator.userAgent)}function St(e,t){setTimeout(u((function(){kt(e,t+1)})),10)}function Et(){gt=void 0;var e=Ct.shift();e&&kt(e)}function Rt(e,t){Lt(e)?function(e){X(wt,"",0,e)}(t):(e.expire=String(U()+yt),Tt(e,t))}function Tt(e,t){X(wt,function(e){return(t=e,Object.keys(t).map((function(e){return[e,t[e]]}))).map((function(e){var t=e[0],n=e[1];return"".concat(t,"=").concat(n)})).join(bt);var t}(e),yt,t)}function _t(){var e=Y(wt),t={};return function(e){return void 0!==e&&(-1!==e.indexOf(bt)||mt.test(e))}(e)&&e.split(bt).forEach((function(e){var n=mt.exec(e);if(null!==n){var r=n[1],o=n[2];t[r]=o}})),t}function Lt(e){return S(e)}function Ot(e,t,n){var r=new Be,o=new Be,i=setInterval(u((function(){kt({options:e,process:function(e){return f(e)?void 0:{}},after:a})})),1e3),s=function(){var e=_t();if(f(e))return e;return{}}();function a(e){return f(e)||(e={}),c()&&(!function(e){return s.id!==e.id||s[t]!==e[t]}(e)?s=e:(s={},o.notify())),e}function c(){return void 0!==s[t]}function f(e){return(void 0===e.created||U()-Number(e.created)<ht)&&(void 0===e.expire||U()<Number(e.expire))}return{expandOrRenewSession:p(u((function(){var o;kt({options:e,process:function(e){var r=a(e);return o=function(e){var r=n(e[t]),o=r.trackingType,i=r.isTracked;e[t]=o,i&&!e.id&&(e.id=g(),e.created=String(U()));return i}(r),r},after:function(e){o&&!c()&&function(e){s=e,r.notify()}(e),s=e}})})),1e3).throttled,expandSession:function(){kt({options:e,process:function(e){return c()?a(e):void 0}})},getSession:function(){return s},renewObservable:r,expireObservable:o,stop:function(){clearInterval(i)}}}var Bt=[];function Mt(e,t,n){!function(e){var t=Y(wt),n=Y("_dd"),r=Y("_dd_r"),o=Y("_dd_l");if(!t){var i={};n&&(i.id=n),o&&/^[01]$/.test(o)&&(i.logs=o),r&&/^[012]$/.test(r)&&(i.rum=r),Rt(i,e)}}(e);var r=Ot(e,t,n);Bt.push((function(){return r.stop()}));var o,i=new vt(144e5);function s(){return{id:r.getSession().id,trackingType:r.getSession()[t]}}return Bt.push((function(){return i.stop()})),r.renewObservable.subscribe((function(){i.add(s(),D())})),r.expireObservable.subscribe((function(){i.closeActive(D())})),r.expandOrRenewSession(),i.add(s(),[0,H()][0]),o=L(window,["click","touchstart","keydown","scroll"],(function(){return r.expandOrRenewSession()}),{capture:!0,passive:!0}).stop,Bt.push(o),function(e){var t=u((function(){"visible"===document.visibilityState&&e()})),n=_(document,"visibilitychange",t).stop;Bt.push(n);var r=setInterval(t,6e4);Bt.push((function(){clearInterval(r)}))}((function(){return r.expandSession()})),{findActiveSession:function(e){return i.find(e)},renewObservable:r.renewObservable,expireObservable:r.expireObservable}}var Pt;function qt(e){var t=Mt(e.cookieOptions,"logs",(function(t){return function(e,t){var n=function(e){return"0"===e||"1"===e}(t)?t:It(e);return{trackingType:n,isTracked:"1"===n}}(e,t)}));return{findTrackedSession:function(e){var n=t.findActiveSession(e);return n&&"1"===n.trackingType?{id:n.id}:void 0}}}function It(e){return h(e.sampleRate)?"1":"0"}var At=((Pt={})[je.debug]=0,Pt[je.info]=1,Pt[je.warn]=2,Pt[je.error]=3,Pt);function Ut(e,t,n){var r=n.getHandler(),o=Array.isArray(r)?r:[r];return At[e]>=At[n.getLevel()]&&w(o,t)}function jt(e,t,n,r,o,i){var s=Ne.concat(["custom"]),a={};s.forEach((function(e){var n,r,o,s,u;a[e]=(n=e,r=t.eventRateLimiterThreshold,o=i,s=0,u=!1,{isLimitReached:function(){if(0===s&&setTimeout((function(){s=0}),d),(s+=1)<=r||u)return u=!1,!1;if(s===r+1){u=!0;try{o({message:"Reached max number of ".concat(n,"s by minute: ").concat(r),source:Ce,startClocks:F()})}finally{u=!1}}return!0}})})),n.subscribe(0,(function(i){var s,u,c,f=i.rawLogsEvent,l=i.messageContext,d=void 0===l?void 0:l,p=i.savedCommonContext,v=void 0===p?void 0:p,g=i.logger,h=void 0===g?o:g,y=f.date-H(),m=e.findTrackedSession(y);if(m){var b=v||r(),w=P({service:t.service,session_id:m.id,usr:S(b.user)?void 0:b.user,view:b.view},b.context,Ft(y),f,h.getContext(),d);!Ut(f.status,Fe,h)||!1===(null===(s=t.beforeSend)||void 0===s?void 0:s.call(t,w))||(null===(u=w.error)||void 0===u?void 0:u.origin)!==Ce&&(null!==(c=a[w.status])&&void 0!==c?c:a.custom).isLimitReached()||n.notify(1,w)}}))}var Dt=!1;function Ft(t){var n,r=window;if(Ge()){var o=i(r.DD_RUM_SYNTHETICS);return o||Dt||(Dt=!0,function(t,n){f(e.debug,t,n),Ze(v({type:$e,message:t,status:"debug"},n))}("Logs sent before RUM is injected by the synthetics worker",{testId:(n=window._DATADOG_SYNTHETICS_PUBLIC_ID||Y("datadog-synthetics-public-id"),"string"==typeof n?n:void 0),resultId:ze()})),o}return i(r.DD_RUM);function i(e){if(e&&e.getInternalContext)return e.getInternalContext(t)}}var Nt,Ht={};function Gt(e){var t=e.map((function(e){return Ht[e]||(Ht[e]=function(e){var t=new Be((function(){var n=console[e];return console[e]=function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];n.apply(console,r);var i=Le();c((function(){t.notify(zt(r,e,i))}))},function(){console[e]=n}}));return t}(e)),Ht[e]}));return Me.apply(void 0,t)}function zt(t,n,r){var o,i=t.map((function(e){return function(e){if("string"==typeof e)return e;if(e instanceof Error)return _e(le(e));return m(e,void 0,2)}(e)})).join(" ");if(n===e.error){var s=function(e,t){for(var n=0;n<e.length;n+=1){var r=e[n];if(t(r,n))return r}}(t,(function(e){return e instanceof Error}));o=s?Te(le(s)):void 0,i="console error: ".concat(i)}return{api:n,message:i,stack:o,handlingStack:r}}var Vt,$t=((Nt={})[e.log]=je.info,Nt[e.debug]=je.debug,Nt[e.info]=je.info,Nt[e.warn]=je.warn,Nt[e.error]=je.error,Nt);var Jt,Wt=((Vt={})[Pe.cspViolation]=je.error,Vt[Pe.intervention]=je.error,Vt[Pe.deprecation]=je.warn,Vt);function Xt(e,t,n){var r=e[t],o=n(r),i=function(){if("function"==typeof o)return o.apply(this,arguments)};return e[t]=i,{stop:function(){e[t]===i?e[t]=r:o=r}}}function Yt(e,t,n){var r=n.before,o=n.after;return Xt(e,t,(function(e){return function(){var t,n=arguments;return r&&c(r,this,n),"function"==typeof e&&(t=e.apply(this,n)),o&&c(o,this,n),t}}))}var Kt,Qt=new WeakMap;function Zt(){var e;return Jt||(e=new Be((function(){var t=Yt(XMLHttpRequest.prototype,"open",{before:en}).stop,n=Yt(XMLHttpRequest.prototype,"send",{before:function(){tn.call(this,e)}}).stop,r=Yt(XMLHttpRequest.prototype,"abort",{before:nn}).stop;return function(){t(),n(),r()}})),Jt=e),Jt}function en(e,t){Qt.set(this,{state:"open",method:e,url:Z(String(t))})}function tn(e){var t=this,n=Qt.get(this);if(n){var r=n;r.state="start",r.startTime=D(),r.startClocks=F(),r.isAborted=!1,r.xhr=this;var o=!1,i=Yt(this,"onreadystatechange",{before:function(){this.readyState===XMLHttpRequest.DONE&&s()}}).stop,s=u((function(){if(t.removeEventListener("loadend",s),i(),!o){o=!0;var a=n;a.state="complete",a.duration=N(r.startClocks.timeStamp,j()),a.status=t.status,e.notify(v({},a))}}));this.addEventListener("loadend",s),e.notify(r)}}function nn(){var e=Qt.get(this);e&&(e.isAborted=!0)}function rn(){var e;return Kt||(e=new Be((function(){if(window.fetch)return Xt(window,"fetch",(function(t){return function(n,r){var o,i=c(on,null,[e,n,r]);return i?(o=t.call(this,i.input,i.init),c(sn,null,[e,o,i])):o=t.call(this,n,r),o}})).stop})),Kt=e),Kt}function on(e,t,n){var r=n&&n.method||"object"==typeof t&&t.method||"GET",o=Z("object"==typeof t&&t.url||t),i={state:"start",init:n,input:t,method:r,startClocks:F(),url:o};return e.notify(i),i}function sn(e,t,n){var r=function(t){var r=n;r.state="complete",r.duration=N(r.startClocks.timeStamp,j()),"stack"in t||t instanceof Error?(r.status=0,r.isAborted=t instanceof DOMException&&t.code===DOMException.ABORT_ERR,r.error=t,e.notify(r)):"status"in t&&(r.response=t,r.responseType=t.type,r.status=t.status,r.isAborted=!1,e.notify(r))};t.then(u(r),u(r))}function an(e,t){if(!e.forwardErrorsToLogs)return{stop:y};var n=Zt().subscribe((function(e){"complete"===e.state&&o("xhr",e)})),r=rn().subscribe((function(e){"complete"===e.state&&o("fetch",e)}));function o(n,r){function o(e){t.notify(0,{rawLogsEvent:{message:"".concat(cn(n)," error ").concat(r.method," ").concat(r.url),date:r.startClocks.timeStamp,error:{origin:Se,stack:e||"Failed to load"},http:{method:r.method,status_code:r.status,url:r.url},status:je.error,origin:Se}})}e.isIntakeUrl(r.url)||!function(e){return 0===e.status&&"opaque"!==e.responseType}(r)&&!function(e){return e.status>=500}(r)||("xhr"in r?function(e,t,n){"string"==typeof e.response?n(un(e.response,t)):n(e.response)}(r.xhr,e,o):r.response?function(e,t,n){window.TextDecoder?e.body?function(e,t,n){!function(e,t,n){var r=e.getReader(),o=[],i=0;function s(){r.read().then(u((function(e){e.done?a():(o.push(e.value),(i+=e.value.length)>t?a():s())})),u((function(e){return n(e)})))}function a(){var e;if(r.cancel().catch(y),1===o.length)e=o[0];else{e=new Uint8Array(i);var s=0;o.forEach((function(t){e.set(t,s),s+=t.length}))}n(void 0,e.slice(0,t),e.length>t)}s()}(e,t,(function(e,t,r){if(e)n(e);else{var o=(new TextDecoder).decode(t);r&&(o+="..."),n(void 0,o)}}))}(e.clone().body,t.requestErrorResponseLengthLimit,(function(e,t){n(e?"Unable to retrieve response: ".concat(e):t)})):n():e.clone().text().then(u((function(e){return n(un(e,t))})),u((function(e){return n("Unable to retrieve response: ".concat(e))})))}(r.response,e,o):r.error&&function(e,t,n){n(un(Te(le(e)),t))}(r.error,e,o))}return{stop:function(){n.unsubscribe(),r.unsubscribe()}}}function un(e,t){return e.length>t.requestErrorResponseLengthLimit?"".concat(e.substring(0,t.requestErrorResponseLengthLimit),"..."):e}function cn(e){return"xhr"===e?"XHR":"Fetch"}var fn=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/;function ln(e){var t=function(e){return Yt(window,"onerror",{before:function(t,n,r,o,i){var s;if(i)s=le(i),e(s,i);else{var a,u={url:n,column:o,line:r},c=t;if("[object String]"==={}.toString.call(t)){var f=fn.exec(c);f&&(a=f[1],c=f[2])}e(s={name:a,message:"string"==typeof c?c:void 0,stack:[u]},t)}}})}(e).stop,n=function(e){return Yt(window,"onunhandledrejection",{before:function(t){var n=t.reason||"Empty reason",r=le(n);e(r,n)}})}(e).stop;return{stop:function(){t(),n()}}}function dn(e){return ln((function(t,n){e.notify(function(e){var t=e.stackTrace,n=e.originalError,r=e.handlingStack,o=e.startClocks,i=e.nonErrorPrefix,s=e.source,a=e.handling;return t&&(void 0!==t.message||n instanceof Error)?{startClocks:o,source:s,handling:a,originalError:n,message:t.message||"Empty message",stack:Te(t),handlingStack:r,type:t.name,causes:Oe(n,s)}:{startClocks:o,source:s,handling:a,originalError:n,message:"".concat(i," ").concat(m(n)),stack:"No stack, consider using an instance of Error",handlingStack:r,type:t&&t.name}}({stackTrace:t,originalError:n,startClocks:F(),nonErrorPrefix:"Uncaught",source:Ee,handling:"unhandled"}))}))}var pn=function(){function e(){this.callbacks={}}return e.prototype.notify=function(e,t){var n=this.callbacks[e];n&&n.forEach((function(e){return e(t)}))},e.prototype.subscribe=function(e,t){var n=this;return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),{unsubscribe:function(){n.callbacks[e]=n.callbacks[e].filter((function(e){return t!==e}))}}},e}();var vn,gn,hn,yn,mn=function(n){var r,o,i=!1,a=q(),c=q(),f={},l=function(){},d=new A,p=function(e,t,n,r){void 0===n&&(n=M(y())),void 0===r&&(r=j()),d.add((function(){return p(e,t,n,r)}))},g=function(){},h=new He((function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return p.apply(void 0,e)}));function y(){return{view:{referrer:document.referrer,url:window.location.href},context:a.getContext(),user:c.getContext()}}return r={logger:h,init:u((function(r){var o;if(z()&&(r=function(e){return v({},e,{clientToken:"empty"})}(r)),function(e){return!i||(e.silentMultipleInit||t.error("DD_LOGS is already initialized."),!1)}(r)){var s=function(t){var n=ue(t),r=Ae(t.forwardConsoleLogs,x(e),"Forward Console Logs"),o=Ae(t.forwardReports,x(Pe),"Forward Reports");if(n&&r&&o)return t.forwardErrorsToLogs&&!w(r,e.error)&&r.push(e.error),v({forwardErrorsToLogs:!1!==t.forwardErrorsToLogs,forwardConsoleLogs:r,forwardReports:o,requestErrorResponseLengthLimit:32768},n)}(r);s&&(o=n(r,s,y,h),p=o.handleLog,l=o.getInternalContext,g=function(){return M(r)},d.drain(),i=!0)}})),getLoggerGlobalContext:u(a.get),getGlobalContext:u(a.getContext),setLoggerGlobalContext:u(a.set),setGlobalContext:u(a.setContext),addLoggerGlobalContext:u(a.add),setGlobalContextProperty:u(a.setContextProperty),removeLoggerGlobalContext:u(a.remove),removeGlobalContextProperty:u(a.removeContextProperty),clearGlobalContext:u(a.clearContext),createLogger:u((function(e,t){return void 0===t&&(t={}),f[e]=new He((function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return p.apply(void 0,e)}),e,t.handler,t.level,t.context),f[e]})),getLogger:u((function(e){return f[e]})),getInitConfiguration:u((function(){return g()})),getInternalContext:u((function(e){return l(e)})),setUser:u((function(e){(function(e){var n="object"===O(e);return n||t.error("Unsupported user:",e),n})(e)&&c.setContext(V(e))})),getUser:u(c.getContext),setUserProperty:u((function(e,t){var n,r=V((n={},n[e]=t,n))[e];c.setContextProperty(e,r)})),removeUserProperty:u(c.removeContextProperty),clearUser:u(c.clearContext)},o=v({version:"4.25.0",onReady:function(e){e()}},r),Object.defineProperty(o,"_setDebug",{get:function(){return s},enumerable:!1}),o}((function(n,r,o,i){var s,a=new pn,u=function(e){return a.notify(0,{rawLogsEvent:{message:e.message,date:e.startClocks.timeStamp,error:{origin:Ce},origin:Ce,status:je.error}})},c=s=new Be((function(){var e=_(document,"visibilitychange",(function(){"hidden"===document.visibilityState&&s.notify({reason:"visibility_hidden"})}),{capture:!0}).stop,t=_(window,"beforeunload",(function(){s.notify({reason:"before_unload"})})).stop;return function(){e(),t()}})),f=function(e,t,n){var r,o=Ke("browser-logs-sdk",e);if(z()){var i=G();o.observable.subscribe((function(e){return i.send("internal_telemetry",e)}))}else{var s=dt(e,e.rumEndpointBuilder,t,n,null===(r=e.replica)||void 0===r?void 0:r.rumEndpointBuilder);o.observable.subscribe((function(t){return s.add(t,function(e){return"datad0g.com"===e.site}(e))}))}return o}(r,u,c);f.setContextProvider((function(){var e,t,n,r,o,i;return{application:{id:null===(e=Ft())||void 0===e?void 0:e.application_id},session:{id:null===(t=h.findTrackedSession())||void 0===t?void 0:t.id},view:{id:null===(r=null===(n=Ft())||void 0===n?void 0:n.view)||void 0===r?void 0:r.id},action:{id:null===(i=null===(o=Ft())||void 0===o?void 0:o.user_action)||void 0===i?void 0:i.id}}})),an(r,a),function(e,t){if(!e.forwardErrorsToLogs)return{stop:y};var n=new Be,r=dn(n).stop,o=n.subscribe((function(e){t.notify(0,{rawLogsEvent:{message:e.message,date:e.startClocks.timeStamp,error:{kind:e.type,origin:Ee,stack:e.stack},origin:Ee,status:je.error}})}))}(r,a),function(t,n){var r=Gt(t.forwardConsoleLogs).subscribe((function(t){n.notify(0,{rawLogsEvent:{date:j(),message:t.message,origin:ke,error:t.api===e.error?{origin:ke,stack:t.stack}:void 0,status:$t[t.api]}})}))}(r,a),function(e,t){var n=qe(e.forwardReports).subscribe((function(e){var n,r=e.message,o=Wt[e.type];o===je.error?n={kind:e.subtype,origin:Re,stack:e.stack}:e.stack&&(r+=" Found in ".concat(function(e){var t;return null===(t=/@ (.+)/.exec(e))||void 0===t?void 0:t[1]}(e.stack))),t.notify(0,{rawLogsEvent:{date:j(),message:r,origin:Re,error:n,status:o}})}))}(r,a);var d,p=function(e){return{handleLog:function(n,r,o,i){var s=n.context;Ut(n.status,De,r)&&t(n.status,n.message,P(r.getContext(),s)),e.notify(0,{rawLogsEvent:{date:i||j(),message:n.message,status:n.status,origin:xe},messageContext:s,savedCommonContext:o,logger:r})}}}(a).handleLog,h=!function(e){if(void 0===document.cookie||null===document.cookie)return!1;try{var n="dd_cookie_test_".concat(g()),r="test";X(n,r,l,e);var o=Y(n)===r;return K(n,e),o}catch(e){return t.error(e),!1}}(r.cookieOptions)||z()||Ge()?function(e){var t="1"===It(e)?{}:void 0;return{findTrackedSession:function(){return t}}}(r):qt(r);return jt(h,r,a,o,i,u),z()?function(e){var t=G();e.subscribe(1,(function(e){t.send("log",e)}))}(a):function(e,t,n,r){var o,i=dt(e,e.logsEndpointBuilder,n,r,null===(o=e.replica)||void 0===o?void 0:o.logsEndpointBuilder);t.subscribe(1,(function(e){i.add(e)}))}(r,a,u,c),function(e){Ye.telemetryConfigurationEnabled&&Ze({type:Je,configuration:e})}(function(e){var t=function(e){return{session_sample_rate:e.sampleRate,telemetry_sample_rate:e.telemetrySampleRate,telemetry_configuration_sample_rate:e.telemetryConfigurationSampleRate,use_before_send:!!e.beforeSend,use_cross_site_session_cookie:e.useCrossSiteSessionCookie,use_secure_session_cookie:e.useSecureSessionCookie,use_proxy:void 0!==e.proxyUrl?!!e.proxyUrl:void 0,silent_multiple_init:e.silentMultipleInit,track_session_across_subdomains:e.trackSessionAcrossSubdomains,track_resources:e.trackResources,track_long_task:e.trackLongTasks}}(e);return v({forward_errors_to_logs:e.forwardErrorsToLogs,forward_console_logs:e.forwardConsoleLogs,forward_reports:e.forwardReports},t)}(n)),{handleLog:p,getInternalContext:(d=h,{get:function(e){var t=d.findTrackedSession(e);if(t)return{session_id:t.id}}}).get}}));vn=R(),hn=mn,yn=vn[gn="DD_LOGS"],vn[gn]=hn,yn&&yn.q&&yn.q.forEach((function(e){return n(e,"onReady callback threw an error:")()}))}(); | ||
!function(){"use strict";var e={log:"log",debug:"debug",info:"info",warn:"warn",error:"error"},t=function(n){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];Object.prototype.hasOwnProperty.call(e,n)||(n=e.log),t[n].apply(t,r)};function n(e,n){return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];try{return e.apply(void 0,r)}catch(e){t.error(n,e)}}}t.debug=console.debug.bind(console),t.log=console.log.bind(console),t.info=console.info.bind(console),t.warn=console.warn.bind(console),t.error=console.error.bind(console);var r,o=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))},i=!1;function s(e){i=e}function a(e,t,n){var o=n.value;n.value=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=r?u(o):o;return n.apply(this,e)}}function u(e){return function(){return c(e,this,arguments)}}function c(t,n,o){try{return t.apply(n,o)}catch(t){if(f(e.error,t),r)try{r(t)}catch(t){f(e.error,t)}}}function f(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];i&&t.apply(void 0,o([e,"[MONITOR]"],n,!1))}var l=1e3,d=6e4;function p(e,t,n){var r,o,i=!n||void 0===n.leading||n.leading,s=!n||void 0===n.trailing||n.trailing,a=!1;return{throttled:function(){for(var n=[],u=0;u<arguments.length;u++)n[u]=arguments[u];a?r=n:(i?e.apply(void 0,n):r=n,a=!0,o=setTimeout((function(){s&&r&&e.apply(void 0,r),a=!1,r=void 0}),t))},cancel:function(){clearTimeout(o),a=!1,r=void 0}}}function v(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return t.forEach((function(t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})),e}function h(e){return e?(parseInt(e,10)^16*Math.random()>>parseInt(e,10)/4).toString(16):"".concat(1e7,"-").concat(1e3,"-").concat(4e3,"-").concat(8e3,"-").concat(1e11).replace(/[018]/g,h)}function g(e){return 0!==e&&100*Math.random()<=e}function y(){}function m(e,t,n){if("object"!=typeof e||null===e)return JSON.stringify(e);var r=b(Object.prototype),o=b(Array.prototype),i=b(Object.getPrototypeOf(e)),s=b(e);try{return JSON.stringify(e,t,n)}catch(e){return"<error: unable to serialize object>"}finally{r(),o(),i(),s()}}function b(e){var t=e,n=t.toJSON;return n?(delete t.toJSON,function(){t.toJSON=n}):y}function w(e,t){return-1!==e.indexOf(t)}function C(e){if(Array.from)return Array.from(e);var t=[];if(e instanceof Set)e.forEach((function(e){return t.push(e)}));else for(var n=0;n<e.length;n++)t.push(e[n]);return t}function k(e){return function(e){return"number"==typeof e}(e)&&e>=0&&e<=100}function x(e){return Object.keys(e).map((function(t){return e[t]}))}function S(e){return 0===Object.keys(e).length}function E(e,t){return e.slice(0,t.length)===t}function R(){if("object"==typeof globalThis)return globalThis;Object.defineProperty(Object.prototype,"_dd_temp_",{get:function(){return this},configurable:!0});var e=_dd_temp_;return delete Object.prototype._dd_temp_,"object"!=typeof e&&(e="object"==typeof self?self:"object"==typeof window?window:{}),e}function T(e,t,n){void 0===n&&(n="");var r=e.charCodeAt(t-1),o=r>=55296&&r<=56319?t+1:t;return e.length<=o?e:"".concat(e.slice(0,o)).concat(n)}function L(e,t,n,r){return _(e,[t],n,r)}function _(e,t,n,r){var o=void 0===r?{}:r,i=o.once,s=o.capture,a=o.passive,c=u(i?function(e){l(),n(e)}:n),f=a?{capture:s,passive:a}:s;t.forEach((function(t){return e.addEventListener(t,c,f)}));var l=function(){return t.forEach((function(t){return e.removeEventListener(t,c,f)}))};return{stop:l}}function O(e){return null===e?"null":Array.isArray(e)?"array":typeof e}function B(e,t,n){if(void 0===n&&(n=function(){if("undefined"!=typeof WeakSet){var e=new WeakSet;return{hasAlreadyBeenSeen:function(t){var n=e.has(t);return n||e.add(t),n}}}var t=[];return{hasAlreadyBeenSeen:function(e){var n=t.indexOf(e)>=0;return n||t.push(e),n}}}()),void 0===t)return e;if("object"!=typeof t||null===t)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){var r=t.flags||[t.global?"g":"",t.ignoreCase?"i":"",t.multiline?"m":"",t.sticky?"y":"",t.unicode?"u":""].join("");return new RegExp(t.source,r)}if(!n.hasAlreadyBeenSeen(t)){if(Array.isArray(t)){for(var o=Array.isArray(e)?e:[],i=0;i<t.length;++i)o[i]=B(o[i],t[i],n);return o}var s="object"===O(e)?e:{};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(s[a]=B(s[a],t[a],n));return s}}function M(e){return B(void 0,e)}function P(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];for(var r=0,o=t;r<o.length;r++){var i=o[r];null!=i&&(e=B(e,i))}return e}function q(){var e={};return{get:function(){return e},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},set:function(t){e=t},getContext:function(){return M(e)},setContext:function(t){e=M(t)},setContextProperty:function(t,n){e[t]=M(n)},removeContextProperty:function(t){delete e[t]},clearContext:function(){e={}}}}var I,A=function(){function e(){this.buffer=[]}return e.prototype.add=function(e){this.buffer.push(e)>500&&this.buffer.splice(0,1)},e.prototype.drain=function(){this.buffer.forEach((function(e){return e()})),this.buffer.length=0},e}();function U(){return(new Date).getTime()}function j(){return U()}function D(){return performance.now()}function F(){return{relative:D(),timeStamp:j()}}function N(e,t){return t-e}function H(){return void 0===I&&(I=performance.timing.navigationStart),I}function G(){var e=R().DatadogEventBridge;if(e)return{getAllowedWebViewHosts:function(){return JSON.parse(e.getAllowedWebViewHosts())},send:function(t,n){e.send(JSON.stringify({eventType:t,event:n}))}}}function z(e){var t;void 0===e&&(e=null===(t=R().location)||void 0===t?void 0:t.hostname);var n=G();return!!n&&n.getAllowedWebViewHosts().some((function(t){return e===t||(n=e,r=".".concat(t),n.slice(-r.length)===r);var n,r}))}function V(e){var t=v({},e);return["id","name","email"].forEach((function(e){e in t&&(t[e]=String(t[e]))})),t}var $,J,W;function X(e,t,n,r){var o=new Date;o.setTime(o.getTime()+n);var i="expires=".concat(o.toUTCString()),s=r&&r.crossSite?"none":"strict",a=r&&r.domain?";domain=".concat(r.domain):"",u=r&&r.secure?";secure":"";document.cookie="".concat(e,"=").concat(t,";").concat(i,";path=/;samesite=").concat(s).concat(a).concat(u)}function Y(e){return function(e,t){var n=new RegExp("(?:^|;)\\s*".concat(t,"\\s*=\\s*([^;]+)")).exec(e);return n?n[1]:void 0}(document.cookie,e)}function K(e,t){X(e,"",0,t)}function Q(){return J||new Set}function Z(e){return ee(e,function(e){if(e.origin)return e.origin;var t=e.host.replace(/(:80|:443)$/,"");return"".concat(e.protocol,"//").concat(t)}(window.location)).href}function ee(e,t){if(function(){if(void 0!==W)return W;try{var e=new URL("http://test/path");return W="http://test/path"===e.href}catch(e){W=!1}return W}())return void 0!==t?new URL(e,t):new URL(e);if(void 0===t&&!/:/.test(e))throw new Error("Invalid URL: '".concat(e,"'"));var n=document,r=n.createElement("a");if(void 0!==t){var o=(n=document.implementation.createHTMLDocument("")).createElement("base");o.href=t,n.head.appendChild(o),n.body.appendChild(r)}return r.href=e,r}var te="datadoghq.com",ne={logs:"logs",rum:"rum",sessionReplay:"session-replay"},re={logs:"logs",rum:"rum",sessionReplay:"replay"};function oe(e,t,n){var r=e.site,o=void 0===r?te:r,i=e.clientToken,s=o.split("."),a=s.pop(),u="".concat(ne[t],".browser-intake-").concat(s.join("-"),".").concat(a),c="https://".concat(u,"/api/v2/").concat(re[t]),f=e.proxyUrl&&Z(e.proxyUrl);return{build:function(e,r){var o=["sdk_version:".concat("4.26.0"),"api:".concat(e)].concat(n);r&&o.push("retry_count:".concat(r.count),"retry_after:".concat(r.lastFailureStatus));var s="ddsource=browser"+"&ddtags=".concat(encodeURIComponent(o.join(",")))+"&dd-api-key=".concat(i)+"&dd-evp-origin-version=".concat(encodeURIComponent("4.26.0"))+"&dd-evp-origin=browser"+"&dd-request-id=".concat(h());"rum"===t&&(s+="&batch_time=".concat(j()));var a="".concat(c,"?").concat(s);return f?"".concat(f,"?ddforward=").concat(encodeURIComponent(a)):a},buildIntakeUrl:function(){return f?"".concat(f,"?ddforward"):c},endpointType:t}}var ie=/[^a-z0-9_:./-]/;function se(e,n){var r=200-e.length-1;(n.length>r||ie.test(n))&&t.warn("".concat(e," value doesn't meet tag requirements and will be sanitized"));var o=n.replace(/,/g,"_");return"".concat(e,":").concat(o)}function ae(e){var t=function(e){var t=e.env,n=e.service,r=e.version,o=e.datacenter,i=[];return t&&i.push(se("env",t)),n&&i.push(se("service",n)),r&&i.push(se("version",r)),o&&i.push(se("datacenter",o)),i}(e),n=function(e,t){return{logsEndpointBuilder:oe(e,"logs",t),rumEndpointBuilder:oe(e,"rum",t),sessionReplayEndpointBuilder:oe(e,"sessionReplay",t)}}(e,t),r=x(n).map((function(e){return e.buildIntakeUrl()})),o=function(e,t,n){if(!e.replica)return;var r=v({},e,{site:te,clientToken:e.replica.clientToken}),o={logsEndpointBuilder:oe(r,"logs",n),rumEndpointBuilder:oe(r,"rum",n)};return t.push.apply(t,x(o).map((function(e){return e.buildIntakeUrl()}))),v({applicationId:e.replica.applicationId},o)}(e,r,t);return v({isIntakeUrl:function(e){return r.some((function(t){return 0===e.indexOf(t)}))},replica:o,site:e.site||te},n)}function ue(e){var r,o,i;if(e&&e.clientToken)if(void 0===e.sampleRate||k(e.sampleRate))if(void 0===e.telemetrySampleRate||k(e.telemetrySampleRate)){var s;if(void 0===e.telemetryConfigurationSampleRate||k(e.telemetryConfigurationSampleRate))return s=e.enableExperimentalFeatures,Array.isArray(s)&&(J||(J=new Set(s)),s.filter((function(e){return"string"==typeof e})).forEach((function(e){w(e,"-")&&t.warn("please use snake case for '".concat(e,"'")),J.add(e)}))),v({beforeSend:e.beforeSend&&n(e.beforeSend,"beforeSend threw an error:"),cookieOptions:ce(e),sampleRate:null!==(r=e.sampleRate)&&void 0!==r?r:100,telemetrySampleRate:null!==(o=e.telemetrySampleRate)&&void 0!==o?o:20,telemetryConfigurationSampleRate:null!==(i=e.telemetryConfigurationSampleRate)&&void 0!==i?i:5,service:e.service,silentMultipleInit:!!e.silentMultipleInit,batchBytesLimit:16384,eventRateLimiterThreshold:3e3,maxTelemetryEventsPerPage:15,flushTimeout:3e4,batchMessagesLimit:50,messageBytesLimit:262144},ae(e));t.error("Telemetry Configuration Sample Rate should be a number between 0 and 100")}else t.error("Telemetry Sample Rate should be a number between 0 and 100");else t.error("Sample Rate should be a number between 0 and 100");else t.error("Client Token is not configured, we will not send any data.")}function ce(e){var t={};return t.secure=function(e){return!!e.useSecureSessionCookie||!!e.useCrossSiteSessionCookie}(e),t.crossSite=!!e.useCrossSiteSessionCookie,e.trackSessionAcrossSubdomains&&(t.domain=function(){if(void 0===$){for(var e="dd_site_test_".concat(h()),t=window.location.hostname.split("."),n=t.pop();t.length&&!Y(e);)n="".concat(t.pop(),".").concat(n),X(e,"test",l,{domain:n});K(e,{domain:n}),$=n}return $}()),t}var fe="?";function le(e){var t=[],n=we(e,"stack"),r=String(e);return n&&E(n,r)&&(n=n.slice(r.length)),n&&n.split("\n").forEach((function(e){var n=function(e){var t=ve.exec(e);if(!t)return;var n=t[2]&&0===t[2].indexOf("native"),r=t[2]&&0===t[2].indexOf("eval"),o=he.exec(t[2]);r&&o&&(t[2]=o[1],t[3]=o[2],t[4]=o[3]);return{args:n?[t[2]]:[],column:t[4]?+t[4]:void 0,func:t[1]||fe,line:t[3]?+t[3]:void 0,url:n?void 0:t[2]}}(e)||function(e){var t=ge.exec(e);if(!t)return;return{args:[],column:t[3]?+t[3]:void 0,func:fe,line:t[2]?+t[2]:void 0,url:t[1]}}(e)||function(e){var t=ye.exec(e);if(!t)return;return{args:[],column:t[4]?+t[4]:void 0,func:t[1]||fe,line:+t[3],url:t[2]}}(e)||function(e){var t=me.exec(e);if(!t)return;var n=t[3]&&t[3].indexOf(" > eval")>-1,r=be.exec(t[3]);n&&r&&(t[3]=r[1],t[4]=r[2],t[5]=void 0);return{args:t[2]?t[2].split(","):[],column:t[5]?+t[5]:void 0,func:t[1]||fe,line:t[4]?+t[4]:void 0,url:t[3]}}(e);n&&(!n.func&&n.line&&(n.func=fe),t.push(n))})),{message:we(e,"message"),name:we(e,"name"),stack:t}}var de="((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\\w+\\.|\\/).*?)",pe="(?::(\\d+))",ve=new RegExp("^\\s*at (.*?) ?\\(".concat(de).concat(pe,"?").concat(pe,"?\\)?\\s*$"),"i"),he=new RegExp("\\((\\S*)".concat(pe).concat(pe,"\\)"));var ge=new RegExp("^\\s*at ?".concat(de).concat(pe,"?").concat(pe,"??\\s*$"),"i");var ye=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;var me=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|capacitor|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i,be=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;function we(e,t){if("object"==typeof e&&e&&t in e){var n=e[t];return"string"==typeof n?n:void 0}}var Ce="agent",ke="console",xe="logger",Se="network",Ee="source",Re="report";function Te(e){var t=Le(e);return e.stack.forEach((function(e){var n="?"===e.func?"<anonymous>":e.func,r=e.args&&e.args.length>0?"(".concat(e.args.join(", "),")"):"",o=e.line?":".concat(e.line):"",i=e.line&&e.column?":".concat(e.column):"";t+="\n at ".concat(n).concat(r," @ ").concat(e.url).concat(o).concat(i)})),t}function Le(e){return"".concat(e.name||"Error",": ").concat(e.message)}function _e(){var e,t=new Error;if(!t.stack)try{throw t}catch(e){}return c((function(){var n=le(t);n.stack=n.stack.slice(2),e=Te(n)})),e}function Oe(e,t){for(var n=e,r=[];(null==n?void 0:n.cause)instanceof Error&&r.length<10;){var o=le(n.cause);r.push({message:n.cause.message,source:t,type:null==o?void 0:o.name,stack:o&&Te(o)}),n=n.cause}return r.length?r:void 0}var Be=function(){function e(e){this.onFirstSubscribe=e,this.observers=[]}return e.prototype.subscribe=function(e){var t=this;return!this.observers.length&&this.onFirstSubscribe&&(this.onLastUnsubscribe=this.onFirstSubscribe()||void 0),this.observers.push(e),{unsubscribe:function(){t.observers=t.observers.filter((function(t){return e!==t})),!t.observers.length&&t.onLastUnsubscribe&&t.onLastUnsubscribe()}}},e.prototype.notify=function(e){this.observers.forEach((function(t){return t(e)}))},e}();function Me(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=new Be((function(){var t=e.map((function(e){return e.subscribe((function(e){return n.notify(e)}))}));return function(){return t.forEach((function(e){return e.unsubscribe()}))}}));return n}var Pe={intervention:"intervention",deprecation:"deprecation",cspViolation:"csp_violation"};function qe(e){var t,n=[];w(e,Pe.cspViolation)&&n.push(t=new Be((function(){var e=u((function(e){t.notify(function(e){var t=Pe.cspViolation,n="'".concat(e.blockedURI,"' blocked by '").concat(e.effectiveDirective,"' directive");return{type:Pe.cspViolation,subtype:e.effectiveDirective,message:"".concat(t,": ").concat(n),stack:Ie(e.effectiveDirective,e.originalPolicy?"".concat(n,' of the policy "').concat(T(e.originalPolicy,100,"..."),'"'):"no policy",e.sourceFile,e.lineNumber,e.columnNumber)}}(e))}));return L(document,"securitypolicyviolation",e).stop})));var r=e.filter((function(e){return e!==Pe.cspViolation}));return r.length&&n.push(function(e){var t=new Be((function(){if(window.ReportingObserver){var n=u((function(e){return e.forEach((function(e){t.notify(function(e){var t=e.type,n=e.body;return{type:t,subtype:n.id,message:"".concat(t,": ").concat(n.message),stack:Ie(n.id,n.message,n.sourceFile,n.lineNumber,n.columnNumber)}}(e))}))})),r=new window.ReportingObserver(n,{types:e,buffered:!0});return r.observe(),function(){r.disconnect()}}}));return t}(r)),Me.apply(void 0,n)}function Ie(e,t,n,r,o){return n&&Te({name:e,message:t,stack:[{func:"?",url:n,line:r,column:o}]})}function Ae(e,n,r){return void 0===e?[]:"all"===e||Array.isArray(e)&&e.every((function(e){return w(n,e)}))?"all"===e?n:(o=e,i=new Set,o.forEach((function(e){return i.add(e)})),C(i)):void t.error("".concat(r,' should be "all" or an array with allowed values "').concat(n.join('", "'),'"'));var o,i}var Ue=function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},je={debug:"debug",error:"error",info:"info",warn:"warn"},De="console",Fe="http",Ne=Object.keys(je),He=function(){function e(e,t,n,r,o){void 0===n&&(n=Fe),void 0===r&&(r=je.debug),void 0===o&&(o={}),this.handleLogStrategy=e,this.handlerType=n,this.level=r,this.contextManager=q(),this.contextManager.set(v({},o,t?{logger:{name:t}}:void 0))}return e.prototype.log=function(e,t,n){void 0===n&&(n=je.info),this.handleLogStrategy({message:e,context:M(t),status:n},this)},e.prototype.debug=function(e,t){this.log(e,t,je.debug)},e.prototype.info=function(e,t){this.log(e,t,je.info)},e.prototype.warn=function(e,t){this.log(e,t,je.warn)},e.prototype.error=function(e,t){var n={error:{origin:xe}};this.log(e,P(n,t),je.error)},e.prototype.setContext=function(e){this.contextManager.set(e)},e.prototype.getContext=function(){return this.contextManager.get()},e.prototype.addContext=function(e,t){this.contextManager.add(e,t)},e.prototype.removeContext=function(e){this.contextManager.remove(e)},e.prototype.setHandler=function(e){this.handlerType=e},e.prototype.getHandler=function(){return this.handlerType},e.prototype.setLevel=function(e){this.level=e},e.prototype.getLevel=function(){return this.level},Ue([a],e.prototype,"log",null),e}();function Ge(){return Boolean(window._DATADOG_SYNTHETICS_INJECTS_RUM||Y("datadog-synthetics-injects-rum"))}function ze(){var e=window._DATADOG_SYNTHETICS_RESULT_ID||Y("datadog-synthetics-result-id");return"string"==typeof e?e:void 0}var Ve,$e="log",Je="configuration",We=["https://www.datadoghq-browser-agent.com","https://www.datad0g-browser-agent.com","http://localhost","<anonymous>"],Xe=["ddog-gov.com"],Ye={maxEventsPerPage:0,sentEventCount:0,telemetryEnabled:!1,telemetryConfigurationEnabled:!1};function Ke(e,t){var n,o=new Be;return Ye.telemetryEnabled=g(t.telemetrySampleRate),Ye.telemetryConfigurationEnabled=Ye.telemetryEnabled&&g(t.telemetryConfigurationSampleRate),Ve=function(r){!w(Xe,t.site)&&Ye.telemetryEnabled&&o.notify(function(e,t){return P({type:"telemetry",date:j(),service:e,version:"4.26.0",source:"browser",_dd:{format_version:2},telemetry:t,experimental_features:C(Q())},void 0!==n?n():{})}(e,r))},r=Qe,v(Ye,{maxEventsPerPage:t.maxTelemetryEventsPerPage,sentEventCount:0}),{setContextProvider:function(e){n=e},observable:o}}function Qe(e){Ze(v({type:$e,status:"error"},function(e){if(e instanceof Error){var t=le(e);return{error:{kind:t.name,stack:Te(et(t))},message:t.message}}return{error:{stack:"Not an instance of error"},message:"Uncaught ".concat(m(e))}}(e)))}function Ze(e){Ve&&Ye.sentEventCount<Ye.maxEventsPerPage&&(Ye.sentEventCount+=1,Ve(e))}function et(e){return e.stack=e.stack.filter((function(e){return!e.url||We.some((function(t){return E(e.url,t)}))})),e}var tt=/[^\u0000-\u007F]/,nt=function(){function e(e,t,n,r,o,i){var s=this;this.request=e,this.batchMessagesLimit=t,this.batchBytesLimit=n,this.messageBytesLimit=r,this.flushTimeout=o,this.pageExitObservable=i,this.pushOnlyBuffer=[],this.upsertBuffer={},this.bufferBytesCount=0,this.bufferMessagesCount=0,i.subscribe((function(){return s.flush(s.request.sendOnExit)})),this.flushPeriodically()}return e.prototype.add=function(e){this.addOrUpdate(e)},e.prototype.upsert=function(e,t){this.addOrUpdate(e,t)},e.prototype.flush=function(e){if(void 0===e&&(e=this.request.send),0!==this.bufferMessagesCount){var t=this.pushOnlyBuffer.concat(x(this.upsertBuffer)),n=this.bufferBytesCount;this.pushOnlyBuffer=[],this.upsertBuffer={},this.bufferBytesCount=0,this.bufferMessagesCount=0,e({data:t.join("\n"),bytesCount:n})}},e.prototype.computeBytesCount=function(e){return tt.test(e)?void 0!==window.TextEncoder?(new TextEncoder).encode(e).length:new Blob([e]).size:e.length},e.prototype.addOrUpdate=function(e,n){var r=this.process(e),o=r.processedMessage,i=r.messageBytesCount;i>=this.messageBytesLimit?t.warn("Discarded a message whose size was bigger than the maximum allowed size ".concat(this.messageBytesLimit,"KB.")):(this.hasMessageFor(n)&&this.remove(n),this.willReachedBytesLimitWith(i)&&this.flush(),this.push(o,i,n),this.isFull()&&this.flush())},e.prototype.process=function(e){var t=m(e);return{processedMessage:t,messageBytesCount:this.computeBytesCount(t)}},e.prototype.push=function(e,t,n){this.bufferMessagesCount>0&&(this.bufferBytesCount+=1),void 0!==n?this.upsertBuffer[n]=e:this.pushOnlyBuffer.push(e),this.bufferBytesCount+=t,this.bufferMessagesCount+=1},e.prototype.remove=function(e){var t=this.upsertBuffer[e];delete this.upsertBuffer[e];var n=this.computeBytesCount(t);this.bufferBytesCount-=n,this.bufferMessagesCount-=1,this.bufferMessagesCount>0&&(this.bufferBytesCount-=1)},e.prototype.hasMessageFor=function(e){return void 0!==e&&void 0!==this.upsertBuffer[e]},e.prototype.willReachedBytesLimitWith=function(e){return this.bufferBytesCount+e+1>=this.batchBytesLimit},e.prototype.isFull=function(){return this.bufferMessagesCount===this.batchMessagesLimit||this.bufferBytesCount>=this.batchBytesLimit},e.prototype.flushPeriodically=function(){var e=this;setTimeout(u((function(){e.flush(),e.flushPeriodically()})),this.flushTimeout)},e}(),rt=3145728;function ot(e,t,n,r,o){0===t.transportStatus&&0===t.queuedPayloads.size()&&t.bandwidthMonitor.canHandle(e)?st(e,t,n,{onSuccess:function(){return at(0,t,n,r,o)},onFailure:function(){t.queuedPayloads.enqueue(e),it(t,n,r,o)}}):t.queuedPayloads.enqueue(e)}function it(e,t,n,r){2===e.transportStatus&&setTimeout(u((function(){st(e.queuedPayloads.first(),e,t,{onSuccess:function(){e.queuedPayloads.dequeue(),e.currentBackoffTime=1e3,at(1,e,t,n,r)},onFailure:function(){e.currentBackoffTime=Math.min(6e4,2*e.currentBackoffTime),it(e,t,n,r)}})})),e.currentBackoffTime)}function st(e,t,n,r){var o=r.onSuccess,i=r.onFailure;t.bandwidthMonitor.add(e),n(e,(function(n){t.bandwidthMonitor.remove(e),!function(e){return 0===e.status||408===e.status||429===e.status||e.status>=500}(n)?(t.transportStatus=0,o()):(t.transportStatus=t.bandwidthMonitor.ongoingRequestCount>0?1:2,e.retry={count:e.retry?e.retry.count+1:1,lastFailureStatus:n.status},i())}))}function at(e,t,n,r,o){0===e&&t.queuedPayloads.isFull()&&!t.queueFullReported&&(o({message:"Reached max ".concat(r," events size queued for upload: ").concat(3,"MiB"),source:Ce,startClocks:F()}),t.queueFullReported=!0);var i=t.queuedPayloads;for(t.queuedPayloads=ut();i.size()>0;)ot(i.dequeue(),t,n,r,o)}function ut(){var e=[];return{bytesCount:0,enqueue:function(t){this.isFull()||(e.push(t),this.bytesCount+=t.bytesCount)},first:function(){return e[0]},dequeue:function(){var t=e.shift();return t&&(this.bytesCount-=t.bytesCount),t},size:function(){return e.length},isFull:function(){return this.bytesCount>=rt}}}function ct(e,t,n){var r={transportStatus:0,currentBackoffTime:1e3,bandwidthMonitor:{ongoingRequestCount:0,ongoingByteCount:0,canHandle:function(e){return 0===this.ongoingRequestCount||this.ongoingByteCount+e.bytesCount<=81920&&this.ongoingRequestCount<32},add:function(e){this.ongoingRequestCount+=1,this.ongoingByteCount+=e.bytesCount},remove:function(e){this.ongoingRequestCount-=1,this.ongoingByteCount-=e.bytesCount}},queuedPayloads:ut(),queueFullReported:!1},o=function(n,r){return function(e,t,n,r){var o=n.data,i=n.bytesCount,s=n.retry;if(function(){try{return window.Request&&"keepalive"in new Request("http://a")}catch(e){return!1}}()&&i<t){var a=e.build("fetch",s);fetch(a,{method:"POST",body:o,keepalive:!0}).then(u((function(e){return null==r?void 0:r({status:e.status})})),u((function(){lt(e.build("xhr",s),o,r)})))}else{lt(e.build("xhr",s),o,r)}}(e,t,n,r)};return{send:function(t){ot(t,r,o,e.endpointType,n)},sendOnExit:function(n){!function(e,t,n){var r=n.data,o=n.bytesCount;if(navigator.sendBeacon&&o<t)try{var i=e.build("beacon");if(navigator.sendBeacon(i,r))return}catch(e){!function(e){ft||(ft=!0,Qe(e))}(e)}lt(e.build("xhr"),r)}(e,t,n)}}}var ft=!1;function lt(e,t,n){var r=new XMLHttpRequest,o=u((function(){r.removeEventListener("loadend",o),null==n||n({status:r.status})}));r.open("POST",e,!0),r.addEventListener("loadend",o),r.send(t)}function dt(e,t,n,r,o){var i,s=a(t);function a(t){return new nt(ct(t,e.batchBytesLimit,n),e.batchMessagesLimit,e.batchBytesLimit,e.messageBytesLimit,e.flushTimeout,r)}return o&&(i=a(o)),{add:function(e,t){void 0===t&&(t=!0),s.add(e),i&&t&&i.add(e)}}}var pt=1/0,vt=function(){function e(e){var t=this;this.expireDelay=e,this.entries=[],this.clearOldContextsInterval=setInterval((function(){return t.clearOldContexts()}),6e4)}return e.prototype.add=function(e,t){var n=this,r={context:e,startTime:t,endTime:pt,remove:function(){var e=n.entries.indexOf(r);e>=0&&n.entries.splice(e,1)},close:function(e){r.endTime=e}};return this.entries.unshift(r),r},e.prototype.find=function(e){void 0===e&&(e=pt);for(var t=0,n=this.entries;t<n.length;t++){var r=n[t];if(r.startTime<=e){if(e<=r.endTime)return r.context;break}}},e.prototype.closeActive=function(e){var t=this.entries[0];t&&t.endTime===pt&&t.close(e)},e.prototype.findAll=function(e){return void 0===e&&(e=pt),this.entries.filter((function(t){return t.startTime<=e&&e<=t.endTime})).map((function(e){return e.context}))},e.prototype.reset=function(){this.entries=[]},e.prototype.stop=function(){clearInterval(this.clearOldContextsInterval)},e.prototype.clearOldContexts=function(){for(var e=D()-this.expireDelay;this.entries.length>0&&this.entries[this.entries.length-1].endTime<e;)this.entries.pop()},e}();var ht,gt=144e5,yt=9e5,mt=/^([a-z]+)=([a-z0-9-]+)$/,bt="&",wt="_dd_s",Ct=[];function kt(e,t){var n;if(void 0===t&&(t=0),ht||(ht=e),e===ht)if(t>=100)Et();else{var r,o=Lt();if(xt()){if(o.lock)return void St(e,t);if(r=h(),o.lock=r,Tt(o,e.options),(o=Lt()).lock!==r)return void St(e,t)}var i=e.process(o);if(xt()&&(o=Lt()).lock!==r)St(e,t);else{if(i&&Rt(i,e.options),xt()&&(!i||!_t(i))){if((o=Lt()).lock!==r)return void St(e,t);delete o.lock,Tt(o,e.options),i=o}null===(n=e.after)||void 0===n||n.call(e,i||o),Et()}}else Ct.push(e)}function xt(){return!!window.chrome||/HeadlessChrome/.test(window.navigator.userAgent)}function St(e,t){setTimeout(u((function(){kt(e,t+1)})),10)}function Et(){ht=void 0;var e=Ct.shift();e&&kt(e)}function Rt(e,t){_t(e)?function(e){X(wt,"",0,e)}(t):(e.expire=String(U()+yt),Tt(e,t))}function Tt(e,t){X(wt,function(e){return(t=e,Object.keys(t).map((function(e){return[e,t[e]]}))).map((function(e){var t=e[0],n=e[1];return"".concat(t,"=").concat(n)})).join(bt);var t}(e),yt,t)}function Lt(){var e=Y(wt),t={};return function(e){return void 0!==e&&(-1!==e.indexOf(bt)||mt.test(e))}(e)&&e.split(bt).forEach((function(e){var n=mt.exec(e);if(null!==n){var r=n[1],o=n[2];t[r]=o}})),t}function _t(e){return S(e)}function Ot(e,t,n){var r=new Be,o=new Be,i=setInterval(u((function(){kt({options:e,process:function(e){return f(e)?void 0:{}},after:a})})),1e3),s=function(){var e=Lt();if(f(e))return e;return{}}();function a(e){return f(e)||(e={}),c()&&(!function(e){return s.id!==e.id||s[t]!==e[t]}(e)?s=e:(s={},o.notify())),e}function c(){return void 0!==s[t]}function f(e){return(void 0===e.created||U()-Number(e.created)<gt)&&(void 0===e.expire||U()<Number(e.expire))}return{expandOrRenewSession:p(u((function(){var o;kt({options:e,process:function(e){var r=a(e);return o=function(e){var r=n(e[t]),o=r.trackingType,i=r.isTracked;e[t]=o,i&&!e.id&&(e.id=h(),e.created=String(U()));return i}(r),r},after:function(e){o&&!c()&&function(e){s=e,r.notify()}(e),s=e}})})),1e3).throttled,expandSession:function(){kt({options:e,process:function(e){return c()?a(e):void 0}})},getSession:function(){return s},renewObservable:r,expireObservable:o,stop:function(){clearInterval(i)}}}var Bt=[];function Mt(e,t,n){!function(e){var t=Y(wt),n=Y("_dd"),r=Y("_dd_r"),o=Y("_dd_l");if(!t){var i={};n&&(i.id=n),o&&/^[01]$/.test(o)&&(i.logs=o),r&&/^[012]$/.test(r)&&(i.rum=r),Rt(i,e)}}(e);var r=Ot(e,t,n);Bt.push((function(){return r.stop()}));var o,i=new vt(144e5);function s(){return{id:r.getSession().id,trackingType:r.getSession()[t]}}return Bt.push((function(){return i.stop()})),r.renewObservable.subscribe((function(){i.add(s(),D())})),r.expireObservable.subscribe((function(){i.closeActive(D())})),r.expandOrRenewSession(),i.add(s(),[0,H()][0]),o=_(window,["click","touchstart","keydown","scroll"],(function(){return r.expandOrRenewSession()}),{capture:!0,passive:!0}).stop,Bt.push(o),function(e){var t=u((function(){"visible"===document.visibilityState&&e()})),n=L(document,"visibilitychange",t).stop;Bt.push(n);var r=setInterval(t,6e4);Bt.push((function(){clearInterval(r)}))}((function(){return r.expandSession()})),{findActiveSession:function(e){return i.find(e)},renewObservable:r.renewObservable,expireObservable:r.expireObservable}}var Pt;function qt(e){var t=Mt(e.cookieOptions,"logs",(function(t){return function(e,t){var n=function(e){return"0"===e||"1"===e}(t)?t:It(e);return{trackingType:n,isTracked:"1"===n}}(e,t)}));return{findTrackedSession:function(e){var n=t.findActiveSession(e);return n&&"1"===n.trackingType?{id:n.id}:void 0}}}function It(e){return g(e.sampleRate)?"1":"0"}var At=((Pt={})[je.debug]=0,Pt[je.info]=1,Pt[je.warn]=2,Pt[je.error]=3,Pt);function Ut(e,t,n){var r=n.getHandler(),o=Array.isArray(r)?r:[r];return At[e]>=At[n.getLevel()]&&w(o,t)}function jt(e,t,n,r,o,i){var s=Ne.concat(["custom"]),a={};s.forEach((function(e){var n,r,o,s,u;a[e]=(n=e,r=t.eventRateLimiterThreshold,o=i,s=0,u=!1,{isLimitReached:function(){if(0===s&&setTimeout((function(){s=0}),d),(s+=1)<=r||u)return u=!1,!1;if(s===r+1){u=!0;try{o({message:"Reached max number of ".concat(n,"s by minute: ").concat(r),source:Ce,startClocks:F()})}finally{u=!1}}return!0}})})),n.subscribe(0,(function(i){var s,u,c,f=i.rawLogsEvent,l=i.messageContext,d=void 0===l?void 0:l,p=i.savedCommonContext,v=void 0===p?void 0:p,h=i.logger,g=void 0===h?o:h,y=f.date-H(),m=e.findTrackedSession(y);if(m){var b=v||r(),w=P({service:t.service,session_id:m.id,usr:S(b.user)?void 0:b.user,view:b.view},b.context,Ft(y),f,g.getContext(),d);!Ut(f.status,Fe,g)||!1===(null===(s=t.beforeSend)||void 0===s?void 0:s.call(t,w))||(null===(u=w.error)||void 0===u?void 0:u.origin)!==Ce&&(null!==(c=a[w.status])&&void 0!==c?c:a.custom).isLimitReached()||n.notify(1,w)}}))}var Dt=!1;function Ft(t){var n,r=window;if(Ge()){var o=i(r.DD_RUM_SYNTHETICS);return o||Dt||(Dt=!0,function(t,n){f(e.debug,t,n),Ze(v({type:$e,message:t,status:"debug"},n))}("Logs sent before RUM is injected by the synthetics worker",{testId:(n=window._DATADOG_SYNTHETICS_PUBLIC_ID||Y("datadog-synthetics-public-id"),"string"==typeof n?n:void 0),resultId:ze()})),o}return i(r.DD_RUM);function i(e){if(e&&e.getInternalContext)return e.getInternalContext(t)}}var Nt,Ht={};function Gt(e){var t=e.map((function(e){return Ht[e]||(Ht[e]=function(e){var t=new Be((function(){var n=console[e];return console[e]=function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];n.apply(console,r);var i=_e();c((function(){t.notify(zt(r,e,i))}))},function(){console[e]=n}}));return t}(e)),Ht[e]}));return Me.apply(void 0,t)}function zt(t,n,r){var o,i=t.map((function(e){return function(e){if("string"==typeof e)return e;if(e instanceof Error)return Le(le(e));return m(e,void 0,2)}(e)})).join(" ");if(n===e.error){var s=function(e,t){for(var n=0;n<e.length;n+=1){var r=e[n];if(t(r,n))return r}}(t,(function(e){return e instanceof Error}));o=s?Te(le(s)):void 0,i="console error: ".concat(i)}return{api:n,message:i,stack:o,handlingStack:r}}var Vt,$t=((Nt={})[e.log]=je.info,Nt[e.debug]=je.debug,Nt[e.info]=je.info,Nt[e.warn]=je.warn,Nt[e.error]=je.error,Nt);var Jt,Wt=((Vt={})[Pe.cspViolation]=je.error,Vt[Pe.intervention]=je.error,Vt[Pe.deprecation]=je.warn,Vt);function Xt(e,t,n){var r=e[t],o=n(r),i=function(){if("function"==typeof o)return o.apply(this,arguments)};return e[t]=i,{stop:function(){e[t]===i?e[t]=r:o=r}}}function Yt(e,t,n){var r=n.before,o=n.after;return Xt(e,t,(function(e){return function(){var t,n=arguments;return r&&c(r,this,n),"function"==typeof e&&(t=e.apply(this,n)),o&&c(o,this,n),t}}))}var Kt,Qt=new WeakMap;function Zt(){var e;return Jt||(e=new Be((function(){var t=Yt(XMLHttpRequest.prototype,"open",{before:en}).stop,n=Yt(XMLHttpRequest.prototype,"send",{before:function(){tn.call(this,e)}}).stop,r=Yt(XMLHttpRequest.prototype,"abort",{before:nn}).stop;return function(){t(),n(),r()}})),Jt=e),Jt}function en(e,t){Qt.set(this,{state:"open",method:e,url:Z(String(t))})}function tn(e){var t=this,n=Qt.get(this);if(n){var r=n;r.state="start",r.startTime=D(),r.startClocks=F(),r.isAborted=!1,r.xhr=this;var o=!1,i=Yt(this,"onreadystatechange",{before:function(){this.readyState===XMLHttpRequest.DONE&&s()}}).stop,s=u((function(){if(t.removeEventListener("loadend",s),i(),!o){o=!0;var a=n;a.state="complete",a.duration=N(r.startClocks.timeStamp,j()),a.status=t.status,e.notify(v({},a))}}));this.addEventListener("loadend",s),e.notify(r)}}function nn(){var e=Qt.get(this);e&&(e.isAborted=!0)}function rn(){var e;return Kt||(e=new Be((function(){if(window.fetch)return Xt(window,"fetch",(function(t){return function(n,r){var o,i=c(on,null,[e,n,r]);return i?(o=t.call(this,i.input,i.init),c(sn,null,[e,o,i])):o=t.call(this,n,r),o}})).stop})),Kt=e),Kt}function on(e,t,n){var r=n&&n.method||"object"==typeof t&&t.method||"GET",o=Z("object"==typeof t&&t.url||t),i={state:"start",init:n,input:t,method:r,startClocks:F(),url:o};return e.notify(i),i}function sn(e,t,n){var r=function(t){var r=n;r.state="resolve",r.resolveDuration=N(n.startClocks.timeStamp,j()),"stack"in t||t instanceof Error?(r.status=0,r.isAborted=t instanceof DOMException&&t.code===DOMException.ABORT_ERR,r.error=t):"status"in t&&(r.response=t,r.responseType=t.type,r.status=t.status,r.isAborted=!1),e.notify(r)};t.then(u(r),u(r))}function an(e,t){if(!e.forwardErrorsToLogs)return{stop:y};var n=Zt().subscribe((function(e){"complete"===e.state&&o("xhr",e)})),r=rn().subscribe((function(e){"resolve"===e.state&&o("fetch",e)}));function o(n,r){function o(e){t.notify(0,{rawLogsEvent:{message:"".concat(cn(n)," error ").concat(r.method," ").concat(r.url),date:r.startClocks.timeStamp,error:{origin:Se,stack:e||"Failed to load"},http:{method:r.method,status_code:r.status,url:r.url},status:je.error,origin:Se}})}e.isIntakeUrl(r.url)||!function(e){return 0===e.status&&"opaque"!==e.responseType}(r)&&!function(e){return e.status>=500}(r)||("xhr"in r?function(e,t,n){"string"==typeof e.response?n(un(e.response,t)):n(e.response)}(r.xhr,e,o):r.response?function(e,t,n){window.TextDecoder?e.body?function(e,t,n){!function(e,t,n){var r=e.getReader(),o=[],i=0;function s(){var e,s;if(r.cancel().catch(y),n.collectStreamBody){var a;if(1===o.length)a=o[0];else{a=new Uint8Array(i);var u=0;o.forEach((function(e){a.set(e,u),u+=e.length}))}e=a.slice(0,n.bytesLimit),s=a.length>n.bytesLimit}t(void 0,e,s)}!function e(){r.read().then(u((function(t){t.done?s():(n.collectStreamBody&&o.push(t.value),(i+=t.value.length)>n.bytesLimit?s():e())})),u((function(e){return t(e)})))}()}(e,(function(e,t,r){if(e)n(e);else{var o=(new TextDecoder).decode(t);r&&(o+="..."),n(void 0,o)}}),{bytesLimit:t,collectStreamBody:!0})}(e.clone().body,t.requestErrorResponseLengthLimit,(function(e,t){n(e?"Unable to retrieve response: ".concat(e):t)})):n():e.clone().text().then(u((function(e){return n(un(e,t))})),u((function(e){return n("Unable to retrieve response: ".concat(e))})))}(r.response,e,o):r.error&&function(e,t,n){n(un(Te(le(e)),t))}(r.error,e,o))}return{stop:function(){n.unsubscribe(),r.unsubscribe()}}}function un(e,t){return e.length>t.requestErrorResponseLengthLimit?"".concat(e.substring(0,t.requestErrorResponseLengthLimit),"..."):e}function cn(e){return"xhr"===e?"XHR":"Fetch"}var fn=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/;function ln(e){var t=function(e){return Yt(window,"onerror",{before:function(t,n,r,o,i){var s;if(i)s=le(i),e(s,i);else{var a,u={url:n,column:o,line:r},c=t;if("[object String]"==={}.toString.call(t)){var f=fn.exec(c);f&&(a=f[1],c=f[2])}e(s={name:a,message:"string"==typeof c?c:void 0,stack:[u]},t)}}})}(e).stop,n=function(e){return Yt(window,"onunhandledrejection",{before:function(t){var n=t.reason||"Empty reason",r=le(n);e(r,n)}})}(e).stop;return{stop:function(){t(),n()}}}function dn(e){return ln((function(t,n){e.notify(function(e){var t=e.stackTrace,n=e.originalError,r=e.handlingStack,o=e.startClocks,i=e.nonErrorPrefix,s=e.source,a=e.handling;return t&&(void 0!==t.message||n instanceof Error)?{startClocks:o,source:s,handling:a,originalError:n,message:t.message||"Empty message",stack:Te(t),handlingStack:r,type:t.name,causes:Oe(n,s)}:{startClocks:o,source:s,handling:a,originalError:n,message:"".concat(i," ").concat(m(n)),stack:"No stack, consider using an instance of Error",handlingStack:r,type:t&&t.name}}({stackTrace:t,originalError:n,startClocks:F(),nonErrorPrefix:"Uncaught",source:Ee,handling:"unhandled"}))}))}var pn=function(){function e(){this.callbacks={}}return e.prototype.notify=function(e,t){var n=this.callbacks[e];n&&n.forEach((function(e){return e(t)}))},e.prototype.subscribe=function(e,t){var n=this;return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),{unsubscribe:function(){n.callbacks[e]=n.callbacks[e].filter((function(e){return t!==e}))}}},e}();var vn,hn,gn,yn,mn=function(n){var r,o,i=!1,a=q(),c=q(),f={},l=function(){},d=new A,p=function(e,t,n,r){void 0===n&&(n=M(y())),void 0===r&&(r=j()),d.add((function(){return p(e,t,n,r)}))},h=function(){},g=new He((function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return p.apply(void 0,e)}));function y(){return{view:{referrer:document.referrer,url:window.location.href},context:a.getContext(),user:c.getContext()}}return r={logger:g,init:u((function(r){var o;if(z()&&(r=function(e){return v({},e,{clientToken:"empty"})}(r)),function(e){return!i||(e.silentMultipleInit||t.error("DD_LOGS is already initialized."),!1)}(r)){var s=function(t){var n=ue(t),r=Ae(t.forwardConsoleLogs,x(e),"Forward Console Logs"),o=Ae(t.forwardReports,x(Pe),"Forward Reports");if(n&&r&&o)return t.forwardErrorsToLogs&&!w(r,e.error)&&r.push(e.error),v({forwardErrorsToLogs:!1!==t.forwardErrorsToLogs,forwardConsoleLogs:r,forwardReports:o,requestErrorResponseLengthLimit:32768},n)}(r);s&&(o=n(r,s,y,g),p=o.handleLog,l=o.getInternalContext,h=function(){return M(r)},d.drain(),i=!0)}})),getLoggerGlobalContext:u(a.get),getGlobalContext:u(a.getContext),setLoggerGlobalContext:u(a.set),setGlobalContext:u(a.setContext),addLoggerGlobalContext:u(a.add),setGlobalContextProperty:u(a.setContextProperty),removeLoggerGlobalContext:u(a.remove),removeGlobalContextProperty:u(a.removeContextProperty),clearGlobalContext:u(a.clearContext),createLogger:u((function(e,t){return void 0===t&&(t={}),f[e]=new He((function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return p.apply(void 0,e)}),e,t.handler,t.level,t.context),f[e]})),getLogger:u((function(e){return f[e]})),getInitConfiguration:u((function(){return h()})),getInternalContext:u((function(e){return l(e)})),setUser:u((function(e){(function(e){var n="object"===O(e);return n||t.error("Unsupported user:",e),n})(e)&&c.setContext(V(e))})),getUser:u(c.getContext),setUserProperty:u((function(e,t){var n,r=V((n={},n[e]=t,n))[e];c.setContextProperty(e,r)})),removeUserProperty:u(c.removeContextProperty),clearUser:u(c.clearContext)},o=v({version:"4.26.0",onReady:function(e){e()}},r),Object.defineProperty(o,"_setDebug",{get:function(){return s},enumerable:!1}),o}((function(n,r,o,i){var s,a=new pn,u=function(e){return a.notify(0,{rawLogsEvent:{message:e.message,date:e.startClocks.timeStamp,error:{origin:Ce},origin:Ce,status:je.error}})},c=s=new Be((function(){var e=L(document,"visibilitychange",(function(){"hidden"===document.visibilityState&&s.notify({reason:"visibility_hidden"})}),{capture:!0}).stop,t=L(window,"beforeunload",(function(){s.notify({reason:"before_unload"})})).stop;return function(){e(),t()}})),f=function(e,t,n){var r,o=Ke("browser-logs-sdk",e);if(z()){var i=G();o.observable.subscribe((function(e){return i.send("internal_telemetry",e)}))}else{var s=dt(e,e.rumEndpointBuilder,t,n,null===(r=e.replica)||void 0===r?void 0:r.rumEndpointBuilder);o.observable.subscribe((function(t){return s.add(t,function(e){return"datad0g.com"===e.site}(e))}))}return o}(r,u,c);f.setContextProvider((function(){var e,t,n,r,o,i;return{application:{id:null===(e=Ft())||void 0===e?void 0:e.application_id},session:{id:null===(t=g.findTrackedSession())||void 0===t?void 0:t.id},view:{id:null===(r=null===(n=Ft())||void 0===n?void 0:n.view)||void 0===r?void 0:r.id},action:{id:null===(i=null===(o=Ft())||void 0===o?void 0:o.user_action)||void 0===i?void 0:i.id}}})),an(r,a),function(e,t){if(!e.forwardErrorsToLogs)return{stop:y};var n=new Be,r=dn(n).stop,o=n.subscribe((function(e){t.notify(0,{rawLogsEvent:{message:e.message,date:e.startClocks.timeStamp,error:{kind:e.type,origin:Ee,stack:e.stack},origin:Ee,status:je.error}})}))}(r,a),function(t,n){var r=Gt(t.forwardConsoleLogs).subscribe((function(t){n.notify(0,{rawLogsEvent:{date:j(),message:t.message,origin:ke,error:t.api===e.error?{origin:ke,stack:t.stack}:void 0,status:$t[t.api]}})}))}(r,a),function(e,t){var n=qe(e.forwardReports).subscribe((function(e){var n,r=e.message,o=Wt[e.type];o===je.error?n={kind:e.subtype,origin:Re,stack:e.stack}:e.stack&&(r+=" Found in ".concat(function(e){var t;return null===(t=/@ (.+)/.exec(e))||void 0===t?void 0:t[1]}(e.stack))),t.notify(0,{rawLogsEvent:{date:j(),message:r,origin:Re,error:n,status:o}})}))}(r,a);var d,p=function(e){return{handleLog:function(n,r,o,i){var s=n.context;Ut(n.status,De,r)&&t(n.status,n.message,P(r.getContext(),s)),e.notify(0,{rawLogsEvent:{date:i||j(),message:n.message,status:n.status,origin:xe},messageContext:s,savedCommonContext:o,logger:r})}}}(a).handleLog,g=!function(e){if(void 0===document.cookie||null===document.cookie)return!1;try{var n="dd_cookie_test_".concat(h()),r="test";X(n,r,l,e);var o=Y(n)===r;return K(n,e),o}catch(e){return t.error(e),!1}}(r.cookieOptions)||z()||Ge()?function(e){var t="1"===It(e)?{}:void 0;return{findTrackedSession:function(){return t}}}(r):qt(r);return jt(g,r,a,o,i,u),z()?function(e){var t=G();e.subscribe(1,(function(e){t.send("log",e)}))}(a):function(e,t,n,r){var o,i=dt(e,e.logsEndpointBuilder,n,r,null===(o=e.replica)||void 0===o?void 0:o.logsEndpointBuilder);t.subscribe(1,(function(e){i.add(e)}))}(r,a,u,c),function(e){Ye.telemetryConfigurationEnabled&&Ze({type:Je,configuration:e})}(function(e){var t=function(e){return{session_sample_rate:e.sampleRate,telemetry_sample_rate:e.telemetrySampleRate,telemetry_configuration_sample_rate:e.telemetryConfigurationSampleRate,use_before_send:!!e.beforeSend,use_cross_site_session_cookie:e.useCrossSiteSessionCookie,use_secure_session_cookie:e.useSecureSessionCookie,use_proxy:void 0!==e.proxyUrl?!!e.proxyUrl:void 0,silent_multiple_init:e.silentMultipleInit,track_session_across_subdomains:e.trackSessionAcrossSubdomains,track_resources:e.trackResources,track_long_task:e.trackLongTasks}}(e);return v({forward_errors_to_logs:e.forwardErrorsToLogs,forward_console_logs:e.forwardConsoleLogs,forward_reports:e.forwardReports},t)}(n)),{handleLog:p,getInternalContext:(d=g,{get:function(e){var t=d.findTrackedSession(e);if(t)return{session_id:t.id}}}).get}}));vn=R(),gn=mn,yn=vn[hn="DD_LOGS"],vn[hn]=gn,yn&&yn.q&&yn.q.forEach((function(e){return n(e,"onReady callback threw an error:")()}))}(); |
@@ -12,11 +12,11 @@ "use strict"; | ||
if (context.state === 'complete') { | ||
handleCompleteRequest("xhr" /* XHR */, context); | ||
handleResponse("xhr" /* XHR */, context); | ||
} | ||
}); | ||
var fetchSubscription = (0, browser_core_1.initFetchObservable)().subscribe(function (context) { | ||
if (context.state === 'complete') { | ||
handleCompleteRequest("fetch" /* FETCH */, context); | ||
if (context.state === 'resolve') { | ||
handleResponse("fetch" /* FETCH */, context); | ||
} | ||
}); | ||
function handleCompleteRequest(type, request) { | ||
function handleResponse(type, request) { | ||
if (!configuration.isIntakeUrl(request.url) && (isRejected(request) || isServerError(request))) { | ||
@@ -146,4 +146,4 @@ if ('xhr' in request) { | ||
} | ||
function truncateResponseStream(stream, limit, callback) { | ||
readLimitedAmountOfBytes(stream, limit, function (error, bytes, limitExceeded) { | ||
function truncateResponseStream(stream, bytesLimit, callback) { | ||
(0, browser_core_1.readBytesFromStream)(stream, function (error, bytes, limitExceeded) { | ||
if (error) { | ||
@@ -159,53 +159,7 @@ callback(error); | ||
} | ||
}, { | ||
bytesLimit: bytesLimit, | ||
collectStreamBody: true, | ||
}); | ||
} | ||
/** | ||
* Read bytes from a ReadableStream until at least `limit` bytes have been read (or until the end of | ||
* the stream). The callback is invoked with the at most `limit` bytes, and indicates that the limit | ||
* has been exceeded if more bytes were available. | ||
*/ | ||
function readLimitedAmountOfBytes(stream, limit, callback) { | ||
var reader = stream.getReader(); | ||
var chunks = []; | ||
var readBytesCount = 0; | ||
readMore(); | ||
function readMore() { | ||
reader.read().then((0, browser_core_1.monitor)(function (result) { | ||
if (result.done) { | ||
onDone(); | ||
return; | ||
} | ||
chunks.push(result.value); | ||
readBytesCount += result.value.length; | ||
if (readBytesCount > limit) { | ||
onDone(); | ||
} | ||
else { | ||
readMore(); | ||
} | ||
}), (0, browser_core_1.monitor)(function (error) { return callback(error); })); | ||
} | ||
function onDone() { | ||
reader.cancel().catch( | ||
// we don't care if cancel fails, but we still need to catch the error to avoid reporting it | ||
// as an unhandled rejection | ||
browser_core_1.noop); | ||
var completeBuffer; | ||
if (chunks.length === 1) { | ||
// optim: if the response is small enough to fit in a single buffer (provided by the browser), just | ||
// use it directly. | ||
completeBuffer = chunks[0]; | ||
} | ||
else { | ||
// else, we need to copy buffers into a larger buffer to concatenate them. | ||
completeBuffer = new Uint8Array(readBytesCount); | ||
var offset_1 = 0; | ||
chunks.forEach(function (chunk) { | ||
completeBuffer.set(chunk, offset_1); | ||
offset_1 += chunk.length; | ||
}); | ||
} | ||
callback(undefined, completeBuffer.slice(0, limit), completeBuffer.length > limit); | ||
} | ||
} | ||
//# sourceMappingURL=networkErrorCollection.js.map |
@@ -1,2 +0,2 @@ | ||
import { ErrorSource, initXhrObservable, initFetchObservable, computeStackTrace, toStackTraceString, monitor, noop, } from '@datadog/browser-core'; | ||
import { ErrorSource, initXhrObservable, initFetchObservable, computeStackTrace, toStackTraceString, monitor, noop, readBytesFromStream, } from '@datadog/browser-core'; | ||
import { StatusType } from '../../logger'; | ||
@@ -9,11 +9,11 @@ export function startNetworkErrorCollection(configuration, lifeCycle) { | ||
if (context.state === 'complete') { | ||
handleCompleteRequest("xhr" /* XHR */, context); | ||
handleResponse("xhr" /* XHR */, context); | ||
} | ||
}); | ||
var fetchSubscription = initFetchObservable().subscribe(function (context) { | ||
if (context.state === 'complete') { | ||
handleCompleteRequest("fetch" /* FETCH */, context); | ||
if (context.state === 'resolve') { | ||
handleResponse("fetch" /* FETCH */, context); | ||
} | ||
}); | ||
function handleCompleteRequest(type, request) { | ||
function handleResponse(type, request) { | ||
if (!configuration.isIntakeUrl(request.url) && (isRejected(request) || isServerError(request))) { | ||
@@ -139,4 +139,4 @@ if ('xhr' in request) { | ||
} | ||
function truncateResponseStream(stream, limit, callback) { | ||
readLimitedAmountOfBytes(stream, limit, function (error, bytes, limitExceeded) { | ||
function truncateResponseStream(stream, bytesLimit, callback) { | ||
readBytesFromStream(stream, function (error, bytes, limitExceeded) { | ||
if (error) { | ||
@@ -152,53 +152,7 @@ callback(error); | ||
} | ||
}, { | ||
bytesLimit: bytesLimit, | ||
collectStreamBody: true, | ||
}); | ||
} | ||
/** | ||
* Read bytes from a ReadableStream until at least `limit` bytes have been read (or until the end of | ||
* the stream). The callback is invoked with the at most `limit` bytes, and indicates that the limit | ||
* has been exceeded if more bytes were available. | ||
*/ | ||
function readLimitedAmountOfBytes(stream, limit, callback) { | ||
var reader = stream.getReader(); | ||
var chunks = []; | ||
var readBytesCount = 0; | ||
readMore(); | ||
function readMore() { | ||
reader.read().then(monitor(function (result) { | ||
if (result.done) { | ||
onDone(); | ||
return; | ||
} | ||
chunks.push(result.value); | ||
readBytesCount += result.value.length; | ||
if (readBytesCount > limit) { | ||
onDone(); | ||
} | ||
else { | ||
readMore(); | ||
} | ||
}), monitor(function (error) { return callback(error); })); | ||
} | ||
function onDone() { | ||
reader.cancel().catch( | ||
// we don't care if cancel fails, but we still need to catch the error to avoid reporting it | ||
// as an unhandled rejection | ||
noop); | ||
var completeBuffer; | ||
if (chunks.length === 1) { | ||
// optim: if the response is small enough to fit in a single buffer (provided by the browser), just | ||
// use it directly. | ||
completeBuffer = chunks[0]; | ||
} | ||
else { | ||
// else, we need to copy buffers into a larger buffer to concatenate them. | ||
completeBuffer = new Uint8Array(readBytesCount); | ||
var offset_1 = 0; | ||
chunks.forEach(function (chunk) { | ||
completeBuffer.set(chunk, offset_1); | ||
offset_1 += chunk.length; | ||
}); | ||
} | ||
callback(undefined, completeBuffer.slice(0, limit), completeBuffer.length > limit); | ||
} | ||
} | ||
//# sourceMappingURL=networkErrorCollection.js.map |
{ | ||
"name": "@datadog/browser-logs", | ||
"version": "4.25.0", | ||
"version": "4.26.0", | ||
"license": "Apache-2.0", | ||
@@ -16,6 +16,6 @@ "main": "cjs/entries/main.js", | ||
"dependencies": { | ||
"@datadog/browser-core": "4.25.0" | ||
"@datadog/browser-core": "4.26.0" | ||
}, | ||
"peerDependencies": { | ||
"@datadog/browser-rum": "4.25.0" | ||
"@datadog/browser-rum": "4.26.0" | ||
}, | ||
@@ -36,3 +36,3 @@ "peerDependenciesMeta": { | ||
}, | ||
"gitHead": "f66e5c81ad28c86a74ecd319cc10290e875442e9" | ||
"gitHead": "d00b17d0484fee1a1e880987aa314a113dff0da6" | ||
} |
@@ -76,3 +76,3 @@ import { ErrorSource, display, stopSessionManager, getCookie, SESSION_COOKIE_NAME } from '@datadog/browser-core' | ||
expect(requests.length).toEqual(1) | ||
expect(requests[0].url).toContain(baseConfiguration.logsEndpointBuilder.build()) | ||
expect(requests[0].url).toContain(baseConfiguration.logsEndpointBuilder.build('xhr')) | ||
expect(getLoggedMessage(requests, 0)).toEqual({ | ||
@@ -79,0 +79,0 @@ date: jasmine.any(Number), |
@@ -229,32 +229,9 @@ import { isIE, ErrorSource } from '@datadog/browser-core' | ||
it('reads a limited amount of bytes from the response', (done) => { | ||
// Creates a response that stream "f" indefinitely, one byte at a time | ||
const cancelSpy = jasmine.createSpy() | ||
const pullSpy = jasmine.createSpy().and.callFake((controller: ReadableStreamDefaultController<Uint8Array>) => { | ||
controller.enqueue(new TextEncoder().encode('f')) | ||
}) | ||
const response = new ResponseStub({ | ||
body: new ReadableStream({ | ||
pull: pullSpy, | ||
cancel: cancelSpy, | ||
}), | ||
}) | ||
computeFetchResponseText(response, CONFIGURATION, () => { | ||
expect(pullSpy).toHaveBeenCalledTimes( | ||
// readLimitedAmountOfBytes may read one more byte than necessary to make sure it exceeds the limit | ||
CONFIGURATION.requestErrorResponseLengthLimit + 1 | ||
) | ||
expect(cancelSpy).toHaveBeenCalledTimes(1) | ||
done() | ||
}) | ||
}) | ||
it('truncates the response if its size is greater than the limit', (done) => { | ||
const text = 'foobar' | ||
it('does not truncate the response if its size is equal to the limit', (done) => { | ||
const text = 'foo' | ||
computeFetchResponseText( | ||
new ResponseStub({ responseText: text }), | ||
{ ...CONFIGURATION, requestErrorResponseLengthLimit: text.length - 1 }, | ||
{ ...CONFIGURATION, requestErrorResponseLengthLimit: text.length }, | ||
(responseData) => { | ||
expect(responseData).toBe('fooba...') | ||
expect(responseData).toBe(text) | ||
done() | ||
@@ -265,9 +242,9 @@ } | ||
it('does not truncate the response if its size is equal to the limit', (done) => { | ||
const text = 'foo' | ||
it('truncates the response if its size is greater than the limit', (done) => { | ||
const text = 'foobar' | ||
computeFetchResponseText( | ||
new ResponseStub({ responseText: text }), | ||
{ ...CONFIGURATION, requestErrorResponseLengthLimit: text.length }, | ||
{ ...CONFIGURATION, requestErrorResponseLengthLimit: text.length - 1 }, | ||
(responseData) => { | ||
expect(responseData).toBe(text) | ||
expect(responseData).toBe('fooba...') | ||
done() | ||
@@ -277,19 +254,2 @@ } | ||
}) | ||
it('does not yield an unhandled rejection error if the cancel promise is rejected', (done) => { | ||
// Creates a response that stream "f" indefinitely and fails to be canceled | ||
const response = new ResponseStub({ | ||
body: new ReadableStream({ | ||
pull: (controller) => controller.enqueue(new TextEncoder().encode('f')), | ||
cancel: () => Promise.reject(new Error('foo')), | ||
}), | ||
}) | ||
computeFetchResponseText(response, CONFIGURATION, () => { | ||
setTimeout(() => { | ||
expect(onunhandledrejectionSpy).not.toHaveBeenCalled() | ||
done() | ||
}) | ||
}) | ||
}) | ||
}) | ||
@@ -296,0 +256,0 @@ |
@@ -1,2 +0,2 @@ | ||
import type { FetchCompleteContext, XhrCompleteContext } from '@datadog/browser-core' | ||
import type { FetchResolveContext, XhrCompleteContext } from '@datadog/browser-core' | ||
import { | ||
@@ -11,2 +11,3 @@ ErrorSource, | ||
noop, | ||
readBytesFromStream, | ||
} from '@datadog/browser-core' | ||
@@ -26,12 +27,12 @@ import type { RawNetworkLogsEvent } from '../../../rawLogsEvent.types' | ||
if (context.state === 'complete') { | ||
handleCompleteRequest(RequestType.XHR, context) | ||
handleResponse(RequestType.XHR, context) | ||
} | ||
}) | ||
const fetchSubscription = initFetchObservable().subscribe((context) => { | ||
if (context.state === 'complete') { | ||
handleCompleteRequest(RequestType.FETCH, context) | ||
if (context.state === 'resolve') { | ||
handleResponse(RequestType.FETCH, context) | ||
} | ||
}) | ||
function handleCompleteRequest(type: RequestType, request: XhrCompleteContext | FetchCompleteContext) { | ||
function handleResponse(type: RequestType, request: XhrCompleteContext | FetchResolveContext) { | ||
if (!configuration.isIntakeUrl(request.url) && (isRejected(request) || isServerError(request))) { | ||
@@ -182,79 +183,23 @@ if ('xhr' in request) { | ||
stream: ReadableStream<Uint8Array>, | ||
limit: number, | ||
bytesLimit: number, | ||
callback: (error?: Error, responseText?: string) => void | ||
) { | ||
readLimitedAmountOfBytes(stream, limit, (error, bytes, limitExceeded) => { | ||
if (error) { | ||
callback(error) | ||
} else { | ||
let responseText = new TextDecoder().decode(bytes) | ||
if (limitExceeded) { | ||
responseText += '...' | ||
readBytesFromStream( | ||
stream, | ||
(error, bytes, limitExceeded) => { | ||
if (error) { | ||
callback(error) | ||
} else { | ||
let responseText = new TextDecoder().decode(bytes) | ||
if (limitExceeded) { | ||
responseText += '...' | ||
} | ||
callback(undefined, responseText) | ||
} | ||
callback(undefined, responseText) | ||
}, | ||
{ | ||
bytesLimit, | ||
collectStreamBody: true, | ||
} | ||
}) | ||
) | ||
} | ||
/** | ||
* Read bytes from a ReadableStream until at least `limit` bytes have been read (or until the end of | ||
* the stream). The callback is invoked with the at most `limit` bytes, and indicates that the limit | ||
* has been exceeded if more bytes were available. | ||
*/ | ||
function readLimitedAmountOfBytes( | ||
stream: ReadableStream<Uint8Array>, | ||
limit: number, | ||
callback: (error?: Error, bytes?: Uint8Array, limitExceeded?: boolean) => void | ||
) { | ||
const reader = stream.getReader() | ||
const chunks: Uint8Array[] = [] | ||
let readBytesCount = 0 | ||
readMore() | ||
function readMore() { | ||
reader.read().then( | ||
monitor((result: ReadableStreamDefaultReadResult<Uint8Array>) => { | ||
if (result.done) { | ||
onDone() | ||
return | ||
} | ||
chunks.push(result.value) | ||
readBytesCount += result.value.length | ||
if (readBytesCount > limit) { | ||
onDone() | ||
} else { | ||
readMore() | ||
} | ||
}), | ||
monitor((error) => callback(error)) | ||
) | ||
} | ||
function onDone() { | ||
reader.cancel().catch( | ||
// we don't care if cancel fails, but we still need to catch the error to avoid reporting it | ||
// as an unhandled rejection | ||
noop | ||
) | ||
let completeBuffer: Uint8Array | ||
if (chunks.length === 1) { | ||
// optim: if the response is small enough to fit in a single buffer (provided by the browser), just | ||
// use it directly. | ||
completeBuffer = chunks[0] | ||
} else { | ||
// else, we need to copy buffers into a larger buffer to concatenate them. | ||
completeBuffer = new Uint8Array(readBytesCount) | ||
let offset = 0 | ||
chunks.forEach((chunk) => { | ||
completeBuffer.set(chunk, offset) | ||
offset += chunk.length | ||
}) | ||
} | ||
callback(undefined, completeBuffer.slice(0, limit), completeBuffer.length > limit) | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
363823
5416
+ Added@datadog/browser-core@4.26.0(transitive)
+ Added@datadog/browser-rum@4.26.0(transitive)
+ Added@datadog/browser-rum-core@4.26.0(transitive)
- Removed@datadog/browser-core@4.25.0(transitive)
- Removed@datadog/browser-rum@4.25.0(transitive)
- Removed@datadog/browser-rum-core@4.25.0(transitive)
Updated@datadog/browser-core@4.26.0