Socket
Socket
Sign inDemoInstall

@datadog/browser-rum

Package Overview
Dependencies
Maintainers
1
Versions
254
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datadog/browser-rum - npm Package Compare versions

Comparing version 2.1.2 to 2.2.0

2

bundle/datadog-rum.js

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

!function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([,function(t,e,n){"use strict";n.r(e),n.d(e,"datadogRum",(function(){return Gn})),n.d(e,"makeRumGlobal",(function(){return zn}));var r=function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function i(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}}function o(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],a=0,u=o.length;a<u;a++,i++)r[i]=o[a];return r}function a(t){var e={};return Object.keys(t).forEach((function(n){var r;e[(r=n,r.replace(/[A-Z]/g,(function(t,e){return(0!==e?"_":"")+t.toLowerCase()})).replace(/-/g,"_"))]=function t(e){if(Array.isArray(e))return e.map((function(e){return t(e)}));if("object"==typeof e&&null!==e)return a(e);return e}(t[n])})),e}var u=function(t){return Array.isArray(t)},s=function(t){return!Array.isArray(t)&&"object"==typeof t&&null!==t};function c(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];for(var r=0,i=e;r<i.length;r++){var o=i[r];null!=o&&(t=l(t,o,d()))}return t}function f(t){return l(void 0,t,d())}function d(){if("undefined"!=typeof WeakSet){var t=new WeakSet;return{hasAlreadyBeenSeen:function(e){var n=t.has(e);return n||t.add(e),n}}}var e=[];return{hasAlreadyBeenSeen:function(t){var n=e.indexOf(t)>=0;return n||e.push(t),n}}}function l(t,e,n){if(void 0===e)return t;if(!s(e)&&!u(e))return e;if(!n.hasAlreadyBeenSeen(e)){if(s(e)&&(void 0===t||s(t))){var r=t||{};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=l(r[i],e[i],n));return r}if(u(e)&&(void 0===t||u(t))){(r=t||[]).length=Math.max(r.length,e.length);for(var o=0;o<e.length;o+=1)r[o]=l(r[o],e[o],n);return r}return e}}var p={AGENT:"agent",CONSOLE:"console",CUSTOM:"custom",LOGGER:"logger",NETWORK:"network",SOURCE:"source"};function m(t,e,n){return t&&(void 0!==t.message||e instanceof Error)?{message:t.message||"Empty message",stack:v(t),type:t.name}:{message:n+" "+z(e),stack:"No stack, consider using an instance of Error",type:t&&t.name}}function v(t){var e=(t.name||"Error")+": "+t.message;return t.stack.forEach((function(t){var n="?"===t.func?"<anonymous>":t.func,r=t.args&&t.args.length>0?"("+t.args.join(", ")+")":"",i=t.line?":"+t.line:"",o=t.line&&t.column?":"+t.column:"";e+="\n at "+n+r+" @ "+t.url+i+o})),e}var E=/[^\u0000-\u007F]/,h=function(){function t(t,e,n){void 0===n&&(n=!1),this.endpointUrl=t,this.bytesLimit=e,this.withBatchTime=n}return t.prototype.send=function(t,e){var n=this.withBatchTime?function(t){return t+(-1===t.indexOf("?")?"?":"&")+"batch_time="+(new Date).getTime()}(this.endpointUrl):this.endpointUrl;if(navigator.sendBeacon&&e<this.bytesLimit&&navigator.sendBeacon(n,t))return;var r=new XMLHttpRequest;r.open("POST",n,!0),r.send(t)},t}();var T=function(){function t(t,e,n,r,i,o){void 0===o&&(o=G),this.request=t,this.maxSize=e,this.bytesLimit=n,this.maxMessageSize=r,this.flushTimeout=i,this.beforeUnloadCallback=o,this.pushOnlyBuffer=[],this.upsertBuffer={},this.bufferBytesSize=0,this.bufferMessageCount=0,this.flushOnVisibilityHidden(),this.flushPeriodically()}return t.prototype.add=function(t){this.addOrUpdate(t)},t.prototype.upsert=function(t,e){this.addOrUpdate(t,e)},t.prototype.flush=function(){if(0!==this.bufferMessageCount){var t=o(this.pushOnlyBuffer,(e=this.upsertBuffer,n=[],Object.keys(e).forEach((function(t){n.push(e[t])})),n));this.request.send(t.join("\n"),this.bufferBytesSize),this.pushOnlyBuffer=[],this.upsertBuffer={},this.bufferBytesSize=0,this.bufferMessageCount=0}var e,n},t.prototype.sizeInBytes=function(t){return E.test(t)?void 0!==window.TextEncoder?(new TextEncoder).encode(t).length:new Blob([t]).size:t.length},t.prototype.addOrUpdate=function(t,e){var n=this.process(t),r=n.processedMessage,i=n.messageBytesSize;i>=this.maxMessageSize?console.warn("Discarded a message whose size was bigger than the maximum allowed size "+this.maxMessageSize+"KB."):(this.hasMessageFor(e)&&this.remove(e),this.willReachedBytesLimitWith(i)&&this.flush(),this.push(r,i,e),this.isFull()&&this.flush())},t.prototype.process=function(t){var e=z(t);return{processedMessage:e,messageBytesSize:this.sizeInBytes(e)}},t.prototype.push=function(t,e,n){this.bufferMessageCount>0&&(this.bufferBytesSize+=1),void 0!==n?this.upsertBuffer[n]=t:this.pushOnlyBuffer.push(t),this.bufferBytesSize+=e,this.bufferMessageCount+=1},t.prototype.remove=function(t){var e=this.upsertBuffer[t];delete this.upsertBuffer[t];var n=this.sizeInBytes(e);this.bufferBytesSize-=n,this.bufferMessageCount-=1,this.bufferMessageCount>0&&(this.bufferBytesSize-=1)},t.prototype.hasMessageFor=function(t){return void 0!==t&&void 0!==this.upsertBuffer[t]},t.prototype.willReachedBytesLimitWith=function(t){return this.bufferBytesSize+t+1>=this.bytesLimit},t.prototype.isFull=function(){return this.bufferMessageCount===this.maxSize||this.bufferBytesSize>=this.bytesLimit},t.prototype.flushPeriodically=function(){var t=this;setTimeout((function(){t.flush(),t.flushPeriodically()}),this.flushTimeout)},t.prototype.flushOnVisibilityHidden=function(){var t=this;navigator.sendBeacon&&(rt(window,M.BEFORE_UNLOAD,this.beforeUnloadCallback),rt(document,M.VISIBILITY_CHANGE,(function(){"hidden"===document.visibilityState&&t.flush()})),rt(window,M.BEFORE_UNLOAD,(function(){return t.flush()})))},t}(),g="?",y=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/;function b(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var C,O=function(){var t,e,n,r,i,o,a=[];function u(t,e,n){var r;for(var i in a)if(b(a,i))try{a[i](t,e,n)}catch(t){r=t}if(r)throw r}function s(t,r,i,o,a){if(e)R.augmentStackTraceWithInitialElement(e,r,i,""+t),f();else if(a)u(R(a),!0,a);else{var s,c={url:r,column:o,line:i},d=t;if("[object String]"==={}.toString.call(t)){var l=d.match(y);l&&(s=l[1],d=l[2])}u({name:s,message:"string"==typeof d?d:void 0,stack:[c]},!0,t)}return!!n&&n.apply(this,arguments)}function c(t){var e=t.reason||"Empty reason";u(R(e),!0,e)}function f(){var n=e,r=t;e=void 0,t=void 0,u(n,!1,r)}function d(n){if(e){if(t===n)return;f()}var r=R(n);throw e=r,t=n,setTimeout((function(){t===n&&f()}),r.incomplete?2e3:0),n}return d.subscribe=function(t){!function(){if(r)return;n=window.onerror,window.onerror=A(s),r=!0}(),function(){if(o)return;i=null!==window.onunhandledrejection?window.onunhandledrejection:void 0,window.onunhandledrejection=A(c),o=!0}(),a.push(t)},d.unsubscribe=function(t){for(var e=a.length-1;e>=0;e-=1)a[e]===t&&a.splice(e,1);0===a.length&&(r&&(window.onerror=n,r=!1),o&&(window.onunhandledrejection=i,o=!1))},d.traceKitWindowOnError=s,d}(),R=function(){var t=!1;function e(t){var e=o(t,"stack");if(e){for(var n,r,i,a,u=/^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,s=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i,c=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,f=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,d=/\((\S*)(?::(\d+))(?::(\d+))\)/,l=e.split("\n"),p=[],m=0,v=l.length;m<v;m+=1){if(u.exec(l[m])){var E=(i=u.exec(l[m]))[2]&&0===i[2].indexOf("native");n=i[2]&&0===i[2].indexOf("eval"),r=d.exec(i[2]),n&&r&&(i[2]=r[1],i[3]=r[2],i[4]=r[3]),a={args:E?[i[2]]:[],column:i[4]?+i[4]:void 0,func:i[1]||g,line:i[3]?+i[3]:void 0,url:E?void 0:i[2]}}else if(c.exec(l[m]))a={args:[],column:(i=c.exec(l[m]))[4]?+i[4]:void 0,func:i[1]||g,line:+i[3],url:i[2]};else{if(!s.exec(l[m]))continue;n=(i=s.exec(l[m]))[3]&&i[3].indexOf(" > eval")>-1,r=f.exec(i[3]),n&&r?(i[3]=r[1],i[4]=r[2],i[5]=void 0):0!==m||i[5]||void 0===t.columnNumber||(p[0].column=t.columnNumber+1),a={args:i[2]?i[2].split(","):[],column:i[5]?+i[5]:void 0,func:i[1]||g,line:i[4]?+i[4]:void 0,url:i[3]}}!a.func&&a.line&&(a.func=g),p.push(a)}if(p.length)return{stack:p,message:o(t,"message"),name:o(t,"name")}}}function n(t,e,n,r){var i={url:e,line:n?+n:void 0};if(i.url&&i.line){t.incomplete=!1;var o=t.stack;if(o.length>0&&o[0].url===i.url){if(o[0].line===i.line)return!1;if(!o[0].line&&o[0].func===i.func)return o[0].line=i.line,o[0].context=i.context,!1}return o.unshift(i),t.partial=!0,!0}return t.incomplete=!0,!1}function r(t,e){for(var i,a,u=/function\s+([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)?\s*\(/i,s=[],c={},f=!1,d=r.caller;d&&!f;d=d.caller)d!==R&&d!==O&&(a={args:[],column:void 0,func:g,line:void 0,url:void 0},i=u.exec(d.toString()),d.name?a.func=d.name:i&&(a.func=i[1]),void 0===a.func&&(a.func=i?i.input.substring(0,i.input.indexOf("{")):void 0),c[""+d]?f=!0:c[""+d]=!0,s.push(a));e&&s.splice(0,e);var l={stack:s,message:o(t,"message"),name:o(t,"name")};return n(l,o(t,"sourceURL")||o(t,"fileName"),o(t,"line")||o(t,"lineNumber"),o(t,"message")||o(t,"description")),l}function i(n,i){var a,u=void 0===i?0:+i;try{if(a=function(t){var e=o(t,"stacktrace");if(e){for(var n,r=/ line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i,i=/ line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^\)]+))\((.*)\))? in (.*):\s*$/i,a=e.split("\n"),u=[],s=0;s<a.length;s+=2){var c=void 0;r.exec(a[s])?c={args:[],column:void 0,func:(n=r.exec(a[s]))[3],line:+n[1],url:n[2]}:i.exec(a[s])&&(c={args:(n=i.exec(a[s]))[5]?n[5].split(","):[],column:+n[2],func:n[3]||n[4],line:+n[1],url:n[6]}),c&&(!c.func&&c.line&&(c.func=g),c.context=[a[s+1]],u.push(c))}if(u.length)return{stack:u,message:o(t,"message"),name:o(t,"name")}}}(n))return a}catch(e){if(t)throw e}try{if(a=e(n))return a}catch(e){if(t)throw e}try{if(a=function(t){var e=o(t,"message");if(e){var n=e.split("\n");if(!(n.length<4)){var r,i=/^\s*Line (\d+) of linked script ((?:file|https?|blob)\S+)(?:: in function (\S+))?\s*$/i,a=/^\s*Line (\d+) of inline#(\d+) script in ((?:file|https?|blob)\S+)(?:: in function (\S+))?\s*$/i,u=/^\s*Line (\d+) of function script\s*$/i,s=[],c=window&&window.document&&window.document.getElementsByTagName("script"),f=[];for(var d in c)b(c,d)&&!c[d].src&&f.push(c[d]);for(var l=2;l<n.length;l+=2){var p=void 0;if(i.exec(n[l]))p={args:[],column:void 0,func:(r=i.exec(n[l]))[3],line:+r[1],url:r[2]};else if(a.exec(n[l]))p={args:[],column:void 0,func:(r=a.exec(n[l]))[4],line:+r[1],url:r[3]};else if(u.exec(n[l])){r=u.exec(n[l]),p={url:window.location.href.replace(/#.*$/,""),args:[],column:void 0,func:"",line:+r[1]}}p&&(p.func||(p.func=g),p.context=[n[l+1]],s.push(p))}if(s.length)return{stack:s,message:n[0],name:o(t,"name")}}}}(n))return a}catch(e){if(t)throw e}try{if(a=r(n,u+1))return a}catch(e){if(t)throw e}return{message:o(n,"message"),name:o(n,"name"),stack:[]}}function o(t,e){if("object"==typeof t&&t&&e in t){var n=t[e];return"string"==typeof n?n:void 0}}return i.augmentStackTraceWithInitialElement=n,i.computeStackTraceFromStackProp=e,i.ofCaller=function(t){var e=1+(void 0===t?0:+t);try{throw new Error}catch(t){return R(t,e+1)}},i}();!function(t){t.info="info",t.error="error"}(C||(C={}));var S,_={maxMessagesPerPage:0,sentMessageCount:0};function w(t){if(t.internalMonitoringEndpoint){var e=function(t){var e,n=r(t.internalMonitoringEndpoint);void 0!==t.replica&&(e=r(t.replica.internalMonitoringEndpoint));function r(e){return new T(new h(e,t.batchBytesLimit),t.maxBatchSize,t.batchBytesLimit,t.maxMessageSize,t.flushTimeout)}return{add:function(t){var r=function(t){return c({date:(new Date).getTime(),view:{referrer:document.referrer,url:window.location.href}},void 0!==S?S():{},t)}(t);n.add(r),e&&e.add(r)}}}(t);!function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];e.forEach((function(e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}))}(_,{batch:e,maxMessagesPerPage:t.maxInternalMonitoringMessagesPerPage,sentMessageCount:0})}return{setExternalContextProvider:function(t){S=t}}}function A(t){return function(){try{return t.apply(this,arguments)}catch(t){x(t);try{N(t)}catch(t){x(t)}}}}function I(t,e){!function(t){_.debugMode&&console.log("[MONITORING MESSAGE]",t)}(t),D(r(r({message:t},e),{status:C.info}))}function N(t){D(r(r({},function(t){if(t instanceof Error){var e=R(t);return{error:{kind:e.name,stack:v(e)},message:e.message}}return{error:{stack:"Not an instance of error"},message:"Uncaught "+z(t)}}(t)),{status:C.error}))}function D(t){_.batch&&_.sentMessageCount<_.maxMessagesPerPage&&(_.sentMessageCount+=1,_.batch.add(t))}function L(t){_.debugMode=t}function x(t){_.debugMode&&console.warn("[INTERNAL ERROR]",t)}var M,U,k,P,B=1e3,H=60*B,W=60*H;function j(t,e,n){var r,i=!n||void 0===n.leading||n.leading,o=!n||void 0===n.trailing||n.trailing,a=!1,u=!1;return{throttled:function(){var n=this;a?u=!0:(i?t.apply(this):u=!0,a=!0,r=window.setTimeout((function(){o&&u&&t.apply(n),a=!1,u=!1}),e))},cancel:function(){window.clearTimeout(r),a=!1,u=!1}}}function V(t){return t?(parseInt(t,10)^16*Math.random()>>parseInt(t,10)/4).toString(16):(1e7+"-1000-4000-8000-100000000000").replace(/[018]/g,V)}function F(t){return 0!==t&&100*Math.random()<=t}function q(t){return"number"!=typeof t?t:+(1e6*t).toFixed(0)}function G(){}function z(t,e,n){if(null==t)return JSON.stringify(t);var r=[!1,void 0];K(t)&&(r=[!0,t.toJSON],delete t.toJSON);var i,o,a=[!1,void 0];"object"==typeof t&&K(i=Object.getPrototypeOf(t))&&(a=[!0,i.toJSON],delete i.toJSON);try{o=JSON.stringify(t,void 0,n)}catch(t){o="<error: unable to serialize object>"}finally{r[0]&&(t.toJSON=r[1]),a[0]&&(i.toJSON=a[1])}return o}function K(t){return"object"==typeof t&&null!==t&&t.hasOwnProperty("toJSON")}function Y(t,e){return-1!==t.indexOf(e)}function $(t){return X(t)&&t>=0&&t<=100}function X(t){return"number"==typeof t}function J(t){return Math.floor(Q()+t)}function Q(){return void 0===P&&(P=performance.timing.navigationStart),P}function Z(t){return Object.keys(t).map((function(e){return[e,t[e]]}))}function tt(t){return 0===Object.keys(t).length}function et(t){if(t.origin)return t.origin;var e=t.host.replace(/(:80|:443)$/,"");return t.protocol+"//"+e}function nt(t,e){var n=t.match("(?:^|;)\\s*"+e+"\\s*=\\s*([^;]+)");return n?n[1]:void 0}function rt(t,e,n,r){return it(t,[e],n,r)}function it(t,e,n,r){var i=void 0===r?{}:r,o=i.once,a=i.capture,u=i.passive,s=A(o?function(t){f(),n(t)}:n),c=u?{capture:a,passive:u}:a;e.forEach((function(e){return t.addEventListener(e,s,c)}));var f=function(){return e.forEach((function(e){return t.removeEventListener(e,s,c)}))};return{stop:f}}!function(t){t.BEFORE_UNLOAD="beforeunload",t.CLICK="click",t.KEY_DOWN="keydown",t.LOAD="load",t.POP_STATE="popstate",t.SCROLL="scroll",t.TOUCH_START="touchstart",t.VISIBILITY_CHANGE="visibilitychange",t.DOM_CONTENT_LOADED="DOMContentLoaded",t.POINTER_DOWN="pointerdown",t.POINTER_UP="pointerup",t.POINTER_CANCEL="pointercancel",t.HASH_CHANGE="hashchange",t.PAGE_HIDE="pagehide",t.MOUSE_DOWN="mousedown"}(M||(M={})),function(t){t.DOCUMENT="document",t.XHR="xhr",t.BEACON="beacon",t.FETCH="fetch",t.CSS="css",t.JS="js",t.IMAGE="image",t.FONT="font",t.MEDIA="media",t.OTHER="other"}(U||(U={})),function(t){t.FETCH="fetch",t.XHR="xhr"}(k||(k={}));var ot,at=B;function ut(t,e,n,r){var i=new Date;i.setTime(i.getTime()+n);var o="expires="+i.toUTCString(),a=r&&r.crossSite?"none":"strict",u=r&&r.domain?";domain="+r.domain:"",s=r&&r.secure?";secure":"";document.cookie=t+"="+e+";"+o+";path=/;samesite="+a+u+s}function st(t){return nt(document.cookie,t)}var ct,ft={allowedTracingOrigins:[],maxErrorsByMinute:3e3,maxInternalMonitoringMessagesPerPage:15,resourceSampleRate:100,sampleRate:100,silentMultipleInit:!1,trackInteractions:!1,requestErrorResponseLengthLimit:32768,flushTimeout:30*B,maxBatchSize:50,maxMessageSize:262144,batchBytesLimit:16384},dt={alternate:{logs:"logs",rum:"rum",trace:"trace"},classic:{logs:"browser",rum:"rum",trace:"public-trace"}};function lt(t,e){var n={applicationId:t.applicationId,buildMode:e.buildMode,clientToken:t.clientToken,env:t.env,proxyHost:t.proxyHost,sdkVersion:e.sdkVersion,service:t.service,site:t.site||Tt[t.datacenter||e.datacenter],version:t.version},i=Array.isArray(t.enableExperimentalFeatures)?t.enableExperimentalFeatures:[],o=t.useAlternateIntakeDomains?"alternate":"classic",a=function(t,e,n){if(e.proxyHost)return["https://"+e.proxyHost+"/v1/input/"];var r=[e.site];e.buildMode===Et.STAGING&&n&&r.push(Tt[ht.US]);for(var i=[],o=Object.keys(dt[t]),a=0,u=r;a<u.length;a++)for(var s=u[a],c=0,f=o;c<f.length;c++){var d=f[c];i.push("https://"+vt(t,d,s)+"/v1/input/")}return i}(o,n,void 0!==t.replica),u=r({beforeSend:t.beforeSend,cookieOptions:pt(t),isEnabled:function(t){return Y(i,t)},logsEndpoint:mt(o,"logs",n),proxyHost:t.proxyHost,rumEndpoint:mt(o,"rum",n),service:t.service,traceEndpoint:mt(o,"trace",n),isIntakeUrl:function(t){return a.some((function(e){return 0===t.indexOf(e)}))}},ft);if(t.internalMonitoringApiKey&&(u.internalMonitoringEndpoint=mt(o,"logs",n,"browser-agent-internal-monitoring")),"allowedTracingOrigins"in t&&(u.allowedTracingOrigins=t.allowedTracingOrigins),"sampleRate"in t&&(u.sampleRate=t.sampleRate),"resourceSampleRate"in t&&(u.resourceSampleRate=t.resourceSampleRate),"trackInteractions"in t&&(u.trackInteractions=!!t.trackInteractions),n.buildMode===Et.E2E_TEST&&(u.internalMonitoringEndpoint="<<< E2E INTERNAL MONITORING ENDPOINT >>>",u.logsEndpoint="<<< E2E LOGS ENDPOINT >>>",u.rumEndpoint="<<< E2E RUM ENDPOINT >>>"),n.buildMode===Et.STAGING&&void 0!==t.replica){var s=r(r({},n),{applicationId:t.replica.applicationId,clientToken:t.replica.clientToken,site:Tt[ht.US]});u.replica={applicationId:t.replica.applicationId,internalMonitoringEndpoint:mt(o,"logs",s,"browser-agent-internal-monitoring"),logsEndpoint:mt(o,"logs",s),rumEndpoint:mt(o,"rum",s)}}return u}function pt(t){var e={};return e.secure=function(t){return!!t.useSecureSessionCookie||!!t.useCrossSiteSessionCookie}(t),e.crossSite=!!t.useCrossSiteSessionCookie,t.trackSessionAcrossSubdomains&&(e.domain=function(){if(void 0===ot){for(var t="dd_site_test_"+V(),e=window.location.hostname.split("."),n=e.pop();e.length&&!st(t);)n=e.pop()+"."+n,ut(t,"test",B,{domain:n});ot=n}return ot}()),e}function mt(t,e,n,r){var i="sdk_version:"+n.sdkVersion+(n.env?",env:"+n.env:"")+(n.service?",service:"+n.service:"")+(n.version?",version:"+n.version:""),o=vt(t,e,n.site),a=n.proxyHost?n.proxyHost:o,u=n.proxyHost?"ddhost="+o+"&":"",s=""+(n.applicationId?"_dd.application_id="+n.applicationId+"&":"")+u+"ddsource="+(r||"browser")+"&ddtags="+i;return"https://"+a+"/v1/input/"+n.clientToken+"?"+s}function vt(t,e,n){var r=dt[t][e];if("classic"===t)return r+"-http-intake.logs."+n;var i=n.split("."),o=i.pop();return r+".browser-intake-"+(i.join("-")+"."+o)}var Et,ht={EU:"eu",US:"us"},Tt=((ct={})[ht.EU]="datadoghq.eu",ct[ht.US]="datadoghq.com",ct);function gt(t){return!!function(t){if(void 0===document.cookie||null===document.cookie)return!1;try{var e="dd_cookie_test_"+V();return ut(e,"test",B,t),"test"===st(e)}catch(t){return console.error(t),!1}}(t)||(console.warn("Cookies are not authorized, we will not send any data."),!1)}function yt(){return"file:"!==window.location.protocol||(console.error("Execution is not allowed in the current context."),!1)}!function(t){t.RELEASE="release",t.STAGING="staging",t.E2E_TEST="e2e-test"}(Et||(Et={}));var bt,Ct=1e4,Ot=function(){function t(t){void 0===t&&(t=Ct),this.limit=t,this.buffer=[]}return t.prototype.add=function(t){this.buffer.push(t)>this.limit&&this.buffer.splice(0,1)},t.prototype.drain=function(t){this.buffer.forEach((function(e){return t(e)})),this.buffer.length=0},t}();!function(t){t[t.PERFORMANCE_ENTRY_COLLECTED=0]="PERFORMANCE_ENTRY_COLLECTED",t[t.AUTO_ACTION_CREATED=1]="AUTO_ACTION_CREATED",t[t.AUTO_ACTION_COMPLETED=2]="AUTO_ACTION_COMPLETED",t[t.AUTO_ACTION_DISCARDED=3]="AUTO_ACTION_DISCARDED",t[t.VIEW_CREATED=4]="VIEW_CREATED",t[t.VIEW_UPDATED=5]="VIEW_UPDATED",t[t.REQUEST_STARTED=6]="REQUEST_STARTED",t[t.REQUEST_COMPLETED=7]="REQUEST_COMPLETED",t[t.SESSION_RENEWED=8]="SESSION_RENEWED",t[t.DOM_MUTATED=9]="DOM_MUTATED",t[t.BEFORE_UNLOAD=10]="BEFORE_UNLOAD",t[t.RAW_RUM_EVENT_COLLECTED=11]="RAW_RUM_EVENT_COLLECTED",t[t.RUM_EVENT_COLLECTED=12]="RUM_EVENT_COLLECTED"}(bt||(bt={}));var Rt,St=function(){function t(){this.callbacks={}}return t.prototype.notify=function(t,e){var n=this.callbacks[t];n&&n.forEach((function(t){return t(e)}))},t.prototype.subscribe=function(t,e){var n=this;return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),{unsubscribe:function(){n.callbacks[t]=n.callbacks[t].filter((function(t){return e!==t}))}}},t}();function _t(t,e){void 0===e&&(e=G);var n={errorCount:0,longTaskCount:0,resourceCount:0,userActionCount:0},r=t.subscribe(bt.RAW_RUM_EVENT_COLLECTED,(function(t){switch(t.rawRumEvent.type){case Rt.ERROR:n.errorCount+=1,e(n);break;case Rt.ACTION:n.userActionCount+=1,e(n);break;case Rt.LONG_TASK:n.longTaskCount+=1,e(n);break;case Rt.RESOURCE:n.resourceCount+=1,e(n)}}));return{stop:function(){r.unsubscribe()},eventCounts:n}}!function(t){t.ACTION="action",t.ERROR="error",t.LONG_TASK="long_task",t.VIEW="view",t.RESOURCE="resource"}(Rt||(Rt={}));var wt=function(){function t(){this.observers=[]}return t.prototype.subscribe=function(t){this.observers.push(t)},t.prototype.notify=function(t){this.observers.forEach((function(e){return e(t)}))},t}(),At=100,It=100,Nt=1e4;function Dt(t,e){var n=function(t){var e,n=new wt,r=[],i=0;function o(){n.notify({isBusy:i>0})}return r.push(t.subscribe(bt.DOM_MUTATED,(function(){return o()}))),r.push(t.subscribe(bt.PERFORMANCE_ENTRY_COLLECTED,(function(t){"resource"===t.entryType&&o()}))),r.push(t.subscribe(bt.REQUEST_STARTED,(function(t){void 0===e&&(e=t.requestIndex),i+=1,o()}))),r.push(t.subscribe(bt.REQUEST_COMPLETED,(function(t){void 0===e||t.requestIndex<e||(i-=1,o())}))),{observable:n,stop:function(){r.forEach((function(t){return t.unsubscribe()}))}}}(t),r=n.observable,i=n.stop,o=function(t,e,n){var r,i=!1,o=setTimeout(A((function(){return s(!1,0)})),At),a=setTimeout(A((function(){return s(!0,performance.now())})),Nt);function u(){i=!0,clearTimeout(o),clearTimeout(r),clearTimeout(a),e()}function s(t,e){i||(u(),n(t,e))}return t.subscribe((function(t){var e=t.isBusy;clearTimeout(o),clearTimeout(r);var n=performance.now();e||(r=setTimeout(A((function(){return s(!0,n)})),It))})),{stop:u}}(r,i,e).stop;return{stop:function(){o(),i()}}}function Lt(t){return function(t){var e;if(function(){void 0===kt&&(kt="closest"in HTMLElement.prototype);return kt}())e=t.closest("["+xt+"]");else for(var n=t;n;){if(n.hasAttribute(xt)){e=n;break}n=n.parentElement}if(!e)return;return Ft(Vt(e.getAttribute(xt).trim()))}(t)||jt(t,Bt)||jt(t,Ht)||""}var xt="data-dd-action-name";var Mt,Ut,kt,Pt,Bt=[function(t){if(function(){void 0===Ut&&(Ut="labels"in HTMLInputElement.prototype);return Ut}()){if("labels"in t&&t.labels&&t.labels.length>0)return qt(t.labels[0])}else if(t.id){var e=t.ownerDocument&&t.ownerDocument.querySelector('label[for="'+t.id.replace('"','\\"')+'"]');return e&&qt(e)}},function(t){if("INPUT"===t.nodeName){var e=t,n=e.getAttribute("type");if("button"===n||"submit"===n||"reset"===n)return e.value}},function(t){if("BUTTON"===t.nodeName||"LABEL"===t.nodeName||"button"===t.getAttribute("role"))return qt(t)},function(t){return t.getAttribute("aria-label")},function(t){var e=t.getAttribute("aria-labelledby");if(e)return e.split(/\s+/).map((function(e){return function(t,e){return t.ownerDocument?t.ownerDocument.getElementById(e):null}(t,e)})).filter((function(t){return Boolean(t)})).map(qt).join(" ")},function(t){return t.getAttribute("alt")},function(t){return t.getAttribute("name")},function(t){return t.getAttribute("title")},function(t){return t.getAttribute("placeholder")},function(t){if("options"in t&&t.options.length>0)return qt(t.options[0])}],Ht=[function(t){return qt(t)}],Wt=10;function jt(t,e){for(var n=t,r=0;r<=Wt&&n&&"BODY"!==n.nodeName&&"HTML"!==n.nodeName&&"HEAD"!==n.nodeName;){for(var i=0,o=e;i<o.length;i++){var a=(0,o[i])(n);if("string"==typeof a){var u=a.trim();if(u)return Ft(Vt(u))}}if("FORM"===n.nodeName)break;n=n.parentElement,r+=1}}function Vt(t){return t.replace(/\s+/g," ")}function Ft(t){return t.length>100?(n=100,((r=(e=t).charCodeAt(n-1))>=55296&&r<=56319?e.slice(0,n+1):e.slice(0,n))+" [...]"):t;var e,n,r}function qt(t){if(!t.isContentEditable){if("innerText"in t){var e=t.innerText;if(!function(){if(void 0===Mt){var t=document.createElement("style");t.textContent="*";var e=document.createElement("div");e.appendChild(t),document.body.appendChild(e),Mt=""===e.innerText,document.body.removeChild(e)}return Mt}())for(var n=t.querySelectorAll("script, style"),r=0;r<n.length;r+=1){var i=n[r].innerText;i.trim().length>0&&(e=e.replace(i,""))}return e}return t.textContent}}function Gt(t){var e=function(t){var e,n;return{create:function(r,i){if(!e){var o=new Kt(t,r,i);e=o,n=Dt(t,(function(t,n){t?o.complete(n):o.discard(),e=void 0}))}},discardCurrent:function(){e&&(n.stop(),e.discard(),e=void 0)}}}(t);t.subscribe(bt.VIEW_CREATED,(function(){e.discardCurrent()}));var n=rt(window,M.CLICK,(function(t){if(t.target instanceof Element){var n=Lt(t.target);n&&e.create(Pt.CLICK,n)}}),{capture:!0}).stop;return{stop:function(){e.discardCurrent(),n()}}}!function(t){t.CLICK="click",t.CUSTOM="custom"}(Pt||(Pt={}));var zt,Kt=function(){function t(t,e,n){this.lifeCycle=t,this.type=e,this.name=n,this.id=V(),this.startTime=performance.now(),this.eventCountsSubscription=_t(t),this.lifeCycle.notify(bt.AUTO_ACTION_CREATED,{id:this.id,startTime:this.startTime})}return t.prototype.complete=function(t){var e=this.eventCountsSubscription.eventCounts;this.lifeCycle.notify(bt.AUTO_ACTION_COMPLETED,{counts:{errorCount:e.errorCount,longTaskCount:e.longTaskCount,resourceCount:e.resourceCount},duration:t-this.startTime,id:this.id,name:this.name,startTime:this.startTime,type:this.type}),this.eventCountsSubscription.stop()},t.prototype.discard=function(){this.lifeCycle.notify(bt.AUTO_ACTION_DISCARDED),this.eventCountsSubscription.stop()},t}();function Yt(t){var e,n=function(){var t,e=window;if(e.Zone){var n=e.Zone.__symbol__("MutationObserver");t=e[n]}return t||(t=e.MutationObserver),t}();return n&&(e=new n(A((function(){t.notify(bt.DOM_MUTATED)})))).observe(document.documentElement,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),{stop:function(){e&&e.disconnect()}}}function $t(t){return Jt(t,et(window.location)).href}function Xt(t){return et(Jt(t))}function Jt(t,e){if(function(){if(void 0!==zt)return zt;try{var t=new URL("http://test/path");return zt="http://test/path"===t.href}catch(t){zt=!1}return zt}())return void 0!==e?new URL(t,e):new URL(t);if(void 0===e&&!/:/.test(t))throw new Error("Invalid URL: '"+t+"'");var n=document,r=n.createElement("a");if(void 0!==e){var i=(n=document.implementation.createHTMLDocument("")).createElement("base");i.href=e,n.head.appendChild(i),n.body.appendChild(r)}return r.href=t,r}var Qt="initial_document",Zt=[[U.DOCUMENT,function(t){return Qt===t}],[U.XHR,function(t){return"xmlhttprequest"===t}],[U.FETCH,function(t){return"fetch"===t}],[U.BEACON,function(t){return"beacon"===t}],[U.CSS,function(t,e){return null!==e.match(/\.css$/i)}],[U.JS,function(t,e){return null!==e.match(/\.js$/i)}],[U.IMAGE,function(t,e){return Y(["image","img","icon"],t)||null!==e.match(/\.(gif|jpg|jpeg|tiff|png|svg|ico)$/i)}],[U.FONT,function(t,e){return null!==e.match(/\.(woff|eot|woff2|ttf)$/i)}],[U.MEDIA,function(t,e){return Y(["audio","video"],t)||null!==e.match(/\.(mp3|mp4)$/i)}]];function te(t){var e=t.name;if(!function(t){try{return!!Jt(t)}catch(t){return!1}}(e))return I('Failed to construct URL for "'+t.name+'"'),U.OTHER;for(var n=function(t){var e=Jt(t).pathname;return"/"===e[0]?e:"/"+e}(e),r=0,i=Zt;r<i.length;r++){var o=i[r],a=o[0];if((0,o[1])(t.initiatorType,n))return a}return U.OTHER}function ee(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=1;n<t.length;n+=1)if(t[n-1]>t[n])return!1;return!0}function ne(t){var e=re(t);if(e){var n=e.startTime,r=e.fetchStart,i=e.redirectStart,o=e.redirectEnd,a=e.domainLookupStart,u=e.domainLookupEnd,s=e.connectStart,c=e.secureConnectionStart,f=e.connectEnd,d=e.requestStart,l=e.responseStart,p={download:oe(n,l,e.responseEnd),firstByte:oe(n,d,l)};return f!==r&&(p.connect=oe(n,s,f),ee(s,c,f)&&(p.ssl=oe(n,c,f))),u!==r&&(p.dns=oe(n,a,u)),ie(t)&&(p.redirect=oe(n,i,o)),p}}function re(t){if(ee(t.startTime,t.fetchStart,t.domainLookupStart,t.domainLookupEnd,t.connectStart,t.connectEnd,t.requestStart,t.responseStart,t.responseEnd)){if(!ie(t))return t;var e=t.redirectStart,n=t.redirectEnd;if(e<t.startTime&&(e=t.startTime),n<t.startTime&&(n=t.fetchStart),ee(t.startTime,e,n,t.fetchStart))return r(r({},t),{redirectEnd:n,redirectStart:e})}}function ie(t){return t.fetchStart!==t.startTime}function oe(t,e,n){return{duration:q(n-e),start:q(e-t)}}function ae(t){if(t.startTime<t.responseStart)return t.decodedBodySize}function ue(t,e){return e&&!t.isIntakeUrl(e)}var se,ce=2*H;function fe(t){var e=function(t){var e=t.querySelector("meta[name=dd-trace-id]"),n=t.querySelector("meta[name=dd-trace-time]");return de(e&&e.content,n&&n.content)}(t)||function(t){var e=function(t){for(var e=0;e<t.childNodes.length;e+=1){if(n=le(t.childNodes[e]))return n}if(t.body)for(e=t.body.childNodes.length-1;e>=0;e-=1){var n,r=t.body.childNodes[e];if(n=le(r))return n;if(!pe(r))break}}(t);if(!e)return;return de(nt(e,"trace-id"),nt(e,"trace-time"))}(t);if(e&&!(e.traceTime<=Date.now()-ce))return e.traceId}function de(t,e){var n=e&&Number(e);if(t&&n)return{traceId:t,traceTime:n}}function le(t){if(t&&function(t){return"#comment"===t.nodeName}(t)){var e=t.data.match(/^\s*DATADOG;(.*?)\s*$/);if(e)return e[1]}}function pe(t){return"#text"===t.nodeName}function me(){return void 0!==window.performance&&"getEntries"in performance}function ve(t){return window.PerformanceObserver&&void 0!==PerformanceObserver.supportedEntryTypes&&PerformanceObserver.supportedEntryTypes.includes(t)}function Ee(t,e){var n;if(n=function(n){ye(t,e,n)},he("interactive",(function(){var t,e={entryType:"resource",initiatorType:Qt,traceId:fe(document)};if(ve("navigation")&&performance.getEntriesByType("navigation").length>0){var i=performance.getEntriesByType("navigation")[0];t=r(r({},i.toJSON()),e)}else{var o=Te();t=r(r(r({},o),{decodedBodySize:0,duration:o.responseEnd,name:window.location.href,startTime:0}),e)}n(t)})),me()&&ge(t,e,performance.getEntries()),window.PerformanceObserver){new PerformanceObserver(A((function(n){return ge(t,e,n.getEntries())}))).observe({entryTypes:["resource","navigation","longtask","paint","largest-contentful-paint","first-input","layout-shift"]}),me()&&"addEventListener"in performance&&performance.addEventListener("resourcetimingbufferfull",(function(){performance.clearResourceTimings()}))}ve("navigation")||function(t){function e(){t(r(r({},Te()),{entryType:"navigation"}))}he("complete",(function(){setTimeout(A(e))}))}((function(n){ye(t,e,n)})),ve("first-input")||function(t){var e=Date.now(),n=!1,r=it(window,[M.CLICK,M.MOUSE_DOWN,M.KEY_DOWN,M.TOUCH_START,M.POINTER_DOWN],(function(t){if(t.cancelable){var e={entryType:"first-input",processingStart:performance.now(),startTime:t.timeStamp};t.type===M.POINTER_DOWN?function(t){it(window,[M.POINTER_UP,M.POINTER_CANCEL],(function(e){e.type===M.POINTER_UP&&i(t)}),{once:!0})}(e):i(e)}}),{passive:!0,capture:!0}).stop;function i(i){if(!n){n=!0,r();var o=i.processingStart-i.startTime;o>=0&&o<Date.now()-e&&t(i)}}}((function(n){ye(t,e,n)}))}function he(t,e){if(document.readyState===t||"complete"===document.readyState)e();else{var n="complete"===t?M.LOAD:M.DOM_CONTENT_LOADED;rt(window,n,e,{once:!0})}}function Te(){var t={},e=performance.timing;for(var n in e)X(e[n])&&(t[n]=0===e[n]?0:e[n]-Q());return t}function ge(t,e,n){n.forEach((function(n){"resource"!==n.entryType&&"navigation"!==n.entryType&&"paint"!==n.entryType&&"longtask"!==n.entryType&&"largest-contentful-paint"!==n.entryType&&"first-input"!==n.entryType&&"layout-shift"!==n.entryType||ye(t,e,n)}))}function ye(t,e,n){(function(t){return"navigation"===t.entryType&&t.loadEventEnd<=0})(n)||function(t,e){return"resource"===e.entryType&&!ue(t,e.name)}(e,n)||t.notify(bt.PERFORMANCE_ENTRY_COLLECTED,n)}function be(t,e,n){var r=f(t);try{n(r)}catch(e){return console.error(e),t}return e.forEach((function(e){var n=Ce(t,e),i=Ce(r,e);"string"==typeof n&&"string"==typeof i&&function(t,e,n){for(var r=t,i=e.split("."),o=0;o<i.length;o+=1){var a=i[o];if(!Oe(r,a))return;o!==i.length-1?r=r[a]:r[a]=n}}(t,e,i)})),t}function Ce(t,e){for(var n=t,r=0,i=e.split(".");r<i.length;r++){var o=i[r];if(!Oe(n,o))return;n=n[o]}return n}function Oe(t,e){return"object"==typeof t&&null!==t&&e in t}!function(t){t.SYNTHETICS="synthetics",t.USER="user"}(se||(se={}));var Re=["view.url","view.referrer","action.target.name","error.message","error.stack","error.resource.url","resource.url"];function Se(t,e,n,r,i,o){n.subscribe(bt.RAW_RUM_EVENT_COLLECTED,(function(u){var s,f=u.startTime,d=u.rawRumEvent,l=u.savedCommonContext,p=u.customerContext,m=i.findView(f);if(r.isTracked()&&m&&m.session.id){var v=i.findAction(f),E={_dd:{formatVersion:2},application:{id:t},date:(new Date).getTime(),service:e.service,session:{type:void 0===window._DATADOG_SYNTHETICS_BROWSER?se.USER:se.SYNTHETICS}},h=(s=d,-1!==[Rt.ERROR,Rt.RESOURCE,Rt.LONG_TASK].indexOf(s.type)?c(E,m,v,d):c(E,m,d)),T=a(h),g=l||o(),y=c(g.context,p);tt(y)||(T.context=y),tt(g.user)||(T.usr=g.user),e.beforeSend&&be(T,Re,e.beforeSend),n.notify(bt.RUM_EVENT_COLLECTED,{assembledRumEvent:h,serverRumEvent:T})}}))}var _e="_dd",we="_dd_r",Ae="_dd_l",Ie="rum",Ne="logs";var De="_dd_s",Le=15*H,xe=4*W,Me=H;function Ue(t,e,n){var r=function(t,e){var n,r,i=!1,o=function(){i=!0,window.clearTimeout(n),n=window.setTimeout((function(){i=!1}),at)};return{get:function(){return i?r:(r=st(t),o(),r)},set:function(n,i){ut(t,n,i,e),r=n,o()}}}(De,t);!function(t){var e=t.get(),n=st(_e),r=st(we),i=st(Ae);if(!e){var o={};n&&(o.id=n),i&&/^[01]$/.test(i)&&(o[Ne]=i),r&&/^[012]$/.test(r)&&(o[Ie]=r),He(o,t)}}(r);var i=new wt,o=Be(r).id,a=j((function(){var t=Be(r),a=n(t[e]),u=a.trackingType,s=a.isTracked;t[e]=u,s&&!t.id&&(t.id=V(),t.created=String(Date.now())),He(t,r),s&&o!==t.id&&(o=t.id,i.notify())}),at).throttled;return a(),function(t){var e=it(window,[M.CLICK,M.TOUCH_START,M.KEY_DOWN,M.SCROLL],t,{capture:!0,passive:!0}).stop;je.push(e)}(a),function(t){var e=A((function(){"visible"===document.visibilityState&&t()})),n=rt(document,M.VISIBILITY_CHANGE,e).stop;je.push(n);var r=window.setInterval(e,Me);je.push((function(){clearInterval(r)}))}((function(){He(Be(r),r)})),{getId:function(){return Be(r).id},getTrackingType:function(){return Be(r)[e]},renewObservable:i}}var ke=/^([a-z]+)=([a-z0-9-]+)$/,Pe="&";function Be(t){var e=function(t){var e=t.get(),n={};(function(t){return void 0!==t&&(-1!==t.indexOf(Pe)||ke.test(t))})(e)&&e.split(Pe).forEach((function(t){var e=ke.exec(t);if(null!==e){var r=e[1],i=e[2];n[r]=i}}));return n}(t);return function(t){return(void 0===t.created||Date.now()-Number(t.created)<xe)&&(void 0===t.expire||Date.now()<Number(t.expire))}(e)?e:(We(t),{})}function He(t,e){if(tt(t))We(e);else{t.expire=String(Date.now()+Le);var n=Z(t).map((function(t){return t[0]+"="+t[1]})).join(Pe);e.set(n,Le)}}function We(t){t.set("",0)}var je=[];var Ve,Fe=xe,qe=5*H,Ge=H;var ze,Ke,Ye,$e,Xe=[],Je=[];function Qe(){return Ve||(ze=XMLHttpRequest.prototype.open,Ke=XMLHttpRequest.prototype.send,XMLHttpRequest.prototype.open=A((function(t,e){return this._datadog_xhr={method:t,startTime:-1,url:$t(e)},ze.apply(this,arguments)})),XMLHttpRequest.prototype.send=A((function(t){var e=this;if(this._datadog_xhr){this._datadog_xhr.startTime=performance.now();var n=this.onreadystatechange;this.onreadystatechange=function(){this.readyState===XMLHttpRequest.DONE&&A(i)(),n&&n.apply(this,arguments)};var r=!1,i=function(){r||(r=!0,e._datadog_xhr.duration=performance.now()-e._datadog_xhr.startTime,e._datadog_xhr.response=e.response,e._datadog_xhr.status=e.status,Je.forEach((function(t){return t(e._datadog_xhr)})))};this.addEventListener("loadend",A(i)),Xe.forEach((function(t){return t(e._datadog_xhr,e)}))}return Ke.apply(this,arguments)})),Ve={beforeSend:function(t){Xe.push(t)},onRequestComplete:function(t){Je.push(t)}}),Ve}var Ze=[],tn=[];function en(){return Ye||(!function(){if(!window.fetch)return;$e=window.fetch,window.fetch=A((function(t,e){var n=this,r=e&&e.method||"object"==typeof t&&t.method||"GET",o=$t("object"==typeof t&&t.url||t),a={init:e,method:r,startTime:performance.now(),url:o},u=function(t){return e=n,r=void 0,u=function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return a.duration=performance.now()-a.startTime,"stack"in t||t instanceof Error?(a.status=0,a.response=v(R(t)),tn.forEach((function(t){return t(a)})),[3,6]):[3,1];case 1:if(!("status"in t))return[3,6];e=void 0,r.label=2;case 2:return r.trys.push([2,4,,5]),[4,t.clone().text()];case 3:return e=r.sent(),[3,5];case 4:return n=r.sent(),e="Unable to retrieve response: "+n,[3,5];case 5:a.response=e,a.responseType=t.type,a.status=t.status,tn.forEach((function(t){return t(a)})),r.label=6;case 6:return[2]}}))},new((o=void 0)||(o=Promise))((function(t,n){function i(t){try{s(u.next(t))}catch(t){n(t)}}function a(t){try{s(u.throw(t))}catch(t){n(t)}}function s(e){e.done?t(e.value):new o((function(t){t(e.value)})).then(i,a)}s((u=u.apply(e,r||[])).next())}));var e,r,o,u};Ze.forEach((function(t){return t(a)}));var s=$e.call(this,t,a.init);return s.then(A(u),A(u)),s}))}(),Ye={beforeSend:function(t){Ze.push(t)},onRequestComplete:function(t){tn.push(t)}}),Ye}function nn(t){0===t.status&&(t.traceId=void 0,t.spanId=void 0)}function rn(t,e,n){var r;void 0!==on()&&function(t,e){for(var n=Xt(e),r=0,i=t.allowedTracingOrigins;r<i.length;r++){var o=i[r];if(n===o||o instanceof RegExp&&o.test(n))return!0}return!1}(t,e.url)&&(e.traceId=new dn,e.spanId=new dn,n((r=e.traceId,{"x-datadog-origin":"rum","x-datadog-parent-id":e.spanId.toDecimalString(),"x-datadog-sampled":"1","x-datadog-sampling-priority":"1","x-datadog-trace-id":r.toDecimalString()})))}function on(){return window.crypto||window.msCrypto}var an,un,sn,cn,fn,dn=function(){function t(){this.buffer=new Uint8Array(8),on().getRandomValues(this.buffer),this.buffer[0]=127&this.buffer[0]}return t.prototype.toString=function(t){for(var e=this.readInt32(0),n=this.readInt32(4),r="";;){var i=e%t*4294967296+n;if(e=Math.floor(e/t),n=Math.floor(i/t),r=(i%t).toString(t)+r,!e&&!n)break}return r},t.prototype.toDecimalString=function(){return this.toString(10)},t.prototype.readInt32=function(t){return 16777216*this.buffer[t]+(this.buffer[t+1]<<16)+(this.buffer[t+2]<<8)+this.buffer[t+3]},t}(),ln=1;function pn(t,e){var n=function(t){return{clearTracingIfCancelled:nn,traceFetch:function(e){return rn(t,e,(function(t){e.init=r({},e.init);var n=[];e.init.headers instanceof Headers?e.init.headers.forEach((function(t,e){n.push([e,t])})):Array.isArray(e.init.headers)?e.init.headers.forEach((function(t){n.push(t)})):e.init.headers&&Object.keys(e.init.headers).forEach((function(t){n.push([t,e.init.headers[t]])})),e.init.headers=n.concat(Z(t))}))},traceXhr:function(e,n){return rn(t,e,(function(t){Object.keys(t).forEach((function(e){n.setRequestHeader(e,t[e])}))}))}}}(e);!function(t,e,n){var r=Qe();r.beforeSend((function(r,i){ue(e,r.url)&&(n.traceXhr(r,i),r.requestIndex=mn(),t.notify(bt.REQUEST_STARTED,{requestIndex:r.requestIndex}))})),r.onRequestComplete((function(r){ue(e,r.url)&&(n.clearTracingIfCancelled(r),t.notify(bt.REQUEST_COMPLETED,{duration:r.duration,method:r.method,requestIndex:r.requestIndex,response:r.response,spanId:r.spanId,startTime:r.startTime,status:r.status,traceId:r.traceId,type:k.XHR,url:r.url}))}))}(t,e,n),function(t,e,n){var r=en();r.beforeSend((function(r){ue(e,r.url)&&(n.traceFetch(r),r.requestIndex=mn(),t.notify(bt.REQUEST_STARTED,{requestIndex:r.requestIndex}))})),r.onRequestComplete((function(r){ue(e,r.url)&&(n.clearTracingIfCancelled(r),t.notify(bt.REQUEST_COMPLETED,{duration:r.duration,method:r.method,requestIndex:r.requestIndex,response:r.response,responseType:r.responseType,spanId:r.spanId,startTime:r.startTime,status:r.status,traceId:r.traceId,type:k.FETCH,url:r.url}))}))}(t,e,n)}function mn(){var t=ln;return ln+=1,t}function vn(t,e){return t.subscribe(bt.AUTO_ACTION_COMPLETED,(function(e){return t.notify(bt.RAW_RUM_EVENT_COLLECTED,En(e))})),e.trackInteractions&&Gt(t),{addAction:function(e,n){t.notify(bt.RAW_RUM_EVENT_COLLECTED,r({savedCommonContext:n},En(e)))}}}function En(t){var e=hn(t)?{action:{error:{count:t.counts.errorCount},id:t.id,loadingTime:q(t.duration),longTask:{count:t.counts.longTaskCount},resource:{count:t.counts.resourceCount}}}:void 0;return{customerContext:hn(t)?void 0:t.context,rawRumEvent:c({action:{target:{name:t.name},type:t.type},date:J(t.startTime),type:Rt.ACTION},e),startTime:t.startTime}}function hn(t){return t.type!==Pt.CUSTOM}function Tn(t){if(!an){var e=new wt;!function(t,e){function n(n,r){t.isIntakeUrl(r.url)||!function(t){return 0===t.status&&"opaque"!==t.responseType}(r)&&!function(t){return t.status>=500}(r)||e.notify({message:bn(n)+" error "+r.method+" "+r.url,resource:{method:r.method,statusCode:r.status,url:r.url},source:p.NETWORK,stack:yn(r.response,t)||"Failed to load",startTime:r.startTime})}Qe().onRequestComplete((function(t){return n(k.XHR,t)})),en().onRequestComplete((function(t){return n(k.FETCH,t)}))}(t,e),function(t){un=console.error,console.error=A((function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];un.apply(console,o([e],n)),t.notify({message:o(["console error:",e],n).map(gn).join(" "),source:p.CONSOLE,startTime:performance.now()})}))}(e),function(t){sn=function(e,n,r){var i=m(e,r,"Uncaught"),o=i.stack,a=i.message,u=i.type;t.notify({message:a,stack:o,type:u,source:p.SOURCE,startTime:performance.now()})},O.subscribe(sn)}(e),an=function(t,e){var n=0,r=new wt;return e.subscribe((function(e){n<t.maxErrorsByMinute?(n+=1,r.notify(e)):n===t.maxErrorsByMinute&&(n+=1,r.notify({message:"Reached max number of errors by minute: "+t.maxErrorsByMinute,source:p.AGENT,startTime:performance.now()}))})),setInterval((function(){return n=0}),H),r}(t,e)}return an}function gn(t){return"string"==typeof t?t:t instanceof Error?v(R(t)):z(t,0,2)}function yn(t,e){return t&&t.length>e.requestErrorResponseLengthLimit?t.substring(0,e.requestErrorResponseLengthLimit)+"...":t}function bn(t){return k.XHR===t?"XHR":"Fetch"}function Cn(t,e){return function(t,e,n){return n.subscribe((function(e){return t.notify(bt.RAW_RUM_EVENT_COLLECTED,On(e))})),{addError:function(e,n){var i=e.error,o=e.startTime,a=e.context,u=function(t,e,n){var i=t instanceof Error?R(t):void 0;return r({startTime:e,source:n},m(i,t,"Provided"))}(i,o,e.source);t.notify(bt.RAW_RUM_EVENT_COLLECTED,r({customerContext:a,savedCommonContext:n},On(u)))}}}(t,0,Tn(e))}function On(t){return{rawRumEvent:{date:J(t.startTime),error:{message:t.message,resource:t.resource,source:t.source,stack:t.stack,type:t.type},type:Rt.ERROR},startTime:t.startTime}}function Rn(t){if(performance&&"getEntriesByName"in performance){var e=performance.getEntriesByName(t.url,"resource");if(e.length&&"toJSON"in e[0]){var n,r=e.map((function(t){return t.toJSON()})).filter(re).filter((function(e){return n=e,r=t.startTime,i=Sn(t),n.startTime>=r&&Sn(n)<=i;var n,r,i}));return 1===r.length?r[0]:2===r.length&&Sn((n=r)[0])<=n[1].startTime?r[1]:void 0}}}function Sn(t){return t.startTime+t.duration}function _n(t,e,n){t.subscribe(bt.REQUEST_COMPLETED,(function(e){n.isTrackedWithResource()&&t.notify(bt.RAW_RUM_EVENT_COLLECTED,function(t){var e=t.type===k.XHR?U.XHR:U.FETCH,n=Rn(t),r=n?n.startTime:t.startTime,i=n?wn(n):void 0,o=function(t){if(!t.traceId||!t.spanId)return;return{_dd:{spanId:t.spanId.toDecimalString(),traceId:t.traceId.toDecimalString()},resource:{id:V()}}}(t),a=c({date:J(r),resource:{type:e,duration:q(t.duration),method:t.method,statusCode:t.status,url:t.url},type:Rt.RESOURCE},o,i);return{startTime:r,rawRumEvent:a}}(e))})),t.subscribe(bt.PERFORMANCE_ENTRY_COLLECTED,(function(e){var r;n.isTrackedWithResource()&&"resource"===e.entryType&&("xmlhttprequest"!==(r=e).initiatorType&&"fetch"!==r.initiatorType)&&t.notify(bt.RAW_RUM_EVENT_COLLECTED,function(t){var e=te(t),n=wn(t),r=function(t){return t.traceId?{_dd:{traceId:t.traceId}}:void 0}(t),i=c({date:J(t.startTime),resource:{type:e,url:t.name},type:Rt.RESOURCE},r,n);return{startTime:t.startTime,rawRumEvent:i}}(e))}))}function wn(t){return{resource:r({duration:(e=t,n=e.duration,i=e.startTime,o=e.responseEnd,q(0===n&&i<o?o-i:n)),size:ae(t)},ne(t))};var e,n,i,o}function An(t){return void 0===t&&(t=window),cn||("hidden"===document.visibilityState?cn={timeStamp:0}:(cn={timeStamp:1/0},rt(t,M.PAGE_HIDE,(function(t){var e=t.timeStamp;cn.timeStamp=e}),{capture:!0,once:!0}).stop)),cn}function In(t,e){var n;function i(t){n=r(r({},n),t),e(n)}var o=function(t,e){return{stop:t.subscribe(bt.PERFORMANCE_ENTRY_COLLECTED,(function(t){"navigation"===t.entryType&&e({domComplete:t.domComplete,domContentLoaded:t.domContentLoadedEventEnd,domInteractive:t.domInteractive,loadEvent:t.loadEventEnd})})).unsubscribe}}(t,i).stop,a=function(t,e){var n=An();return{stop:t.subscribe(bt.PERFORMANCE_ENTRY_COLLECTED,(function(t){"paint"===t.entryType&&"first-contentful-paint"===t.name&&t.startTime<n.timeStamp&&e(t.startTime)})).unsubscribe}}(t,(function(t){return i({firstContentfulPaint:t})})).stop,u=function(t,e,n){var r=An(),i=1/0,o=it(e,[M.POINTER_DOWN,M.KEY_DOWN],(function(t){i=t.timeStamp}),{capture:!0,once:!0}).stop,a=t.subscribe(bt.PERFORMANCE_ENTRY_COLLECTED,(function(t){"largest-contentful-paint"===t.entryType&&t.startTime<i&&t.startTime<r.timeStamp&&n(t.startTime)})).unsubscribe;return{stop:function(){o(),a()}}}(t,window,(function(t){i({largestContentfulPaint:t})})).stop,s=function(t,e){var n=An();return{stop:t.subscribe(bt.PERFORMANCE_ENTRY_COLLECTED,(function(t){"first-input"===t.entryType&&t.startTime<n.timeStamp&&e(t.processingStart-t.startTime)})).unsubscribe}}(t,(function(t){i({firstInputDelay:t})})).stop;return{stop:function(){o(),a(),u(),s()}}}!function(t){t.INITIAL_LOAD="initial_load",t.ROUTE_CHANGE="route_change"}(fn||(fn={}));var Nn=3e3,Dn=5*H;function Ln(t,e){var n,r=xn(e,t,fn.INITIAL_LOAD,document.referrer,0),i=r,o=In(e,(function(t){r.updateTimings(t),r.scheduleUpdate()})).stop;function a(){i.isDifferentView(t)?(i.end(),i.triggerUpdate(),i=xn(e,t,fn.ROUTE_CHANGE,i.url)):(i.updateLocation(t),i.triggerUpdate())}!function(t){var e=history.pushState;history.pushState=A((function(){e.apply(this,arguments),t()}));var n=history.replaceState;history.replaceState=A((function(){n.apply(this,arguments),t()})),rt(window,M.POP_STATE,t)}(a),n=a,rt(window,M.HASH_CHANGE,n),e.subscribe(bt.SESSION_RENEWED,(function(){i.end(),i=xn(e,t,fn.ROUTE_CHANGE,i.url)})),e.subscribe(bt.BEFORE_UNLOAD,(function(){i.end(),i.triggerUpdate()}));var u=window.setInterval(A((function(){i.triggerUpdate()})),Dn);return{stop:function(){o(),i.end(),clearInterval(u)}}}function xn(t,e,n,i,o){void 0===o&&(o=performance.now());var a,u,s,c=V(),f={errorCount:0,longTaskCount:0,resourceCount:0,userActionCount:0},d={},l=0,p=r({},e);t.notify(bt.VIEW_CREATED,{id:c,startTime:o,location:p,referrer:i});var m,v=j(A(O),Nn,{leading:!1}),E=v.throttled,h=v.cancel,T=_t(t,(function(t){f=t,E()})).stop,g=function(t,e){var n=t===fn.INITIAL_LOAD,r=!0,i=[];function o(){!r&&!n&&i.length>0&&e(Math.max.apply(Math,i))}return{setLoadEvent:function(t){n&&(n=!1,i.push(t),o())},setActivityLoadingTime:function(t){r&&(r=!1,void 0!==t&&i.push(t),o())}}}(n,(function(t){u=t,E()})),y=g.setActivityLoadingTime,b=g.setLoadEvent,C=function(t,e){var n=performance.now();return{stop:Dt(t,(function(t,r){e(t?r-n:void 0)})).stop}}(t,y).stop;function O(){l+=1,t.notify(bt.VIEW_UPDATED,{cumulativeLayoutShift:a,documentVersion:l,eventCounts:f,id:c,loadingTime:u,loadingType:n,location:p,referrer:i,startTime:o,timings:d,duration:(void 0===s?performance.now():s)-o,isActive:void 0===s})}return ve("layout-shift")?(a=0,m=function(t,e){return{stop:t.subscribe(bt.PERFORMANCE_ENTRY_COLLECTED,(function(t){"layout-shift"!==t.entryType||t.hadRecentInput||e(t.value)})).unsubscribe}}(t,(function(t){a+=t,E()})).stop):m=G,O(),{scheduleUpdate:E,end:function(){s=performance.now(),T(),C(),m()},isDifferentView:function(t){return p.pathname!==t.pathname||(e=t.hash,n=e.substr(1),!document.getElementById(n)&&t.hash!==p.hash);var e,n},triggerUpdate:function(){h(),O()},updateTimings:function(t){d=t,void 0!==t.loadEvent&&b(t.loadEvent)},updateLocation:function(t){p=r({},t)},get url(){return p.href}}}function Mn(t,e,n){return t.subscribe(bt.VIEW_UPDATED,(function(e){return t.notify(bt.RAW_RUM_EVENT_COLLECTED,function(t){return{rawRumEvent:{_dd:{documentVersion:t.documentVersion},date:J(t.startTime),type:Rt.VIEW,view:{action:{count:t.eventCounts.userActionCount},cumulativeLayoutShift:t.cumulativeLayoutShift,domComplete:q(t.timings.domComplete),domContentLoaded:q(t.timings.domContentLoaded),domInteractive:q(t.timings.domInteractive),error:{count:t.eventCounts.errorCount},firstContentfulPaint:q(t.timings.firstContentfulPaint),firstInputDelay:q(t.timings.firstInputDelay),isActive:t.isActive,largestContentfulPaint:q(t.timings.largestContentfulPaint),loadEvent:q(t.timings.loadEvent),loadingTime:q(t.loadingTime),loadingType:t.loadingType,longTask:{count:t.eventCounts.longTaskCount},resource:{count:t.eventCounts.resourceCount},timeSpent:q(t.duration)}},startTime:t.startTime}}(e))})),Ln(n,t)}var Un,kn="rum";function Pn(t,e){var n=Ue(t.cookieOptions,kn,(function(e){return function(t,e){var n;n=function(t){return t===Un.NOT_TRACKED||t===Un.TRACKED_WITH_RESOURCES||t===Un.TRACKED_WITHOUT_RESOURCES}(e)?e:F(t.sampleRate)?F(t.resourceSampleRate)?Un.TRACKED_WITH_RESOURCES:Un.TRACKED_WITHOUT_RESOURCES:Un.NOT_TRACKED;return{trackingType:n,isTracked:Bn(n)}}(t,e)}));return n.renewObservable.subscribe((function(){e.notify(bt.SESSION_RENEWED)})),{getId:n.getId,isTracked:function(){return void 0!==n.getId()&&Bn(n.getTrackingType())},isTrackedWithResource:function(){return void 0!==n.getId()&&n.getTrackingType()===Un.TRACKED_WITH_RESOURCES}}}function Bn(t){return t===Un.TRACKED_WITH_RESOURCES||t===Un.TRACKED_WITHOUT_RESOURCES}function Hn(t,e){var n=function(t,e){var n,r=o(t.rumEndpoint,(function(){return e.notify(bt.BEFORE_UNLOAD)})),i=t.replica;void 0!==i&&(n=o(i.rumEndpoint));function o(e,n){return new T(new h(e,t.batchBytesLimit,!0),t.maxBatchSize,t.batchBytesLimit,t.maxMessageSize,t.flushTimeout,n)}function a(t){return c(t,{application:{id:i.applicationId}})}var u=!1;return{add:function(t){u||(r.add(t),n&&n.add(a(t)))},stop:function(){u=!0},upsert:function(t,e){u||(r.upsert(t,e),n&&n.upsert(a(t),e))}}}(t,e);return e.subscribe(bt.RUM_EVENT_COLLECTED,(function(t){var e=t.assembledRumEvent,r=t.serverRumEvent;e.type===Rt.VIEW?n.upsert(r,e.view.id):n.add(r)})),{stop:function(){n.stop()}}}!function(t){t.NOT_TRACKED="0",t.TRACKED_WITH_RESOURCES="1",t.TRACKED_WITHOUT_RESOURCES="2"}(Un||(Un={}));var Wn={buildMode:"release",datacenter:"us",sdkVersion:"2.1.2"};var jn,Vn,Fn,qn,Gn=zn((function(t,e){var n=new St,r=function(t,e){var n=lt(t,e);return{configuration:n,internalMonitoring:w(n)}}(t,Wn),i=r.configuration,o=r.internalMonitoring,u=Pn(i,n);o.setExternalContextProvider((function(){return c({application_id:t.applicationId},f.findView(),e().context)}));var s=function(t,e,n,r,i,o){var a=function(t,e){var n,r,i,o=[],a=[];t.subscribe(bt.VIEW_CREATED,(function(t){n&&o.unshift({context:c(),endTime:t.startTime,startTime:n.startTime}),n=t,i=e.getId()})),t.subscribe(bt.VIEW_UPDATED,(function(t){n.id===t.id&&(n=t)})),t.subscribe(bt.AUTO_ACTION_CREATED,(function(t){r=t})),t.subscribe(bt.AUTO_ACTION_COMPLETED,(function(t){r&&a.unshift({context:f(),endTime:r.startTime+t.duration,startTime:r.startTime}),r=void 0})),t.subscribe(bt.AUTO_ACTION_DISCARDED,(function(){r=void 0})),t.subscribe(bt.SESSION_RENEWED,(function(){o=[],a=[],n=void 0,r=void 0}));var u=window.setInterval(A((function(){s(o,Fe),s(a,qe)})),Ge);function s(t,e){for(var n=performance.now()-e;t.length>0&&t[t.length-1].startTime<n;)t.pop()}function c(){return{session:{id:i},view:{id:n.id,referrer:n.referrer,url:n.location.href}}}function f(){return{action:{id:r.id}}}function d(t,e,n,r){if(void 0===r)return n?t():void 0;if(n&&r>=n.startTime)return t();for(var i=0,o=e;i<o.length;i++){var a=o[i];if(r>a.endTime)break;if(r>=a.startTime)return a.context}}return{findAction:function(t){return d(f,a,r,t)},findView:function(t){return d(c,o,n,t)},stop:function(){window.clearInterval(u)}}}(n,i),u=Hn(r,n);Se(t,r,n,i,a,o),function(t,e){t.subscribe(bt.PERFORMANCE_ENTRY_COLLECTED,(function(e){if("longtask"===e.entryType){var n={date:J(e.startTime),longTask:{duration:q(e.duration)},type:Rt.LONG_TASK};t.notify(bt.RAW_RUM_EVENT_COLLECTED,{rawRumEvent:n,startTime:e.startTime})}}))}(n),_n(n,0,i),Mn(n,0,e);var s=Cn(n,r).addError;return{addAction:vn(n,r).addAction,addError:s,parentContexts:a,stop:function(){u.stop()}}}(t.applicationId,location,n,i,u,e),f=s.parentContexts,d=s.addError,l=s.addAction;return pn(n,i),Ee(n,i),Yt(n),{addAction:l,addError:d,getInternalContext:function(t,e,n){return{get:function(r){var i=n.findView(r);if(e.isTracked()&&i&&i.session.id){var o=n.findAction(r);return a(c({applicationId:t},{sessionId:i.session.id,view:i.view},o?{userAction:{id:o.action.id}}:void 0))}}}}(t.applicationId,u,f).get}}));function zn(t){var e,n=!1,i=(e={},{get:function(){return e},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},set:function(t){e=t}}),o={},a=function(){},u=new Ot,s=function(t){u.add([t,l()])},c=new Ot,d=function(t){c.add([t,l()])};function l(){return f({context:i.get(),user:o})}var m=function(t){var e=r(r({},t),{onReady:function(t){t()}});return Object.defineProperty(e,"_setDebug",{get:function(){return L},enumerable:!1}),e}({init:A((function(e){var r;gt(pt(e))&&yt()&&function(t){if(n)return t.silentMultipleInit||console.error("DD_RUM is already initialized."),!1;if(!t||!t.clientToken&&!t.publicApiKey)return console.error("Client Token is not configured, we will not send any data."),!1;if(!t.applicationId)return console.error("Application ID is not configured, no RUM data will be collected."),!1;if(void 0!==t.sampleRate&&!$(t.sampleRate))return console.error("Sample Rate should be a number between 0 and 100"),!1;if(void 0!==t.resourceSampleRate&&!$(t.resourceSampleRate))return console.error("Resource Sample Rate should be a number between 0 and 100"),!1;if(Array.isArray(t.allowedTracingOrigins)&&0!==t.allowedTracingOrigins.length&&void 0===t.service)return console.error("Service need to be configured when tracing is enabled"),!1;return!0}(e)&&(e.publicApiKey&&(e.clientToken=e.publicApiKey),r=t(e,(function(){return{user:o,context:i.get()}})),s=r.addAction,d=r.addError,a=r.getInternalContext,u.drain((function(t){var e=t[0],n=t[1];return s(e,n)})),c.drain((function(t){var e=t[0],n=t[1];return d(e,n)})),n=!0)})),addRumGlobalContext:A(i.add),removeRumGlobalContext:A(i.remove),getRumGlobalContext:A(i.get),setRumGlobalContext:A(i.set),getInternalContext:A((function(t){return a(t)})),addAction:A((function(t,e){s({name:t,context:f(e),startTime:performance.now(),type:Pt.CUSTOM})})),addUserAction:function(t,e){m.addAction(t,e)},addError:A((function(t,e,n){var r;void 0===n&&(n=p.CUSTOM),n===p.CUSTOM||n===p.NETWORK||n===p.SOURCE?r=n:(console.error("DD_RUM.addError: Invalid source '"+n+"'"),r=p.CUSTOM),d({error:t,context:f(e),source:r,startTime:performance.now()})})),setUser:A((function(t){var e=function(t){if("object"!=typeof t||!t)return;var e=f(t);"id"in e&&(e.id=String(e.id));"name"in e&&(e.name=String(e.name));"email"in e&&(e.email=String(e.email));return e}(t);e?o=e:console.error("Unsupported user:",t)}))});return m}jn=function(){if("object"==typeof globalThis)return globalThis;Object.defineProperty(Object.prototype,"_dd_temp_",{get:function(){return this},configurable:!0});var t=_dd_temp_;return delete Object.prototype._dd_temp_,"object"!=typeof t&&(t="object"==typeof self?self:"object"==typeof window?window:{}),t}(),Fn=Gn,qn=jn[Vn="DD_RUM"],jn[Vn]=Fn,qn&&qn.q&&qn.q.forEach((function(t){return t()}))}]);
!function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([,function(t,e,n){"use strict";n.r(e),n.d(e,"datadogRum",(function(){return zn}));var r=function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function i(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}}function o(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],a=0,u=o.length;a<u;a++,i++)r[i]=o[a];return r}function a(t){var e={};return Object.keys(t).forEach((function(n){var r;e[(r=n,r.replace(/[A-Z]/g,(function(t,e){return(0!==e?"_":"")+t.toLowerCase()})).replace(/-/g,"_"))]=function t(e){if(Array.isArray(e))return e.map((function(e){return t(e)}));if("object"==typeof e&&null!==e)return a(e);return e}(t[n])})),e}var u=function(t){return Array.isArray(t)},s=function(t){return!Array.isArray(t)&&"object"==typeof t&&null!==t};function c(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];for(var r=0,i=e;r<i.length;r++){var o=i[r];null!=o&&(t=l(t,o,d()))}return t}function f(t){return l(void 0,t,d())}function d(){if("undefined"!=typeof WeakSet){var t=new WeakSet;return{hasAlreadyBeenSeen:function(e){var n=t.has(e);return n||t.add(e),n}}}var e=[];return{hasAlreadyBeenSeen:function(t){var n=e.indexOf(t)>=0;return n||e.push(t),n}}}function l(t,e,n){if(void 0===e)return t;if(!s(e)&&!u(e))return e;if(!n.hasAlreadyBeenSeen(e)){if(s(e)&&(void 0===t||s(t))){var r=t||{};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=l(r[i],e[i],n));return r}if(u(e)&&(void 0===t||u(t))){(r=t||[]).length=Math.max(r.length,e.length);for(var o=0;o<e.length;o+=1)r[o]=l(r[o],e[o],n);return r}return e}}var p={AGENT:"agent",CONSOLE:"console",CUSTOM:"custom",LOGGER:"logger",NETWORK:"network",SOURCE:"source"};function m(t,e,n){return t&&(void 0!==t.message||e instanceof Error)?{message:t.message||"Empty message",stack:v(t),type:t.name}:{message:n+" "+G(e),stack:"No stack, consider using an instance of Error",type:t&&t.name}}function v(t){var e=(t.name||"Error")+": "+t.message;return t.stack.forEach((function(t){var n="?"===t.func?"<anonymous>":t.func,r=t.args&&t.args.length>0?"("+t.args.join(", ")+")":"",i=t.line?":"+t.line:"",o=t.line&&t.column?":"+t.column:"";e+="\n at "+n+r+" @ "+t.url+i+o})),e}var E=/[^\u0000-\u007F]/,h=function(){function t(t,e,n){void 0===n&&(n=!1),this.endpointUrl=t,this.bytesLimit=e,this.withBatchTime=n}return t.prototype.send=function(t,e){var n=this.withBatchTime?function(t){return t+(-1===t.indexOf("?")?"?":"&")+"batch_time="+(new Date).getTime()}(this.endpointUrl):this.endpointUrl;if(navigator.sendBeacon&&e<this.bytesLimit&&navigator.sendBeacon(n,t))return;var r=new XMLHttpRequest;r.open("POST",n,!0),r.send(t)},t}();var T=function(){function t(t,e,n,r,i,o){void 0===o&&(o=z),this.request=t,this.maxSize=e,this.bytesLimit=n,this.maxMessageSize=r,this.flushTimeout=i,this.beforeUnloadCallback=o,this.pushOnlyBuffer=[],this.upsertBuffer={},this.bufferBytesSize=0,this.bufferMessageCount=0,this.flushOnVisibilityHidden(),this.flushPeriodically()}return t.prototype.add=function(t){this.addOrUpdate(t)},t.prototype.upsert=function(t,e){this.addOrUpdate(t,e)},t.prototype.flush=function(){if(0!==this.bufferMessageCount){var t=o(this.pushOnlyBuffer,(e=this.upsertBuffer,n=[],Object.keys(e).forEach((function(t){n.push(e[t])})),n));this.request.send(t.join("\n"),this.bufferBytesSize),this.pushOnlyBuffer=[],this.upsertBuffer={},this.bufferBytesSize=0,this.bufferMessageCount=0}var e,n},t.prototype.sizeInBytes=function(t){return E.test(t)?void 0!==window.TextEncoder?(new TextEncoder).encode(t).length:new Blob([t]).size:t.length},t.prototype.addOrUpdate=function(t,e){var n=this.process(t),r=n.processedMessage,i=n.messageBytesSize;i>=this.maxMessageSize?console.warn("Discarded a message whose size was bigger than the maximum allowed size "+this.maxMessageSize+"KB."):(this.hasMessageFor(e)&&this.remove(e),this.willReachedBytesLimitWith(i)&&this.flush(),this.push(r,i,e),this.isFull()&&this.flush())},t.prototype.process=function(t){var e=G(t);return{processedMessage:e,messageBytesSize:this.sizeInBytes(e)}},t.prototype.push=function(t,e,n){this.bufferMessageCount>0&&(this.bufferBytesSize+=1),void 0!==n?this.upsertBuffer[n]=t:this.pushOnlyBuffer.push(t),this.bufferBytesSize+=e,this.bufferMessageCount+=1},t.prototype.remove=function(t){var e=this.upsertBuffer[t];delete this.upsertBuffer[t];var n=this.sizeInBytes(e);this.bufferBytesSize-=n,this.bufferMessageCount-=1,this.bufferMessageCount>0&&(this.bufferBytesSize-=1)},t.prototype.hasMessageFor=function(t){return void 0!==t&&void 0!==this.upsertBuffer[t]},t.prototype.willReachedBytesLimitWith=function(t){return this.bufferBytesSize+t+1>=this.bytesLimit},t.prototype.isFull=function(){return this.bufferMessageCount===this.maxSize||this.bufferBytesSize>=this.bytesLimit},t.prototype.flushPeriodically=function(){var t=this;setTimeout((function(){t.flush(),t.flushPeriodically()}),this.flushTimeout)},t.prototype.flushOnVisibilityHidden=function(){var t=this;navigator.sendBeacon&&(rt(window,M.BEFORE_UNLOAD,this.beforeUnloadCallback),rt(document,M.VISIBILITY_CHANGE,(function(){"hidden"===document.visibilityState&&t.flush()})),rt(window,M.BEFORE_UNLOAD,(function(){return t.flush()})))},t}(),g="?",y=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/;function b(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var C,O=function(){var t,e,n,r,i,o,a=[];function u(t,e,n){var r;for(var i in a)if(b(a,i))try{a[i](t,e,n)}catch(t){r=t}if(r)throw r}function s(t,r,i,o,a){if(e)R.augmentStackTraceWithInitialElement(e,r,i,""+t),f();else if(a)u(R(a),!0,a);else{var s,c={url:r,column:o,line:i},d=t;if("[object String]"==={}.toString.call(t)){var l=d.match(y);l&&(s=l[1],d=l[2])}u({name:s,message:"string"==typeof d?d:void 0,stack:[c]},!0,t)}return!!n&&n.apply(this,arguments)}function c(t){var e=t.reason||"Empty reason";u(R(e),!0,e)}function f(){var n=e,r=t;e=void 0,t=void 0,u(n,!1,r)}function d(n){if(e){if(t===n)return;f()}var r=R(n);throw e=r,t=n,setTimeout((function(){t===n&&f()}),r.incomplete?2e3:0),n}return d.subscribe=function(t){!function(){if(r)return;n=window.onerror,window.onerror=I(s),r=!0}(),function(){if(o)return;i=null!==window.onunhandledrejection?window.onunhandledrejection:void 0,window.onunhandledrejection=I(c),o=!0}(),a.push(t)},d.unsubscribe=function(t){for(var e=a.length-1;e>=0;e-=1)a[e]===t&&a.splice(e,1);0===a.length&&(r&&(window.onerror=n,r=!1),o&&(window.onunhandledrejection=i,o=!1))},d.traceKitWindowOnError=s,d}(),R=function(){var t=!1;function e(t){var e=o(t,"stack");if(e){for(var n,r,i,a,u=/^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,s=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i,c=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,f=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,d=/\((\S*)(?::(\d+))(?::(\d+))\)/,l=e.split("\n"),p=[],m=0,v=l.length;m<v;m+=1){if(u.exec(l[m])){var E=(i=u.exec(l[m]))[2]&&0===i[2].indexOf("native");n=i[2]&&0===i[2].indexOf("eval"),r=d.exec(i[2]),n&&r&&(i[2]=r[1],i[3]=r[2],i[4]=r[3]),a={args:E?[i[2]]:[],column:i[4]?+i[4]:void 0,func:i[1]||g,line:i[3]?+i[3]:void 0,url:E?void 0:i[2]}}else if(c.exec(l[m]))a={args:[],column:(i=c.exec(l[m]))[4]?+i[4]:void 0,func:i[1]||g,line:+i[3],url:i[2]};else{if(!s.exec(l[m]))continue;n=(i=s.exec(l[m]))[3]&&i[3].indexOf(" > eval")>-1,r=f.exec(i[3]),n&&r?(i[3]=r[1],i[4]=r[2],i[5]=void 0):0!==m||i[5]||void 0===t.columnNumber||(p[0].column=t.columnNumber+1),a={args:i[2]?i[2].split(","):[],column:i[5]?+i[5]:void 0,func:i[1]||g,line:i[4]?+i[4]:void 0,url:i[3]}}!a.func&&a.line&&(a.func=g),p.push(a)}if(p.length)return{stack:p,message:o(t,"message"),name:o(t,"name")}}}function n(t,e,n,r){var i={url:e,line:n?+n:void 0};if(i.url&&i.line){t.incomplete=!1;var o=t.stack;if(o.length>0&&o[0].url===i.url){if(o[0].line===i.line)return!1;if(!o[0].line&&o[0].func===i.func)return o[0].line=i.line,o[0].context=i.context,!1}return o.unshift(i),t.partial=!0,!0}return t.incomplete=!0,!1}function r(t,e){for(var i,a,u=/function\s+([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)?\s*\(/i,s=[],c={},f=!1,d=r.caller;d&&!f;d=d.caller)d!==R&&d!==O&&(a={args:[],column:void 0,func:g,line:void 0,url:void 0},i=u.exec(d.toString()),d.name?a.func=d.name:i&&(a.func=i[1]),void 0===a.func&&(a.func=i?i.input.substring(0,i.input.indexOf("{")):void 0),c[""+d]?f=!0:c[""+d]=!0,s.push(a));e&&s.splice(0,e);var l={stack:s,message:o(t,"message"),name:o(t,"name")};return n(l,o(t,"sourceURL")||o(t,"fileName"),o(t,"line")||o(t,"lineNumber"),o(t,"message")||o(t,"description")),l}function i(n,i){var a,u=void 0===i?0:+i;try{if(a=function(t){var e=o(t,"stacktrace");if(e){for(var n,r=/ line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i,i=/ line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^\)]+))\((.*)\))? in (.*):\s*$/i,a=e.split("\n"),u=[],s=0;s<a.length;s+=2){var c=void 0;r.exec(a[s])?c={args:[],column:void 0,func:(n=r.exec(a[s]))[3],line:+n[1],url:n[2]}:i.exec(a[s])&&(c={args:(n=i.exec(a[s]))[5]?n[5].split(","):[],column:+n[2],func:n[3]||n[4],line:+n[1],url:n[6]}),c&&(!c.func&&c.line&&(c.func=g),c.context=[a[s+1]],u.push(c))}if(u.length)return{stack:u,message:o(t,"message"),name:o(t,"name")}}}(n))return a}catch(e){if(t)throw e}try{if(a=e(n))return a}catch(e){if(t)throw e}try{if(a=function(t){var e=o(t,"message");if(e){var n=e.split("\n");if(!(n.length<4)){var r,i=/^\s*Line (\d+) of linked script ((?:file|https?|blob)\S+)(?:: in function (\S+))?\s*$/i,a=/^\s*Line (\d+) of inline#(\d+) script in ((?:file|https?|blob)\S+)(?:: in function (\S+))?\s*$/i,u=/^\s*Line (\d+) of function script\s*$/i,s=[],c=window&&window.document&&window.document.getElementsByTagName("script"),f=[];for(var d in c)b(c,d)&&!c[d].src&&f.push(c[d]);for(var l=2;l<n.length;l+=2){var p=void 0;if(i.exec(n[l]))p={args:[],column:void 0,func:(r=i.exec(n[l]))[3],line:+r[1],url:r[2]};else if(a.exec(n[l]))p={args:[],column:void 0,func:(r=a.exec(n[l]))[4],line:+r[1],url:r[3]};else if(u.exec(n[l])){r=u.exec(n[l]),p={url:window.location.href.replace(/#.*$/,""),args:[],column:void 0,func:"",line:+r[1]}}p&&(p.func||(p.func=g),p.context=[n[l+1]],s.push(p))}if(s.length)return{stack:s,message:n[0],name:o(t,"name")}}}}(n))return a}catch(e){if(t)throw e}try{if(a=r(n,u+1))return a}catch(e){if(t)throw e}return{message:o(n,"message"),name:o(n,"name"),stack:[]}}function o(t,e){if("object"==typeof t&&t&&e in t){var n=t[e];return"string"==typeof n?n:void 0}}return i.augmentStackTraceWithInitialElement=n,i.computeStackTraceFromStackProp=e,i.ofCaller=function(t){var e=1+(void 0===t?0:+t);try{throw new Error}catch(t){return R(t,e+1)}},i}();!function(t){t.info="info",t.error="error"}(C||(C={}));var S,_={maxMessagesPerPage:0,sentMessageCount:0};function w(t){if(t.internalMonitoringEndpoint){var e=function(t){var e,n=r(t.internalMonitoringEndpoint);void 0!==t.replica&&(e=r(t.replica.internalMonitoringEndpoint));function r(e){return new T(new h(e,t.batchBytesLimit),t.maxBatchSize,t.batchBytesLimit,t.maxMessageSize,t.flushTimeout)}return{add:function(t){var r=function(t){return c({date:(new Date).getTime(),view:{referrer:document.referrer,url:window.location.href}},void 0!==S?S():{},t)}(t);n.add(r),e&&e.add(r)}}}(t);!function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];e.forEach((function(e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}))}(_,{batch:e,maxMessagesPerPage:t.maxInternalMonitoringMessagesPerPage,sentMessageCount:0})}return{setExternalContextProvider:function(t){S=t}}}function I(t){return function(){try{return t.apply(this,arguments)}catch(t){x(t);try{N(t)}catch(t){x(t)}}}}function A(t,e){!function(t){_.debugMode&&console.log("[MONITORING MESSAGE]",t)}(t),D(r(r({message:t},e),{status:C.info}))}function N(t){D(r(r({},function(t){if(t instanceof Error){var e=R(t);return{error:{kind:e.name,stack:v(e)},message:e.message}}return{error:{stack:"Not an instance of error"},message:"Uncaught "+G(t)}}(t)),{status:C.error}))}function D(t){_.batch&&_.sentMessageCount<_.maxMessagesPerPage&&(_.sentMessageCount+=1,_.batch.add(t))}function L(t){_.debugMode=t}function x(t){_.debugMode&&console.warn("[INTERNAL ERROR]",t)}var M,U,k,P,B=1e3,H=60*B,W=60*H;function j(t,e,n){var r,i=!n||void 0===n.leading||n.leading,o=!n||void 0===n.trailing||n.trailing,a=!1,u=!1;return{throttled:function(){var n=this;a?u=!0:(i?t.apply(this):u=!0,a=!0,r=window.setTimeout((function(){o&&u&&t.apply(n),a=!1,u=!1}),e))},cancel:function(){window.clearTimeout(r),a=!1,u=!1}}}function F(t){return t?(parseInt(t,10)^16*Math.random()>>parseInt(t,10)/4).toString(16):(1e7+"-1000-4000-8000-100000000000").replace(/[018]/g,F)}function V(t){return 0!==t&&100*Math.random()<=t}function q(t){return"number"!=typeof t?t:+(1e6*t).toFixed(0)}function z(){}function G(t,e,n){if(null==t)return JSON.stringify(t);var r=[!1,void 0];K(t)&&(r=[!0,t.toJSON],delete t.toJSON);var i,o,a=[!1,void 0];"object"==typeof t&&K(i=Object.getPrototypeOf(t))&&(a=[!0,i.toJSON],delete i.toJSON);try{o=JSON.stringify(t,void 0,n)}catch(t){o="<error: unable to serialize object>"}finally{r[0]&&(t.toJSON=r[1]),a[0]&&(i.toJSON=a[1])}return o}function K(t){return"object"==typeof t&&null!==t&&t.hasOwnProperty("toJSON")}function Y(t,e){return-1!==t.indexOf(e)}function $(t){return X(t)&&t>=0&&t<=100}function X(t){return"number"==typeof t}function J(t){return Math.floor(Q()+t)}function Q(){return void 0===P&&(P=performance.timing.navigationStart),P}function Z(t){return Object.keys(t).map((function(e){return[e,t[e]]}))}function tt(t){return 0===Object.keys(t).length}function et(t){if(t.origin)return t.origin;var e=t.host.replace(/(:80|:443)$/,"");return t.protocol+"//"+e}function nt(t,e){var n=t.match("(?:^|;)\\s*"+e+"\\s*=\\s*([^;]+)");return n?n[1]:void 0}function rt(t,e,n,r){return it(t,[e],n,r)}function it(t,e,n,r){var i=void 0===r?{}:r,o=i.once,a=i.capture,u=i.passive,s=I(o?function(t){f(),n(t)}:n),c=u?{capture:a,passive:u}:a;e.forEach((function(e){return t.addEventListener(e,s,c)}));var f=function(){return e.forEach((function(e){return t.removeEventListener(e,s,c)}))};return{stop:f}}!function(t){t.BEFORE_UNLOAD="beforeunload",t.CLICK="click",t.KEY_DOWN="keydown",t.LOAD="load",t.POP_STATE="popstate",t.SCROLL="scroll",t.TOUCH_START="touchstart",t.VISIBILITY_CHANGE="visibilitychange",t.DOM_CONTENT_LOADED="DOMContentLoaded",t.POINTER_DOWN="pointerdown",t.POINTER_UP="pointerup",t.POINTER_CANCEL="pointercancel",t.HASH_CHANGE="hashchange",t.PAGE_HIDE="pagehide",t.MOUSE_DOWN="mousedown"}(M||(M={})),function(t){t.DOCUMENT="document",t.XHR="xhr",t.BEACON="beacon",t.FETCH="fetch",t.CSS="css",t.JS="js",t.IMAGE="image",t.FONT="font",t.MEDIA="media",t.OTHER="other"}(U||(U={})),function(t){t.FETCH="fetch",t.XHR="xhr"}(k||(k={}));var ot,at=B;function ut(t,e,n,r){var i=new Date;i.setTime(i.getTime()+n);var o="expires="+i.toUTCString(),a=r&&r.crossSite?"none":"strict",u=r&&r.domain?";domain="+r.domain:"",s=r&&r.secure?";secure":"";document.cookie=t+"="+e+";"+o+";path=/;samesite="+a+u+s}function st(t){return nt(document.cookie,t)}var ct,ft={allowedTracingOrigins:[],maxErrorsByMinute:3e3,maxInternalMonitoringMessagesPerPage:15,resourceSampleRate:100,sampleRate:100,silentMultipleInit:!1,trackInteractions:!1,requestErrorResponseLengthLimit:32768,flushTimeout:30*B,maxBatchSize:50,maxMessageSize:262144,batchBytesLimit:16384},dt={alternate:{logs:"logs",rum:"rum",trace:"trace"},classic:{logs:"browser",rum:"rum",trace:"public-trace"}};function lt(t,e){var n={applicationId:t.applicationId,buildMode:e.buildMode,clientToken:t.clientToken,env:t.env,proxyHost:t.proxyHost,sdkVersion:e.sdkVersion,service:t.service,site:t.site||Tt[t.datacenter||e.datacenter],version:t.version},i=Array.isArray(t.enableExperimentalFeatures)?t.enableExperimentalFeatures:[],o=function(t,e){return e.useAlternateIntakeDomains||"us3.datadoghq.com"===t?"alternate":"classic"}(n.site,t),a=function(t,e,n){if(e.proxyHost)return["https://"+e.proxyHost+"/v1/input/"];var r=[e.site];e.buildMode===Et.STAGING&&n&&r.push(Tt[ht.US]);for(var i=[],o=Object.keys(dt[t]),a=0,u=r;a<u.length;a++)for(var s=u[a],c=0,f=o;c<f.length;c++){var d=f[c];i.push("https://"+vt(t,d,s)+"/v1/input/")}return i}(o,n,void 0!==t.replica),u=r({beforeSend:t.beforeSend,cookieOptions:pt(t),isEnabled:function(t){return Y(i,t)},logsEndpoint:mt(o,"logs",n),proxyHost:t.proxyHost,rumEndpoint:mt(o,"rum",n),service:t.service,traceEndpoint:mt(o,"trace",n),isIntakeUrl:function(t){return a.some((function(e){return 0===t.indexOf(e)}))}},ft);if(t.internalMonitoringApiKey&&(u.internalMonitoringEndpoint=mt(o,"logs",n,"browser-agent-internal-monitoring")),"allowedTracingOrigins"in t&&(u.allowedTracingOrigins=t.allowedTracingOrigins),"sampleRate"in t&&(u.sampleRate=t.sampleRate),"resourceSampleRate"in t&&(u.resourceSampleRate=t.resourceSampleRate),"trackInteractions"in t&&(u.trackInteractions=!!t.trackInteractions),n.buildMode===Et.E2E_TEST&&(u.internalMonitoringEndpoint="<<< E2E INTERNAL MONITORING ENDPOINT >>>",u.logsEndpoint="<<< E2E LOGS ENDPOINT >>>",u.rumEndpoint="<<< E2E RUM ENDPOINT >>>"),n.buildMode===Et.STAGING&&void 0!==t.replica){var s=r(r({},n),{applicationId:t.replica.applicationId,clientToken:t.replica.clientToken,site:Tt[ht.US]});u.replica={applicationId:t.replica.applicationId,internalMonitoringEndpoint:mt(o,"logs",s,"browser-agent-internal-monitoring"),logsEndpoint:mt(o,"logs",s),rumEndpoint:mt(o,"rum",s)}}return u}function pt(t){var e={};return e.secure=function(t){return!!t.useSecureSessionCookie||!!t.useCrossSiteSessionCookie}(t),e.crossSite=!!t.useCrossSiteSessionCookie,t.trackSessionAcrossSubdomains&&(e.domain=function(){if(void 0===ot){for(var t="dd_site_test_"+F(),e=window.location.hostname.split("."),n=e.pop();e.length&&!st(t);)n=e.pop()+"."+n,ut(t,"test",B,{domain:n});ot=n}return ot}()),e}function mt(t,e,n,r){var i="sdk_version:"+n.sdkVersion+(n.env?",env:"+n.env:"")+(n.service?",service:"+n.service:"")+(n.version?",version:"+n.version:""),o=vt(t,e,n.site),a=n.proxyHost?n.proxyHost:o,u=n.proxyHost?"ddhost="+o+"&":"",s=""+(n.applicationId?"_dd.application_id="+n.applicationId+"&":"")+u+"ddsource="+(r||"browser")+"&ddtags="+i;return"https://"+a+"/v1/input/"+n.clientToken+"?"+s}function vt(t,e,n){var r=dt[t][e];if("classic"===t)return r+"-http-intake.logs."+n;var i=n.split("."),o=i.pop();return r+".browser-intake-"+(i.join("-")+"."+o)}var Et,ht={EU:"eu",US:"us"},Tt=((ct={})[ht.EU]="datadoghq.eu",ct[ht.US]="datadoghq.com",ct);function gt(t){return!!function(t){if(void 0===document.cookie||null===document.cookie)return!1;try{var e="dd_cookie_test_"+F();return ut(e,"test",B,t),"test"===st(e)}catch(t){return console.error(t),!1}}(t)||(console.warn("Cookies are not authorized, we will not send any data."),!1)}function yt(){return"file:"!==window.location.protocol||(console.error("Execution is not allowed in the current context."),!1)}!function(t){t.RELEASE="release",t.STAGING="staging",t.E2E_TEST="e2e-test"}(Et||(Et={}));var bt,Ct=1e4,Ot=function(){function t(t){void 0===t&&(t=Ct),this.limit=t,this.buffer=[]}return t.prototype.add=function(t){this.buffer.push(t)>this.limit&&this.buffer.splice(0,1)},t.prototype.drain=function(t){this.buffer.forEach((function(e){return t(e)})),this.buffer.length=0},t}();!function(t){t[t.PERFORMANCE_ENTRY_COLLECTED=0]="PERFORMANCE_ENTRY_COLLECTED",t[t.AUTO_ACTION_CREATED=1]="AUTO_ACTION_CREATED",t[t.AUTO_ACTION_COMPLETED=2]="AUTO_ACTION_COMPLETED",t[t.AUTO_ACTION_DISCARDED=3]="AUTO_ACTION_DISCARDED",t[t.VIEW_CREATED=4]="VIEW_CREATED",t[t.VIEW_UPDATED=5]="VIEW_UPDATED",t[t.REQUEST_STARTED=6]="REQUEST_STARTED",t[t.REQUEST_COMPLETED=7]="REQUEST_COMPLETED",t[t.SESSION_RENEWED=8]="SESSION_RENEWED",t[t.DOM_MUTATED=9]="DOM_MUTATED",t[t.BEFORE_UNLOAD=10]="BEFORE_UNLOAD",t[t.RAW_RUM_EVENT_COLLECTED=11]="RAW_RUM_EVENT_COLLECTED",t[t.RUM_EVENT_COLLECTED=12]="RUM_EVENT_COLLECTED"}(bt||(bt={}));var Rt,St=function(){function t(){this.callbacks={}}return t.prototype.notify=function(t,e){var n=this.callbacks[t];n&&n.forEach((function(t){return t(e)}))},t.prototype.subscribe=function(t,e){var n=this;return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),{unsubscribe:function(){n.callbacks[t]=n.callbacks[t].filter((function(t){return e!==t}))}}},t}();function _t(t,e){void 0===e&&(e=z);var n={errorCount:0,longTaskCount:0,resourceCount:0,userActionCount:0},r=t.subscribe(bt.RAW_RUM_EVENT_COLLECTED,(function(t){switch(t.rawRumEvent.type){case Rt.ERROR:n.errorCount+=1,e(n);break;case Rt.ACTION:n.userActionCount+=1,e(n);break;case Rt.LONG_TASK:n.longTaskCount+=1,e(n);break;case Rt.RESOURCE:n.resourceCount+=1,e(n)}}));return{stop:function(){r.unsubscribe()},eventCounts:n}}!function(t){t.ACTION="action",t.ERROR="error",t.LONG_TASK="long_task",t.VIEW="view",t.RESOURCE="resource"}(Rt||(Rt={}));var wt=function(){function t(){this.observers=[]}return t.prototype.subscribe=function(t){this.observers.push(t)},t.prototype.notify=function(t){this.observers.forEach((function(e){return e(t)}))},t}(),It=100,At=100,Nt=1e4;function Dt(t,e){var n=function(t){var e,n=new wt,r=[],i=0;function o(){n.notify({isBusy:i>0})}return r.push(t.subscribe(bt.DOM_MUTATED,(function(){return o()}))),r.push(t.subscribe(bt.PERFORMANCE_ENTRY_COLLECTED,(function(t){"resource"===t.entryType&&o()}))),r.push(t.subscribe(bt.REQUEST_STARTED,(function(t){void 0===e&&(e=t.requestIndex),i+=1,o()}))),r.push(t.subscribe(bt.REQUEST_COMPLETED,(function(t){void 0===e||t.requestIndex<e||(i-=1,o())}))),{observable:n,stop:function(){r.forEach((function(t){return t.unsubscribe()}))}}}(t),r=n.observable,i=n.stop,o=function(t,e,n){var r,i=!1,o=setTimeout(I((function(){return s(!1,0)})),It),a=setTimeout(I((function(){return s(!0,performance.now())})),Nt);function u(){i=!0,clearTimeout(o),clearTimeout(r),clearTimeout(a),e()}function s(t,e){i||(u(),n(t,e))}return t.subscribe((function(t){var e=t.isBusy;clearTimeout(o),clearTimeout(r);var n=performance.now();e||(r=setTimeout(I((function(){return s(!0,n)})),At))})),{stop:u}}(r,i,e).stop;return{stop:function(){o(),i()}}}function Lt(t){return function(t){var e;if(function(){void 0===kt&&(kt="closest"in HTMLElement.prototype);return kt}())e=t.closest("["+xt+"]");else for(var n=t;n;){if(n.hasAttribute(xt)){e=n;break}n=n.parentElement}if(!e)return;return Vt(Ft(e.getAttribute(xt).trim()))}(t)||jt(t,Bt)||jt(t,Ht)||""}var xt="data-dd-action-name";var Mt,Ut,kt,Pt,Bt=[function(t){if(function(){void 0===Ut&&(Ut="labels"in HTMLInputElement.prototype);return Ut}()){if("labels"in t&&t.labels&&t.labels.length>0)return qt(t.labels[0])}else if(t.id){var e=t.ownerDocument&&t.ownerDocument.querySelector('label[for="'+t.id.replace('"','\\"')+'"]');return e&&qt(e)}},function(t){if("INPUT"===t.nodeName){var e=t,n=e.getAttribute("type");if("button"===n||"submit"===n||"reset"===n)return e.value}},function(t){if("BUTTON"===t.nodeName||"LABEL"===t.nodeName||"button"===t.getAttribute("role"))return qt(t)},function(t){return t.getAttribute("aria-label")},function(t){var e=t.getAttribute("aria-labelledby");if(e)return e.split(/\s+/).map((function(e){return function(t,e){return t.ownerDocument?t.ownerDocument.getElementById(e):null}(t,e)})).filter((function(t){return Boolean(t)})).map(qt).join(" ")},function(t){return t.getAttribute("alt")},function(t){return t.getAttribute("name")},function(t){return t.getAttribute("title")},function(t){return t.getAttribute("placeholder")},function(t){if("options"in t&&t.options.length>0)return qt(t.options[0])}],Ht=[function(t){return qt(t)}],Wt=10;function jt(t,e){for(var n=t,r=0;r<=Wt&&n&&"BODY"!==n.nodeName&&"HTML"!==n.nodeName&&"HEAD"!==n.nodeName;){for(var i=0,o=e;i<o.length;i++){var a=(0,o[i])(n);if("string"==typeof a){var u=a.trim();if(u)return Vt(Ft(u))}}if("FORM"===n.nodeName)break;n=n.parentElement,r+=1}}function Ft(t){return t.replace(/\s+/g," ")}function Vt(t){return t.length>100?(n=100,((r=(e=t).charCodeAt(n-1))>=55296&&r<=56319?e.slice(0,n+1):e.slice(0,n))+" [...]"):t;var e,n,r}function qt(t){if(!t.isContentEditable){if("innerText"in t){var e=t.innerText;if(!function(){if(void 0===Mt){var t=document.createElement("style");t.textContent="*";var e=document.createElement("div");e.appendChild(t),document.body.appendChild(e),Mt=""===e.innerText,document.body.removeChild(e)}return Mt}())for(var n=t.querySelectorAll("script, style"),r=0;r<n.length;r+=1){var i=n[r].innerText;i.trim().length>0&&(e=e.replace(i,""))}return e}return t.textContent}}function zt(t){var e=function(t){var e,n;return{create:function(r,i){if(!e){var o=new Kt(t,r,i);e=o,n=Dt(t,(function(t,n){t?o.complete(n):o.discard(),e=void 0}))}},discardCurrent:function(){e&&(n.stop(),e.discard(),e=void 0)}}}(t);t.subscribe(bt.VIEW_CREATED,(function(){e.discardCurrent()}));var n=rt(window,M.CLICK,(function(t){if(t.target instanceof Element){var n=Lt(t.target);n&&e.create(Pt.CLICK,n)}}),{capture:!0}).stop;return{stop:function(){e.discardCurrent(),n()}}}!function(t){t.CLICK="click",t.CUSTOM="custom"}(Pt||(Pt={}));var Gt,Kt=function(){function t(t,e,n){this.lifeCycle=t,this.type=e,this.name=n,this.id=F(),this.startTime=performance.now(),this.eventCountsSubscription=_t(t),this.lifeCycle.notify(bt.AUTO_ACTION_CREATED,{id:this.id,startTime:this.startTime})}return t.prototype.complete=function(t){var e=this.eventCountsSubscription.eventCounts;this.lifeCycle.notify(bt.AUTO_ACTION_COMPLETED,{counts:{errorCount:e.errorCount,longTaskCount:e.longTaskCount,resourceCount:e.resourceCount},duration:t-this.startTime,id:this.id,name:this.name,startTime:this.startTime,type:this.type}),this.eventCountsSubscription.stop()},t.prototype.discard=function(){this.lifeCycle.notify(bt.AUTO_ACTION_DISCARDED),this.eventCountsSubscription.stop()},t}();function Yt(t){var e,n=function(){var t,e=window;if(e.Zone){var n=e.Zone.__symbol__("MutationObserver");t=e[n]}return t||(t=e.MutationObserver),t}();return n&&(e=new n(I((function(){t.notify(bt.DOM_MUTATED)})))).observe(document.documentElement,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),{stop:function(){e&&e.disconnect()}}}function $t(t){return Jt(t,et(window.location)).href}function Xt(t){return et(Jt(t))}function Jt(t,e){if(function(){if(void 0!==Gt)return Gt;try{var t=new URL("http://test/path");return Gt="http://test/path"===t.href}catch(t){Gt=!1}return Gt}())return void 0!==e?new URL(t,e):new URL(t);if(void 0===e&&!/:/.test(t))throw new Error("Invalid URL: '"+t+"'");var n=document,r=n.createElement("a");if(void 0!==e){var i=(n=document.implementation.createHTMLDocument("")).createElement("base");i.href=e,n.head.appendChild(i),n.body.appendChild(r)}return r.href=t,r}var Qt="initial_document",Zt=[[U.DOCUMENT,function(t){return Qt===t}],[U.XHR,function(t){return"xmlhttprequest"===t}],[U.FETCH,function(t){return"fetch"===t}],[U.BEACON,function(t){return"beacon"===t}],[U.CSS,function(t,e){return null!==e.match(/\.css$/i)}],[U.JS,function(t,e){return null!==e.match(/\.js$/i)}],[U.IMAGE,function(t,e){return Y(["image","img","icon"],t)||null!==e.match(/\.(gif|jpg|jpeg|tiff|png|svg|ico)$/i)}],[U.FONT,function(t,e){return null!==e.match(/\.(woff|eot|woff2|ttf)$/i)}],[U.MEDIA,function(t,e){return Y(["audio","video"],t)||null!==e.match(/\.(mp3|mp4)$/i)}]];function te(t){var e=t.name;if(!function(t){try{return!!Jt(t)}catch(t){return!1}}(e))return A('Failed to construct URL for "'+t.name+'"'),U.OTHER;for(var n=function(t){var e=Jt(t).pathname;return"/"===e[0]?e:"/"+e}(e),r=0,i=Zt;r<i.length;r++){var o=i[r],a=o[0];if((0,o[1])(t.initiatorType,n))return a}return U.OTHER}function ee(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=1;n<t.length;n+=1)if(t[n-1]>t[n])return!1;return!0}function ne(t){var e=re(t);if(e){var n=e.startTime,r=e.fetchStart,i=e.redirectStart,o=e.redirectEnd,a=e.domainLookupStart,u=e.domainLookupEnd,s=e.connectStart,c=e.secureConnectionStart,f=e.connectEnd,d=e.requestStart,l=e.responseStart,p={download:oe(n,l,e.responseEnd),firstByte:oe(n,d,l)};return f!==r&&(p.connect=oe(n,s,f),ee(s,c,f)&&(p.ssl=oe(n,c,f))),u!==r&&(p.dns=oe(n,a,u)),ie(t)&&(p.redirect=oe(n,i,o)),p}}function re(t){if(ee(t.startTime,t.fetchStart,t.domainLookupStart,t.domainLookupEnd,t.connectStart,t.connectEnd,t.requestStart,t.responseStart,t.responseEnd)){if(!ie(t))return t;var e=t.redirectStart,n=t.redirectEnd;if(e<t.startTime&&(e=t.startTime),n<t.startTime&&(n=t.fetchStart),ee(t.startTime,e,n,t.fetchStart))return r(r({},t),{redirectEnd:n,redirectStart:e})}}function ie(t){return t.fetchStart!==t.startTime}function oe(t,e,n){return{duration:q(n-e),start:q(e-t)}}function ae(t){if(t.startTime<t.responseStart)return t.decodedBodySize}function ue(t,e){return e&&!t.isIntakeUrl(e)}var se,ce=2*H;function fe(t){var e=function(t){var e=t.querySelector("meta[name=dd-trace-id]"),n=t.querySelector("meta[name=dd-trace-time]");return de(e&&e.content,n&&n.content)}(t)||function(t){var e=function(t){for(var e=0;e<t.childNodes.length;e+=1){if(n=le(t.childNodes[e]))return n}if(t.body)for(e=t.body.childNodes.length-1;e>=0;e-=1){var n,r=t.body.childNodes[e];if(n=le(r))return n;if(!pe(r))break}}(t);if(!e)return;return de(nt(e,"trace-id"),nt(e,"trace-time"))}(t);if(e&&!(e.traceTime<=Date.now()-ce))return e.traceId}function de(t,e){var n=e&&Number(e);if(t&&n)return{traceId:t,traceTime:n}}function le(t){if(t&&function(t){return"#comment"===t.nodeName}(t)){var e=t.data.match(/^\s*DATADOG;(.*?)\s*$/);if(e)return e[1]}}function pe(t){return"#text"===t.nodeName}function me(){return void 0!==window.performance&&"getEntries"in performance}function ve(t){return window.PerformanceObserver&&void 0!==PerformanceObserver.supportedEntryTypes&&PerformanceObserver.supportedEntryTypes.includes(t)}function Ee(t,e){var n;if(n=function(n){ye(t,e,n)},he("interactive",(function(){var t,e={entryType:"resource",initiatorType:Qt,traceId:fe(document)};if(ve("navigation")&&performance.getEntriesByType("navigation").length>0){var i=performance.getEntriesByType("navigation")[0];t=r(r({},i.toJSON()),e)}else{var o=Te();t=r(r(r({},o),{decodedBodySize:0,duration:o.responseEnd,name:window.location.href,startTime:0}),e)}n(t)})),me()&&ge(t,e,performance.getEntries()),window.PerformanceObserver){new PerformanceObserver(I((function(n){return ge(t,e,n.getEntries())}))).observe({entryTypes:["resource","navigation","longtask","paint","largest-contentful-paint","first-input","layout-shift"]}),me()&&"addEventListener"in performance&&performance.addEventListener("resourcetimingbufferfull",(function(){performance.clearResourceTimings()}))}ve("navigation")||function(t){function e(){t(r(r({},Te()),{entryType:"navigation"}))}he("complete",(function(){setTimeout(I(e))}))}((function(n){ye(t,e,n)})),ve("first-input")||function(t){var e=Date.now(),n=!1,r=it(window,[M.CLICK,M.MOUSE_DOWN,M.KEY_DOWN,M.TOUCH_START,M.POINTER_DOWN],(function(t){if(t.cancelable){var e={entryType:"first-input",processingStart:performance.now(),startTime:t.timeStamp};t.type===M.POINTER_DOWN?function(t){it(window,[M.POINTER_UP,M.POINTER_CANCEL],(function(e){e.type===M.POINTER_UP&&i(t)}),{once:!0})}(e):i(e)}}),{passive:!0,capture:!0}).stop;function i(i){if(!n){n=!0,r();var o=i.processingStart-i.startTime;o>=0&&o<Date.now()-e&&t(i)}}}((function(n){ye(t,e,n)}))}function he(t,e){if(document.readyState===t||"complete"===document.readyState)e();else{var n="complete"===t?M.LOAD:M.DOM_CONTENT_LOADED;rt(window,n,e,{once:!0})}}function Te(){var t={},e=performance.timing;for(var n in e)X(e[n])&&(t[n]=0===e[n]?0:e[n]-Q());return t}function ge(t,e,n){n.forEach((function(n){"resource"!==n.entryType&&"navigation"!==n.entryType&&"paint"!==n.entryType&&"longtask"!==n.entryType&&"largest-contentful-paint"!==n.entryType&&"first-input"!==n.entryType&&"layout-shift"!==n.entryType||ye(t,e,n)}))}function ye(t,e,n){(function(t){return"navigation"===t.entryType&&t.loadEventEnd<=0})(n)||function(t,e){return"resource"===e.entryType&&!ue(t,e.name)}(e,n)||t.notify(bt.PERFORMANCE_ENTRY_COLLECTED,n)}function be(t,e,n){var r=f(t);try{n(r)}catch(e){return console.error(e),t}return e.forEach((function(e){var n=Ce(t,e),i=Ce(r,e);"string"==typeof n&&"string"==typeof i&&function(t,e,n){for(var r=t,i=e.split("."),o=0;o<i.length;o+=1){var a=i[o];if(!Oe(r,a))return;o!==i.length-1?r=r[a]:r[a]=n}}(t,e,i)})),t}function Ce(t,e){for(var n=t,r=0,i=e.split(".");r<i.length;r++){var o=i[r];if(!Oe(n,o))return;n=n[o]}return n}function Oe(t,e){return"object"==typeof t&&null!==t&&e in t}!function(t){t.SYNTHETICS="synthetics",t.USER="user"}(se||(se={}));var Re=["view.url","view.referrer","action.target.name","error.message","error.stack","error.resource.url","resource.url"];function Se(t,e,n,r,i,o){n.subscribe(bt.RAW_RUM_EVENT_COLLECTED,(function(u){var s,f=u.startTime,d=u.rawRumEvent,l=u.savedCommonContext,p=u.customerContext,m=i.findView(f);if(r.isTracked()&&m&&m.session.id){var v=i.findAction(f),E={_dd:{formatVersion:2},application:{id:t},date:(new Date).getTime(),service:e.service,session:{type:void 0===window._DATADOG_SYNTHETICS_BROWSER?se.USER:se.SYNTHETICS}},h=(s=d,-1!==[Rt.ERROR,Rt.RESOURCE,Rt.LONG_TASK].indexOf(s.type)?c(E,m,v,d):c(E,m,d)),T=a(h),g=l||o(),y=c(g.context,p);tt(y)||(T.context=y),tt(g.user)||(T.usr=g.user),e.beforeSend&&be(T,Re,e.beforeSend),n.notify(bt.RUM_EVENT_COLLECTED,{assembledRumEvent:h,serverRumEvent:T})}}))}var _e="_dd",we="_dd_r",Ie="_dd_l",Ae="rum",Ne="logs";var De="_dd_s",Le=15*H,xe=4*W,Me=H;function Ue(t,e,n){var r=function(t,e){var n,r,i=!1,o=function(){i=!0,window.clearTimeout(n),n=window.setTimeout((function(){i=!1}),at)};return{get:function(){return i?r:(r=st(t),o(),r)},set:function(n,i){ut(t,n,i,e),r=n,o()}}}(De,t);!function(t){var e=t.get(),n=st(_e),r=st(we),i=st(Ie);if(!e){var o={};n&&(o.id=n),i&&/^[01]$/.test(i)&&(o[Ne]=i),r&&/^[012]$/.test(r)&&(o[Ae]=r),He(o,t)}}(r);var i=new wt,o=Be(r).id,a=j((function(){var t=Be(r),a=n(t[e]),u=a.trackingType,s=a.isTracked;t[e]=u,s&&!t.id&&(t.id=F(),t.created=String(Date.now())),He(t,r),s&&o!==t.id&&(o=t.id,i.notify())}),at).throttled;return a(),function(t){var e=it(window,[M.CLICK,M.TOUCH_START,M.KEY_DOWN,M.SCROLL],t,{capture:!0,passive:!0}).stop;je.push(e)}(a),function(t){var e=I((function(){"visible"===document.visibilityState&&t()})),n=rt(document,M.VISIBILITY_CHANGE,e).stop;je.push(n);var r=window.setInterval(e,Me);je.push((function(){clearInterval(r)}))}((function(){He(Be(r),r)})),{getId:function(){return Be(r).id},getTrackingType:function(){return Be(r)[e]},renewObservable:i}}var ke=/^([a-z]+)=([a-z0-9-]+)$/,Pe="&";function Be(t){var e=function(t){var e=t.get(),n={};(function(t){return void 0!==t&&(-1!==t.indexOf(Pe)||ke.test(t))})(e)&&e.split(Pe).forEach((function(t){var e=ke.exec(t);if(null!==e){var r=e[1],i=e[2];n[r]=i}}));return n}(t);return function(t){return(void 0===t.created||Date.now()-Number(t.created)<xe)&&(void 0===t.expire||Date.now()<Number(t.expire))}(e)?e:(We(t),{})}function He(t,e){if(tt(t))We(e);else{t.expire=String(Date.now()+Le);var n=Z(t).map((function(t){return t[0]+"="+t[1]})).join(Pe);e.set(n,Le)}}function We(t){t.set("",0)}var je=[];var Fe,Ve=xe,qe=5*H,ze=H;var Ge,Ke,Ye,$e,Xe=[],Je=[];function Qe(){return Fe||(Ge=XMLHttpRequest.prototype.open,Ke=XMLHttpRequest.prototype.send,XMLHttpRequest.prototype.open=I((function(t,e){return this._datadog_xhr={method:t,startTime:-1,url:$t(e)},Ge.apply(this,arguments)})),XMLHttpRequest.prototype.send=I((function(t){var e=this;if(this._datadog_xhr){this._datadog_xhr.startTime=performance.now();var n=this.onreadystatechange;this.onreadystatechange=function(){this.readyState===XMLHttpRequest.DONE&&I(i)(),n&&n.apply(this,arguments)};var r=!1,i=function(){r||(r=!0,e._datadog_xhr.duration=performance.now()-e._datadog_xhr.startTime,e._datadog_xhr.response=e.response,e._datadog_xhr.status=e.status,Je.forEach((function(t){return t(e._datadog_xhr)})))};this.addEventListener("loadend",I(i)),Xe.forEach((function(t){return t(e._datadog_xhr,e)}))}return Ke.apply(this,arguments)})),Fe={beforeSend:function(t){Xe.push(t)},onRequestComplete:function(t){Je.push(t)}}),Fe}var Ze=[],tn=[];function en(){return Ye||(!function(){if(!window.fetch)return;$e=window.fetch,window.fetch=I((function(t,e){var n=this,r=e&&e.method||"object"==typeof t&&t.method||"GET",o=$t("object"==typeof t&&t.url||t),a={init:e,method:r,startTime:performance.now(),url:o},u=function(t){return e=n,r=void 0,u=function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return a.duration=performance.now()-a.startTime,"stack"in t||t instanceof Error?(a.status=0,a.response=v(R(t)),tn.forEach((function(t){return t(a)})),[3,6]):[3,1];case 1:if(!("status"in t))return[3,6];e=void 0,r.label=2;case 2:return r.trys.push([2,4,,5]),[4,t.clone().text()];case 3:return e=r.sent(),[3,5];case 4:return n=r.sent(),e="Unable to retrieve response: "+n,[3,5];case 5:a.response=e,a.responseType=t.type,a.status=t.status,tn.forEach((function(t){return t(a)})),r.label=6;case 6:return[2]}}))},new((o=void 0)||(o=Promise))((function(t,n){function i(t){try{s(u.next(t))}catch(t){n(t)}}function a(t){try{s(u.throw(t))}catch(t){n(t)}}function s(e){e.done?t(e.value):new o((function(t){t(e.value)})).then(i,a)}s((u=u.apply(e,r||[])).next())}));var e,r,o,u};Ze.forEach((function(t){return t(a)}));var s=$e.call(this,t,a.init);return s.then(I(u),I(u)),s}))}(),Ye={beforeSend:function(t){Ze.push(t)},onRequestComplete:function(t){tn.push(t)}}),Ye}function nn(t){0===t.status&&(t.traceId=void 0,t.spanId=void 0)}function rn(t,e,n){var r;void 0!==on()&&function(t,e){for(var n=Xt(e),r=0,i=t.allowedTracingOrigins;r<i.length;r++){var o=i[r];if(n===o||o instanceof RegExp&&o.test(n))return!0}return!1}(t,e.url)&&(e.traceId=new dn,e.spanId=new dn,n((r=e.traceId,{"x-datadog-origin":"rum","x-datadog-parent-id":e.spanId.toDecimalString(),"x-datadog-sampled":"1","x-datadog-sampling-priority":"1","x-datadog-trace-id":r.toDecimalString()})))}function on(){return window.crypto||window.msCrypto}var an,un,sn,cn,fn,dn=function(){function t(){this.buffer=new Uint8Array(8),on().getRandomValues(this.buffer),this.buffer[0]=127&this.buffer[0]}return t.prototype.toString=function(t){for(var e=this.readInt32(0),n=this.readInt32(4),r="";;){var i=e%t*4294967296+n;if(e=Math.floor(e/t),n=Math.floor(i/t),r=(i%t).toString(t)+r,!e&&!n)break}return r},t.prototype.toDecimalString=function(){return this.toString(10)},t.prototype.readInt32=function(t){return 16777216*this.buffer[t]+(this.buffer[t+1]<<16)+(this.buffer[t+2]<<8)+this.buffer[t+3]},t}(),ln=1;function pn(t,e){var n=function(t){return{clearTracingIfCancelled:nn,traceFetch:function(e){return rn(t,e,(function(t){e.init=r({},e.init);var n=[];e.init.headers instanceof Headers?e.init.headers.forEach((function(t,e){n.push([e,t])})):Array.isArray(e.init.headers)?e.init.headers.forEach((function(t){n.push(t)})):e.init.headers&&Object.keys(e.init.headers).forEach((function(t){n.push([t,e.init.headers[t]])})),e.init.headers=n.concat(Z(t))}))},traceXhr:function(e,n){return rn(t,e,(function(t){Object.keys(t).forEach((function(e){n.setRequestHeader(e,t[e])}))}))}}}(e);!function(t,e,n){var r=Qe();r.beforeSend((function(r,i){ue(e,r.url)&&(n.traceXhr(r,i),r.requestIndex=mn(),t.notify(bt.REQUEST_STARTED,{requestIndex:r.requestIndex}))})),r.onRequestComplete((function(r){ue(e,r.url)&&(n.clearTracingIfCancelled(r),t.notify(bt.REQUEST_COMPLETED,{duration:r.duration,method:r.method,requestIndex:r.requestIndex,response:r.response,spanId:r.spanId,startTime:r.startTime,status:r.status,traceId:r.traceId,type:k.XHR,url:r.url}))}))}(t,e,n),function(t,e,n){var r=en();r.beforeSend((function(r){ue(e,r.url)&&(n.traceFetch(r),r.requestIndex=mn(),t.notify(bt.REQUEST_STARTED,{requestIndex:r.requestIndex}))})),r.onRequestComplete((function(r){ue(e,r.url)&&(n.clearTracingIfCancelled(r),t.notify(bt.REQUEST_COMPLETED,{duration:r.duration,method:r.method,requestIndex:r.requestIndex,response:r.response,responseType:r.responseType,spanId:r.spanId,startTime:r.startTime,status:r.status,traceId:r.traceId,type:k.FETCH,url:r.url}))}))}(t,e,n)}function mn(){var t=ln;return ln+=1,t}function vn(t,e){return t.subscribe(bt.AUTO_ACTION_COMPLETED,(function(e){return t.notify(bt.RAW_RUM_EVENT_COLLECTED,En(e))})),e.trackInteractions&&zt(t),{addAction:function(e,n){t.notify(bt.RAW_RUM_EVENT_COLLECTED,r({savedCommonContext:n},En(e)))}}}function En(t){var e=hn(t)?{action:{error:{count:t.counts.errorCount},id:t.id,loadingTime:q(t.duration),longTask:{count:t.counts.longTaskCount},resource:{count:t.counts.resourceCount}}}:void 0;return{customerContext:hn(t)?void 0:t.context,rawRumEvent:c({action:{target:{name:t.name},type:t.type},date:J(t.startTime),type:Rt.ACTION},e),startTime:t.startTime}}function hn(t){return t.type!==Pt.CUSTOM}function Tn(t){if(!an){var e=new wt;!function(t,e){function n(n,r){t.isIntakeUrl(r.url)||!function(t){return 0===t.status&&"opaque"!==t.responseType}(r)&&!function(t){return t.status>=500}(r)||e.notify({message:bn(n)+" error "+r.method+" "+r.url,resource:{method:r.method,statusCode:r.status,url:r.url},source:p.NETWORK,stack:yn(r.response,t)||"Failed to load",startTime:r.startTime})}Qe().onRequestComplete((function(t){return n(k.XHR,t)})),en().onRequestComplete((function(t){return n(k.FETCH,t)}))}(t,e),function(t){un=console.error,console.error=I((function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];un.apply(console,o([e],n)),t.notify({message:o(["console error:",e],n).map(gn).join(" "),source:p.CONSOLE,startTime:performance.now()})}))}(e),function(t){sn=function(e,n,r){var i=m(e,r,"Uncaught"),o=i.stack,a=i.message,u=i.type;t.notify({message:a,stack:o,type:u,source:p.SOURCE,startTime:performance.now()})},O.subscribe(sn)}(e),an=function(t,e){var n=0,r=new wt;return e.subscribe((function(e){n<t.maxErrorsByMinute?(n+=1,r.notify(e)):n===t.maxErrorsByMinute&&(n+=1,r.notify({message:"Reached max number of errors by minute: "+t.maxErrorsByMinute,source:p.AGENT,startTime:performance.now()}))})),setInterval((function(){return n=0}),H),r}(t,e)}return an}function gn(t){return"string"==typeof t?t:t instanceof Error?v(R(t)):G(t,0,2)}function yn(t,e){return t&&t.length>e.requestErrorResponseLengthLimit?t.substring(0,e.requestErrorResponseLengthLimit)+"...":t}function bn(t){return k.XHR===t?"XHR":"Fetch"}function Cn(t,e){return function(t,e,n){return n.subscribe((function(e){return t.notify(bt.RAW_RUM_EVENT_COLLECTED,On(e))})),{addError:function(e,n){var i=e.error,o=e.startTime,a=e.context,u=function(t,e,n){var i=t instanceof Error?R(t):void 0;return r({startTime:e,source:n},m(i,t,"Provided"))}(i,o,e.source);t.notify(bt.RAW_RUM_EVENT_COLLECTED,r({customerContext:a,savedCommonContext:n},On(u)))}}}(t,0,Tn(e))}function On(t){return{rawRumEvent:{date:J(t.startTime),error:{message:t.message,resource:t.resource,source:t.source,stack:t.stack,type:t.type},type:Rt.ERROR},startTime:t.startTime}}function Rn(t){if(performance&&"getEntriesByName"in performance){var e=performance.getEntriesByName(t.url,"resource");if(e.length&&"toJSON"in e[0]){var n,r=e.map((function(t){return t.toJSON()})).filter(re).filter((function(e){return n=e,r=t.startTime,i=Sn(t),n.startTime>=r&&Sn(n)<=i;var n,r,i}));return 1===r.length?r[0]:2===r.length&&Sn((n=r)[0])<=n[1].startTime?r[1]:void 0}}}function Sn(t){return t.startTime+t.duration}function _n(t,e,n){t.subscribe(bt.REQUEST_COMPLETED,(function(e){n.isTrackedWithResource()&&t.notify(bt.RAW_RUM_EVENT_COLLECTED,function(t){var e=t.type===k.XHR?U.XHR:U.FETCH,n=Rn(t),r=n?n.startTime:t.startTime,i=n?wn(n):void 0,o=function(t){if(!t.traceId||!t.spanId)return;return{_dd:{spanId:t.spanId.toDecimalString(),traceId:t.traceId.toDecimalString()},resource:{id:F()}}}(t),a=c({date:J(r),resource:{type:e,duration:q(t.duration),method:t.method,statusCode:t.status,url:t.url},type:Rt.RESOURCE},o,i);return{startTime:r,rawRumEvent:a}}(e))})),t.subscribe(bt.PERFORMANCE_ENTRY_COLLECTED,(function(e){var r;n.isTrackedWithResource()&&"resource"===e.entryType&&("xmlhttprequest"!==(r=e).initiatorType&&"fetch"!==r.initiatorType)&&t.notify(bt.RAW_RUM_EVENT_COLLECTED,function(t){var e=te(t),n=wn(t),r=function(t){return t.traceId?{_dd:{traceId:t.traceId}}:void 0}(t),i=c({date:J(t.startTime),resource:{type:e,url:t.name},type:Rt.RESOURCE},r,n);return{startTime:t.startTime,rawRumEvent:i}}(e))}))}function wn(t){return{resource:r({duration:(e=t,n=e.duration,i=e.startTime,o=e.responseEnd,q(0===n&&i<o?o-i:n)),size:ae(t)},ne(t))};var e,n,i,o}function In(t){return void 0===t&&(t=window),cn||("hidden"===document.visibilityState?cn={timeStamp:0}:(cn={timeStamp:1/0},rt(t,M.PAGE_HIDE,(function(t){var e=t.timeStamp;cn.timeStamp=e}),{capture:!0,once:!0}).stop)),cn}function An(t,e){var n;function i(t){n=r(r({},n),t),e(n)}var o=function(t,e){return{stop:t.subscribe(bt.PERFORMANCE_ENTRY_COLLECTED,(function(t){"navigation"===t.entryType&&e({domComplete:t.domComplete,domContentLoaded:t.domContentLoadedEventEnd,domInteractive:t.domInteractive,loadEvent:t.loadEventEnd})})).unsubscribe}}(t,i).stop,a=function(t,e){var n=In();return{stop:t.subscribe(bt.PERFORMANCE_ENTRY_COLLECTED,(function(t){"paint"===t.entryType&&"first-contentful-paint"===t.name&&t.startTime<n.timeStamp&&e(t.startTime)})).unsubscribe}}(t,(function(t){return i({firstContentfulPaint:t})})).stop,u=function(t,e,n){var r=In(),i=1/0,o=it(e,[M.POINTER_DOWN,M.KEY_DOWN],(function(t){i=t.timeStamp}),{capture:!0,once:!0}).stop,a=t.subscribe(bt.PERFORMANCE_ENTRY_COLLECTED,(function(t){"largest-contentful-paint"===t.entryType&&t.startTime<i&&t.startTime<r.timeStamp&&n(t.startTime)})).unsubscribe;return{stop:function(){o(),a()}}}(t,window,(function(t){i({largestContentfulPaint:t})})).stop,s=function(t,e){var n=In();return{stop:t.subscribe(bt.PERFORMANCE_ENTRY_COLLECTED,(function(t){"first-input"===t.entryType&&t.startTime<n.timeStamp&&e({firstInputDelay:t.processingStart-t.startTime,firstInputTime:t.startTime})})).unsubscribe}}(t,(function(t){i({firstInputDelay:t.firstInputDelay,firstInputTime:t.firstInputTime})})).stop;return{stop:function(){o(),a(),u(),s()}}}!function(t){t.INITIAL_LOAD="initial_load",t.ROUTE_CHANGE="route_change"}(fn||(fn={}));var Nn=3e3,Dn=5*H;function Ln(t,e){var n,r=xn(e,t,fn.INITIAL_LOAD,document.referrer,0),i=r,o=An(e,(function(t){r.updateTimings(t),r.scheduleUpdate()})).stop;function a(){i.isDifferentView(t)?(i.end(),i.triggerUpdate(),i=xn(e,t,fn.ROUTE_CHANGE,i.url)):(i.updateLocation(t),i.triggerUpdate())}!function(t){var e=history.pushState;history.pushState=I((function(){e.apply(this,arguments),t()}));var n=history.replaceState;history.replaceState=I((function(){n.apply(this,arguments),t()})),rt(window,M.POP_STATE,t)}(a),n=a,rt(window,M.HASH_CHANGE,n),e.subscribe(bt.SESSION_RENEWED,(function(){i.end(),i=xn(e,t,fn.ROUTE_CHANGE,i.url)})),e.subscribe(bt.BEFORE_UNLOAD,(function(){i.end(),i.triggerUpdate()}));var u=window.setInterval(I((function(){i.triggerUpdate()})),Dn);return{stop:function(){o(),i.end(),clearInterval(u)}}}function xn(t,e,n,i,o){void 0===o&&(o=performance.now());var a,u,s,c=F(),f={errorCount:0,longTaskCount:0,resourceCount:0,userActionCount:0},d={},l=0,p=r({},e);t.notify(bt.VIEW_CREATED,{id:c,startTime:o,location:p,referrer:i});var m,v=j(I(O),Nn,{leading:!1}),E=v.throttled,h=v.cancel,T=_t(t,(function(t){f=t,E()})).stop,g=function(t,e){var n=t===fn.INITIAL_LOAD,r=!0,i=[];function o(){!r&&!n&&i.length>0&&e(Math.max.apply(Math,i))}return{setLoadEvent:function(t){n&&(n=!1,i.push(t),o())},setActivityLoadingTime:function(t){r&&(r=!1,void 0!==t&&i.push(t),o())}}}(n,(function(t){u=t,E()})),y=g.setActivityLoadingTime,b=g.setLoadEvent,C=function(t,e){var n=performance.now();return{stop:Dt(t,(function(t,r){e(t?r-n:void 0)})).stop}}(t,y).stop;function O(){l+=1,t.notify(bt.VIEW_UPDATED,{cumulativeLayoutShift:a,documentVersion:l,eventCounts:f,id:c,loadingTime:u,loadingType:n,location:p,referrer:i,startTime:o,timings:d,duration:(void 0===s?performance.now():s)-o,isActive:void 0===s})}return ve("layout-shift")?(a=0,m=function(t,e){return{stop:t.subscribe(bt.PERFORMANCE_ENTRY_COLLECTED,(function(t){"layout-shift"!==t.entryType||t.hadRecentInput||e(t.value)})).unsubscribe}}(t,(function(t){a+=t,E()})).stop):m=z,O(),{scheduleUpdate:E,end:function(){s=performance.now(),T(),C(),m()},isDifferentView:function(t){return p.pathname!==t.pathname||(e=t.hash,n=e.substr(1),!document.getElementById(n)&&t.hash!==p.hash);var e,n},triggerUpdate:function(){h(),O()},updateTimings:function(t){d=t,void 0!==t.loadEvent&&b(t.loadEvent)},updateLocation:function(t){p=r({},t)},get url(){return p.href}}}function Mn(t,e,n){return t.subscribe(bt.VIEW_UPDATED,(function(e){return t.notify(bt.RAW_RUM_EVENT_COLLECTED,function(t){return{rawRumEvent:{_dd:{documentVersion:t.documentVersion},date:J(t.startTime),type:Rt.VIEW,view:{action:{count:t.eventCounts.userActionCount},cumulativeLayoutShift:t.cumulativeLayoutShift,domComplete:q(t.timings.domComplete),domContentLoaded:q(t.timings.domContentLoaded),domInteractive:q(t.timings.domInteractive),error:{count:t.eventCounts.errorCount},firstContentfulPaint:q(t.timings.firstContentfulPaint),firstInputDelay:q(t.timings.firstInputDelay),firstInputTime:q(t.timings.firstInputTime),isActive:t.isActive,largestContentfulPaint:q(t.timings.largestContentfulPaint),loadEvent:q(t.timings.loadEvent),loadingTime:q(t.loadingTime),loadingType:t.loadingType,longTask:{count:t.eventCounts.longTaskCount},resource:{count:t.eventCounts.resourceCount},timeSpent:q(t.duration)}},startTime:t.startTime}}(e))})),Ln(n,t)}var Un,kn="rum";function Pn(t,e){var n=Ue(t.cookieOptions,kn,(function(e){return function(t,e){var n;n=function(t){return t===Un.NOT_TRACKED||t===Un.TRACKED_WITH_RESOURCES||t===Un.TRACKED_WITHOUT_RESOURCES}(e)?e:V(t.sampleRate)?V(t.resourceSampleRate)?Un.TRACKED_WITH_RESOURCES:Un.TRACKED_WITHOUT_RESOURCES:Un.NOT_TRACKED;return{trackingType:n,isTracked:Bn(n)}}(t,e)}));return n.renewObservable.subscribe((function(){e.notify(bt.SESSION_RENEWED)})),{getId:n.getId,isTracked:function(){return void 0!==n.getId()&&Bn(n.getTrackingType())},isTrackedWithResource:function(){return void 0!==n.getId()&&n.getTrackingType()===Un.TRACKED_WITH_RESOURCES}}}function Bn(t){return t===Un.TRACKED_WITH_RESOURCES||t===Un.TRACKED_WITHOUT_RESOURCES}function Hn(t,e){var n=function(t,e){var n,r=o(t.rumEndpoint,(function(){return e.notify(bt.BEFORE_UNLOAD)})),i=t.replica;void 0!==i&&(n=o(i.rumEndpoint));function o(e,n){return new T(new h(e,t.batchBytesLimit,!0),t.maxBatchSize,t.batchBytesLimit,t.maxMessageSize,t.flushTimeout,n)}function a(t){return c(t,{application:{id:i.applicationId}})}var u=!1;return{add:function(t){u||(r.add(t),n&&n.add(a(t)))},stop:function(){u=!0},upsert:function(t,e){u||(r.upsert(t,e),n&&n.upsert(a(t),e))}}}(t,e);return e.subscribe(bt.RUM_EVENT_COLLECTED,(function(t){var e=t.assembledRumEvent,r=t.serverRumEvent;e.type===Rt.VIEW?n.upsert(r,e.view.id):n.add(r)})),{stop:function(){n.stop()}}}!function(t){t.NOT_TRACKED="0",t.TRACKED_WITH_RESOURCES="1",t.TRACKED_WITHOUT_RESOURCES="2"}(Un||(Un={}));var Wn={buildMode:"release",datacenter:"us",sdkVersion:"2.2.0"};var jn,Fn,Vn,qn,zn=function(t){var e,n=!1,i=(e={},{get:function(){return e},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},set:function(t){e=t}}),o={},a=function(){},u=new Ot,s=function(t){u.add([t,l()])},c=new Ot,d=function(t){c.add([t,l()])};function l(){return f({context:i.get(),user:o})}var m,v,E=(m={init:I((function(e){var r;gt(pt(e))&&yt()&&function(t){return n?(t.silentMultipleInit||console.error("DD_RUM is already initialized."),!1):t&&(t.clientToken||t.publicApiKey)?t.applicationId?void 0===t.sampleRate||$(t.sampleRate)?void 0===t.resourceSampleRate||$(t.resourceSampleRate)?!Array.isArray(t.allowedTracingOrigins)||0===t.allowedTracingOrigins.length||void 0!==t.service||(console.error("Service need to be configured when tracing is enabled"),!1):(console.error("Resource Sample Rate should be a number between 0 and 100"),!1):(console.error("Sample Rate should be a number between 0 and 100"),!1):(console.error("Application ID is not configured, no RUM data will be collected."),!1):(console.error("Client Token is not configured, we will not send any data."),!1)}(e)&&(e.publicApiKey&&(e.clientToken=e.publicApiKey),r=t(e,(function(){return{user:o,context:i.get()}})),s=r.addAction,d=r.addError,a=r.getInternalContext,u.drain((function(t){var e=t[0],n=t[1];return s(e,n)})),c.drain((function(t){var e=t[0],n=t[1];return d(e,n)})),n=!0)})),addRumGlobalContext:I(i.add),removeRumGlobalContext:I(i.remove),getRumGlobalContext:I(i.get),setRumGlobalContext:I(i.set),getInternalContext:I((function(t){return a(t)})),addAction:I((function(t,e){s({name:t,context:f(e),startTime:performance.now(),type:Pt.CUSTOM})})),addUserAction:function(t,e){E.addAction(t,e)},addError:I((function(t,e,n){var r;void 0===n&&(n=p.CUSTOM),n===p.CUSTOM||n===p.NETWORK||n===p.SOURCE?r=n:(console.error("DD_RUM.addError: Invalid source '"+n+"'"),r=p.CUSTOM),d({error:t,context:f(e),source:r,startTime:performance.now()})})),setUser:I((function(t){var e=function(t){if("object"==typeof t&&t){var e=f(t);return"id"in e&&(e.id=String(e.id)),"name"in e&&(e.name=String(e.name)),"email"in e&&(e.email=String(e.email)),e}}(t);e?o=e:console.error("Unsupported user:",t)}))},v=r(r({},m),{onReady:function(t){t()}}),Object.defineProperty(v,"_setDebug",{get:function(){return L},enumerable:!1}),v);return E}((function(t,e){var n=new St,r=function(t,e){var n=lt(t,e);return{configuration:n,internalMonitoring:w(n)}}(t,Wn),i=r.configuration,o=r.internalMonitoring,u=Pn(i,n);o.setExternalContextProvider((function(){return c({application_id:t.applicationId},f.findView(),e().context)}));var s=function(t,e,n,r,i,o){var a=function(t,e){var n,r,i,o=[],a=[];t.subscribe(bt.VIEW_CREATED,(function(t){n&&o.unshift({context:c(),endTime:t.startTime,startTime:n.startTime}),n=t,i=e.getId()})),t.subscribe(bt.VIEW_UPDATED,(function(t){n.id===t.id&&(n=t)})),t.subscribe(bt.AUTO_ACTION_CREATED,(function(t){r=t})),t.subscribe(bt.AUTO_ACTION_COMPLETED,(function(t){r&&a.unshift({context:f(),endTime:r.startTime+t.duration,startTime:r.startTime}),r=void 0})),t.subscribe(bt.AUTO_ACTION_DISCARDED,(function(){r=void 0})),t.subscribe(bt.SESSION_RENEWED,(function(){o=[],a=[],n=void 0,r=void 0}));var u=window.setInterval(I((function(){s(o,Ve),s(a,qe)})),ze);function s(t,e){for(var n=performance.now()-e;t.length>0&&t[t.length-1].startTime<n;)t.pop()}function c(){return{session:{id:i},view:{id:n.id,referrer:n.referrer,url:n.location.href}}}function f(){return{action:{id:r.id}}}function d(t,e,n,r){if(void 0===r)return n?t():void 0;if(n&&r>=n.startTime)return t();for(var i=0,o=e;i<o.length;i++){var a=o[i];if(r>a.endTime)break;if(r>=a.startTime)return a.context}}return{findAction:function(t){return d(f,a,r,t)},findView:function(t){return d(c,o,n,t)},stop:function(){window.clearInterval(u)}}}(n,i),u=Hn(r,n);Se(t,r,n,i,a,o),function(t,e){t.subscribe(bt.PERFORMANCE_ENTRY_COLLECTED,(function(e){if("longtask"===e.entryType){var n={date:J(e.startTime),longTask:{duration:q(e.duration)},type:Rt.LONG_TASK};t.notify(bt.RAW_RUM_EVENT_COLLECTED,{rawRumEvent:n,startTime:e.startTime})}}))}(n),_n(n,0,i),Mn(n,0,e);var s=Cn(n,r).addError;return{addAction:vn(n,r).addAction,addError:s,parentContexts:a,stop:function(){u.stop()}}}(t.applicationId,location,n,i,u,e),f=s.parentContexts,d=s.addError,l=s.addAction;return pn(n,i),Ee(n,i),Yt(n),{addAction:l,addError:d,getInternalContext:function(t,e,n){return{get:function(r){var i=n.findView(r);if(e.isTracked()&&i&&i.session.id){var o=n.findAction(r);return a(c({applicationId:t},{sessionId:i.session.id,view:i.view},o?{userAction:{id:o.action.id}}:void 0))}}}}(t.applicationId,u,f).get}}));jn=function(){if("object"==typeof globalThis)return globalThis;Object.defineProperty(Object.prototype,"_dd_temp_",{get:function(){return this},configurable:!0});var t=_dd_temp_;return delete Object.prototype._dd_temp_,"object"!=typeof t&&(t="object"==typeof self?self:"object"==typeof window?window:{}),t}(),Vn=zn,qn=jn[Fn="DD_RUM"],jn[Fn]=Vn,qn&&qn.q&&qn.q.forEach((function(t){return t()}))}]);

@@ -1,47 +0,14 @@

import { Context, UserConfiguration } from '@datadog/browser-core';
import { ProvidedSource } from '../domain/rumEventsCollection/error/errorCollection';
import { User } from '../rawRumEvent.types';
import { RumEvent } from '../rumEvent.types';
import { startRum } from './rum';
export interface RumUserConfiguration extends UserConfiguration {
applicationId: string;
beforeSend?: (event: RumEvent) => void;
}
export declare type RumGlobal = ReturnType<typeof makeRumGlobal>;
export declare const datadogRum: {
init: (userConfiguration: RumUserConfiguration) => void;
init: (userConfiguration: import("@datadog/browser-rum-core").RumUserConfiguration) => void;
addRumGlobalContext: (key: string, value: any) => void;
removeRumGlobalContext: (key: string) => void;
getRumGlobalContext: () => Context;
getRumGlobalContext: () => import("@datadog/browser-core").Context;
setRumGlobalContext: (newContext: object) => void;
getInternalContext: (startTime?: number | undefined) => import("../rawRumEvent.types").InternalContext | undefined;
getInternalContext: (startTime?: number | undefined) => import("@datadog/browser-rum-core/cjs/rawRumEvent.types").InternalContext | undefined;
addAction: (name: string, context?: object | undefined) => void;
/**
* @deprecated
* @see addAction
*/
addUserAction: (name: string, context?: object | undefined) => void;
addError: (error: unknown, context?: object | undefined, source?: ProvidedSource) => void;
setUser: (newUser: User) => void;
addError: (error: unknown, context?: object | undefined, source?: "custom" | "network" | "source" | undefined) => void;
setUser: (newUser: import("@datadog/browser-rum-core/cjs/rawRumEvent.types").User) => void;
} & {
onReady(callback: () => void): void;
};
export declare type StartRum = typeof startRum;
export declare function makeRumGlobal(startRumImpl: StartRum): {
init: (userConfiguration: RumUserConfiguration) => void;
addRumGlobalContext: (key: string, value: any) => void;
removeRumGlobalContext: (key: string) => void;
getRumGlobalContext: () => Context;
setRumGlobalContext: (newContext: object) => void;
getInternalContext: (startTime?: number | undefined) => import("../rawRumEvent.types").InternalContext | undefined;
addAction: (name: string, context?: object | undefined) => void;
/**
* @deprecated
* @see addAction
*/
addUserAction: (name: string, context?: object | undefined) => void;
addError: (error: unknown, context?: object | undefined, source?: ProvidedSource) => void;
setUser: (newUser: User) => void;
} & {
onReady(callback: () => void): void;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var browser_core_1 = require("@datadog/browser-core");
var trackActions_1 = require("../domain/rumEventsCollection/action/trackActions");
var rum_1 = require("./rum");
exports.datadogRum = makeRumGlobal(rum_1.startRum);
var browser_rum_core_1 = require("@datadog/browser-rum-core");
exports.datadogRum = browser_rum_core_1.makeRumPublicApi(browser_rum_core_1.startRum);
browser_core_1.defineGlobal(browser_core_1.getGlobalObject(), 'DD_RUM', exports.datadogRum);
function makeRumGlobal(startRumImpl) {
var isAlreadyInitialized = false;
var globalContextManager = browser_core_1.createContextManager();
var user = {};
var getInternalContextStrategy = function () {
return undefined;
};
var beforeInitAddAction = new browser_core_1.BoundedBuffer();
var addActionStrategy = function (action) {
beforeInitAddAction.add([action, clonedCommonContext()]);
};
var beforeInitAddError = new browser_core_1.BoundedBuffer();
var addErrorStrategy = function (providedError) {
beforeInitAddError.add([providedError, clonedCommonContext()]);
};
function clonedCommonContext() {
return browser_core_1.deepClone({
context: globalContextManager.get(),
user: user,
});
}
var rumGlobal = browser_core_1.makeGlobal({
init: browser_core_1.monitor(function (userConfiguration) {
var _a;
if (!browser_core_1.checkCookiesAuthorized(browser_core_1.buildCookieOptions(userConfiguration)) ||
!browser_core_1.checkIsNotLocalFile() ||
!canInitRum(userConfiguration)) {
return;
}
if (userConfiguration.publicApiKey) {
userConfiguration.clientToken = userConfiguration.publicApiKey;
}
;
(_a = startRumImpl(userConfiguration, function () { return ({
user: user,
context: globalContextManager.get(),
}); }), addActionStrategy = _a.addAction, addErrorStrategy = _a.addError, getInternalContextStrategy = _a.getInternalContext);
beforeInitAddAction.drain(function (_a) {
var action = _a[0], commonContext = _a[1];
return addActionStrategy(action, commonContext);
});
beforeInitAddError.drain(function (_a) {
var error = _a[0], commonContext = _a[1];
return addErrorStrategy(error, commonContext);
});
isAlreadyInitialized = true;
}),
addRumGlobalContext: browser_core_1.monitor(globalContextManager.add),
removeRumGlobalContext: browser_core_1.monitor(globalContextManager.remove),
getRumGlobalContext: browser_core_1.monitor(globalContextManager.get),
setRumGlobalContext: browser_core_1.monitor(globalContextManager.set),
getInternalContext: browser_core_1.monitor(function (startTime) {
return getInternalContextStrategy(startTime);
}),
addAction: browser_core_1.monitor(function (name, context) {
addActionStrategy({
name: name,
context: browser_core_1.deepClone(context),
startTime: performance.now(),
type: trackActions_1.ActionType.CUSTOM,
});
}),
/**
* @deprecated
* @see addAction
*/
addUserAction: function (name, context) {
rumGlobal.addAction(name, context);
},
addError: browser_core_1.monitor(function (error, context, source) {
if (source === void 0) { source = browser_core_1.ErrorSource.CUSTOM; }
var checkedSource;
if (source === browser_core_1.ErrorSource.CUSTOM || source === browser_core_1.ErrorSource.NETWORK || source === browser_core_1.ErrorSource.SOURCE) {
checkedSource = source;
}
else {
console.error("DD_RUM.addError: Invalid source '" + source + "'");
checkedSource = browser_core_1.ErrorSource.CUSTOM;
}
addErrorStrategy({
error: error,
context: browser_core_1.deepClone(context),
source: checkedSource,
startTime: performance.now(),
});
}),
setUser: browser_core_1.monitor(function (newUser) {
var sanitizedUser = sanitizeUser(newUser);
if (sanitizedUser) {
user = sanitizedUser;
}
else {
console.error('Unsupported user:', newUser);
}
}),
});
return rumGlobal;
function sanitizeUser(newUser) {
if (typeof newUser !== 'object' || !newUser) {
return;
}
var result = browser_core_1.deepClone(newUser);
if ('id' in result) {
result.id = String(result.id);
}
if ('name' in result) {
result.name = String(result.name);
}
if ('email' in result) {
result.email = String(result.email);
}
return result;
}
function canInitRum(userConfiguration) {
if (isAlreadyInitialized) {
if (!userConfiguration.silentMultipleInit) {
console.error('DD_RUM is already initialized.');
}
return false;
}
if (!userConfiguration || (!userConfiguration.clientToken && !userConfiguration.publicApiKey)) {
console.error('Client Token is not configured, we will not send any data.');
return false;
}
if (!userConfiguration.applicationId) {
console.error('Application ID is not configured, no RUM data will be collected.');
return false;
}
if (userConfiguration.sampleRate !== undefined && !browser_core_1.isPercentage(userConfiguration.sampleRate)) {
console.error('Sample Rate should be a number between 0 and 100');
return false;
}
if (userConfiguration.resourceSampleRate !== undefined && !browser_core_1.isPercentage(userConfiguration.resourceSampleRate)) {
console.error('Resource Sample Rate should be a number between 0 and 100');
return false;
}
if (Array.isArray(userConfiguration.allowedTracingOrigins) &&
userConfiguration.allowedTracingOrigins.length !== 0 &&
userConfiguration.service === undefined) {
console.error('Service need to be configured when tracing is enabled');
return false;
}
return true;
}
}
exports.makeRumGlobal = makeRumGlobal;
//# sourceMappingURL=rum.entry.js.map

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

export { RumUserConfiguration, RumGlobal, datadogRum } from './boot/rum.entry';
export { ProvidedSource } from './domain/rumEventsCollection/error/errorCollection';
export { RumEvent, RumActionEvent, CommonProperties, RumErrorEvent, RumViewEvent, RumResourceEvent, RumLongTaskEvent, } from './rumEvent.types';
export { datadogRum } from './boot/rum.entry';
export { CommonProperties, ProvidedSource, RumPublicApi as RumGlobal, RumUserConfiguration, RumEvent, RumActionEvent, RumErrorEvent, RumLongTaskEvent, RumResourceEvent, RumViewEvent, } from '@datadog/browser-rum-core';

@@ -1,47 +0,14 @@

import { Context, UserConfiguration } from '@datadog/browser-core';
import { ProvidedSource } from '../domain/rumEventsCollection/error/errorCollection';
import { User } from '../rawRumEvent.types';
import { RumEvent } from '../rumEvent.types';
import { startRum } from './rum';
export interface RumUserConfiguration extends UserConfiguration {
applicationId: string;
beforeSend?: (event: RumEvent) => void;
}
export declare type RumGlobal = ReturnType<typeof makeRumGlobal>;
export declare const datadogRum: {
init: (userConfiguration: RumUserConfiguration) => void;
init: (userConfiguration: import("@datadog/browser-rum-core").RumUserConfiguration) => void;
addRumGlobalContext: (key: string, value: any) => void;
removeRumGlobalContext: (key: string) => void;
getRumGlobalContext: () => Context;
getRumGlobalContext: () => import("@datadog/browser-core").Context;
setRumGlobalContext: (newContext: object) => void;
getInternalContext: (startTime?: number | undefined) => import("../rawRumEvent.types").InternalContext | undefined;
getInternalContext: (startTime?: number | undefined) => import("@datadog/browser-rum-core/cjs/rawRumEvent.types").InternalContext | undefined;
addAction: (name: string, context?: object | undefined) => void;
/**
* @deprecated
* @see addAction
*/
addUserAction: (name: string, context?: object | undefined) => void;
addError: (error: unknown, context?: object | undefined, source?: ProvidedSource) => void;
setUser: (newUser: User) => void;
addError: (error: unknown, context?: object | undefined, source?: "custom" | "network" | "source" | undefined) => void;
setUser: (newUser: import("@datadog/browser-rum-core/cjs/rawRumEvent.types").User) => void;
} & {
onReady(callback: () => void): void;
};
export declare type StartRum = typeof startRum;
export declare function makeRumGlobal(startRumImpl: StartRum): {
init: (userConfiguration: RumUserConfiguration) => void;
addRumGlobalContext: (key: string, value: any) => void;
removeRumGlobalContext: (key: string) => void;
getRumGlobalContext: () => Context;
setRumGlobalContext: (newContext: object) => void;
getInternalContext: (startTime?: number | undefined) => import("../rawRumEvent.types").InternalContext | undefined;
addAction: (name: string, context?: object | undefined) => void;
/**
* @deprecated
* @see addAction
*/
addUserAction: (name: string, context?: object | undefined) => void;
addError: (error: unknown, context?: object | undefined, source?: ProvidedSource) => void;
setUser: (newUser: User) => void;
} & {
onReady(callback: () => void): void;
};

@@ -1,151 +0,5 @@

import { BoundedBuffer, buildCookieOptions, checkCookiesAuthorized, checkIsNotLocalFile, createContextManager, deepClone, defineGlobal, ErrorSource, getGlobalObject, isPercentage, makeGlobal, monitor, } from '@datadog/browser-core';
import { ActionType } from '../domain/rumEventsCollection/action/trackActions';
import { startRum } from './rum';
export var datadogRum = makeRumGlobal(startRum);
import { defineGlobal, getGlobalObject } from '@datadog/browser-core';
import { makeRumPublicApi, startRum } from '@datadog/browser-rum-core';
export var datadogRum = makeRumPublicApi(startRum);
defineGlobal(getGlobalObject(), 'DD_RUM', datadogRum);
export function makeRumGlobal(startRumImpl) {
var isAlreadyInitialized = false;
var globalContextManager = createContextManager();
var user = {};
var getInternalContextStrategy = function () {
return undefined;
};
var beforeInitAddAction = new BoundedBuffer();
var addActionStrategy = function (action) {
beforeInitAddAction.add([action, clonedCommonContext()]);
};
var beforeInitAddError = new BoundedBuffer();
var addErrorStrategy = function (providedError) {
beforeInitAddError.add([providedError, clonedCommonContext()]);
};
function clonedCommonContext() {
return deepClone({
context: globalContextManager.get(),
user: user,
});
}
var rumGlobal = makeGlobal({
init: monitor(function (userConfiguration) {
var _a;
if (!checkCookiesAuthorized(buildCookieOptions(userConfiguration)) ||
!checkIsNotLocalFile() ||
!canInitRum(userConfiguration)) {
return;
}
if (userConfiguration.publicApiKey) {
userConfiguration.clientToken = userConfiguration.publicApiKey;
}
;
(_a = startRumImpl(userConfiguration, function () { return ({
user: user,
context: globalContextManager.get(),
}); }), addActionStrategy = _a.addAction, addErrorStrategy = _a.addError, getInternalContextStrategy = _a.getInternalContext);
beforeInitAddAction.drain(function (_a) {
var action = _a[0], commonContext = _a[1];
return addActionStrategy(action, commonContext);
});
beforeInitAddError.drain(function (_a) {
var error = _a[0], commonContext = _a[1];
return addErrorStrategy(error, commonContext);
});
isAlreadyInitialized = true;
}),
addRumGlobalContext: monitor(globalContextManager.add),
removeRumGlobalContext: monitor(globalContextManager.remove),
getRumGlobalContext: monitor(globalContextManager.get),
setRumGlobalContext: monitor(globalContextManager.set),
getInternalContext: monitor(function (startTime) {
return getInternalContextStrategy(startTime);
}),
addAction: monitor(function (name, context) {
addActionStrategy({
name: name,
context: deepClone(context),
startTime: performance.now(),
type: ActionType.CUSTOM,
});
}),
/**
* @deprecated
* @see addAction
*/
addUserAction: function (name, context) {
rumGlobal.addAction(name, context);
},
addError: monitor(function (error, context, source) {
if (source === void 0) { source = ErrorSource.CUSTOM; }
var checkedSource;
if (source === ErrorSource.CUSTOM || source === ErrorSource.NETWORK || source === ErrorSource.SOURCE) {
checkedSource = source;
}
else {
console.error("DD_RUM.addError: Invalid source '" + source + "'");
checkedSource = ErrorSource.CUSTOM;
}
addErrorStrategy({
error: error,
context: deepClone(context),
source: checkedSource,
startTime: performance.now(),
});
}),
setUser: monitor(function (newUser) {
var sanitizedUser = sanitizeUser(newUser);
if (sanitizedUser) {
user = sanitizedUser;
}
else {
console.error('Unsupported user:', newUser);
}
}),
});
return rumGlobal;
function sanitizeUser(newUser) {
if (typeof newUser !== 'object' || !newUser) {
return;
}
var result = deepClone(newUser);
if ('id' in result) {
result.id = String(result.id);
}
if ('name' in result) {
result.name = String(result.name);
}
if ('email' in result) {
result.email = String(result.email);
}
return result;
}
function canInitRum(userConfiguration) {
if (isAlreadyInitialized) {
if (!userConfiguration.silentMultipleInit) {
console.error('DD_RUM is already initialized.');
}
return false;
}
if (!userConfiguration || (!userConfiguration.clientToken && !userConfiguration.publicApiKey)) {
console.error('Client Token is not configured, we will not send any data.');
return false;
}
if (!userConfiguration.applicationId) {
console.error('Application ID is not configured, no RUM data will be collected.');
return false;
}
if (userConfiguration.sampleRate !== undefined && !isPercentage(userConfiguration.sampleRate)) {
console.error('Sample Rate should be a number between 0 and 100');
return false;
}
if (userConfiguration.resourceSampleRate !== undefined && !isPercentage(userConfiguration.resourceSampleRate)) {
console.error('Resource Sample Rate should be a number between 0 and 100');
return false;
}
if (Array.isArray(userConfiguration.allowedTracingOrigins) &&
userConfiguration.allowedTracingOrigins.length !== 0 &&
userConfiguration.service === undefined) {
console.error('Service need to be configured when tracing is enabled');
return false;
}
return true;
}
}
//# sourceMappingURL=rum.entry.js.map

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

export { RumUserConfiguration, RumGlobal, datadogRum } from './boot/rum.entry';
export { ProvidedSource } from './domain/rumEventsCollection/error/errorCollection';
export { RumEvent, RumActionEvent, CommonProperties, RumErrorEvent, RumViewEvent, RumResourceEvent, RumLongTaskEvent, } from './rumEvent.types';
export { datadogRum } from './boot/rum.entry';
export { CommonProperties, ProvidedSource, RumPublicApi as RumGlobal, RumUserConfiguration, RumEvent, RumActionEvent, RumErrorEvent, RumLongTaskEvent, RumResourceEvent, RumViewEvent, } from '@datadog/browser-rum-core';
{
"name": "@datadog/browser-rum",
"version": "2.1.2",
"version": "2.2.0",
"license": "Apache-2.0",

@@ -10,14 +10,11 @@ "main": "cjs/index.js",

"build": "run-p build:cjs build:esm build:bundle",
"build:bundle": "rm -rf bundle && webpack --config webpack.config.js --mode=production && yarn replace-build-env bundle",
"build:cjs": "rm -rf cjs && tsc -p tsconfig.cjs.json && yarn replace-build-env cjs",
"build:esm": "rm -rf esm && tsc -p tsconfig.esm.json && yarn replace-build-env esm",
"replace-build-env": "node ../../scripts/replace-build-env.js"
"build:bundle": "rm -rf bundle && webpack --mode=production",
"build:cjs": "rm -rf cjs && tsc -p tsconfig.cjs.json",
"build:esm": "rm -rf esm && tsc -p tsconfig.esm.json"
},
"dependencies": {
"@datadog/browser-core": "2.1.2",
"@datadog/browser-core": "2.2.0",
"@datadog/browser-rum-core": "2.2.0",
"tslib": "^1.10.0"
},
"devDependencies": {
"ajv": "6.12.6"
},
"repository": {

@@ -28,3 +25,3 @@ "type": "git",

},
"gitHead": "6c5a255d8ec1cd4562de2f74e42b74ac22702dee"
"gitHead": "8cb2ec883174f7194f62d2c66e0ba42152619b63"
}

@@ -1,198 +0,9 @@

import {
BoundedBuffer,
buildCookieOptions,
checkCookiesAuthorized,
checkIsNotLocalFile,
Context,
createContextManager,
deepClone,
defineGlobal,
ErrorSource,
getGlobalObject,
isPercentage,
makeGlobal,
monitor,
UserConfiguration,
} from '@datadog/browser-core'
import { ActionType, CustomAction } from '../domain/rumEventsCollection/action/trackActions'
import { ProvidedError, ProvidedSource } from '../domain/rumEventsCollection/error/errorCollection'
import { CommonContext, User } from '../rawRumEvent.types'
import { RumEvent } from '../rumEvent.types'
import { startRum } from './rum'
import { defineGlobal, getGlobalObject } from '@datadog/browser-core'
import { makeRumPublicApi, RumPublicApi, startRum } from '@datadog/browser-rum-core'
export interface RumUserConfiguration extends UserConfiguration {
applicationId: string
beforeSend?: (event: RumEvent) => void
}
export const datadogRum = makeRumPublicApi(startRum)
export type RumGlobal = ReturnType<typeof makeRumGlobal>
export const datadogRum = makeRumGlobal(startRum)
interface BrowserWindow extends Window {
DD_RUM?: RumGlobal
DD_RUM?: RumPublicApi
}
defineGlobal(getGlobalObject<BrowserWindow>(), 'DD_RUM', datadogRum)
export type StartRum = typeof startRum
export function makeRumGlobal(startRumImpl: StartRum) {
let isAlreadyInitialized = false
const globalContextManager = createContextManager()
let user: User = {}
let getInternalContextStrategy: ReturnType<StartRum>['getInternalContext'] = () => {
return undefined
}
const beforeInitAddAction = new BoundedBuffer<[CustomAction, CommonContext]>()
let addActionStrategy: ReturnType<StartRum>['addAction'] = (action) => {
beforeInitAddAction.add([action, clonedCommonContext()])
}
const beforeInitAddError = new BoundedBuffer<[ProvidedError, CommonContext]>()
let addErrorStrategy: ReturnType<StartRum>['addError'] = (providedError) => {
beforeInitAddError.add([providedError, clonedCommonContext()])
}
function clonedCommonContext(): CommonContext {
return deepClone({
context: globalContextManager.get(),
user: user as Context,
})
}
const rumGlobal = makeGlobal({
init: monitor((userConfiguration: RumUserConfiguration) => {
if (
!checkCookiesAuthorized(buildCookieOptions(userConfiguration)) ||
!checkIsNotLocalFile() ||
!canInitRum(userConfiguration)
) {
return
}
if (userConfiguration.publicApiKey) {
userConfiguration.clientToken = userConfiguration.publicApiKey
}
;({
addAction: addActionStrategy,
addError: addErrorStrategy,
getInternalContext: getInternalContextStrategy,
} = startRumImpl(userConfiguration, () => ({
user,
context: globalContextManager.get(),
})))
beforeInitAddAction.drain(([action, commonContext]) => addActionStrategy(action, commonContext))
beforeInitAddError.drain(([error, commonContext]) => addErrorStrategy(error, commonContext))
isAlreadyInitialized = true
}),
addRumGlobalContext: monitor(globalContextManager.add),
removeRumGlobalContext: monitor(globalContextManager.remove),
getRumGlobalContext: monitor(globalContextManager.get),
setRumGlobalContext: monitor(globalContextManager.set),
getInternalContext: monitor((startTime?: number) => {
return getInternalContextStrategy(startTime)
}),
addAction: monitor((name: string, context?: object) => {
addActionStrategy({
name,
context: deepClone(context as Context),
startTime: performance.now(),
type: ActionType.CUSTOM,
})
}),
/**
* @deprecated
* @see addAction
*/
addUserAction: (name: string, context?: object) => {
rumGlobal.addAction(name, context as Context)
},
addError: monitor((error: unknown, context?: object, source: ProvidedSource = ErrorSource.CUSTOM) => {
let checkedSource: ProvidedSource
if (source === ErrorSource.CUSTOM || source === ErrorSource.NETWORK || source === ErrorSource.SOURCE) {
checkedSource = source
} else {
console.error(`DD_RUM.addError: Invalid source '${source}'`)
checkedSource = ErrorSource.CUSTOM
}
addErrorStrategy({
error,
context: deepClone(context as Context),
source: checkedSource,
startTime: performance.now(),
})
}),
setUser: monitor((newUser: User) => {
const sanitizedUser = sanitizeUser(newUser)
if (sanitizedUser) {
user = sanitizedUser
} else {
console.error('Unsupported user:', newUser)
}
}),
})
return rumGlobal
function sanitizeUser(newUser: unknown) {
if (typeof newUser !== 'object' || !newUser) {
return
}
const result = deepClone(newUser as Context)
if ('id' in result) {
result.id = String(result.id)
}
if ('name' in result) {
result.name = String(result.name)
}
if ('email' in result) {
result.email = String(result.email)
}
return result
}
function canInitRum(userConfiguration: RumUserConfiguration) {
if (isAlreadyInitialized) {
if (!userConfiguration.silentMultipleInit) {
console.error('DD_RUM is already initialized.')
}
return false
}
if (!userConfiguration || (!userConfiguration.clientToken && !userConfiguration.publicApiKey)) {
console.error('Client Token is not configured, we will not send any data.')
return false
}
if (!userConfiguration.applicationId) {
console.error('Application ID is not configured, no RUM data will be collected.')
return false
}
if (userConfiguration.sampleRate !== undefined && !isPercentage(userConfiguration.sampleRate)) {
console.error('Sample Rate should be a number between 0 and 100')
return false
}
if (userConfiguration.resourceSampleRate !== undefined && !isPercentage(userConfiguration.resourceSampleRate)) {
console.error('Resource Sample Rate should be a number between 0 and 100')
return false
}
if (
Array.isArray(userConfiguration.allowedTracingOrigins) &&
userConfiguration.allowedTracingOrigins.length !== 0 &&
userConfiguration.service === undefined
) {
console.error('Service need to be configured when tracing is enabled')
return false
}
return true
}
}

@@ -1,11 +0,14 @@

export { RumUserConfiguration, RumGlobal, datadogRum } from './boot/rum.entry'
export { ProvidedSource } from './domain/rumEventsCollection/error/errorCollection'
export { datadogRum } from './boot/rum.entry'
export {
CommonProperties,
ProvidedSource,
RumPublicApi as RumGlobal,
RumUserConfiguration,
// Events
RumEvent,
RumActionEvent,
CommonProperties,
RumErrorEvent,
RumLongTaskEvent,
RumResourceEvent,
RumViewEvent,
RumResourceEvent,
RumLongTaskEvent,
} from './rumEvent.types'
} from '@datadog/browser-rum-core'

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