Socket
Socket
Sign inDemoInstall

@datadog/browser-logs

Package Overview
Dependencies
1
Maintainers
1
Versions
247
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.37.0 to 4.38.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 a(e){i=e}function s(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))}function l(e,t){var n,r=window;return r.Zone&&"function"==typeof r.Zone.__symbol__&&(n=e[r.Zone.__symbol__(t)]),n||(n=e[t]),n}function d(e,t){return l(window,"setTimeout")(u(e),t)}function v(e,t){return l(window,"setInterval")(u(e),t)}function p(e){l(window,"clearInterval")(e)}var h=1e3,g=6e4;function y(e,t,n){var r,o,i=!n||void 0===n.leading||n.leading,a=!n||void 0===n.trailing||n.trailing,s=!1;return{throttled:function(){for(var n=[],u=0;u<arguments.length;u++)n[u]=arguments[u];s?r=n:(i?e.apply(void 0,n):r=n,s=!0,o=d((function(){a&&r&&e.apply(void 0,r),s=!1,r=void 0}),t))},cancel:function(){var e;e=o,l(window,"clearTimeout")(e),s=!1,r=void 0}}}function b(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 m(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,m)}function w(e){return 0!==e&&100*Math.random()<=e}function C(){}function k(e,t,n){if("object"!=typeof e||null===e)return JSON.stringify(e);var r=x(Object.prototype),o=x(Array.prototype),i=x(Object.getPrototypeOf(e)),a=x(e);try{return JSON.stringify(e,t,n)}catch(e){return"<error: unable to serialize object>"}finally{r(),o(),i(),a()}}function x(e){var t=e,n=t.toJSON;return n?(delete t.toJSON,function(){t.toJSON=n}):C}function S(e,t){return-1!==e.indexOf(t)}function E(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 _(e){return function(e){return"number"==typeof e}(e)&&e>=0&&e<=100}function R(e){return Object.keys(e).map((function(t){return e[t]}))}function T(e){return 0===Object.keys(e).length}function L(e,t){return e.slice(0,t.length)===t}function O(){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 B(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 P(e){return null===e?"null":Array.isArray(e)?"array":typeof e}function A(e,t,n){if(void 0===n&&(n=function(){if("undefined"!=typeof WeakSet){var e=new WeakSet;return{hasAlreadyBeenSeen:function(t){var n=e.has(t);return n||e.add(t),n}}}var t=[];return{hasAlreadyBeenSeen:function(e){var n=t.indexOf(e)>=0;return n||t.push(e),n}}}()),void 0===t)return e;if("object"!=typeof t||null===t)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){var r=t.flags||[t.global?"g":"",t.ignoreCase?"i":"",t.multiline?"m":"",t.sticky?"y":"",t.unicode?"u":""].join("");return new RegExp(t.source,r)}if(!n.hasAlreadyBeenSeen(t)){if(Array.isArray(t)){for(var o=Array.isArray(e)?e:[],i=0;i<t.length;++i)o[i]=A(o[i],t[i],n);return o}var a="object"===P(e)?e:{};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(a[s]=A(a[s],t[s],n));return a}}function M(e){return A(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=A(e,i))}return e}var j,I=/[^\u0000-\u007F]/;function D(e){return I.test(e)?void 0!==window.TextEncoder?(new TextEncoder).encode(e).length:new Blob([e]).size:e.length}function U(e){return!!j&&j.has(e)}function N(){return j||new Set}function F(e,t){var n;void 0===t&&(t=225280);var r=x(Object.prototype),o=x(Array.prototype),i=[],a=new WeakMap,s=z(e,"$",void 0,i,a),u=(null===(n=JSON.stringify(s))||void 0===n?void 0:n.length)||0;if(!(u>t)){for(;i.length>0&&u<t;){var c=i.shift(),f=0;if(Array.isArray(c.source))for(var l=0;l<c.source.length;l++){var d=z(c.source[l],c.path,l,i,a);if((u+=JSON.stringify(d).length+f)>t){H(t,"truncated",e);break}f=1,c.target[l]=d}else for(var l in c.source)if(Object.prototype.hasOwnProperty.call(c.source,l)){d=z(c.source[l],c.path,l,i,a);if((u+=JSON.stringify(d).length+f+l.length+3)>t){H(t,"truncated",e);break}f=1,c.target[l]=d}}return r(),o(),s}H(t,"discarded",e)}function z(e,t,n,r,o){var i=function(e){var t=e;if(t&&"function"==typeof t.toJSON)try{return t.toJSON()}catch(e){}return e}(e);if(!i||"object"!=typeof i)return function(e){if("bigint"==typeof e)return"[BigInt] ".concat(e.toString());if("function"==typeof e)return"[Function] ".concat(e.name||"unknown");if("symbol"==typeof e)return"[Symbol] ".concat(e.description||e.toString());return e}(i);var a=function(e){try{if(e instanceof Event)return{isTrusted:e.isTrusted};var t=Object.prototype.toString.call(e).match(/\[object (.*)\]/);if(t&&t[1])return"[".concat(t[1],"]")}catch(e){}return"[Unserializable]"}(i);if("[Object]"!==a&&"[Array]"!==a)return a;var s=e;if(o.has(s))return"[Reference seen at ".concat(o.get(s),"]");var u=void 0!==n?"".concat(t,".").concat(n):t,c=Array.isArray(i)?[]:{};return o.set(s,u),r.push({source:i,target:c,path:u}),c}function H(e,n,r){t.warn("The data provided has been ".concat(n," as it is over the limit of ").concat(e," characters:"),r)}function G(e){void 0===e&&(e=D);var t,n={};return{getBytesCount:function(){return void 0===t&&(t=e(k(n))),t},get:function(){return n},add:function(e,r){n[e]=r,t=void 0},remove:function(e){delete n[e],t=void 0},set:function(e){n=e,t=void 0},getContext:function(){return M(n)},setContext:function(e){n=U("sanitize_inputs")?F(e):M(e),t=void 0},setContextProperty:function(e,r){n[e]=U("sanitize_inputs")?F(r):M(r),t=void 0},removeContextProperty:function(e){delete n[e],t=void 0},clearContext:function(){n={},t=void 0}}}var 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 V(){return(new Date).getTime()}function W(){return V()}function X(){return performance.now()}function Z(){return{relative:X(),timeStamp:W()}}function Y(){return void 0===J&&(J=performance.timing.navigationStart),J}function K(){var e=O().DatadogEventBridge;if(e)return{getAllowedWebViewHosts:function(){return JSON.parse(e.getAllowedWebViewHosts())},send:function(t,n){e.send(JSON.stringify({eventType:t,event:n}))}}}function Q(e){var t;void 0===e&&(e=null===(t=O().location)||void 0===t?void 0:t.hostname);var n=K();return!!n&&n.getAllowedWebViewHosts().some((function(t){return e===t||(n=e,r=".".concat(t),n.slice(-r.length)===r);var n,r}))}function ee(e){var t=b({},e);return["id","name","email"].forEach((function(e){e in t&&(t[e]=String(t[e]))})),t}var te,ne;function re(e,t,n,r){var o=new Date;o.setTime(o.getTime()+n);var i="expires=".concat(o.toUTCString()),a=r&&r.crossSite?"none":"strict",s=r&&r.domain?";domain=".concat(r.domain):"",u=r&&r.secure?";secure":"";document.cookie="".concat(e,"=").concat(t,";").concat(i,";path=/;samesite=").concat(a).concat(s).concat(u)}function oe(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 ie(e,t){re(e,"",0,t)}function ae(e){return se(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 se(e,t){if(function(){if(void 0!==ne)return ne;try{var e=new URL("http://test/path");return ne="http://test/path"===e.href}catch(e){ne=!1}return ne}())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 ue="datadoghq.com",ce="ap1.datadoghq.com",fe={logs:"logs",rum:"rum",sessionReplay:"session-replay"},le={logs:"logs",rum:"rum",sessionReplay:"replay"};function de(e,t,n){var r=function(e,t){var n="/api/v2/".concat(le[t]),r=e.proxy,o=e.proxyUrl;if(r){var i=ae(r);return function(e){return"".concat(i,"?ddforward=").concat(encodeURIComponent("".concat(n,"?").concat(e)))}}var a=function(e,t){var n=e.site,r=void 0===n?ue:n,o=e.internalAnalyticsSubdomain;if(o&&r===ue)return"".concat(o,".").concat(ue);var i=r.split("."),a=i.pop(),s=r!==ce?"".concat(fe[t],"."):"";return"".concat(s,"browser-intake-").concat(i.join("-"),".").concat(a)}(e,t);if(void 0===r&&o){var s=ae(o);return function(e){return"".concat(s,"?ddforward=").concat(encodeURIComponent("https://".concat(a).concat(n,"?").concat(e)))}}return function(e){return"https://".concat(a).concat(n,"?").concat(e)}}(e,t);return{build:function(o,i,a){var s=function(e,t,n,r,o,i){var a=e.clientToken,s=e.internalAnalyticsSubdomain,u=["sdk_version:".concat("4.37.0"),"api:".concat(r)].concat(n);o&&U("collect_flush_reason")&&u.push("flush_reason:".concat(o));i&&u.push("retry_count:".concat(i.count),"retry_after:".concat(i.lastFailureStatus));var c=["ddsource=browser","ddtags=".concat(encodeURIComponent(u.join(","))),"dd-api-key=".concat(a),"dd-evp-origin-version=".concat(encodeURIComponent("4.37.0")),"dd-evp-origin=browser","dd-request-id=".concat(m())];"rum"===t&&c.push("batch_time=".concat(W()));s&&c.reverse();return c.join("&")}(e,t,n,o,i,a);return r(s)},urlPrefix:r(""),endpointType:t}}var ve=/[^a-z0-9_:./-]/;function pe(e,n){var r=200-e.length-1;(n.length>r||ve.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 he(e){var t=function(e){var t=e.env,n=e.service,r=e.version,o=e.datacenter,i=[];return t&&i.push(pe("env",t)),n&&i.push(pe("service",n)),r&&i.push(pe("version",r)),o&&i.push(pe("datacenter",o)),i}(e),n=function(e,t){return{logsEndpointBuilder:de(e,"logs",t),rumEndpointBuilder:de(e,"rum",t),sessionReplayEndpointBuilder:de(e,"sessionReplay",t)}}(e,t),r=R(n).map((function(e){return e.urlPrefix})),o=function(e,t,n){if(!e.replica)return;var r=b({},e,{site:ue,clientToken:e.replica.clientToken}),o={logsEndpointBuilder:de(r,"logs",n),rumEndpointBuilder:de(r,"rum",n)};return t.push.apply(t,R(o).map((function(e){return e.urlPrefix}))),b({applicationId:e.replica.applicationId},o)}(e,r,t);return b({isIntakeUrl:function(e){return r.some((function(t){return 0===e.indexOf(t)}))},replica:o,site:e.site||ue},n)}function ge(e){var r,o,i;if(e&&e.clientToken){var a=null!==(r=e.sessionSampleRate)&&void 0!==r?r:e.sampleRate;if(void 0===a||_(a))if(void 0===e.telemetrySampleRate||_(e.telemetrySampleRate)){var s;if(void 0===e.telemetryConfigurationSampleRate||_(e.telemetryConfigurationSampleRate))return s=e.enableExperimentalFeatures,Array.isArray(s)&&(j||(j=new Set(s)),s.filter((function(e){return"string"==typeof e})).forEach((function(e){S(e,"-")&&t.warn("please use snake case for '".concat(e,"'")),j.add(e)}))),b({beforeSend:e.beforeSend&&n(e.beforeSend,"beforeSend threw an error:"),cookieOptions:ye(e),sessionSampleRate:null!=a?a: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},he(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("Session 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 ye(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===te){for(var e="dd_site_test_".concat(m()),t=window.location.hostname.split("."),n=t.pop();t.length&&!oe(e);)n="".concat(t.pop(),".").concat(n),re(e,"test",h,{domain:n});ie(e,{domain:n}),te=n}return te}()),t}var be="?";function me(e){var t=[],n=Te(e,"stack"),r=String(e);return n&&L(n,r)&&(n=n.slice(r.length)),n&&n.split("\n").forEach((function(e){var n=function(e){var t=ke.exec(e);if(!t)return;var n=t[2]&&0===t[2].indexOf("native"),r=t[2]&&0===t[2].indexOf("eval"),o=xe.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]||be,line:t[3]?+t[3]:void 0,url:n?void 0:t[2]}}(e)||function(e){var t=Se.exec(e);if(!t)return;return{args:[],column:t[3]?+t[3]:void 0,func:be,line:t[2]?+t[2]:void 0,url:t[1]}}(e)||function(e){var t=Ee.exec(e);if(!t)return;return{args:[],column:t[4]?+t[4]:void 0,func:t[1]||be,line:+t[3],url:t[2]}}(e)||function(e){var t=_e.exec(e);if(!t)return;var n=t[3]&&t[3].indexOf(" > eval")>-1,r=Re.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]||be,line:t[4]?+t[4]:void 0,url:t[3]}}(e);n&&(!n.func&&n.line&&(n.func=be),t.push(n))})),{message:Te(e,"message"),name:Te(e,"name"),stack:t}}var we="((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\\w+\\.|\\/).*?)",Ce="(?::(\\d+))",ke=new RegExp("^\\s*at (.*?) ?\\(".concat(we).concat(Ce,"?").concat(Ce,"?\\)?\\s*$"),"i"),xe=new RegExp("\\((\\S*)".concat(Ce).concat(Ce,"\\)"));var Se=new RegExp("^\\s*at ?".concat(we).concat(Ce,"?").concat(Ce,"??\\s*$"),"i");var Ee=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;var _e=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|capacitor|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i,Re=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;function Te(e,t){if("object"==typeof e&&e&&t in e){var n=e[t];return"string"==typeof n?n:void 0}}var Le="agent",Oe="console",Be="logger",Pe="network",Ae="source",Me="report";function qe(e){var t=e.stackTrace,n=e.originalError,r=e.handlingStack,o=e.startClocks,i=e.nonErrorPrefix,a=e.source,s=e.handling;if(!t||void 0===t.message&&!(n instanceof Error)){var u=U("sanitize_inputs")?F(n):n;return{startClocks:o,source:a,handling:s,originalError:u,message:"".concat(i," ").concat(k(u)),stack:"No stack, consider using an instance of Error",handlingStack:r,type:t&&t.name}}return{startClocks:o,source:a,handling:s,originalError:n,message:t.message||"Empty message",stack:je(t),handlingStack:r,type:t.name,causes:Ue(n,a)}}function je(e){var t=Ie(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 Ie(e){return"".concat(e.name||"Error",": ").concat(e.message)}function De(){var e,t=new Error;if(!t.stack)try{throw t}catch(e){}return c((function(){var n=me(t);n.stack=n.stack.slice(2),e=je(n)})),e}function Ue(e,t){for(var n=e,r=[];(null==n?void 0:n.cause)instanceof Error&&r.length<10;){var o=me(n.cause);r.push({message:n.cause.message,source:t,type:null==o?void 0:o.name,stack:o&&je(o)}),n=n.cause}return r.length?r:void 0}var Ne=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 Fe(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=new Ne((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}function ze(e,t,n,r){return He(e,[t],n,r)}function He(e,t,n,r){var o=void 0===r?{}:r,i=o.once,a=o.capture,s=o.passive,c=u(i?function(e){v(),n(e)}:n),f=s?{capture:a,passive:s}:a,d=l(e,"addEventListener");function v(){var n=l(e,"removeEventListener");t.forEach((function(t){return n.call(e,t,c,f)}))}return t.forEach((function(t){return d.call(e,t,c,f)})),{stop:v}}var Ge={intervention:"intervention",deprecation:"deprecation",cspViolation:"csp_violation"};function Je(e){var t,n=[];S(e,Ge.cspViolation)&&n.push(t=new Ne((function(){var e=u((function(e){t.notify(function(e){var t=Ge.cspViolation,n="'".concat(e.blockedURI,"' blocked by '").concat(e.effectiveDirective,"' directive");return{type:Ge.cspViolation,subtype:e.effectiveDirective,message:"".concat(t,": ").concat(n),stack:$e(e.effectiveDirective,e.originalPolicy?"".concat(n,' of the policy "').concat(B(e.originalPolicy,100,"..."),'"'):"no policy",e.sourceFile,e.lineNumber,e.columnNumber)}}(e))}));return ze(document,"securitypolicyviolation",e).stop})));var r=e.filter((function(e){return e!==Ge.cspViolation}));return r.length&&n.push(function(e){var t=new Ne((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:$e(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)),Fe.apply(void 0,n)}function $e(e,t,n,r,o){return n&&je({name:e,message:t,stack:[{func:"?",url:n,line:r,column:o}]})}function Ve(e,n,r){return void 0===e?[]:"all"===e||Array.isArray(e)&&e.every((function(e){return S(n,e)}))?"all"===e?n:(o=e,i=new Set,o.forEach((function(e){return i.add(e)})),E(i)):void t.error("".concat(r,' should be "all" or an array with allowed values "').concat(n.join('", "'),'"'));var o,i}var We=function(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},Xe={debug:"debug",error:"error",info:"info",warn:"warn"},Ze="console",Ye="http",Ke=Object.keys(Xe),Qe=function(){function e(e,t,n,r,o){void 0===n&&(n=Ye),void 0===r&&(r=Xe.debug),void 0===o&&(o={}),this.handleLogStrategy=e,this.handlerType=n,this.level=r,this.contextManager=G(),this.contextManager.set(b({},o,t?{logger:{name:t}}:void 0))}return e.prototype.log=function(e,t,n,r){var o;if(void 0===n&&(n=Xe.info),n===Xe.error&&(o={origin:Be}),null!=r){var i=qe({stackTrace:r instanceof Error?me(r):void 0,originalError:r,nonErrorPrefix:"Provided",source:Be,handling:"handled",startClocks:Z()});o={origin:Be,stack:i.stack,kind:i.type,message:i.message}}var a=U("sanitize_inputs")?F(t):M(t),s=o?q({error:o},a):a;this.handleLogStrategy({message:U("sanitize_inputs")?F(e):e,context:s,status:n},this)},e.prototype.debug=function(e,t,n){this.log(e,t,Xe.debug,n)},e.prototype.info=function(e,t,n){this.log(e,t,Xe.info,n)},e.prototype.warn=function(e,t,n){this.log(e,t,Xe.warn,n)},e.prototype.error=function(e,t,n){this.log(e,t,Xe.error,n)},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},We([s],e.prototype,"log",null),e}();function et(e,t){var n=window.__ddBrowserSdkExtensionCallback;n&&n({type:e,payload:t})}var tt={HIDDEN:"visibility_hidden",UNLOADING:"before_unload",PAGEHIDE:"page_hide",FROZEN:"page_frozen"};function nt(){return Boolean(window._DATADOG_SYNTHETICS_INJECTS_RUM||oe("datadog-synthetics-injects-rum"))}function rt(){var e=window._DATADOG_SYNTHETICS_RESULT_ID||oe("datadog-synthetics-result-id");return"string"==typeof e?e:void 0}var ot,it="log",at="configuration",st=["https://www.datadoghq-browser-agent.com","https://www.datad0g-browser-agent.com","http://localhost","<anonymous>"],ut=["ddog-gov.com"],ct={maxEventsPerPage:0,sentEventCount:0,telemetryEnabled:!1,telemetryConfigurationEnabled:!1};function ft(e,t){var n,o=new Ne;return ct.telemetryEnabled=!S(ut,t.site)&&w(t.telemetrySampleRate),ct.telemetryConfigurationEnabled=ct.telemetryEnabled&&w(t.telemetryConfigurationSampleRate),ot=function(t){if(ct.telemetryEnabled){var r=function(e,t){return q({type:"telemetry",date:W(),service:e,version:"4.37.0",source:"browser",_dd:{format_version:2},telemetry:t,experimental_features:E(N())},void 0!==n?n():{})}(e,t);o.notify(r),et("telemetry",r)}},r=lt,b(ct,{maxEventsPerPage:t.maxTelemetryEventsPerPage,sentEventCount:0}),{setContextProvider:function(e){n=e},observable:o,enabled:ct.telemetryEnabled}}function lt(e){dt(b({type:it,status:"error"},function(e){if(e instanceof Error){var t=me(e);return{error:{kind:t.name,stack:je(vt(t))},message:t.message}}return{error:{stack:"Not an instance of error"},message:"Uncaught ".concat(k(e))}}(e)))}function dt(e){ot&&ct.sentEventCount<ct.maxEventsPerPage&&(ct.sentEventCount+=1,ot(e))}function vt(e){return e.stack=e.stack.filter((function(e){return!e.url||st.some((function(t){return L(e.url,t)}))})),e}var pt=function(){function e(e,t,n,r,o,i){var a=this;this.request=e,this.batchMessagesLimit=t,this.batchBytesLimit=n,this.messageBytesLimit=r,this.flushTimeout=o,this.pageExitObservable=i,this.flushObservable=new Ne,this.pushOnlyBuffer=[],this.upsertBuffer={},this.bufferBytesCount=0,this.bufferMessagesCount=0,i.subscribe((function(e){return a.flush(e.reason,a.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,t){if(void 0===t&&(t=this.request.send),0!==this.bufferMessagesCount){var n=this.pushOnlyBuffer.concat(R(this.upsertBuffer)),r=this.bufferBytesCount;this.flushObservable.notify({bufferBytesCount:this.bufferBytesCount,bufferMessagesCount:this.bufferMessagesCount}),this.pushOnlyBuffer=[],this.upsertBuffer={},this.bufferBytesCount=0,this.bufferMessagesCount=0,t({data:n.join("\n"),bytesCount:r,flushReason:e})}},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("batch_bytes_limit"),this.push(o,i,n),this.isFull()&&this.flush("batch_bytes_limit"))},e.prototype.process=function(e){var t=k(e);return{processedMessage:t,messageBytesCount:D(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=D(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;d((function(){e.flush("batch_duration_limit"),e.flushPeriodically()}),this.flushTimeout)},e}(),ht=3145728;function gt(e,t,n,r,o){0===t.transportStatus&&0===t.queuedPayloads.size()&&t.bandwidthMonitor.canHandle(e)?bt(e,t,n,{onSuccess:function(){return mt(0,t,n,r,o)},onFailure:function(){t.queuedPayloads.enqueue(e),yt(t,n,r,o)}}):t.queuedPayloads.enqueue(e)}function yt(e,t,n,r){2===e.transportStatus&&d((function(){bt(e.queuedPayloads.first(),e,t,{onSuccess:function(){e.queuedPayloads.dequeue(),e.currentBackoffTime=1e3,mt(1,e,t,n,r)},onFailure:function(){e.currentBackoffTime=Math.min(6e4,2*e.currentBackoffTime),yt(e,t,n,r)}})}),e.currentBackoffTime)}function bt(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"opaque"!==e.type&&(0===e.status&&!navigator.onLine||408===e.status||429===e.status||e.status>=500)}(n)?(t.transportStatus=0,o()):(t.transportStatus=t.bandwidthMonitor.ongoingRequestCount>0?1:2,e.retry={count:e.retry?e.retry.count+1:1,lastFailureStatus:n.status},i())}))}function mt(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:Le,startClocks:Z()}),t.queueFullReported=!0);var i=t.queuedPayloads;for(t.queuedPayloads=wt();i.size()>0;)gt(i.dequeue(),t,n,r,o)}function wt(){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>=ht}}}function Ct(e,t,n){var r={transportStatus:0,currentBackoffTime:1e3,bandwidthMonitor:{ongoingRequestCount:0,ongoingByteCount:0,canHandle:function(e){return 0===this.ongoingRequestCount||this.ongoingByteCount+e.bytesCount<=81920&&this.ongoingRequestCount<32},add:function(e){this.ongoingRequestCount+=1,this.ongoingByteCount+=e.bytesCount},remove:function(e){this.ongoingRequestCount-=1,this.ongoingByteCount-=e.bytesCount}},queuedPayloads:wt(),queueFullReported:!1},o=function(n,r){return function(e,t,n,r){var o=n.data,i=n.bytesCount,a=n.flushReason,s=n.retry;if(function(){try{return window.Request&&"keepalive"in new Request("http://a")}catch(e){return!1}}()&&i<t){var c=e.build("fetch",a,s);fetch(c,{method:"POST",body:o,keepalive:!0,mode:"cors"}).then(u((function(e){return null==r?void 0:r({status:e.status,type:e.type})})),u((function(){xt(e.build("xhr",a,s),o,r)})))}else{xt(e.build("xhr",a,s),o,r)}}(e,t,n,r)};return{send:function(t){gt(t,r,o,e.endpointType,n)},sendOnExit:function(n){!function(e,t,n){var r=n.data,o=n.bytesCount,i=n.flushReason;if(navigator.sendBeacon&&o<t)try{var a=e.build("beacon",i);if(navigator.sendBeacon(a,r))return}catch(e){!function(e){kt||(kt=!0,lt(e))}(e)}xt(e.build("xhr",i),r)}(e,t,n)}}}var kt=!1;function xt(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 St(e,t,n,r,o){var i,a=s(t);function s(t){return new pt(Ct(t,e.batchBytesLimit,n),e.batchMessagesLimit,e.batchBytesLimit,e.messageBytesLimit,e.flushTimeout,r)}return o&&(i=s(o)),{add:function(e,t){void 0===t&&(t=!0),a.add(e),i&&t&&i.add(e)}}}var Et=1/0,_t=function(){function e(e){var t=this;this.expireDelay=e,this.entries=[],this.clearOldContextsInterval=v((function(){return t.clearOldContexts()}),6e4)}return e.prototype.add=function(e,t){var n=this,r={context:e,startTime:t,endTime:Et,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=Et);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===Et&&t.close(e)},e.prototype.findAll=function(e){return void 0===e&&(e=Et),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(){p(this.clearOldContextsInterval)},e.prototype.clearOldContexts=function(){for(var e=X()-this.expireDelay;this.entries.length>0&&this.entries[this.entries.length-1].endTime<e;)this.entries.pop()},e}();var Rt,Tt=144e5,Lt=9e5,Ot=/^([a-z]+)=([a-z0-9-]+)$/,Bt="&",Pt="_dd_s",At=[];function Mt(e,t){var n;if(void 0===t&&(t=0),Rt||(Rt=e),e===Rt)if(t>=100)It();else{var r,o=Nt();if(qt()){if(o.lock)return void jt(e,t);if(r=m(),o.lock=r,Ut(o,e.options),(o=Nt()).lock!==r)return void jt(e,t)}var i=e.process(o);if(qt()&&(o=Nt()).lock!==r)jt(e,t);else{if(i&&Dt(i,e.options),qt()&&(!i||!zt(i))){if((o=Nt()).lock!==r)return void jt(e,t);delete o.lock,Ut(o,e.options),i=o}null===(n=e.after)||void 0===n||n.call(e,i||o),It()}}else At.push(e)}function qt(){return!!window.chrome||/HeadlessChrome/.test(window.navigator.userAgent)}function jt(e,t){d((function(){Mt(e,t+1)}),10)}function It(){Rt=void 0;var e=At.shift();e&&Mt(e)}function Dt(e,t){zt(e)?Ft(t):(e.expire=String(V()+Lt),Ut(e,t))}function Ut(e,t){re(Pt,function(e){return(t=e,Object.keys(t).map((function(e){return[e,t[e]]}))).map((function(e){var t=e[0],n=e[1];return"".concat(t,"=").concat(n)})).join(Bt);var t}(e),Lt,t)}function Nt(){var e=oe(Pt),t={};return function(e){return void 0!==e&&(-1!==e.indexOf(Bt)||Ot.test(e))}(e)&&e.split(Bt).forEach((function(e){var n=Ot.exec(e);if(null!==n){var r=n[1],o=n[2];t[r]=o}})),t}function Ft(e){ie(Pt,e)}function zt(e){return T(e)}function Ht(e,t,n){var r=new Ne,o=new Ne,i=v((function(){Mt({options:e,process:function(e){return c(e)?void 0:{}},after:s})}),1e3),a=function(){var e=Nt();if(c(e))return e;return{}}();function s(e){return c(e)||(e={}),u()&&(!function(e){return a.id!==e.id||a[t]!==e[t]}(e)?a=e:(a={},o.notify())),e}function u(){return void 0!==a[t]}function c(e){return(void 0===e.created||V()-Number(e.created)<Tt)&&(void 0===e.expire||V()<Number(e.expire))}return{expandOrRenewSession:y((function(){var o;Mt({options:e,process:function(e){var r=s(e);return o=function(e){var r=n(e[t]),o=r.trackingType,i=r.isTracked;e[t]=o,i&&!e.id&&(e.id=m(),e.created=String(V()));return i}(r),r},after:function(e){o&&!u()&&function(e){a=e,r.notify()}(e),a=e}})}),1e3).throttled,expandSession:function(){Mt({options:e,process:function(e){return u()?s(e):void 0}})},getSession:function(){return a},renewObservable:r,expireObservable:o,expire:function(){Ft(e),s({})},stop:function(){p(i)}}}var Gt=[];function Jt(e,t,n){!function(e){var t=oe(Pt),n=oe("_dd"),r=oe("_dd_r"),o=oe("_dd_l");if(!t){var i={};n&&(i.id=n),o&&/^[01]$/.test(o)&&(i.logs=o),r&&/^[012]$/.test(r)&&(i.rum=r),Dt(i,e)}}(e);var r=Ht(e,t,n);Gt.push((function(){return r.stop()}));var o,i=new _t(144e5);function a(){return{id:r.getSession().id,trackingType:r.getSession()[t]}}return Gt.push((function(){return i.stop()})),r.renewObservable.subscribe((function(){i.add(a(),X())})),r.expireObservable.subscribe((function(){i.closeActive(X())})),r.expandOrRenewSession(),i.add(a(),[0,Y()][0]),o=He(window,["click","touchstart","keydown","scroll"],(function(){return r.expandOrRenewSession()}),{capture:!0,passive:!0}).stop,Gt.push(o),function(e){var t=function(){"visible"===document.visibilityState&&e()},n=ze(document,"visibilitychange",t).stop;Gt.push(n);var r=v(t,6e4);Gt.push((function(){p(r)}))}((function(){return r.expandSession()})),{findActiveSession:function(e){return i.find(e)},renewObservable:r.renewObservable,expireObservable:r.expireObservable,expire:r.expire}}var $t;function Vt(e){var t=Jt(e.cookieOptions,"logs",(function(t){return function(e,t){var n=function(e){return"0"===e||"1"===e}(t)?t:Wt(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 Wt(e){return w(e.sessionSampleRate)?"1":"0"}var Xt=(($t={})[Xe.debug]=0,$t[Xe.info]=1,$t[Xe.warn]=2,$t[Xe.error]=3,$t);function Zt(e,t,n){var r=n.getHandler(),o=Array.isArray(r)?r:[r];return Xt[e]>=Xt[n.getLevel()]&&S(o,t)}function Yt(e,t,n,r,o,i){var a=Ke.concat(["custom"]),s={};a.forEach((function(e){var n,r,o,a,u;s[e]=(n=e,r=t.eventRateLimiterThreshold,o=i,a=0,u=!1,{isLimitReached:function(){if(0===a&&d((function(){a=0}),g),(a+=1)<=r||u)return u=!1,!1;if(a===r+1){u=!0;try{o({message:"Reached max number of ".concat(n,"s by minute: ").concat(r),source:Le,startClocks:Z()})}finally{u=!1}}return!0}})})),n.subscribe(0,(function(i){var a,u,c,f=i.rawLogsEvent,l=i.messageContext,d=void 0===l?void 0:l,v=i.savedCommonContext,p=void 0===v?void 0:v,h=i.logger,g=void 0===h?o:h,y=f.date-Y(),b=e.findTrackedSession(y);if(b){var m=p||r(),w=q({service:t.service,session_id:b.id,usr:T(m.user)?void 0:m.user,view:m.view},m.context,Qt(y),f,g.getContext(),d);!Zt(f.status,Ye,g)||!1===(null===(a=t.beforeSend)||void 0===a?void 0:a.call(t,w))||(null===(u=w.error)||void 0===u?void 0:u.origin)!==Le&&(null!==(c=s[w.status])&&void 0!==c?c:s.custom).isLimitReached()||n.notify(1,w)}}))}var Kt=!1;function Qt(t){var n,r=window;if(nt()){var o=i(r.DD_RUM_SYNTHETICS);return o||Kt||(Kt=!0,function(t,n){f(e.debug,t,n),dt(b({type:it,message:t,status:"debug"},n))}("Logs sent before RUM is injected by the synthetics worker",{testId:(n=window._DATADOG_SYNTHETICS_PUBLIC_ID||oe("datadog-synthetics-public-id"),"string"==typeof n?n:void 0),resultId:rt()})),o}return i(r.DD_RUM);function i(e){if(e&&e.getInternalContext)return e.getInternalContext(t)}}var en,tn={};function nn(e){var t=e.map((function(e){return tn[e]||(tn[e]=function(e){var t=new Ne((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=De();c((function(){t.notify(rn(r,e,i))}))},function(){console[e]=n}}));return t}(e)),tn[e]}));return Fe.apply(void 0,t)}function rn(t,n,r){var o,i=t.map((function(e){return function(e){if("string"==typeof e)return U("sanitize_inputs")?F(e):e;if(e instanceof Error)return Ie(me(e));return k(U("sanitize_inputs")?F(e):e,void 0,2)}(e)})).join(" ");if(n===e.error){var a=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=a?je(me(a)):void 0,i="console error: ".concat(i)}return{api:n,message:i,stack:o,handlingStack:r}}var on,an=((en={})[e.log]=Xe.info,en[e.debug]=Xe.debug,en[e.info]=Xe.info,en[e.warn]=Xe.warn,en[e.error]=Xe.error,en);var sn,un=((on={})[Ge.cspViolation]=Xe.error,on[Ge.intervention]=Xe.error,on[Ge.deprecation]=Xe.warn,on);function cn(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 fn(e,t,n){var r=n.before,o=n.after;return cn(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 ln,dn=new WeakMap;function vn(){var e;return sn||(e=new Ne((function(){var t=fn(XMLHttpRequest.prototype,"open",{before:pn}).stop,n=fn(XMLHttpRequest.prototype,"send",{before:function(){hn.call(this,e)}}).stop,r=fn(XMLHttpRequest.prototype,"abort",{before:gn}).stop;return function(){t(),n(),r()}})),sn=e),sn}function pn(e,t){dn.set(this,{state:"open",method:e,url:ae(String(t))})}function hn(e){var t=this,n=dn.get(this);if(n){var r=n;r.state="start",r.startTime=X(),r.startClocks=Z(),r.isAborted=!1,r.xhr=this;var o=!1,i=fn(this,"onreadystatechange",{before:function(){this.readyState===XMLHttpRequest.DONE&&a()}}).stop,a=u((function(){if(t.removeEventListener("loadend",a),i(),!o){o=!0;var s,u=n;u.state="complete",u.duration=(s=r.startClocks.timeStamp,W()-s),u.status=t.status,e.notify(b({},u))}}));this.addEventListener("loadend",a),e.notify(r)}}function gn(){var e=dn.get(this);e&&(e.isAborted=!0)}function yn(){var e;return ln||(e=new Ne((function(){if(window.fetch)return cn(window,"fetch",(function(t){return function(n,r){var o,i=c(bn,null,[e,n,r]);return i?(o=t.call(this,i.input,i.init),c(mn,null,[e,o,i])):o=t.call(this,n,r),o}})).stop})),ln=e),ln}function bn(e,t,n){var r=n&&n.method||t instanceof Request&&t.method||"GET",o=t instanceof Request?t.url:ae(String(t)),i={state:"start",init:n,input:t,method:r,startClocks:Z(),url:o};return e.notify(i),i}function mn(e,t,n){var r=function(t){var r=n;r.state="resolve","stack"in t||t instanceof Error?(r.status=0,r.isAborted=t instanceof DOMException&&t.code===DOMException.ABORT_ERR,r.error=t):"status"in t&&(r.response=t,r.responseType=t.type,r.status=t.status,r.isAborted=!1),e.notify(r)};t.then(u(r),u(r))}function wn(e,t){if(!e.forwardErrorsToLogs)return{stop:C};var n=vn().subscribe((function(e){"complete"===e.state&&o("xhr",e)})),r=yn().subscribe((function(e){"resolve"===e.state&&o("fetch",e)}));function o(n,r){function o(e){t.notify(0,{rawLogsEvent:{message:"".concat(kn(n)," error ").concat(r.method," ").concat(r.url),date:r.startClocks.timeStamp,error:{origin:Pe,stack:e||"Failed to load"},http:{method:r.method,status_code:r.status,url:r.url},status:Xe.error,origin:Pe}})}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){var r=function(e){try{return e.clone()}catch(e){return}}(e);r&&r.body?window.TextDecoder?function(e,t,n){!function(e,t,n){var r=e.getReader(),o=[],i=0;function a(){var e,a;if(r.cancel().catch(C),n.collectStreamBody){var s;if(1===o.length)s=o[0];else{s=new Uint8Array(i);var u=0;o.forEach((function(e){s.set(e,u),u+=e.length}))}e=s.slice(0,n.bytesLimit),a=s.length>n.bytesLimit}t(void 0,e,a)}!function e(){r.read().then(u((function(t){t.done?a():(n.collectStreamBody&&o.push(t.value),(i+=t.value.length)>n.bytesLimit?a():e())})),u((function(e){return t(e)})))}()}(e,(function(e,t,r){if(e)n(e);else{var o=(new TextDecoder).decode(t);r&&(o+="..."),n(void 0,o)}}),{bytesLimit:t,collectStreamBody:!0})}(r.body,t.requestErrorResponseLengthLimit,(function(e,t){n(e?"Unable to retrieve response: ".concat(e):t)})):r.text().then(u((function(e){return n(Cn(e,t))})),u((function(e){return n("Unable to retrieve response: ".concat(e))}))):n()}(r.response,e,o):r.error&&function(e,t,n){n(Cn(je(me(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 kn(e){return"xhr"===e?"XHR":"Fetch"}var xn=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/;function Sn(e){var t=function(e){return fn(window,"onerror",{before:function(t,n,r,o,i){var a;if(i)a=me(i),e(a,i);else{var s,u={url:n,column:o,line:r},c=t;if("[object String]"==={}.toString.call(t)){var f=xn.exec(c);f&&(s=f[1],c=f[2])}e(a={name:s,message:"string"==typeof c?c:void 0,stack:[u]},t)}}})}(e).stop,n=function(e){return fn(window,"onunhandledrejection",{before:function(t){var n=t.reason||"Empty reason",r=me(n);e(r,n)}})}(e).stop;return{stop:function(){t(),n()}}}function En(e,t){if(!e.forwardErrorsToLogs)return{stop:C};var n,r=new Ne,o=(n=r,Sn((function(e,t){n.notify(qe({stackTrace:e,originalError:t,startClocks:Z(),nonErrorPrefix:"Uncaught",source:Ae,handling:"unhandled"}))}))).stop,i=r.subscribe((function(e){t.notify(0,{rawLogsEvent:{message:e.message,date:e.startClocks.timeStamp,error:{kind:e.type,origin:Ae,stack:e.stack},origin:Ae,status:Xe.error}})}));return{stop:function(){o(),i.unsubscribe()}}}var _n=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 Rn,Tn,Ln,On,Bn=function(n){var r,o,i=!1,s=G(),c=G(),f={},l=function(){},d=new $,v=function(e,t,n,r){void 0===n&&(n=M(g())),void 0===r&&(r=W()),d.add((function(){return v(e,t,n,r)}))},p=function(){},h=new Qe((function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return v.apply(void 0,e)}));function g(){return{view:{referrer:document.referrer,url:window.location.href},context:s.getContext(),user:c.getContext()}}return r={logger:h,init:u((function(r){var o;if(p=function(){return M(r)},Q()&&(r=function(e){return b({},e,{clientToken:"empty"})}(r)),function(e){return!i||(e.silentMultipleInit||t.error("DD_LOGS is already initialized."),!1)}(r)){var a=function(t){var n=ge(t),r=Ve(t.forwardConsoleLogs,R(e),"Forward Console Logs"),o=Ve(t.forwardReports,R(Ge),"Forward Reports");if(n&&r&&o)return t.forwardErrorsToLogs&&!S(r,e.error)&&r.push(e.error),b({forwardErrorsToLogs:!1!==t.forwardErrorsToLogs,forwardConsoleLogs:r,forwardReports:o,requestErrorResponseLengthLimit:32768},n)}(r);a&&(o=n(r,a,g,h),v=o.handleLog,l=o.getInternalContext,d.drain(),i=!0)}})),getLoggerGlobalContext:u(s.get),getGlobalContext:u(s.getContext),setLoggerGlobalContext:u(s.set),setGlobalContext:u(s.setContext),addLoggerGlobalContext:u(s.add),setGlobalContextProperty:u(s.setContextProperty),removeLoggerGlobalContext:u(s.remove),removeGlobalContextProperty:u(s.removeContextProperty),clearGlobalContext:u(s.clearContext),createLogger:u((function(e,t){return void 0===t&&(t={}),f[e]=new Qe((function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return v.apply(void 0,e)}),U("sanitize_inputs")?F(e):e,t.handler,t.level,U("sanitize_inputs")?F(t.context):t.context),f[e]})),getLogger:u((function(e){return f[e]})),getInitConfiguration:u((function(){return p()})),getInternalContext:u((function(e){return l(e)})),setUser:u((function(e){(function(e){var n="object"===P(e);return n||t.error("Unsupported user:",e),n})(e)&&c.setContext(ee(e))})),getUser:u(c.getContext),setUserProperty:u((function(e,t){var n,r=ee((n={},n[e]=t,n))[e];c.setContextProperty(e,r)})),removeUserProperty:u(c.removeContextProperty),clearUser:u(c.clearContext)},o=b({version:"4.37.0",onReady:function(e){e()}},r),Object.defineProperty(o,"_setDebug",{get:function(){return a},enumerable:!1}),o}((function(n,r,o,i){var a=new _n;a.subscribe(1,(function(e){return et("logs",e)}));var s,u=function(e){return a.notify(0,{rawLogsEvent:{message:e.message,date:e.startClocks.timeStamp,error:{origin:Le},origin:Le,status:Xe.error}})},c=s=new Ne((function(){var e=U("pagehide"),t=He(window,["visibilitychange","freeze","pagehide"],(function(t){"pagehide"===t.type&&e?s.notify({reason:tt.PAGEHIDE}):"visibilitychange"===t.type&&"hidden"===document.visibilityState?s.notify({reason:tt.HIDDEN}):"freeze"===t.type&&s.notify({reason:tt.FROZEN})}),{capture:!0}).stop,n=C;return e||(n=ze(window,"beforeunload",(function(){s.notify({reason:tt.UNLOADING})})).stop),function(){t(),n()}})),f=function(e,t,n){var r,o=ft("browser-logs-sdk",e);if(Q()){var i=K();o.observable.subscribe((function(e){return i.send("internal_telemetry",e)}))}else{var a=St(e,e.rumEndpointBuilder,t,n,null===(r=e.replica)||void 0===r?void 0:r.rumEndpointBuilder);o.observable.subscribe((function(t){return a.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=Qt())||void 0===e?void 0:e.application_id},session:{id:null===(t=v.findTrackedSession())||void 0===t?void 0:t.id},view:{id:null===(r=null===(n=Qt())||void 0===n?void 0:n.view)||void 0===r?void 0:r.id},action:{id:null===(i=null===(o=Qt())||void 0===o?void 0:o.user_action)||void 0===i?void 0:i.id}}})),wn(r,a),En(r,a),function(t,n){var r=nn(t.forwardConsoleLogs).subscribe((function(t){n.notify(0,{rawLogsEvent:{date:W(),message:t.message,origin:Oe,error:t.api===e.error?{origin:Oe,stack:t.stack}:void 0,status:an[t.api]}})}))}(r,a),function(e,t){var n=Je(e.forwardReports).subscribe((function(e){var n,r=e.message,o=un[e.type];o===Xe.error?n={kind:e.subtype,origin:Me,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:W(),message:r,origin:Me,error:n,status:o}})}))}(r,a);var l,d=function(e){return{handleLog:function(n,r,o,i){var a=n.context;Zt(n.status,Ze,r)&&t(n.status,n.message,q(r.getContext(),a)),e.notify(0,{rawLogsEvent:{date:i||W(),message:n.message,status:n.status,origin:Be},messageContext:a,savedCommonContext:o,logger:r})}}}(a).handleLog,v=!function(e){if(void 0===document.cookie||null===document.cookie)return!1;try{var n="dd_cookie_test_".concat(m()),r="test";re(n,r,g,e);var o=oe(n)===r;return ie(n,e),o}catch(e){return t.error(e),!1}}(r.cookieOptions)||Q()||nt()?function(e){var t="1"===Wt(e)?{}:void 0;return{findTrackedSession:function(){return t}}}(r):Vt(r);return Yt(v,r,a,o,i,u),Q()?function(e){var t=K();e.subscribe(1,(function(e){t.send("log",e)}))}(a):function(e,t,n,r){var o,i=St(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){ct.telemetryConfigurationEnabled&&dt({type:at,configuration:e})}(function(e){var t=function(e){var t,n,r=null!==(t=e.proxy)&&void 0!==t?t:e.proxyUrl;return{session_sample_rate:null!==(n=e.sessionSampleRate)&&void 0!==n?n: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!==r?!!r:void 0,silent_multiple_init:e.silentMultipleInit,track_session_across_subdomains:e.trackSessionAcrossSubdomains,track_resources:e.trackResources,track_long_task:e.trackLongTasks}}(e);return b({forward_errors_to_logs:e.forwardErrorsToLogs,forward_console_logs:e.forwardConsoleLogs,forward_reports:e.forwardReports},t)}(n)),{handleLog:d,getInternalContext:(l=v,{get:function(e){var t=l.findTrackedSession(e);if(t)return{session_id:t.id}}}).get}}));Rn=O(),Ln=Bn,On=Rn[Tn="DD_LOGS"],Rn[Tn]=Ln,On&&On.q&&On.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 a(e){i=e}function s(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))}function l(){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 d(e,t){var n,r=l();return r.Zone&&"function"==typeof r.Zone.__symbol__&&(n=e[r.Zone.__symbol__(t)]),n||(n=e[t]),n}function v(e,t){return d(l(),"setTimeout")(u(e),t)}function p(e,t){return d(window,"setInterval")(u(e),t)}function h(e){d(window,"clearInterval")(e)}var g=1e3,y=6e4;function b(e,t,n){var r,o,i=!n||void 0===n.leading||n.leading,a=!n||void 0===n.trailing||n.trailing,s=!1;return{throttled:function(){for(var n=[],u=0;u<arguments.length;u++)n[u]=arguments[u];s?r=n:(i?e.apply(void 0,n):r=n,s=!0,o=v((function(){a&&r&&e.apply(void 0,r),s=!1,r=void 0}),t))},cancel:function(){var e;e=o,d(l(),"clearTimeout")(e),s=!1,r=void 0}}}function m(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 w(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,w)}function S(e){return 0!==e&&100*Math.random()<=e}function C(){}function E(e,t,n){if("object"!=typeof e||null===e)return JSON.stringify(e);var r=x(Object.prototype),o=x(Array.prototype),i=x(Object.getPrototypeOf(e)),a=x(e);try{return JSON.stringify(e,t,n)}catch(e){return"<error: unable to serialize object>"}finally{r(),o(),i(),a()}}function x(e){var t=e,n=t.toJSON;return n?(delete t.toJSON,function(){t.toJSON=n}):C}function k(e,t){return-1!==e.indexOf(t)}function _(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 T(e){return function(e){return"number"==typeof e}(e)&&e>=0&&e<=100}function R(e){return Object.keys(e).map((function(t){return e[t]}))}function O(e){return 0===Object.keys(e).length}function L(e,t){return e.slice(0,t.length)===t}function I(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 A(e){return null===e?"null":Array.isArray(e)?"array":typeof e}function B(e,t,n){if(void 0===n&&(n=function(){if("undefined"!=typeof WeakSet){var e=new WeakSet;return{hasAlreadyBeenSeen:function(t){var n=e.has(t);return n||e.add(t),n}}}var t=[];return{hasAlreadyBeenSeen:function(e){var n=t.indexOf(e)>=0;return n||t.push(e),n}}}()),void 0===t)return e;if("object"!=typeof t||null===t)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){var r=t.flags||[t.global?"g":"",t.ignoreCase?"i":"",t.multiline?"m":"",t.sticky?"y":"",t.unicode?"u":""].join("");return new RegExp(t.source,r)}if(!n.hasAlreadyBeenSeen(t)){if(Array.isArray(t)){for(var o=Array.isArray(e)?e:[],i=0;i<t.length;++i)o[i]=B(o[i],t[i],n);return o}var a="object"===A(e)?e:{};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(a[s]=B(a[s],t[s],n));return a}}function P(e){return B(void 0,e)}function U(){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}var N,M=/[^\u0000-\u007F]/;function q(e){return M.test(e)?void 0!==window.TextEncoder?(new TextEncoder).encode(e).length:new Blob([e]).size:e.length}!function(e){e.PAGEHIDE="pagehide",e.SHADOW_DOM_DEBUG="shadow_dom_debug",e.FEATURE_FLAGS="feature_flags",e.RESOURCE_DURATIONS="resource_durations",e.RESOURCE_PAGE_STATES="resource_page_states",e.CLICKMAP="clickmap",e.COLLECT_FLUSH_REASON="collect_flush_reason",e.SANITIZE_INPUTS="sanitize_inputs"}(N||(N={}));var D=new Set;function j(e){return D.has(e)}function F(){return D}function H(e,t){var n;void 0===t&&(t=225280);var r=x(Object.prototype),o=x(Array.prototype),i=[],a=new WeakMap,s=G(e,"$",void 0,i,a),u=(null===(n=JSON.stringify(s))||void 0===n?void 0:n.length)||0;if(!(u>t)){for(;i.length>0&&u<t;){var c=i.shift(),f=0;if(Array.isArray(c.source))for(var l=0;l<c.source.length;l++){if(u+=void 0!==(d=G(c.source[l],c.path,l,i,a))?JSON.stringify(d).length:4,u+=f,f=1,u>t){z(t,"truncated",e);break}c.target[l]=d}else for(var l in c.source)if(Object.prototype.hasOwnProperty.call(c.source,l)){var d;if(void 0!==(d=G(c.source[l],c.path,l,i,a))&&(u+=JSON.stringify(d).length+f+l.length+3,f=1),u>t){z(t,"truncated",e);break}c.target[l]=d}}return r(),o(),s}z(t,"discarded",e)}function G(e,t,n,r,o){var i=function(e){var t=e;if(t&&"function"==typeof t.toJSON)try{return t.toJSON()}catch(e){}return e}(e);if(!i||"object"!=typeof i)return function(e){if("bigint"==typeof e)return"[BigInt] ".concat(e.toString());if("function"==typeof e)return"[Function] ".concat(e.name||"unknown");if("symbol"==typeof e)return"[Symbol] ".concat(e.description||e.toString());return e}(i);var a=function(e){try{if(e instanceof Event)return{isTrusted:e.isTrusted};var t=Object.prototype.toString.call(e).match(/\[object (.*)\]/);if(t&&t[1])return"[".concat(t[1],"]")}catch(e){}return"[Unserializable]"}(i);if("[Object]"!==a&&"[Array]"!==a)return a;var s=e;if(o.has(s))return"[Reference seen at ".concat(o.get(s),"]");var u=void 0!==n?"".concat(t,".").concat(n):t,c=Array.isArray(i)?[]:{};return o.set(s,u),r.push({source:i,target:c,path:u}),c}function z(e,n,r){t.warn("The data provided has been ".concat(n," as it is over the limit of ").concat(e," characters:"),r)}function Z(e,n){void 0===n&&(n=q);var r,o={},i=!1,a=b((function(o){r=n(E(o)),i||(i=function(e,n){return e>3072&&(t.warn("The ".concat(n," data is over ").concat(3,"KiB. On low connectivity, the SDK has the potential to exhaust the user's upload bandwidth.")),!0)}(r,e))}),200).throttled;return{getBytesCount:function(){return r},get:function(){return o},add:function(e,t){o[e]=t,a(o)},remove:function(e){delete o[e],a(o)},set:function(e){a(o=e)},getContext:function(){return P(o)},setContext:function(e){o=j(N.SANITIZE_INPUTS)?H(e):P(e),a(o)},setContextProperty:function(e,t){o[e]=j(N.SANITIZE_INPUTS)?H(t):P(t),a(o)},removeContextProperty:function(e){delete o[e],a(o)},clearContext:function(){o={},r=0}}}var J,W=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 $(){return(new Date).getTime()}function V(){return $()}function X(){return performance.now()}function K(){return{relative:X(),timeStamp:V()}}function Y(){return void 0===J&&(J=performance.timing.navigationStart),J}function Q(){var e=l().DatadogEventBridge;if(e)return{getAllowedWebViewHosts:function(){return JSON.parse(e.getAllowedWebViewHosts())},send:function(t,n){e.send(JSON.stringify({eventType:t,event:n}))}}}function ee(e){var t;void 0===e&&(e=null===(t=l().location)||void 0===t?void 0:t.hostname);var n=Q();return!!n&&n.getAllowedWebViewHosts().some((function(t){return e===t||(n=e,r=".".concat(t),n.slice(-r.length)===r);var n,r}))}function te(e){var t=m({},e);return["id","name","email"].forEach((function(e){e in t&&(t[e]=String(t[e]))})),t}var ne,re;function oe(e,t,n,r){var o=new Date;o.setTime(o.getTime()+n);var i="expires=".concat(o.toUTCString()),a=r&&r.crossSite?"none":"strict",s=r&&r.domain?";domain=".concat(r.domain):"",u=r&&r.secure?";secure":"";document.cookie="".concat(e,"=").concat(t,";").concat(i,";path=/;samesite=").concat(a).concat(s).concat(u)}function ie(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 ae(e,t){oe(e,"",0,t)}function se(e){return ue(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 ue(e,t){if(function(){if(void 0!==re)return re;try{var e=new URL("http://test/path");return re="http://test/path"===e.href}catch(e){re=!1}return re}())try{return void 0!==t?new URL(e,t):new URL(e)}catch(n){throw new Error("Failed to construct URL. ".concat(E({url:e,base:t})))}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 ce="datadoghq.com",fe="ap1.datadoghq.com",le={logs:"logs",rum:"rum",sessionReplay:"session-replay"},de={logs:"logs",rum:"rum",sessionReplay:"replay"};function ve(e,t,n){var r=function(e,t){var n="/api/v2/".concat(de[t]),r=e.proxy,o=e.proxyUrl;if(r){var i=se(r);return function(e){return"".concat(i,"?ddforward=").concat(encodeURIComponent("".concat(n,"?").concat(e)))}}var a=function(e,t){var n=e.site,r=void 0===n?ce:n,o=e.internalAnalyticsSubdomain;if(o&&r===ce)return"".concat(o,".").concat(ce);var i=r.split("."),a=i.pop(),s=r!==fe?"".concat(le[t],"."):"";return"".concat(s,"browser-intake-").concat(i.join("-"),".").concat(a)}(e,t);if(void 0===r&&o){var s=se(o);return function(e){return"".concat(s,"?ddforward=").concat(encodeURIComponent("https://".concat(a).concat(n,"?").concat(e)))}}return function(e){return"https://".concat(a).concat(n,"?").concat(e)}}(e,t);return{build:function(o,i,a){var s=function(e,t,n,r,o,i){var a=e.clientToken,s=e.internalAnalyticsSubdomain,u=["sdk_version:".concat("4.38.0"),"api:".concat(r)].concat(n);o&&j(N.COLLECT_FLUSH_REASON)&&u.push("flush_reason:".concat(o));i&&u.push("retry_count:".concat(i.count),"retry_after:".concat(i.lastFailureStatus));var c=["ddsource=browser","ddtags=".concat(encodeURIComponent(u.join(","))),"dd-api-key=".concat(a),"dd-evp-origin-version=".concat(encodeURIComponent("4.38.0")),"dd-evp-origin=browser","dd-request-id=".concat(w())];"rum"===t&&c.push("batch_time=".concat(V()));s&&c.reverse();return c.join("&")}(e,t,n,o,i,a);return r(s)},urlPrefix:r(""),endpointType:t}}var pe=/[^a-z0-9_:./-]/;function he(e,n){var r=200-e.length-1;(n.length>r||pe.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 ge(e){var t=function(e){var t=e.env,n=e.service,r=e.version,o=e.datacenter,i=[];return t&&i.push(he("env",t)),n&&i.push(he("service",n)),r&&i.push(he("version",r)),o&&i.push(he("datacenter",o)),i}(e),n=function(e,t){return{logsEndpointBuilder:ve(e,"logs",t),rumEndpointBuilder:ve(e,"rum",t),sessionReplayEndpointBuilder:ve(e,"sessionReplay",t)}}(e,t),r=R(n).map((function(e){return e.urlPrefix})),o=function(e,t,n){if(!e.replica)return;var r=m({},e,{site:ce,clientToken:e.replica.clientToken}),o={logsEndpointBuilder:ve(r,"logs",n),rumEndpointBuilder:ve(r,"rum",n)};return t.push.apply(t,R(o).map((function(e){return e.urlPrefix}))),m({applicationId:e.replica.applicationId},o)}(e,r,t);return m({isIntakeUrl:function(e){return r.some((function(t){return 0===e.indexOf(t)}))},replica:o,site:e.site||ce},n)}function ye(e){var r,o,i;if(e&&e.clientToken){var a=null!==(r=e.sessionSampleRate)&&void 0!==r?r:e.sampleRate;if(void 0===a||T(a))if(void 0===e.telemetrySampleRate||T(e.telemetrySampleRate)){if(void 0===e.telemetryConfigurationSampleRate||T(e.telemetryConfigurationSampleRate))return Array.isArray(e.enableExperimentalFeatures)&&e.enableExperimentalFeatures.filter((function(e){return t=N,n=e,Object.keys(t).some((function(e){return t[e]===n}));var t,n})).forEach((function(e){D.add(e)})),m({beforeSend:e.beforeSend&&n(e.beforeSend,"beforeSend threw an error:"),cookieOptions:be(e),sessionSampleRate:null!=a?a: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},ge(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("Session 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 be(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===ne){for(var e="dd_site_test_".concat(w()),t=window.location.hostname.split("."),n=t.pop();t.length&&!ie(e);)n="".concat(t.pop(),".").concat(n),oe(e,"test",g,{domain:n});ae(e,{domain:n}),ne=n}return ne}()),t}var me="?";function we(e){var t=[],n=Oe(e,"stack"),r=String(e);return n&&L(n,r)&&(n=n.slice(r.length)),n&&n.split("\n").forEach((function(e){var n=function(e){var t=Ee.exec(e);if(!t)return;var n=t[2]&&0===t[2].indexOf("native"),r=t[2]&&0===t[2].indexOf("eval"),o=xe.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]||me,line:t[3]?+t[3]:void 0,url:n?void 0:t[2]}}(e)||function(e){var t=ke.exec(e);if(!t)return;return{args:[],column:t[3]?+t[3]:void 0,func:me,line:t[2]?+t[2]:void 0,url:t[1]}}(e)||function(e){var t=_e.exec(e);if(!t)return;return{args:[],column:t[4]?+t[4]:void 0,func:t[1]||me,line:+t[3],url:t[2]}}(e)||function(e){var t=Te.exec(e);if(!t)return;var n=t[3]&&t[3].indexOf(" > eval")>-1,r=Re.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]||me,line:t[4]?+t[4]:void 0,url:t[3]}}(e);n&&(!n.func&&n.line&&(n.func=me),t.push(n))})),{message:Oe(e,"message"),name:Oe(e,"name"),stack:t}}var Se="((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\\w+\\.|\\/).*?)",Ce="(?::(\\d+))",Ee=new RegExp("^\\s*at (.*?) ?\\(".concat(Se).concat(Ce,"?").concat(Ce,"?\\)?\\s*$"),"i"),xe=new RegExp("\\((\\S*)".concat(Ce).concat(Ce,"\\)"));var ke=new RegExp("^\\s*at ?".concat(Se).concat(Ce,"?").concat(Ce,"??\\s*$"),"i");var _e=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;var Te=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|capacitor|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i,Re=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;function Oe(e,t){if("object"==typeof e&&e&&t in e){var n=e[t];return"string"==typeof n?n:void 0}}var Le="agent",Ie="console",Ae="logger",Be="network",Pe="source",Ue="report";function Ne(e){var t=e.stackTrace,n=e.originalError,r=e.handlingStack,o=e.startClocks,i=e.nonErrorPrefix,a=e.source,s=e.handling;if(!t||void 0===t.message&&!(n instanceof Error)){var u=j(N.SANITIZE_INPUTS)?H(n):n;return{startClocks:o,source:a,handling:s,originalError:u,message:"".concat(i," ").concat(E(u)),stack:"No stack, consider using an instance of Error",handlingStack:r,type:t&&t.name}}return{startClocks:o,source:a,handling:s,originalError:n,message:t.message||"Empty message",stack:Me(t),handlingStack:r,type:t.name,causes:je(n,a)}}function Me(e){var t=qe(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 qe(e){return"".concat(e.name||"Error",": ").concat(e.message)}function De(){var e,t=new Error;if(!t.stack)try{throw t}catch(e){}return c((function(){var n=we(t);n.stack=n.stack.slice(2),e=Me(n)})),e}function je(e,t){for(var n=e,r=[];(null==n?void 0:n.cause)instanceof Error&&r.length<10;){var o=we(n.cause);r.push({message:n.cause.message,source:t,type:null==o?void 0:o.name,stack:o&&Me(o)}),n=n.cause}return r.length?r:void 0}var Fe=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 He(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=new Fe((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}function Ge(e,t,n,r){return ze(e,[t],n,r)}function ze(e,t,n,r){var o=void 0===r?{}:r,i=o.once,a=o.capture,s=o.passive,c=u(i?function(e){v(),n(e)}:n),f=s?{capture:a,passive:s}:a,l=d(e,"addEventListener");function v(){var n=d(e,"removeEventListener");t.forEach((function(t){return n.call(e,t,c,f)}))}return t.forEach((function(t){return l.call(e,t,c,f)})),{stop:v}}var Ze={intervention:"intervention",deprecation:"deprecation",cspViolation:"csp_violation"};function Je(e){var t,n=[];k(e,Ze.cspViolation)&&n.push(t=new Fe((function(){var e=u((function(e){t.notify(function(e){var t=Ze.cspViolation,n="'".concat(e.blockedURI,"' blocked by '").concat(e.effectiveDirective,"' directive");return{type:Ze.cspViolation,subtype:e.effectiveDirective,message:"".concat(t,": ").concat(n),stack:We(e.effectiveDirective,e.originalPolicy?"".concat(n,' of the policy "').concat(I(e.originalPolicy,100,"..."),'"'):"no policy",e.sourceFile,e.lineNumber,e.columnNumber)}}(e))}));return Ge(document,"securitypolicyviolation",e).stop})));var r=e.filter((function(e){return e!==Ze.cspViolation}));return r.length&&n.push(function(e){var t=new Fe((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:We(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)),He.apply(void 0,n)}function We(e,t,n,r,o){return n&&Me({name:e,message:t,stack:[{func:"?",url:n,line:r,column:o}]})}function $e(e,n,r){return void 0===e?[]:"all"===e||Array.isArray(e)&&e.every((function(e){return k(n,e)}))?"all"===e?n:(o=e,i=new Set,o.forEach((function(e){return i.add(e)})),_(i)):void t.error("".concat(r,' should be "all" or an array with allowed values "').concat(n.join('", "'),'"'));var o,i}var Ve=function(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},Xe={debug:"debug",error:"error",info:"info",warn:"warn"},Ke="console",Ye="http",Qe=Object.keys(Xe),et=function(){function e(e,t,n,r,o){void 0===n&&(n=Ye),void 0===r&&(r=Xe.debug),void 0===o&&(o={}),this.handleLogStrategy=e,this.handlerType=n,this.level=r,this.contextManager=Z("logger context"),this.contextManager.set(m({},o,t?{logger:{name:t}}:void 0))}return e.prototype.log=function(e,t,n,r){var o;if(void 0===n&&(n=Xe.info),n===Xe.error&&(o={origin:Ae}),null!=r){var i=Ne({stackTrace:r instanceof Error?we(r):void 0,originalError:r,nonErrorPrefix:"Provided",source:Ae,handling:"handled",startClocks:K()});o={origin:Ae,stack:i.stack,kind:i.type,message:i.message}}var a=j(N.SANITIZE_INPUTS)?H(t):P(t),s=o?U({error:o},a):a;this.handleLogStrategy({message:j(N.SANITIZE_INPUTS)?H(e):e,context:s,status:n},this)},e.prototype.debug=function(e,t,n){this.log(e,t,Xe.debug,n)},e.prototype.info=function(e,t,n){this.log(e,t,Xe.info,n)},e.prototype.warn=function(e,t,n){this.log(e,t,Xe.warn,n)},e.prototype.error=function(e,t,n){this.log(e,t,Xe.error,n)},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},Ve([s],e.prototype,"log",null),e}();function tt(e,t){var n=window.__ddBrowserSdkExtensionCallback;n&&n({type:e,payload:t})}var nt={HIDDEN:"visibility_hidden",UNLOADING:"before_unload",PAGEHIDE:"page_hide",FROZEN:"page_frozen"};function rt(){return Boolean(window._DATADOG_SYNTHETICS_INJECTS_RUM||ie("datadog-synthetics-injects-rum"))}function ot(){var e=window._DATADOG_SYNTHETICS_RESULT_ID||ie("datadog-synthetics-result-id");return"string"==typeof e?e:void 0}var it,at="log",st="configuration",ut=["https://www.datadoghq-browser-agent.com","https://www.datad0g-browser-agent.com","http://localhost","<anonymous>"],ct=["ddog-gov.com"],ft={maxEventsPerPage:0,sentEventCount:0,telemetryEnabled:!1,telemetryConfigurationEnabled:!1};function lt(e,t){var n,o=new Fe;return ft.telemetryEnabled=!k(ct,t.site)&&S(t.telemetrySampleRate),ft.telemetryConfigurationEnabled=ft.telemetryEnabled&&S(t.telemetryConfigurationSampleRate),it=function(t){if(ft.telemetryEnabled){var r=function(e,t){return U({type:"telemetry",date:V(),service:e,version:"4.38.0",source:"browser",_dd:{format_version:2},telemetry:t,experimental_features:_(F())},void 0!==n?n():{})}(e,t);o.notify(r),tt("telemetry",r)}},r=dt,m(ft,{maxEventsPerPage:t.maxTelemetryEventsPerPage,sentEventCount:0}),{setContextProvider:function(e){n=e},observable:o,enabled:ft.telemetryEnabled}}function dt(e){vt(m({type:at,status:"error"},function(e){if(e instanceof Error){var t=we(e);return{error:{kind:t.name,stack:Me(pt(t))},message:t.message}}return{error:{stack:"Not an instance of error"},message:"Uncaught ".concat(E(e))}}(e)))}function vt(e){it&&ft.sentEventCount<ft.maxEventsPerPage&&(ft.sentEventCount+=1,it(e))}function pt(e){return e.stack=e.stack.filter((function(e){return!e.url||ut.some((function(t){return L(e.url,t)}))})),e}var ht=function(){function e(e,t,n,r,o,i){var a=this;this.request=e,this.batchMessagesLimit=t,this.batchBytesLimit=n,this.messageBytesLimit=r,this.flushTimeout=o,this.pageExitObservable=i,this.flushObservable=new Fe,this.pushOnlyBuffer=[],this.upsertBuffer={},this.bufferBytesCount=0,this.bufferMessagesCount=0,i.subscribe((function(e){return a.flush(e.reason,a.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,t){if(void 0===t&&(t=this.request.send),0!==this.bufferMessagesCount){var n=this.pushOnlyBuffer.concat(R(this.upsertBuffer)),r=this.bufferBytesCount;this.flushObservable.notify({bufferBytesCount:this.bufferBytesCount,bufferMessagesCount:this.bufferMessagesCount}),this.pushOnlyBuffer=[],this.upsertBuffer={},this.bufferBytesCount=0,this.bufferMessagesCount=0,t({data:n.join("\n"),bytesCount:r,flushReason:e})}},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("batch_bytes_limit"),this.push(o,i,n),this.isFull()&&this.flush("batch_bytes_limit"))},e.prototype.process=function(e){var t=E(e);return{processedMessage:t,messageBytesCount:q(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=q(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;v((function(){e.flush("batch_duration_limit"),e.flushPeriodically()}),this.flushTimeout)},e}(),gt=3145728;function yt(e,t,n,r,o){0===t.transportStatus&&0===t.queuedPayloads.size()&&t.bandwidthMonitor.canHandle(e)?mt(e,t,n,{onSuccess:function(){return wt(0,t,n,r,o)},onFailure:function(){t.queuedPayloads.enqueue(e),bt(t,n,r,o)}}):t.queuedPayloads.enqueue(e)}function bt(e,t,n,r){2===e.transportStatus&&v((function(){mt(e.queuedPayloads.first(),e,t,{onSuccess:function(){e.queuedPayloads.dequeue(),e.currentBackoffTime=1e3,wt(1,e,t,n,r)},onFailure:function(){e.currentBackoffTime=Math.min(6e4,2*e.currentBackoffTime),bt(e,t,n,r)}})}),e.currentBackoffTime)}function mt(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"opaque"!==e.type&&(0===e.status&&!navigator.onLine||408===e.status||429===e.status||e.status>=500)}(n)?(t.transportStatus=0,o()):(t.transportStatus=t.bandwidthMonitor.ongoingRequestCount>0?1:2,e.retry={count:e.retry?e.retry.count+1:1,lastFailureStatus:n.status},i())}))}function wt(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:Le,startClocks:K()}),t.queueFullReported=!0);var i=t.queuedPayloads;for(t.queuedPayloads=St();i.size()>0;)yt(i.dequeue(),t,n,r,o)}function St(){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>=gt}}}function Ct(e,t,n){var r={transportStatus:0,currentBackoffTime:1e3,bandwidthMonitor:{ongoingRequestCount:0,ongoingByteCount:0,canHandle:function(e){return 0===this.ongoingRequestCount||this.ongoingByteCount+e.bytesCount<=81920&&this.ongoingRequestCount<32},add:function(e){this.ongoingRequestCount+=1,this.ongoingByteCount+=e.bytesCount},remove:function(e){this.ongoingRequestCount-=1,this.ongoingByteCount-=e.bytesCount}},queuedPayloads:St(),queueFullReported:!1},o=function(n,r){return function(e,t,n,r){var o=n.data,i=n.bytesCount,a=n.flushReason,s=n.retry;if(function(){try{return window.Request&&"keepalive"in new Request("http://a")}catch(e){return!1}}()&&i<t){var c=e.build("fetch",a,s);fetch(c,{method:"POST",body:o,keepalive:!0,mode:"cors"}).then(u((function(e){return null==r?void 0:r({status:e.status,type:e.type})})),u((function(){xt(e.build("xhr",a,s),o,r)})))}else{xt(e.build("xhr",a,s),o,r)}}(e,t,n,r)};return{send:function(t){yt(t,r,o,e.endpointType,n)},sendOnExit:function(n){!function(e,t,n){var r=n.data,o=n.bytesCount,i=n.flushReason;if(navigator.sendBeacon&&o<t)try{var a=e.build("beacon",i);if(navigator.sendBeacon(a,r))return}catch(e){!function(e){Et||(Et=!0,dt(e))}(e)}xt(e.build("xhr",i),r)}(e,t,n)}}}var Et=!1;function xt(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 kt(e,t,n,r,o){var i,a=s(t);function s(t){return new ht(Ct(t,e.batchBytesLimit,n),e.batchMessagesLimit,e.batchBytesLimit,e.messageBytesLimit,e.flushTimeout,r)}return o&&(i=s(o)),{add:function(e,t){void 0===t&&(t=!0),a.add(e),i&&t&&i.add(e)}}}var _t=1/0,Tt=function(){function e(e){var t=this;this.expireDelay=e,this.entries=[],this.clearOldContextsInterval=p((function(){return t.clearOldContexts()}),6e4)}return e.prototype.add=function(e,t){var n=this,r={context:e,startTime:t,endTime:_t,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=_t);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===_t&&t.close(e)},e.prototype.findAll=function(e){return void 0===e&&(e=_t),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(){h(this.clearOldContextsInterval)},e.prototype.clearOldContexts=function(){for(var e=X()-this.expireDelay;this.entries.length>0&&this.entries[this.entries.length-1].endTime<e;)this.entries.pop()},e}();var Rt,Ot=144e5,Lt=9e5,It=/^([a-z]+)=([a-z0-9-]+)$/,At="&",Bt="_dd_s",Pt=[];function Ut(e,t){var n;if(void 0===t&&(t=0),Rt||(Rt=e),e===Rt)if(t>=100)qt();else{var r,o=Ft();if(Nt()){if(o.lock)return void Mt(e,t);if(r=w(),o.lock=r,jt(o,e.options),(o=Ft()).lock!==r)return void Mt(e,t)}var i=e.process(o);if(Nt()&&(o=Ft()).lock!==r)Mt(e,t);else{if(i&&Dt(i,e.options),Nt()&&(!i||!Gt(i))){if((o=Ft()).lock!==r)return void Mt(e,t);delete o.lock,jt(o,e.options),i=o}null===(n=e.after)||void 0===n||n.call(e,i||o),qt()}}else Pt.push(e)}function Nt(){return!!window.chrome||/HeadlessChrome/.test(window.navigator.userAgent)}function Mt(e,t){v((function(){Ut(e,t+1)}),10)}function qt(){Rt=void 0;var e=Pt.shift();e&&Ut(e)}function Dt(e,t){Gt(e)?Ht(t):(e.expire=String($()+Lt),jt(e,t))}function jt(e,t){oe(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(At);var t}(e),Lt,t)}function Ft(){var e=ie(Bt),t={};return function(e){return void 0!==e&&(-1!==e.indexOf(At)||It.test(e))}(e)&&e.split(At).forEach((function(e){var n=It.exec(e);if(null!==n){var r=n[1],o=n[2];t[r]=o}})),t}function Ht(e){ae(Bt,e)}function Gt(e){return O(e)}function zt(e,t,n){var r=new Fe,o=new Fe,i=p((function(){Ut({options:e,process:function(e){return c(e)?void 0:{}},after:s})}),1e3),a=function(){var e=Ft();if(c(e))return e;return{}}();function s(e){return c(e)||(e={}),u()&&(!function(e){return a.id!==e.id||a[t]!==e[t]}(e)?a=e:(a={},o.notify())),e}function u(){return void 0!==a[t]}function c(e){return(void 0===e.created||$()-Number(e.created)<Ot)&&(void 0===e.expire||$()<Number(e.expire))}return{expandOrRenewSession:b((function(){var o;Ut({options:e,process:function(e){var r=s(e);return o=function(e){var r=n(e[t]),o=r.trackingType,i=r.isTracked;e[t]=o,i&&!e.id&&(e.id=w(),e.created=String($()));return i}(r),r},after:function(e){o&&!u()&&function(e){a=e,r.notify()}(e),a=e}})}),1e3).throttled,expandSession:function(){Ut({options:e,process:function(e){return u()?s(e):void 0}})},getSession:function(){return a},renewObservable:r,expireObservable:o,expire:function(){Ht(e),s({})},stop:function(){h(i)}}}var Zt=[];function Jt(e,t,n){!function(e){var t=ie(Bt),n=ie("_dd"),r=ie("_dd_r"),o=ie("_dd_l");if(!t){var i={};n&&(i.id=n),o&&/^[01]$/.test(o)&&(i.logs=o),r&&/^[012]$/.test(r)&&(i.rum=r),Dt(i,e)}}(e);var r=zt(e,t,n);Zt.push((function(){return r.stop()}));var o,i=new Tt(144e5);function a(){return{id:r.getSession().id,trackingType:r.getSession()[t]}}return Zt.push((function(){return i.stop()})),r.renewObservable.subscribe((function(){i.add(a(),X())})),r.expireObservable.subscribe((function(){i.closeActive(X())})),r.expandOrRenewSession(),i.add(a(),[0,Y()][0]),o=ze(window,["click","touchstart","keydown","scroll"],(function(){return r.expandOrRenewSession()}),{capture:!0,passive:!0}).stop,Zt.push(o),function(e){var t=function(){"visible"===document.visibilityState&&e()},n=Ge(document,"visibilitychange",t).stop;Zt.push(n);var r=p(t,6e4);Zt.push((function(){h(r)}))}((function(){return r.expandSession()})),{findActiveSession:function(e){return i.find(e)},renewObservable:r.renewObservable,expireObservable:r.expireObservable,expire:r.expire}}var Wt;function $t(e){var t=Jt(e.cookieOptions,"logs",(function(t){return function(e,t){var n=function(e){return"0"===e||"1"===e}(t)?t:Vt(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 Vt(e){return S(e.sessionSampleRate)?"1":"0"}var Xt=((Wt={})[Xe.debug]=0,Wt[Xe.info]=1,Wt[Xe.warn]=2,Wt[Xe.error]=3,Wt);function Kt(e,t,n){var r=n.getHandler(),o=Array.isArray(r)?r:[r];return Xt[e]>=Xt[n.getLevel()]&&k(o,t)}function Yt(e,t,n,r,o,i){var a=Qe.concat(["custom"]),s={};a.forEach((function(e){var n,r,o,a,u;s[e]=(n=e,r=t.eventRateLimiterThreshold,o=i,a=0,u=!1,{isLimitReached:function(){if(0===a&&v((function(){a=0}),y),(a+=1)<=r||u)return u=!1,!1;if(a===r+1){u=!0;try{o({message:"Reached max number of ".concat(n,"s by minute: ").concat(r),source:Le,startClocks:K()})}finally{u=!1}}return!0}})})),n.subscribe(0,(function(i){var a,u,c,f=i.rawLogsEvent,l=i.messageContext,d=void 0===l?void 0:l,v=i.savedCommonContext,p=void 0===v?void 0:v,h=i.logger,g=void 0===h?o:h,y=f.date-Y(),b=e.findTrackedSession(y);if(b){var m=p||r(),w=U({service:t.service,session_id:b.id,usr:O(m.user)?void 0:m.user,view:m.view},m.context,en(y),f,g.getContext(),d);!Kt(f.status,Ye,g)||!1===(null===(a=t.beforeSend)||void 0===a?void 0:a.call(t,w))||(null===(u=w.error)||void 0===u?void 0:u.origin)!==Le&&(null!==(c=s[w.status])&&void 0!==c?c:s.custom).isLimitReached()||n.notify(1,w)}}))}var Qt=!1;function en(t){var n,r=window;if(rt()){var o=i(r.DD_RUM_SYNTHETICS);return o||Qt||(Qt=!0,function(t,n){f(e.debug,t,n),vt(m({type:at,message:t,status:"debug"},n))}("Logs sent before RUM is injected by the synthetics worker",{testId:(n=window._DATADOG_SYNTHETICS_PUBLIC_ID||ie("datadog-synthetics-public-id"),"string"==typeof n?n:void 0),resultId:ot()})),o}return i(r.DD_RUM);function i(e){if(e&&e.getInternalContext)return e.getInternalContext(t)}}var tn,nn={};function rn(e){var t=e.map((function(e){return nn[e]||(nn[e]=function(e){var t=new Fe((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=De();c((function(){t.notify(on(r,e,i))}))},function(){console[e]=n}}));return t}(e)),nn[e]}));return He.apply(void 0,t)}function on(t,n,r){var o,i=t.map((function(e){return function(e){if("string"==typeof e)return j(N.SANITIZE_INPUTS)?H(e):e;if(e instanceof Error)return qe(we(e));return E(j(N.SANITIZE_INPUTS)?H(e):e,void 0,2)}(e)})).join(" ");if(n===e.error){var a=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=a?Me(we(a)):void 0,i="console error: ".concat(i)}return{api:n,message:i,stack:o,handlingStack:r}}var an,sn=((tn={})[e.log]=Xe.info,tn[e.debug]=Xe.debug,tn[e.info]=Xe.info,tn[e.warn]=Xe.warn,tn[e.error]=Xe.error,tn);var un,cn=((an={})[Ze.cspViolation]=Xe.error,an[Ze.intervention]=Xe.error,an[Ze.deprecation]=Xe.warn,an);function fn(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 ln(e,t,n){var r=n.before,o=n.after;return fn(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 dn,vn=new WeakMap;function pn(){var e;return un||(e=new Fe((function(){var t=ln(XMLHttpRequest.prototype,"open",{before:hn}).stop,n=ln(XMLHttpRequest.prototype,"send",{before:function(){gn.call(this,e)}}).stop,r=ln(XMLHttpRequest.prototype,"abort",{before:yn}).stop;return function(){t(),n(),r()}})),un=e),un}function hn(e,t){vn.set(this,{state:"open",method:e,url:se(String(t))})}function gn(e){var t=this,n=vn.get(this);if(n){var r=n;r.state="start",r.startTime=X(),r.startClocks=K(),r.isAborted=!1,r.xhr=this;var o=!1,i=ln(this,"onreadystatechange",{before:function(){this.readyState===XMLHttpRequest.DONE&&a()}}).stop,a=u((function(){if(t.removeEventListener("loadend",a),i(),!o){o=!0;var s,u=n;u.state="complete",u.duration=(s=r.startClocks.timeStamp,V()-s),u.status=t.status,e.notify(m({},u))}}));this.addEventListener("loadend",a),e.notify(r)}}function yn(){var e=vn.get(this);e&&(e.isAborted=!0)}function bn(){var e;return dn||(e=new Fe((function(){if(window.fetch)return fn(window,"fetch",(function(t){return function(n,r){var o,i=c(mn,null,[e,n,r]);return i?(o=t.call(this,i.input,i.init),c(wn,null,[e,o,i])):o=t.call(this,n,r),o}})).stop})),dn=e),dn}function mn(e,t,n){var r=n&&n.method||t instanceof Request&&t.method||"GET",o=t instanceof Request?t.url:se(String(t)),i={state:"start",init:n,input:t,method:r,startClocks:K(),url:o};return e.notify(i),i}function wn(e,t,n){var r=function(t){var r=n;r.state="resolve","stack"in t||t instanceof Error?(r.status=0,r.isAborted=t instanceof DOMException&&t.code===DOMException.ABORT_ERR,r.error=t):"status"in t&&(r.response=t,r.responseType=t.type,r.status=t.status,r.isAborted=!1),e.notify(r)};t.then(u(r),u(r))}function Sn(e,t){if(!e.forwardErrorsToLogs)return{stop:C};var n=pn().subscribe((function(e){"complete"===e.state&&o("xhr",e)})),r=bn().subscribe((function(e){"resolve"===e.state&&o("fetch",e)}));function o(n,r){function o(e){t.notify(0,{rawLogsEvent:{message:"".concat(En(n)," error ").concat(r.method," ").concat(r.url),date:r.startClocks.timeStamp,error:{origin:Be,stack:e||"Failed to load"},http:{method:r.method,status_code:r.status,url:r.url},status:Xe.error,origin:Be}})}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){var r=function(e){try{return e.clone()}catch(e){return}}(e);r&&r.body?window.TextDecoder?function(e,t,n){!function(e,t,n){var r=e.getReader(),o=[],i=0;function a(){var e,a;if(r.cancel().catch(C),n.collectStreamBody){var s;if(1===o.length)s=o[0];else{s=new Uint8Array(i);var u=0;o.forEach((function(e){s.set(e,u),u+=e.length}))}e=s.slice(0,n.bytesLimit),a=s.length>n.bytesLimit}t(void 0,e,a)}!function e(){r.read().then(u((function(t){t.done?a():(n.collectStreamBody&&o.push(t.value),(i+=t.value.length)>n.bytesLimit?a():e())})),u((function(e){return t(e)})))}()}(e,(function(e,t,r){if(e)n(e);else{var o=(new TextDecoder).decode(t);r&&(o+="..."),n(void 0,o)}}),{bytesLimit:t,collectStreamBody:!0})}(r.body,t.requestErrorResponseLengthLimit,(function(e,t){n(e?"Unable to retrieve response: ".concat(e):t)})):r.text().then(u((function(e){return n(Cn(e,t))})),u((function(e){return n("Unable to retrieve response: ".concat(e))}))):n()}(r.response,e,o):r.error&&function(e,t,n){n(Cn(Me(we(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 En(e){return"xhr"===e?"XHR":"Fetch"}var xn=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/;function kn(e){var t=function(e){return ln(window,"onerror",{before:function(t,n,r,o,i){var a;if(i)a=we(i),e(a,i);else{var s,u={url:n,column:o,line:r},c=t;if("[object String]"==={}.toString.call(t)){var f=xn.exec(c);f&&(s=f[1],c=f[2])}e(a={name:s,message:"string"==typeof c?c:void 0,stack:[u]},t)}}})}(e).stop,n=function(e){return ln(window,"onunhandledrejection",{before:function(t){var n=t.reason||"Empty reason",r=we(n);e(r,n)}})}(e).stop;return{stop:function(){t(),n()}}}function _n(e,t){if(!e.forwardErrorsToLogs)return{stop:C};var n,r=new Fe,o=(n=r,kn((function(e,t){n.notify(Ne({stackTrace:e,originalError:t,startClocks:K(),nonErrorPrefix:"Uncaught",source:Pe,handling:"unhandled"}))}))).stop,i=r.subscribe((function(e){t.notify(0,{rawLogsEvent:{message:e.message,date:e.startClocks.timeStamp,error:{kind:e.type,origin:Pe,stack:e.stack},origin:Pe,status:Xe.error}})}));return{stop:function(){o(),i.unsubscribe()}}}var Tn=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 Rn,On,Ln,In,An=function(n){var r,o,i=!1,s=Z("global context"),c=Z("user"),f={},l=function(){},d=new W,v=function(e,t,n,r){void 0===n&&(n=P(g())),void 0===r&&(r=V()),d.add((function(){return v(e,t,n,r)}))},p=function(){},h=new et((function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return v.apply(void 0,e)}));function g(){return{view:{referrer:document.referrer,url:window.location.href},context:s.getContext(),user:c.getContext()}}return r={logger:h,init:u((function(r){var o;if(p=function(){return P(r)},ee()&&(r=function(e){return m({},e,{clientToken:"empty"})}(r)),function(e){return!i||(e.silentMultipleInit||t.error("DD_LOGS is already initialized."),!1)}(r)){var a=function(t){var n=ye(t),r=$e(t.forwardConsoleLogs,R(e),"Forward Console Logs"),o=$e(t.forwardReports,R(Ze),"Forward Reports");if(n&&r&&o)return t.forwardErrorsToLogs&&!k(r,e.error)&&r.push(e.error),m({forwardErrorsToLogs:!1!==t.forwardErrorsToLogs,forwardConsoleLogs:r,forwardReports:o,requestErrorResponseLengthLimit:32768},n)}(r);a&&(o=n(r,a,g,h),v=o.handleLog,l=o.getInternalContext,d.drain(),i=!0)}})),getLoggerGlobalContext:u(s.get),getGlobalContext:u(s.getContext),setLoggerGlobalContext:u(s.set),setGlobalContext:u(s.setContext),addLoggerGlobalContext:u(s.add),setGlobalContextProperty:u(s.setContextProperty),removeLoggerGlobalContext:u(s.remove),removeGlobalContextProperty:u(s.removeContextProperty),clearGlobalContext:u(s.clearContext),createLogger:u((function(e,t){return void 0===t&&(t={}),f[e]=new et((function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return v.apply(void 0,e)}),j(N.SANITIZE_INPUTS)?H(e):e,t.handler,t.level,j(N.SANITIZE_INPUTS)?H(t.context):t.context),f[e]})),getLogger:u((function(e){return f[e]})),getInitConfiguration:u((function(){return p()})),getInternalContext:u((function(e){return l(e)})),setUser:u((function(e){(function(e){var n="object"===A(e);return n||t.error("Unsupported user:",e),n})(e)&&c.setContext(te(e))})),getUser:u(c.getContext),setUserProperty:u((function(e,t){var n,r=te((n={},n[e]=t,n))[e];c.setContextProperty(e,r)})),removeUserProperty:u(c.removeContextProperty),clearUser:u(c.clearContext)},o=m({version:"4.38.0",onReady:function(e){e()}},r),Object.defineProperty(o,"_setDebug",{get:function(){return a},enumerable:!1}),o}((function(n,r,o,i){var a=new Tn;a.subscribe(1,(function(e){return tt("logs",e)}));var s,u=function(e){return a.notify(0,{rawLogsEvent:{message:e.message,date:e.startClocks.timeStamp,error:{origin:Le},origin:Le,status:Xe.error}})},c=s=new Fe((function(){var e=j(N.PAGEHIDE),t=ze(window,["visibilitychange","freeze","pagehide"],(function(t){"pagehide"===t.type&&e?s.notify({reason:nt.PAGEHIDE}):"visibilitychange"===t.type&&"hidden"===document.visibilityState?s.notify({reason:nt.HIDDEN}):"freeze"===t.type&&s.notify({reason:nt.FROZEN})}),{capture:!0}).stop,n=C;return e||(n=Ge(window,"beforeunload",(function(){s.notify({reason:nt.UNLOADING})})).stop),function(){t(),n()}})),f=function(e,t,n){var r,o=lt("browser-logs-sdk",e);if(ee()){var i=Q();o.observable.subscribe((function(e){return i.send("internal_telemetry",e)}))}else{var a=kt(e,e.rumEndpointBuilder,t,n,null===(r=e.replica)||void 0===r?void 0:r.rumEndpointBuilder);o.observable.subscribe((function(t){return a.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=en())||void 0===e?void 0:e.application_id},session:{id:null===(t=v.findTrackedSession())||void 0===t?void 0:t.id},view:{id:null===(r=null===(n=en())||void 0===n?void 0:n.view)||void 0===r?void 0:r.id},action:{id:null===(i=null===(o=en())||void 0===o?void 0:o.user_action)||void 0===i?void 0:i.id}}})),Sn(r,a),_n(r,a),function(t,n){var r=rn(t.forwardConsoleLogs).subscribe((function(t){n.notify(0,{rawLogsEvent:{date:V(),message:t.message,origin:Ie,error:t.api===e.error?{origin:Ie,stack:t.stack}:void 0,status:sn[t.api]}})}))}(r,a),function(e,t){var n=Je(e.forwardReports).subscribe((function(e){var n,r=e.message,o=cn[e.type];o===Xe.error?n={kind:e.subtype,origin:Ue,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:V(),message:r,origin:Ue,error:n,status:o}})}))}(r,a);var l,d=function(e){return{handleLog:function(n,r,o,i){var a=n.context;Kt(n.status,Ke,r)&&t(n.status,n.message,U(r.getContext(),a)),e.notify(0,{rawLogsEvent:{date:i||V(),message:n.message,status:n.status,origin:Ae},messageContext:a,savedCommonContext:o,logger:r})}}}(a).handleLog,v=!function(e){if(void 0===document.cookie||null===document.cookie)return!1;try{var n="dd_cookie_test_".concat(w()),r="test";oe(n,r,y,e);var o=ie(n)===r;return ae(n,e),o}catch(e){return t.error(e),!1}}(r.cookieOptions)||ee()||rt()?function(e){var t="1"===Vt(e)?{}:void 0;return{findTrackedSession:function(){return t}}}(r):$t(r);return Yt(v,r,a,o,i,u),ee()?function(e){var t=Q();e.subscribe(1,(function(e){t.send("log",e)}))}(a):function(e,t,n,r){var o,i=kt(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){ft.telemetryConfigurationEnabled&&vt({type:st,configuration:e})}(function(e){var t=function(e){var t,n,r=null!==(t=e.proxy)&&void 0!==t?t:e.proxyUrl;return{session_sample_rate:null!==(n=e.sessionSampleRate)&&void 0!==n?n: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!==r?!!r:void 0,silent_multiple_init:e.silentMultipleInit,track_session_across_subdomains:e.trackSessionAcrossSubdomains,track_resources:e.trackResources,track_long_task:e.trackLongTasks}}(e);return m({forward_errors_to_logs:e.forwardErrorsToLogs,forward_console_logs:e.forwardConsoleLogs,forward_reports:e.forwardReports},t)}(n)),{handleLog:d,getInternalContext:(l=v,{get:function(e){var t=l.findTrackedSession(e);if(t)return{session_id:t.id}}}).get}}));Rn=l(),Ln=An,In=Rn[On="DD_LOGS"],Rn[On]=Ln,In&&In.q&&In.q.forEach((function(e){return n(e,"onReady callback threw an error:")()}))}();

@@ -9,4 +9,4 @@ "use strict";

var isAlreadyInitialized = false;
var globalContextManager = (0, browser_core_1.createContextManager)();
var userContextManager = (0, browser_core_1.createContextManager)();
var globalContextManager = (0, browser_core_1.createContextManager)("global context" /* CustomerDataType.GlobalContext */);
var userContextManager = (0, browser_core_1.createContextManager)("user" /* CustomerDataType.User */);
var customLoggers = {};

@@ -80,3 +80,5 @@ var getInternalContextStrategy = function () { return undefined; };

return handleLogStrategy.apply(void 0, params);
}, (0, browser_core_1.isExperimentalFeatureEnabled)('sanitize_inputs') ? (0, browser_core_1.sanitize)(name) : name, conf.handler, conf.level, (0, browser_core_1.isExperimentalFeatureEnabled)('sanitize_inputs') ? (0, browser_core_1.sanitize)(conf.context) : conf.context);
}, (0, browser_core_1.isExperimentalFeatureEnabled)(browser_core_1.ExperimentalFeature.SANITIZE_INPUTS) ? (0, browser_core_1.sanitize)(name) : name, conf.handler, conf.level, (0, browser_core_1.isExperimentalFeatureEnabled)(browser_core_1.ExperimentalFeature.SANITIZE_INPUTS)
? (0, browser_core_1.sanitize)(conf.context)
: conf.context);
return customLoggers[name];

@@ -83,0 +85,0 @@ }),

@@ -31,3 +31,3 @@ "use strict";

this.level = level;
this.contextManager = (0, browser_core_1.createContextManager)();
this.contextManager = (0, browser_core_1.createContextManager)("logger context" /* CustomerDataType.LoggerContext */);
this.contextManager.set((0, browser_core_1.assign)({}, loggerContext, name ? { logger: { name: name } } : undefined));

@@ -59,7 +59,13 @@ }

}
var sanitizedMessageContext = ((0, browser_core_1.isExperimentalFeatureEnabled)('sanitize_inputs') ? (0, browser_core_1.sanitize)(messageContext) : (0, browser_core_1.deepClone)(messageContext));
var sanitizedMessageContext = ((0, browser_core_1.isExperimentalFeatureEnabled)(browser_core_1.ExperimentalFeature.SANITIZE_INPUTS)
? (0, browser_core_1.sanitize)(messageContext)
: (0, browser_core_1.deepClone)(messageContext));
var context = errorContext
? (0, browser_core_1.combine)({ error: errorContext }, sanitizedMessageContext)
: sanitizedMessageContext;
this.handleLogStrategy({ message: (0, browser_core_1.isExperimentalFeatureEnabled)('sanitize_inputs') ? (0, browser_core_1.sanitize)(message) : message, context: context, status: status }, this);
this.handleLogStrategy({
message: (0, browser_core_1.isExperimentalFeatureEnabled)(browser_core_1.ExperimentalFeature.SANITIZE_INPUTS) ? (0, browser_core_1.sanitize)(message) : message,
context: context,
status: status,
}, this);
};

@@ -66,0 +72,0 @@ Logger.prototype.debug = function (message, messageContext, error) {

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

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

@@ -6,4 +6,4 @@ import { Logger } from '../domain/logger';

var isAlreadyInitialized = false;
var globalContextManager = createContextManager();
var userContextManager = createContextManager();
var globalContextManager = createContextManager("global context" /* CustomerDataType.GlobalContext */);
var userContextManager = createContextManager("user" /* CustomerDataType.User */);
var customLoggers = {};

@@ -77,3 +77,5 @@ var getInternalContextStrategy = function () { return undefined; };

return handleLogStrategy.apply(void 0, params);
}, isExperimentalFeatureEnabled('sanitize_inputs') ? sanitize(name) : name, conf.handler, conf.level, isExperimentalFeatureEnabled('sanitize_inputs') ? sanitize(conf.context) : conf.context);
}, isExperimentalFeatureEnabled(ExperimentalFeature.SANITIZE_INPUTS) ? sanitize(name) : name, conf.handler, conf.level, isExperimentalFeatureEnabled(ExperimentalFeature.SANITIZE_INPUTS)
? sanitize(conf.context)
: conf.context);
return customLoggers[name];

@@ -80,0 +82,0 @@ }),

@@ -7,3 +7,3 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

};
import { isExperimentalFeatureEnabled, clocksNow, computeRawError, PROVIDED_ERROR_MESSAGE_PREFIX, computeStackTrace, deepClone, assign, combine, createContextManager, ErrorSource, monitored, sanitize, } from '@datadog/browser-core';
import { ExperimentalFeature, isExperimentalFeatureEnabled, clocksNow, computeRawError, PROVIDED_ERROR_MESSAGE_PREFIX, computeStackTrace, deepClone, assign, combine, createContextManager, ErrorSource, monitored, sanitize, } from '@datadog/browser-core';
export var StatusType = {

@@ -29,3 +29,3 @@ debug: 'debug',

this.level = level;
this.contextManager = createContextManager();
this.contextManager = createContextManager("logger context" /* CustomerDataType.LoggerContext */);
this.contextManager.set(assign({}, loggerContext, name ? { logger: { name: name } } : undefined));

@@ -57,7 +57,13 @@ }

}
var sanitizedMessageContext = (isExperimentalFeatureEnabled('sanitize_inputs') ? sanitize(messageContext) : deepClone(messageContext));
var sanitizedMessageContext = (isExperimentalFeatureEnabled(ExperimentalFeature.SANITIZE_INPUTS)
? sanitize(messageContext)
: deepClone(messageContext));
var context = errorContext
? combine({ error: errorContext }, sanitizedMessageContext)
: sanitizedMessageContext;
this.handleLogStrategy({ message: isExperimentalFeatureEnabled('sanitize_inputs') ? sanitize(message) : message, context: context, status: status }, this);
this.handleLogStrategy({
message: isExperimentalFeatureEnabled(ExperimentalFeature.SANITIZE_INPUTS) ? sanitize(message) : message,
context: context,
status: status,
}, this);
};

@@ -64,0 +70,0 @@ Logger.prototype.debug = function (message, messageContext, error) {

{
"name": "@datadog/browser-logs",
"version": "4.37.0",
"version": "4.38.0",
"license": "Apache-2.0",

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

"dependencies": {
"@datadog/browser-core": "4.37.0"
"@datadog/browser-core": "4.38.0"
},
"peerDependencies": {
"@datadog/browser-rum": "4.37.0"
"@datadog/browser-rum": "4.38.0"
},

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

},
"gitHead": "058831610a12a72ff5e650e47a6ce8cfe9e20012"
"gitHead": "61ff7fdf8c51ea1bb789cb3d865ad094bfcdcf71"
}

@@ -5,31 +5,8 @@ # Browser Log Collection

With the browser logs SDK, you can send logs directly to Datadog from web browser pages and leverage the following features:
See the [dedicated datadog documentation][1] for more details.
- Use the SDK as a logger. Everything is forwarded to Datadog as JSON documents.
- Add `context` and extra custom attributes to each log sent.
- Wrap and forward every frontend error automatically.
- Forward frontend errors.
- Record real client IP addresses and user agents.
- Optimized network usage with automatic bulk posts.
## Usage
## Setup
After adding [`@datadog/browser-logs`][2] to your `package.json` file, initialize it with:
**Datadog client token**: For security reasons, [API keys][1] cannot be used to configure the browser logs SDK, because they would be exposed client-side in the JavaScript code. To collect logs from web browsers, a [client token][2] must be used. See the [client token documentation][2] for more details.
**Datadog browser logs SDK**: Configure the SDK through [NPM](#npm) or use the [CDN async](#cdn-async) or [CDN sync](#cdn-sync) code snippets in the head tag.
**Supported browsers**: The browser logs SDK supports all modern desktop and mobile browsers including IE11. See the [browser support][4] table.
### Choose the right installation method
| Installation method | Use case |
| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| npm (node package manager) | This method is recommended for modern web applications. The browser logs SDK gets packaged with the rest of your front-end javascript code. It has no impact on page load performance. However, the SDK might miss errors, resources and user actions triggered before the SDK is initialized. **Note**: it is recommended to use a matching version with RUM SDK if used. |
| CDN async | This method is recommended for web applications with performance targets. The browser logs SDK is loaded from our CDN asynchronously: this method ensures the SDK download does not impact page load performance. However, the SDK might miss errors, resources and user actions triggered before the SDK is initialized. |
| CDN sync | This method is recommended for collecting all RUM events. The browser logs SDK is loaded from our CDN synchronously: this method ensures the SDK is loaded first and collects all errors, resources and user actions. This method might impact page load performance. |
### NPM
After adding [`@datadog/browser-logs`][3] to your `package.json` file, initialize it with:
```javascript

@@ -46,113 +23,4 @@ import { datadogLogs } from '@datadog/browser-logs'

### CDN async
After the Datadog browser logs SDK is initialized, send custom log entries directly to Datadog:
Load and configure the SDK in the head section of your pages.
<!-- prettier-ignore -->
```html
<html>
<head>
<title>Example to send logs to Datadog</title>
<script>
(function(h,o,u,n,d) {
h=h[d]=h[d]||{q:[],onReady:function(c){h.q.push(c)}}
d=o.createElement(u);d.async=1;d.src=n
n=o.getElementsByTagName(u)[0];n.parentNode.insertBefore(d,n)
})(window,document,'script','https://www.datadoghq-browser-agent.com/datadog-logs-v4.js','DD_LOGS')
DD_LOGS.onReady(function() {
DD_LOGS.init({
clientToken: 'XXX',
site: 'datadoghq.com',
forwardErrorsToLogs: true,
sessionSampleRate: 100,
})
})
</script>
</head>
</html>
```
**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
To receive all logs and errors, load and configure the SDK at the beginning of the head section for your pages.
```html
<html>
<head>
<title>Example to send logs to Datadog</title>
<script type="text/javascript" src="https://www.datadoghq-browser-agent.com/datadog-logs-v4.js"></script>
<script>
window.DD_LOGS &&
DD_LOGS.init({
clientToken: '<CLIENT_TOKEN>',
site: '<DATADOG_SITE>',
forwardErrorsToLogs: true,
sessionSampleRate: 100,
})
</script>
</head>
</html>
```
**Note**: The `window.DD_LOGS` check prevents issues when a loading failure occurs with the SDK.
### TypeScript
Types are compatible with TypeScript >= 3.8.2. For earlier versions, import JS sources and use global variables to avoid any compilation issues:
```typescript
import '@datadog/browser-logs/bundle/datadog-logs'
window.DD_LOGS.init({
clientToken: '<CLIENT_TOKEN>',
site: '<DATADOG_SITE>',
forwardErrorsToLogs: true,
sessionSampleRate: 100,
})
```
## Configuration
### Initialization parameters
The following parameters are available to configure the Datadog browser logs SDK to send logs to Datadog:
| Parameter | Type | Required | Default | Description |
| --------------------- | ------------------------------------------------------------------------- | -------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `clientToken` | String | Yes | | A [Datadog client token][2]. |
| `site` | String | Yes | `datadoghq.com` | The [Datadog site parameter of your organization][9]. |
| `service` | String | No | | The service name for your application. It should follow the [tag syntax requirements][7]. |
| `env` | String | No | | The application’s environment, for example: prod, pre-prod, staging, etc. It should follow the [tag syntax requirements][7]. |
| `version` | String | No | | The application’s version, for example: 1.2.3, 6c44da20, 2020.02.13, etc. It should follow the [tag syntax requirements][7]. |
| `forwardErrorsToLogs` | Boolean | No | `true` | Set to `false` to stop forwarding console.error logs, uncaught exceptions and network errors to Datadog. |
| `forwardConsoleLogs` | `"all"` or an Array of `"log"` `"debug"` `"info"` `"warn"` `"error"` | No | `[]` | Forward logs from `console.*` to Datadog. Use `"all"` to forward everything or an array of console API names to forward only a subset. |
| `forwardReports` | `"all"` or an Array of `"intervention"` `"deprecation"` `"csp_violation"` | No | `[]` | Forward reports from the [Reporting API][8] to Datadog. Use `"all"` to forward everything or an array of report types to forward only a subset. |
| `sampleRate` | Number | No | `100` | **Deprecated** - see `sessionSampleRate`. |
| `sessionSampleRate` | Number | No | `100` | The percentage of sessions to track: `100` for all, `0` for none. Only tracked sessions send logs. |
| `silentMultipleInit` | Boolean | No | | Prevent logging errors while having multiple init. |
| `proxyUrl` | String | No | | Optional proxy URL (ex: https://www.proxy.com/path), see the full [proxy setup guide][6] for more information. |
| `telemetrySampleRate` | Number | No | `20` | Telemetry data (error, debug logs) about SDK execution is sent to Datadog in order to detect and solve potential issues. Set this option to `0` to opt out from telemetry collection. |
Options that must have a matching configuration when using the `RUM` SDK:
| Parameter | Type | Required | Default | Description |
| ------------------------------ | ------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `trackSessionAcrossSubdomains` | Boolean | No | `false` | Preserve the session across subdomains for the same site. |
| `useSecureSessionCookie` | Boolean | No | `false` | Use a secure session cookie. This disables logs sent on insecure (non-HTTPS) connections. |
| `useCrossSiteSessionCookie` | Boolean | No | `false` | Use a secure cross-site session cookie. This allows the logs SDK to run when the site is loaded from another one (iframe). Implies `useSecureSessionCookie`. |
## Usage
### Custom logs
After the Datadog browser logs SDK is initialized, send a custom log entry directly to Datadog with the API:
```
logger.debug | info | warn | error (message: string, messageContext?: Context, error?: Error)
```
#### NPM
```javascript

@@ -162,77 +30,3 @@ import { datadogLogs } from '@datadog/browser-logs'

datadogLogs.logger.info('Button clicked', { name: 'buttonName', id: 123 })
```
#### CDN async
```javascript
DD_LOGS.onReady(function () {
DD_LOGS.logger.info('Button clicked', { name: 'buttonName', id: 123 })
})
```
**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
```javascript
window.DD_LOGS && DD_LOGS.logger.info('Button clicked', { name: 'buttonName', id: 123 })
```
**Note**: The `window.DD_LOGS` check prevents issues when a loading failure occurs with the SDK.
#### Results
The results are the same when using NPM, CDN async, or CDN sync:
```json
{
"status": "info",
"session_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"name": "buttonName",
"id": 123,
"message": "Button clicked",
"date": 1234567890000,
"origin": "logger",
"http": {
"useragent": "Mozilla/5.0 ...",
},
"view": {
"url": "https://...",
"referrer": "https://...",
},
"network": {
"client": {
"geoip": {...}
"ip": "xxx.xxx.xxx.xxx"
}
}
}
```
The Logs SDK adds the following information by default (more fields can be added if the RUM SDK is
present):
- `date`
- `view.url`
- `view.referrer`
- `session_id` (only if a session is used)
The Datadog backend adds more fields, like:
- `http.useragent`
- `network.client.ip`
### Error tracking
The Datadog browser logs SDK allows for manual error tracking by using the optional `error` parameter (Available in SDK v4.36.0+). When an instance of a [JavaScript Error][10] is provided, the SDK extracts relevant information (kind, message, stack trace) from the error.
```
logger.debug | info | warn | error (message: string, messageContext?: Context, error?: Error)
```
#### NPM
```javascript
import { datadogLogs } from '@datadog/browser-logs'
try {

@@ -243,684 +37,9 @@ ...

} catch (ex) {
datadogLogs.logger.error('Error occurred', {}, ex)
datadogLogs.logger.error('Error occurred', { team: 'myTeam' }, ex)
}
```
#### CDN async
```javascript
try {
...
throw new Error('Wrong behavior')
...
} catch (ex) {
DD_LOGS.onReady(function () {
DD_LOGS.logger.error('Error occurred', {}, ex)
})
}
```
**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
```javascript
try {
...
throw new Error('Wrong behavior')
...
} catch (ex) {
window.DD_LOGS && DD_LOGS.logger.error('Error occurred', {}, ex)
}
```
**Note**: The `window.DD_LOGS` check prevents issues when a loading failure occurs with the SDK.
#### Results
The results are the same when using NPM, CDN async, or CDN sync:
```json
{
"status": "error",
"session_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"message": "Error occurred",
"date": 1234567890000,
"origin": "logger",
"error" : {
"message": "Wrong behavior",
"kind" : "Error",
"stack" : "Error: Wrong behavior at <anonymous> @ <anonymous>:1:1"
},
...
}
```
### Generic logger function
The Datadog browser logs SDK adds shorthand functions (`.debug`, `.info`, `.warn`, `.error`) to the loggers for convenience. A generic logger function is also available, exposing the `status` parameter:
```
log (message: string, messageContext?: Context, status? = 'debug' | 'info' | 'warn' | 'error', error?: Error)
```
#### NPM
For NPM, use:
```javascript
import { datadogLogs } from '@datadog/browser-logs';
datadogLogs.logger.log(<MESSAGE>,<JSON_ATTRIBUTES>,<STATUS>,<ERROR>);
```
#### CDN async
For CDN async, use:
```javascript
DD_LOGS.onReady(function() {
DD_LOGS.logger.log(<MESSAGE>,<JSON_ATTRIBUTES>,<STATUS>,<ERROR>);
})
```
**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.logger.log(<MESSAGE>,<JSON_ATTRIBUTES>,<STATUS>,<ERROR>);
```
#### Placeholders
The placeholders in the examples above are described below:
| Placeholder | Description |
| ------------------- | --------------------------------------------------------------------------------------- |
| `<MESSAGE>` | The message of your log that is fully indexed by Datadog. |
| `<JSON_ATTRIBUTES>` | A valid JSON object, which includes all attributes attached to the `<MESSAGE>`. |
| `<STATUS>` | The status of your log; accepted status values are `debug`, `info`, `warn`, or `error`. |
| `<ERROR>` | An instance of a [JavaScript Error][10] object. |
## Advanced usage
### Scrub sensitive data from your Browser logs
If your Browser logs contain sensitive information that needs redacting, configure the Browser SDK to scrub sensitive sequences by using the `beforeSend` callback when you initialize the Browser Log Collector.
The `beforeSend` callback function gives you access to each log collected by the Browser SDK before it is sent to Datadog, and lets you update any property.
To redact email addresses from your web application URLs:
#### NPM
```javascript
import { datadogLogs } from '@datadog/browser-logs'
datadogLogs.init({
...,
beforeSend: (log) => {
// remove email from view url
log.view.url = log.view.url.replace(/email=[^&]*/, "email=REDACTED")
},
...
});
```
#### CDN Async
```javascript
DD_LOGS.onReady(function() {
DD_LOGS.init({
...,
beforeSend: (log) => {
// remove email from view url
log.view.url = log.view.url.replace(/email=[^&]*/, "email=REDACTED")
},
...
})
})
```
#### CDN Sync
```javascript
window.DD_LOGS &&
window.DD_LOGS.init({
...,
beforeSend: (log) => {
// remove email from view url
log.view.url = log.view.url.replace(/email=[^&]*/, "email=REDACTED")
},
...
});
```
The following properties are automatically collected by the SDK and could contain sensitive data:
| Attribute | Type | Description |
| --------------- | ------ | ------------------------------------------------------------------------------------------------ |
| `view.url` | String | The URL of the active web page. |
| `view.referrer` | String | The URL of the previous web page from which a link to the currently requested page was followed. |
| `message` | String | The content of the log. |
| `error.stack` | String | The stack trace or complementary information about the error. |
| `http.url` | String | The HTTP URL. |
### Discard specific logs
The `beforeSend` callback function allows you to also discard a log before it is sent to Datadog.
To discard network errors if their status is 404:
#### NPM
```javascript
import { datadogLogs } from '@datadog/browser-logs'
datadogLogs.init({
...,
beforeSend: (log) => {
// discard 404 network errors
if (log.http && log.http.status_code === 404) {
return false
}
},
...
});
```
#### CDN Async
```javascript
DD_LOGS.onReady(function() {
DD_LOGS.init({
...,
beforeSend: (log) => {
// discard 404 network errors
if (log.http && log.http.status_code === 404) {
return false
}
},
...
})
})
```
#### CDN Sync
```javascript
window.DD_LOGS &&
window.DD_LOGS.init({
...,
beforeSend: (log) => {
// discard 404 network errors
if (log.http && log.http.status_code === 404) {
return false
}
},
...
});
```
### Define multiple loggers
The Datadog browser logs SDK contains a default logger, but it is possible to define different loggers.
#### Create a new logger
After the Datadog browser logs SDK is initialized, use the API `createLogger` to define a new logger:
```typescript
createLogger (name: string, conf?: {
level?: 'debug' | 'info' | 'warn' | 'error',
handler?: 'http' | 'console' | 'silent',
context?: Context
})
```
**Note**: These parameters can be set with the [setLevel](#filter-by-status), [setHandler](#change-the-destination), and [setContext](#overwrite-context) APIs.
#### Get a custom logger
After the creation of a logger, access it in any part of your JavaScript code with the API:
```typescript
getLogger(name: string)
```
##### NPM
For example, assume there is a `signupLogger`, defined with all the other loggers:
```javascript
import { datadogLogs } from '@datadog/browser-logs'
datadogLogs.createLogger('signupLogger', 'info', 'http', { env: 'staging' })
```
It can now be used in a different part of the code with:
```javascript
import { datadogLogs } from '@datadog/browser-logs'
const signupLogger = datadogLogs.getLogger('signupLogger')
signupLogger.info('Test sign up completed')
```
#### CDN async
For example, assume there is a `signupLogger`, defined with all the other loggers:
```javascript
DD_LOGS.onReady(function () {
const signupLogger = DD_LOGS.createLogger('signupLogger', 'info', 'http', { env: 'staging' })
})
```
It can now be used in a different part of the code with:
```javascript
DD_LOGS.onReady(function () {
const signupLogger = DD_LOGS.getLogger('signupLogger')
signupLogger.info('Test sign up completed')
})
```
**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 example, assume there is a `signupLogger`, defined with all the other loggers:
```javascript
if (window.DD_LOGS) {
const signupLogger = DD_LOGS.createLogger('signupLogger', 'info', 'http', { env: 'staging' })
}
```
It can now be used in a different part of the code with:
```javascript
if (window.DD_LOGS) {
const signupLogger = DD_LOGS.getLogger('signupLogger')
signupLogger.info('Test sign up completed')
}
```
**Note**: The `window.DD_LOGS` check prevents issues when a loading failure occurs with the SDK.
### Overwrite context
#### Global context
After the Datadog browser logs SDK is initialized, it is possible to:
- Set the entire context for all your loggers with the `setGlobalContext (context: object)` API.
- Add a context to all your loggers with the `setGlobalContextProperty (key: string, value: any)` API.
- Get the entire global context with the `getGlobalContext ()` API.
- Remove context property with the `removeGlobalContextProperty (key: string)` API.
- Clear all existing context properties with the `clearGlobalContext ()` API.
> The Log Browser SDK v4.17.0 has updated the names of several APIs:
>
> - `getGlobalContext` instead of `getLoggerGlobalContext`
> - `setGlobalContext` instead of `setLoggerGlobalContext`
> - `setGlobalContextProperty` instead of `addLoggerGlobalContext`
> - `removeGlobalContextProperty` instead of `removeLoggerGlobalContext`
##### NPM
For NPM, use:
```javascript
import { datadogLogs } from '@datadog/browser-logs'
datadogLogs.setGlobalContext({ env: 'staging' })
datadogLogs.setGlobalContextProperty('referrer', document.referrer)
datadogLogs.getGlobalContext() // => {env: 'staging', referrer: ...}
datadogLogs.removeGlobalContextProperty('referrer')
datadogLogs.getGlobalContext() // => {env: 'staging'}
datadogLogs.clearGlobalContext()
datadogLogs.getGlobalContext() // => {}
```
#### CDN async
For CDN async, use:
```javascript
DD_LOGS.onReady(function () {
DD_LOGS.setGlobalContext({ env: 'staging' })
})
DD_LOGS.onReady(function () {
DD_LOGS.setGlobalContextProperty('referrer', document.referrer)
})
DD_LOGS.onReady(function () {
DD_LOGS.getGlobalContext() // => {env: 'staging', referrer: ...}
})
DD_LOGS.onReady(function () {
DD_LOGS.removeGlobalContextProperty('referrer')
})
DD_LOGS.onReady(function () {
DD_LOGS.getGlobalContext() // => {env: 'staging'}
})
DD_LOGS.onReady(function () {
DD_LOGS.clearGlobalContext()
})
DD_LOGS.onReady(function () {
DD_LOGS.getGlobalContext() // => {}
})
```
**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.setGlobalContext({ env: 'staging' })
window.DD_LOGS && DD_LOGS.setGlobalContextProperty('referrer', document.referrer)
window.DD_LOGS && DD_LOGS.getGlobalContext() // => {env: 'staging', referrer: ...}
window.DD_LOGS && DD_LOGS.removeGlobalContextProperty('referrer')
window.DD_LOGS && DD_LOGS.getGlobalContext() // => {env: 'staging'}
window.DD_LOGS && DD_LOGS.clearGlobalContext()
window.DD_LOGS && DD_LOGS.getGlobalContext() // => {}
```
**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
After a logger is created, it is possible to:
- Set the entire context for your logger with the `setContext (context: object)` API.
- Add a context to your logger with `addContext (key: string, value: any)` API:
##### NPM
For NPM, use:
```javascript
import { datadogLogs } from '@datadog/browser-logs'
datadogLogs.setContext("{'env': 'staging'}")
datadogLogs.addContext('referrer', document.referrer)
```
#### CDN async
For CDN async, use:
```javascript
DD_LOGS.onReady(function () {
DD_LOGS.setContext("{'env': 'staging'}")
})
DD_LOGS.onReady(function () {
DD_LOGS.addContext('referrer', document.referrer)
})
```
**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.setContext("{'env': 'staging'}")
window.DD_LOGS && DD_LOGS.addContext('referrer', document.referrer)
```
**Note**: The `window.DD_LOGS` check prevents issues when a loading failure occurs with the SDK.
### Filter by status
After the Datadog browser logs SDK is initialized, the minimal log level for your logger is set with the API:
```
setLevel (level?: 'debug' | 'info' | 'warn' | 'error')
```
Only logs with a status equal to or higher than the specified level are sent.
##### NPM
For NPM, use:
```javascript
import { datadogLogs } from '@datadog/browser-logs'
datadogLogs.logger.setLevel('<LEVEL>')
```
#### CDN async
For CDN async, use:
```javascript
DD_LOGS.onReady(function () {
DD_LOGS.logger.setLevel('<LEVEL>')
})
```
**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.logger.setLevel('<LEVEL>')
```
**Note**: The `window.DD_LOGS` check prevents issues when a loading failure occurs with the SDK.
### Change the destination
By default, loggers created by the Datadog browser logs SDK are sending logs to Datadog. After the Datadog browser logs SDK is initialized, it is possible to configure the logger to:
- send logs to the `console` and Datadog (`http`)
- send logs to the `console` only
- not send logs at all (`silent`)
```
setHandler (handler?: 'http' | 'console' | 'silent' | Array<handler>)
```
##### NPM
For NPM, use:
```javascript
import { datadogLogs } from '@datadog/browser-logs'
datadogLogs.logger.setHandler('<HANDLER>')
datadogLogs.logger.setHandler(['<HANDLER1>', '<HANDLER2>'])
```
#### CDN async
For CDN async, use:
```javascript
DD_LOGS.onReady(function () {
DD_LOGS.logger.setHandler('<HANDLER>')
DD_LOGS.logger.setHandler(['<HANDLER1>', '<HANDLER2>'])
})
```
**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.logger.setHandler('<HANDLER>')
window.DD_LOGS && DD_LOGS.logger.setHandler(['<HANDLER1>', '<HANDLER2>'])
```
**Note**: The `window.DD_LOGS` check prevents issues when a loading failure occurs with the SDK.
### Access internal context
After the Datadog browser logs SDK is initialized, you can access the internal context of the SDK. This allows you to access the `session_id`.
```
getInternalContext (startTime?: 'number' | undefined)
```
You can optionally use `startTime` parameter to get the context of a specific time. If the parameter is omitted, the current context is returned.
##### NPM
For NPM, use:
```javascript
import { datadogLogs } from '@datadog/browser-logs'
datadogLogs.getInternalContext() // { session_id: "xxxx-xxxx-xxxx-xxxx" }
```
#### CDN async
For CDN async, use:
```javascript
DD_LOGS.onReady(function () {
DD_LOGS.getInternalContext() // { session_id: "xxxx-xxxx-xxxx-xxxx" }
})
```
##### CDN sync
For CDN sync, use:
```javascript
window.DD_LOGS && window.DD_LOGS.getInternalContext() // { session_id: "xxxx-xxxx-xxxx-xxxx" }
```
<!-- Note: all URLs should be absolute -->
[1]: https://docs.datadoghq.com/account_management/api-app-keys/#api-keys
[2]: https://docs.datadoghq.com/account_management/api-app-keys/#client-tokens
[3]: https://www.npmjs.com/package/@datadog/browser-logs
[4]: https://github.com/DataDog/browser-sdk/blob/main/packages/logs/BROWSER_SUPPORT.md
[5]: https://docs.datadoghq.com/real_user_monitoring/guide/enrich-and-control-rum-data/
[6]: https://docs.datadoghq.com/real_user_monitoring/faq/proxy_rum_data/
[7]: https://docs.datadoghq.com/getting_started/tagging/#defining-tags
[8]: https://developer.mozilla.org/en-US/docs/Web/API/Reporting_API
[9]: https://docs.datadoghq.com/getting_started/site/
[10]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
[1]: https://docs.datadoghq.com/logs/log_collection/javascript
[2]: https://www.npmjs.com/package/@datadog/browser-logs
import type { TimeStamp } from '@datadog/browser-core'
import { monitor, ONE_SECOND, display } from '@datadog/browser-core'
import type { Clock } from '../../../core/test/specHelper'
import { deleteEventBridgeStub, initEventBridgeStub, mockClock } from '../../../core/test/specHelper'
import type { Clock } from '@datadog/browser-core/test'
import { deleteEventBridgeStub, initEventBridgeStub, mockClock } from '@datadog/browser-core/test'
import type { HybridInitConfiguration, LogsInitConfiguration } from '../domain/configuration'

@@ -6,0 +6,0 @@ import type { Logger, LogsMessage } from '../domain/logger'

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

@@ -39,4 +41,4 @@ BoundedBuffer,

const globalContextManager = createContextManager()
const userContextManager = createContextManager()
const globalContextManager = createContextManager(CustomerDataType.GlobalContext)
const userContextManager = createContextManager(CustomerDataType.User)

@@ -124,6 +126,8 @@ const customLoggers: { [name: string]: Logger | undefined } = {}

(...params) => handleLogStrategy(...params),
isExperimentalFeatureEnabled('sanitize_inputs') ? sanitize(name) : name,
isExperimentalFeatureEnabled(ExperimentalFeature.SANITIZE_INPUTS) ? sanitize(name) : name,
conf.handler,
conf.level,
isExperimentalFeatureEnabled('sanitize_inputs') ? (sanitize(conf.context) as object) : conf.context
isExperimentalFeatureEnabled(ExperimentalFeature.SANITIZE_INPUTS)
? (sanitize(conf.context) as object)
: conf.context
)

@@ -130,0 +134,0 @@

import { ErrorSource, display, stopSessionManager, getCookie, SESSION_COOKIE_NAME } from '@datadog/browser-core'
import { cleanupSyntheticsWorkerValues, mockSyntheticsWorkerValues } from '../../../core/test/syntheticsWorkerValues'
import type { Request } from '@datadog/browser-core/test'
import {
interceptRequests,
stubEndpointBuilder,
deleteEventBridgeStub,
initEventBridgeStub,
stubEndpointBuilder,
interceptRequests,
} from '../../../core/test/specHelper'
import type { Request } from '../../../core/test/specHelper'
cleanupSyntheticsWorkerValues,
mockSyntheticsWorkerValues,
} from '@datadog/browser-core/test'
import type { LogsConfiguration } from '../domain/configuration'
import { validateAndBuildLogsConfiguration } from '../domain/configuration'
import { HandlerType, Logger, StatusType } from '../domain/logger'

@@ -14,0 +15,0 @@ import type { startLoggerCollection } from '../domain/logsCollection/logger/loggerCollection'

import type { Context, RelativeTime, TelemetryEvent, TimeStamp } from '@datadog/browser-core'
import { TelemetryService, startTelemetry, ErrorSource, ONE_MINUTE, getTimeStamp, noop } from '@datadog/browser-core'
import { cleanupSyntheticsWorkerValues, mockSyntheticsWorkerValues } from '../../../core/test/syntheticsWorkerValues'
import type { Clock } from '@datadog/browser-core/test'
import { mockClock, cleanupSyntheticsWorkerValues, mockSyntheticsWorkerValues } from '@datadog/browser-core/test'
import type { LogsEvent } from '../logsEvent.types'
import type { Clock } from '../../../core/test/specHelper'
import { mockClock } from '../../../core/test/specHelper'
import type { CommonContext } from '../rawLogsEvent.types'

@@ -8,0 +7,0 @@ import { getRUMInternalContext, resetRUMInternalContext, startLogsAssembly } from './assembly'

import type { Context } from '@datadog/browser-core'
import {
ExperimentalFeature,
isExperimentalFeatureEnabled,

@@ -9,2 +10,3 @@ clocksNow,

computeStackTrace,
CustomerDataType,
deepClone,

@@ -18,2 +20,3 @@ assign,

} from '@datadog/browser-core'
import type { LogsEvent } from '../logsEvent.types'

@@ -46,3 +49,3 @@

export class Logger {
private contextManager = createContextManager()
private contextManager = createContextManager(CustomerDataType.LoggerContext)

@@ -88,3 +91,5 @@ constructor(

const sanitizedMessageContext = (
isExperimentalFeatureEnabled('sanitize_inputs') ? sanitize(messageContext) : deepClone(messageContext)
isExperimentalFeatureEnabled(ExperimentalFeature.SANITIZE_INPUTS)
? sanitize(messageContext)
: deepClone(messageContext)
) as Context

@@ -97,3 +102,7 @@

this.handleLogStrategy(
{ message: isExperimentalFeatureEnabled('sanitize_inputs') ? sanitize(message)! : message, context, status },
{
message: isExperimentalFeatureEnabled(ExperimentalFeature.SANITIZE_INPUTS) ? sanitize(message)! : message,
context,
status,
},
this

@@ -100,0 +109,0 @@ )

import type { TimeStamp } from '@datadog/browser-core'
import { ConsoleApiName, timeStampNow, display, ErrorSource } from '@datadog/browser-core'
import type { Clock } from '@datadog/browser-core/test/specHelper'
import { mockClock } from '@datadog/browser-core/test/specHelper'
import type { Clock } from '@datadog/browser-core/test'
import { mockClock } from '@datadog/browser-core/test'
import type { CommonContext, RawLoggerLogsEvent } from '../../../rawLogsEvent.types'

@@ -6,0 +6,0 @@ import type { RawLogsEventCollectedData } from '../../lifeCycle'

import { isIE, ErrorSource } from '@datadog/browser-core'
import type { FetchStub, FetchStubManager } from '@datadog/browser-core/test/specHelper'
import { SPEC_ENDPOINTS, ResponseStub, stubFetch } from '@datadog/browser-core/test/specHelper'
import type { FetchStub, FetchStubManager } from '@datadog/browser-core/test'
import { SPEC_ENDPOINTS, ResponseStub, stubFetch } from '@datadog/browser-core/test'
import type { RawNetworkLogsEvent } from '../../../rawLogsEvent.types'

@@ -5,0 +5,0 @@ import type { LogsConfiguration } from '../../configuration'

import { ErrorSource, noop } from '@datadog/browser-core'
import { stubReportingObserver } from '@datadog/browser-core/test/stubReportApis'
import { stubReportingObserver } from '@datadog/browser-core/test'
import type { RawReportLogsEvent } from '../../../rawLogsEvent.types'

@@ -4,0 +4,0 @@ import { validateAndBuildLogsConfiguration } from '../../configuration'

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

} from '@datadog/browser-core'
import type { Clock } from '../../../core/test/specHelper'
import { mockClock } from '../../../core/test/specHelper'
import type { Clock } from '@datadog/browser-core/test'
import { mockClock } from '@datadog/browser-core/test'

@@ -14,0 +14,0 @@ import type { LogsConfiguration } from './configuration'

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc