Socket
Socket
Sign inDemoInstall

@datadog/browser-logs

Package Overview
Dependencies
Maintainers
1
Versions
256
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datadog/browser-logs - npm Package Compare versions

Comparing version 4.23.3 to 4.24.0

2

bundle/datadog-logs.js

@@ -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 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){if("object"!=typeof e||null===e)return JSON.stringify(e);var n,r=b(Object.prototype),o=b(Array.prototype),i=b(Object.getPrototypeOf(e)),s=b(e);try{return JSON.stringify(e,(n=O(),function(e,t){var r=_(t);return"object"!==r&&"array"!==r||!n.hasAlreadyBeenSeen(t)?t:"<warning: cyclic reference not serialized>"}),t)}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,t){return e.slice(0,t.length)===t}function E(){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 R(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 T(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 _(e){return null===e?"null":Array.isArray(e)?"array":typeof e}function O(){var e=new WeakMap;return{hasAlreadyBeenSeen:function(t){var n=e.has(t);return n||e.set(t,!0),n}}}function B(e,t,n){if(void 0===n&&(n=O()),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"===_(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 q(){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 I(){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 P,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 j(){return(new Date).getTime()}function U(){return j()}function D(){return performance.now()}function F(){return{relative:D(),timeStamp:U()}}function N(e,t){return t-e}function H(){return void 0===P&&(P=performance.timing.navigationStart),P}function G(){var e=E().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=E().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}))}var V,$,J;function W(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 X(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 Y(e,t){W(e,"",0,t)}function K(){return $||new Set}function Q(e){return Z(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 Z(e,t){if(function(){if(void 0!==J)return J;try{var e=new URL("http://test/path");return J="http://test/path"===e.href}catch(e){J=!1}return J}())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 ee="datadoghq.com",te={logs:"logs",rum:"rum",sessionReplay:"session-replay"},ne={logs:"logs",rum:"rum",sessionReplay:"replay"};function re(e,t,n){var r=e.site,o=void 0===r?ee:r,i=e.clientToken,s=o.split("."),a=s.pop(),u="".concat(te[t],".browser-intake-").concat(s.join("-"),".").concat(a),c="https://".concat(u,"/api/v2/").concat(ne[t]),f=e.proxyUrl&&Q(e.proxyUrl);return{build:function(){var e="ddsource=browser"+"&ddtags=".concat(encodeURIComponent(["sdk_version:".concat("4.23.3")].concat(n).join(",")))+"&dd-api-key=".concat(i)+"&dd-evp-origin-version=".concat(encodeURIComponent("4.23.3"))+"&dd-evp-origin=browser"+"&dd-request-id=".concat(h());"rum"===t&&(e+="&batch_time=".concat(U()));var r="".concat(c,"?").concat(e);return f?"".concat(f,"?ddforward=").concat(encodeURIComponent(r)):r},buildIntakeUrl:function(){return f?"".concat(f,"?ddforward"):c},endpointType:t}}var oe=/[^a-z0-9_:./-]/;function ie(e,n){var r=200-e.length-1;(n.length>r||oe.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 se(e){var t=function(e){var t=e.env,n=e.service,r=e.version,o=e.datacenter,i=[];return t&&i.push(ie("env",t)),n&&i.push(ie("service",n)),r&&i.push(ie("version",r)),o&&i.push(ie("datacenter",o)),i}(e),n=function(e,t){return{logsEndpointBuilder:re(e,"logs",t),rumEndpointBuilder:re(e,"rum",t),sessionReplayEndpointBuilder:re(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:ee,clientToken:e.replica.clientToken}),o={logsEndpointBuilder:re(r,"logs",n),rumEndpointBuilder:re(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||ee},n)}function ae(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)&&($||($=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,"'")),$.add(e)}))),v({beforeSend:e.beforeSend&&n(e.beforeSend,"beforeSend threw an error:"),cookieOptions:ue(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},se(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 ue(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===V){for(var e="dd_site_test_".concat(h()),t=window.location.hostname.split("."),n=t.pop();t.length&&!X(e);)n="".concat(t.pop(),".").concat(n),W(e,"test",l,{domain:n});Y(e,{domain:n}),V=n}return V}()),t}var ce="?";function fe(e){var t=[],n=be(e,"stack"),r=String(e);return n&&S(n,r)&&(n=n.slice(r.length)),n&&n.split("\n").forEach((function(e){var n=function(e){var t=pe.exec(e);if(!t)return;var n=t[2]&&0===t[2].indexOf("native"),r=t[2]&&0===t[2].indexOf("eval"),o=ve.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]||ce,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:ce,line:t[2]?+t[2]:void 0,url:t[1]}}(e)||function(e){var t=ge.exec(e);if(!t)return;return{args:[],column:t[4]?+t[4]:void 0,func:t[1]||ce,line:+t[3],url:t[2]}}(e)||function(e){var t=ye.exec(e);if(!t)return;var n=t[3]&&t[3].indexOf(" > eval")>-1,r=me.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]||ce,line:t[4]?+t[4]:void 0,url:t[3]}}(e);n&&(!n.func&&n.line&&(n.func=ce),t.push(n))})),{message:be(e,"message"),name:be(e,"name"),stack:t}}var le="((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\\w+\\.|\\/).*?)",de="(?::(\\d+))",pe=new RegExp("^\\s*at (.*?) ?\\(".concat(le).concat(de,"?").concat(de,"?\\)?\\s*$"),"i"),ve=new RegExp("\\((\\S*)".concat(de).concat(de,"\\)"));var he=new RegExp("^\\s*at ?".concat(le).concat(de,"?").concat(de,"??\\s*$"),"i");var ge=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;var ye=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|capacitor|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i,me=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;function be(e,t){if("object"==typeof e&&e&&t in e){var n=e[t];return"string"==typeof n?n:void 0}}var we="agent",Ce="console",ke="logger",xe="network",Se="source",Ee="report";function Re(e){var t=Te(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 Te(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=fe(t);n.stack=n.stack.slice(2),e=Re(n)})),e}function _e(e,t){for(var n=e,r=[];(null==n?void 0:n.cause)instanceof Error&&r.length<10;){var o=fe(n.cause);r.push({message:n.cause.message,source:t,type:null==o?void 0:o.name,stack:o&&Re(o)}),n=n.cause}return r.length?r:void 0}var Oe=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 Be(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=new Oe((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 Me={intervention:"intervention",deprecation:"deprecation",cspViolation:"csp_violation"};function qe(e){var t,n=[];w(e,Me.cspViolation)&&n.push(t=new Oe((function(){var e=u((function(e){t.notify(function(e){var t=Me.cspViolation,n="'".concat(e.blockedURI,"' blocked by '").concat(e.effectiveDirective,"' directive");return{type:Me.cspViolation,subtype:e.effectiveDirective,message:"".concat(t,": ").concat(n),stack:Ie(e.effectiveDirective,e.originalPolicy?"".concat(n,' of the policy "').concat(R(e.originalPolicy,100,"..."),'"'):"no policy",e.sourceFile,e.lineNumber,e.columnNumber)}}(e))}));return T(document,"securitypolicyviolation",e).stop})));var r=e.filter((function(e){return e!==Me.cspViolation}));return r.length&&n.push(function(e){var t=new Oe((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)),Be.apply(void 0,n)}function Ie(e,t,n,r,o){return n&&Re({name:e,message:t,stack:[{func:"?",url:n,line:r,column:o}]})}function Pe(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 Ae=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"},Ue="console",De="http",Fe=Object.keys(je),Ne=function(){function e(e,t,n,r,o){void 0===n&&(n=De),void 0===r&&(r=je.debug),void 0===o&&(o={}),this.handleLogStrategy=e,this.handlerType=n,this.level=r,this.contextManager=I(),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:ke}};this.log(e,q(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},Ae([a],e.prototype,"log",null),e}();function He(){return Boolean(window._DATADOG_SYNTHETICS_INJECTS_RUM||X("datadog-synthetics-injects-rum"))}function Ge(){var e=window._DATADOG_SYNTHETICS_RESULT_ID||X("datadog-synthetics-result-id");return"string"==typeof e?e:void 0}var ze,Ve="log",$e="configuration",Je=["https://www.datadoghq-browser-agent.com","https://www.datad0g-browser-agent.com","http://localhost","<anonymous>"],We=["ddog-gov.com"],Xe={maxEventsPerPage:0,sentEventCount:0,telemetryEnabled:!1,telemetryConfigurationEnabled:!1};function Ye(e,t){var n,o=new Oe;return Xe.telemetryEnabled=g(t.telemetrySampleRate),Xe.telemetryConfigurationEnabled=Xe.telemetryEnabled&&g(t.telemetryConfigurationSampleRate),ze=function(r){!w(We,t.site)&&Xe.telemetryEnabled&&o.notify(function(e,t){return q({type:"telemetry",date:U(),service:e,version:"4.23.3",source:"browser",_dd:{format_version:2},telemetry:t,experimental_features:C(K())},void 0!==n?n():{})}(e,r))},r=Ke,v(Xe,{maxEventsPerPage:t.maxTelemetryEventsPerPage,sentEventCount:0}),{setContextProvider:function(e){n=e},observable:o}}function Ke(e){Qe(v({type:Ve,status:"error"},function(e){if(e instanceof Error){var t=fe(e);return{error:{kind:t.name,stack:Re(Ze(t))},message:t.message}}return{error:{stack:"Not an instance of error"},message:"Uncaught ".concat(m(e))}}(e)))}function Qe(e){ze&&Xe.sentEventCount<Xe.maxEventsPerPage&&(Xe.sentEventCount+=1,ze(e))}function Ze(e){return e.stack=e.stack.filter((function(e){return!e.url||Je.some((function(t){return S(e.url,t)}))})),e}var et=/[^\u0000-\u007F]/,tt=function(){function e(e,t,n,r,o,i){void 0===i&&(i=y),this.request=e,this.batchMessagesLimit=t,this.batchBytesLimit=n,this.messageBytesLimit=r,this.flushTimeout=o,this.beforeUnloadCallback=i,this.pushOnlyBuffer=[],this.upsertBuffer={},this.bufferBytesCount=0,this.bufferMessagesCount=0,this.setupFlushOnExit(),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.flushOnExit=function(){this.flush(this.request.sendOnExit)},e.prototype.computeBytesCount=function(e){return et.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.prototype.setupFlushOnExit=function(){var e=this;navigator.sendBeacon&&(T(window,"beforeunload",this.beforeUnloadCallback),T(document,"visibilitychange",(function(){"hidden"===document.visibilityState&&e.flushOnExit()})),T(window,"beforeunload",(function(){return e.flushOnExit()})))},e}(),nt=3145728;function rt(e,t,n,r,o){0===t.transportStatus&&0===t.queuedPayloads.size()&&t.bandwidthMonitor.canHandle(e)?it(e,t,n,{onSuccess:function(){return st(0,t,n,r,o)},onFailure:function(){t.queuedPayloads.enqueue(e),ot(t,n,r,o)}}):t.queuedPayloads.enqueue(e)}function ot(e,t,n,r){2===e.transportStatus&&setTimeout(u((function(){it(e.queuedPayloads.first(),e,t,{onSuccess:function(){e.queuedPayloads.dequeue(),e.currentBackoffTime=1e3,st(1,e,t,n,r)},onFailure:function(){e.currentBackoffTime=Math.min(6e4,2*e.currentBackoffTime),ot(e,t,n,r)}})})),e.currentBackoffTime)}function it(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,i())}))}function st(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:we,startClocks:F()}),t.queueFullReported=!0);var i=t.queuedPayloads;for(t.queuedPayloads=at();i.size()>0;)rt(i.dequeue(),t,n,r,o)}function at(){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>=nt}}}function ut(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:at(),queueFullReported:!1},o=function(n,r){return function(e,t,n,r){var o=n.data,i=n.bytesCount,s=e.build();(function(){try{return window.Request&&"keepalive"in new Request("http://a")}catch(e){return!1}})()&&i<t?fetch(s,{method:"POST",body:o,keepalive:!0}).then(u((function(e){return null==r?void 0:r({status:e.status})})),u((function(){ft(s,o,r)}))):ft(s,o,r)}(e,t,n,r)};return{send:function(t){rt(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){ct||(ct=!0,Ke(e))}(e)}ft(i,r)}(e,t,n)}}}var ct=!1;function ft(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 lt(e,t,n,r){var o,i=s(t);function s(t){return new tt(ut(t,e.batchBytesLimit,n),e.batchMessagesLimit,e.batchBytesLimit,e.messageBytesLimit,e.flushTimeout)}return r&&(o=s(r)),{add:function(e,t){void 0===t&&(t=!0),i.add(e),o&&t&&o.add(e)}}}var dt=1/0,pt=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:dt,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=dt);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===dt&&t.close(e)},e.prototype.findAll=function(e){return void 0===e&&(e=dt),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 vt,ht=144e5,gt=9e5,yt=/^([a-z]+)=([a-z0-9-]+)$/,mt="&",bt="_dd_s",wt=[];function Ct(e,t){var n;if(void 0===t&&(t=0),vt||(vt=e),e===vt)if(t>=100)St();else{var r,o=Tt();if(kt()){if(o.lock)return void xt(e,t);if(r=h(),o.lock=r,Rt(o,e.options),(o=Tt()).lock!==r)return void xt(e,t)}var i=e.process(o);if(kt()&&(o=Tt()).lock!==r)xt(e,t);else{if(i&&Et(i,e.options),kt()&&(!i||!Lt(i))){if((o=Tt()).lock!==r)return void xt(e,t);delete o.lock,Rt(o,e.options),i=o}null===(n=e.after)||void 0===n||n.call(e,i||o),St()}}else wt.push(e)}function kt(){return!!window.chrome||/HeadlessChrome/.test(window.navigator.userAgent)}function xt(e,t){setTimeout(u((function(){Ct(e,t+1)})),10)}function St(){vt=void 0;var e=wt.shift();e&&Ct(e)}function Et(e,t){Lt(e)?function(e){W(bt,"",0,e)}(t):(e.expire=String(j()+gt),Rt(e,t))}function Rt(e,t){W(bt,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(mt);var t}(e),gt,t)}function Tt(){var e=X(bt),t={};return function(e){return void 0!==e&&(-1!==e.indexOf(mt)||yt.test(e))}(e)&&e.split(mt).forEach((function(e){var n=yt.exec(e);if(null!==n){var r=n[1],o=n[2];t[r]=o}})),t}function Lt(e){return t=e,0===Object.keys(t).length;var t}function _t(e,t,n){var r=new Oe,o=new Oe,i=setInterval(u((function(){Ct({options:e,process:function(e){return f(e)?void 0:{}},after:a})})),1e3),s=function(){var e=Tt();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||j()-Number(e.created)<ht)&&(void 0===e.expire||j()<Number(e.expire))}return{expandOrRenewSession:p(u((function(){var o;Ct({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(j()));return i}(r),r},after:function(e){o&&!c()&&function(e){s=e,r.notify()}(e),s=e}})})),1e3).throttled,expandSession:function(){Ct({options:e,process:function(e){return c()?a(e):void 0}})},getSession:function(){return s},renewObservable:r,expireObservable:o,stop:function(){clearInterval(i)}}}var Ot=[];function Bt(e,t,n){!function(e){var t=X(bt),n=X("_dd"),r=X("_dd_r"),o=X("_dd_l");if(!t){var i={};n&&(i.id=n),o&&/^[01]$/.test(o)&&(i.logs=o),r&&/^[012]$/.test(r)&&(i.rum=r),Et(i,e)}}(e);var r=_t(e,t,n);Ot.push((function(){return r.stop()}));var o,i=new pt(144e5);function s(){return{id:r.getSession().id,trackingType:r.getSession()[t]}}return Ot.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,Ot.push(o),function(e){var t=u((function(){"visible"===document.visibilityState&&e()})),n=T(document,"visibilitychange",t).stop;Ot.push(n);var r=setInterval(t,6e4);Ot.push((function(){clearInterval(r)}))}((function(){return r.expandSession()})),{findActiveSession:function(e){return i.find(e)},renewObservable:r.renewObservable,expireObservable:r.expireObservable}}var Mt;function qt(e){var t=Bt(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 Pt=((Mt={})[je.debug]=0,Mt[je.info]=1,Mt[je.warn]=2,Mt[je.error]=3,Mt);function At(e,t,n){var r=n.getHandler(),o=Array.isArray(r)?r:[r];return Pt[e]>=Pt[n.getLevel()]&&w(o,t)}function jt(e,t,n,r,o,i){var s=Fe.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:we,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=q({service:t.service,session_id:m.id,view:b.view},b.context,Dt(y),f,g.getContext(),d);!At(f.status,De,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)!==we&&(null!==(c=a[w.status])&&void 0!==c?c:a.custom).isLimitReached()||n.notify(1,w)}}))}var Ut=!1;function Dt(t){var n,r=window;if(He()){var o=i(r.DD_RUM_SYNTHETICS);return o||Ut||(Ut=!0,function(t,n){f(e.debug,t,n),Qe(v({type:Ve,message:t,status:"debug"},n))}("Logs sent before RUM is injected by the synthetics worker",{testId:(n=window._DATADOG_SYNTHETICS_PUBLIC_ID||X("datadog-synthetics-public-id"),"string"==typeof n?n:void 0),resultId:Ge()})),o}return i(r.DD_RUM);function i(e){if(e&&e.getInternalContext)return e.getInternalContext(t)}}var Ft,Nt={};function Ht(e){var t=e.map((function(e){return Nt[e]||(Nt[e]=function(e){var t=new Oe((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(Gt(r,e,i))}))},function(){console[e]=n}}));return t}(e)),Nt[e]}));return Be.apply(void 0,t)}function Gt(t,n,r){var o,i=t.map((function(e){return function(e){if("string"==typeof e)return e;if(e instanceof Error)return Te(fe(e));return m(e,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?Re(fe(s)):void 0,i="console error: ".concat(i)}return{api:n,message:i,stack:o,handlingStack:r}}var zt,Vt=((Ft={})[e.log]=je.info,Ft[e.debug]=je.debug,Ft[e.info]=je.info,Ft[e.warn]=je.warn,Ft[e.error]=je.error,Ft);var $t,Jt=((zt={})[Me.cspViolation]=je.error,zt[Me.intervention]=je.error,zt[Me.deprecation]=je.warn,zt);function Wt(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 Xt(e,t,n){var r=n.before,o=n.after;return Wt(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 Yt,Kt=new WeakMap;function Qt(){var e;return $t||(e=new Oe((function(){var t=Xt(XMLHttpRequest.prototype,"open",{before:Zt}).stop,n=Xt(XMLHttpRequest.prototype,"send",{before:function(){en.call(this,e)}}).stop,r=Xt(XMLHttpRequest.prototype,"abort",{before:tn}).stop;return function(){t(),n(),r()}})),$t=e),$t}function Zt(e,t){Kt.set(this,{state:"open",method:e,url:Q(String(t))})}function en(e){var t=this,n=Kt.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=Xt(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,U()),a.status=t.status,e.notify(v({},a))}}));this.addEventListener("loadend",s),e.notify(r)}}function tn(){var e=Kt.get(this);e&&(e.isAborted=!0)}function nn(){var e;return Yt||(e=new Oe((function(){if(window.fetch)return Wt(window,"fetch",(function(t){return function(n,r){var o,i=c(rn,null,[e,n,r]);return i?(o=t.call(this,i.input,i.init),c(on,null,[e,o,i])):o=t.call(this,n,r),o}})).stop})),Yt=e),Yt}function rn(e,t,n){var r=n&&n.method||"object"==typeof t&&t.method||"GET",o=Q("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 on(e,t,n){var r=function(t){var r=n;r.state="complete",r.duration=N(r.startClocks.timeStamp,U()),"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 sn(e,t){if(!e.forwardErrorsToLogs)return{stop:y};var n=Qt().subscribe((function(e){"complete"===e.state&&o("xhr",e)})),r=nn().subscribe((function(e){"complete"===e.state&&o("fetch",e)}));function o(n,r){function o(e){t.notify(0,{rawLogsEvent:{message:"".concat(un(n)," error ").concat(r.method," ").concat(r.url),date:r.startClocks.timeStamp,error:{origin:xe,stack:e||"Failed to load"},http:{method:r.method,status_code:r.status,url:r.url},status:je.error,origin:xe}})}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(an(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(an(e,t))})),u((function(e){return n("Unable to retrieve response: ".concat(e))})))}(r.response,e,o):r.error&&function(e,t,n){n(an(Re(fe(e)),t))}(r.error,e,o))}return{stop:function(){n.unsubscribe(),r.unsubscribe()}}}function an(e,t){return e.length>t.requestErrorResponseLengthLimit?"".concat(e.substring(0,t.requestErrorResponseLengthLimit),"..."):e}function un(e){return"xhr"===e?"XHR":"Fetch"}var cn=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/;function fn(e){var t=function(e){return Xt(window,"onerror",{before:function(t,n,r,o,i){var s;if(i)s=fe(i),e(s,i);else{var a,u={url:n,column:o,line:r},c=t;if("[object String]"==={}.toString.call(t)){var f=cn.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 Xt(window,"onunhandledrejection",{before:function(t){var n=t.reason||"Empty reason",r=fe(n);e(r,n)}})}(e).stop;return{stop:function(){t(),n()}}}function ln(e){return fn((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:Re(t),handlingStack:r,type:t.name,causes:_e(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:Se,handling:"unhandled"}))}))}var dn=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 pn,vn,hn,gn,yn=function(n){var r,o,i=!1,a=I(),c={},f=function(){},l=new A,d=function(e,t,n,r){void 0===n&&(n=M(g())),void 0===r&&(r=U()),l.add((function(){return d(e,t,n,r)}))},p=function(){},h=new Ne((function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return d.apply(void 0,e)}));function g(){return{view:{referrer:document.referrer,url:window.location.href},context:a.get()}}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=ae(t),r=Pe(t.forwardConsoleLogs,x(e),"Forward Console Logs"),o=Pe(t.forwardReports,x(Me),"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,g,h),d=o.handleLog,f=o.getInternalContext,p=function(){return M(r)},l.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={}),c[e]=new Ne((function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return d.apply(void 0,e)}),e,t.handler,t.level,t.context),c[e]})),getLogger:u((function(e){return c[e]})),getInitConfiguration:u((function(){return p()})),getInternalContext:u((function(e){return f(e)}))},o=v({version:"4.23.3",onReady:function(e){e()}},r),Object.defineProperty(o,"_setDebug",{get:function(){return s},enumerable:!1}),o}((function(n,r,o,i){var s=new dn,a=function(e){return s.notify(0,{rawLogsEvent:{message:e.message,date:e.startClocks.timeStamp,error:{origin:we},origin:we,status:je.error}})},u=function(e,t){var n,r=Ye("browser-logs-sdk",e);if(z()){var o=G();r.observable.subscribe((function(e){return o.send("internal_telemetry",e)}))}else{var i=lt(e,e.rumEndpointBuilder,t,null===(n=e.replica)||void 0===n?void 0:n.rumEndpointBuilder);r.observable.subscribe((function(t){return i.add(t,function(e){return"datad0g.com"===e.site}(e))}))}return r}(r,a);u.setContextProvider((function(){var e,t,n,r,o,i;return{application:{id:null===(e=Dt())||void 0===e?void 0:e.application_id},session:{id:null===(t=d.findTrackedSession())||void 0===t?void 0:t.id},view:{id:null===(r=null===(n=Dt())||void 0===n?void 0:n.view)||void 0===r?void 0:r.id},action:{id:null===(i=null===(o=Dt())||void 0===o?void 0:o.user_action)||void 0===i?void 0:i.id}}})),sn(r,s),function(e,t){if(!e.forwardErrorsToLogs)return{stop:y};var n=new Oe,r=ln(n).stop,o=n.subscribe((function(e){t.notify(0,{rawLogsEvent:{message:e.message,date:e.startClocks.timeStamp,error:{kind:e.type,origin:Se,stack:e.stack},origin:Se,status:je.error}})}))}(r,s),function(t,n){var r=Ht(t.forwardConsoleLogs).subscribe((function(t){n.notify(0,{rawLogsEvent:{date:U(),message:t.message,origin:Ce,error:t.api===e.error?{origin:Ce,stack:t.stack}:void 0,status:Vt[t.api]}})}))}(r,s),function(e,t){var n=qe(e.forwardReports).subscribe((function(e){var n,r=e.message,o=Jt[e.type];o===je.error?n={kind:e.subtype,origin:Ee,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:U(),message:r,origin:Ee,error:n,status:o}})}))}(r,s);var c,f=function(e){return{handleLog:function(n,r,o,i){var s=n.context;At(n.status,Ue,r)&&t(n.status,n.message,q(r.getContext(),s)),e.notify(0,{rawLogsEvent:{date:i||U(),message:n.message,status:n.status,origin:ke},messageContext:s,savedCommonContext:o,logger:r})}}}(s).handleLog,d=!function(e){if(void 0===document.cookie||null===document.cookie)return!1;try{var n="dd_cookie_test_".concat(h()),r="test";W(n,r,l,e);var o=X(n)===r;return Y(n,e),o}catch(e){return t.error(e),!1}}(r.cookieOptions)||z()||He()?function(e){var t="1"===It(e)?{}:void 0;return{findTrackedSession:function(){return t}}}(r):qt(r);return jt(d,r,s,o,i,a),z()?function(e){var t=G();e.subscribe(1,(function(e){t.send("log",e)}))}(s):function(e,t,n){var r,o=lt(e,e.logsEndpointBuilder,n,null===(r=e.replica)||void 0===r?void 0:r.logsEndpointBuilder);t.subscribe(1,(function(e){o.add(e)}))}(r,s,a),function(e){Xe.telemetryConfigurationEnabled&&Qe({type:$e,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}}(e);return v({forward_errors_to_logs:e.forwardErrorsToLogs,forward_console_logs:e.forwardConsoleLogs,forward_reports:e.forwardReports},t)}(n)),{handleLog:f,getInternalContext:(c=d,{get:function(e){var t=c.findTrackedSession(e);if(t)return{session_id:t.id}}}).get}}));pn=E(),hn=yn,gn=pn[vn="DD_LOGS"],pn[vn]=hn,gn&&gn.q&&gn.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 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){if("object"!=typeof e||null===e)return JSON.stringify(e);var n,r=b(Object.prototype),o=b(Array.prototype),i=b(Object.getPrototypeOf(e)),s=b(e);try{return JSON.stringify(e,(n=B(),function(e,t){var r=O(t);return"object"!==r&&"array"!==r||!n.hasAlreadyBeenSeen(t)?t:"<warning: cyclic reference not serialized>"}),t)}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 x(e){return function(e){return"number"==typeof e}(e)&&e>=0&&e<=100}function k(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(){var e=new WeakMap;return{hasAlreadyBeenSeen:function(t){var n=e.has(t);return n||e.set(t,!0),n}}}function M(e,t,n){if(void 0===n&&(n=B()),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]=M(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]=M(s[a],t[a],n));return s}}function P(e){return M(void 0,e)}function q(){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=M(e,i))}return e}function I(){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 P(e)},setContext:function(t){e=P(t)},setContextProperty:function(t,n){e[t]=P(n)},removeContextProperty:function(t){delete e[t]},clearContext:function(){e={}}}}var A,j=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 D(){return U()}function F(){return performance.now()}function N(){return{relative:F(),timeStamp:D()}}function H(e,t){return t-e}function G(){return void 0===A&&(A=performance.timing.navigationStart),A}function z(){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 V(e){var t;void 0===e&&(e=null===(t=R().location)||void 0===t?void 0:t.hostname);var n=z();return!!n&&n.getAllowedWebViewHosts().some((function(t){return e===t||(n=e,r=".".concat(t),n.slice(-r.length)===r);var n,r}))}function $(e){var t=v({},e);return["id","name","email"].forEach((function(e){e in t&&(t[e]=String(t[e]))})),t}var J,W,X;function Y(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 K(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 Q(e,t){Y(e,"",0,t)}function Z(){return W||new Set}function ee(e){return te(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 te(e,t){if(function(){if(void 0!==X)return X;try{var e=new URL("http://test/path");return X="http://test/path"===e.href}catch(e){X=!1}return X}())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 ne="datadoghq.com",re={logs:"logs",rum:"rum",sessionReplay:"session-replay"},oe={logs:"logs",rum:"rum",sessionReplay:"replay"};function ie(e,t,n){var r=e.site,o=void 0===r?ne:r,i=e.clientToken,s=o.split("."),a=s.pop(),u="".concat(re[t],".browser-intake-").concat(s.join("-"),".").concat(a),c="https://".concat(u,"/api/v2/").concat(oe[t]),f=e.proxyUrl&&ee(e.proxyUrl);return{build:function(){var e="ddsource=browser"+"&ddtags=".concat(encodeURIComponent(["sdk_version:".concat("4.24.0")].concat(n).join(",")))+"&dd-api-key=".concat(i)+"&dd-evp-origin-version=".concat(encodeURIComponent("4.24.0"))+"&dd-evp-origin=browser"+"&dd-request-id=".concat(g());"rum"===t&&(e+="&batch_time=".concat(D()));var r="".concat(c,"?").concat(e);return f?"".concat(f,"?ddforward=").concat(encodeURIComponent(r)):r},buildIntakeUrl:function(){return f?"".concat(f,"?ddforward"):c},endpointType:t}}var se=/[^a-z0-9_:./-]/;function ae(e,n){var r=200-e.length-1;(n.length>r||se.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 ue(e){var t=function(e){var t=e.env,n=e.service,r=e.version,o=e.datacenter,i=[];return t&&i.push(ae("env",t)),n&&i.push(ae("service",n)),r&&i.push(ae("version",r)),o&&i.push(ae("datacenter",o)),i}(e),n=function(e,t){return{logsEndpointBuilder:ie(e,"logs",t),rumEndpointBuilder:ie(e,"rum",t),sessionReplayEndpointBuilder:ie(e,"sessionReplay",t)}}(e,t),r=k(n).map((function(e){return e.buildIntakeUrl()})),o=function(e,t,n){if(!e.replica)return;var r=v({},e,{site:ne,clientToken:e.replica.clientToken}),o={logsEndpointBuilder:ie(r,"logs",n),rumEndpointBuilder:ie(r,"rum",n)};return t.push.apply(t,k(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||ne},n)}function ce(e){var r,o,i;if(e&&e.clientToken)if(void 0===e.sampleRate||x(e.sampleRate))if(void 0===e.telemetrySampleRate||x(e.telemetrySampleRate)){var s;if(void 0===e.telemetryConfigurationSampleRate||x(e.telemetryConfigurationSampleRate))return s=e.enableExperimentalFeatures,Array.isArray(s)&&(W||(W=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,"'")),W.add(e)}))),v({beforeSend:e.beforeSend&&n(e.beforeSend,"beforeSend threw an error:"),cookieOptions:fe(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},ue(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 fe(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===J){for(var e="dd_site_test_".concat(g()),t=window.location.hostname.split("."),n=t.pop();t.length&&!K(e);)n="".concat(t.pop(),".").concat(n),Y(e,"test",l,{domain:n});Q(e,{domain:n}),J=n}return J}()),t}var le="?";function de(e){var t=[],n=Ce(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=ge.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]||le,line:t[3]?+t[3]:void 0,url:n?void 0:t[2]}}(e)||function(e){var t=ye.exec(e);if(!t)return;return{args:[],column:t[3]?+t[3]:void 0,func:le,line:t[2]?+t[2]:void 0,url:t[1]}}(e)||function(e){var t=me.exec(e);if(!t)return;return{args:[],column:t[4]?+t[4]:void 0,func:t[1]||le,line:+t[3],url:t[2]}}(e)||function(e){var t=be.exec(e);if(!t)return;var n=t[3]&&t[3].indexOf(" > eval")>-1,r=we.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]||le,line:t[4]?+t[4]:void 0,url:t[3]}}(e);n&&(!n.func&&n.line&&(n.func=le),t.push(n))})),{message:Ce(e,"message"),name:Ce(e,"name"),stack:t}}var pe="((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\\w+\\.|\\/).*?)",ve="(?::(\\d+))",ge=new RegExp("^\\s*at (.*?) ?\\(".concat(pe).concat(ve,"?").concat(ve,"?\\)?\\s*$"),"i"),he=new RegExp("\\((\\S*)".concat(ve).concat(ve,"\\)"));var ye=new RegExp("^\\s*at ?".concat(pe).concat(ve,"?").concat(ve,"??\\s*$"),"i");var me=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;var be=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|capacitor|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i,we=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;function Ce(e,t){if("object"==typeof e&&e&&t in e){var n=e[t];return"string"==typeof n?n:void 0}}var xe="agent",ke="console",Se="logger",Ee="network",Re="source",Te="report";function Le(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 Oe(){var e,t=new Error;if(!t.stack)try{throw t}catch(e){}return c((function(){var n=de(t);n.stack=n.stack.slice(2),e=Le(n)})),e}function Be(e,t){for(var n=e,r=[];(null==n?void 0:n.cause)instanceof Error&&r.length<10;){var o=de(n.cause);r.push({message:n.cause.message,source:t,type:null==o?void 0:o.name,stack:o&&Le(o)}),n=n.cause}return r.length?r:void 0}var Me=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 Pe(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=new Me((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 qe={intervention:"intervention",deprecation:"deprecation",cspViolation:"csp_violation"};function Ie(e){var t,n=[];w(e,qe.cspViolation)&&n.push(t=new Me((function(){var e=u((function(e){t.notify(function(e){var t=qe.cspViolation,n="'".concat(e.blockedURI,"' blocked by '").concat(e.effectiveDirective,"' directive");return{type:qe.cspViolation,subtype:e.effectiveDirective,message:"".concat(t,": ").concat(n),stack:Ae(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!==qe.cspViolation}));return r.length&&n.push(function(e){var t=new Me((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:Ae(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)),Pe.apply(void 0,n)}function Ae(e,t,n,r,o){return n&&Le({name:e,message:t,stack:[{func:"?",url:n,line:r,column:o}]})}function je(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},De={debug:"debug",error:"error",info:"info",warn:"warn"},Fe="console",Ne="http",He=Object.keys(De),Ge=function(){function e(e,t,n,r,o){void 0===n&&(n=Ne),void 0===r&&(r=De.debug),void 0===o&&(o={}),this.handleLogStrategy=e,this.handlerType=n,this.level=r,this.contextManager=I(),this.contextManager.set(v({},o,t?{logger:{name:t}}:void 0))}return e.prototype.log=function(e,t,n){void 0===n&&(n=De.info),this.handleLogStrategy({message:e,context:P(t),status:n},this)},e.prototype.debug=function(e,t){this.log(e,t,De.debug)},e.prototype.info=function(e,t){this.log(e,t,De.info)},e.prototype.warn=function(e,t){this.log(e,t,De.warn)},e.prototype.error=function(e,t){var n={error:{origin:Se}};this.log(e,q(n,t),De.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 ze(){return Boolean(window._DATADOG_SYNTHETICS_INJECTS_RUM||K("datadog-synthetics-injects-rum"))}function Ve(){var e=window._DATADOG_SYNTHETICS_RESULT_ID||K("datadog-synthetics-result-id");return"string"==typeof e?e:void 0}var $e,Je="log",We="configuration",Xe=["https://www.datadoghq-browser-agent.com","https://www.datad0g-browser-agent.com","http://localhost","<anonymous>"],Ye=["ddog-gov.com"],Ke={maxEventsPerPage:0,sentEventCount:0,telemetryEnabled:!1,telemetryConfigurationEnabled:!1};function Qe(e,t){var n,o=new Me;return Ke.telemetryEnabled=h(t.telemetrySampleRate),Ke.telemetryConfigurationEnabled=Ke.telemetryEnabled&&h(t.telemetryConfigurationSampleRate),$e=function(r){!w(Ye,t.site)&&Ke.telemetryEnabled&&o.notify(function(e,t){return q({type:"telemetry",date:D(),service:e,version:"4.24.0",source:"browser",_dd:{format_version:2},telemetry:t,experimental_features:C(Z())},void 0!==n?n():{})}(e,r))},r=Ze,v(Ke,{maxEventsPerPage:t.maxTelemetryEventsPerPage,sentEventCount:0}),{setContextProvider:function(e){n=e},observable:o}}function Ze(e){et(v({type:Je,status:"error"},function(e){if(e instanceof Error){var t=de(e);return{error:{kind:t.name,stack:Le(tt(t))},message:t.message}}return{error:{stack:"Not an instance of error"},message:"Uncaught ".concat(m(e))}}(e)))}function et(e){$e&&Ke.sentEventCount<Ke.maxEventsPerPage&&(Ke.sentEventCount+=1,$e(e))}function tt(e){return e.stack=e.stack.filter((function(e){return!e.url||Xe.some((function(t){return E(e.url,t)}))})),e}var nt=/[^\u0000-\u007F]/,rt=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(k(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 nt.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}(),ot=3145728;function it(e,t,n,r,o){0===t.transportStatus&&0===t.queuedPayloads.size()&&t.bandwidthMonitor.canHandle(e)?at(e,t,n,{onSuccess:function(){return ut(0,t,n,r,o)},onFailure:function(){t.queuedPayloads.enqueue(e),st(t,n,r,o)}}):t.queuedPayloads.enqueue(e)}function st(e,t,n,r){2===e.transportStatus&&setTimeout(u((function(){at(e.queuedPayloads.first(),e,t,{onSuccess:function(){e.queuedPayloads.dequeue(),e.currentBackoffTime=1e3,ut(1,e,t,n,r)},onFailure:function(){e.currentBackoffTime=Math.min(6e4,2*e.currentBackoffTime),st(e,t,n,r)}})})),e.currentBackoffTime)}function at(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,i())}))}function ut(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:xe,startClocks:N()}),t.queueFullReported=!0);var i=t.queuedPayloads;for(t.queuedPayloads=ct();i.size()>0;)it(i.dequeue(),t,n,r,o)}function ct(){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>=ot}}}function ft(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:ct(),queueFullReported:!1},o=function(n,r){return function(e,t,n,r){var o=n.data,i=n.bytesCount,s=e.build();(function(){try{return window.Request&&"keepalive"in new Request("http://a")}catch(e){return!1}})()&&i<t?fetch(s,{method:"POST",body:o,keepalive:!0}).then(u((function(e){return null==r?void 0:r({status:e.status})})),u((function(){dt(s,o,r)}))):dt(s,o,r)}(e,t,n,r)};return{send:function(t){it(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){lt||(lt=!0,Ze(e))}(e)}dt(i,r)}(e,t,n)}}}var lt=!1;function dt(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 pt(e,t,n,r,o){var i,s=a(t);function a(t){return new rt(ft(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 vt=1/0,gt=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:vt,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=vt);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===vt&&t.close(e)},e.prototype.findAll=function(e){return void 0===e&&(e=vt),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=F()-this.expireDelay;this.entries.length>0&&this.entries[this.entries.length-1].endTime<e;)this.entries.pop()},e}();var ht,yt=144e5,mt=9e5,bt=/^([a-z]+)=([a-z0-9-]+)$/,wt="&",Ct="_dd_s",xt=[];function kt(e,t){var n;if(void 0===t&&(t=0),ht||(ht=e),e===ht)if(t>=100)Rt();else{var r,o=_t();if(St()){if(o.lock)return void Et(e,t);if(r=g(),o.lock=r,Lt(o,e.options),(o=_t()).lock!==r)return void Et(e,t)}var i=e.process(o);if(St()&&(o=_t()).lock!==r)Et(e,t);else{if(i&&Tt(i,e.options),St()&&(!i||!Ot(i))){if((o=_t()).lock!==r)return void Et(e,t);delete o.lock,Lt(o,e.options),i=o}null===(n=e.after)||void 0===n||n.call(e,i||o),Rt()}}else xt.push(e)}function St(){return!!window.chrome||/HeadlessChrome/.test(window.navigator.userAgent)}function Et(e,t){setTimeout(u((function(){kt(e,t+1)})),10)}function Rt(){ht=void 0;var e=xt.shift();e&&kt(e)}function Tt(e,t){Ot(e)?function(e){Y(Ct,"",0,e)}(t):(e.expire=String(U()+mt),Lt(e,t))}function Lt(e,t){Y(Ct,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(wt);var t}(e),mt,t)}function _t(){var e=K(Ct),t={};return function(e){return void 0!==e&&(-1!==e.indexOf(wt)||bt.test(e))}(e)&&e.split(wt).forEach((function(e){var n=bt.exec(e);if(null!==n){var r=n[1],o=n[2];t[r]=o}})),t}function Ot(e){return S(e)}function Bt(e,t,n){var r=new Me,o=new Me,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)<yt)&&(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 Mt=[];function Pt(e,t,n){!function(e){var t=K(Ct),n=K("_dd"),r=K("_dd_r"),o=K("_dd_l");if(!t){var i={};n&&(i.id=n),o&&/^[01]$/.test(o)&&(i.logs=o),r&&/^[012]$/.test(r)&&(i.rum=r),Tt(i,e)}}(e);var r=Bt(e,t,n);Mt.push((function(){return r.stop()}));var o,i=new gt(144e5);function s(){return{id:r.getSession().id,trackingType:r.getSession()[t]}}return Mt.push((function(){return i.stop()})),r.renewObservable.subscribe((function(){i.add(s(),F())})),r.expireObservable.subscribe((function(){i.closeActive(F())})),r.expandOrRenewSession(),i.add(s(),[0,G()][0]),o=_(window,["click","touchstart","keydown","scroll"],(function(){return r.expandOrRenewSession()}),{capture:!0,passive:!0}).stop,Mt.push(o),function(e){var t=u((function(){"visible"===document.visibilityState&&e()})),n=L(document,"visibilitychange",t).stop;Mt.push(n);var r=setInterval(t,6e4);Mt.push((function(){clearInterval(r)}))}((function(){return r.expandSession()})),{findActiveSession:function(e){return i.find(e)},renewObservable:r.renewObservable,expireObservable:r.expireObservable}}var qt;function It(e){var t=Pt(e.cookieOptions,"logs",(function(t){return function(e,t){var n=function(e){return"0"===e||"1"===e}(t)?t:At(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 At(e){return h(e.sampleRate)?"1":"0"}var jt=((qt={})[De.debug]=0,qt[De.info]=1,qt[De.warn]=2,qt[De.error]=3,qt);function Ut(e,t,n){var r=n.getHandler(),o=Array.isArray(r)?r:[r];return jt[e]>=jt[n.getLevel()]&&w(o,t)}function Dt(e,t,n,r,o,i){var s=He.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:xe,startClocks:N()})}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-G(),m=e.findTrackedSession(y);if(m){var b=v||r(),w=q({service:t.service,session_id:m.id,usr:S(b.user)?void 0:b.user,view:b.view},b.context,Nt(y),f,h.getContext(),d);!Ut(f.status,Ne,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)!==xe&&(null!==(c=a[w.status])&&void 0!==c?c:a.custom).isLimitReached()||n.notify(1,w)}}))}var Ft=!1;function Nt(t){var n,r=window;if(ze()){var o=i(r.DD_RUM_SYNTHETICS);return o||Ft||(Ft=!0,function(t,n){f(e.debug,t,n),et(v({type:Je,message:t,status:"debug"},n))}("Logs sent before RUM is injected by the synthetics worker",{testId:(n=window._DATADOG_SYNTHETICS_PUBLIC_ID||K("datadog-synthetics-public-id"),"string"==typeof n?n:void 0),resultId:Ve()})),o}return i(r.DD_RUM);function i(e){if(e&&e.getInternalContext)return e.getInternalContext(t)}}var Ht,Gt={};function zt(e){var t=e.map((function(e){return Gt[e]||(Gt[e]=function(e){var t=new Me((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=Oe();c((function(){t.notify(Vt(r,e,i))}))},function(){console[e]=n}}));return t}(e)),Gt[e]}));return Pe.apply(void 0,t)}function Vt(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(de(e));return m(e,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?Le(de(s)):void 0,i="console error: ".concat(i)}return{api:n,message:i,stack:o,handlingStack:r}}var $t,Jt=((Ht={})[e.log]=De.info,Ht[e.debug]=De.debug,Ht[e.info]=De.info,Ht[e.warn]=De.warn,Ht[e.error]=De.error,Ht);var Wt,Xt=(($t={})[qe.cspViolation]=De.error,$t[qe.intervention]=De.error,$t[qe.deprecation]=De.warn,$t);function Yt(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 Kt(e,t,n){var r=n.before,o=n.after;return Yt(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 Qt,Zt=new WeakMap;function en(){var e;return Wt||(e=new Me((function(){var t=Kt(XMLHttpRequest.prototype,"open",{before:tn}).stop,n=Kt(XMLHttpRequest.prototype,"send",{before:function(){nn.call(this,e)}}).stop,r=Kt(XMLHttpRequest.prototype,"abort",{before:rn}).stop;return function(){t(),n(),r()}})),Wt=e),Wt}function tn(e,t){Zt.set(this,{state:"open",method:e,url:ee(String(t))})}function nn(e){var t=this,n=Zt.get(this);if(n){var r=n;r.state="start",r.startTime=F(),r.startClocks=N(),r.isAborted=!1,r.xhr=this;var o=!1,i=Kt(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=H(r.startClocks.timeStamp,D()),a.status=t.status,e.notify(v({},a))}}));this.addEventListener("loadend",s),e.notify(r)}}function rn(){var e=Zt.get(this);e&&(e.isAborted=!0)}function on(){var e;return Qt||(e=new Me((function(){if(window.fetch)return Yt(window,"fetch",(function(t){return function(n,r){var o,i=c(sn,null,[e,n,r]);return i?(o=t.call(this,i.input,i.init),c(an,null,[e,o,i])):o=t.call(this,n,r),o}})).stop})),Qt=e),Qt}function sn(e,t,n){var r=n&&n.method||"object"==typeof t&&t.method||"GET",o=ee("object"==typeof t&&t.url||t),i={state:"start",init:n,input:t,method:r,startClocks:N(),url:o};return e.notify(i),i}function an(e,t,n){var r=function(t){var r=n;r.state="complete",r.duration=H(r.startClocks.timeStamp,D()),"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 un(e,t){if(!e.forwardErrorsToLogs)return{stop:y};var n=en().subscribe((function(e){"complete"===e.state&&o("xhr",e)})),r=on().subscribe((function(e){"complete"===e.state&&o("fetch",e)}));function o(n,r){function o(e){t.notify(0,{rawLogsEvent:{message:"".concat(fn(n)," error ").concat(r.method," ").concat(r.url),date:r.startClocks.timeStamp,error:{origin:Ee,stack:e||"Failed to load"},http:{method:r.method,status_code:r.status,url:r.url},status:De.error,origin:Ee}})}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(cn(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(cn(e,t))})),u((function(e){return n("Unable to retrieve response: ".concat(e))})))}(r.response,e,o):r.error&&function(e,t,n){n(cn(Le(de(e)),t))}(r.error,e,o))}return{stop:function(){n.unsubscribe(),r.unsubscribe()}}}function cn(e,t){return e.length>t.requestErrorResponseLengthLimit?"".concat(e.substring(0,t.requestErrorResponseLengthLimit),"..."):e}function fn(e){return"xhr"===e?"XHR":"Fetch"}var ln=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/;function dn(e){var t=function(e){return Kt(window,"onerror",{before:function(t,n,r,o,i){var s;if(i)s=de(i),e(s,i);else{var a,u={url:n,column:o,line:r},c=t;if("[object String]"==={}.toString.call(t)){var f=ln.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 Kt(window,"onunhandledrejection",{before:function(t){var n=t.reason||"Empty reason",r=de(n);e(r,n)}})}(e).stop;return{stop:function(){t(),n()}}}function pn(e){return dn((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:Le(t),handlingStack:r,type:t.name,causes:Be(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:N(),nonErrorPrefix:"Uncaught",source:Re,handling:"unhandled"}))}))}var vn=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 gn,hn,yn,mn,bn=function(n){var r,o,i=!1,a=I(),c=I(),f={},l=function(){},d=new j,p=function(e,t,n,r){void 0===n&&(n=P(y())),void 0===r&&(r=D()),d.add((function(){return p(e,t,n,r)}))},g=function(){},h=new Ge((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(V()&&(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=ce(t),r=je(t.forwardConsoleLogs,k(e),"Forward Console Logs"),o=je(t.forwardReports,k(qe),"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 P(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 Ge((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($(e))})),getUser:u(c.getContext),setUserProperty:u((function(e,t){var n,r=$((n={},n[e]=t,n))[e];c.setContextProperty(e,r)})),removeUserProperty:u(c.removeContextProperty),clearUser:u(c.clearContext)},o=v({version:"4.24.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 vn,u=function(e){return a.notify(0,{rawLogsEvent:{message:e.message,date:e.startClocks.timeStamp,error:{origin:xe},origin:xe,status:De.error}})},c=s=new Me((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=Qe("browser-logs-sdk",e);if(V()){var i=z();o.observable.subscribe((function(e){return i.send("internal_telemetry",e)}))}else{var s=pt(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=Nt())||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=Nt())||void 0===n?void 0:n.view)||void 0===r?void 0:r.id},action:{id:null===(i=null===(o=Nt())||void 0===o?void 0:o.user_action)||void 0===i?void 0:i.id}}})),un(r,a),function(e,t){if(!e.forwardErrorsToLogs)return{stop:y};var n=new Me,r=pn(n).stop,o=n.subscribe((function(e){t.notify(0,{rawLogsEvent:{message:e.message,date:e.startClocks.timeStamp,error:{kind:e.type,origin:Re,stack:e.stack},origin:Re,status:De.error}})}))}(r,a),function(t,n){var r=zt(t.forwardConsoleLogs).subscribe((function(t){n.notify(0,{rawLogsEvent:{date:D(),message:t.message,origin:ke,error:t.api===e.error?{origin:ke,stack:t.stack}:void 0,status:Jt[t.api]}})}))}(r,a),function(e,t){var n=Ie(e.forwardReports).subscribe((function(e){var n,r=e.message,o=Xt[e.type];o===De.error?n={kind:e.subtype,origin:Te,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:D(),message:r,origin:Te,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,Fe,r)&&t(n.status,n.message,q(r.getContext(),s)),e.notify(0,{rawLogsEvent:{date:i||D(),message:n.message,status:n.status,origin:Se},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";Y(n,r,l,e);var o=K(n)===r;return Q(n,e),o}catch(e){return t.error(e),!1}}(r.cookieOptions)||V()||ze()?function(e){var t="1"===At(e)?{}:void 0;return{findTrackedSession:function(){return t}}}(r):It(r);return Dt(h,r,a,o,i,u),V()?function(e){var t=z();e.subscribe(1,(function(e){t.send("log",e)}))}(a):function(e,t,n,r){var o,i=pt(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){Ke.telemetryConfigurationEnabled&&et({type:We,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}}(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}}));gn=R(),yn=bn,mn=gn[hn="DD_LOGS"],gn[hn]=yn,mn&&mn.q&&mn.q.forEach((function(e){return n(e,"onReady callback threw an error:")()}))}();

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

import type { InitConfiguration } from '@datadog/browser-core';
import type { Context, InitConfiguration, User } from '@datadog/browser-core';
import type { LogsInitConfiguration } from '../domain/configuration';

@@ -17,7 +17,7 @@ import type { HandlerType, StatusType } from '../domain/logger';

/** @deprecated: use getGlobalContext instead */
getLoggerGlobalContext: () => import("@datadog/browser-core").Context;
getGlobalContext: () => import("@datadog/browser-core").Context;
getLoggerGlobalContext: () => Context;
getGlobalContext: () => Context;
/** @deprecated: use setGlobalContext instead */
setLoggerGlobalContext: (newContext: object) => void;
setGlobalContext: (newContext: import("@datadog/browser-core").Context) => void;
setGlobalContext: (newContext: Context) => void;
/** @deprecated: use setGlobalContextProperty instead */

@@ -34,2 +34,7 @@ addLoggerGlobalContext: (key: string, value: any) => void;

getInternalContext: (startTime?: number | undefined) => import("../domain/internalContext").InternalContext | undefined;
setUser: (newUser: User) => void;
getUser: () => Context;
setUserProperty: (key: any, property: any) => void;
removeUserProperty: (key: string) => void;
clearUser: () => void;
} & {

@@ -36,0 +41,0 @@ onReady(callback: () => void): void;

@@ -10,2 +10,3 @@ "use strict";

var globalContextManager = (0, browser_core_1.createContextManager)();
var userContextManager = (0, browser_core_1.createContextManager)();
var customLoggers = {};

@@ -33,3 +34,4 @@ var getInternalContextStrategy = function () { return undefined; };

},
context: globalContextManager.get(),
context: globalContextManager.getContext(),
user: userContextManager.getContext(),
};

@@ -84,2 +86,15 @@ }

getInternalContext: (0, browser_core_1.monitor)(function (startTime) { return getInternalContextStrategy(startTime); }),
setUser: (0, browser_core_1.monitor)(function (newUser) {
if ((0, browser_core_1.checkUser)(newUser)) {
userContextManager.setContext((0, browser_core_1.sanitizeUser)(newUser));
}
}),
getUser: (0, browser_core_1.monitor)(userContextManager.getContext),
setUserProperty: (0, browser_core_1.monitor)(function (key, property) {
var _a;
var sanitizedProperty = (0, browser_core_1.sanitizeUser)((_a = {}, _a[key] = property, _a))[key];
userContextManager.setContextProperty(key, sanitizedProperty);
}),
removeUserProperty: (0, browser_core_1.monitor)(userContextManager.removeContextProperty),
clearUser: (0, browser_core_1.monitor)(userContextManager.clearContext),
});

@@ -86,0 +101,0 @@ function overrideInitConfigurationForBridge(initConfiguration) {

@@ -33,3 +33,4 @@ "use strict";

};
var telemetry = startLogsTelemetry(configuration, reportError);
var pageExitObservable = (0, browser_core_1.createPageExitObservable)();
var telemetry = startLogsTelemetry(configuration, reportError, pageExitObservable);
telemetry.setContextProvider(function () {

@@ -62,3 +63,3 @@ var _a, _b, _c, _d, _e, _f;

if (!(0, browser_core_1.canUseEventBridge)()) {
(0, startLogsBatch_1.startLogsBatch)(configuration, lifeCycle, reportError);
(0, startLogsBatch_1.startLogsBatch)(configuration, lifeCycle, reportError, pageExitObservable);
}

@@ -76,3 +77,3 @@ else {

exports.startLogs = startLogs;
function startLogsTelemetry(configuration, reportError) {
function startLogsTelemetry(configuration, reportError, pageExitObservable) {
var _a;

@@ -85,3 +86,3 @@ var telemetry = (0, browser_core_1.startTelemetry)("browser-logs-sdk" /* LOGS */, configuration);

else {
var telemetryBatch_1 = (0, browser_core_1.startBatchWithReplica)(configuration, configuration.rumEndpointBuilder, reportError, (_a = configuration.replica) === null || _a === void 0 ? void 0 : _a.rumEndpointBuilder);
var telemetryBatch_1 = (0, browser_core_1.startBatchWithReplica)(configuration, configuration.rumEndpointBuilder, reportError, pageExitObservable, (_a = configuration.replica) === null || _a === void 0 ? void 0 : _a.rumEndpointBuilder);
telemetry.observable.subscribe(function (event) { return telemetryBatch_1.add(event, (0, browser_core_1.isTelemetryReplicationAllowed)(configuration)); });

@@ -88,0 +89,0 @@ }

@@ -23,3 +23,9 @@ "use strict";

var commonContext = savedCommonContext || getCommonContext();
var log = (0, browser_core_1.combine)({ service: configuration.service, session_id: session.id, view: commonContext.view }, commonContext.context, getRUMInternalContext(startTime), rawLogsEvent, logger.getContext(), messageContext);
var log = (0, browser_core_1.combine)({
service: configuration.service,
session_id: session.id,
// Insert user first to allow overrides from global context
usr: !(0, browser_core_1.isEmptyObject)(commonContext.user) ? commonContext.user : undefined,
view: commonContext.view,
}, commonContext.context, getRUMInternalContext(startTime), rawLogsEvent, logger.getContext(), messageContext);
if (

@@ -26,0 +32,0 @@ // Todo: [RUMF-1230] Move this check to the logger collection in the next major release

@@ -21,2 +21,7 @@ export { Logger, LogsMessage, StatusType, HandlerType } from '../domain/logger';

getInternalContext: (startTime?: number | undefined) => import("../domain/internalContext").InternalContext | undefined;
setUser: (newUser: import("@datadog/browser-core").User) => void;
getUser: () => import("@datadog/browser-core").Context;
setUserProperty: (key: any, property: any) => void;
removeUserProperty: (key: string) => void;
clearUser: () => void;
} & {

@@ -23,0 +28,0 @@ onReady(callback: () => void): void;

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

import type { Context, ErrorSource, TimeStamp } from '@datadog/browser-core';
import type { Context, ErrorSource, TimeStamp, User } from '@datadog/browser-core';
import type { StatusType } from './domain/logger';

@@ -52,3 +52,4 @@ export declare type RawLogsEvent = RawConsoleLogsEvent | RawNetworkLogsEvent | RawLoggerLogsEvent | RawAgentLogsEvent | RawReportLogsEvent | RawRuntimeLogsEvent;

context: Context;
user: User;
}
export {};

@@ -1,4 +0,4 @@

import type { RawError } from '@datadog/browser-core';
import type { Observable, PageExitEvent, RawError } from '@datadog/browser-core';
import type { LogsConfiguration } from '../domain/configuration';
import type { LifeCycle } from '../domain/lifeCycle';
export declare function startLogsBatch(configuration: LogsConfiguration, lifeCycle: LifeCycle, reportError: (error: RawError) => void): void;
export declare function startLogsBatch(configuration: LogsConfiguration, lifeCycle: LifeCycle, reportError: (error: RawError) => void, pageExitObservable: Observable<PageExitEvent>): void;

@@ -5,5 +5,5 @@ "use strict";

var browser_core_1 = require("@datadog/browser-core");
function startLogsBatch(configuration, lifeCycle, reportError) {
function startLogsBatch(configuration, lifeCycle, reportError, pageExitObservable) {
var _a;
var batch = (0, browser_core_1.startBatchWithReplica)(configuration, configuration.logsEndpointBuilder, reportError, (_a = configuration.replica) === null || _a === void 0 ? void 0 : _a.logsEndpointBuilder);
var batch = (0, browser_core_1.startBatchWithReplica)(configuration, configuration.logsEndpointBuilder, reportError, pageExitObservable, (_a = configuration.replica) === null || _a === void 0 ? void 0 : _a.logsEndpointBuilder);
lifeCycle.subscribe(1 /* LOG_COLLECTED */, function (serverLogsEvent) {

@@ -10,0 +10,0 @@ batch.add(serverLogsEvent);

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

import type { InitConfiguration } from '@datadog/browser-core';
import type { Context, InitConfiguration, User } from '@datadog/browser-core';
import type { LogsInitConfiguration } from '../domain/configuration';

@@ -17,7 +17,7 @@ import type { HandlerType, StatusType } from '../domain/logger';

/** @deprecated: use getGlobalContext instead */
getLoggerGlobalContext: () => import("@datadog/browser-core").Context;
getGlobalContext: () => import("@datadog/browser-core").Context;
getLoggerGlobalContext: () => Context;
getGlobalContext: () => Context;
/** @deprecated: use setGlobalContext instead */
setLoggerGlobalContext: (newContext: object) => void;
setGlobalContext: (newContext: import("@datadog/browser-core").Context) => void;
setGlobalContext: (newContext: Context) => void;
/** @deprecated: use setGlobalContextProperty instead */

@@ -34,2 +34,7 @@ addLoggerGlobalContext: (key: string, value: any) => void;

getInternalContext: (startTime?: number | undefined) => import("../domain/internalContext").InternalContext | undefined;
setUser: (newUser: User) => void;
getUser: () => Context;
setUserProperty: (key: any, property: any) => void;
removeUserProperty: (key: string) => void;
clearUser: () => void;
} & {

@@ -36,0 +41,0 @@ onReady(callback: () => void): void;

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

import { assign, BoundedBuffer, createContextManager, makePublicApi, monitor, display, deepClone, canUseEventBridge, timeStampNow, } from '@datadog/browser-core';
import { assign, BoundedBuffer, createContextManager, makePublicApi, monitor, display, deepClone, canUseEventBridge, timeStampNow, checkUser, sanitizeUser, } from '@datadog/browser-core';
import { validateAndBuildLogsConfiguration } from '../domain/configuration';

@@ -7,2 +7,3 @@ import { Logger } from '../domain/logger';

var globalContextManager = createContextManager();
var userContextManager = createContextManager();
var customLoggers = {};

@@ -30,3 +31,4 @@ var getInternalContextStrategy = function () { return undefined; };

},
context: globalContextManager.get(),
context: globalContextManager.getContext(),
user: userContextManager.getContext(),
};

@@ -81,2 +83,15 @@ }

getInternalContext: monitor(function (startTime) { return getInternalContextStrategy(startTime); }),
setUser: monitor(function (newUser) {
if (checkUser(newUser)) {
userContextManager.setContext(sanitizeUser(newUser));
}
}),
getUser: monitor(userContextManager.getContext),
setUserProperty: monitor(function (key, property) {
var _a;
var sanitizedProperty = sanitizeUser((_a = {}, _a[key] = property, _a))[key];
userContextManager.setContextProperty(key, sanitizedProperty);
}),
removeUserProperty: monitor(userContextManager.removeContextProperty),
clearUser: monitor(userContextManager.clearContext),
});

@@ -83,0 +98,0 @@ function overrideInitConfigurationForBridge(initConfiguration) {

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

import { willSyntheticsInjectRum, areCookiesAuthorized, canUseEventBridge, getEventBridge, startTelemetry, startBatchWithReplica, isTelemetryReplicationAllowed, ErrorSource, addTelemetryConfiguration, } from '@datadog/browser-core';
import { createPageExitObservable, willSyntheticsInjectRum, areCookiesAuthorized, canUseEventBridge, getEventBridge, startTelemetry, startBatchWithReplica, isTelemetryReplicationAllowed, ErrorSource, addTelemetryConfiguration, } from '@datadog/browser-core';
import { startLogsSessionManager, startLogsSessionManagerStub } from '../domain/logsSessionManager';

@@ -30,3 +30,4 @@ import { serializeLogsConfiguration } from '../domain/configuration';

};
var telemetry = startLogsTelemetry(configuration, reportError);
var pageExitObservable = createPageExitObservable();
var telemetry = startLogsTelemetry(configuration, reportError, pageExitObservable);
telemetry.setContextProvider(function () {

@@ -59,3 +60,3 @@ var _a, _b, _c, _d, _e, _f;

if (!canUseEventBridge()) {
startLogsBatch(configuration, lifeCycle, reportError);
startLogsBatch(configuration, lifeCycle, reportError, pageExitObservable);
}

@@ -72,3 +73,3 @@ else {

}
function startLogsTelemetry(configuration, reportError) {
function startLogsTelemetry(configuration, reportError, pageExitObservable) {
var _a;

@@ -81,3 +82,3 @@ var telemetry = startTelemetry("browser-logs-sdk" /* LOGS */, configuration);

else {
var telemetryBatch_1 = startBatchWithReplica(configuration, configuration.rumEndpointBuilder, reportError, (_a = configuration.replica) === null || _a === void 0 ? void 0 : _a.rumEndpointBuilder);
var telemetryBatch_1 = startBatchWithReplica(configuration, configuration.rumEndpointBuilder, reportError, pageExitObservable, (_a = configuration.replica) === null || _a === void 0 ? void 0 : _a.rumEndpointBuilder);
telemetry.observable.subscribe(function (event) { return telemetryBatch_1.add(event, isTelemetryReplicationAllowed(configuration)); });

@@ -84,0 +85,0 @@ }

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

import { getSyntheticsResultId, getSyntheticsTestId, addTelemetryDebug, willSyntheticsInjectRum, ErrorSource, combine, createEventRateLimiter, getRelativeTime, } from '@datadog/browser-core';
import { getSyntheticsResultId, getSyntheticsTestId, addTelemetryDebug, willSyntheticsInjectRum, ErrorSource, combine, createEventRateLimiter, getRelativeTime, isEmptyObject, } from '@datadog/browser-core';
import { STATUSES, HandlerType } from './logger';

@@ -20,3 +20,9 @@ import { isAuthorized } from './logsCollection/logger/loggerCollection';

var commonContext = savedCommonContext || getCommonContext();
var log = combine({ service: configuration.service, session_id: session.id, view: commonContext.view }, commonContext.context, getRUMInternalContext(startTime), rawLogsEvent, logger.getContext(), messageContext);
var log = combine({
service: configuration.service,
session_id: session.id,
// Insert user first to allow overrides from global context
usr: !isEmptyObject(commonContext.user) ? commonContext.user : undefined,
view: commonContext.view,
}, commonContext.context, getRUMInternalContext(startTime), rawLogsEvent, logger.getContext(), messageContext);
if (

@@ -23,0 +29,0 @@ // Todo: [RUMF-1230] Move this check to the logger collection in the next major release

@@ -21,2 +21,7 @@ export { Logger, LogsMessage, StatusType, HandlerType } from '../domain/logger';

getInternalContext: (startTime?: number | undefined) => import("../domain/internalContext").InternalContext | undefined;
setUser: (newUser: import("@datadog/browser-core").User) => void;
getUser: () => import("@datadog/browser-core").Context;
setUserProperty: (key: any, property: any) => void;
removeUserProperty: (key: string) => void;
clearUser: () => void;
} & {

@@ -23,0 +28,0 @@ onReady(callback: () => void): void;

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

import type { Context, ErrorSource, TimeStamp } from '@datadog/browser-core';
import type { Context, ErrorSource, TimeStamp, User } from '@datadog/browser-core';
import type { StatusType } from './domain/logger';

@@ -52,3 +52,4 @@ export declare type RawLogsEvent = RawConsoleLogsEvent | RawNetworkLogsEvent | RawLoggerLogsEvent | RawAgentLogsEvent | RawReportLogsEvent | RawRuntimeLogsEvent;

context: Context;
user: User;
}
export {};

@@ -1,4 +0,4 @@

import type { RawError } from '@datadog/browser-core';
import type { Observable, PageExitEvent, RawError } from '@datadog/browser-core';
import type { LogsConfiguration } from '../domain/configuration';
import type { LifeCycle } from '../domain/lifeCycle';
export declare function startLogsBatch(configuration: LogsConfiguration, lifeCycle: LifeCycle, reportError: (error: RawError) => void): void;
export declare function startLogsBatch(configuration: LogsConfiguration, lifeCycle: LifeCycle, reportError: (error: RawError) => void, pageExitObservable: Observable<PageExitEvent>): void;
import { startBatchWithReplica } from '@datadog/browser-core';
export function startLogsBatch(configuration, lifeCycle, reportError) {
export function startLogsBatch(configuration, lifeCycle, reportError, pageExitObservable) {
var _a;
var batch = startBatchWithReplica(configuration, configuration.logsEndpointBuilder, reportError, (_a = configuration.replica) === null || _a === void 0 ? void 0 : _a.logsEndpointBuilder);
var batch = startBatchWithReplica(configuration, configuration.logsEndpointBuilder, reportError, pageExitObservable, (_a = configuration.replica) === null || _a === void 0 ? void 0 : _a.logsEndpointBuilder);
lifeCycle.subscribe(1 /* LOG_COLLECTED */, function (serverLogsEvent) {

@@ -6,0 +6,0 @@ batch.add(serverLogsEvent);

{
"name": "@datadog/browser-logs",
"version": "4.23.3",
"version": "4.24.0",
"license": "Apache-2.0",

@@ -16,6 +16,6 @@ "main": "cjs/entries/main.js",

"dependencies": {
"@datadog/browser-core": "4.23.3"
"@datadog/browser-core": "4.24.0"
},
"peerDependencies": {
"@datadog/browser-rum": "4.23.3"
"@datadog/browser-rum": "4.24.0"
},

@@ -36,3 +36,3 @@ "peerDependenciesMeta": {

},
"gitHead": "34d32df19bb97046feb67fc585376e3b06295702"
"gitHead": "5d165e9050d3cb2554d5a402af6959c13ad3d26b"
}
# Browser Log Collection
Send logs to Datadog from web browsers or other Javascript clients with the browser logs SDK.
Send logs to Datadog from web browser pages with the browser logs SDK.
With the browser logs SDK, you can send logs directly to Datadog from JS clients and leverage the following features:
With the browser logs SDK, you can send logs directly to Datadog from web browser pages and leverage the following features:

@@ -97,3 +97,3 @@ - Use the SDK as a logger. Everything is forwarded to Datadog as JSON documents.

**Note**: The `window.DD_LOGS` check is used to prevent issues if a loading failure occurs with the SDK.
**Note**: The `window.DD_LOGS` check prevents issues when a loading failure occurs with the SDK.

@@ -178,3 +178,3 @@ ### TypeScript

**Note**: The `window.DD_LOGS` check is used to prevent issues if a loading failure occurs with the SDK.
**Note**: The `window.DD_LOGS` check prevents issues when a loading failure occurs with the SDK.

@@ -476,3 +476,3 @@ #### Results

**Note**: The `window.DD_LOGS` check is used to prevent issues if a loading failure occurs with the SDK.
**Note**: The `window.DD_LOGS` check prevents issues when a loading failure occurs with the SDK.

@@ -576,4 +576,92 @@ ### Overwrite context

**Note**: The `window.DD_LOGS` check is used to prevent issues if a loading failure occurs with the SDK.
**Note**: The `window.DD_LOGS` check prevents issues when a loading failure occurs with the SDK.
#### User context
The Datadog logs SDK provides convenient functions to associate a `User` with generated logs.
- Set the user for all your loggers with the `setUser (newUser: User)` API.
- Add or modify a user property to all your loggers with the `setUserProperty (key: string, value: any)` API.
- Get the currently stored user with the `getUser ()` API.
- Remove a user property with the `removeUserProperty (key: string)` API.
- Clear all existing user properties with the `clearUser ()` API.
**Note**: The user context is applied before the global context. Hence, every user property included in the global context will override the user context when generating logs.
##### NPM
For NPM, use:
```javascript
import { datadogLogs } from '@datadog/browser-logs'
datadogLogs.setUser({ id: '1234', name: 'John Doe', email: 'john@doe.com' })
datadogLogs.setUserProperty('type', 'customer')
datadogLogs.getUser() // => {id: '1234', name: 'John Doe', email: 'john@doe.com', type: 'customer'}
datadogLogs.removeUserProperty('type')
datadogLogs.getUser() // => {id: '1234', name: 'John Doe', email: 'john@doe.com'}
datadogLogs.clearUser()
datadogLogs.getUser() // => {}
```
#### CDN async
For CDN async, use:
```javascript
DD_LOGS.onReady(function () {
DD_LOGS.setUser({ id: '1234', name: 'John Doe', email: 'john@doe.com' })
})
DD_LOGS.onReady(function () {
DD_LOGS.setUserProperty('type', 'customer')
})
DD_LOGS.onReady(function () {
DD_LOGS.getUser() // => {id: '1234', name: 'John Doe', email: 'john@doe.com', type: 'customer'}
})
DD_LOGS.onReady(function () {
DD_LOGS.removeUserProperty('type')
})
DD_LOGS.onReady(function () {
DD_LOGS.getUser() // => {id: '1234', name: 'John Doe', email: 'john@doe.com'}
})
DD_LOGS.onReady(function () {
DD_LOGS.clearUser()
})
DD_LOGS.onReady(function () {
DD_LOGS.getUser() // => {}
})
```
**Note:** Early API calls must be wrapped in the `DD_LOGS.onReady()` callback. This ensures the code only gets executed once the SDK is properly loaded.
##### CDN sync
For CDN sync, use:
```javascript
window.DD_LOGS && DD_LOGS.setUser({ id: '1234', name: 'John Doe', email: 'john@doe.com' })
window.DD_LOGS && DD_LOGS.setUserProperty('type', 'customer')
window.DD_LOGS && DD_LOGS.getUser() // => {id: '1234', name: 'John Doe', email: 'john@doe.com', type: 'customer'}
window.DD_LOGS && DD_LOGS.removeUserProperty('type')
window.DD_LOGS && DD_LOGS.getUser() // => {id: '1234', name: 'John Doe', email: 'john@doe.com'}
window.DD_LOGS && DD_LOGS.clearUser()
window.DD_LOGS && DD_LOGS.getUser() // => {}
```
**Note**: The `window.DD_LOGS` check prevents issues when a loading failure occurs with the SDK.
#### Logger context

@@ -624,3 +712,3 @@

**Note**: The `window.DD_LOGS` check is used to prevent issues if a loading failure occurs with the SDK.
**Note**: The `window.DD_LOGS` check prevents issues when a loading failure occurs with the SDK.

@@ -667,3 +755,3 @@ ### Filter by status

**Note**: The `window.DD_LOGS` check is used to prevent issues if a loading failure occurs with the SDK.
**Note**: The `window.DD_LOGS` check prevents issues when a loading failure occurs with the SDK.

@@ -715,3 +803,3 @@ ### Change the destination

**Note**: The `window.DD_LOGS` check is used to prevent issues if a loading failure occurs with the SDK.
**Note**: The `window.DD_LOGS` check prevents issues when a loading failure occurs with the SDK.

@@ -718,0 +806,0 @@ ### Access internal context

@@ -141,3 +141,3 @@ import type { TimeStamp } from '@datadog/browser-core'

it('should have the current date, view and global context', () => {
LOGS.addLoggerGlobalContext('foo', 'bar')
LOGS.setGlobalContextProperty('foo', 'bar')

@@ -151,2 +151,3 @@ const getCommonContext = startLogs.calls.mostRecent().args[2]

context: { foo: 'bar' },
user: {},
})

@@ -330,3 +331,145 @@ })

})
describe('setUser', () => {
let logsPublicApi: LogsPublicApi
let displaySpy: jasmine.Spy<() => void>
beforeEach(() => {
displaySpy = spyOn(display, 'error')
logsPublicApi = makeLogsPublicApi(startLogs)
logsPublicApi.init(DEFAULT_INIT_CONFIGURATION)
})
it('should store user in common context', () => {
const user = { id: 'foo', name: 'bar', email: 'qux', foo: { bar: 'qux' } }
logsPublicApi.setUser(user)
const getCommonContext = startLogs.calls.mostRecent().args[2]
expect(getCommonContext().user).toEqual({
email: 'qux',
foo: { bar: 'qux' },
id: 'foo',
name: 'bar',
})
})
it('should sanitize predefined properties', () => {
const user = { id: null, name: 2, email: { bar: 'qux' } }
logsPublicApi.setUser(user as any)
const getCommonContext = startLogs.calls.mostRecent().args[2]
expect(getCommonContext().user).toEqual({
email: '[object Object]',
id: 'null',
name: '2',
})
})
it('should clear a previously set user', () => {
const user = { id: 'foo', name: 'bar', email: 'qux' }
logsPublicApi.setUser(user)
logsPublicApi.clearUser()
const getCommonContext = startLogs.calls.mostRecent().args[2]
expect(getCommonContext().user).toEqual({})
})
it('should reject non object input', () => {
logsPublicApi.setUser(2 as any)
logsPublicApi.setUser(null as any)
logsPublicApi.setUser(undefined as any)
expect(displaySpy).toHaveBeenCalledTimes(3)
})
})
describe('getUser', () => {
let logsPublicApi: LogsPublicApi
beforeEach(() => {
logsPublicApi = makeLogsPublicApi(startLogs)
logsPublicApi.init(DEFAULT_INIT_CONFIGURATION)
})
it('should return empty object if no user has been set', () => {
const userClone = logsPublicApi.getUser()
expect(userClone).toEqual({})
})
it('should return a clone of the original object if set', () => {
const user = { id: 'foo', name: 'bar', email: 'qux', foo: { bar: 'qux' } }
logsPublicApi.setUser(user)
const userClone = logsPublicApi.getUser()
const userClone2 = logsPublicApi.getUser()
expect(userClone).not.toBe(user)
expect(userClone).not.toBe(userClone2)
expect(userClone).toEqual(user)
})
})
describe('setUserProperty', () => {
const user = { id: 'foo', name: 'bar', email: 'qux', foo: { bar: 'qux' } }
const addressAttribute = { city: 'Paris' }
let logsPublicApi: LogsPublicApi
beforeEach(() => {
logsPublicApi = makeLogsPublicApi(startLogs)
logsPublicApi.init(DEFAULT_INIT_CONFIGURATION)
})
it('should add attribute', () => {
logsPublicApi.setUser(user)
logsPublicApi.setUserProperty('address', addressAttribute)
const userClone = logsPublicApi.getUser()
expect(userClone.address).toEqual(addressAttribute)
})
it('should not contain original reference to object', () => {
const userDetails: { [key: string]: any } = { name: 'john' }
logsPublicApi.setUser(user)
logsPublicApi.setUserProperty('userDetails', userDetails)
userDetails.DOB = '11/11/1999'
const userClone = logsPublicApi.getUser()
expect(userClone.userDetails).not.toBe(userDetails)
})
it('should override attribute', () => {
logsPublicApi.setUser(user)
logsPublicApi.setUserProperty('foo', addressAttribute)
const userClone = logsPublicApi.getUser()
expect(userClone).toEqual({ ...user, foo: addressAttribute })
})
it('should sanitize properties', () => {
logsPublicApi.setUserProperty('id', 123)
logsPublicApi.setUserProperty('name', ['Adam', 'Smith'])
logsPublicApi.setUserProperty('email', { foo: 'bar' })
const userClone = logsPublicApi.getUser()
expect(userClone.id).toEqual('123')
expect(userClone.name).toEqual('Adam,Smith')
expect(userClone.email).toEqual('[object Object]')
})
})
describe('removeUserProperty', () => {
let logsPublicApi: LogsPublicApi
beforeEach(() => {
logsPublicApi = makeLogsPublicApi(startLogs)
logsPublicApi.init(DEFAULT_INIT_CONFIGURATION)
})
it('should remove property', () => {
const user = { id: 'foo', name: 'bar', email: 'qux', foo: { bar: 'qux' } }
logsPublicApi.setUser(user)
logsPublicApi.removeUserProperty('foo')
const userClone = logsPublicApi.getUser()
expect(userClone.foo).toBeUndefined()
})
})
})
})

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

import type { InitConfiguration } from '@datadog/browser-core'
import type { Context, InitConfiguration, User } from '@datadog/browser-core'
import {

@@ -12,2 +12,4 @@ assign,

timeStampNow,
checkUser,
sanitizeUser,
} from '@datadog/browser-core'

@@ -37,2 +39,4 @@ import type { LogsInitConfiguration } from '../domain/configuration'

const globalContextManager = createContextManager()
const userContextManager = createContextManager()
const customLoggers: { [name: string]: Logger | undefined } = {}

@@ -61,3 +65,4 @@ let getInternalContextStrategy: StartLogsResult['getInternalContext'] = () => undefined

},
context: globalContextManager.get(),
context: globalContextManager.getContext(),
user: userContextManager.getContext(),
}

@@ -131,2 +136,19 @@ }

getInternalContext: monitor((startTime?: number | undefined) => getInternalContextStrategy(startTime)),
setUser: monitor((newUser: User) => {
if (checkUser(newUser)) {
userContextManager.setContext(sanitizeUser(newUser as Context))
}
}),
getUser: monitor(userContextManager.getContext),
setUserProperty: monitor((key, property) => {
const sanitizedProperty = sanitizeUser({ [key]: property })[key]
userContextManager.setContextProperty(key, sanitizedProperty)
}),
removeUserProperty: monitor(userContextManager.removeContextProperty),
clearUser: monitor(userContextManager.clearContext),
})

@@ -133,0 +155,0 @@

@@ -36,2 +36,3 @@ import { ErrorSource, display, stopSessionManager, getCookie, SESSION_COOKIE_NAME } from '@datadog/browser-core'

context: {},
user: {},
}

@@ -38,0 +39,0 @@

@@ -1,3 +0,4 @@

import type { Context, TelemetryEvent, RawError } from '@datadog/browser-core'
import type { Context, TelemetryEvent, RawError, Observable, PageExitEvent } from '@datadog/browser-core'
import {
createPageExitObservable,
TelemetryService,

@@ -51,3 +52,4 @@ willSyntheticsInjectRum,

})
const telemetry = startLogsTelemetry(configuration, reportError)
const pageExitObservable = createPageExitObservable()
const telemetry = startLogsTelemetry(configuration, reportError, pageExitObservable)
telemetry.setContextProvider(() => ({

@@ -82,3 +84,3 @@ application: {

if (!canUseEventBridge()) {
startLogsBatch(configuration, lifeCycle, reportError)
startLogsBatch(configuration, lifeCycle, reportError, pageExitObservable)
} else {

@@ -97,3 +99,7 @@ startLogsBridge(lifeCycle)

function startLogsTelemetry(configuration: LogsConfiguration, reportError: (error: RawError) => void) {
function startLogsTelemetry(
configuration: LogsConfiguration,
reportError: (error: RawError) => void,
pageExitObservable: Observable<PageExitEvent>
) {
const telemetry = startTelemetry(TelemetryService.LOGS, configuration)

@@ -108,2 +114,3 @@ if (canUseEventBridge()) {

reportError,
pageExitObservable,
configuration.replica?.rumEndpointBuilder

@@ -110,0 +117,0 @@ )

@@ -28,4 +28,10 @@ import type { Context, RelativeTime, TelemetryEvent, TimeStamp } from '@datadog/browser-core'

context: { common_context_key: 'common_context_value' },
user: {},
}
const COMMON_CONTEXT_WITH_USER: CommonContext = {
...COMMON_CONTEXT,
user: { id: 'id', name: 'name', email: 'test@test.com' },
}
describe('startLogsAssembly', () => {

@@ -130,2 +136,3 @@ const sessionManager: LogsSessionManager = {

context: { foo: 'bar' },
user: { email: 'test@test.com' },
}

@@ -275,2 +282,69 @@ lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, { rawLogsEvent: DEFAULT_MESSAGE, savedCommonContext })

describe('user management', () => {
const sessionManager: LogsSessionManager = {
findTrackedSession: () => (sessionIsTracked ? { id: SESSION_ID } : undefined),
}
let sessionIsTracked: boolean
let lifeCycle: LifeCycle
let serverLogs: Array<LogsEvent & Context> = []
const beforeSend: (event: LogsEvent) => void | boolean = noop
const mainLogger = new Logger(() => noop)
const configuration = {
...validateAndBuildLogsConfiguration(initConfiguration)!,
beforeSend: (x: LogsEvent) => beforeSend(x),
}
beforeEach(() => {
sessionIsTracked = true
lifeCycle = new LifeCycle()
lifeCycle.subscribe(LifeCycleEventType.LOG_COLLECTED, (serverRumEvent) => serverLogs.push(serverRumEvent))
})
afterEach(() => {
delete window.DD_RUM
serverLogs = []
})
it('should not output usr key if user is not set', () => {
startLogsAssembly(sessionManager, configuration, lifeCycle, () => COMMON_CONTEXT, mainLogger, noop)
lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, { rawLogsEvent: DEFAULT_MESSAGE })
expect(serverLogs[0].usr).toBeUndefined()
})
it('should include user data when user has been set', () => {
startLogsAssembly(sessionManager, configuration, lifeCycle, () => COMMON_CONTEXT_WITH_USER, mainLogger, noop)
lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, { rawLogsEvent: DEFAULT_MESSAGE })
expect(serverLogs[0].usr).toEqual({
id: 'id',
name: 'name',
email: 'test@test.com',
})
})
it('should prioritize global context over user context', () => {
const globalContextWithUser = {
...COMMON_CONTEXT_WITH_USER,
context: {
...COMMON_CONTEXT.context,
usr: {
id: 4242,
name: 'solution',
},
},
}
startLogsAssembly(sessionManager, configuration, lifeCycle, () => globalContextWithUser, mainLogger, noop)
lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, { rawLogsEvent: DEFAULT_MESSAGE })
expect(serverLogs[0].usr).toEqual({
id: 4242,
name: 'solution',
email: 'test@test.com',
})
})
})
describe('logs limitation', () => {

@@ -277,0 +351,0 @@ let clock: Clock

@@ -11,2 +11,3 @@ import type { Context, EventRateLimiter, RawError, RelativeTime } from '@datadog/browser-core'

getRelativeTime,
isEmptyObject,
} from '@datadog/browser-core'

@@ -48,3 +49,9 @@ import type { CommonContext } from '../rawLogsEvent.types'

const log = combine(
{ service: configuration.service, session_id: session.id, view: commonContext.view },
{
service: configuration.service,
session_id: session.id,
// Insert user first to allow overrides from global context
usr: !isEmptyObject(commonContext.user) ? commonContext.user : undefined,
view: commonContext.view,
},
commonContext.context,

@@ -51,0 +58,0 @@ getRUMInternalContext(startTime),

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

import type { Context, ErrorSource, TimeStamp } from '@datadog/browser-core'
import type { Context, ErrorSource, TimeStamp, User } from '@datadog/browser-core'
import type { StatusType } from './domain/logger'

@@ -68,2 +68,3 @@

context: Context
user: User
}

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

import type { Context, RawError } from '@datadog/browser-core'
import type { Context, Observable, PageExitEvent, RawError } from '@datadog/browser-core'
import { startBatchWithReplica } from '@datadog/browser-core'

@@ -11,3 +11,4 @@ import type { LogsConfiguration } from '../domain/configuration'

lifeCycle: LifeCycle,
reportError: (error: RawError) => void
reportError: (error: RawError) => void,
pageExitObservable: Observable<PageExitEvent>
) {

@@ -18,2 +19,3 @@ const batch = startBatchWithReplica(

reportError,
pageExitObservable,
configuration.replica?.logsEndpointBuilder

@@ -20,0 +22,0 @@ )

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc