Socket
Socket
Sign inDemoInstall

@datadog/browser-logs

Package Overview
Dependencies
Maintainers
1
Versions
253
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 5.4.0 to 5.5.0

cjs/domain/logsTelemetry.d.ts

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=console,n={};Object.keys(e).forEach((function(e){n[e]=t[e]}));var r="Datadog Browser SDK:",o={debug:n.debug.bind(t,r),log:n.log.bind(t,r),info:n.info.bind(t,r),warn:n.warn.bind(t,r),error:n.error.bind(t,r)};function i(e,t){return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];try{return e.apply(void 0,n)}catch(e){o.error(t,e)}}}var a,s=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))},u=!1;function c(e){u=e}function f(e,t,n){var r=n.value;n.value=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return(a?l(r):r).apply(this,e)}}function l(e){return function(){return d(e,this,arguments)}}function d(e,t,n){try{return e.apply(t,n)}catch(e){if(p(e),a)try{a(e)}catch(e){p(e)}}}function p(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];u&&o.error.apply(o,s(["[MONITOR]"],e,!1))}function v(e,t){return-1!==e.indexOf(t)}function g(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 h(e){return Object.keys(e).map((function(t){return e[t]}))}function y(e,t){return e.slice(0,t.length)===t}function m(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return t.forEach((function(t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})),e}function b(){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}var E=1024,w=1024*E,S=/[^\u0000-\u007F]/;function C(e){return S.test(e)?void 0!==window.TextEncoder?(new TextEncoder).encode(e).length:new Blob([e]).size:e.length}function _(e,t){var n,r=b();return r.Zone&&"function"==typeof r.Zone.__symbol__&&(n=e[r.Zone.__symbol__(t)]),n||(n=e[t]),n}function x(e,t){return _(b(),"setTimeout")(l(e),t)}function O(e){_(b(),"clearTimeout")(e)}function k(e,t){return _(b(),"setInterval")(l(e),t)}function T(e){_(b(),"clearInterval")(e)}function R(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=x((function(){a&&r&&e.apply(void 0,r),s=!1,r=void 0}),t))},cancel:function(){O(o),s=!1,r=void 0}}}function L(){}function A(e){return null===e?"null":Array.isArray(e)?"array":typeof e}function I(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]=I(o[i],t[i],n);return o}var a="object"===A(e)?e:{};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(a[s]=I(a[s],t[s],n));return a}}function P(e){return I(void 0,e)}function N(){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=I(e,i))}return e}function B(e,t,n){if("object"!=typeof e||null===e)return JSON.stringify(e);var r=U(Object.prototype),o=U(Array.prototype),i=U(Object.getPrototypeOf(e)),a=U(e);try{return JSON.stringify(e,t,n)}catch(e){return"<error: unable to serialize object>"}finally{r(),o(),i(),a()}}function U(e){var t=e,n=t.toJSON;return n?(delete t.toJSON,function(){t.toJSON=n}):L}var D=220*E,M="$",q=3;function j(e,t){var n;void 0===t&&(t=D);var r=U(Object.prototype),o=U(Array.prototype),i=[],a=new WeakMap,s=H(e,M,void 0,i,a),u=(null===(n=JSON.stringify(s))||void 0===n?void 0:n.length)||0;if(!(u>t)){for(;i.length>0&&u<t;){var c=i.shift(),f=0;if(Array.isArray(c.source))for(var l=0;l<c.source.length;l++){if(u+=void 0!==(d=H(c.source[l],c.path,l,i,a))?JSON.stringify(d).length:4,u+=f,f=1,u>t){G(t,"truncated",e);break}c.target[l]=d}else for(var l in c.source)if(Object.prototype.hasOwnProperty.call(c.source,l)){var d;if(void 0!==(d=H(c.source[l],c.path,l,i,a))&&(u+=JSON.stringify(d).length+f+l.length+q,f=1),u>t){G(t,"truncated",e);break}c.target[l]=d}}return r(),o(),s}G(t,"discarded",e)}function H(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&&"[Error]"!==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 G(e,t,n){o.warn("The data provided has been ".concat(t," as it is over the limit of ").concat(e," characters:"),n)}var F,V=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 z(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=new V((function(){var t=e.map((function(e){return e.subscribe((function(e){return n.notify(e)}))}));return function(){return t.forEach((function(e){return e.unsubscribe()}))}}));return n}var Y=3*E,J=((F={})[0]="feature flag evaluation",F[1]="user",F[2]="global context",F[3]="logger context",F);var W=200;function K(e,t){void 0===t&&(t=C);var n,r={},i=!1,a=new V,s=R((function(r){n=t(B(r)),i||(i=function(e,t){return e>Y&&(o.warn("The ".concat(J[t]," data exceeds the recommended ").concat(Y/E,"KiB threshold. More details: https://docs.datadoghq.com/real_user_monitoring/browser/troubleshooting/#customer-data-exceeds-the-recommended-3kib-warning")),!0)}(n,e))}),W).throttled,u={getBytesCount:function(){return n},getContext:function(){return P(r)},setContext:function(e){"object"===A(e)?(r=j(e),s(r)):u.clearContext(),a.notify()},setContextProperty:function(e,t){r[e]=j(t),s(r),a.notify()},removeContextProperty:function(e){delete r[e],s(r),a.notify()},clearContext:function(){r={},n=0,a.notify()},changeObservable:a};return u}var $,Z,X=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}(),Q=1e3,ee=60*Q,te=60*ee;function ne(){return(new Date).getTime()}function re(){return ne()}function oe(){return performance.now()}function ie(){return{relative:oe(),timeStamp:re()}}function ae(e,t){return e+t}function se(){return void 0===$&&($=performance.timing.navigationStart),$}function ue(){var e=b().DatadogEventBridge;if(e)return{getAllowedWebViewHosts:function(){return JSON.parse(e.getAllowedWebViewHosts())},send:function(t,n){e.send(JSON.stringify({eventType:t,event:n}))}}}function ce(e){var t;void 0===e&&(e=null===(t=b().location)||void 0===t?void 0:t.hostname);var n=ue();return!!n&&n.getAllowedWebViewHosts().some((function(t){return e===t||(n=e,r=".".concat(t),n.slice(-r.length)===r);var n,r}))}function fe(e,t,n,r,o){return le(e,t,[n],r,o)}function le(e,t,n,r,o){var i=void 0===o?{}:o,a=i.once,s=i.capture,u=i.passive,c=l((function(t){(t.isTrusted||t.__ddIsTrusted||e.allowUntrustedEvents)&&(a&&p(),r(t))})),f=u?{capture:s,passive:u}:s,d=_(t,"addEventListener");function p(){var e=_(t,"removeEventListener");n.forEach((function(n){return e.call(t,n,c,f)}))}return n.forEach((function(e){return d.call(t,e,c,f)})),{stop:p}}!function(e){e.BEFORE_UNLOAD="beforeunload",e.CLICK="click",e.DBL_CLICK="dblclick",e.KEY_DOWN="keydown",e.LOAD="load",e.POP_STATE="popstate",e.SCROLL="scroll",e.TOUCH_START="touchstart",e.TOUCH_END="touchend",e.TOUCH_MOVE="touchmove",e.VISIBILITY_CHANGE="visibilitychange",e.PAGE_SHOW="pageshow",e.FREEZE="freeze",e.RESUME="resume",e.DOM_CONTENT_LOADED="DOMContentLoaded",e.POINTER_DOWN="pointerdown",e.POINTER_UP="pointerup",e.POINTER_CANCEL="pointercancel",e.HASH_CHANGE="hashchange",e.PAGE_HIDE="pagehide",e.MOUSE_DOWN="mousedown",e.MOUSE_UP="mouseup",e.MOUSE_MOVE="mousemove",e.FOCUS="focus",e.BLUR="blur",e.CONTEXT_MENU="contextmenu",e.RESIZE="resize",e.CHANGE="change",e.INPUT="input",e.PLAY="play",e.PAUSE="pause",e.SECURITY_POLICY_VIOLATION="securitypolicyviolation",e.SELECTION_CHANGE="selectionchange",e.STORAGE="storage"}(Z||(Z={}));var de,pe="_dd_c",ve=[];function ge(e,t,n,r){void 0===r&&(r=C);var o=function(e,t){return"".concat(pe,"_").concat(e,"_").concat(t)}(t,n),i=K(n,r);return a(),ve.push(fe(e,window,Z.STORAGE,(function(e){var t=e.key;o===t&&a()}))),i.changeObservable.subscribe((function(){localStorage.setItem(o,JSON.stringify(i.getContext()))})),i;function a(){var e=localStorage.getItem(o),t=null!==e?JSON.parse(e):{};i.setContext(t)}}function he(e){var t=m({},e);return["id","name","email"].forEach((function(e){e in t&&(t[e]=String(t[e]))})),t}!function(e){e.PAGEHIDE="pagehide",e.FEATURE_FLAGS="feature_flags",e.RESOURCE_PAGE_STATES="resource_page_states",e.COLLECT_FLUSH_REASON="collect_flush_reason",e.SCROLLMAP="scrollmap",e.DISABLE_REPLAY_INLINE_CSS="disable_replay_inline_css"}(de||(de={}));var ye=new Set;function me(e){return ye.has(e)}function be(){return ye}function Ee(e){return 0!==e&&100*Math.random()<=e}function we(e){return function(e){return"number"==typeof e}(e)&&e>=0&&e<=100}function Se(e){return 0===Object.keys(e).length}function Ce(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,Ce)}var _e=/([\w-]+)\s*=\s*([^;]+)/g;function xe(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)}var Oe,ke,Te,Re=4*te,Le=15*ee;function Ae(){return null!=Oe?Oe:Oe=function(e){var t;void 0===e&&(e=window);var n=e.navigator.userAgent;if(e.chrome||/HeadlessChrome/.test(n))return 1;if(0===(null===(t=e.navigator.vendor)||void 0===t?void 0:t.indexOf("Apple"))||/safari/i.test(n)&&!/chrome|android/i.test(n))return 2;if(e.document.documentMode)return 0;return 3}()}function Ie(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 Pe(e){return function(e,t){for(_e.lastIndex=0;;){var n=_e.exec(e);if(!n)break;if(n[1]===t)return n[2]}}(document.cookie,e)}function Ne(e){return ke||(ke=function(e){var t=new Map;for(_e.lastIndex=0;;){var n=_e.exec(e);if(!n)break;t.set(n[1],n[2])}return t}(document.cookie)),ke.get(e)}function Be(e,t){Ie(e,"",0,t)}var Ue="_dd_s",De=/^([a-z]+)=([a-z0-9-]+)$/,Me="&";function qe(e){return Se(e)}function je(e){e.expire=String(ne()+Le)}function He(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(Me);var t}function Ge(e){var t={};return function(e){return!!e&&(-1!==e.indexOf(Me)||De.test(e))}(e)&&e.split(Me).forEach((function(e){var n=De.exec(e);if(null!==n){var r=n[1],o=n[2];t[r]=o}})),t}var Fe="_dd",Ve="_dd_r",ze="_dd_l",Ye="rum",Je="logs";function We(e){var t=function(e){var t={};t.secure=!!e.useSecureSessionCookie||!!e.useCrossSiteSessionCookie,t.crossSite=!!e.useCrossSiteSessionCookie,e.trackSessionAcrossSubdomains&&(t.domain=function(){if(void 0===Te){for(var e="dd_site_test_".concat(Ce()),t=window.location.hostname.split("."),n=t.pop();t.length&&!Pe(e);)n="".concat(t.pop(),".").concat(n),Ie(e,"test",Q,{domain:n});Be(e,{domain:n}),Te=n}return Te}());return t}(e);return function(e){if(void 0===document.cookie||null===document.cookie)return!1;try{var t="dd_cookie_test_".concat(Ce()),n="test";Ie(t,n,ee,e);var r=Pe(t)===n;return Be(t,e),r}catch(e){return o.error(e),!1}}(t)?{type:"Cookie",cookieOptions:t}:void 0}function Ke(e){var t,n={isLockEnabled:1===Ae(),persistSession:(t=e,function(e){Ie(Ue,He(e),Le,t)}),retrieveSession:$e,clearSession:Ze(e)};return function(e){if(!Ne(Ue)){var t=Ne(Fe),n=Ne(Ve),r=Ne(ze),o={};t&&(o.id=t),r&&/^[01]$/.test(r)&&(o[Je]=r),n&&/^[012]$/.test(n)&&(o[Ye]=n),qe(o)||(je(o),e.persistSession(o))}}(n),n}function $e(){return Ge(Pe(Ue))}function Ze(e){return function(){Be(Ue,e)}}var Xe="_dd_test_";function Qe(e){localStorage.setItem(Ue,He(e))}function et(){return Ge(localStorage.getItem(Ue))}function tt(){localStorage.removeItem(Ue)}var nt,rt=10,ot=100,it=[];function at(e,t,n){var r;void 0===n&&(n=0);var o=t.isLockEnabled,i=t.retrieveSession,a=t.persistSession,s=t.clearSession;if(nt||(nt=e),e===nt)if(o&&n>=ot)ut(t);else{var u,c=i();if(o){if(c.lock)return void st(e,t,n);if(u=Ce(),c.lock=u,a(c),(c=i()).lock!==u)return void st(e,t,n)}var f=e.process(c);if(o&&(c=i()).lock!==u)st(e,t,n);else{if(f&&(qe(f)?s():(je(f),a(f))),o&&(!f||!qe(f))){if((c=i()).lock!==u)return void st(e,t,n);delete c.lock,a(c),f=c}null===(r=e.after)||void 0===r||r.call(e,f||c),ut(t)}}else it.push(e)}function st(e,t,n){x((function(){at(e,t,n+1)}),rt)}function ut(e){nt=void 0;var t=it.shift();t&&at(t,e)}var ct=Q;function ft(e){var t=We(e);return!t&&e.allowFallbackToLocalStorage&&(t=function(){try{var e=Ce(),t="".concat(Xe).concat(e);localStorage.setItem(t,e);var n=localStorage.getItem(t);return localStorage.removeItem(t),e===n?{type:"LocalStorage"}:void 0}catch(e){return}}()),t}function lt(e,t,n){var r=new V,o=new V,i="Cookie"===e.type?Ke(e.cookieOptions):{isLockEnabled:!1,persistSession:Qe,retrieveSession:et,clearSession:tt},a=i.clearSession,s=i.retrieveSession,u=k((function(){at({process:function(e){return d(e)?void 0:{}},after:f},i)}),ct),c=function(){var e=s();if(d(e))return e;return{}}();function f(e){return d(e)||(e={}),l()&&(!function(e){return c.id!==e.id||c[t]!==e[t]}(e)?c=e:(c={},o.notify())),e}function l(){return void 0!==c[t]}function d(e){return(void 0===e.created||ne()-Number(e.created)<Re)&&(void 0===e.expire||ne()<Number(e.expire))}return{expandOrRenewSession:R((function(){var e;at({process:function(r){var o=f(r);return e=function(e){var r=n(e[t]),o=r.trackingType,i=r.isTracked;e[t]=o,i&&!e.id&&(e.id=Ce(),e.created=String(ne()));return i}(o),o},after:function(t){e&&!l()&&function(e){c=e,r.notify()}(t),c=t}},i)}),ct).throttled,expandSession:function(){at({process:function(e){return l()?f(e):void 0}},i)},getSession:function(){return c},renewObservable:r,expireObservable:o,expire:function(){a(),f({})},stop:function(){T(u)}}}function dt(e){return pt(e,ht(window.location)).href}function pt(e,t){var n=function(){if(void 0===vt)try{var e=new gt("http://test/path");vt="http://test/path"===e.href}catch(e){vt=!1}return vt?gt:void 0}();if(n)try{return void 0!==t?new n(e,t):new n(e)}catch(n){throw new Error("Failed to construct URL: ".concat(String(n)," ").concat(B({url:e,base:t})))}if(void 0===t&&!/:/.test(e))throw new Error("Invalid URL: '".concat(e,"'"));var r=document,o=r.createElement("a");if(void 0!==t){var i=(r=document.implementation.createHTMLDocument("")).createElement("base");i.href=t,r.head.appendChild(i),r.body.appendChild(o)}return o.href=e,o}var vt,gt=URL;function ht(e){if(e.origin&&"null"!==e.origin)return e.origin;var t=e.host.replace(/(:80|:443)$/,"");return"".concat(e.protocol,"//").concat(t)}var yt="datad0g.com",mt="datadoghq.com";function bt(e,t,n){var r=function(e,t){var n="/api/v2/".concat(t),r=e.proxy;if("string"==typeof r){var o=dt(r);return function(e){return"".concat(o,"?ddforward=").concat(encodeURIComponent("".concat(n,"?").concat(e)))}}if("function"==typeof r)return function(e){return r({path:n,parameters:e})};var i=function(e){var t=e.site,n=void 0===t?mt:t,r=e.internalAnalyticsSubdomain;if(r&&n===mt)return"".concat(r,".").concat(mt);var o=n.split("."),i=o.pop();return"browser-intake-".concat(o.join("-"),".").concat(i)}(e);return function(e){return"https://".concat(i).concat(n,"?").concat(e)}}(e,t);return{build:function(o,i){var a=function(e,t,n,r,o){var i=e.clientToken,a=e.internalAnalyticsSubdomain,s=o.retry,u=o.flushReason,c=o.encoding,f=["sdk_version:".concat("5.4.0"),"api:".concat(r)].concat(n);u&&me(de.COLLECT_FLUSH_REASON)&&f.push("flush_reason:".concat(u));s&&f.push("retry_count:".concat(s.count),"retry_after:".concat(s.lastFailureStatus));var l=["ddsource=browser","ddtags=".concat(encodeURIComponent(f.join(","))),"dd-api-key=".concat(i),"dd-evp-origin-version=".concat(encodeURIComponent("5.4.0")),"dd-evp-origin=browser","dd-request-id=".concat(Ce())];c&&l.push("dd-evp-encoding=".concat(c));"rum"===t&&l.push("batch_time=".concat(re()));a&&l.reverse();return l.join("&")}(e,t,n,o,i);return r(a)},urlPrefix:r(""),trackType:t}}var Et=200;var wt=/[^a-z0-9_:./-]/;function St(e,t){var n=Et-e.length-1;(t.length>n||wt.test(t))&&o.warn("".concat(e," value doesn't meet tag requirements and will be sanitized"));var r=t.replace(/,/g,"_");return"".concat(e,":").concat(r)}function Ct(e){var t=function(e){var t=e.env,n=e.service,r=e.version,o=e.datacenter,i=[];return t&&i.push(St("env",t)),n&&i.push(St("service",n)),r&&i.push(St("version",r)),o&&i.push(St("datacenter",o)),i}(e),n=function(e,t){return{logsEndpointBuilder:bt(e,"logs",t),rumEndpointBuilder:bt(e,"rum",t),sessionReplayEndpointBuilder:bt(e,"replay",t)}}(e,t),r=h(n).map((function(e){return e.urlPrefix})),o=function(e,t,n){if(!e.replica)return;var r=m({},e,{site:mt,clientToken:e.replica.clientToken}),o={logsEndpointBuilder:bt(r,"logs",n),rumEndpointBuilder:bt(r,"rum",n)};return t.push.apply(t,h(o).map((function(e){return e.urlPrefix}))),m({applicationId:e.replica.applicationId},o)}(e,r,t);return m({isIntakeUrl:function(e){return r.some((function(t){return 0===e.indexOf(t)}))},replica:o,site:e.site||mt},n)}function _t(e){var t,n,r;if(e&&e.clientToken)if(void 0===e.sessionSampleRate||we(e.sessionSampleRate))if(void 0===e.telemetrySampleRate||we(e.telemetrySampleRate)){if(void 0===e.telemetryConfigurationSampleRate||we(e.telemetryConfigurationSampleRate))return Array.isArray(e.enableExperimentalFeatures)&&e.enableExperimentalFeatures.filter((function(e){return t=de,n=e,Object.keys(t).some((function(e){return t[e]===n}));var t,n})).forEach((function(e){ye.add(e)})),m({beforeSend:e.beforeSend&&i(e.beforeSend,"beforeSend threw an error:"),sessionStoreStrategyType:ft(e),sessionSampleRate:null!==(t=e.sessionSampleRate)&&void 0!==t?t:100,telemetrySampleRate:null!==(n=e.telemetrySampleRate)&&void 0!==n?n:20,telemetryConfigurationSampleRate:null!==(r=e.telemetryConfigurationSampleRate)&&void 0!==r?r:5,service:e.service,silentMultipleInit:!!e.silentMultipleInit,allowUntrustedEvents:!!e.allowUntrustedEvents,batchBytesLimit:16*E,eventRateLimiterThreshold:3e3,maxTelemetryEventsPerPage:15,flushTimeout:30*Q,batchMessagesLimit:50,messageBytesLimit:256*E},Ct(e));o.error("Telemetry Configuration Sample Rate should be a number between 0 and 100")}else o.error("Telemetry Sample Rate should be a number between 0 and 100");else o.error("Session Sample Rate should be a number between 0 and 100");else o.error("Client Token is not configured, we will not send any data.")}var xt="?";function Ot(e){var t=[],n=Bt(e,"stack"),r=String(e);return n&&y(n,r)&&(n=n.slice(r.length)),n&&n.split("\n").forEach((function(e){var n=function(e){var t=Rt.exec(e);if(!t)return;var n=t[2]&&0===t[2].indexOf("native"),r=t[2]&&0===t[2].indexOf("eval"),o=Lt.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]||xt,line:t[3]?+t[3]:void 0,url:n?void 0:t[2]}}(e)||function(e){var t=At.exec(e);if(!t)return;return{args:[],column:t[3]?+t[3]:void 0,func:xt,line:t[2]?+t[2]:void 0,url:t[1]}}(e)||function(e){var t=It.exec(e);if(!t)return;return{args:[],column:t[4]?+t[4]:void 0,func:t[1]||xt,line:+t[3],url:t[2]}}(e)||function(e){var t=Pt.exec(e);if(!t)return;var n=t[3]&&t[3].indexOf(" > eval")>-1,r=Nt.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]||xt,line:t[4]?+t[4]:void 0,url:t[3]}}(e);n&&(!n.func&&n.line&&(n.func=xt),t.push(n))})),{message:Bt(e,"message"),name:Bt(e,"name"),stack:t}}var kt="((?:file|https?|blob|chrome-extension|native|eval|webpack|snippet|<anonymous>|\\w+\\.|\\/).*?)",Tt="(?::(\\d+))",Rt=new RegExp("^\\s*at (.*?) ?\\(".concat(kt).concat(Tt,"?").concat(Tt,"?\\)?\\s*$"),"i"),Lt=new RegExp("\\((\\S*)".concat(Tt).concat(Tt,"\\)"));var At=new RegExp("^\\s*at ?".concat(kt).concat(Tt,"?").concat(Tt,"??\\s*$"),"i");var It=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;var Pt=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|capacitor|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i,Nt=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;function Bt(e,t){if("object"==typeof e&&e&&t in e){var n=e[t];return"string"==typeof n?n:void 0}}function Ut(e,t,n,r){var o=[{url:t,column:r,line:n}],i=function(e){var t,n,r;"[object String]"==={}.toString.call(e)&&(n=(t=Dt.exec(e))[1],r=t[2]);return{name:n,message:r}}(e);return{name:i.name,message:i.message,stack:o}}var Dt=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?([\s\S]*)$/;var Mt="No stack, consider using an instance of Error";function qt(e){var t=e.stackTrace,n=e.originalError,r=e.handlingStack,o=e.startClocks,i=e.nonErrorPrefix,a=e.source,s=e.handling,u=n instanceof Error,c=function(e,t,n,r){return(null==e?void 0:e.message)&&(null==e?void 0:e.name)?e.message:t?"Empty message":"".concat(n," ").concat(B(j(r)))}(t,u,i,n),f=function(e,t){if(void 0===t)return!1;if(e)return!0;return t.stack.length>0&&(t.stack.length>1||void 0!==t.stack[0].url)}(u,t)?Ht(t):Mt,l=u?function(e,t){var n=e,r=[];for(;(null==n?void 0:n.cause)instanceof Error&&r.length<10;){var o=Ot(n.cause);r.push({message:n.cause.message,source:t,type:null==o?void 0:o.name,stack:o&&Ht(o)}),n=n.cause}return r.length?r:void 0}(n,a):void 0;return{startClocks:o,source:a,handling:s,handlingStack:r,originalError:n,type:null==t?void 0:t.name,message:c,stack:f,causes:l,fingerprint:jt(n)}}function jt(e){return e instanceof Error&&"dd_fingerprint"in e?String(e.dd_fingerprint):void 0}function Ht(e){var t=Gt(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 Gt(e){return"".concat(e.name||"Error",": ").concat(e.message)}var Ft={intervention:"intervention",deprecation:"deprecation",cspViolation:"csp_violation"};function Vt(e,t){var n=[];v(t,Ft.cspViolation)&&n.push(function(e){var t=new V((function(){return fe(e,document,Z.SECURITY_POLICY_VIOLATION,(function(e){t.notify(function(e){var t=Ft.cspViolation,n="'".concat(e.blockedURI,"' blocked by '").concat(e.effectiveDirective,"' directive");return{type:Ft.cspViolation,subtype:e.effectiveDirective,message:"".concat(t,": ").concat(n),stack:zt(e.effectiveDirective,e.originalPolicy?"".concat(n,' of the policy "').concat(xe(e.originalPolicy,100,"..."),'"'):"no policy",e.sourceFile,e.lineNumber,e.columnNumber)}}(e))})).stop}));return t}(e));var r=t.filter((function(e){return e!==Ft.cspViolation}));return r.length&&n.push(function(e){var t=new V((function(){if(window.ReportingObserver){var n=l((function(e,n){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:zt(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)),z.apply(void 0,n)}function zt(e,t,n,r,o){return n?Ht({name:e,message:t,stack:[{func:"?",url:n,line:null!=r?r:void 0,column:null!=o?o:void 0}]}):void 0}var Yt=32*E;function Jt(e,t,n){return void 0===e?[]:"all"===e||Array.isArray(e)&&e.every((function(e){return v(t,e)}))?"all"===e?t:(r=e,i=new Set,r.forEach((function(e){return i.add(e)})),g(i)):void o.error("".concat(n,' should be "all" or an array with allowed values "').concat(t.join('", "'),'"'));var r,i}var Wt={AGENT:"agent",CONSOLE:"console",CUSTOM:"custom",LOGGER:"logger",NETWORK:"network",SOURCE:"source",REPORT:"report"},Kt=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},$t={debug:"debug",error:"error",info:"info",warn:"warn"},Zt={console:"console",http:"http",silent:"silent"},Xt=Object.keys($t),Qt=function(){function e(e,t,n,r,o){void 0===n&&(n=Zt.http),void 0===r&&(r=$t.debug),void 0===o&&(o={}),this.handleLogStrategy=e,this.handlerType=n,this.level=r,this.contextManager=K(3),this.contextManager.setContext(o),t&&this.contextManager.setContextProperty("logger",{name:t})}return e.prototype.log=function(e,t,n,r){var o;if(void 0===n&&(n=$t.info),null!=r){var i=qt({stackTrace:r instanceof Error?Ot(r):void 0,originalError:r,nonErrorPrefix:"Provided",source:Wt.LOGGER,handling:"handled",startClocks:ie()});o={stack:i.stack,kind:i.type,message:i.message}}var a=j(t),s=o?N({error:o},a):a;this.handleLogStrategy({message:j(e),context:s,status:n},this)},e.prototype.debug=function(e,t,n){this.log(e,t,$t.debug,n)},e.prototype.info=function(e,t,n){this.log(e,t,$t.info,n)},e.prototype.warn=function(e,t,n){this.log(e,t,$t.warn,n)},e.prototype.error=function(e,t,n){this.log(e,t,$t.error,n)},e.prototype.setContext=function(e){this.contextManager.setContext(e)},e.prototype.getContext=function(){return this.contextManager.getContext()},e.prototype.setContextProperty=function(e,t){this.contextManager.setContextProperty(e,t)},e.prototype.removeContextProperty=function(e){this.contextManager.removeContextProperty(e)},e.prototype.clearContext=function(){this.contextManager.clearContext()},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},Kt([f],e.prototype,"log",null),e}(),en="logs";function tn(e,t){var n=window.__ddBrowserSdkExtensionCallback;n&&n({type:e,payload:t})}var nn,rn={log:"log",configuration:"configuration"},on=["https://www.datadoghq-browser-agent.com","https://www.datad0g-browser-agent.com","https://d3uc069fcn7uxw.cloudfront.net","https://d20xtzwzcl0ceb.cloudfront.net","http://localhost","<anonymous>"],an=["ddog-gov.com"],sn={maxEventsPerPage:0,sentEventCount:0,telemetryEnabled:!1,telemetryConfigurationEnabled:!1};function un(e,t){var n,r=new V;sn.telemetryEnabled=!v(an,t.site)&&Ee(t.telemetrySampleRate),sn.telemetryConfigurationEnabled=sn.telemetryEnabled&&Ee(t.telemetryConfigurationSampleRate);var o={is_local_file:"file:"===window.location.protocol,is_worker:"WorkerGlobalScope"in self};return nn=function(t){if(sn.telemetryEnabled){var i=function(e,t,r){return N({type:"telemetry",date:re(),service:e,version:"5.4.0",source:"browser",_dd:{format_version:2},telemetry:N(t,{runtime_env:r}),experimental_features:g(be())},void 0!==n?n():{})}(e,t,o);r.notify(i),tn("telemetry",i)}},a=fn,m(sn,{maxEventsPerPage:t.maxTelemetryEventsPerPage,sentEventCount:0}),{setContextProvider:function(e){n=e},observable:r,enabled:sn.telemetryEnabled}}function cn(t,n){p(e.debug,t,n),ln(m({type:rn.log,message:t,status:"debug"},n))}function fn(e,t){ln(m({type:rn.log,status:"error"},function(e){if(e instanceof Error){var t=Ot(e);return{error:{kind:t.name,stack:Ht(dn(t))},message:t.message}}return{error:{stack:Mt},message:"".concat("Uncaught"," ").concat(B(e))}}(e),t))}function ln(e){nn&&sn.sentEventCount<sn.maxEventsPerPage&&(sn.sentEventCount+=1,nn(e))}function dn(e){return e.stack=e.stack.filter((function(e){return!e.url||on.some((function(t){return y(e.url,t)}))})),e}var pn={HIDDEN:"visibility_hidden",UNLOADING:"before_unload",PAGEHIDE:"page_hide",FROZEN:"page_frozen"};var vn="datadog-synthetics-public-id",gn="datadog-synthetics-result-id",hn="datadog-synthetics-injects-rum";function yn(){return Boolean(window._DATADOG_SYNTHETICS_INJECTS_RUM||Ne(hn))}function mn(){var e=window._DATADOG_SYNTHETICS_RESULT_ID||Ne(gn);return"string"==typeof e?e:void 0}var bn=function(){function e(e,t,n,r){var o=this;this.encoder=e,this.request=t,this.flushController=n,this.messageBytesLimit=r,this.upsertBuffer={},this.flushSubscription=this.flushController.flushObservable.subscribe((function(e){return o.flush(e)}))}return e.prototype.add=function(e){this.addOrUpdate(e)},e.prototype.upsert=function(e,t){this.addOrUpdate(e,t)},e.prototype.stop=function(){this.flushSubscription.unsubscribe()},e.prototype.flush=function(e){var t=h(this.upsertBuffer).join("\n");this.upsertBuffer={};var n,r=(n=e.reason,v(h(pn),n)),o=r?this.request.sendOnExit:this.request.send;if(r&&this.encoder.isAsync){var i=this.encoder.finishSync();i.outputBytesCount&&o(En(i,e));var a=[i.pendingData,t].filter(Boolean).join("\n");a&&o({data:a,bytesCount:C(a),flushReason:e.reason})}else t&&this.encoder.write(this.encoder.isEmpty?t:"\n".concat(t)),this.encoder.finish((function(t){o(En(t,e))}))},e.prototype.addOrUpdate=function(e,t){var n=B(e),r=this.encoder.estimateEncodedBytesCount(n);r>=this.messageBytesLimit?o.warn("Discarded a message whose size was bigger than the maximum allowed size ".concat(this.messageBytesLimit,"KB.")):(this.hasMessageFor(t)&&this.remove(t),this.push(n,r,t))},e.prototype.push=function(e,t,n){var r=this;this.flushController.notifyBeforeAddMessage(t),void 0!==n?(this.upsertBuffer[n]=e,this.flushController.notifyAfterAddMessage()):this.encoder.write(this.encoder.isEmpty?e:"\n".concat(e),(function(e){r.flushController.notifyAfterAddMessage(e-t)}))},e.prototype.remove=function(e){var t=this.upsertBuffer[e];delete this.upsertBuffer[e];var n=this.encoder.estimateEncodedBytesCount(t);this.flushController.notifyAfterRemoveMessage(n)},e.prototype.hasMessageFor=function(e){return void 0!==e&&void 0!==this.upsertBuffer[e]},e}();function En(e,t){return{data:"string"==typeof e.output?e.output:new Blob([e.output],{type:"text/plain"}),bytesCount:e.outputBytesCount,encoding:e.encoding,flushReason:t.reason}}function wn(e){return e>=500}var Sn=80*E,Cn=32,_n=3*w,xn=ee,On=Q;function kn(e,t,n,r,o){0===t.transportStatus&&0===t.queuedPayloads.size()&&t.bandwidthMonitor.canHandle(e)?Rn(e,t,n,{onSuccess:function(){return Ln(0,t,n,r,o)},onFailure:function(){t.queuedPayloads.enqueue(e),Tn(t,n,r,o)}}):t.queuedPayloads.enqueue(e)}function Tn(e,t,n,r){2===e.transportStatus&&x((function(){Rn(e.queuedPayloads.first(),e,t,{onSuccess:function(){e.queuedPayloads.dequeue(),e.currentBackoffTime=On,Ln(1,e,t,n,r)},onFailure:function(){e.currentBackoffTime=Math.min(xn,2*e.currentBackoffTime),Tn(e,t,n,r)}})}),e.currentBackoffTime)}function Rn(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||wn(e.status))}(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 Ln(e,t,n,r,o){0===e&&t.queuedPayloads.isFull()&&!t.queueFullReported&&(o({message:"Reached max ".concat(r," events size queued for upload: ").concat(_n/w,"MiB"),source:Wt.AGENT,startClocks:ie()}),t.queueFullReported=!0);var i=t.queuedPayloads;for(t.queuedPayloads=An();i.size()>0;)kn(i.dequeue(),t,n,r,o)}function An(){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>=_n}}}function In(e,t,n,r){var o={transportStatus:0,currentBackoffTime:On,bandwidthMonitor:{ongoingRequestCount:0,ongoingByteCount:0,canHandle:function(e){return 0===this.ongoingRequestCount||this.ongoingByteCount+e.bytesCount<=Sn&&this.ongoingRequestCount<Cn},add:function(e){this.ongoingRequestCount+=1,this.ongoingByteCount+=e.bytesCount},remove:function(e){this.ongoingRequestCount-=1,this.ongoingByteCount-=e.bytesCount}},queuedPayloads:An(),queueFullReported:!1},i=function(r,o){return function(e,t,n,r,o){var i=function(){try{return window.Request&&"keepalive"in new Request("http://a")}catch(e){return!1}}()&&r.bytesCount<n;if(i){var a=t.build("fetch",r);fetch(a,{method:"POST",body:r.data,keepalive:!0,mode:"cors"}).then(l((function(e){return null==o?void 0:o({status:e.status,type:e.type})})),l((function(){var n=t.build("xhr",r);Nn(e,n,r.data,o)})))}else{var s=t.build("xhr",r);Nn(e,s,r.data,o)}}(e,t,n,r,o)};return{send:function(e){kn(e,o,i,t.trackType,r)},sendOnExit:function(r){!function(e,t,n,r){var o=!!navigator.sendBeacon&&r.bytesCount<n;if(o)try{var i=t.build("beacon",r);if(navigator.sendBeacon(i,r.data))return}catch(e){!function(e){Pn||(Pn=!0,fn(e))}(e)}var a=t.build("xhr",r);Nn(e,a,r.data)}(e,t,n,r)}}}var Pn=!1;function Nn(e,t,n,r){var o=new XMLHttpRequest;o.open("POST",t,!0),n instanceof Blob&&o.setRequestHeader("Content-Type",n.type),fe(e,o,"loadend",(function(){null==r||r({status:o.status})}),{once:!0}),o.send(n)}function Bn(e){var t,n=e.messagesLimit,r=e.bytesLimit,o=e.durationLimit,i=e.pageExitObservable,a=e.sessionExpireObservable,s=i.subscribe((function(e){return d(e.reason)})),u=a.subscribe((function(){return d("session_expire")})),c=new V((function(){return function(){s.unsubscribe(),u.unsubscribe()}})),f=0,l=0;function d(e){if(0!==l){var t=l,n=f;l=0,f=0,p(),c.notify({reason:e,messagesCount:t,bytesCount:n})}}function p(){O(t),t=void 0}return{flushObservable:c,get messagesCount(){return l},notifyBeforeAddMessage:function(e){f+e>=r&&d("bytes_limit"),l+=1,f+=e,void 0===t&&(t=x((function(){d("duration_limit")}),o))},notifyAfterAddMessage:function(e){void 0===e&&(e=0),f+=e,l>=n?d("messages_limit"):f>=r&&d("bytes_limit")},notifyAfterRemoveMessage:function(e){f-=e,0===(l-=1)&&p()}}}function Un(e,t,n,r,o,i){var a=u(e,t),s=n&&u(e,n);function u(e,t){var n=t.endpoint,a=t.encoder;return new bn(a,In(e,n,e.batchBytesLimit,r),Bn({messagesLimit:e.batchMessagesLimit,bytesLimit:e.batchBytesLimit,durationLimit:e.flushTimeout,pageExitObservable:o,sessionExpireObservable:i}),e.messageBytesLimit)}return{flushObservable:a.flushController.flushObservable,add:function(e,t){void 0===t&&(t=!0),a.add(e),s&&t&&s.add(n.transformMessage?n.transformMessage(e):e)},upsert:function(e,t){a.upsert(e,t),s&&s.upsert(n.transformMessage?n.transformMessage(e):e,t)},stop:function(){a.stop(),null==s||s.stop()}}}function Dn(){var e="",t=0;return{isAsync:!1,get isEmpty(){return!e},write:function(n,r){var o=C(n);t+=o,e+=n,r&&r(o)},finish:function(e){e(this.finishSync())},finishSync:function(){var n={output:e,outputBytesCount:t,rawBytesCount:t,pendingData:""};return e="",t=0,n},estimateEncodedBytesCount:function(e){return e.length}}}var Mn=1/0,qn=ee,jn=function(){function e(e,t){var n=this;this.expireDelay=e,this.maxEntries=t,this.entries=[],this.clearOldValuesInterval=k((function(){return n.clearOldValues()}),qn)}return e.prototype.add=function(e,t){var n=this,r={value:e,startTime:t,endTime:Mn,remove:function(){var e=n.entries.indexOf(r);e>=0&&n.entries.splice(e,1)},close:function(e){r.endTime=e}};return this.maxEntries&&this.entries.length>=this.maxEntries&&this.entries.pop(),this.entries.unshift(r),r},e.prototype.find=function(e){void 0===e&&(e=Mn);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.value;break}}},e.prototype.closeActive=function(e){var t=this.entries[0];t&&t.endTime===Mn&&t.close(e)},e.prototype.findAll=function(e,t){void 0===e&&(e=Mn),void 0===t&&(t=0);var n=ae(e,t);return this.entries.filter((function(t){return t.startTime<=n&&e<=t.endTime})).map((function(e){return e.value}))},e.prototype.reset=function(){this.entries=[]},e.prototype.stop=function(){T(this.clearOldValuesInterval)},e.prototype.clearOldValues=function(){for(var e=oe()-this.expireDelay;this.entries.length>0&&this.entries[this.entries.length-1].endTime<e;)this.entries.pop()},e}(),Hn=ee,Gn=Re,Fn=[];function Vn(e,t,n){var r=lt(e.sessionStoreStrategyType,t,n);Fn.push((function(){return r.stop()}));var o=new jn(Gn);function i(){return{id:r.getSession().id,trackingType:r.getSession()[t]}}return Fn.push((function(){return o.stop()})),r.renewObservable.subscribe((function(){o.add(i(),oe())})),r.expireObservable.subscribe((function(){o.closeActive(oe())})),r.expandOrRenewSession(),o.add(i(),[0,se()][0]),function(e,t){var n=le(e,window,[Z.CLICK,Z.TOUCH_START,Z.KEY_DOWN,Z.SCROLL],t,{capture:!0,passive:!0}).stop;Fn.push(n)}(e,(function(){return r.expandOrRenewSession()})),function(e,t){var n=function(){"visible"===document.visibilityState&&t()},r=fe(e,document,Z.VISIBILITY_CHANGE,n).stop;Fn.push(r);var o=k(n,Hn);Fn.push((function(){T(o)}))}(e,(function(){return r.expandSession()})),{findActiveSession:function(e){return o.find(e)},renewObservable:r.renewObservable,expireObservable:r.expireObservable,expire:r.expire}}var zn="logs";function Yn(e){var t=Vn(e,zn,(function(t){return function(e,t){var n=function(e){return"0"===e||"1"===e}(t)?t:Jn(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},expireObservable:t.expireObservable}}function Jn(e){return Ee(e.sessionSampleRate)?"1":"0"}function Wn(e,t,n,r,o){var i=Xt.concat(["custom"]),a={};i.forEach((function(e){var n,r,i,s,u;a[e]=(n=e,r=t.eventRateLimiterThreshold,i=o,s=0,u=!1,{isLimitReached:function(){if(0===s&&x((function(){s=0}),ee),(s+=1)<=r||u)return u=!1,!1;if(s===r+1){u=!0;try{i({message:"Reached max number of ".concat(n,"s by minute: ").concat(r),source:Wt.AGENT,startClocks:ie()})}finally{u=!1}}return!0}})})),n.subscribe(0,(function(o){var i,s,u=o.rawLogsEvent,c=o.messageContext,f=void 0===c?void 0:c,l=o.savedCommonContext,d=void 0===l?void 0:l,p=u.date-se(),v=e.findTrackedSession(p);if(v){var g=d||r(),h=N({service:t.service,session_id:v.id,usr:Se(g.user)?void 0:g.user,view:g.view},g.context,$n(p),u,f);!1===(null===(i=t.beforeSend)||void 0===i?void 0:i.call(t,h))||h.origin!==Wt.AGENT&&(null!==(s=a[h.status])&&void 0!==s?s:a.custom).isLimitReached()||n.notify(1,h)}}))}var Kn=!1;function $n(e){var t,n=window;if(yn()){var r=o(n.DD_RUM_SYNTHETICS);return r||Kn||(Kn=!0,cn("Logs sent before RUM is injected by the synthetics worker",{testId:(t=window._DATADOG_SYNTHETICS_PUBLIC_ID||Ne(vn),"string"==typeof t?t:void 0),resultId:mn()})),r}return o(n.DD_RUM);function o(t){if(t&&t.getInternalContext)return t.getInternalContext(e)}}var Zn,Xn={};function Qn(n){var r=n.map((function(n){return Xn[n]||(Xn[n]=function(n){var r=new V((function(){var o=t[n];return t[n]=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];o.apply(console,t);var a=function(){var e,t=new Error;if(!t.stack)try{throw t}catch(e){}return d((function(){var n=Ot(t);n.stack=n.stack.slice(2),e=Ht(n)})),e}();d((function(){r.notify(function(t,n,r){var o,i,a=t.map((function(e){return function(e){if("string"==typeof e)return j(e);if(e instanceof Error)return Gt(Ot(e));return B(j(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?Ht(Ot(s)):void 0,i=jt(s)}return{api:n,message:a,stack:o,handlingStack:r,fingerprint:i}}(t,n,a))}))},function(){t[n]=o}}));return r}(n)),Xn[n]}));return z.apply(void 0,r)}var er,tr=((Zn={})[e.log]=$t.info,Zn[e.debug]=$t.debug,Zn[e.info]=$t.info,Zn[e.warn]=$t.warn,Zn[e.error]=$t.error,Zn);var nr,rr=((er={})[Ft.cspViolation]=$t.error,er[Ft.intervention]=$t.error,er[Ft.deprecation]=$t.warn,er);function or(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 ir(e,t,n){var r=n.before,o=n.after;return or(e,t,(function(e){return function(){var t,n=arguments;return r&&d(r,this,n),"function"==typeof e&&(t=e.apply(this,n)),o&&d(o,this,n),t}}))}var ar,sr=new WeakMap;function ur(e){return nr||(nr=function(e){var t=new V((function(){var n=ir(XMLHttpRequest.prototype,"open",{before:cr}).stop,r=ir(XMLHttpRequest.prototype,"send",{before:function(){fr.call(this,e,t)}}).stop,o=ir(XMLHttpRequest.prototype,"abort",{before:lr}).stop;return function(){n(),r(),o()}}));return t}(e)),nr}function cr(e,t){sr.set(this,{state:"open",method:e.toUpperCase(),url:dt(String(t))})}function fr(e,t){var n=this,r=sr.get(this);if(r){var o=r;o.state="start",o.startClocks=ie(),o.isAborted=!1,o.xhr=this;var i=!1,a=ir(this,"onreadystatechange",{before:function(){this.readyState===XMLHttpRequest.DONE&&s()}}).stop,s=function(){if(u(),a(),!i){i=!0;var e,s=r;s.state="complete",s.duration=(e=o.startClocks.timeStamp,re()-e),s.status=n.status,t.notify(m({},s))}},u=fe(e,this,"loadend",s).stop;t.notify(o)}}function lr(){var e=sr.get(this);e&&(e.isAborted=!0)}function dr(){var e;return ar||(e=new V((function(){if(window.fetch)return or(window,"fetch",(function(t){return function(n,r){var o,i=d(pr,null,[e,n,r]);return i?(o=t.call(this,i.input,i.init),d(vr,null,[e,o,i])):o=t.call(this,n,r),o}})).stop})),ar=e),ar}function pr(e,t,n){var r=n&&n.method||t instanceof Request&&t.method,o=r?r.toUpperCase():"GET",i=t instanceof Request?t.url:dt(String(t)),a={state:"start",init:n,input:t,method:o,startClocks:ie(),url:i};return e.notify(a),a}function vr(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(l(r),l(r))}function gr(e,t){if(!e.forwardErrorsToLogs)return{stop:L};var n=ur(e).subscribe((function(e){"complete"===e.state&&o("xhr",e)})),r=dr().subscribe((function(e){"resolve"===e.state&&o("fetch",e)}));function o(n,r){function o(e){t.notify(0,{rawLogsEvent:{message:"".concat(yr(n)," error ").concat(r.method," ").concat(r.url),date:r.startClocks.timeStamp,error:{stack:e||"Failed to load"},http:{method:r.method,status_code:r.status,url:r.url},status:$t.error,origin:Wt.NETWORK}})}e.isIntakeUrl(r.url)||!function(e){return 0===e.status&&"opaque"!==e.responseType}(r)&&!wn(r.status)||("xhr"in r?function(e,t,n){"string"==typeof e.response?n(hr(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(L),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(l((function(t){t.done?a():(n.collectStreamBody&&o.push(t.value),(i+=t.value.length)>n.bytesLimit?a():e())})),l((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(l((function(e){return n(hr(e,t))})),l((function(e){return n("Unable to retrieve response: ".concat(e))}))):n()}(r.response,e,o):r.error&&function(e,t,n){n(hr(Ht(Ot(e)),t))}(r.error,e,o))}return{stop:function(){n.unsubscribe(),r.unsubscribe()}}}function hr(e,t){return e.length>t.requestErrorResponseLengthLimit?"".concat(e.substring(0,t.requestErrorResponseLengthLimit),"..."):e}function yr(e){return"xhr"===e?"XHR":"Fetch"}function mr(e){var t,n=function(t,n){var r=qt({stackTrace:t,originalError:n,startClocks:ie(),nonErrorPrefix:"Uncaught",source:Wt.SOURCE,handling:"unhandled"});e.notify(r)},r=(t=n,ir(window,"onerror",{before:function(e,n,r,o,i){var a;a=i instanceof Error?Ot(i):Ut(e,n,r,o),t(a,null!=i?i:e)}})).stop,o=function(e){return ir(window,"onunhandledrejection",{before:function(t){var n=t.reason||"Empty reason",r=Ot(n);e(r,n)}})}(n).stop;return{stop:function(){r(),o()}}}var br,Er=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}(),wr=((br={})[$t.debug]=0,br[$t.info]=1,br[$t.warn]=2,br[$t.error]=3,br);function Sr(e){return{handleLog:function(r,o,i,a){var s=N(o.getContext(),r.context);Cr(r.status,Zt.console,o)&&function(e,r){n[e.status].call(t,e.message,r)}(r,s),Cr(r.status,Zt.http,o)&&e.notify(0,{rawLogsEvent:{date:a||re(),message:r.message,status:r.status,origin:Wt.LOGGER},messageContext:s,savedCommonContext:i})}}}function Cr(e,t,n){var r=n.getHandler(),o=Array.isArray(r)?r:[r];return wr[e]>=wr[n.getLevel()]&&v(o,t)}var _r,xr,Or,kr,Tr=function(t){var n,r,i=!1,a=K(2),s=K(1),u={},f=function(){},d=new X,p=function(e,t,n,r){void 0===n&&(n=P(b())),void 0===r&&(r=re()),d.add((function(){return p(e,t,n,r)}))},g=function(){},y=new Qt((function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return p.apply(void 0,e)}));function b(){return{view:{referrer:document.referrer,url:window.location.href},context:a.getContext(),user:s.getContext()}}return n={logger:y,init:l((function(n){var r;if(n){if(g=function(){return P(n)},ce()&&(n=function(e){return m({},e,{clientToken:"empty"})}(n)),function(e){return!i||(e.silentMultipleInit||o.error("DD_LOGS is already initialized."),!1)}(n)){var u=function(t){var n=_t(t),r=Jt(t.forwardConsoleLogs,h(e),"Forward Console Logs"),o=Jt(t.forwardReports,h(Ft),"Forward Reports");if(n&&r&&o)return t.forwardErrorsToLogs&&!v(r,e.error)&&r.push(e.error),m({forwardErrorsToLogs:!1!==t.forwardErrorsToLogs,forwardConsoleLogs:r,forwardReports:o,requestErrorResponseLengthLimit:Yt},n)}(n);if(u){if(n.storeContextsAcrossPages){var c=a.getContext();(a=ge(u,en,2)).setContext(N(a.getContext(),c));var l=s.getContext();(s=ge(u,en,1)).setContext(N(s.getContext(),l))}r=t(n,u,b),p=r.handleLog,f=r.getInternalContext,d.drain(),i=!0}}}else o.error("Missing configuration")})),getGlobalContext:l((function(){return a.getContext()})),setGlobalContext:l((function(e){return a.setContext(e)})),setGlobalContextProperty:l((function(e,t){return a.setContextProperty(e,t)})),removeGlobalContextProperty:l((function(e){return a.removeContextProperty(e)})),clearGlobalContext:l((function(){return a.clearContext()})),createLogger:l((function(e,t){return void 0===t&&(t={}),u[e]=new Qt((function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return p.apply(void 0,e)}),j(e),t.handler,t.level,j(t.context)),u[e]})),getLogger:l((function(e){return u[e]})),getInitConfiguration:l((function(){return g()})),getInternalContext:l((function(e){return f(e)})),setUser:l((function(e){(function(e){var t="object"===A(e);return t||o.error("Unsupported user:",e),t})(e)&&s.setContext(he(e))})),getUser:l((function(){return s.getContext()})),setUserProperty:l((function(e,t){var n,r=he((n={},n[e]=t,n))[e];s.setContextProperty(e,r)})),removeUserProperty:l((function(e){return s.removeContextProperty(e)})),clearUser:l((function(){return s.clearContext()}))},r=m({version:"5.4.0",onReady:function(e){e()}},n),Object.defineProperty(r,"_setDebug",{get:function(){return c},enumerable:!1}),r}((function(t,n,r){var o=new Er,i=[];o.subscribe(1,(function(e){return tn("logs",e)}));var a=function(e){o.notify(0,{rawLogsEvent:{message:e.message,date:e.startClocks.timeStamp,origin:Wt.AGENT,status:$t.error}}),cn("Error reported to customer",{"error.message":e.message})},s=function(e){var t=new V((function(){var n=me(de.PAGEHIDE),r=le(e,window,[Z.VISIBILITY_CHANGE,Z.FREEZE,Z.PAGE_HIDE],(function(e){e.type===Z.PAGE_HIDE&&n?t.notify({reason:pn.PAGEHIDE}):e.type===Z.VISIBILITY_CHANGE&&"hidden"===document.visibilityState?t.notify({reason:pn.HIDDEN}):e.type===Z.FREEZE&&t.notify({reason:pn.FROZEN})}),{capture:!0}).stop,o=L;return n||(o=fe(e,window,Z.BEFORE_UNLOAD,(function(){t.notify({reason:pn.UNLOADING})})).stop),function(){r(),o()}}));return t}(n),u=!n.sessionStoreStrategyType||ce()||yn()?function(e){var t="1"===Jn(e)?{}:void 0;return{findTrackedSession:function(){return t},expireObservable:new V}}(n):Yn(n),c=function(e,t,n,r){var o=un("browser-logs-sdk",e),i=[];if(ce()){var a=ue(),s=o.observable.subscribe((function(e){return a.send("internal_telemetry",e)}));i.push((function(){return s.unsubscribe()}))}else{var u=Un(e,{endpoint:e.rumEndpointBuilder,encoder:Dn()},e.replica&&{endpoint:e.replica.rumEndpointBuilder,encoder:Dn()},t,n,r);i.push((function(){return u.stop()}));var c=o.observable.subscribe((function(t){return u.add(t,function(e){return e.site===yt}(e))}));i.push((function(){return c.unsubscribe()}))}return{telemetry:o,stop:function(){i.forEach((function(e){return e()}))}}}(n,a,s,u.expireObservable),f=c.telemetry,l=c.stop;i.push((function(){return l()})),f.setContextProvider((function(){var e,t,n,r,o,i;return{application:{id:null===(e=$n())||void 0===e?void 0:e.application_id},session:{id:null===(t=u.findTrackedSession())||void 0===t?void 0:t.id},view:{id:null===(r=null===(n=$n())||void 0===n?void 0:n.view)||void 0===r?void 0:r.id},action:{id:null===(i=null===(o=$n())||void 0===o?void 0:o.user_action)||void 0===i?void 0:i.id}}})),gr(n,o),function(e,t){if(!e.forwardErrorsToLogs)return{stop:L};var n=new V,r=mr(n).stop,o=n.subscribe((function(e){t.notify(0,{rawLogsEvent:{message:e.message,date:e.startClocks.timeStamp,error:{kind:e.type,stack:e.stack},origin:Wt.SOURCE,status:$t.error}})}))}(n,o),function(t,n){var r=Qn(t.forwardConsoleLogs).subscribe((function(t){n.notify(0,{rawLogsEvent:{date:re(),message:t.message,origin:Wt.CONSOLE,error:t.api===e.error?{stack:t.stack,fingerprint:t.fingerprint}:void 0,status:tr[t.api]}})}))}(n,o),function(e,t){var n=Vt(e,e.forwardReports).subscribe((function(e){var n,r=e.message,o=rr[e.type];o===$t.error?n={kind:e.subtype,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:re(),message:r,origin:Wt.REPORT,error:n,status:o}})}))}(n,o);var d,p=Sr(o).handleLog;if(Wn(u,n,o,r,a),ce())!function(e){var t=ue();e.subscribe(1,(function(e){t.send("log",e)}))}(o);else{var v=function(e,t,n,r,o){var i=Un(e,{endpoint:e.logsEndpointBuilder,encoder:Dn()},e.replica&&{endpoint:e.replica.logsEndpointBuilder,encoder:Dn()},n,r,o);return t.subscribe(1,(function(e){i.add(e)})),i}(n,o,a,s,u.expireObservable).stop;i.push((function(){return v()}))}return function(e){sn.telemetryConfigurationEnabled&&ln({type:rn.configuration,configuration:e})}(function(e){var t,n={session_sample_rate:(t=e).sessionSampleRate,telemetry_sample_rate:t.telemetrySampleRate,telemetry_configuration_sample_rate:t.telemetryConfigurationSampleRate,use_before_send:!!t.beforeSend,use_cross_site_session_cookie:t.useCrossSiteSessionCookie,use_secure_session_cookie:t.useSecureSessionCookie,use_proxy:!!t.proxy,silent_multiple_init:t.silentMultipleInit,track_session_across_subdomains:t.trackSessionAcrossSubdomains,allow_fallback_to_local_storage:!!t.allowFallbackToLocalStorage,store_contexts_across_pages:!!t.storeContextsAcrossPages,allow_untrusted_events:!!t.allowUntrustedEvents};return m({forward_errors_to_logs:e.forwardErrorsToLogs,forward_console_logs:e.forwardConsoleLogs,forward_reports:e.forwardReports},n)}(t)),{handleLog:p,getInternalContext:(d=u,{get:function(e){var t=d.findTrackedSession(e);if(t)return{session_id:t.id}}}).get,stop:function(){i.forEach((function(e){return e()}))}}}));_r=b(),Or=Tr,kr=_r[xr="DD_LOGS"],_r[xr]=Or,kr&&kr.q&&kr.q.forEach((function(e){return i(e,"onReady callback threw an error:")()}))}();
!function(){"use strict";var e={log:"log",debug:"debug",info:"info",warn:"warn",error:"error"},t=console,n={};Object.keys(e).forEach((function(e){n[e]=t[e]}));var r="Datadog Browser SDK:",o={debug:n.debug.bind(t,r),log:n.log.bind(t,r),info:n.info.bind(t,r),warn:n.warn.bind(t,r),error:n.error.bind(t,r)};function i(e,t){return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];try{return e.apply(void 0,n)}catch(e){o.error(t,e)}}}var a,s=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))},u=!1;function c(e){u=e}function f(e,t,n){var r=n.value;n.value=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return(a?l(r):r).apply(this,e)}}function l(e){return function(){return d(e,this,arguments)}}function d(e,t,n){try{return e.apply(t,n)}catch(e){if(p(e),a)try{a(e)}catch(e){p(e)}}}function p(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];u&&o.error.apply(o,s(["[MONITOR]"],e,!1))}function v(e,t){return-1!==e.indexOf(t)}function g(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 h(e){return Object.keys(e).map((function(t){return e[t]}))}function y(e,t){return e.slice(0,t.length)===t}function m(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return t.forEach((function(t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})),e}function b(){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}var E=1024,w=1024*E,S=/[^\u0000-\u007F]/;function C(e){return S.test(e)?void 0!==window.TextEncoder?(new TextEncoder).encode(e).length:new Blob([e]).size:e.length}function _(e,t){var n,r=b();return r.Zone&&"function"==typeof r.Zone.__symbol__&&(n=e[r.Zone.__symbol__(t)]),n||(n=e[t]),n}function x(e,t){return _(b(),"setTimeout")(l(e),t)}function O(e){_(b(),"clearTimeout")(e)}function k(e,t){return _(b(),"setInterval")(l(e),t)}function T(e){_(b(),"clearInterval")(e)}function R(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=x((function(){a&&r&&e.apply(void 0,r),s=!1,r=void 0}),t))},cancel:function(){O(o),s=!1,r=void 0}}}function L(){}function A(e){return null===e?"null":Array.isArray(e)?"array":typeof e}function I(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]=I(o[i],t[i],n);return o}var a="object"===A(e)?e:{};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(a[s]=I(a[s],t[s],n));return a}}function P(e){return I(void 0,e)}function N(){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=I(e,i))}return e}function B(e,t,n){if("object"!=typeof e||null===e)return JSON.stringify(e);var r=U(Object.prototype),o=U(Array.prototype),i=U(Object.getPrototypeOf(e)),a=U(e);try{return JSON.stringify(e,t,n)}catch(e){return"<error: unable to serialize object>"}finally{r(),o(),i(),a()}}function U(e){var t=e,n=t.toJSON;return n?(delete t.toJSON,function(){t.toJSON=n}):L}var D=220*E,M="$",q=3;function j(e,t){var n;void 0===t&&(t=D);var r=U(Object.prototype),o=U(Array.prototype),i=[],a=new WeakMap,s=H(e,M,void 0,i,a),u=(null===(n=JSON.stringify(s))||void 0===n?void 0:n.length)||0;if(!(u>t)){for(;i.length>0&&u<t;){var c=i.shift(),f=0;if(Array.isArray(c.source))for(var l=0;l<c.source.length;l++){if(u+=void 0!==(d=H(c.source[l],c.path,l,i,a))?JSON.stringify(d).length:4,u+=f,f=1,u>t){G(t,"truncated",e);break}c.target[l]=d}else for(var l in c.source)if(Object.prototype.hasOwnProperty.call(c.source,l)){var d;if(void 0!==(d=H(c.source[l],c.path,l,i,a))&&(u+=JSON.stringify(d).length+f+l.length+q,f=1),u>t){G(t,"truncated",e);break}c.target[l]=d}}return r(),o(),s}G(t,"discarded",e)}function H(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&&"[Error]"!==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 G(e,t,n){o.warn("The data provided has been ".concat(t," as it is over the limit of ").concat(e," characters:"),n)}var F,V=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 z(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=new V((function(){var t=e.map((function(e){return e.subscribe((function(e){return n.notify(e)}))}));return function(){return t.forEach((function(e){return e.unsubscribe()}))}}));return n}var Y=3*E,J=((F={})[0]="feature flag evaluation",F[1]="user",F[2]="global context",F[3]="logger context",F);var W=200;function K(e,t){void 0===t&&(t=C);var n,r={},i=!1,a=new V,s=R((function(r){n=t(B(r)),i||(i=function(e,t){return e>Y&&(o.warn("The ".concat(J[t]," data exceeds the recommended ").concat(Y/E,"KiB threshold. More details: https://docs.datadoghq.com/real_user_monitoring/browser/troubleshooting/#customer-data-exceeds-the-recommended-3kib-warning")),!0)}(n,e))}),W).throttled,u={getBytesCount:function(){return n},getContext:function(){return P(r)},setContext:function(e){"object"===A(e)?(r=j(e),s(r)):u.clearContext(),a.notify()},setContextProperty:function(e,t){r[e]=j(t),s(r),a.notify()},removeContextProperty:function(e){delete r[e],s(r),a.notify()},clearContext:function(){r={},n=0,a.notify()},changeObservable:a};return u}var $,Z,X=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}(),Q=1e3,ee=60*Q,te=60*ee;function ne(){return(new Date).getTime()}function re(){return ne()}function oe(){return performance.now()}function ie(){return{relative:oe(),timeStamp:re()}}function ae(e,t){return e+t}function se(){return void 0===$&&($=performance.timing.navigationStart),$}function ue(){var e=b().DatadogEventBridge;if(e)return{getAllowedWebViewHosts:function(){return JSON.parse(e.getAllowedWebViewHosts())},send:function(t,n){e.send(JSON.stringify({eventType:t,event:n}))}}}function ce(e){var t;void 0===e&&(e=null===(t=b().location)||void 0===t?void 0:t.hostname);var n=ue();return!!n&&n.getAllowedWebViewHosts().some((function(t){return e===t||(n=e,r=".".concat(t),n.slice(-r.length)===r);var n,r}))}function fe(e,t,n,r,o){return le(e,t,[n],r,o)}function le(e,t,n,r,o){var i=void 0===o?{}:o,a=i.once,s=i.capture,u=i.passive,c=l((function(t){(t.isTrusted||t.__ddIsTrusted||e.allowUntrustedEvents)&&(a&&p(),r(t))})),f=u?{capture:s,passive:u}:s,d=_(t,"addEventListener");function p(){var e=_(t,"removeEventListener");n.forEach((function(n){return e.call(t,n,c,f)}))}return n.forEach((function(e){return d.call(t,e,c,f)})),{stop:p}}!function(e){e.BEFORE_UNLOAD="beforeunload",e.CLICK="click",e.DBL_CLICK="dblclick",e.KEY_DOWN="keydown",e.LOAD="load",e.POP_STATE="popstate",e.SCROLL="scroll",e.TOUCH_START="touchstart",e.TOUCH_END="touchend",e.TOUCH_MOVE="touchmove",e.VISIBILITY_CHANGE="visibilitychange",e.PAGE_SHOW="pageshow",e.FREEZE="freeze",e.RESUME="resume",e.DOM_CONTENT_LOADED="DOMContentLoaded",e.POINTER_DOWN="pointerdown",e.POINTER_UP="pointerup",e.POINTER_CANCEL="pointercancel",e.HASH_CHANGE="hashchange",e.PAGE_HIDE="pagehide",e.MOUSE_DOWN="mousedown",e.MOUSE_UP="mouseup",e.MOUSE_MOVE="mousemove",e.FOCUS="focus",e.BLUR="blur",e.CONTEXT_MENU="contextmenu",e.RESIZE="resize",e.CHANGE="change",e.INPUT="input",e.PLAY="play",e.PAUSE="pause",e.SECURITY_POLICY_VIOLATION="securitypolicyviolation",e.SELECTION_CHANGE="selectionchange",e.STORAGE="storage"}(Z||(Z={}));var de,pe="_dd_c",ve=[];function ge(e,t,n,r){void 0===r&&(r=C);var o=function(e,t){return"".concat(pe,"_").concat(e,"_").concat(t)}(t,n),i=K(n,r);return a(),ve.push(fe(e,window,Z.STORAGE,(function(e){var t=e.key;o===t&&a()}))),i.changeObservable.subscribe((function(){localStorage.setItem(o,JSON.stringify(i.getContext()))})),i;function a(){var e=localStorage.getItem(o),t=null!==e?JSON.parse(e):{};i.setContext(t)}}function he(e){var t=m({},e);return["id","name","email"].forEach((function(e){e in t&&(t[e]=String(t[e]))})),t}!function(e){e.PAGEHIDE="pagehide",e.FEATURE_FLAGS="feature_flags",e.RESOURCE_PAGE_STATES="resource_page_states",e.COLLECT_FLUSH_REASON="collect_flush_reason",e.SCROLLMAP="scrollmap",e.DISABLE_REPLAY_INLINE_CSS="disable_replay_inline_css"}(de||(de={}));var ye=new Set;function me(e){return ye.has(e)}function be(){return ye}function Ee(e){return 0!==e&&100*Math.random()<=e}function we(e){return function(e){return"number"==typeof e}(e)&&e>=0&&e<=100}function Se(e){return 0===Object.keys(e).length}function Ce(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,Ce)}var _e=/([\w-]+)\s*=\s*([^;]+)/g;function xe(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)}var Oe,ke,Te,Re=4*te,Le=15*ee;function Ae(){return null!=Oe?Oe:Oe=function(e){var t;void 0===e&&(e=window);var n=e.navigator.userAgent;if(e.chrome||/HeadlessChrome/.test(n))return 1;if(0===(null===(t=e.navigator.vendor)||void 0===t?void 0:t.indexOf("Apple"))||/safari/i.test(n)&&!/chrome|android/i.test(n))return 2;if(e.document.documentMode)return 0;return 3}()}function Ie(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 Pe(e){return function(e,t){for(_e.lastIndex=0;;){var n=_e.exec(e);if(!n)break;if(n[1]===t)return n[2]}}(document.cookie,e)}function Ne(e){return ke||(ke=function(e){var t=new Map;for(_e.lastIndex=0;;){var n=_e.exec(e);if(!n)break;t.set(n[1],n[2])}return t}(document.cookie)),ke.get(e)}function Be(e,t){Ie(e,"",0,t)}var Ue="_dd_s",De=/^([a-z]+)=([a-z0-9-]+)$/,Me="&";function qe(e){return Se(e)}function je(e){e.expire=String(ne()+Le)}function He(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(Me);var t}function Ge(e){var t={};return function(e){return!!e&&(-1!==e.indexOf(Me)||De.test(e))}(e)&&e.split(Me).forEach((function(e){var n=De.exec(e);if(null!==n){var r=n[1],o=n[2];t[r]=o}})),t}var Fe="_dd",Ve="_dd_r",ze="_dd_l",Ye="rum",Je="logs";function We(e){var t=function(e){var t={};t.secure=!!e.useSecureSessionCookie||!!e.useCrossSiteSessionCookie,t.crossSite=!!e.useCrossSiteSessionCookie,e.trackSessionAcrossSubdomains&&(t.domain=function(){if(void 0===Te){for(var e="dd_site_test_".concat(Ce()),t=window.location.hostname.split("."),n=t.pop();t.length&&!Pe(e);)n="".concat(t.pop(),".").concat(n),Ie(e,"test",Q,{domain:n});Be(e,{domain:n}),Te=n}return Te}());return t}(e);return function(e){if(void 0===document.cookie||null===document.cookie)return!1;try{var t="dd_cookie_test_".concat(Ce()),n="test";Ie(t,n,ee,e);var r=Pe(t)===n;return Be(t,e),r}catch(e){return o.error(e),!1}}(t)?{type:"Cookie",cookieOptions:t}:void 0}function Ke(e){var t,n={isLockEnabled:1===Ae(),persistSession:(t=e,function(e){Ie(Ue,He(e),Le,t)}),retrieveSession:$e,clearSession:Ze(e)};return function(e){if(!Ne(Ue)){var t=Ne(Fe),n=Ne(Ve),r=Ne(ze),o={};t&&(o.id=t),r&&/^[01]$/.test(r)&&(o[Je]=r),n&&/^[012]$/.test(n)&&(o[Ye]=n),qe(o)||(je(o),e.persistSession(o))}}(n),n}function $e(){return Ge(Pe(Ue))}function Ze(e){return function(){Be(Ue,e)}}var Xe="_dd_test_";function Qe(e){localStorage.setItem(Ue,He(e))}function et(){return Ge(localStorage.getItem(Ue))}function tt(){localStorage.removeItem(Ue)}var nt,rt=10,ot=100,it=[];function at(e,t,n){var r;void 0===n&&(n=0);var o=t.isLockEnabled,i=t.retrieveSession,a=t.persistSession,s=t.clearSession;if(nt||(nt=e),e===nt)if(o&&n>=ot)ut(t);else{var u,c=i();if(o){if(c.lock)return void st(e,t,n);if(u=Ce(),c.lock=u,a(c),(c=i()).lock!==u)return void st(e,t,n)}var f=e.process(c);if(o&&(c=i()).lock!==u)st(e,t,n);else{if(f&&(qe(f)?s():(je(f),a(f))),o&&(!f||!qe(f))){if((c=i()).lock!==u)return void st(e,t,n);delete c.lock,a(c),f=c}null===(r=e.after)||void 0===r||r.call(e,f||c),ut(t)}}else it.push(e)}function st(e,t,n){x((function(){at(e,t,n+1)}),rt)}function ut(e){nt=void 0;var t=it.shift();t&&at(t,e)}var ct=Q;function ft(e){var t=We(e);return!t&&e.allowFallbackToLocalStorage&&(t=function(){try{var e=Ce(),t="".concat(Xe).concat(e);localStorage.setItem(t,e);var n=localStorage.getItem(t);return localStorage.removeItem(t),e===n?{type:"LocalStorage"}:void 0}catch(e){return}}()),t}function lt(e,t,n){var r=new V,o=new V,i="Cookie"===e.type?Ke(e.cookieOptions):{isLockEnabled:!1,persistSession:Qe,retrieveSession:et,clearSession:tt},a=i.clearSession,s=i.retrieveSession,u=k((function(){at({process:function(e){return d(e)?void 0:{}},after:f},i)}),ct),c=function(){var e=s();if(d(e))return e;return{}}();function f(e){return d(e)||(e={}),l()&&(!function(e){return c.id!==e.id||c[t]!==e[t]}(e)?c=e:(c={},o.notify())),e}function l(){return void 0!==c[t]}function d(e){return(void 0===e.created||ne()-Number(e.created)<Re)&&(void 0===e.expire||ne()<Number(e.expire))}return{expandOrRenewSession:R((function(){var e;at({process:function(r){var o=f(r);return e=function(e){var r=n(e[t]),o=r.trackingType,i=r.isTracked;e[t]=o,i&&!e.id&&(e.id=Ce(),e.created=String(ne()));return i}(o),o},after:function(t){e&&!l()&&function(e){c=e,r.notify()}(t),c=t}},i)}),ct).throttled,expandSession:function(){at({process:function(e){return l()?f(e):void 0}},i)},getSession:function(){return c},renewObservable:r,expireObservable:o,expire:function(){a(),f({})},stop:function(){T(u)}}}function dt(e){return pt(e,ht(window.location)).href}function pt(e,t){var n=function(){if(void 0===vt)try{var e=new gt("http://test/path");vt="http://test/path"===e.href}catch(e){vt=!1}return vt?gt:void 0}();if(n)try{return void 0!==t?new n(e,t):new n(e)}catch(n){throw new Error("Failed to construct URL: ".concat(String(n)," ").concat(B({url:e,base:t})))}if(void 0===t&&!/:/.test(e))throw new Error("Invalid URL: '".concat(e,"'"));var r=document,o=r.createElement("a");if(void 0!==t){var i=(r=document.implementation.createHTMLDocument("")).createElement("base");i.href=t,r.head.appendChild(i),r.body.appendChild(o)}return o.href=e,o}var vt,gt=URL;function ht(e){if(e.origin&&"null"!==e.origin)return e.origin;var t=e.host.replace(/(:80|:443)$/,"");return"".concat(e.protocol,"//").concat(t)}var yt="datad0g.com",mt="datadoghq.com";function bt(e,t,n){var r=function(e,t){var n="/api/v2/".concat(t),r=e.proxy;if("string"==typeof r){var o=dt(r);return function(e){return"".concat(o,"?ddforward=").concat(encodeURIComponent("".concat(n,"?").concat(e)))}}if("function"==typeof r)return function(e){return r({path:n,parameters:e})};var i=function(e){var t=e.site,n=void 0===t?mt:t,r=e.internalAnalyticsSubdomain;if(r&&n===mt)return"".concat(r,".").concat(mt);var o=n.split("."),i=o.pop();return"browser-intake-".concat(o.join("-"),".").concat(i)}(e);return function(e){return"https://".concat(i).concat(n,"?").concat(e)}}(e,t);return{build:function(o,i){var a=function(e,t,n,r,o){var i=e.clientToken,a=e.internalAnalyticsSubdomain,s=o.retry,u=o.flushReason,c=o.encoding,f=["sdk_version:".concat("5.5.0"),"api:".concat(r)].concat(n);u&&me(de.COLLECT_FLUSH_REASON)&&f.push("flush_reason:".concat(u));s&&f.push("retry_count:".concat(s.count),"retry_after:".concat(s.lastFailureStatus));var l=["ddsource=browser","ddtags=".concat(encodeURIComponent(f.join(","))),"dd-api-key=".concat(i),"dd-evp-origin-version=".concat(encodeURIComponent("5.5.0")),"dd-evp-origin=browser","dd-request-id=".concat(Ce())];c&&l.push("dd-evp-encoding=".concat(c));"rum"===t&&l.push("batch_time=".concat(re()));a&&l.reverse();return l.join("&")}(e,t,n,o,i);return r(a)},urlPrefix:r(""),trackType:t}}var Et=200;var wt=/[^a-z0-9_:./-]/;function St(e,t){var n=Et-e.length-1;(t.length>n||wt.test(t))&&o.warn("".concat(e," value doesn't meet tag requirements and will be sanitized"));var r=t.replace(/,/g,"_");return"".concat(e,":").concat(r)}function Ct(e){var t=function(e){var t=e.env,n=e.service,r=e.version,o=e.datacenter,i=[];return t&&i.push(St("env",t)),n&&i.push(St("service",n)),r&&i.push(St("version",r)),o&&i.push(St("datacenter",o)),i}(e),n=function(e,t){return{logsEndpointBuilder:bt(e,"logs",t),rumEndpointBuilder:bt(e,"rum",t),sessionReplayEndpointBuilder:bt(e,"replay",t)}}(e,t),r=h(n).map((function(e){return e.urlPrefix})),o=function(e,t,n){if(!e.replica)return;var r=m({},e,{site:mt,clientToken:e.replica.clientToken}),o={logsEndpointBuilder:bt(r,"logs",n),rumEndpointBuilder:bt(r,"rum",n)};return t.push.apply(t,h(o).map((function(e){return e.urlPrefix}))),m({applicationId:e.replica.applicationId},o)}(e,r,t);return m({isIntakeUrl:function(e){return r.some((function(t){return 0===e.indexOf(t)}))},replica:o,site:e.site||mt},n)}function _t(e){var t,n,r;if(e&&e.clientToken)if(void 0===e.sessionSampleRate||we(e.sessionSampleRate))if(void 0===e.telemetrySampleRate||we(e.telemetrySampleRate)){if(void 0===e.telemetryConfigurationSampleRate||we(e.telemetryConfigurationSampleRate))return Array.isArray(e.enableExperimentalFeatures)&&e.enableExperimentalFeatures.filter((function(e){return t=de,n=e,Object.keys(t).some((function(e){return t[e]===n}));var t,n})).forEach((function(e){ye.add(e)})),m({beforeSend:e.beforeSend&&i(e.beforeSend,"beforeSend threw an error:"),sessionStoreStrategyType:ft(e),sessionSampleRate:null!==(t=e.sessionSampleRate)&&void 0!==t?t:100,telemetrySampleRate:null!==(n=e.telemetrySampleRate)&&void 0!==n?n:20,telemetryConfigurationSampleRate:null!==(r=e.telemetryConfigurationSampleRate)&&void 0!==r?r:5,service:e.service,silentMultipleInit:!!e.silentMultipleInit,allowUntrustedEvents:!!e.allowUntrustedEvents,batchBytesLimit:16*E,eventRateLimiterThreshold:3e3,maxTelemetryEventsPerPage:15,flushTimeout:30*Q,batchMessagesLimit:50,messageBytesLimit:256*E},Ct(e));o.error("Telemetry Configuration Sample Rate should be a number between 0 and 100")}else o.error("Telemetry Sample Rate should be a number between 0 and 100");else o.error("Session Sample Rate should be a number between 0 and 100");else o.error("Client Token is not configured, we will not send any data.")}var xt="?";function Ot(e){var t=[],n=Bt(e,"stack"),r=String(e);return n&&y(n,r)&&(n=n.slice(r.length)),n&&n.split("\n").forEach((function(e){var n=function(e){var t=Rt.exec(e);if(!t)return;var n=t[2]&&0===t[2].indexOf("native"),r=t[2]&&0===t[2].indexOf("eval"),o=Lt.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]||xt,line:t[3]?+t[3]:void 0,url:n?void 0:t[2]}}(e)||function(e){var t=At.exec(e);if(!t)return;return{args:[],column:t[3]?+t[3]:void 0,func:xt,line:t[2]?+t[2]:void 0,url:t[1]}}(e)||function(e){var t=It.exec(e);if(!t)return;return{args:[],column:t[4]?+t[4]:void 0,func:t[1]||xt,line:+t[3],url:t[2]}}(e)||function(e){var t=Pt.exec(e);if(!t)return;var n=t[3]&&t[3].indexOf(" > eval")>-1,r=Nt.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]||xt,line:t[4]?+t[4]:void 0,url:t[3]}}(e);n&&(!n.func&&n.line&&(n.func=xt),t.push(n))})),{message:Bt(e,"message"),name:Bt(e,"name"),stack:t}}var kt="((?:file|https?|blob|chrome-extension|native|eval|webpack|snippet|<anonymous>|\\w+\\.|\\/).*?)",Tt="(?::(\\d+))",Rt=new RegExp("^\\s*at (.*?) ?\\(".concat(kt).concat(Tt,"?").concat(Tt,"?\\)?\\s*$"),"i"),Lt=new RegExp("\\((\\S*)".concat(Tt).concat(Tt,"\\)"));var At=new RegExp("^\\s*at ?".concat(kt).concat(Tt,"?").concat(Tt,"??\\s*$"),"i");var It=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;var Pt=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|capacitor|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i,Nt=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;function Bt(e,t){if("object"==typeof e&&e&&t in e){var n=e[t];return"string"==typeof n?n:void 0}}function Ut(e,t,n,r){var o=[{url:t,column:r,line:n}],i=function(e){var t,n,r;"[object String]"==={}.toString.call(e)&&(n=(t=Dt.exec(e))[1],r=t[2]);return{name:n,message:r}}(e);return{name:i.name,message:i.message,stack:o}}var Dt=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?([\s\S]*)$/;var Mt="No stack, consider using an instance of Error";function qt(e){var t=e.stackTrace,n=e.originalError,r=e.handlingStack,o=e.startClocks,i=e.nonErrorPrefix,a=e.source,s=e.handling,u=n instanceof Error,c=function(e,t,n,r){return(null==e?void 0:e.message)&&(null==e?void 0:e.name)?e.message:t?"Empty message":"".concat(n," ").concat(B(j(r)))}(t,u,i,n),f=function(e,t){if(void 0===t)return!1;if(e)return!0;return t.stack.length>0&&(t.stack.length>1||void 0!==t.stack[0].url)}(u,t)?Ht(t):Mt,l=u?function(e,t){var n=e,r=[];for(;(null==n?void 0:n.cause)instanceof Error&&r.length<10;){var o=Ot(n.cause);r.push({message:n.cause.message,source:t,type:null==o?void 0:o.name,stack:o&&Ht(o)}),n=n.cause}return r.length?r:void 0}(n,a):void 0;return{startClocks:o,source:a,handling:s,handlingStack:r,originalError:n,type:null==t?void 0:t.name,message:c,stack:f,causes:l,fingerprint:jt(n)}}function jt(e){return e instanceof Error&&"dd_fingerprint"in e?String(e.dd_fingerprint):void 0}function Ht(e){var t=Gt(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 Gt(e){return"".concat(e.name||"Error",": ").concat(e.message)}var Ft={intervention:"intervention",deprecation:"deprecation",cspViolation:"csp_violation"};function Vt(e,t){var n=[];v(t,Ft.cspViolation)&&n.push(function(e){var t=new V((function(){return fe(e,document,Z.SECURITY_POLICY_VIOLATION,(function(e){t.notify(function(e){var t=Ft.cspViolation,n="'".concat(e.blockedURI,"' blocked by '").concat(e.effectiveDirective,"' directive");return{type:Ft.cspViolation,subtype:e.effectiveDirective,message:"".concat(t,": ").concat(n),stack:zt(e.effectiveDirective,e.originalPolicy?"".concat(n,' of the policy "').concat(xe(e.originalPolicy,100,"..."),'"'):"no policy",e.sourceFile,e.lineNumber,e.columnNumber),originalReport:e}}(e))})).stop}));return t}(e));var r=t.filter((function(e){return e!==Ft.cspViolation}));return r.length&&n.push(function(e){var t=new V((function(){if(window.ReportingObserver){var n=l((function(e,n){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),originalReport:e,stack:zt(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)),z.apply(void 0,n)}function zt(e,t,n,r,o){return n?Ht({name:e,message:t,stack:[{func:"?",url:n,line:null!=r?r:void 0,column:null!=o?o:void 0}]}):void 0}var Yt=32*E;function Jt(e,t,n){return void 0===e?[]:"all"===e||Array.isArray(e)&&e.every((function(e){return v(t,e)}))?"all"===e?t:(r=e,i=new Set,r.forEach((function(e){return i.add(e)})),g(i)):void o.error("".concat(n,' should be "all" or an array with allowed values "').concat(t.join('", "'),'"'));var r,i}var Wt={AGENT:"agent",CONSOLE:"console",CUSTOM:"custom",LOGGER:"logger",NETWORK:"network",SOURCE:"source",REPORT:"report"},Kt=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},$t={debug:"debug",error:"error",info:"info",warn:"warn"},Zt={console:"console",http:"http",silent:"silent"},Xt=Object.keys($t),Qt=function(){function e(e,t,n,r,o){void 0===n&&(n=Zt.http),void 0===r&&(r=$t.debug),void 0===o&&(o={}),this.handleLogStrategy=e,this.handlerType=n,this.level=r,this.contextManager=K(3),this.contextManager.setContext(o),t&&this.contextManager.setContextProperty("logger",{name:t})}return e.prototype.log=function(e,t,n,r){var o;if(void 0===n&&(n=$t.info),null!=r){var i=qt({stackTrace:r instanceof Error?Ot(r):void 0,originalError:r,nonErrorPrefix:"Provided",source:Wt.LOGGER,handling:"handled",startClocks:ie()});o={stack:i.stack,kind:i.type,message:i.message}}var a=j(t),s=o?N({error:o},a):a;this.handleLogStrategy({message:j(e),context:s,status:n},this)},e.prototype.debug=function(e,t,n){this.log(e,t,$t.debug,n)},e.prototype.info=function(e,t,n){this.log(e,t,$t.info,n)},e.prototype.warn=function(e,t,n){this.log(e,t,$t.warn,n)},e.prototype.error=function(e,t,n){this.log(e,t,$t.error,n)},e.prototype.setContext=function(e){this.contextManager.setContext(e)},e.prototype.getContext=function(){return this.contextManager.getContext()},e.prototype.setContextProperty=function(e,t){this.contextManager.setContextProperty(e,t)},e.prototype.removeContextProperty=function(e){this.contextManager.removeContextProperty(e)},e.prototype.clearContext=function(){this.contextManager.clearContext()},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},Kt([f],e.prototype,"log",null),e}(),en="logs";function tn(e,t){var n=window.__ddBrowserSdkExtensionCallback;n&&n({type:e,payload:t})}var nn={HIDDEN:"visibility_hidden",UNLOADING:"before_unload",PAGEHIDE:"page_hide",FROZEN:"page_frozen"};var rn="datadog-synthetics-public-id",on="datadog-synthetics-result-id",an="datadog-synthetics-injects-rum";function sn(){return Boolean(window._DATADOG_SYNTHETICS_INJECTS_RUM||Ne(an))}function un(){var e=window._DATADOG_SYNTHETICS_RESULT_ID||Ne(on);return"string"==typeof e?e:void 0}var cn=1/0,fn=ee,ln=function(){function e(e,t){var n=this;this.expireDelay=e,this.maxEntries=t,this.entries=[],this.clearOldValuesInterval=k((function(){return n.clearOldValues()}),fn)}return e.prototype.add=function(e,t){var n=this,r={value:e,startTime:t,endTime:cn,remove:function(){var e=n.entries.indexOf(r);e>=0&&n.entries.splice(e,1)},close:function(e){r.endTime=e}};return this.maxEntries&&this.entries.length>=this.maxEntries&&this.entries.pop(),this.entries.unshift(r),r},e.prototype.find=function(e){void 0===e&&(e=cn);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.value;break}}},e.prototype.closeActive=function(e){var t=this.entries[0];t&&t.endTime===cn&&t.close(e)},e.prototype.findAll=function(e,t){void 0===e&&(e=cn),void 0===t&&(t=0);var n=ae(e,t);return this.entries.filter((function(t){return t.startTime<=n&&e<=t.endTime})).map((function(e){return e.value}))},e.prototype.reset=function(){this.entries=[]},e.prototype.stop=function(){T(this.clearOldValuesInterval)},e.prototype.clearOldValues=function(){for(var e=oe()-this.expireDelay;this.entries.length>0&&this.entries[this.entries.length-1].endTime<e;)this.entries.pop()},e}(),dn=ee,pn=Re,vn=[];function gn(e,t,n){var r=lt(e.sessionStoreStrategyType,t,n);vn.push((function(){return r.stop()}));var o=new ln(pn);function i(){return{id:r.getSession().id,trackingType:r.getSession()[t]}}return vn.push((function(){return o.stop()})),r.renewObservable.subscribe((function(){o.add(i(),oe())})),r.expireObservable.subscribe((function(){o.closeActive(oe())})),r.expandOrRenewSession(),o.add(i(),[0,se()][0]),function(e,t){var n=le(e,window,[Z.CLICK,Z.TOUCH_START,Z.KEY_DOWN,Z.SCROLL],t,{capture:!0,passive:!0}).stop;vn.push(n)}(e,(function(){return r.expandOrRenewSession()})),function(e,t){var n=function(){"visible"===document.visibilityState&&t()},r=fe(e,document,Z.VISIBILITY_CHANGE,n).stop;vn.push(r);var o=k(n,dn);vn.push((function(){T(o)}))}(e,(function(){return r.expandSession()})),{findActiveSession:function(e){return o.find(e)},renewObservable:r.renewObservable,expireObservable:r.expireObservable,expire:r.expire}}var hn="logs";function yn(e){var t=gn(e,hn,(function(t){return function(e,t){var n=function(e){return"0"===e||"1"===e}(t)?t:mn(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},expireObservable:t.expireObservable}}function mn(e){return Ee(e.sessionSampleRate)?"1":"0"}var bn,En={log:"log",configuration:"configuration"},wn=["https://www.datadoghq-browser-agent.com","https://www.datad0g-browser-agent.com","https://d3uc069fcn7uxw.cloudfront.net","https://d20xtzwzcl0ceb.cloudfront.net","http://localhost","<anonymous>"],Sn=["ddog-gov.com"],Cn={maxEventsPerPage:0,sentEventCount:0,telemetryEnabled:!1,telemetryConfigurationEnabled:!1};function _n(e,t){var n,r=new V;Cn.telemetryEnabled=!v(Sn,t.site)&&Ee(t.telemetrySampleRate),Cn.telemetryConfigurationEnabled=Cn.telemetryEnabled&&Ee(t.telemetryConfigurationSampleRate);var o={is_local_file:"file:"===window.location.protocol,is_worker:"WorkerGlobalScope"in self};return bn=function(t){if(Cn.telemetryEnabled){var i=function(e,t,r){return N({type:"telemetry",date:re(),service:e,version:"5.5.0",source:"browser",_dd:{format_version:2},telemetry:N(t,{runtime_env:r}),experimental_features:g(be())},void 0!==n?n():{})}(e,t,o);r.notify(i),tn("telemetry",i)}},a=On,m(Cn,{maxEventsPerPage:t.maxTelemetryEventsPerPage,sentEventCount:0}),{setContextProvider:function(e){n=e},observable:r,enabled:Cn.telemetryEnabled}}function xn(t,n){p(e.debug,t,n),kn(m({type:En.log,message:t,status:"debug"},n))}function On(e,t){kn(m({type:En.log,status:"error"},function(e){if(e instanceof Error){var t=Ot(e);return{error:{kind:t.name,stack:Ht(Tn(t))},message:t.message}}return{error:{stack:Mt},message:"".concat("Uncaught"," ").concat(B(e))}}(e),t))}function kn(e){bn&&Cn.sentEventCount<Cn.maxEventsPerPage&&(Cn.sentEventCount+=1,bn(e))}function Tn(e){return e.stack=e.stack.filter((function(e){return!e.url||wn.some((function(t){return y(e.url,t)}))})),e}var Rn=!1;function Ln(e){var t,n=window;if(sn()){var r=o(n.DD_RUM_SYNTHETICS);return r||Rn||(Rn=!0,xn("Logs sent before RUM is injected by the synthetics worker",{testId:(t=window._DATADOG_SYNTHETICS_PUBLIC_ID||Ne(rn),"string"==typeof t?t:void 0),resultId:un()})),r}return o(n.DD_RUM);function o(t){if(t&&t.getInternalContext)return t.getInternalContext(e)}}function An(e,t,n,r,o){var i=Xt.concat(["custom"]),a={};i.forEach((function(e){var n,r,i,s,u;a[e]=(n=e,r=t.eventRateLimiterThreshold,i=o,s=0,u=!1,{isLimitReached:function(){if(0===s&&x((function(){s=0}),ee),(s+=1)<=r||u)return u=!1,!1;if(s===r+1){u=!0;try{i({message:"Reached max number of ".concat(n,"s by minute: ").concat(r),source:Wt.AGENT,startClocks:ie()})}finally{u=!1}}return!0}})})),n.subscribe(0,(function(o){var i,s,u=o.rawLogsEvent,c=o.messageContext,f=void 0===c?void 0:c,l=o.savedCommonContext,d=void 0===l?void 0:l,p=u.date-se(),v=e.findTrackedSession(p);if(v){var g=d||r(),h=N({service:t.service,session_id:v.id,usr:Se(g.user)?void 0:g.user,view:g.view},g.context,Ln(p),u,f);!1===(null===(i=t.beforeSend)||void 0===i?void 0:i.call(t,h))||h.origin!==Wt.AGENT&&(null!==(s=a[h.status])&&void 0!==s?s:a.custom).isLimitReached()||n.notify(1,h)}}))}var In,Pn={};function Nn(n){var r=n.map((function(n){return Pn[n]||(Pn[n]=function(n){var r=new V((function(){var o=t[n];return t[n]=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];o.apply(console,t);var a=function(){var e,t=new Error;if(!t.stack)try{throw t}catch(e){}return d((function(){var n=Ot(t);n.stack=n.stack.slice(2),e=Ht(n)})),e}();d((function(){r.notify(function(t,n,r){var o,i,a=t.map((function(e){return function(e){if("string"==typeof e)return j(e);if(e instanceof Error)return Gt(Ot(e));return B(j(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?Ht(Ot(s)):void 0,i=jt(s)}return{api:n,message:a,stack:o,handlingStack:r,fingerprint:i}}(t,n,a))}))},function(){t[n]=o}}));return r}(n)),Pn[n]}));return z.apply(void 0,r)}var Bn,Un=((In={})[e.log]=$t.info,In[e.debug]=$t.debug,In[e.info]=$t.info,In[e.warn]=$t.warn,In[e.error]=$t.error,In);var Dn,Mn=((Bn={})[Ft.cspViolation]=$t.error,Bn[Ft.intervention]=$t.error,Bn[Ft.deprecation]=$t.warn,Bn);function qn(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 jn(e,t,n){var r=n.before,o=n.after;return qn(e,t,(function(e){return function(){var t,n=arguments;return r&&d(r,this,n),"function"==typeof e&&(t=e.apply(this,n)),o&&d(o,this,n),t}}))}var Hn,Gn=new WeakMap;function Fn(e){return Dn||(Dn=function(e){var t=new V((function(){var n=jn(XMLHttpRequest.prototype,"open",{before:Vn}).stop,r=jn(XMLHttpRequest.prototype,"send",{before:function(){zn.call(this,e,t)}}).stop,o=jn(XMLHttpRequest.prototype,"abort",{before:Yn}).stop;return function(){n(),r(),o()}}));return t}(e)),Dn}function Vn(e,t){Gn.set(this,{state:"open",method:e.toUpperCase(),url:dt(String(t))})}function zn(e,t){var n=this,r=Gn.get(this);if(r){var o=r;o.state="start",o.startClocks=ie(),o.isAborted=!1,o.xhr=this;var i=!1,a=jn(this,"onreadystatechange",{before:function(){this.readyState===XMLHttpRequest.DONE&&s()}}).stop,s=function(){if(u(),a(),!i){i=!0;var e,s=r;s.state="complete",s.duration=(e=o.startClocks.timeStamp,re()-e),s.status=n.status,t.notify(m({},s))}},u=fe(e,this,"loadend",s).stop;t.notify(o)}}function Yn(){var e=Gn.get(this);e&&(e.isAborted=!0)}function Jn(){var e;return Hn||(e=new V((function(){if(window.fetch)return qn(window,"fetch",(function(t){return function(n,r){var o,i=d(Wn,null,[e,n,r]);return i?(o=t.call(this,i.input,i.init),d(Kn,null,[e,o,i])):o=t.call(this,n,r),o}})).stop})),Hn=e),Hn}function Wn(e,t,n){var r=n&&n.method||t instanceof Request&&t.method,o=r?r.toUpperCase():"GET",i=t instanceof Request?t.url:dt(String(t)),a={state:"start",init:n,input:t,method:o,startClocks:ie(),url:i};return e.notify(a),a}function Kn(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(l(r),l(r))}function $n(e){return e>=500}function Zn(e,t){if(!e.forwardErrorsToLogs)return{stop:L};var n=Fn(e).subscribe((function(e){"complete"===e.state&&o("xhr",e)})),r=Jn().subscribe((function(e){"resolve"===e.state&&o("fetch",e)}));function o(n,r){function o(e){t.notify(0,{rawLogsEvent:{message:"".concat(Qn(n)," error ").concat(r.method," ").concat(r.url),date:r.startClocks.timeStamp,error:{stack:e||"Failed to load"},http:{method:r.method,status_code:r.status,url:r.url},status:$t.error,origin:Wt.NETWORK}})}e.isIntakeUrl(r.url)||!function(e){return 0===e.status&&"opaque"!==e.responseType}(r)&&!$n(r.status)||("xhr"in r?function(e,t,n){"string"==typeof e.response?n(Xn(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(L),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(l((function(t){t.done?a():(n.collectStreamBody&&o.push(t.value),(i+=t.value.length)>n.bytesLimit?a():e())})),l((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(l((function(e){return n(Xn(e,t))})),l((function(e){return n("Unable to retrieve response: ".concat(e))}))):n()}(r.response,e,o):r.error&&function(e,t,n){n(Xn(Ht(Ot(e)),t))}(r.error,e,o))}return{stop:function(){n.unsubscribe(),r.unsubscribe()}}}function Xn(e,t){return e.length>t.requestErrorResponseLengthLimit?"".concat(e.substring(0,t.requestErrorResponseLengthLimit),"..."):e}function Qn(e){return"xhr"===e?"XHR":"Fetch"}function er(e){var t,n=function(t,n){var r=qt({stackTrace:t,originalError:n,startClocks:ie(),nonErrorPrefix:"Uncaught",source:Wt.SOURCE,handling:"unhandled"});e.notify(r)},r=(t=n,jn(window,"onerror",{before:function(e,n,r,o,i){var a;a=i instanceof Error?Ot(i):Ut(e,n,r,o),t(a,null!=i?i:e)}})).stop,o=function(e){return jn(window,"onunhandledrejection",{before:function(t){var n=t.reason||"Empty reason",r=Ot(n);e(r,n)}})}(n).stop;return{stop:function(){r(),o()}}}var tr,nr=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}(),rr=((tr={})[$t.debug]=0,tr[$t.info]=1,tr[$t.warn]=2,tr[$t.error]=3,tr);function or(e){return{handleLog:function(r,o,i,a){var s=N(o.getContext(),r.context);ir(r.status,Zt.console,o)&&function(e,r){n[e.status].call(t,e.message,r)}(r,s),ir(r.status,Zt.http,o)&&e.notify(0,{rawLogsEvent:{date:a||re(),message:r.message,status:r.status,origin:Wt.LOGGER},messageContext:s,savedCommonContext:i})}}}function ir(e,t,n){var r=n.getHandler(),o=Array.isArray(r)?r:[r];return rr[e]>=rr[n.getLevel()]&&v(o,t)}var ar=function(){function e(e,t,n,r){var o=this;this.encoder=e,this.request=t,this.flushController=n,this.messageBytesLimit=r,this.upsertBuffer={},this.flushSubscription=this.flushController.flushObservable.subscribe((function(e){return o.flush(e)}))}return e.prototype.add=function(e){this.addOrUpdate(e)},e.prototype.upsert=function(e,t){this.addOrUpdate(e,t)},e.prototype.stop=function(){this.flushSubscription.unsubscribe()},e.prototype.flush=function(e){var t=h(this.upsertBuffer).join("\n");this.upsertBuffer={};var n,r=(n=e.reason,v(h(nn),n)),o=r?this.request.sendOnExit:this.request.send;if(r&&this.encoder.isAsync){var i=this.encoder.finishSync();i.outputBytesCount&&o(sr(i,e));var a=[i.pendingData,t].filter(Boolean).join("\n");a&&o({data:a,bytesCount:C(a),flushReason:e.reason})}else t&&this.encoder.write(this.encoder.isEmpty?t:"\n".concat(t)),this.encoder.finish((function(t){o(sr(t,e))}))},e.prototype.addOrUpdate=function(e,t){var n=B(e),r=this.encoder.estimateEncodedBytesCount(n);r>=this.messageBytesLimit?o.warn("Discarded a message whose size was bigger than the maximum allowed size ".concat(this.messageBytesLimit,"KB.")):(this.hasMessageFor(t)&&this.remove(t),this.push(n,r,t))},e.prototype.push=function(e,t,n){var r=this;this.flushController.notifyBeforeAddMessage(t),void 0!==n?(this.upsertBuffer[n]=e,this.flushController.notifyAfterAddMessage()):this.encoder.write(this.encoder.isEmpty?e:"\n".concat(e),(function(e){r.flushController.notifyAfterAddMessage(e-t)}))},e.prototype.remove=function(e){var t=this.upsertBuffer[e];delete this.upsertBuffer[e];var n=this.encoder.estimateEncodedBytesCount(t);this.flushController.notifyAfterRemoveMessage(n)},e.prototype.hasMessageFor=function(e){return void 0!==e&&void 0!==this.upsertBuffer[e]},e}();function sr(e,t){return{data:"string"==typeof e.output?e.output:new Blob([e.output],{type:"text/plain"}),bytesCount:e.outputBytesCount,encoding:e.encoding,flushReason:t.reason}}var ur=80*E,cr=32,fr=3*w,lr=ee,dr=Q;function pr(e,t,n,r,o){0===t.transportStatus&&0===t.queuedPayloads.size()&&t.bandwidthMonitor.canHandle(e)?gr(e,t,n,{onSuccess:function(){return hr(0,t,n,r,o)},onFailure:function(){t.queuedPayloads.enqueue(e),vr(t,n,r,o)}}):t.queuedPayloads.enqueue(e)}function vr(e,t,n,r){2===e.transportStatus&&x((function(){gr(e.queuedPayloads.first(),e,t,{onSuccess:function(){e.queuedPayloads.dequeue(),e.currentBackoffTime=dr,hr(1,e,t,n,r)},onFailure:function(){e.currentBackoffTime=Math.min(lr,2*e.currentBackoffTime),vr(e,t,n,r)}})}),e.currentBackoffTime)}function gr(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||$n(e.status))}(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 hr(e,t,n,r,o){0===e&&t.queuedPayloads.isFull()&&!t.queueFullReported&&(o({message:"Reached max ".concat(r," events size queued for upload: ").concat(fr/w,"MiB"),source:Wt.AGENT,startClocks:ie()}),t.queueFullReported=!0);var i=t.queuedPayloads;for(t.queuedPayloads=yr();i.size()>0;)pr(i.dequeue(),t,n,r,o)}function yr(){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>=fr}}}function mr(e,t,n,r){var o={transportStatus:0,currentBackoffTime:dr,bandwidthMonitor:{ongoingRequestCount:0,ongoingByteCount:0,canHandle:function(e){return 0===this.ongoingRequestCount||this.ongoingByteCount+e.bytesCount<=ur&&this.ongoingRequestCount<cr},add:function(e){this.ongoingRequestCount+=1,this.ongoingByteCount+=e.bytesCount},remove:function(e){this.ongoingRequestCount-=1,this.ongoingByteCount-=e.bytesCount}},queuedPayloads:yr(),queueFullReported:!1},i=function(r,o){return function(e,t,n,r,o){var i=function(){try{return window.Request&&"keepalive"in new Request("http://a")}catch(e){return!1}}()&&r.bytesCount<n;if(i){var a=t.build("fetch",r);fetch(a,{method:"POST",body:r.data,keepalive:!0,mode:"cors"}).then(l((function(e){return null==o?void 0:o({status:e.status,type:e.type})})),l((function(){var n=t.build("xhr",r);Er(e,n,r.data,o)})))}else{var s=t.build("xhr",r);Er(e,s,r.data,o)}}(e,t,n,r,o)};return{send:function(e){pr(e,o,i,t.trackType,r)},sendOnExit:function(r){!function(e,t,n,r){var o=!!navigator.sendBeacon&&r.bytesCount<n;if(o)try{var i=t.build("beacon",r);if(navigator.sendBeacon(i,r.data))return}catch(e){!function(e){br||(br=!0,On(e))}(e)}var a=t.build("xhr",r);Er(e,a,r.data)}(e,t,n,r)}}}var br=!1;function Er(e,t,n,r){var o=new XMLHttpRequest;o.open("POST",t,!0),n instanceof Blob&&o.setRequestHeader("Content-Type",n.type),fe(e,o,"loadend",(function(){null==r||r({status:o.status})}),{once:!0}),o.send(n)}function wr(e){var t,n=e.messagesLimit,r=e.bytesLimit,o=e.durationLimit,i=e.pageExitObservable,a=e.sessionExpireObservable,s=i.subscribe((function(e){return d(e.reason)})),u=a.subscribe((function(){return d("session_expire")})),c=new V((function(){return function(){s.unsubscribe(),u.unsubscribe()}})),f=0,l=0;function d(e){if(0!==l){var t=l,n=f;l=0,f=0,p(),c.notify({reason:e,messagesCount:t,bytesCount:n})}}function p(){O(t),t=void 0}return{flushObservable:c,get messagesCount(){return l},notifyBeforeAddMessage:function(e){f+e>=r&&d("bytes_limit"),l+=1,f+=e,void 0===t&&(t=x((function(){d("duration_limit")}),o))},notifyAfterAddMessage:function(e){void 0===e&&(e=0),f+=e,l>=n?d("messages_limit"):f>=r&&d("bytes_limit")},notifyAfterRemoveMessage:function(e){f-=e,0===(l-=1)&&p()}}}function Sr(e,t,n,r,o,i){var a=u(e,t),s=n&&u(e,n);function u(e,t){var n=t.endpoint,a=t.encoder;return new ar(a,mr(e,n,e.batchBytesLimit,r),wr({messagesLimit:e.batchMessagesLimit,bytesLimit:e.batchBytesLimit,durationLimit:e.flushTimeout,pageExitObservable:o,sessionExpireObservable:i}),e.messageBytesLimit)}return{flushObservable:a.flushController.flushObservable,add:function(e,t){void 0===t&&(t=!0),a.add(e),s&&t&&s.add(n.transformMessage?n.transformMessage(e):e)},upsert:function(e,t){a.upsert(e,t),s&&s.upsert(n.transformMessage?n.transformMessage(e):e,t)},stop:function(){a.stop(),null==s||s.stop()}}}function Cr(){var e="",t=0;return{isAsync:!1,get isEmpty(){return!e},write:function(n,r){var o=C(n);t+=o,e+=n,r&&r(o)},finish:function(e){e(this.finishSync())},finishSync:function(){var n={output:e,outputBytesCount:t,rawBytesCount:t,pendingData:""};return e="",t=0,n},estimateEncodedBytesCount:function(e){return e.length}}}function _r(e,t,n,r,o){var i=_n("browser-logs-sdk",t);i.setContextProvider((function(){var e,t,n,r,i,a;return{application:{id:null===(e=Ln())||void 0===e?void 0:e.application_id},session:{id:null===(t=o.findTrackedSession())||void 0===t?void 0:t.id},view:{id:null===(r=null===(n=Ln())||void 0===n?void 0:n.view)||void 0===r?void 0:r.id},action:{id:null===(a=null===(i=Ln())||void 0===i?void 0:i.user_action)||void 0===a?void 0:a.id}}}));var a=[];if(ce()){var s=ue(),u=i.observable.subscribe((function(e){return s.send("internal_telemetry",e)}));a.push((function(){return u.unsubscribe()}))}else{var c=Sr(t,{endpoint:t.rumEndpointBuilder,encoder:Cr()},t.replica&&{endpoint:t.replica.rumEndpointBuilder,encoder:Cr()},n,r,o.expireObservable);a.push((function(){return c.stop()}));var f=i.observable.subscribe((function(e){return c.add(e,function(e){return e.site===yt}(t))}));a.push((function(){return f.unsubscribe()}))}return function(e){Cn.telemetryConfigurationEnabled&&kn({type:En.configuration,configuration:e})}(function(e){var t,n={session_sample_rate:(t=e).sessionSampleRate,telemetry_sample_rate:t.telemetrySampleRate,telemetry_configuration_sample_rate:t.telemetryConfigurationSampleRate,use_before_send:!!t.beforeSend,use_cross_site_session_cookie:t.useCrossSiteSessionCookie,use_secure_session_cookie:t.useSecureSessionCookie,use_proxy:!!t.proxy,silent_multiple_init:t.silentMultipleInit,track_session_across_subdomains:t.trackSessionAcrossSubdomains,allow_fallback_to_local_storage:!!t.allowFallbackToLocalStorage,store_contexts_across_pages:!!t.storeContextsAcrossPages,allow_untrusted_events:!!t.allowUntrustedEvents};return m({forward_errors_to_logs:e.forwardErrorsToLogs,forward_console_logs:e.forwardConsoleLogs,forward_reports:e.forwardReports},n)}(e)),{telemetry:i,stop:function(){a.forEach((function(e){return e()}))}}}var xr,Or,kr,Tr,Rr=function(t){var n,r,i=!1,a=K(2),s=K(1),u={},f=function(){},d=new X,p=function(e,t,n,r){void 0===n&&(n=P(b())),void 0===r&&(r=re()),d.add((function(){return p(e,t,n,r)}))},g=function(){},y=new Qt((function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return p.apply(void 0,e)}));function b(){return{view:{referrer:document.referrer,url:window.location.href},context:a.getContext(),user:s.getContext()}}return n={logger:y,init:l((function(n){var r;if(n){if(g=function(){return P(n)},ce()&&(n=function(e){return m({},e,{clientToken:"empty"})}(n)),function(e){return!i||(e.silentMultipleInit||o.error("DD_LOGS is already initialized."),!1)}(n)){var u=function(t){var n=_t(t),r=Jt(t.forwardConsoleLogs,h(e),"Forward Console Logs"),o=Jt(t.forwardReports,h(Ft),"Forward Reports");if(n&&r&&o)return t.forwardErrorsToLogs&&!v(r,e.error)&&r.push(e.error),m({forwardErrorsToLogs:!1!==t.forwardErrorsToLogs,forwardConsoleLogs:r,forwardReports:o,requestErrorResponseLengthLimit:Yt},n)}(n);if(u){if(n.storeContextsAcrossPages){var c=a.getContext();(a=ge(u,en,2)).setContext(N(a.getContext(),c));var l=s.getContext();(s=ge(u,en,1)).setContext(N(s.getContext(),l))}r=t(n,u,b),p=r.handleLog,f=r.getInternalContext,d.drain(),i=!0}}}else o.error("Missing configuration")})),getGlobalContext:l((function(){return a.getContext()})),setGlobalContext:l((function(e){return a.setContext(e)})),setGlobalContextProperty:l((function(e,t){return a.setContextProperty(e,t)})),removeGlobalContextProperty:l((function(e){return a.removeContextProperty(e)})),clearGlobalContext:l((function(){return a.clearContext()})),createLogger:l((function(e,t){return void 0===t&&(t={}),u[e]=new Qt((function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return p.apply(void 0,e)}),j(e),t.handler,t.level,j(t.context)),u[e]})),getLogger:l((function(e){return u[e]})),getInitConfiguration:l((function(){return g()})),getInternalContext:l((function(e){return f(e)})),setUser:l((function(e){(function(e){var t="object"===A(e);return t||o.error("Unsupported user:",e),t})(e)&&s.setContext(he(e))})),getUser:l((function(){return s.getContext()})),setUserProperty:l((function(e,t){var n,r=he((n={},n[e]=t,n))[e];s.setContextProperty(e,r)})),removeUserProperty:l((function(e){return s.removeContextProperty(e)})),clearUser:l((function(){return s.clearContext()}))},r=m({version:"5.5.0",onReady:function(e){e()}},n),Object.defineProperty(r,"_setDebug",{get:function(){return c},enumerable:!1}),r}((function(t,n,r){var o=new nr,i=[];o.subscribe(1,(function(e){return tn("logs",e)}));var a=function(e){return function(t){e.notify(0,{rawLogsEvent:{message:t.message,date:t.startClocks.timeStamp,origin:Wt.AGENT,status:$t.error}}),xn("Error reported to customer",{"error.message":t.message})}}(o),s=function(e){var t=new V((function(){var n=me(de.PAGEHIDE),r=le(e,window,[Z.VISIBILITY_CHANGE,Z.FREEZE,Z.PAGE_HIDE],(function(e){e.type===Z.PAGE_HIDE&&n?t.notify({reason:nn.PAGEHIDE}):e.type===Z.VISIBILITY_CHANGE&&"hidden"===document.visibilityState?t.notify({reason:nn.HIDDEN}):e.type===Z.FREEZE&&t.notify({reason:nn.FROZEN})}),{capture:!0}).stop,o=L;return n||(o=fe(e,window,Z.BEFORE_UNLOAD,(function(){t.notify({reason:nn.UNLOADING})})).stop),function(){r(),o()}}));return t}(n),u=!n.sessionStoreStrategyType||ce()||sn()?function(e){var t="1"===mn(e)?{}:void 0;return{findTrackedSession:function(){return t},expireObservable:new V}}(n):yn(n),c=_r(t,n,a,s,u).stop;i.push((function(){return c()})),Zn(n,o),function(e,t){if(!e.forwardErrorsToLogs)return{stop:L};var n=new V,r=er(n).stop,o=n.subscribe((function(e){t.notify(0,{rawLogsEvent:{message:e.message,date:e.startClocks.timeStamp,error:{kind:e.type,stack:e.stack},origin:Wt.SOURCE,status:$t.error}})}))}(n,o),function(t,n){var r=Nn(t.forwardConsoleLogs).subscribe((function(t){n.notify(0,{rawLogsEvent:{date:re(),message:t.message,origin:Wt.CONSOLE,error:t.api===e.error?{stack:t.stack,fingerprint:t.fingerprint}:void 0,status:Un[t.api]}})}))}(n,o),function(e,t){var n=Vt(e,e.forwardReports).subscribe((function(e){var n,r=e.message,o=Mn[e.type];o===$t.error?n={kind:e.subtype,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:re(),message:r,origin:Wt.REPORT,error:n,status:o}})}))}(n,o);var f,l=or(o).handleLog;if(An(u,n,o,r,a),ce())!function(e){var t=ue();e.subscribe(1,(function(e){t.send("log",e)}))}(o);else{var d=function(e,t,n,r,o){var i=Sr(e,{endpoint:e.logsEndpointBuilder,encoder:Cr()},e.replica&&{endpoint:e.replica.logsEndpointBuilder,encoder:Cr()},n,r,o.expireObservable);return t.subscribe(1,(function(e){i.add(e)})),i}(n,o,a,s,u).stop;i.push((function(){return d()}))}return{handleLog:l,getInternalContext:(f=u,{get:function(e){var t=f.findTrackedSession(e);if(t)return{session_id:t.id}}}).get,stop:function(){i.forEach((function(e){return e()}))}}}));xr=b(),kr=Rr,Tr=xr[Or="DD_LOGS"],xr[Or]=kr,Tr&&Tr.q&&Tr.q.forEach((function(e){return i(e,"onReady callback threw an error:")()}))}();

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

var logsSessionManager_1 = require("../domain/logsSessionManager");
var configuration_1 = require("../domain/configuration");
var assembly_1 = require("../domain/assembly");

@@ -17,4 +16,5 @@ var consoleCollection_1 = require("../domain/console/consoleCollection");

var startLogsBridge_1 = require("../transport/startLogsBridge");
var logger_1 = require("../domain/logger");
var internalContext_1 = require("../domain/internalContext");
var reportError_1 = require("../domain/reportError");
var logsTelemetry_1 = require("../domain/logsTelemetry");
function startLogs(initConfiguration, configuration, buildCommonContext) {

@@ -24,13 +24,3 @@ var lifeCycle = new lifeCycle_1.LifeCycle();

lifeCycle.subscribe(1 /* LifeCycleEventType.LOG_COLLECTED */, function (log) { return (0, browser_core_1.sendToExtension)('logs', log); });
var reportError = function (error) {
lifeCycle.notify(0 /* LifeCycleEventType.RAW_LOG_COLLECTED */, {
rawLogsEvent: {
message: error.message,
date: error.startClocks.timeStamp,
origin: browser_core_1.ErrorSource.AGENT,
status: logger_1.StatusType.error,
},
});
(0, browser_core_1.addTelemetryDebug)('Error reported to customer', { 'error.message': error.message });
};
var reportError = (0, reportError_1.startReportError)(lifeCycle);
var pageExitObservable = (0, browser_core_1.createPageExitObservable)(configuration);

@@ -40,21 +30,4 @@ var session = configuration.sessionStoreStrategyType && !(0, browser_core_1.canUseEventBridge)() && !(0, browser_core_1.willSyntheticsInjectRum)()

: (0, logsSessionManager_1.startLogsSessionManagerStub)(configuration);
var _a = startLogsTelemetry(configuration, reportError, pageExitObservable, session.expireObservable), telemetry = _a.telemetry, stopLogsTelemetry = _a.stop;
var stopLogsTelemetry = (0, logsTelemetry_1.startLogsTelemetry)(initConfiguration, configuration, reportError, pageExitObservable, session).stop;
cleanupTasks.push(function () { return stopLogsTelemetry(); });
telemetry.setContextProvider(function () {
var _a, _b, _c, _d, _e, _f;
return ({
application: {
id: (_a = (0, assembly_1.getRUMInternalContext)()) === null || _a === void 0 ? void 0 : _a.application_id,
},
session: {
id: (_b = session.findTrackedSession()) === null || _b === void 0 ? void 0 : _b.id,
},
view: {
id: (_d = (_c = (0, assembly_1.getRUMInternalContext)()) === null || _c === void 0 ? void 0 : _c.view) === null || _d === void 0 ? void 0 : _d.id,
},
action: {
id: (_f = (_e = (0, assembly_1.getRUMInternalContext)()) === null || _e === void 0 ? void 0 : _e.user_action) === null || _f === void 0 ? void 0 : _f.id,
},
});
});
(0, networkErrorCollection_1.startNetworkErrorCollection)(configuration, lifeCycle);

@@ -67,3 +40,3 @@ (0, runtimeErrorCollection_1.startRuntimeErrorCollection)(configuration, lifeCycle);

if (!(0, browser_core_1.canUseEventBridge)()) {
var stopLogsBatch_1 = (0, startLogsBatch_1.startLogsBatch)(configuration, lifeCycle, reportError, pageExitObservable, session.expireObservable).stop;
var stopLogsBatch_1 = (0, startLogsBatch_1.startLogsBatch)(configuration, lifeCycle, reportError, pageExitObservable, session).stop;
cleanupTasks.push(function () { return stopLogsBatch_1(); });

@@ -74,3 +47,2 @@ }

}
(0, browser_core_1.addTelemetryConfiguration)((0, configuration_1.serializeLogsConfiguration)(initConfiguration));
var internalContext = (0, internalContext_1.startInternalContext)(session);

@@ -86,31 +58,2 @@ return {

exports.startLogs = startLogs;
function startLogsTelemetry(configuration, reportError, pageExitObservable, sessionExpireObservable) {
var telemetry = (0, browser_core_1.startTelemetry)("browser-logs-sdk" /* TelemetryService.LOGS */, configuration);
var cleanupTasks = [];
if ((0, browser_core_1.canUseEventBridge)()) {
var bridge_1 = (0, browser_core_1.getEventBridge)();
var telemetrySubscription_1 = telemetry.observable.subscribe(function (event) { return bridge_1.send('internal_telemetry', event); });
cleanupTasks.push(function () { return telemetrySubscription_1.unsubscribe(); });
}
else {
var telemetryBatch_1 = (0, browser_core_1.startBatchWithReplica)(configuration, {
endpoint: configuration.rumEndpointBuilder,
encoder: (0, browser_core_1.createIdentityEncoder)(),
}, configuration.replica && {
endpoint: configuration.replica.rumEndpointBuilder,
encoder: (0, browser_core_1.createIdentityEncoder)(),
}, reportError, pageExitObservable, sessionExpireObservable);
cleanupTasks.push(function () { return telemetryBatch_1.stop(); });
var telemetrySubscription_2 = telemetry.observable.subscribe(function (event) {
return telemetryBatch_1.add(event, (0, browser_core_1.isTelemetryReplicationAllowed)(configuration));
});
cleanupTasks.push(function () { return telemetrySubscription_2.unsubscribe(); });
}
return {
telemetry: telemetry,
stop: function () {
cleanupTasks.forEach(function (task) { return task(); });
},
};
}
//# sourceMappingURL=startLogs.js.map

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

import type { Context, RawError, RelativeTime } from '@datadog/browser-core';
import type { RawError } from '@datadog/browser-core';
import type { CommonContext } from '../rawLogsEvent.types';

@@ -7,3 +7,1 @@ import type { LogsConfiguration } from './configuration';

export declare function startLogsAssembly(sessionManager: LogsSessionManager, configuration: LogsConfiguration, lifeCycle: LifeCycle, buildCommonContext: () => CommonContext, reportError: (error: RawError) => void): void;
export declare function getRUMInternalContext(startTime?: RelativeTime): Context | undefined;
export declare function resetRUMInternalContext(): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.resetRUMInternalContext = exports.getRUMInternalContext = exports.startLogsAssembly = void 0;
exports.startLogsAssembly = void 0;
var browser_core_1 = require("@datadog/browser-core");
var logger_1 = require("./logger");
var rumInternalContext_1 = require("./rumInternalContext");
function startLogsAssembly(sessionManager, configuration, lifeCycle, buildCommonContext, reportError) {

@@ -27,3 +28,3 @@ var statusWithCustom = logger_1.STATUSES.concat(['custom']);

view: commonContext.view,
}, commonContext.context, getRUMInternalContext(startTime), rawLogsEvent, messageContext);
}, commonContext.context, (0, rumInternalContext_1.getRUMInternalContext)(startTime), rawLogsEvent, messageContext);
if (((_b = configuration.beforeSend) === null || _b === void 0 ? void 0 : _b.call(configuration, log)) === false ||

@@ -38,28 +39,2 @@ (log.origin !== browser_core_1.ErrorSource.AGENT &&

exports.startLogsAssembly = startLogsAssembly;
var logsSentBeforeRumInjectionTelemetryAdded = false;
function getRUMInternalContext(startTime) {
var browserWindow = window;
if ((0, browser_core_1.willSyntheticsInjectRum)()) {
var context = getInternalContextFromRumGlobal(browserWindow.DD_RUM_SYNTHETICS);
if (!context && !logsSentBeforeRumInjectionTelemetryAdded) {
logsSentBeforeRumInjectionTelemetryAdded = true;
(0, browser_core_1.addTelemetryDebug)('Logs sent before RUM is injected by the synthetics worker', {
testId: (0, browser_core_1.getSyntheticsTestId)(),
resultId: (0, browser_core_1.getSyntheticsResultId)(),
});
}
return context;
}
return getInternalContextFromRumGlobal(browserWindow.DD_RUM);
function getInternalContextFromRumGlobal(rumGlobal) {
if (rumGlobal && rumGlobal.getInternalContext) {
return rumGlobal.getInternalContext(startTime);
}
}
}
exports.getRUMInternalContext = getRUMInternalContext;
function resetRUMInternalContext() {
logsSentBeforeRumInjectionTelemetryAdded = false;
}
exports.resetRUMInternalContext = resetRUMInternalContext;
//# sourceMappingURL=assembly.js.map

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

http: {
method: request.method,
method: request.method, // Cast resource method because of case mismatch cf issue RUMF-1152
status_code: request.status,

@@ -44,0 +44,0 @@ url: request.url,

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

@@ -6,0 +7,0 @@ add(message: Context, replicated?: boolean | undefined): void;

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

var browser_core_1 = require("@datadog/browser-core");
function startLogsBatch(configuration, lifeCycle, reportError, pageExitObservable, sessionExpireObservable) {
function startLogsBatch(configuration, lifeCycle, reportError, pageExitObservable, session) {
var batch = (0, browser_core_1.startBatchWithReplica)(configuration, {

@@ -13,3 +13,3 @@ endpoint: configuration.logsEndpointBuilder,

encoder: (0, browser_core_1.createIdentityEncoder)(),
}, reportError, pageExitObservable, sessionExpireObservable);
}, reportError, pageExitObservable, session.expireObservable);
lifeCycle.subscribe(1 /* LifeCycleEventType.LOG_COLLECTED */, function (serverLogsEvent) {

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

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

import { sendToExtension, createPageExitObservable, willSyntheticsInjectRum, canUseEventBridge, getEventBridge, startTelemetry, startBatchWithReplica, isTelemetryReplicationAllowed, ErrorSource, addTelemetryConfiguration, addTelemetryDebug, createIdentityEncoder, } from '@datadog/browser-core';
import { sendToExtension, createPageExitObservable, willSyntheticsInjectRum, canUseEventBridge, } from '@datadog/browser-core';
import { startLogsSessionManager, startLogsSessionManagerStub } from '../domain/logsSessionManager';
import { serializeLogsConfiguration } from '../domain/configuration';
import { startLogsAssembly, getRUMInternalContext } from '../domain/assembly';
import { startLogsAssembly } from '../domain/assembly';
import { startConsoleCollection } from '../domain/console/consoleCollection';

@@ -13,4 +12,5 @@ import { startReportCollection } from '../domain/report/reportCollection';

import { startLogsBridge } from '../transport/startLogsBridge';
import { StatusType } from '../domain/logger';
import { startInternalContext } from '../domain/internalContext';
import { startReportError } from '../domain/reportError';
import { startLogsTelemetry } from '../domain/logsTelemetry';
export function startLogs(initConfiguration, configuration, buildCommonContext) {

@@ -20,13 +20,3 @@ var lifeCycle = new LifeCycle();

lifeCycle.subscribe(1 /* LifeCycleEventType.LOG_COLLECTED */, function (log) { return sendToExtension('logs', log); });
var reportError = function (error) {
lifeCycle.notify(0 /* LifeCycleEventType.RAW_LOG_COLLECTED */, {
rawLogsEvent: {
message: error.message,
date: error.startClocks.timeStamp,
origin: ErrorSource.AGENT,
status: StatusType.error,
},
});
addTelemetryDebug('Error reported to customer', { 'error.message': error.message });
};
var reportError = startReportError(lifeCycle);
var pageExitObservable = createPageExitObservable(configuration);

@@ -36,21 +26,4 @@ var session = configuration.sessionStoreStrategyType && !canUseEventBridge() && !willSyntheticsInjectRum()

: startLogsSessionManagerStub(configuration);
var _a = startLogsTelemetry(configuration, reportError, pageExitObservable, session.expireObservable), telemetry = _a.telemetry, stopLogsTelemetry = _a.stop;
var stopLogsTelemetry = startLogsTelemetry(initConfiguration, configuration, reportError, pageExitObservable, session).stop;
cleanupTasks.push(function () { return stopLogsTelemetry(); });
telemetry.setContextProvider(function () {
var _a, _b, _c, _d, _e, _f;
return ({
application: {
id: (_a = getRUMInternalContext()) === null || _a === void 0 ? void 0 : _a.application_id,
},
session: {
id: (_b = session.findTrackedSession()) === null || _b === void 0 ? void 0 : _b.id,
},
view: {
id: (_d = (_c = getRUMInternalContext()) === null || _c === void 0 ? void 0 : _c.view) === null || _d === void 0 ? void 0 : _d.id,
},
action: {
id: (_f = (_e = getRUMInternalContext()) === null || _e === void 0 ? void 0 : _e.user_action) === null || _f === void 0 ? void 0 : _f.id,
},
});
});
startNetworkErrorCollection(configuration, lifeCycle);

@@ -63,3 +36,3 @@ startRuntimeErrorCollection(configuration, lifeCycle);

if (!canUseEventBridge()) {
var stopLogsBatch_1 = startLogsBatch(configuration, lifeCycle, reportError, pageExitObservable, session.expireObservable).stop;
var stopLogsBatch_1 = startLogsBatch(configuration, lifeCycle, reportError, pageExitObservable, session).stop;
cleanupTasks.push(function () { return stopLogsBatch_1(); });

@@ -70,3 +43,2 @@ }

}
addTelemetryConfiguration(serializeLogsConfiguration(initConfiguration));
var internalContext = startInternalContext(session);

@@ -81,31 +53,2 @@ return {

}
function startLogsTelemetry(configuration, reportError, pageExitObservable, sessionExpireObservable) {
var telemetry = startTelemetry("browser-logs-sdk" /* TelemetryService.LOGS */, configuration);
var cleanupTasks = [];
if (canUseEventBridge()) {
var bridge_1 = getEventBridge();
var telemetrySubscription_1 = telemetry.observable.subscribe(function (event) { return bridge_1.send('internal_telemetry', event); });
cleanupTasks.push(function () { return telemetrySubscription_1.unsubscribe(); });
}
else {
var telemetryBatch_1 = startBatchWithReplica(configuration, {
endpoint: configuration.rumEndpointBuilder,
encoder: createIdentityEncoder(),
}, configuration.replica && {
endpoint: configuration.replica.rumEndpointBuilder,
encoder: createIdentityEncoder(),
}, reportError, pageExitObservable, sessionExpireObservable);
cleanupTasks.push(function () { return telemetryBatch_1.stop(); });
var telemetrySubscription_2 = telemetry.observable.subscribe(function (event) {
return telemetryBatch_1.add(event, isTelemetryReplicationAllowed(configuration));
});
cleanupTasks.push(function () { return telemetrySubscription_2.unsubscribe(); });
}
return {
telemetry: telemetry,
stop: function () {
cleanupTasks.forEach(function (task) { return task(); });
},
};
}
//# sourceMappingURL=startLogs.js.map

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

import type { Context, RawError, RelativeTime } from '@datadog/browser-core';
import type { RawError } from '@datadog/browser-core';
import type { CommonContext } from '../rawLogsEvent.types';

@@ -7,3 +7,1 @@ import type { LogsConfiguration } from './configuration';

export declare function startLogsAssembly(sessionManager: LogsSessionManager, configuration: LogsConfiguration, lifeCycle: LifeCycle, buildCommonContext: () => CommonContext, reportError: (error: RawError) => void): void;
export declare function getRUMInternalContext(startTime?: RelativeTime): Context | undefined;
export declare function resetRUMInternalContext(): void;

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

import { getSyntheticsResultId, getSyntheticsTestId, addTelemetryDebug, willSyntheticsInjectRum, ErrorSource, combine, createEventRateLimiter, getRelativeTime, isEmptyObject, } from '@datadog/browser-core';
import { ErrorSource, combine, createEventRateLimiter, getRelativeTime, isEmptyObject } from '@datadog/browser-core';
import { STATUSES } from './logger';
import { getRUMInternalContext } from './rumInternalContext';
export function startLogsAssembly(sessionManager, configuration, lifeCycle, buildCommonContext, reportError) {

@@ -33,26 +34,2 @@ var statusWithCustom = STATUSES.concat(['custom']);

}
var logsSentBeforeRumInjectionTelemetryAdded = false;
export function getRUMInternalContext(startTime) {
var browserWindow = window;
if (willSyntheticsInjectRum()) {
var context = getInternalContextFromRumGlobal(browserWindow.DD_RUM_SYNTHETICS);
if (!context && !logsSentBeforeRumInjectionTelemetryAdded) {
logsSentBeforeRumInjectionTelemetryAdded = true;
addTelemetryDebug('Logs sent before RUM is injected by the synthetics worker', {
testId: getSyntheticsTestId(),
resultId: getSyntheticsResultId(),
});
}
return context;
}
return getInternalContextFromRumGlobal(browserWindow.DD_RUM);
function getInternalContextFromRumGlobal(rumGlobal) {
if (rumGlobal && rumGlobal.getInternalContext) {
return rumGlobal.getInternalContext(startTime);
}
}
}
export function resetRUMInternalContext() {
logsSentBeforeRumInjectionTelemetryAdded = false;
}
//# sourceMappingURL=assembly.js.map

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

http: {
method: request.method,
method: request.method, // Cast resource method because of case mismatch cf issue RUMF-1152
status_code: request.status,

@@ -41,0 +41,0 @@ url: request.url,

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

@@ -6,0 +7,0 @@ add(message: Context, replicated?: boolean | undefined): void;

import { createIdentityEncoder, startBatchWithReplica } from '@datadog/browser-core';
export function startLogsBatch(configuration, lifeCycle, reportError, pageExitObservable, sessionExpireObservable) {
export function startLogsBatch(configuration, lifeCycle, reportError, pageExitObservable, session) {
var batch = startBatchWithReplica(configuration, {

@@ -9,3 +9,3 @@ endpoint: configuration.logsEndpointBuilder,

encoder: createIdentityEncoder(),
}, reportError, pageExitObservable, sessionExpireObservable);
}, reportError, pageExitObservable, session.expireObservable);
lifeCycle.subscribe(1 /* LifeCycleEventType.LOG_COLLECTED */, function (serverLogsEvent) {

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

{
"name": "@datadog/browser-logs",
"version": "5.4.0",
"version": "5.5.0",
"license": "Apache-2.0",

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

"dependencies": {
"@datadog/browser-core": "5.4.0"
"@datadog/browser-core": "5.5.0"
},
"peerDependencies": {
"@datadog/browser-rum": "5.4.0"
"@datadog/browser-rum": "5.5.0"
},

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

},
"gitHead": "9160f5cc9961c6f20055780d9880c572f6327992"
"gitHead": "7b824d7ff3e7b535e4f6b4d77f16bf1ceb0c9242"
}

@@ -1,21 +0,10 @@

import type { Context, TelemetryEvent, RawError, Observable, PageExitEvent } from '@datadog/browser-core'
import {
sendToExtension,
createPageExitObservable,
TelemetryService,
willSyntheticsInjectRum,
canUseEventBridge,
getEventBridge,
startTelemetry,
startBatchWithReplica,
isTelemetryReplicationAllowed,
ErrorSource,
addTelemetryConfiguration,
addTelemetryDebug,
createIdentityEncoder,
} from '@datadog/browser-core'
import { startLogsSessionManager, startLogsSessionManagerStub } from '../domain/logsSessionManager'
import type { LogsConfiguration, LogsInitConfiguration } from '../domain/configuration'
import { serializeLogsConfiguration } from '../domain/configuration'
import { startLogsAssembly, getRUMInternalContext } from '../domain/assembly'
import { startLogsAssembly } from '../domain/assembly'
import { startConsoleCollection } from '../domain/console/consoleCollection'

@@ -30,4 +19,5 @@ import { startReportCollection } from '../domain/report/reportCollection'

import { startLogsBridge } from '../transport/startLogsBridge'
import { StatusType } from '../domain/logger'
import { startInternalContext } from '../domain/internalContext'
import { startReportError } from '../domain/reportError'
import { startLogsTelemetry } from '../domain/logsTelemetry'

@@ -44,13 +34,3 @@ export function startLogs(

const reportError = (error: RawError) => {
lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {
rawLogsEvent: {
message: error.message,
date: error.startClocks.timeStamp,
origin: ErrorSource.AGENT,
status: StatusType.error,
},
})
addTelemetryDebug('Error reported to customer', { 'error.message': error.message })
}
const reportError = startReportError(lifeCycle)
const pageExitObservable = createPageExitObservable(configuration)

@@ -63,23 +43,10 @@

const { telemetry, stop: stopLogsTelemetry } = startLogsTelemetry(
const { stop: stopLogsTelemetry } = startLogsTelemetry(
initConfiguration,
configuration,
reportError,
pageExitObservable,
session.expireObservable
session
)
cleanupTasks.push(() => stopLogsTelemetry())
telemetry.setContextProvider(() => ({
application: {
id: getRUMInternalContext()?.application_id,
},
session: {
id: session.findTrackedSession()?.id,
},
view: {
id: (getRUMInternalContext()?.view as Context)?.id,
},
action: {
id: (getRUMInternalContext()?.user_action as Context)?.id,
},
}))

@@ -95,9 +62,3 @@ startNetworkErrorCollection(configuration, lifeCycle)

if (!canUseEventBridge()) {
const { stop: stopLogsBatch } = startLogsBatch(
configuration,
lifeCycle,
reportError,
pageExitObservable,
session.expireObservable
)
const { stop: stopLogsBatch } = startLogsBatch(configuration, lifeCycle, reportError, pageExitObservable, session)
cleanupTasks.push(() => stopLogsBatch())

@@ -108,3 +69,2 @@ } else {

addTelemetryConfiguration(serializeLogsConfiguration(initConfiguration))
const internalContext = startInternalContext(session)

@@ -120,42 +80,1 @@

}
function startLogsTelemetry(
configuration: LogsConfiguration,
reportError: (error: RawError) => void,
pageExitObservable: Observable<PageExitEvent>,
sessionExpireObservable: Observable<void>
) {
const telemetry = startTelemetry(TelemetryService.LOGS, configuration)
const cleanupTasks: Array<() => void> = []
if (canUseEventBridge()) {
const bridge = getEventBridge<'internal_telemetry', TelemetryEvent>()!
const telemetrySubscription = telemetry.observable.subscribe((event) => bridge.send('internal_telemetry', event))
cleanupTasks.push(() => telemetrySubscription.unsubscribe())
} else {
const telemetryBatch = startBatchWithReplica(
configuration,
{
endpoint: configuration.rumEndpointBuilder,
encoder: createIdentityEncoder(),
},
configuration.replica && {
endpoint: configuration.replica.rumEndpointBuilder,
encoder: createIdentityEncoder(),
},
reportError,
pageExitObservable,
sessionExpireObservable
)
cleanupTasks.push(() => telemetryBatch.stop())
const telemetrySubscription = telemetry.observable.subscribe((event) =>
telemetryBatch.add(event, isTelemetryReplicationAllowed(configuration))
)
cleanupTasks.push(() => telemetrySubscription.unsubscribe())
}
return {
telemetry,
stop: () => {
cleanupTasks.forEach((task) => task())
},
}
}

@@ -1,13 +0,3 @@

import type { Context, EventRateLimiter, RawError, RelativeTime } from '@datadog/browser-core'
import {
getSyntheticsResultId,
getSyntheticsTestId,
addTelemetryDebug,
willSyntheticsInjectRum,
ErrorSource,
combine,
createEventRateLimiter,
getRelativeTime,
isEmptyObject,
} from '@datadog/browser-core'
import type { EventRateLimiter, RawError } from '@datadog/browser-core'
import { ErrorSource, combine, createEventRateLimiter, getRelativeTime, isEmptyObject } from '@datadog/browser-core'
import type { CommonContext } from '../rawLogsEvent.types'

@@ -19,2 +9,3 @@ import type { LogsConfiguration } from './configuration'

import type { LogsSessionManager } from './logsSessionManager'
import { getRUMInternalContext } from './rumInternalContext'

@@ -71,40 +62,1 @@ export function startLogsAssembly(

}
interface Rum {
getInternalContext?: (startTime?: RelativeTime) => Context | undefined
}
interface BrowserWindow {
DD_RUM?: Rum
DD_RUM_SYNTHETICS?: Rum
}
let logsSentBeforeRumInjectionTelemetryAdded = false
export function getRUMInternalContext(startTime?: RelativeTime): Context | undefined {
const browserWindow = window as BrowserWindow
if (willSyntheticsInjectRum()) {
const context = getInternalContextFromRumGlobal(browserWindow.DD_RUM_SYNTHETICS)
if (!context && !logsSentBeforeRumInjectionTelemetryAdded) {
logsSentBeforeRumInjectionTelemetryAdded = true
addTelemetryDebug('Logs sent before RUM is injected by the synthetics worker', {
testId: getSyntheticsTestId(),
resultId: getSyntheticsResultId(),
})
}
return context
}
return getInternalContextFromRumGlobal(browserWindow.DD_RUM)
function getInternalContextFromRumGlobal(rumGlobal?: Rum): Context | undefined {
if (rumGlobal && rumGlobal.getInternalContext) {
return rumGlobal.getInternalContext(startTime)
}
}
}
export function resetRUMInternalContext() {
logsSentBeforeRumInjectionTelemetryAdded = false
}

@@ -7,2 +7,3 @@ import type { Context, Observable, PageExitEvent, RawError } from '@datadog/browser-core'

import type { LogsEvent } from '../logsEvent.types'
import type { LogsSessionManager } from '../domain/logsSessionManager'

@@ -14,3 +15,3 @@ export function startLogsBatch(

pageExitObservable: Observable<PageExitEvent>,
sessionExpireObservable: Observable<void>
session: LogsSessionManager
) {

@@ -29,3 +30,3 @@ const batch = startBatchWithReplica(

pageExitObservable,
sessionExpireObservable
session.expireObservable
)

@@ -32,0 +33,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