@datadog/browser-logs
Version:
1 lines • 58.2 kB
JavaScript
(()=>{const e={log:"log",debug:"debug",info:"info",warn:"warn",error:"error"},t=console,n={};Object.keys(e).forEach(e=>{n[e]=t[e]});const o="Datadog Browser SDK:",r={debug:n.debug.bind(t,o),log:n.log.bind(t,o),info:n.info.bind(t,o),warn:n.warn.bind(t,o),error:n.error.bind(t,o)},s="https://docs.datadoghq.com",i=s+"/real_user_monitoring/browser/troubleshooting",a="More details:";function c(e,t){return(...n)=>{try{return e(...n)}catch(e){r.error(t,e)}}}let u,l=!1;function d(e){l=e}function f(e){return function(...t){return p(e,this,t)}}function p(e,t,n){try{return e.apply(t,n)}catch(e){g(e)}}function g(e){if(y(e),u)try{u(e)}catch(e){y(e)}}function y(...e){l&&r.error("[MONITOR]",...e)}function m(){if("object"==typeof globalThis)return globalThis;Object.defineProperty(Object.prototype,"_dd_temp_",{get(){return this},configurable:!0});let e=_dd_temp_;return delete Object.prototype._dd_temp_,"object"!=typeof e&&(e="object"==typeof self?self:"object"==typeof window?window:{}),e}const v=m(),b="WorkerGlobalScope"in v;function h(e){const t=v.queueMicrotask;"function"==typeof t?t(f(e)):Promise.resolve().then(f(e))}class S{constructor(e){this.onFirstSubscribe=e,this.observers=[]}subscribe(e){return this.addObserver(e),{unsubscribe:()=>this.removeObserver(e)}}notify(e){this.observers.forEach(t=>t(e))}addObserver(e){this.observers.push(e),1===this.observers.length&&this.onFirstSubscribe&&(this.onLastUnsubscribe=this.onFirstSubscribe(this)||void 0)}removeObserver(e){this.observers=this.observers.filter(t=>e!==t),!this.observers.length&&this.onLastUnsubscribe&&this.onLastUnsubscribe()}}function w(...e){return new S(t=>{const n=e.map(e=>e.subscribe(e=>t.notify(e)));return()=>n.forEach(e=>e.unsubscribe())})}class k extends S{constructor(e){super(),this.maxBufferSize=e,this.buffer=[]}notify(e){this.buffer.push(e),this.buffer.length>this.maxBufferSize&&this.buffer.shift(),super.notify(e)}subscribe(e){let t=!1;const n={unsubscribe:()=>{t=!0,this.removeObserver(e)}};return h(()=>{for(const n of this.buffer){if(t)return;e(n)}t||this.addObserver(e)}),n}unbuffer(){h(()=>{this.maxBufferSize=this.buffer.length=0})}}const _={GRANTED:"granted",NOT_GRANTED:"not-granted"};function x(e,t){const n=m();let o;return n.Zone&&"function"==typeof n.Zone.__symbol__&&(o=e[n.Zone.__symbol__(t)]),o||(o=e[t]),o}function C(e,t){return x(m(),"setTimeout")(f(e),t)}function E(e){x(m(),"clearTimeout")(e)}function T(e,t){return x(m(),"setInterval")(f(e),t)}function O(e){x(m(),"clearInterval")(e)}function R(){}function A(e){return null===e?"null":Array.isArray(e)?"array":typeof e}function I(e){return"object"===A(e)}new Map;const $="?";function P(e){var t,n;const o=[];let r=F(e,"stack");const s=e+"";if(r&&r.startsWith(s)&&(r=r.slice(s.length)),r&&r.split("\n").forEach(e=>{const t=function(e){const t=N.exec(e);if(!t)return;const n=t[2]&&0===t[2].indexOf("native"),o=t[2]&&0===t[2].indexOf("eval"),r=U.exec(t[2]);return o&&r&&(t[2]=r[1],t[3]=r[2],t[4]=r[3]),{args:n?[t[2]]:[],column:t[4]?+t[4]:void 0,func:t[1]||$,line:t[3]?+t[3]:void 0,url:n?void 0:t[2]}}(e)||function(e){const t=B.exec(e);if(t)return{args:[],column:t[4]?+t[4]:void 0,func:t[1]||$,line:t[3]?+t[3]:void 0,url:t[2]}}(e)||function(e){const t=q.exec(e);if(t)return{args:[],column:t[4]?+t[4]:void 0,func:t[1]||$,line:+t[3],url:t[2]}}(e)||function(e){const t=M.exec(e);if(!t)return;const n=t[3]&&t[3].indexOf(" > eval")>-1,o=j.exec(t[3]);return n&&o&&(t[3]=o[1],t[4]=o[2],t[5]=void 0),{args:t[2]?t[2].split(","):[],column:t[5]?+t[5]:void 0,func:t[1]||$,line:t[4]?+t[4]:void 0,url:t[3]}}(e);t&&(!t.func&&t.line&&(t.func=$),o.push(t))}),o.length>0&&function(){if(void 0!==z)return z;const[e,t]=[class extends Error{constructor(){super(),this.name="Error"}},Error].map(e=>new e);return z=G(Object.getPrototypeOf(e))&&t.stack!==e.stack,z}()&&e instanceof Error){const r=[];let s=e;for(;(s=Object.getPrototypeOf(s))&&G(s);){const e=(null===(t=s.constructor)||void 0===t?void 0:t.name)||$;r.push(e)}for(let e=r.length-1;e>=0&&(null===(n=o[0])||void 0===n?void 0:n.func)===r[e];e--)o.shift()}return{message:F(e,"message"),name:F(e,"name"),stack:o}}const L="((?:file|https?|blob|chrome-extension|electron|native|eval|webpack|snippet|<anonymous>|\\w+\\.|\\/).*?)",D="(?::(\\d+))",N=RegExp(`^\\s*at (.*?) ?\\(${L}${D}?${D}?\\)?\\s*$`,"i"),U=RegExp(`\\((\\S*)${D}${D}\\)`),B=RegExp(`^\\s*at\\s*(?:(.*)?(?: @))?\\s*${L}${D}?${D}??\\s*$`,"i"),q=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,M=/^\s*(.*?)(?:\((.*?)\))?(?:(?:(?:^|@)((?:file|https?|blob|chrome|webpack|resource|capacitor|\[native).*?|[^@]*bundle|\[wasm code\])(?::(\d+))?(?::(\d+))?)|@)\s*$/i,j=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;function F(e,t){return I(e)&&"string"==typeof e[t]?e[t]:void 0}const H=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?([\s\S]*)$/;function G(e){return(e.constructor+"").startsWith("class ")}let z;function W(e){const t=Error(e);let n;return t.name="HandlingStack",p(()=>{const e=P(t);e.stack=e.stack.slice(2),n=J(e)}),n}function J(e){let t=V(e);return e.stack.forEach(e=>{const n="?"===e.func?"<anonymous>":e.func,o=e.args&&e.args.length>0?`(${e.args.join(", ")})`:"",r=e.line?":"+e.line:"",s=e.line&&e.column?":"+e.column:"";t+=`\n at ${n}${o} @ ${e.url}${r}${s}`}),t}function V(e){return`${e.name||"Error"}: ${e.message}`}function K(e,t,n,{computeHandlingStack:o}={}){let r=e[t];if("function"!=typeof r){if(!(t in e)||"string"!=typeof t||!t.startsWith("on"))return{stop:R};r=R}let s=!1;const i=function(){if(s)return r.apply(this,arguments);const e=Array.from(arguments);let t;p(n,null,[{target:this,parameters:e,onPostCall(e){t=e},handlingStack:o?W("instrumented method"):void 0}]);const i=r.apply(this,e);return t&&p(t,null,[i]),i};return e[t]=i,{stop(){s=!0,e[t]===i&&(e[t]=r)}}}function X(){return(new Date).getTime()}function Y(){return X()}function Z(){return performance.now()}function Q(){return{relative:Z(),timeStamp:Y()}}function ee(e,t){return t-e}let te;function ne(){var e,t;return void 0===te&&(te=null!==(t=null===(e=performance.timing)||void 0===e?void 0:e.navigationStart)&&void 0!==t?t:performance.timeOrigin),te}const oe=/[^\u0000-\u007F]/;function re(e){return oe.test(e)?void 0!==window.TextEncoder?(new TextEncoder).encode(e).length:new Blob([e]).size:e.length}function se(e,t,n){if("object"!=typeof e||null===e)return JSON.stringify(e);const o=ie(Object.prototype),r=ie(Array.prototype),s=ie(Object.getPrototypeOf(e)),i=ie(e);try{return JSON.stringify(e,t,n)}catch(e){return"<error: unable to serialize object>"}finally{o(),r(),s(),i()}}function ie(e){const t=e,n=t.toJSON;return n?(delete t.toJSON,()=>{t.toJSON=n}):R}function ae(e,t=225280){const n=ie(Object.prototype),o=ie(Array.prototype),r=[],s=new WeakMap,i=ce(e,"$",void 0,r,s),a=JSON.stringify(i);let c=a?a.length:0;if(!(c>t)){for(;r.length>0&&c<t;){const n=r.shift();let o=0;if(Array.isArray(n.source))for(let i=0;i<n.source.length;i++){const a=ce(n.source[i],n.path,i,r,s);if(c+=void 0!==a?JSON.stringify(a).length:4,c+=o,o=1,c>t){le(t,"truncated",e);break}n.target[i]=a}else for(const i in n.source)if(Object.prototype.hasOwnProperty.call(n.source,i)){const a=ce(n.source[i],n.path,i,r,s);if(void 0!==a&&(c+=JSON.stringify(a).length+o+i.length+3,o=1),c>t){le(t,"truncated",e);break}n.target[i]=a}}return n(),o(),i}le(t,"discarded",e)}function ce(e,t,n,o,r){const s=function(e){const t=e;if(t&&"function"==typeof t.toJSON)try{return t.toJSON()}catch(e){}return e}(e);if(!s||"object"!=typeof s)return"bigint"==typeof(i=s)?"[BigInt] "+i.toString():"function"==typeof i?"[Function] "+(i.name||"unknown"):"symbol"==typeof i?"[Symbol] "+(i.description||i.toString()):i;var i;const a=ue(s);if("[Object]"!==a&&"[Array]"!==a&&"[Error]"!==a)return a;const c=e;if(r.has(c))return`[Reference seen at ${r.get(c)}]`;const u=void 0!==n?`${t}.${n}`:t,l=Array.isArray(s)?[]:{};return r.set(c,u),o.push({source:s,target:l,path:u}),l}function ue(e){try{if(e instanceof Event)return{type:(t=e).type,isTrusted:t.isTrusted,currentTarget:t.currentTarget?ue(t.currentTarget):null,target:t.target?ue(t.target):null};if(e instanceof RegExp)return"[RegExp] "+e.toString();const n=Object.prototype.toString.call(e).match(/\[object (.*)\]/);if(n&&n[1])return`[${n[1]}]`}catch(e){}var t;return"[Unserializable]"}function le(e,t,n){r.warn(`The data provided has been ${t} as it is over the limit of ${e} characters:`,n)}const de="No stack, consider using an instance of Error";function fe({originalError:e,stackTrace:t,source:n,useFallbackStack:o=!0,nonErrorPrefix:r}){const s=ve(e);return!t&&s&&(t=P(e)),{source:n,type:t?t.name:void 0,message:ge(t,s,r,e),stack:t?J(t):o?de:void 0}}function pe({stackTrace:e,originalError:t,handlingStack:n,componentStack:o,startClocks:r,nonErrorPrefix:s,useFallbackStack:i=!0,source:a,handling:c}){return{startClocks:r,handling:c,handlingStack:n,componentStack:o,originalError:t,...fe({originalError:t,stackTrace:e,source:a,useFallbackStack:i,nonErrorPrefix:s}),causes:ve(t)?be(t,a):void 0,fingerprint:ye(t),context:me(t)}}function ge(e,t,n,o){return(null==e?void 0:e.message)&&(null==e?void 0:e.name)?e.message:t?"Empty message":n?`${n} ${se(ae(o))}`:se(ae(o))}function ye(e){return ve(e)&&"dd_fingerprint"in e?e.dd_fingerprint+"":void 0}function me(e){if(I(e))return e.dd_context}function ve(e){return e instanceof Error||"[object Error]"===Object.prototype.toString.call(e)}function be(e,t){const n=[];let o=e.cause;for(;null!=o&&n.length<10;){const e=fe({originalError:o,source:t,useFallbackStack:!1});n.push(e),o=ve(o)?o.cause:void 0}return n.length?n:void 0}const he="agent",Se="console",we="logger",ke="source",_e="report";function xe(e){return{...e}}function Ce(e,t){return Object.keys(e).some(n=>e[n]===t)}function Ee(e){return 0===Object.keys(e).length}var Te;!function(e){e.TRACK_INTAKE_REQUESTS="track_intake_requests",e.USE_TREE_WALKER_FOR_ACTION_NAME="use_tree_walker_for_action_name",e.FEATURE_OPERATION_VITAL="feature_operation_vital",e.SHORT_SESSION_INVESTIGATION="short_session_investigation",e.START_STOP_ACTION="start_stop_action",e.START_STOP_RESOURCE="start_stop_resource",e.USE_CHANGE_RECORDS="use_change_records",e.USE_INCREMENTAL_CHANGE_RECORDS="use_incremental_change_records",e.INP_SUBPARTS="inp_subparts",e.TOO_MANY_REQUESTS_INVESTIGATION="too_many_requests_investigation",e.COMPOSED_PATH_SELECTOR="composed_path_selector"}(Te||(Te={}));const Oe=new Set;function Re(e){const{env:t,service:n,version:o,datacenter:r,sdkVersion:s,variant:i}=e,a=[Ae("sdk_version",null!=s?s:"6.32.0")];return t&&a.push(Ae("env",t)),n&&a.push(Ae("service",n)),o&&a.push(Ae("version",o)),r&&a.push(Ae("datacenter",r)),i&&a.push(Ae("variant",i)),a}function Ae(e,t){const n=t?`${e}:${t}`:e;return(n.length>200||function(e){return!!function(){try{return RegExp("[\\p{Ll}]","u"),!0}catch(e){return!1}}()&&RegExp("[^\\p{Ll}\\p{Lo}0-9_:./-]","u").test(e)}(n))&&r.warn(`Tag ${n} doesn't meet tag requirements and will be sanitized. ${a} ${s}/getting_started/tagging/#defining-tags`),Ie(n)}function Ie(e){return e.replace(/,/g,"_")}const $e="datadoghq.com",Pe=["ddsource","dd-api-key","dd-request-id"];function Le(e,t){const n=v.__ddBrowserSdkExtensionCallback;n&&n({type:e,payload:t})}function De(e){return 0!==e&&100*Math.random()<=e}function Ne(e,t,n=function(){if("undefined"!=typeof WeakSet){const e=new WeakSet;return{hasAlreadyBeenSeen(t){const n=e.has(t);return n||e.add(t),n}}}const e=[];return{hasAlreadyBeenSeen(t){const n=e.indexOf(t)>=0;return n||e.push(t),n}}}()){if(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){const e=t.flags||(t.global?"g":"")+(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.sticky?"y":"")+(t.unicode?"u":"");return RegExp(t.source,e)}if(n.hasAlreadyBeenSeen(t))return;if(Array.isArray(t)){const o=Array.isArray(e)?e:[];for(let e=0;e<t.length;++e)o[e]=Ne(o[e],t[e],n);return o}const o="object"===A(e)?e:{};for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(o[e]=Ne(o[e],t[e],n));return o}function Ue(e){return Ne(void 0,e)}function Be(...e){let t;for(const n of e)null!=n&&(t=Ne(t,n));return t}function qe(){var e;const t=v.navigator;return{status:t.onLine?"connected":"not_connected",interfaces:t.connection&&t.connection.type?[t.connection.type]:void 0,effective_type:null===(e=t.connection)||void 0===e?void 0:e.effectiveType}}function Me(){const e=m().DatadogEventBridge;if(e)return{getCapabilities(){var t;return JSON.parse((null===(t=e.getCapabilities)||void 0===t?void 0:t.call(e))||"[]")},getPrivacyLevel(){var t;return null===(t=e.getPrivacyLevel)||void 0===t?void 0:t.call(e)},getAllowedWebViewHosts(){return JSON.parse(e.getAllowedWebViewHosts())},send(t,n,o){const r=o?{id:o}:void 0;e.send(JSON.stringify({eventType:t,event:n,view:r}))}}}function je(e){var t;void 0===e&&(e=null===(t=m().location)||void 0===t?void 0:t.hostname);const n=Me();return!!n&&n.getAllowedWebViewHosts().some(t=>e===t||e.endsWith("."+t))}function Fe(e){return Object.values(e)}function He(e,t,n,o,r){return Ge(e,t,[n],o,r)}function Ge(e,t,n,o,{once:r,capture:s,passive:i}={}){const a=f(t=>{(t.isTrusted||t.__ddIsTrusted||e.allowUntrustedEvents)&&(r&&d(),o(t))}),c=i?{capture:s,passive:i}:s,u=window.EventTarget&&t instanceof EventTarget?window.EventTarget.prototype:t,l=x(u,"addEventListener");function d(){const e=x(u,"removeEventListener");n.forEach(n=>e.call(t,n,a,c))}return n.forEach(e=>l.call(t,e,a,c)),{stop:d}}const ze={HIDDEN:"visibility_hidden",UNLOADING:"before_unload",PAGEHIDE:"page_hide",FROZEN:"page_frozen"};function We(e){return new S(t=>{if(b)return;const{stop:n}=Ge(e,window,["visibilitychange","freeze"],e=>{"visibilitychange"===e.type&&"hidden"===document.visibilityState?t.notify({reason:ze.HIDDEN}):"freeze"===e.type&&t.notify({reason:ze.FROZEN})},{capture:!0}),o=He(e,window,"beforeunload",()=>{t.notify({reason:ze.UNLOADING})}).stop;return()=>{n(),o()}})}function Je({encoder:e,request:t,flushController:n}){let o={};const s=n.flushObservable.subscribe(n=>function(n){const r=Fe(o).join("\n");o={};const s=(a=n.reason,Fe(ze).includes(a)),i=s?t.sendOnExit:t.send;var a;if(s&&e.isAsync){const t=e.finishSync();t.outputBytesCount&&i(Ve(t));const n=[t.pendingData,r].filter(Boolean).join("\n");n&&i({data:n,bytesCount:re(n)})}else r&&e.write(e.isEmpty?r:"\n"+r),e.finish(e=>{i(Ve(e))})}(n));function c(t,s){const c=se(t),u=e.estimateEncodedBytesCount(c);u>=262144?r.warn(`Discarded a message whose size was bigger than the maximum allowed size 256KiB. ${a} ${i}/#technical-limitations`):(function(e){return void 0!==e&&void 0!==o[e]}(s)&&function(t){const r=o[t];delete o[t];const s=e.estimateEncodedBytesCount(r);n.notifyAfterRemoveMessage(s)}(s),function(t,r,s){n.notifyBeforeAddMessage(r),void 0!==s?(o[s]=t,n.notifyAfterAddMessage()):e.write(e.isEmpty?t:"\n"+t,e=>{n.notifyAfterAddMessage(e-r)})}(c,u,s))}return{flushController:n,add:c,upsert:c,stop:s.unsubscribe}}function Ve(e){let t;return t="string"==typeof e.output?e.output:new Blob([e.output],{type:"text/plain"}),{data:t,bytesCount:e.outputBytesCount,encoding:e.encoding}}function Ke(e){return e>=500}function Xe(e,t,n,o,r,s){0===t.transportStatus&&0===t.queuedPayloads.size()&&t.bandwidthMonitor.canHandle(e)?Ze(e,t,n,s,{onSuccess:()=>Qe(0,t,n,o,r,s),onFailure(){t.queuedPayloads.enqueue(e)||s.notify({type:"queue-full",bandwidth:t.bandwidthMonitor.stats(),payload:e}),Ye(t,n,o,r,s)}}):t.queuedPayloads.enqueue(e)||s.notify({type:"queue-full",bandwidth:t.bandwidthMonitor.stats(),payload:e})}function Ye(e,t,n,o,r){2===e.transportStatus&&C(()=>{Ze(e.queuedPayloads.first(),e,t,r,{onSuccess(){e.queuedPayloads.dequeue(),e.currentBackoffTime=1e3,Qe(1,e,t,n,o,r)},onFailure(){e.currentBackoffTime=Math.min(6e4,2*e.currentBackoffTime),Ye(e,t,n,o,r)}})},e.currentBackoffTime)}function Ze(e,t,n,o,{onSuccess:r,onFailure:s}){t.bandwidthMonitor.add(e),n(e,n=>{t.bandwidthMonitor.remove(e),function(e){return"opaque"!==e.type&&(0===e.status&&!navigator.onLine||408===e.status||429===e.status||Ke(e.status))}(n)?(t.transportStatus=t.bandwidthMonitor.ongoingRequestCount>0?1:2,e.retry={count:e.retry?e.retry.count+1:1,lastFailureStatus:n.status},o.notify({type:"failure",bandwidth:t.bandwidthMonitor.stats(),payload:e}),s()):(t.transportStatus=0,o.notify({type:"success",bandwidth:t.bandwidthMonitor.stats(),payload:e}),r())})}function Qe(e,t,n,o,r,s){0===e&&t.queuedPayloads.isFull()&&!t.queueFullReported&&(r({message:`Reached max ${o} events size queued for upload: 20MiB`,source:he,startClocks:Q()}),t.queueFullReported=!0);const i=t.queuedPayloads;for(t.queuedPayloads=et();i.size()>0;)Xe(i.dequeue(),t,n,o,r,s)}function et(){const e=[];return{bytesCount:0,enqueue(t){return!this.isFull()&&(e.push(t),this.bytesCount+=t.bytesCount,!0)},first(){return e[0]},dequeue(){const t=e.shift();return t&&(this.bytesCount-=t.bytesCount),t},size(){return e.length},isFull(){return this.bytesCount>=20971520}}}function tt(e,t,n=16384){const o=new S,r={transportStatus:0,currentBackoffTime:1e3,bandwidthMonitor:{ongoingRequestCount:0,ongoingByteCount:0,canHandle(e){return 0===this.ongoingRequestCount||this.ongoingByteCount+e.bytesCount<=81920&&this.ongoingRequestCount<32},add(e){this.ongoingRequestCount+=1,this.ongoingByteCount+=e.bytesCount},remove(e){this.ongoingRequestCount-=1,this.ongoingByteCount-=e.bytesCount},stats(){return{ongoingByteCount:this.ongoingByteCount,ongoingRequestCount:this.ongoingRequestCount}}},queuedPayloads:et(),queueFullReported:!1};return{observable:o,send(n){for(const s of e)Xe(n,r,(e,t)=>{rt(s,e,t)},s.trackType,t,o)},sendOnExit(t){for(const o of e)nt(o,n,t)}}}function nt(e,t,n){if(navigator.sendBeacon&&n.bytesCount<t)try{const t=e.build("beacon",n);if(navigator.sendBeacon(t,n.data))return}catch(e){!function(e){ot||(ot=!0,g(e))}(e)}rt(e,n)}let ot=!1;function rt(e,t,n){var o,r;(o=e.build("fetch",t),r={method:"POST",body:t.data,mode:"cors"},x(m(),"fetch")(o,r)).then(f(e=>null==n?void 0:n({status:e.status,type:e.type}))).catch(f(()=>null==n?void 0:n({status:0})))}const st=b?1:50;function it({pageMayExitObservable:e,sessionExpireObservable:t}){const n=e.subscribe(e=>c(e.reason)),o=t.subscribe(()=>c("session_expire")),r=new S(()=>()=>{n.unsubscribe(),o.unsubscribe()});let s,i=0,a=0;function c(e){if(0===a)return;const t=a,n=i;a=0,i=0,u(),r.notify({reason:e,messagesCount:t,bytesCount:n})}function u(){E(s),s=void 0}return{flushObservable:r,get messagesCount(){return a},notifyBeforeAddMessage(e){i+e>=16384&&c("bytes_limit"),a+=1,i+=e,void 0===s&&(s=C(()=>{c("duration_limit")},3e4))},notifyAfterAddMessage(e=0){i+=e,a>=st?c("messages_limit"):i>=16384&&c("bytes_limit")},notifyAfterRemoveMessage(e){i-=e,a-=1,0===a&&u()}}}function at(){let e="",t=0;return{isAsync:!1,get isEmpty(){return!e},write(n,o){const r=re(n);t+=r,e+=n,o&&o(r)},finish(e){e(this.finishSync())},finishSync(){const n={output:e,outputBytesCount:t,rawBytesCount:t,pendingData:""};return e="",t=0,n},estimateEncodedBytesCount(e){return e.length}}}const ct="DISCARDED",ut="SKIPPED",lt="log",dt="configuration",ft="usage",pt=["https://www.datadoghq-browser-agent.com","https://www.datad0g-browser-agent.com","https://d3uc069fcn7uxw.cloudfront.net","https://d20xtzwzcl0ceb.cloudfront.net","http://localhost","<anonymous>"],gt=["ddog-gov.com"];let yt;function mt(){return yt||(yt=new k(100)),yt}function vt(t,n){y(e.debug,t,n),mt().notify({rawEvent:{type:lt,message:t,status:"debug",...n}})}function bt(e,t){mt().notify({rawEvent:{type:lt,status:"error",...St(e),...t}})}function ht(e){mt().notify({rawEvent:{type:ft,usage:e}})}function St(e){if(ve(e)){const t=P(e);return{error:{kind:t.name,stack:J(wt(t))},message:t.message}}return{error:{stack:de},message:"Uncaught "+se(e)}}function wt(e){return e.stack=e.stack.filter(e=>!e.url||pt.some(t=>e.url.startsWith(t))),e}function kt(e,t,n,o){return f((...r)=>(o&&ht({feature:o}),e()[t][n](...r)))}function _t(e,t,n){e.changeObservable.subscribe(()=>{const o=e.getContext();n.add(e=>e[t].setContext(o))})}const xt="userContext",Ct="globalContext",Et="accountContext",Tt="getContext",Ot="setContext",Rt="setContextProperty",At="removeContextProperty",It="clearContext";function $t(e,t){t.silentMultipleInit||r.error(e+" is already initialized.")}function Pt(e,t,n){const o={...e};for(const[e,{required:s,type:i}]of Object.entries(t))"string"!==i||Lt(o[e])||(o[e]=o[e]+""),s&&Lt(o[e])&&r.warn(`The property ${e} of ${n} is required; context will not be sent to the intake.`);return o}function Lt(e){return null==e||""===e}function Dt(e="",{propertiesConfig:t={}}={}){let n={};const o=new S,s={getContext:()=>Ue(n),setContext(i){!function(e){const t="object"===A(e);return t||r.error("Unsupported context:",e),t}(i)?s.clearContext():n=ae(Pt(i,t,e)),o.notify()},setContextProperty(r,s){n=ae(Pt({...n,[r]:s},t,e)),o.notify()},removeContextProperty(r){delete n[r],Pt(n,t,e),o.notify()},clearContext(){n={},o.notify()},changeObservable:o};return s}function Nt(e,t,n){const o=n.getHandler(),r=Array.isArray(o)?o:[o];return Bt[e]>=Bt[n.getLevel()]&&r.includes(t)}const Ut={ok:"ok",debug:"debug",info:"info",notice:"notice",warn:"warn",error:"error",critical:"critical",alert:"alert",emerg:"emerg"},Bt={[Ut.ok]:0,[Ut.debug]:1,[Ut.info]:2,[Ut.notice]:4,[Ut.warn]:5,[Ut.error]:6,[Ut.critical]:7,[Ut.alert]:8,[Ut.emerg]:9};function qt(e,{includeMessage:t=!1}={}){return{stack:e.stack,kind:e.type,message:t?e.message:void 0,causes:e.causes,fingerprint:e.fingerprint,handling:e.handling}}const Mt="http",jt=Object.keys(Ut);class Ft{constructor(e,t,n=Mt,o=Ut.debug,r={}){this.handleLogStrategy=e,this.handlerType=n,this.level=o,this.contextManager=Dt("logger"),this.tags=[],this.contextManager.setContext(r),t&&this.contextManager.setContextProperty("logger",{name:t})}logImplementation(e,t,n=Ut.info,o,r){const s=ae(t);let i;if(null!=o){const e=pe({originalError:o,nonErrorPrefix:"Provided",source:we,handling:"handled",startClocks:Q()});i=Be({error:qt(e,{includeMessage:!0})},e.context,s)}else i=s;this.handleLogStrategy({message:ae(e),context:i,status:n},this,r)}log(e,t,n=Ut.info,o){let r;Nt(n,Mt,this)&&(r=W("log")),this.logImplementation(e,t,n,o,r)}setContext(e){this.contextManager.setContext(e)}getContext(){return this.contextManager.getContext()}setContextProperty(e,t){this.contextManager.setContextProperty(e,t)}removeContextProperty(e){this.contextManager.removeContextProperty(e)}clearContext(){this.contextManager.clearContext()}addTag(e,t){this.tags.push(Ae(e,t))}removeTagsWithKey(e){const t=Ie(e);this.tags=this.tags.filter(e=>e!==t&&!e.startsWith(t+":"))}getTags(){return this.tags.slice()}setHandler(e){this.handlerType=e}getHandler(){return this.handlerType}setLevel(e){this.level=e}getLevel(){return this.level}}function Ht(e){return function(t,n,o){let r;Nt(e,Mt,this)&&(r=W("log")),this.logImplementation(t,n,e,o,r)}}function Gt(){return b?{}:{view:{referrer:document.referrer,url:window.location.href}}}function zt(e){return e?(parseInt(e,10)^16*Math.random()>>parseInt(e,10)/4).toString(16):"10000000-1000-4000-8000-100000000000".replace(/[018]/g,zt)}(function(e,t,n,o){var r,s=arguments.length,i=s<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(i=(s<3?r(i):s>3?r(t,n,i):r(t,n))||i);s>3&&i&&Object.defineProperty(t,n,i)})([function(e,t,n){const o=n.value;n.value=function(...e){return(u?f(o):o).apply(this,e)}}],Ft.prototype,"logImplementation",null),Ft.prototype.ok=Ht(Ut.ok),Ft.prototype.debug=Ht(Ut.debug),Ft.prototype.info=Ht(Ut.info),Ft.prototype.notice=Ht(Ut.notice),Ft.prototype.warn=Ht(Ut.warn),Ft.prototype.error=Ht(Ut.error),Ft.prototype.critical=Ht(Ut.critical),Ft.prototype.alert=Ht(Ut.alert),Ft.prototype.emerg=Ht(Ut.emerg);const Wt=/(\S+?)\s*=\s*(.+?)(?:;|$)/g;function Jt(e,t,n=""){const o=e.charCodeAt(t-1),r=o>=55296&&o<=56319?t+1:t;return e.length<=r?e:`${e.slice(0,r)}${n}`}function Vt(e){return Kt(e,location.href).href}function Kt(e,t){const{URL:n}=function(){var e;if(!Xt){let t,n;try{t=document.createElement("iframe"),t.style.display="none",document.body.appendChild(t),n=null!==(e=t.contentWindow)&&void 0!==e?e:v}catch(e){n=v}Xt={URL:n.URL},null==t||t.remove()}return Xt}();try{return void 0!==t?new n(e,t):new n(e)}catch(e){throw Error("Failed to construct URL: "+e)}}let Xt,Yt,Zt;function Qt(e,t,n=0,o){const r=new Date;r.setTime(r.getTime()+n);const s="expires="+r.toUTCString(),i=o&&o.crossSite?"none":"strict",a=o&&o.domain?";domain="+o.domain:"",c=o&&o.secure?";secure":"",u=o&&o.partitioned?";partitioned":"";document.cookie=`${e}=${t};${s};path=/;samesite=${i}${a}${c}${u}`}function en(e){return function(e,t){for(Wt.lastIndex=0;;){const n=Wt.exec(e);if(!n)break;if(n[1]===t)return n[2]}}(document.cookie,e)}function tn(e){return Yt||(Yt=function(e){const t=new Map;for(Wt.lastIndex=0;;){const n=Wt.exec(e);if(!n)break;t.set(n[1],n[2])}return t}(document.cookie)),Yt.get(e)}function nn(e,t){Qt(e,"",0,t)}function on(e=location.hostname,t=document.referrer){if(void 0===Zt){const n=function(e,t){try{return e||Kt(t).hostname}catch(e){}}(e,t);if(n){const e="dd_site_test_"+zt(),t="test",o=n.split(".");let r=o.pop();for(;o.length&&!en(e);)r=`${o.pop()}.${r}`,Qt(e,t,1e3,{domain:r});nn(e,{domain:r}),Zt=r}}return Zt}const rn="datadog-synthetics-",sn=rn+"public-id",an=rn+"result-id",cn=rn+"injects-rum",un=rn+"rum-context";function ln(){return!(b||!v._DATADOG_SYNTHETICS_INJECTS_RUM&&!tn(cn))}const dn=[];function fn(e,t,n,o){const r=function(e,t){return`_dd_c_${e}_${t}`}(n,o);dn.push(He(e,window,"storage",({key:e})=>{r===e&&t.setContext(i())})),t.changeObservable.subscribe(function(){localStorage.setItem(r,JSON.stringify(t.getContext()))});const s=Be(i(),t.getContext());function i(){const e=localStorage.getItem(r);return e?JSON.parse(e):{}}Ee(s)||t.setContext(s)}function pn(){return Dt("account",{propertiesConfig:{id:{type:"string",required:!0},name:{type:"string"}}})}function gn(){return Dt("user",{propertiesConfig:{id:{type:"string"},name:{type:"string"},email:{type:"string"}}})}function yn(){return Dt("global context")}function mn(e,t){const n=e.indexOf(t);n>=0&&e.splice(n,1)}const vn=1/0;let bn;const hn=new Set,Sn=144e5,wn=9e5,kn="cookie",_n="memory",xn="local-storage";let Cn;const En="_dd_s",Tn=/^([a-zA-Z]+)=([a-z0-9-]+)$/;function On(e,t){const n={isExpired:"1"};return t.trackAnonymousUser&&(null==e?void 0:e.anonymousId)&&(n.anonymousId=null==e?void 0:e.anonymousId),n}function Rn(e){return Ee(e)}function An(e){return!Rn(e)}function In(e){return void 0!==e.isExpired||!((void 0===(t=e).created||X()-Number(t.created)<Sn)&&(void 0===t.expire||X()<Number(t.expire)));var t}function $n(e){e.expire=X()+wn+""}function Pn(e){return(t=e,Object.entries(t)).map(([e,t])=>"anonymousId"===e?"aid="+t:`${e}=${t}`).join("&");var t}function Ln(e){const t={};return function(e){return!!e&&(-1!==e.indexOf("&")||Tn.test(e))}(e)&&e.split("&").forEach(e=>{const n=Tn.exec(e);if(null!==n){const[,e,o]=n;"aid"===e?t.anonymousId=o:t[e]=o}}),t}function Dn(e,t,n,o){let r=Pn(n);t.betaEncodeCookieOptions&&(r=Pn({...n,...Ee(n)?{}:{c:Un(e)}})),Qt(En,r,t.trackAnonymousUser?31536e6:o,e)}function Nn(e,t){return t.betaEncodeCookieOptions?function(e){const t=(o=En,function(e){const t=new Map;for(Wt.lastIndex=0;;){const n=Wt.exec(e);if(!n)break;{const e=n[1],o=n[2];t.has(e)?t.get(e).push(o):t.set(e,[o])}}return t}(document.cookie).get(o)||[]),n=Un(e);var o;let r;for(const e of t.reverse())if(r=Ln(e),r.c===n)break;return null==r||delete r.c,null!=r?r:{}}(e):Ln(en(En))}function Un(e){let t=0;return t|=0,t|=(e.domain?e.domain.split(".").length-1:0)<<1,t|=e.crossSite?1:0,t.toString(16)}function Bn(e){localStorage.setItem(En,Pn(e))}function qn(){return Ln(localStorage.getItem(En))}const Mn=[];let jn;function Fn(e,t,n=0){var o;const{isLockEnabled:r,persistSession:s,expireSession:i}=t,a=e=>s({...e,lock:u}),c=()=>{const{lock:e,...n}=t.retrieveSession();return{session:n,lock:e&&!zn(e)?e:void 0}};if(jn||(jn=e),e!==jn)return void Mn.push(e);if(r&&n>=100)return void Gn(t);let u,l=c();if(r){if(l.lock)return void Hn(e,t,n);if(u=zt()+"--"+Y(),a(l.session),l=c(),l.lock!==u)return void Hn(e,t,n)}let d=e.process(l.session);if(r&&(l=c(),l.lock!==u))Hn(e,t,n);else{if(d&&(In(d)?i(d):($n(d),r?a(d):s(d))),r&&(!d||!In(d))){if(l=c(),l.lock!==u)return void Hn(e,t,n);s(l.session),d=l.session}null===(o=e.after)||void 0===o||o.call(e,d||l.session),Gn(t)}}function Hn(e,t,n){C(()=>{Fn(e,t,n+1)},10)}function Gn(e){jn=void 0;const t=Mn.shift();t&&Fn(t,e)}function zn(e){const[,t]=e.split("--");return!t||ee(Number(t),Y())>1e3}const Wn="_DD_SESSION";function Jn(){const e=m();return e[Wn]||(e[Wn]={}),xe(e[Wn])}function Vn(e){m()[Wn]=xe(e)}function Kn(e){const{sessionPersistence:t}=e,n=function(e,t){return Array.isArray(e)?e:void 0!==e?[e]:t.allowFallbackToLocalStorage?[kn,xn]:[kn]}(t,e);for(const t of n){const n=Xn(t,e);if(void 0!==n)return n}}function Xn(e,t){switch(e){case kn:return function(e){const t=function(e){const t={};if(t.secure=!!e.useSecureSessionCookie||!!e.usePartitionedCrossSiteSessionCookie,t.crossSite=!!e.usePartitionedCrossSiteSessionCookie,t.partitioned=!!e.usePartitionedCrossSiteSessionCookie,e.trackSessionAcrossSubdomains){const e=on();if(!e)return;t.domain=e}return t}(e);return t&&function(e){if(void 0===document.cookie||null===document.cookie)return!1;try{const t="dd_cookie_test_"+zt(),n="test";Qt(t,n,6e4,e);const o=en(t)===n;return nn(t,e),o}catch(e){return r.error(e),!1}}(t)?{type:kn,cookieOptions:t}:void 0}(t);case xn:return function(){try{const e=zt(),t="_dd_test_"+e;localStorage.setItem(t,e);const n=localStorage.getItem(t);return localStorage.removeItem(t),e===n?{type:xn}:void 0}catch(e){return}}();case _n:return{type:_n};default:return void r.error(`Invalid session persistence '${e+""}'`)}}const Yn=Sn;let Zn=[];function Qn(e,t,n,o){const r=new S,s=new S,i=function(e,t,n,o,r=function(e,t){return e.type===kn?function(e,t){const n={isLockEnabled:0===(null!=Cn?Cn:Cn=function(e=window){var t;const n=e.navigator.userAgent;return e.chrome||/HeadlessChrome/.test(n)?0:0===(null===(t=e.navigator.vendor)||void 0===t?void 0:t.indexOf("Apple"))||/safari/i.test(n)&&!/chrome|android/i.test(n)?1:2}()),persistSession:n=>Dn(t,e,n,wn),retrieveSession:()=>Nn(t,e),expireSession:n=>Dn(t,e,On(n,e),Sn)};return function(e){if(!tn(En)){const t=tn("_dd"),n=tn("_dd_r"),o=tn("_dd_l"),r={};t&&(r.id=t),o&&/^[01]$/.test(o)&&(r.logs=o),n&&/^[012]$/.test(n)&&(r.rum=n),An(r)&&($n(r),e.persistSession(r))}}(n),n}(t,e.cookieOptions):e.type===xn?function(e){return{isLockEnabled:!1,persistSession:Bn,retrieveSession:qn,expireSession:t=>function(e,t){Bn(On(e,t))}(t,e)}}(t):function(e){return{expireSession:t=>function(e,t){Vn(On(e,t))}(t,e),isLockEnabled:!1,persistSession:Vn,retrieveSession:Jn}}(t)}(e,t)){const s=new S,i=new S,a=new S,c=T(function(){const e=r.retrieveSession();In(e)?Fn({process(e){return In(e)?On(e,t):void 0},after:f},r):f(e)},1e3);let u;p();const{throttled:l,cancel:d}=function(e){let t,n,o=!1;return{throttled(...r){o?t=r:(e(...r),o=!0,n=C(()=>{t&&e(...t),o=!1,t=void 0},1e3))},cancel(){E(n),o=!1,t=void 0}}}(()=>{Fn({process(e){if(Rn(e))return;const r=f(e);return function(e){if(Rn(e))return!1;const r=o(e[n]);e[n]=r,delete e.isExpired,"0"===r||e.id||(e.id=zt(),e.created=X()+""),t.trackAnonymousUser&&!e.anonymousId&&(e.anonymousId=zt())}(r),r},after(e){An(e)&&!g()&&function(e){u=e,s.notify()}(e),u=e}},r)});function f(e){return In(e)&&(e=On(e,t)),g()&&(function(e){return u.id!==e.id||u[n]!==e[n]}(e)?(u=On(u,t),i.notify()):(a.notify({previousState:u,newState:e}),u=e)),e}function p(){Fn({process(e){if(Rn(e))return e.anonymousId=zt(),On(e,t)},after(e){u=e}},r)}function g(){return void 0!==(null==u?void 0:u[n])}return{expandOrRenewSession:l,expandSession(){Fn({process(e){return g()?f(e):void 0}},r)},getSession(){return u},renewObservable:s,expireObservable:i,sessionStateUpdateObservable:a,restartSession:p,expire(e){d(),!1===e&&u&&delete u.anonymousId,r.expireSession(u),f(On(u,t))},stop(){O(c)},updateSessionState(e){Fn({process(t){return{...t,...e}},after:f},r)}}}(e.sessionStoreStrategyType,e,t,n);Zn.push(()=>i.stop());const a=function({expireDelay:e,maxEntries:t}){let n=[];bn||(bn=T(()=>{hn.forEach(e=>e())},6e4));const o=()=>{const t=Z()-e;for(;n.length>0&&n[n.length-1].endTime<t;)n.pop()};return hn.add(o),{add(e,o){const r={value:e,startTime:o,endTime:vn,remove(){mn(n,r)},close(e){r.endTime=e}};return t&&n.length>=t&&n.pop(),n.unshift(r),r},find(e=1/0,t={returnInactive:!1}){for(const o of n)if(o.startTime<=e){if(t.returnInactive||e<=o.endTime)return o.value;break}},closeActive(e){const t=n[0];t&&t.endTime===vn&&t.close(e)},findAll(e=1/0,t=0){const o=e+t;return n.filter(t=>t.startTime<=o&&e<=t.endTime).map(e=>e.value)},getEntries(e){return n.filter(t=>t.startTime===e)},reset(){n=[]},stop(){hn.delete(o),0===hn.size&&bn&&(O(bn),bn=void 0)}}}({expireDelay:Yn});if(Zn.push(()=>a.stop()),i.renewObservable.subscribe(()=>{a.add(u(),Z()),r.notify()}),i.expireObservable.subscribe(()=>{s.notify(),a.closeActive(Z())}),i.expandOrRenewSession(),a.add(u(),[0,ne()][0]),c=Te.SHORT_SESSION_INVESTIGATION,Oe.has(c)){const t=i.getSession();t&&function(e,t){if(!window.cookieStore||!t.created)return;const n=Number(t.created),o=X(),{stop:r}=He(e,cookieStore,"change",function(e){const s=function(e,t){for(let n=e.length-1;n>=0;n-=1){const o=e[n];if(t(o))return o}}(e.changed,e=>e.name===En);if(!s)return;const i=X()-n;if(i>84e4)r();else{const e=Ln(s.value);if(e.id&&e.id!==t.id){r();const n=X()-o;eo().then(o=>{vt("Session cookie changed",{time:n,session_age:i,old:t,new:e,cookie:o})}).catch(g)}}});Zn.push(r)}(e,t)}var c;function u(){const n=i.getSession();return n?{id:n.id,trackingType:n[t],isReplayForced:!!n.forcedReplay,anonymousId:n.anonymousId}:(async function(e){const t=e.sessionStoreStrategyType;if(!t)return;let n,o;t.type===kn?(n=Nn(t.cookieOptions,e),o={cookie:await eo(),currentDomain:`${window.location.protocol}//${window.location.hostname}`}):n=qn(),vt("Unexpected session state",{sessionStoreStrategyType:t.type,session:n,isSyntheticsTest:!!function(){const e=function(){const e=v._DATADOG_SYNTHETICS_RUM_CONTEXT;if(e)return e;const t=tn(un);return t?function(e){try{return JSON.parse(e)}catch(e){}}(decodeURIComponent(t)):{test_id:window._DATADOG_SYNTHETICS_PUBLIC_ID||tn(sn),result_id:window._DATADOG_SYNTHETICS_RESULT_ID||tn(an)}}();return"object"==typeof(t=e)&&null!==t&&"string"==typeof t.test_id&&"string"==typeof t.result_id?e:void 0;var t}(),createdTimestamp:null==n?void 0:n.created,expireTimestamp:null==n?void 0:n.expire,...o})}(e).catch(()=>{}),{id:"invalid",trackingType:"0",isReplayForced:!1,anonymousId:void 0})}return o.observable.subscribe(()=>{o.isGranted()?i.expandOrRenewSession():i.expire(!1)}),function(e){const{stop:t}=Ge(e,window,["click","touchstart","keydown","scroll"],()=>{o.isGranted()&&i.expandOrRenewSession()},{capture:!0,passive:!0});Zn.push(t)}(e),function(e){const t=()=>{"visible"===document.visibilityState&&i.expandSession()},{stop:n}=He(e,document,"visibilitychange",t);Zn.push(n);const o=T(t,6e4);Zn.push(()=>{O(o)})}(e),function(e){const{stop:t}=He(e,window,"resume",()=>i.restartSession(),{capture:!0});Zn.push(t)}(e),{findSession:(e,t)=>a.find(e,t),renewObservable:r,expireObservable:s,sessionStateUpdateObservable:i.sessionStateUpdateObservable,expire:i.expire,updateSessionState:i.updateSessionState}}async function eo(){let e;return e="cookieStore"in window?await window.cookieStore.getAll(En):document.cookie.split(/\s*;\s*/).filter(e=>e.startsWith(En)),{count:e.length,domain:on()||"undefined",...e}}function to(e,t){return"0"===(n=t)||"1"===n?t:De(e.sessionSampleRate)?"1":"0";var n}let no={};const oo={[e.log]:Ut.info,[e.debug]:Ut.debug,[e.info]:Ut.info,[e.warn]:Ut.warn,[e.error]:Ut.error},ro={intervention:"intervention",deprecation:"deprecation",cspViolation:"csp_violation"};function so(e){return{startClocks:Q(),source:_e,handling:"unhandled",...e}}function io(e,t,n,o,r){return n?J({name:e,message:t,stack:[{func:"?",url:n,line:null!=o?o:void 0,column:null!=r?r:void 0}]}):void 0}let ao;const co=new WeakMap;function uo({target:e,parameters:[t,n]}){co.set(e,{state:"open",method:(t+"").toUpperCase(),url:Vt(n+"")})}function lo({target:e}){const t=co.get(e);t&&(t.isAborted=!0)}let fo;const po=[];function go({responseBodyAction:e}={}){return e&&po.push(e),fo||(fo=new S(e=>{if(!v.fetch)return;const{stop:t}=K(v,"fetch",t=>function({parameters:e,onPostCall:t,handlingStack:n},o){var r,s;const[i,a]=e;let c=a&&a.method;void 0===c&&i instanceof Request&&(c=i.method);const u=void 0!==c?(c+"").toUpperCase():"GET",l=i instanceof Request?i.url:Vt(i+""),d={state:"start",init:a,input:i,method:u,startClocks:Q(),url:l,handlingStack:n,isAbortedOnStart:i instanceof Request&&(null===(r=i.signal)||void 0===r?void 0:r.aborted)||(null===(s=null==a?void 0:a.signal)||void 0===s?void 0:s.aborted)||!1};o.notify(d),e[0]=d.input,e[1]=d.init,t(e=>{(async function(e,t,n){var o,r;const s=n;let i;s.state="resolve";try{i=await t}catch(t){return s.status=0,s.isAborted=(null===(r=null===(o=s.init)||void 0===o?void 0:o.signal)||void 0===r?void 0:r.aborted)||t instanceof DOMException&&t.code===DOMException.ABORT_ERR,s.error=t,void e.notify(s)}s.response=i,s.status=i.status,s.responseType=i.type,s.isAborted=!1;const a=po.reduce((e,t)=>Math.max(e,t(s)),0);if(0!==a){const e=function(e){try{return e.clone()}catch(e){return}}(i);if(e&&e.body)try{const t=await async function(e,t){const n=e.getReader(),o=[];for(;;){const e=await n.read();if(e.done)break;t.collectStreamBody&&o.push(e.value)}return n.cancel().catch(R),t.collectStreamBody?function(e){if(1===e.length)return e[0];const t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t);let o=0;for(const t of e)n.set(t,o),o+=t.length;return n}(o):void 0}(e.body,{collectStreamBody:2===a});s.responseBody=t&&(new TextDecoder).decode(t)}catch(e){}}e.notify(s)})(o,e,d).catch(g)})}(t,e),{computeHandlingStack:!0});return t})),fo}function yo(e,t,n){const o=function(e,t){const n="/api/v2/"+t,o=e.proxy;if("string"==typeof o){const e=Vt(o);return t=>`${e}?ddforward=${encodeURIComponent(`${n}?${t}`)}`}if("function"==typeof o)return e=>o({path:n,parameters:e});const r=function(e,t){const{site:n=$e,internalAnalyticsSubdomain:o}=t;if("logs"===e&&t.usePciIntake&&n===$e)return"pci.browser-intake-datadoghq.com";if(o&&n===$e)return`${o}.${$e}`;if("dd0g-gov.com"===n)return"http-intake.logs."+n;const r=n.split("."),s=r.pop();return`browser-intake-${r.join("-")}.${s}`}(t,e);return e=>`https://${r}${n}?${e}`}(e,t);return{build(r,s){const i=function({clientToken:e,internalAnalyticsSubdomain:t,source:n="browser"},o,r,{retry:s,encoding:i},a=[]){const c=["ddsource="+n,"dd-api-key="+e,"dd-evp-origin-version="+encodeURIComponent("6.32.0"),"dd-evp-origin=browser","dd-request-id="+zt()].concat(a);return i&&c.push("dd-evp-encoding="+i),"rum"===o&&(c.push("batch_time="+Y(),"_dd.api="+r),s&&c.push("_dd.retry_count="+s.count,"_dd.retry_after="+s.lastFailureStatus)),t&&c.reverse(),c.join("&")}(e,t,r,s,n);return o(i)},trackType:t}}function mo(e){const t=e.site||$e,n=function(e){return"flutter"===e||"unity"===e?e:"browser"}(e.source),o=function(e){return{logsEndpointBuilder:yo(e,"logs"),rumEndpointBuilder:yo(e,"rum"),profilingEndpointBuilder:yo(e,"profile"),sessionReplayEndpointBuilder:yo(e,"replay"),exposuresEndpointBuilder:yo(e,"exposures"),flagEvaluationEndpointBuilder:yo(e,"flagevaluation")}}({...e,site:t,source:n}),r=function(e){if(!e.replica)return;const t={...e,site:$e,clientToken:e.replica.clientToken};return{logsEndpointBuilder:yo(t,"logs"),rumEndpointBuilder:yo(t,"rum",["application.id="+e.replica.applicationId])}}({...e,site:t,source:n});return{replica:r,site:t,source:n,...o}}function vo(e){return"xhr"===e?"XHR":"Fetch"}const bo=class{constructor(){this.callbacks={}}notify(e,t){const n=this.callbacks[e];n&&n.forEach(e=>e(t))}subscribe(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),{unsubscribe:()=>{this.callbacks[e]=this.callbacks[e].filter(e=>t!==e)}}}},ho={[Ut.ok]:e.debug,[Ut.debug]:e.debug,[Ut.info]:e.info,[Ut.notice]:e.info,[Ut.warn]:e.warn,[Ut.error]:e.error,[Ut.critical]:e.error,[Ut.alert]:e.error,[Ut.emerg]:e.error},So="logs";const wo=["chrome-extension://","moz-extension://"];function ko(e){return wo.some(t=>e.includes(t))}function _o(e,t){return null==e||"string"==typeof e||(r.error(t+" must be defined as a string"),!1)}function xo(e,t){return!!(void 0===e||(n=e,function(e){return"number"==typeof e}(n)&&n>=0&&n<=100))||(r.error(t+" Sample Rate should be a number between 0 and 100"),!1);var n}function Co(e,t,n){return void 0===e?[]:"all"===e||Array.isArray(e)&&e.every(e=>t.includes(e))?"all"===e?t:function(e){const t=new Set;return e.forEach(e=>t.add(e)),Array.from(t)}(e):void r.error(`${n} should be "all" or an array with allowed values "${t.join('", "')}"`)}const Eo=function(){const o=function(e){const t=new S;return{tryToInit(t){e||(e=t)},update(n){e=n,t.notify()},isGranted:()=>e===_.GRANTED,observable:t}}(),i=function(){const e=new k(500),t=new S(e=>{const t=(t,n)=>{const o=pe({stackTrace:n,originalError:t,startClocks:Q(),nonErrorPrefix:"Uncaught",source:ke,handling:"unhandled"});e.notify(o)},{stop:n}=(o=t,K(m(),"onerror",({parameters:[e,t,n,r,s]})=>{let i;ve(s)||(i=function(e,t,n,o){if(void 0===t)return;const{name:r,message:s}=function(e){let t,n;return"[object String]"==={}.toString.call(e)&&([,t,n]=H.exec(e)),{name:t,message:n}}(e);return{name:r,message:s,stack:[{url:t,column:o,line:n}]}}(e,t,n,r)),o(null!=s?s:e,i)}));var o;const{stop:r}=function(e){return K(m(),"onunhandledrejection",({parameters:[t]})=>{e(t.reason||"Empty reason")})}(t);return()=>{n(),r()}}).subscribe(t=>{e.notify({type:0,error:t})});return{observable:e,stop(){t.unsubscribe()}}}().observable;let l=function(t,n,o){const i=function(){const e=[];return{add(t){e.push(t)>500&&e.splice(0,1)},remove(t){mn(e,t)},drain(t){e.forEach(e=>e(t)),e.length=0}}}(),l=yn();_t(l,Ct,i);const d=pn();_t(d,Et,i);const f=gn();let p,g;_t(f,xt,i);const y=function(){const e={};return{register(t,n){return e[t]||(e[t]=[]),e[t].push(n),{unregister(){e[t]=e[t].filter(e=>e!==n)}}},triggerHook(t,n){const o=e[t]||[],r=[];for(const e of o){const t=e(n);if(t===ct)return ct;t!==ut&&r.push(t)}return Be(...r)}}}(),h=n.observable.subscribe(w);function w(){if(!g||!p||!n.isGranted())return;(function(e,t,n){const o=new S,{enabled:r,metricsEnabled:s}=function(e,t,n,o,r=1,s=15){const i={},a=!gt.includes(t.site)&&De(t.telemetrySampleRate),c={[lt]:a,[dt]:a&&De(t.telemetryConfigurationSampleRate),[ft]:a&&De(t.telemetryUsageSampleRate),metric:a&&De(r)},l={is_local_file:"file:"===(null===(f=v.location)||void 0===f?void 0:f.protocol),is_worker:b},d=mt();var f;return d.subscribe(({rawEvent:r,metricName:a})=>{if(a&&!c.metric||!c[r.type])return;const u=a||r.status||r.type;let d=i[u];if(d||(d=i[u]=new Set),d.size>=s)return;const f=se(r);if(d.has(f))return;const p=n.triggerHook(1,{startTime:Q().relative});if(p===ct)return;const g=function(e,n,o,r){const s={type:"telemetry",date:Q().timeStamp,service:n,version:"6.32.0",source:"browser",_dd:{format_version:2},telemetry:Be(o,{runtime_env:r,connectivity:qe(),sdk_setup:"npm"}),ddtags:Re(t).join(","),experimental_features:Array.from(Oe)};return Be(s,e)}(p,e,r,l);o.notify(g),Le("telemetry",g),d.add(f)}),d.unbuffer(),u=bt,{enabled:a,metricsEnabled:c.metric}}("browser-logs-sdk",t,n,o),{stop:i}=function(e,t){const n=[];if(je()){const e=Me(),o=t.subscribe(t=>e.send("internal_telemetry",t));n.push(o.unsubscribe)}else{const o=[e.rumEndpointBuilder];e.replica&&function(e){return"datad0g.com"===e.site}(e)&&o.push(e.replica.rumEndpointBuilder);const r=Je({encoder:at(),request:tt(o,R),flushController:it({pageMayExitObservable:We(e),sessionExpireObservable:new S})});n.push(r.stop);const s=t.subscribe(r.add);n.push(s.unsubscribe)}return{stop:()=>n.forEach(e=>e())}}(t,o)})(0,g,y),h.unsubscribe();const e=o(p,g,y);i.drain(e)}return{init(t,o){if(!t)return void r.error("Missing configuration");if(i=t.enableExperimentalFeatures,Array.isArray(i)&&i.filter(e=>Ce(Te,e)).forEach(e=>{Oe.add(e)}),je()&&(t=function(e){return{...e,clientToken:"empty"}}(t)),p=t,function(e){mt().notify({rawEvent:{type:dt,configuration:e}})}(function(e){const t={session_sample_rate:(n=e).sessionSampleRate,telemetry_sample_rate:n.telemetrySampleRate,telemetry_configuration_sample_rate:n.telemetryConfigurationSampleRate,telemetry_usage_sample_rate:n.telemetryUsageSampleRate,use_before_send:!!n.beforeSend,use_partitioned_cross_site_session_cookie:n.usePartitionedCrossSiteSessionCookie,use_secure_session_cookie:n.useSecureSessionCookie,use_proxy:!!n.proxy,silent_multiple_init:n.silentMultipleInit,track_session_across_subdomains:n.trackSessionAcrossSubdomains,track_anonymous_user:n.trackAnonymousUser,session_persistence:Array.isArray(n.sessionPersistence)?n.sessionPersistence[0]:n.sessionPersistence,allow_fallback_to_local_storage:!!n.allowFallbackToLocalStorage,store_contexts_across_pages:!!n.storeContextsAcrossPages,allow_untrusted_events:!!n.allowUntrustedEvents,tracking_consent:n.trackingConsent,use_allowed_tracking_origins:Array.isArray(n.allowedTrackingOrigins),beta_encode_cookie_options:n.betaEncodeCookieOptions,source:n.source,sdk_version:n.sdkVersion,variant:n.variant};var n;return{forward_errors_to_logs:e.forwardErrorsToLogs,forward_console_logs:e.forwardConsoleLogs,forward_reports:e.forwardReports,use_pci_intake:e.usePciIntake,...t}}(t)),g)return void $t("DD_LOGS",t);var i;const u=function(t,n){!0===t.usePciIntake&&t.site&&"datadoghq.com"!==t.site&&r.warn("PCI compliance for Logs is only available for Datadog organizations in the US1 site. Default intake will be used.");const o=function(e,t){var n,o,i,u,l,d,f,p,g,y;if(e&&e.clientToken)if(void 0===e.allowedTrackingOrigins||Array.isArray(e.allowedTrackingOrigins)){if((!(v=e.site)||"string"!=typeof v||/(datadog|ddog|datad0g|dd0g)/.test(v)||(r.error(`Site should be a valid Datadog site. ${a} ${s}/getting_started/site/.`),0))&&xo(e.sessionSampleRate,"Session")&&xo(e.telemetrySampleRate,"Telemetry")&&xo(e.telemetryConfigurationSampleRate,"Telemetry Configuration")&&xo(e.telemetryUsageSampleRate,"Telemetry Usage")&&_o(e.version,"Version")&&_o(e.env,"Env")&&_o(e.service,"Service")&&function(e,t){const n=m().location,o=n?n.origin:"",s=e.allowedTrackingOrigins;if(!s)return!function(e,t=""){return!ko(e)&&ko(t.split("\n").filter(e=>{const t=e.trim();return t.length&&/^at\s+|@/.test(t)})[1]||"")}(o,t)||(r.error("Running the Browser SDK in a Web extension content script is forbidden unless the `allowedTrackingOrigins` option is provided."),!1);const i=function(e,t,n=!1){return e.some(e=>{try{if("function"==typeof e)return e(t);if(e instanceof RegExp)return e.test(t);if("string"==typeof e)return n?t.startsWith(e):e===t}catch(e){r.error(e)}return!1})}(s,o);return i||r.error("SDK initialized on a non-allowed domain."),i}(e,null!=t?t:"")){var v;if(void 0===e.trackingConsent||Ce(_,e.trackingConsent))return{beforeSend:e.beforeSend&&c(e.beforeSend,"beforeSend threw an error:"),sessionStoreStrategyType:b?void 0:Kn(e),sessionSampleRate:null!==(n=e.sessionSampleRate)&&void 0!==n?n:100,telemetrySampleRate:null!==(o=e.telemetrySampleRate)&&void 0!==o?o:20,telemetryConfigurationSampleRate:null!==(i=e.telemetryConfigurationSampleRate)&&void 0!==i?i:5,telemetryUsageSampleRate:null!==(u=e.telemetryUsageSampleRate)&&void 0!==u?u:5,service:null!==(l=e.service)&&void 0!==l?l:void 0,env:null!==(d=e.env)&&void 0!==d?d:void 0,version:null!==(f=e.version)&&void 0!==f?f:void 0,datacenter:null!==(p=e.datacenter)&&void 0!==p?p:void 0,silentMultipleInit:!!e.silentMultipleInit,allowUntrustedEvents:!!e.allowUntrustedEvents,trackingConsent:null!==(g=e.trackingConsent)&&void 0!==g?g:_.GRANTED,trackAnonymousUser:null===(y=e.trackAnonymousUser)||void 0===y||y,storeContextsAcrossPages:!!e.storeContextsAcrossPages,betaEncodeCookieOptions:!!e.betaEncodeCookieOptions,variant:e.variant,sdkVersion:e.sdkVersion,...mo(e)};r.error('Tracking Consent should be either "granted" or "not-granted"')}}else r.error("Allowed Tracking Origins must be an array");else r.error("Client Token is not configured, we will not send any data.")}(t,n),i=Co(t.forwardConsoleLogs,Fe(e),"Forward Console Logs"),u=Co(t.forwardReports,Fe(ro),"Forward Reports");if(o&&i&&u)return t.forwardErrorsToLogs&&!i.includes(e.error)&&i.push(e.error),{forwardErrorsToLogs:!1!==t.forwardErrorsToLogs,forwardConsoleLogs:i,forwardReports:u,requestErrorResponseLengthLimit:32768,...o}}(t,o);u&&(g=u,go().subscribe(R),n.tryToInit(u.trackingConsent),w())},get initConfiguration(){return p},globalContext:l,accountContext:d,userContext:f,getInternalContext:R,handleLog(e,n,o,r=t(),s=Y()){i.add(t=>t.handleLog(e,n,o,r,s))}}}(Gt,o,(r,s,a)=>{const c=function(o,r,s,i,a){const c=new bo,u=[];c.subscribe(1,e=>Le("logs",e));const l=function(e){return t=>{e.notify(0,{rawLogsEvent:{message:t.message,date:t.startClocks.timeStamp,origin:he,status:Ut.error}}),vt("Error reported to customer",{"error.message":t.message})}}(c),d=We(o),g=!o.sessionStoreStrategyType||je()||ln()?function(e){const t="1"===to(e)?{}:void 0;return{findTrackedSession:()=>t,expireObservable:new S}}(o):function(e,t){const n=Qn(e,"logs",t=>to(e,t),t);return{findTrackedSession(e,t={returnInactive:!1}){const o=n.findSession(e,t);return o&&"1"===o.trackingType?{id:o.id,anonymousId:o.anonymousId}:void 0},expireObservable:n.expireObservable}}(o,s);!function(e,t){function n(){return t.isGranted()?ut:ct}e.register(0,n),e.register(1,n)}(a,s),function(e,t,n){e.register(0,({startTime:e})=>{const o=n.findTrackedSession(e);return n.findTrackedSession(e,{returnInactive:!0})?{service:t.service,session_id:o?o.id:void 0,session:o?{id:o.id}:void 0}:ct}),e.register(1,({startTime:e})=>{const t=n.findTrackedSession(e);return t&&t.id?{session:{id:t.id}}:ut})}(a,o,g);const y=function(e,t,n){const o=pn();return t.storeContextsAcrossPages&&fn(t,o,n,4),e.register(0,()=>{const e=o.getContext();return Ee(e)|