Socket
Socket
Sign inDemoInstall

@datadog/browser-logs

Package Overview
Dependencies
Maintainers
1
Versions
254
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datadog/browser-logs - npm Package Compare versions

Comparing version 4.36.0 to 4.37.0

2

bundle/datadog-logs.js

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

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

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

}
export declare type LogsPublicApi = ReturnType<typeof makeLogsPublicApi>;
export declare type StartLogs = typeof startLogs;
export type LogsPublicApi = ReturnType<typeof makeLogsPublicApi>;
export type StartLogs = typeof startLogs;
export declare function makeLogsPublicApi(startLogsImpl: StartLogs): {

@@ -15,0 +15,0 @@ logger: Logger;

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

return handleLogStrategy.apply(void 0, params);
}, name, conf.handler, conf.level, conf.context);
}, (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);
return customLoggers[name];

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

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

var lifeCycle = new lifeCycle_1.LifeCycle();
lifeCycle.subscribe(1 /* LOG_COLLECTED */, function (log) { return (0, browser_core_1.sendToExtension)('logs', log); });
lifeCycle.subscribe(1 /* LifeCycleEventType.LOG_COLLECTED */, function (log) { return (0, browser_core_1.sendToExtension)('logs', log); });
var reportError = function (error) {
return lifeCycle.notify(0 /* RAW_LOG_COLLECTED */, {
return lifeCycle.notify(0 /* LifeCycleEventType.RAW_LOG_COLLECTED */, {
rawLogsEvent: {

@@ -79,3 +79,3 @@ message: error.message,

var _a;
var telemetry = (0, browser_core_1.startTelemetry)("browser-logs-sdk" /* LOGS */, configuration);
var telemetry = (0, browser_core_1.startTelemetry)("browser-logs-sdk" /* TelemetryService.LOGS */, configuration);
if ((0, browser_core_1.canUseEventBridge)()) {

@@ -82,0 +82,0 @@ var bridge_1 = (0, browser_core_1.getEventBridge)();

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

});
lifeCycle.subscribe(0 /* RAW_LOG_COLLECTED */, function (_a) {
lifeCycle.subscribe(0 /* LifeCycleEventType.RAW_LOG_COLLECTED */, function (_a) {
var _b, _c, _d;

@@ -39,3 +39,3 @@ var rawLogsEvent = _a.rawLogsEvent, _e = _a.messageContext, messageContext = _e === void 0 ? undefined : _e, _f = _a.savedCommonContext, savedCommonContext = _f === void 0 ? undefined : _f, _g = _a.logger, logger = _g === void 0 ? mainLogger : _g;

}
lifeCycle.notify(1 /* LOG_COLLECTED */, log);
lifeCycle.notify(1 /* LifeCycleEventType.LOG_COLLECTED */, log);
});

@@ -42,0 +42,0 @@ }

@@ -10,3 +10,3 @@ import type { Configuration, InitConfiguration, RawTelemetryConfiguration } from '@datadog/browser-core';

}
export declare type HybridInitConfiguration = Omit<LogsInitConfiguration, 'clientToken'>;
export type HybridInitConfiguration = Omit<LogsInitConfiguration, 'clientToken'>;
export interface LogsConfiguration extends Configuration {

@@ -13,0 +13,0 @@ forwardErrorsToLogs: boolean;

@@ -6,3 +6,3 @@ import type { LogsSessionManager } from './logsSessionManager';

export declare function startInternalContext(sessionManager: LogsSessionManager): {
get: (startTime?: number | undefined) => InternalContext | undefined;
get: (startTime?: number) => InternalContext | undefined;
};

@@ -13,3 +13,3 @@ import type { Context } from '@datadog/browser-core';

};
export declare type StatusType = (typeof StatusType)[keyof typeof StatusType];
export type StatusType = (typeof StatusType)[keyof typeof StatusType];
export declare const HandlerType: {

@@ -20,3 +20,3 @@ readonly console: "console";

};
export declare type HandlerType = (typeof HandlerType)[keyof typeof HandlerType];
export type HandlerType = (typeof HandlerType)[keyof typeof HandlerType];
export declare const STATUSES: StatusType[];

@@ -23,0 +23,0 @@ export declare class Logger {

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

source: browser_core_1.ErrorSource.LOGGER,
handling: "handled" /* HANDLED */,
handling: "handled" /* ErrorHandling.HANDLED */,
startClocks: (0, browser_core_1.clocksNow)(),

@@ -59,6 +59,7 @@ });

}
var sanitizedMessageContext = ((0, browser_core_1.isExperimentalFeatureEnabled)('sanitize_inputs') ? (0, browser_core_1.sanitize)(messageContext) : (0, browser_core_1.deepClone)(messageContext));
var context = errorContext
? (0, browser_core_1.combine)({ error: errorContext }, messageContext)
: (0, browser_core_1.deepClone)(messageContext);
this.handleLogStrategy({ message: message, context: context, status: status }, this);
? (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);
};

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

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

var consoleSubscription = (0, browser_core_1.initConsoleObservable)(configuration.forwardConsoleLogs).subscribe(function (log) {
lifeCycle.notify(0 /* RAW_LOG_COLLECTED */, {
lifeCycle.notify(0 /* LifeCycleEventType.RAW_LOG_COLLECTED */, {
rawLogsEvent: {

@@ -19,0 +19,0 @@ date: (0, browser_core_1.timeStampNow)(),

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

export declare function startLoggerCollection(lifeCycle: LifeCycle): {
handleLog: (logsMessage: LogsMessage, logger: Logger, savedCommonContext?: CommonContext | undefined, savedDate?: TimeStamp | undefined) => void;
handleLog: (logsMessage: LogsMessage, logger: Logger, savedCommonContext?: CommonContext, savedDate?: TimeStamp) => void;
};
export declare function isAuthorized(status: StatusType, handlerType: HandlerType, logger: Logger): boolean;

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

}
lifeCycle.notify(0 /* RAW_LOG_COLLECTED */, {
lifeCycle.notify(0 /* LifeCycleEventType.RAW_LOG_COLLECTED */, {
rawLogsEvent: {

@@ -22,0 +22,0 @@ date: savedDate || (0, browser_core_1.timeStampNow)(),

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

if (context.state === 'complete') {
handleResponse("xhr" /* XHR */, context);
handleResponse("xhr" /* RequestType.XHR */, context);
}

@@ -18,3 +18,3 @@ });

if (context.state === 'resolve') {
handleResponse("fetch" /* FETCH */, context);
handleResponse("fetch" /* RequestType.FETCH */, context);
}

@@ -35,3 +35,3 @@ });

function onResponseDataAvailable(responseData) {
lifeCycle.notify(0 /* RAW_LOG_COLLECTED */, {
lifeCycle.notify(0 /* LifeCycleEventType.RAW_LOG_COLLECTED */, {
rawLogsEvent: {

@@ -142,3 +142,3 @@ message: "".concat(format(type), " error ").concat(request.method, " ").concat(request.url),

function format(type) {
if ("xhr" /* XHR */ === type) {
if ("xhr" /* RequestType.XHR */ === type) {
return 'XHR';

@@ -145,0 +145,0 @@ }

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

}
lifeCycle.notify(0 /* RAW_LOG_COLLECTED */, {
lifeCycle.notify(0 /* LifeCycleEventType.RAW_LOG_COLLECTED */, {
rawLogsEvent: {

@@ -30,0 +30,0 @@ date: (0, browser_core_1.timeStampNow)(),

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

var rawErrorSubscription = rawErrorObservable.subscribe(function (rawError) {
lifeCycle.notify(0 /* RAW_LOG_COLLECTED */, {
lifeCycle.notify(0 /* LifeCycleEventType.RAW_LOG_COLLECTED */, {
rawLogsEvent: {

@@ -16,0 +16,0 @@ message: rawError.message,

@@ -7,3 +7,3 @@ import type { RelativeTime } from '@datadog/browser-core';

}
export declare type LogsSession = {
export type LogsSession = {
id?: string;

@@ -10,0 +10,0 @@ };

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

var session = sessionManager.findActiveSession(startTime);
return session && session.trackingType === "1" /* TRACKED */
return session && session.trackingType === "1" /* LoggerTrackingType.TRACKED */
? {

@@ -24,3 +24,3 @@ id: session.id,

function startLogsSessionManagerStub(configuration) {
var isTracked = computeTrackingType(configuration) === "1" /* TRACKED */;
var isTracked = computeTrackingType(configuration) === "1" /* LoggerTrackingType.TRACKED */;
var session = isTracked ? {} : undefined;

@@ -34,5 +34,5 @@ return {

if (!(0, browser_core_1.performDraw)(configuration.sessionSampleRate)) {
return "0" /* NOT_TRACKED */;
return "0" /* LoggerTrackingType.NOT_TRACKED */;
}
return "1" /* TRACKED */;
return "1" /* LoggerTrackingType.TRACKED */;
}

@@ -43,8 +43,8 @@ function computeSessionState(configuration, rawSessionType) {

trackingType: trackingType,
isTracked: trackingType === "1" /* TRACKED */,
isTracked: trackingType === "1" /* LoggerTrackingType.TRACKED */,
};
}
function hasValidLoggerSession(trackingType) {
return trackingType === "0" /* NOT_TRACKED */ || trackingType === "1" /* TRACKED */;
return trackingType === "0" /* LoggerTrackingType.NOT_TRACKED */ || trackingType === "1" /* LoggerTrackingType.TRACKED */;
}
//# sourceMappingURL=logsSessionManager.js.map
import type { Context, ErrorSource, TimeStamp, User } from '@datadog/browser-core';
import type { StatusType } from './domain/logger';
export declare type RawLogsEvent = RawConsoleLogsEvent | RawNetworkLogsEvent | RawLoggerLogsEvent | RawAgentLogsEvent | RawReportLogsEvent | RawRuntimeLogsEvent;
declare type Error = {
export type RawLogsEvent = RawConsoleLogsEvent | RawNetworkLogsEvent | RawLoggerLogsEvent | RawAgentLogsEvent | RawReportLogsEvent | RawRuntimeLogsEvent;
type Error = {
kind?: string;

@@ -6,0 +6,0 @@ origin: ErrorSource;

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

var batch = (0, browser_core_1.startBatchWithReplica)(configuration, configuration.logsEndpointBuilder, reportError, pageExitObservable, (_a = configuration.replica) === null || _a === void 0 ? void 0 : _a.logsEndpointBuilder);
lifeCycle.subscribe(1 /* LOG_COLLECTED */, function (serverLogsEvent) {
lifeCycle.subscribe(1 /* LifeCycleEventType.LOG_COLLECTED */, function (serverLogsEvent) {
batch.add(serverLogsEvent);

@@ -11,0 +11,0 @@ });

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

var bridge = (0, browser_core_1.getEventBridge)();
lifeCycle.subscribe(1 /* LOG_COLLECTED */, function (serverLogsEvent) {
lifeCycle.subscribe(1 /* LifeCycleEventType.LOG_COLLECTED */, function (serverLogsEvent) {
bridge.send('log', serverLogsEvent);

@@ -10,0 +10,0 @@ });

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

}
export declare type LogsPublicApi = ReturnType<typeof makeLogsPublicApi>;
export declare type StartLogs = typeof startLogs;
export type LogsPublicApi = ReturnType<typeof makeLogsPublicApi>;
export type StartLogs = typeof startLogs;
export declare function makeLogsPublicApi(startLogsImpl: StartLogs): {

@@ -15,0 +15,0 @@ logger: Logger;

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

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

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

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

@@ -79,0 +79,0 @@ }),

@@ -17,5 +17,5 @@ import { sendToExtension, createPageExitObservable, willSyntheticsInjectRum, areCookiesAuthorized, canUseEventBridge, getEventBridge, startTelemetry, startBatchWithReplica, isTelemetryReplicationAllowed, ErrorSource, addTelemetryConfiguration, } from '@datadog/browser-core';

var lifeCycle = new LifeCycle();
lifeCycle.subscribe(1 /* LOG_COLLECTED */, function (log) { return sendToExtension('logs', log); });
lifeCycle.subscribe(1 /* LifeCycleEventType.LOG_COLLECTED */, function (log) { return sendToExtension('logs', log); });
var reportError = function (error) {
return lifeCycle.notify(0 /* RAW_LOG_COLLECTED */, {
return lifeCycle.notify(0 /* LifeCycleEventType.RAW_LOG_COLLECTED */, {
rawLogsEvent: {

@@ -75,3 +75,3 @@ message: error.message,

var _a;
var telemetry = startTelemetry("browser-logs-sdk" /* LOGS */, configuration);
var telemetry = startTelemetry("browser-logs-sdk" /* TelemetryService.LOGS */, configuration);
if (canUseEventBridge()) {

@@ -78,0 +78,0 @@ var bridge_1 = getEventBridge();

@@ -11,3 +11,3 @@ import { getSyntheticsResultId, getSyntheticsTestId, addTelemetryDebug, willSyntheticsInjectRum, ErrorSource, combine, createEventRateLimiter, getRelativeTime, isEmptyObject, } from '@datadog/browser-core';

});
lifeCycle.subscribe(0 /* RAW_LOG_COLLECTED */, function (_a) {
lifeCycle.subscribe(0 /* LifeCycleEventType.RAW_LOG_COLLECTED */, function (_a) {
var _b, _c, _d;

@@ -36,3 +36,3 @@ var rawLogsEvent = _a.rawLogsEvent, _e = _a.messageContext, messageContext = _e === void 0 ? undefined : _e, _f = _a.savedCommonContext, savedCommonContext = _f === void 0 ? undefined : _f, _g = _a.logger, logger = _g === void 0 ? mainLogger : _g;

}
lifeCycle.notify(1 /* LOG_COLLECTED */, log);
lifeCycle.notify(1 /* LifeCycleEventType.LOG_COLLECTED */, log);
});

@@ -39,0 +39,0 @@ }

@@ -10,3 +10,3 @@ import type { Configuration, InitConfiguration, RawTelemetryConfiguration } from '@datadog/browser-core';

}
export declare type HybridInitConfiguration = Omit<LogsInitConfiguration, 'clientToken'>;
export type HybridInitConfiguration = Omit<LogsInitConfiguration, 'clientToken'>;
export interface LogsConfiguration extends Configuration {

@@ -13,0 +13,0 @@ forwardErrorsToLogs: boolean;

@@ -6,3 +6,3 @@ import type { LogsSessionManager } from './logsSessionManager';

export declare function startInternalContext(sessionManager: LogsSessionManager): {
get: (startTime?: number | undefined) => InternalContext | undefined;
get: (startTime?: number) => InternalContext | undefined;
};

@@ -13,3 +13,3 @@ import type { Context } from '@datadog/browser-core';

};
export declare type StatusType = (typeof StatusType)[keyof typeof StatusType];
export type StatusType = (typeof StatusType)[keyof typeof StatusType];
export declare const HandlerType: {

@@ -20,3 +20,3 @@ readonly console: "console";

};
export declare type HandlerType = (typeof HandlerType)[keyof typeof HandlerType];
export type HandlerType = (typeof HandlerType)[keyof typeof HandlerType];
export declare const STATUSES: StatusType[];

@@ -23,0 +23,0 @@ export declare class Logger {

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

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

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

source: ErrorSource.LOGGER,
handling: "handled" /* HANDLED */,
handling: "handled" /* ErrorHandling.HANDLED */,
startClocks: clocksNow(),

@@ -57,6 +57,7 @@ });

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

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

@@ -13,3 +13,3 @@ var _a;

var consoleSubscription = initConsoleObservable(configuration.forwardConsoleLogs).subscribe(function (log) {
lifeCycle.notify(0 /* RAW_LOG_COLLECTED */, {
lifeCycle.notify(0 /* LifeCycleEventType.RAW_LOG_COLLECTED */, {
rawLogsEvent: {

@@ -16,0 +16,0 @@ date: timeStampNow(),

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

export declare function startLoggerCollection(lifeCycle: LifeCycle): {
handleLog: (logsMessage: LogsMessage, logger: Logger, savedCommonContext?: CommonContext | undefined, savedDate?: TimeStamp | undefined) => void;
handleLog: (logsMessage: LogsMessage, logger: Logger, savedCommonContext?: CommonContext, savedDate?: TimeStamp) => void;
};
export declare function isAuthorized(status: StatusType, handlerType: HandlerType, logger: Logger): boolean;

@@ -16,3 +16,3 @@ var _a;

}
lifeCycle.notify(0 /* RAW_LOG_COLLECTED */, {
lifeCycle.notify(0 /* LifeCycleEventType.RAW_LOG_COLLECTED */, {
rawLogsEvent: {

@@ -19,0 +19,0 @@ date: savedDate || timeStampNow(),

@@ -9,3 +9,3 @@ import { ErrorSource, initXhrObservable, initFetchObservable, computeStackTrace, toStackTraceString, monitor, noop, readBytesFromStream, tryToClone, } from '@datadog/browser-core';

if (context.state === 'complete') {
handleResponse("xhr" /* XHR */, context);
handleResponse("xhr" /* RequestType.XHR */, context);
}

@@ -15,3 +15,3 @@ });

if (context.state === 'resolve') {
handleResponse("fetch" /* FETCH */, context);
handleResponse("fetch" /* RequestType.FETCH */, context);
}

@@ -32,3 +32,3 @@ });

function onResponseDataAvailable(responseData) {
lifeCycle.notify(0 /* RAW_LOG_COLLECTED */, {
lifeCycle.notify(0 /* LifeCycleEventType.RAW_LOG_COLLECTED */, {
rawLogsEvent: {

@@ -135,3 +135,3 @@ message: "".concat(format(type), " error ").concat(request.method, " ").concat(request.url),

function format(type) {
if ("xhr" /* XHR */ === type) {
if ("xhr" /* RequestType.XHR */ === type) {
return 'XHR';

@@ -138,0 +138,0 @@ }

@@ -24,3 +24,3 @@ var _a;

}
lifeCycle.notify(0 /* RAW_LOG_COLLECTED */, {
lifeCycle.notify(0 /* LifeCycleEventType.RAW_LOG_COLLECTED */, {
rawLogsEvent: {

@@ -27,0 +27,0 @@ date: timeStampNow(),

@@ -10,3 +10,3 @@ import { noop, ErrorSource, trackRuntimeError, Observable } from '@datadog/browser-core';

var rawErrorSubscription = rawErrorObservable.subscribe(function (rawError) {
lifeCycle.notify(0 /* RAW_LOG_COLLECTED */, {
lifeCycle.notify(0 /* LifeCycleEventType.RAW_LOG_COLLECTED */, {
rawLogsEvent: {

@@ -13,0 +13,0 @@ message: rawError.message,

@@ -7,3 +7,3 @@ import type { RelativeTime } from '@datadog/browser-core';

}
export declare type LogsSession = {
export type LogsSession = {
id?: string;

@@ -10,0 +10,0 @@ };

@@ -10,3 +10,3 @@ import { performDraw, startSessionManager } from '@datadog/browser-core';

var session = sessionManager.findActiveSession(startTime);
return session && session.trackingType === "1" /* TRACKED */
return session && session.trackingType === "1" /* LoggerTrackingType.TRACKED */
? {

@@ -20,3 +20,3 @@ id: session.id,

export function startLogsSessionManagerStub(configuration) {
var isTracked = computeTrackingType(configuration) === "1" /* TRACKED */;
var isTracked = computeTrackingType(configuration) === "1" /* LoggerTrackingType.TRACKED */;
var session = isTracked ? {} : undefined;

@@ -29,5 +29,5 @@ return {

if (!performDraw(configuration.sessionSampleRate)) {
return "0" /* NOT_TRACKED */;
return "0" /* LoggerTrackingType.NOT_TRACKED */;
}
return "1" /* TRACKED */;
return "1" /* LoggerTrackingType.TRACKED */;
}

@@ -38,8 +38,8 @@ function computeSessionState(configuration, rawSessionType) {

trackingType: trackingType,
isTracked: trackingType === "1" /* TRACKED */,
isTracked: trackingType === "1" /* LoggerTrackingType.TRACKED */,
};
}
function hasValidLoggerSession(trackingType) {
return trackingType === "0" /* NOT_TRACKED */ || trackingType === "1" /* TRACKED */;
return trackingType === "0" /* LoggerTrackingType.NOT_TRACKED */ || trackingType === "1" /* LoggerTrackingType.TRACKED */;
}
//# sourceMappingURL=logsSessionManager.js.map
import type { Context, ErrorSource, TimeStamp, User } from '@datadog/browser-core';
import type { StatusType } from './domain/logger';
export declare type RawLogsEvent = RawConsoleLogsEvent | RawNetworkLogsEvent | RawLoggerLogsEvent | RawAgentLogsEvent | RawReportLogsEvent | RawRuntimeLogsEvent;
declare type Error = {
export type RawLogsEvent = RawConsoleLogsEvent | RawNetworkLogsEvent | RawLoggerLogsEvent | RawAgentLogsEvent | RawReportLogsEvent | RawRuntimeLogsEvent;
type Error = {
kind?: string;

@@ -6,0 +6,0 @@ origin: ErrorSource;

@@ -5,3 +5,3 @@ import { startBatchWithReplica } from '@datadog/browser-core';

var batch = startBatchWithReplica(configuration, configuration.logsEndpointBuilder, reportError, pageExitObservable, (_a = configuration.replica) === null || _a === void 0 ? void 0 : _a.logsEndpointBuilder);
lifeCycle.subscribe(1 /* LOG_COLLECTED */, function (serverLogsEvent) {
lifeCycle.subscribe(1 /* LifeCycleEventType.LOG_COLLECTED */, function (serverLogsEvent) {
batch.add(serverLogsEvent);

@@ -8,0 +8,0 @@ });

import { getEventBridge } from '@datadog/browser-core';
export function startLogsBridge(lifeCycle) {
var bridge = getEventBridge();
lifeCycle.subscribe(1 /* LOG_COLLECTED */, function (serverLogsEvent) {
lifeCycle.subscribe(1 /* LifeCycleEventType.LOG_COLLECTED */, function (serverLogsEvent) {
bridge.send('log', serverLogsEvent);

@@ -6,0 +6,0 @@ });

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

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

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

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

},
"gitHead": "bcd2446e1d5f38c915f5fb581421bfd3fdd8dab6"
"gitHead": "058831610a12a72ff5e650e47a6ce8cfe9e20012"
}

@@ -26,3 +26,3 @@ # Browser Log Collection

| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 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. |
| 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. |

@@ -74,3 +74,3 @@ | 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. |

**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.
**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.

@@ -153,3 +153,3 @@ ### CDN sync

```
logger.debug | info | warn | error (message: string, messageContext = Context)
logger.debug | info | warn | error (message: string, messageContext?: Context, error?: Error)
```

@@ -173,3 +173,3 @@

**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.
**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.

@@ -186,3 +186,3 @@ #### CDN sync

The results are the same when using NPM, CDN async or CDN sync:
The results are the same when using NPM, CDN async, or CDN sync:

@@ -227,8 +227,8 @@ ```json

### Status parameter
### Error tracking
After the Datadog browser logs SDK is initialized, send a custom log entry to Datadog with the API using the status as a parameter:
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.
```
log (message: string, messageContext: Context, status? = 'debug' | 'info' | 'warn' | 'error')
logger.debug | info | warn | error (message: string, messageContext?: Context, error?: Error)
```

@@ -238,2 +238,74 @@

```javascript
import { datadogLogs } from '@datadog/browser-logs'
try {
...
throw new Error('Wrong behavior')
...
} catch (ex) {
datadogLogs.logger.error('Error occurred', {}, 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:

@@ -244,3 +316,3 @@

datadogLogs.logger.log(<MESSAGE>,<JSON_ATTRIBUTES>,<STATUS>);
datadogLogs.logger.log(<MESSAGE>,<JSON_ATTRIBUTES>,<STATUS>,<ERROR>);
```

@@ -254,7 +326,7 @@

DD_LOGS.onReady(function() {
DD_LOGS.logger.log(<MESSAGE>,<JSON_ATTRIBUTES>,<STATUS>);
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.
**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.

@@ -266,3 +338,3 @@ #### CDN sync

```javascript
window.DD_LOGS && DD_LOGS.logger.log(<MESSAGE>,<JSON_ATTRIBUTES>,<STATUS>);
window.DD_LOGS && DD_LOGS.logger.log(<MESSAGE>,<JSON_ATTRIBUTES>,<STATUS>,<ERROR>);
```

@@ -279,2 +351,3 @@

| `<STATUS>` | The status of your log; accepted status values are `debug`, `info`, `warn`, or `error`. |
| `<ERROR>` | An instance of a [JavaScript Error][10] object. |

@@ -465,3 +538,3 @@ ## Advanced usage

**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.
**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.

@@ -564,3 +637,3 @@ ##### CDN sync

**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.
**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.

@@ -653,3 +726,3 @@ ##### CDN sync

**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.
**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.

@@ -711,3 +784,3 @@ ##### CDN sync

**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.
**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.

@@ -756,3 +829,3 @@ ##### CDN sync

**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.
**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.

@@ -803,3 +876,3 @@ ##### CDN sync

**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.
**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.

@@ -866,1 +939,2 @@ ##### CDN sync

[9]: https://docs.datadoghq.com/getting_started/site/
[10]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
import type { Context, InitConfiguration, User } from '@datadog/browser-core'
import {
isExperimentalFeatureEnabled,
assign,

@@ -14,2 +15,3 @@ BoundedBuffer,

sanitizeUser,
sanitize,
} from '@datadog/browser-core'

@@ -122,6 +124,6 @@ import type { LogsInitConfiguration } from '../domain/configuration'

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

@@ -128,0 +130,0 @@

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

@@ -14,2 +15,3 @@ computeRawError,

monitored,
sanitize,
} from '@datadog/browser-core'

@@ -83,7 +85,14 @@ import type { LogsEvent } from '../logsEvent.types'

const sanitizedMessageContext = (
isExperimentalFeatureEnabled('sanitize_inputs') ? sanitize(messageContext) : deepClone(messageContext)
) as Context
const context = errorContext
? (combine({ error: errorContext }, messageContext) as Context)
: (deepClone(messageContext) as Context)
? (combine({ error: errorContext }, sanitizedMessageContext) as Context)
: sanitizedMessageContext
this.handleLogStrategy({ message, context, status }, this)
this.handleLogStrategy(
{ message: isExperimentalFeatureEnabled('sanitize_inputs') ? sanitize(message)! : message, context, status },
this
)
}

@@ -90,0 +99,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc