@datadog/browser-rum
Advanced tools
Comparing version 1.26.3 to 2.0.0
@@ -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 $n})),n.d(e,"makeRumGlobal",(function(){return Xn}));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,s=function(t){return Array.isArray(t)},c=function(t){return!Array.isArray(t)&&"object"==typeof t&&null!==t};function f(){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=p(t,o,l()))}return t}function d(t){return p(void 0,t,l())}function l(){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 p(t,e,n){if(void 0===e)return t;if(!c(e)&&!s(e))return e;if(!n.hasAlreadyBeenSeen(e)){if(c(e)&&(void 0===t||c(t))){var r=t||{};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=p(r[i],e[i],n));return r}if(s(e)&&(void 0===t||s(t))){(r=t||[]).length=Math.max(r.length,e.length);for(var o=0;o<e.length;o+=1)r[o]=p(r[o],e[o],n);return r}return e}}function m(t,e,n){return t&&(void 0!==t.message||e instanceof Error)?{message:t.message||"Empty message",stack:E(t),type:t.name}:{message:n+" "+K(e),stack:"No stack, consider using an instance of Error",type:t&&t.name}}function E(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}!function(t){t.AGENT="agent",t.CONSOLE="console",t.NETWORK="network",t.SOURCE="source",t.LOGGER="logger",t.CUSTOM="custom"}(u||(u={}));var v=/[^\u0000-\u007F]/,T=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 h=function(){function t(t,e,n,r,i,o){void 0===o&&(o=q),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 v.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=K(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&&(nt(window,x.BEFORE_UNLOAD,this.beforeUnloadCallback),nt(document,x.VISIBILITY_CHANGE,(function(){"hidden"===document.visibilityState&&t.flush()})),nt(window,x.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,_=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:d,stack:[c]},!0)}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){if(t.stack){for(var e,n,r,i,o=/^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,a=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i,u=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,s=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,c=/\((\S*)(?::(\d+))(?::(\d+))\)/,f=t.stack.split("\n"),d=[],l=0,p=f.length;l<p;l+=1){if(o.exec(f[l])){var m=(r=o.exec(f[l]))[2]&&0===r[2].indexOf("native");e=r[2]&&0===r[2].indexOf("eval"),n=c.exec(r[2]),e&&n&&(r[2]=n[1],r[3]=n[2],r[4]=n[3]),i={args:m?[r[2]]:[],column:r[4]?+r[4]:void 0,func:r[1]||g,line:r[3]?+r[3]:void 0,url:m?void 0:r[2]}}else if(u.exec(f[l]))i={args:[],column:(r=u.exec(f[l]))[4]?+r[4]:void 0,func:r[1]||g,line:+r[3],url:r[2]};else{if(!a.exec(f[l]))continue;e=(r=a.exec(f[l]))[3]&&r[3].indexOf(" > eval")>-1,n=s.exec(r[3]),e&&n?(r[3]=n[1],r[4]=n[2],r[5]=void 0):0!==l||r[5]||void 0===t.columnNumber||(d[0].column=t.columnNumber+1),i={args:r[2]?r[2].split(","):[],column:r[5]?+r[5]:void 0,func:r[1]||g,line:r[4]?+r[4]:void 0,url:r[3]}}!i.func&&i.line&&(i.func=g),d.push(i)}if(d.length)return{stack:d,message:t.message,name: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,o,a=/function\s+([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)?\s*\(/i,u=[],s={},c=!1,f=r.caller;f&&!c;f=f.caller)f!==R&&f!==_&&(o={args:[],column:void 0,func:g,line:void 0,url:void 0},i=a.exec(f.toString()),f.name?o.func=f.name:i&&(o.func=i[1]),void 0===o.func&&(o.func=i?i.input.substring(0,i.input.indexOf("{")):void 0),s[""+f]?c=!0:s[""+f]=!0,u.push(o));e&&u.splice(0,e);var d={stack:u,message:t.message,name:t.name};return n(d,t.sourceURL||t.fileName,t.line||t.lineNumber,t.message||t.description),d}function i(n,i){var o,a=void 0===i?0:+i;try{if(o=function(t){var e=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,o=e.split("\n"),a=[],u=0;u<o.length;u+=2){var s=void 0;r.exec(o[u])?s={args:[],column:void 0,func:(n=r.exec(o[u]))[3],line:+n[1],url:n[2]}:i.exec(o[u])&&(s={args:(n=i.exec(o[u]))[5]?n[5].split(","):[],column:+n[2],func:n[3]||n[4],line:+n[1],url:n[6]}),s&&(!s.func&&s.line&&(s.func=g),s.context=[o[u+1]],a.push(s))}if(a.length)return{stack:a,message:t.message,name:t.name}}}(n))return o}catch(e){if(t)throw e}try{if(o=e(n))return o}catch(e){if(t)throw e}try{if(o=function(t){var e=t.message.split("\n");if(!(e.length<4)){var n,r=/^\s*Line (\d+) of linked script ((?:file|https?|blob)\S+)(?:: in function (\S+))?\s*$/i,i=/^\s*Line (\d+) of inline#(\d+) script in ((?:file|https?|blob)\S+)(?:: in function (\S+))?\s*$/i,o=/^\s*Line (\d+) of function script\s*$/i,a=[],u=window&&window.document&&window.document.getElementsByTagName("script"),s=[];for(var c in u)b(u,c)&&!u[c].src&&s.push(u[c]);for(var f=2;f<e.length;f+=2){var d=void 0;if(r.exec(e[f]))d={args:[],column:void 0,func:(n=r.exec(e[f]))[3],line:+n[1],url:n[2]};else if(i.exec(e[f]))d={args:[],column:void 0,func:(n=i.exec(e[f]))[4],line:+n[1],url:n[3]};else if(o.exec(e[f])){n=o.exec(e[f]),d={url:window.location.href.replace(/#.*$/,""),args:[],column:void 0,func:"",line:+n[1]}}d&&(d.func||(d.func=g),d.context=[e[f+1]],a.push(d))}if(a.length)return{stack:a,message:e[0],name:t.name}}}(n))return o}catch(e){if(t)throw e}try{if(o=r(n,a+1))return o}catch(e){if(t)throw e}return{message:n.message,name:n.name,stack:[]}}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 O,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 h(new T(e,t.batchBytesLimit),t.maxBatchSize,t.batchBytesLimit,t.maxMessageSize,t.flushTimeout)}return{add:function(t){var r=function(t){return f({date:(new Date).getTime(),view:{referrer:document.referrer,url:window.location.href}},void 0!==O?O():{},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])}))}(S,{batch:e,maxMessagesPerPage:t.maxInternalMonitoringMessagesPerPage,sentMessageCount:0})}return{setExternalContextProvider:function(t){O=t}}}function A(t){return function(){try{return t.apply(this,arguments)}catch(t){U(t);try{N(t)}catch(t){U(t)}}}}function I(t,e){!function(t){S.debugMode&&console.log("[MONITORING MESSAGE]",t)}(t),L(r(r({message:t},e),{status:C.info}))}function N(t){L(r(r({},function(t){if(t instanceof Error){var e=R(t);return{error:{kind:e.name,stack:E(e)},message:e.message}}return{error:{stack:"Not an instance of error"},message:"Uncaught "+K(t)}}(t)),{status:C.error}))}function L(t){S.batch&&S.sentMessageCount<S.maxMessagesPerPage&&(S.sentMessageCount+=1,S.batch.add(t))}function D(t){S.debugMode=t}function U(t){S.debugMode&&console.warn("[INTERNAL ERROR]",t)}var x,M,k,V,P=1e3,B=60*P,W=60*B;function H(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 j(t){return t?(parseInt(t,10)^16*Math.random()>>parseInt(t,10)/4).toString(16):(1e7+"-1000-4000-8000-100000000000").replace(/[018]/g,j)}function G(t){return 0!==t&&100*Math.random()<=t}function F(t){return"number"!=typeof t?t:+(1e6*t).toFixed(0)}function q(){}function K(t,e,n){if(null==t)return JSON.stringify(t);var r=[!1,void 0];z(t)&&(r=[!0,t.toJSON],delete t.toJSON);var i,o,a=[!1,void 0];"object"==typeof t&&z(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 z(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===V&&(V=performance.timing.navigationStart),V}function Z(t){return Object.keys(t).map((function(e){return[e,t[e]]}))}function tt(t){if(t.origin)return t.origin;var e=t.host.replace(/(:80|:443)$/,"");return t.protocol+"//"+e}function et(t,e){var n=t.match("(?:^|;)\\s*"+e+"\\s*=\\s*([^;]+)");return n?n[1]:void 0}function nt(t,e,n,r){return rt(t,[e],n,r)}function rt(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"}(x||(x={})),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"}(M||(M={})),function(t){t.FETCH="fetch",t.XHR="xhr"}(k||(k={}));var it,ot=P;function at(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 ut(t){return et(document.cookie,t)}var st,ct,ft={allowedTracingOrigins:[],maxErrorsByMinute:3e3,maxInternalMonitoringMessagesPerPage:15,resourceSampleRate:100,sampleRate:100,silentMultipleInit:!1,trackInteractions:!1,requestErrorResponseLengthLimit:32768,flushTimeout:30*P,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===vt.STAGING&&n&&r.push(Tt[ct.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://"+Et(t,d,s)+"/v1/input/")}return i}(o,n,void 0!==t.replica),u=r({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===vt.E2E_TEST&&(u.internalMonitoringEndpoint="<<< E2E INTERNAL MONITORING ENDPOINT >>>",u.logsEndpoint="<<< E2E LOGS ENDPOINT >>>",u.rumEndpoint="<<< E2E RUM ENDPOINT >>>"),n.buildMode===vt.STAGING&&void 0!==t.replica){var s=r(r({},n),{applicationId:t.replica.applicationId,clientToken:t.replica.clientToken,site:Tt[ct.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===it){for(var t="dd_site_test_"+j(),e=window.location.hostname.split("."),n=e.pop();e.length&&!ut(t);)n=e.pop()+"."+n,at(t,"test",P,{domain:n});it=n}return it}()),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=Et(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 Et(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)}!function(t){t.US="us",t.EU="eu"}(ct||(ct={}));var vt,Tt=((st={})[ct.EU]="datadoghq.eu",st[ct.US]="datadoghq.com",st);function ht(t){return!!function(t){if(void 0===document.cookie||null===document.cookie)return!1;try{var e="dd_cookie_test_"+j();return at(e,"test",P,t),"test"===ut(e)}catch(t){return console.error(t),!1}}(t)||(console.warn("Cookies are not authorized, we will not send any data."),!1)}function gt(){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"}(vt||(vt={}));var yt,bt=1e4,Ct=function(){function t(t){void 0===t&&(t=bt),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.RAW_RUM_EVENT_V2_COLLECTED=12]="RAW_RUM_EVENT_V2_COLLECTED",t[t.RUM_EVENT_COLLECTED=13]="RUM_EVENT_COLLECTED",t[t.RUM_EVENT_V2_COLLECTED=14]="RUM_EVENT_V2_COLLECTED"}(yt||(yt={}));var _t,Rt,Ot=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 St(t,e){void 0===e&&(e=q);var n={errorCount:0,longTaskCount:0,resourceCount:0,userActionCount:0},r=t.subscribe(yt.RAW_RUM_EVENT_COLLECTED,(function(t){switch(t.rawRumEvent.evt.category){case _t.ERROR:n.errorCount+=1,e(n);break;case _t.USER_ACTION:n.userActionCount+=1,e(n);break;case _t.LONG_TASK:n.longTaskCount+=1,e(n);break;case _t.RESOURCE:n.resourceCount+=1,e(n)}})),i=t.subscribe(yt.RAW_RUM_EVENT_V2_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(),i.unsubscribe()},eventCounts:n}}!function(t){t.USER_ACTION="user_action",t.ERROR="error",t.LONG_TASK="long_task",t.VIEW="view",t.RESOURCE="resource"}(_t||(_t={})),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 Lt(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(yt.DOM_MUTATED,(function(){return o()}))),r.push(t.subscribe(yt.PERFORMANCE_ENTRY_COLLECTED,(function(t){"resource"===t.entryType&&o()}))),r.push(t.subscribe(yt.REQUEST_STARTED,(function(t){void 0===e&&(e=t.requestIndex),i+=1,o()}))),r.push(t.subscribe(yt.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 Dt(t){return function(t){var e;if(function(){void 0===kt&&(kt="closest"in HTMLElement.prototype);return kt}())e=t.closest("["+Ut+"]");else for(var n=t;n;){if(n.hasAttribute(Ut)){e=n;break}n=n.parentElement}if(!e)return;return Gt(jt(e.getAttribute(Ut).trim()))}(t)||Ht(t,Pt)||Ht(t,Bt)||""}var Ut="data-dd-action-name";var xt,Mt,kt,Vt,Pt=[function(t){if(function(){void 0===Mt&&(Mt="labels"in HTMLInputElement.prototype);return Mt}()){if("labels"in t&&t.labels&&t.labels.length>0)return Ft(t.labels[0])}else if(t.id){var e=t.ownerDocument&&t.ownerDocument.querySelector('label[for="'+t.id.replace('"','\\"')+'"]');return e&&Ft(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 Ft(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(Ft).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 Ft(t.options[0])}],Bt=[function(t){return Ft(t)}],Wt=10;function Ht(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 Gt(jt(u))}}if("FORM"===n.nodeName)break;n=n.parentElement,r+=1}}function jt(t){return t.replace(/\s+/g," ")}function Gt(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 Ft(t){if(!t.isContentEditable){if("innerText"in t){var e=t.innerText;if(!function(){if(void 0===xt){var t=document.createElement("style");t.textContent="*";var e=document.createElement("div");e.appendChild(t),document.body.appendChild(e),xt=""===e.innerText,document.body.removeChild(e)}return xt}())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 qt(t){var e=function(t){var e,n;return{create:function(r,i){if(!e){var o=new zt(t,r,i);e=o,n=Lt(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(yt.VIEW_CREATED,(function(){e.discardCurrent()}));var n=nt(window,x.CLICK,(function(t){if(t.target instanceof Element){var n=Dt(t.target);n&&e.create(Vt.CLICK,n)}}),{capture:!0}).stop;return{stop:function(){e.discardCurrent(),n()}}}!function(t){t.CLICK="click",t.CUSTOM="custom"}(Vt||(Vt={}));var Kt,zt=function(){function t(t,e,n){this.lifeCycle=t,this.type=e,this.name=n,this.id=j(),this.startTime=performance.now(),this.eventCountsSubscription=St(t),this.lifeCycle.notify(yt.AUTO_ACTION_CREATED,{id:this.id,startTime:this.startTime})}return t.prototype.complete=function(t){var e=this.eventCountsSubscription.eventCounts;this.lifeCycle.notify(yt.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(yt.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(yt.DOM_MUTATED)})))).observe(document.documentElement,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),{stop:function(){e&&e.disconnect()}}}function $t(t){return Jt(t,tt(window.location)).href}function Xt(t){return tt(Jt(t))}function Jt(t,e){if(function(){if(void 0!==Kt)return Kt;try{var t=new URL("http://test/path");return Kt="http://test/path"===t.href}catch(t){Kt=!1}return Kt}())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=[[M.DOCUMENT,function(t){return Qt===t}],[M.XHR,function(t){return"xmlhttprequest"===t}],[M.FETCH,function(t){return"fetch"===t}],[M.BEACON,function(t){return"beacon"===t}],[M.CSS,function(t,e){return null!==e.match(/\.css$/i)}],[M.JS,function(t,e){return null!==e.match(/\.js$/i)}],[M.IMAGE,function(t,e){return Y(["image","img","icon"],t)||null!==e.match(/\.(gif|jpg|jpeg|tiff|png|svg|ico)$/i)}],[M.FONT,function(t,e){return null!==e.match(/\.(woff|eot|woff2|ttf)$/i)}],[M.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+'"'),M.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 M.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=t.duration,n=t.startTime,r=t.responseEnd;return F(0===e&&n<r?r-n:e)}function re(t){var e=ie(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:ae(n,l,e.responseEnd),firstByte:ae(n,d,l)};return f!==r&&(p.connect=ae(n,s,f),ee(s,c,f)&&(p.ssl=ae(n,c,f))),u!==r&&(p.dns=ae(n,a,u)),oe(t)&&(p.redirect=ae(n,i,o)),p}}function ie(t){if(ee(t.startTime,t.fetchStart,t.domainLookupStart,t.domainLookupEnd,t.connectStart,t.connectEnd,t.requestStart,t.responseStart,t.responseEnd)){if(!oe(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 oe(t){return t.fetchStart!==t.startTime}function ae(t,e,n){return{duration:F(n-e),start:F(e-t)}}function ue(t){if(t.startTime<t.responseStart)return t.decodedBodySize}function se(t,e){return e&&!t.isIntakeUrl(e)}var ce,fe,de=2*B;function le(t){var e=function(t){var e=t.querySelector("meta[name=dd-trace-id]"),n=t.querySelector("meta[name=dd-trace-time]");return pe(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=me(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=me(r))return n;if(!Ee(r))break}}(t);if(!e)return;return pe(et(e,"trace-id"),et(e,"trace-time"))}(t);if(e&&!(e.traceTime<=Date.now()-de))return e.traceId}function pe(t,e){var n=e&&Number(e);if(t&&n)return{traceId:t,traceTime:n}}function me(t){if(t&&function(t){return"#comment"===t.nodeName}(t)){var e=t.data.match(/^\s*DATADOG;(.*?)\s*$/);if(e)return e[1]}}function Ee(t){return"#text"===t.nodeName}function ve(){return void 0!==window.performance&&"getEntries"in performance}function Te(t){return window.PerformanceObserver&&void 0!==PerformanceObserver.supportedEntryTypes&&PerformanceObserver.supportedEntryTypes.includes(t)}function he(t,e){var n;if(n=function(n){Ce(t,e,n)},ge("interactive",(function(){var t,e={entryType:"resource",initiatorType:Qt,traceId:le(document)};if(Te("navigation")&&performance.getEntriesByType("navigation").length>0){var i=performance.getEntriesByType("navigation")[0];t=r(r({},i.toJSON()),e)}else{var o=ye();t=r(r(r({},o),{decodedBodySize:0,duration:o.responseEnd,name:window.location.href,startTime:0}),e)}n(t)})),ve()&&be(t,e,performance.getEntries()),window.PerformanceObserver){new PerformanceObserver(A((function(n){return be(t,e,n.getEntries())}))).observe({entryTypes:["resource","navigation","longtask","paint","largest-contentful-paint","first-input","layout-shift"]}),ve()&&"addEventListener"in performance&&performance.addEventListener("resourcetimingbufferfull",(function(){performance.clearResourceTimings()}))}Te("navigation")||function(t){function e(){t(r(r({},ye()),{entryType:"navigation"}))}ge("complete",(function(){setTimeout(A(e))}))}((function(n){Ce(t,e,n)})),Te("first-input")||function(t){var e=Date.now(),n=!1,r=rt(window,[x.CLICK,x.MOUSE_DOWN,x.KEY_DOWN,x.TOUCH_START,x.POINTER_DOWN],(function(t){if(t.cancelable){var e={entryType:"first-input",processingStart:performance.now(),startTime:t.timeStamp};t.type===x.POINTER_DOWN?function(t){rt(window,[x.POINTER_UP,x.POINTER_CANCEL],(function(e){e.type===x.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){Ce(t,e,n)}))}function ge(t,e){if(document.readyState===t||"complete"===document.readyState)e();else{var n="complete"===t?x.LOAD:x.DOM_CONTENT_LOADED;nt(window,n,e,{once:!0})}}function ye(){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 be(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||Ce(t,e,n)}))}function Ce(t,e,n){(function(t){return"navigation"===t.entryType&&t.loadEventEnd<=0})(n)||function(t,e){return"resource"===e.entryType&&!se(t,e.name)}(e,n)||t.notify(yt.PERFORMANCE_ENTRY_COLLECTED,n)}function _e(t,e,n,r,i,o){n.subscribe(yt.RAW_RUM_EVENT_COLLECTED,(function(u){var s,c=u.startTime,d=u.rawRumEvent,l=u.savedGlobalContext,p=u.customerContext,m=i.findView(c);if(r.isTracked()&&m&&m.sessionId){var E=i.findAction(c),v={applicationId:t,date:(new Date).getTime(),service:e.service,session:{type:void 0===window._DATADOG_SYNTHETICS_BROWSER?ce.USER:ce.SYNTHETICS}},T=(s=d,-1!==[_t.ERROR,_t.RESOURCE,_t.LONG_TASK].indexOf(s.evt.category)?f(v,m,E,d):f(v,m,d)),h=f(l||o(),p,a(T));n.notify(yt.RUM_EVENT_COLLECTED,{rumEvent:T,serverRumEvent:h})}}))}function Re(t,e,n,r,i,o){n.subscribe(yt.RAW_RUM_EVENT_V2_COLLECTED,(function(u){var s,c=u.startTime,d=u.rawRumEvent,l=u.savedGlobalContext,p=u.customerContext,m=i.findViewV2(c);if(r.isTracked()&&m&&m.session.id){var E=i.findActionV2(c),v={_dd:{formatVersion:2},application:{id:t},date:(new Date).getTime(),service:e.service,session:{type:void 0===window._DATADOG_SYNTHETICS_BROWSER?fe.USER:fe.SYNTHETICS}},T=(s=d,-1!==[Rt.ERROR,Rt.RESOURCE,Rt.LONG_TASK].indexOf(s.type)?f(v,m,E,d):f(v,m,d)),h=a(T);h.context=f(l||o(),p),n.notify(yt.RUM_EVENT_V2_COLLECTED,{rumEvent:T,serverRumEvent:h})}}))}!function(t){t.SYNTHETICS="synthetics",t.USER="user"}(ce||(ce={})),function(t){t.SYNTHETICS="synthetics",t.USER="user"}(fe||(fe={}));var Oe="_dd",Se="_dd_r",we="_dd_l",Ae="rum",Ie="logs";var Ne="_dd_s",Le=15*B,De=4*W,Ue=B;function xe(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}),ot)};return{get:function(){return i?r:(r=ut(t),o(),r)},set:function(n,i){at(t,n,i,e),r=n,o()}}}(Ne,t);!function(t){var e=t.get(),n=ut(Oe),r=ut(Se),i=ut(we);if(!e){var o={};n&&(o.id=n),i&&/^[01]$/.test(i)&&(o[Ie]=i),r&&/^[012]$/.test(r)&&(o[Ae]=r),Pe(o,t)}}(r);var i=new wt,o=Ve(r).id,a=H((function(){var t=Ve(r),a=n(t[e]),u=a.trackingType,s=a.isTracked;t[e]=u,s&&!t.id&&(t.id=j(),t.created=String(Date.now())),Pe(t,r),s&&o!==t.id&&(o=t.id,i.notify())}),ot).throttled;return a(),function(t){var e=rt(window,[x.CLICK,x.TOUCH_START,x.KEY_DOWN,x.SCROLL],t,{capture:!0,passive:!0}).stop;We.push(e)}(a),function(t){var e=A((function(){"visible"===document.visibilityState&&t()})),n=nt(document,x.VISIBILITY_CHANGE,e).stop;We.push(n);var r=window.setInterval(e,Ue);We.push((function(){clearInterval(r)}))}((function(){Pe(Ve(r),r)})),{getId:function(){return Ve(r).id},getTrackingType:function(){return Ve(r)[e]},renewObservable:i}}var Me=/^([a-z]+)=([a-z0-9-]+)$/,ke="&";function Ve(t){var e=function(t){var e=t.get(),n={};(function(t){return void 0!==t&&(-1!==t.indexOf(ke)||Me.test(t))})(e)&&e.split(ke).forEach((function(t){var e=Me.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)<De)&&(void 0===t.expire||Date.now()<Number(t.expire))}(e)?e:(Be(t),{})}function Pe(t,e){if(n=t,0!==Object.keys(n).length){var n;t.expire=String(Date.now()+Le);var r=Z(t).map((function(t){return t[0]+"="+t[1]})).join(ke);e.set(r,Le)}else Be(e)}function Be(t){t.set("",0)}var We=[];var He,je=De,Ge=5*B,Fe=B;var qe,Ke,ze,Ye,$e=[],Xe=[];function Je(){return He||(qe=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)},qe.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,Xe.forEach((function(t){return t(e._datadog_xhr)})))};this.addEventListener("loadend",A(i)),$e.forEach((function(t){return t(e._datadog_xhr,e)}))}return Ke.apply(this,arguments)})),He={beforeSend:function(t){$e.push(t)},onRequestComplete:function(t){Xe.push(t)}}),He}var Qe=[],Ze=[];function tn(){return ze||(!function(){if(!window.fetch)return;Ye=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=E(R(t)),Ze.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,Ze.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};Qe.forEach((function(t){return t(a)}));var s=Ye.call(this,t,a.init);return s.then(A(u),A(u)),s}))}(),ze={beforeSend:function(t){Qe.push(t)},onRequestComplete:function(t){Ze.push(t)}}),ze}function en(t){0===t.status&&(t.traceId=void 0,t.spanId=void 0)}function nn(t,e,n){var r;void 0!==rn()&&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 fn,e.spanId=new fn,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 rn(){return window.crypto||window.msCrypto}var on,an,un,sn,cn,fn=function(){function t(){this.buffer=new Uint8Array(8),rn().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}(),dn=1;function ln(t,e){var n=function(t){return{clearTracingIfCancelled:en,traceFetch:function(e){return nn(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 nn(t,e,(function(t){Object.keys(t).forEach((function(e){n.setRequestHeader(e,t[e])}))}))}}}(e);!function(t,e,n){var r=Je();r.beforeSend((function(r,i){se(e,r.url)&&(n.traceXhr(r,i),r.requestIndex=pn(),t.notify(yt.REQUEST_STARTED,{requestIndex:r.requestIndex}))})),r.onRequestComplete((function(r){se(e,r.url)&&(n.clearTracingIfCancelled(r),t.notify(yt.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=tn();r.beforeSend((function(r){se(e,r.url)&&(n.traceFetch(r),r.requestIndex=pn(),t.notify(yt.REQUEST_STARTED,{requestIndex:r.requestIndex}))})),r.onRequestComplete((function(r){se(e,r.url)&&(n.clearTracingIfCancelled(r),t.notify(yt.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 pn(){var t=dn;return dn+=1,t}function mn(t,e){return t.subscribe(yt.AUTO_ACTION_COMPLETED,(function(n){e.isEnabled("v2_format")?t.notify(yt.RAW_RUM_EVENT_V2_COLLECTED,vn(n)):t.notify(yt.RAW_RUM_EVENT_COLLECTED,En(n))})),e.trackInteractions&&qt(t),{addAction:function(n,i){e.isEnabled("v2_format")?t.notify(yt.RAW_RUM_EVENT_V2_COLLECTED,r({savedGlobalContext:i},vn(n))):t.notify(yt.RAW_RUM_EVENT_COLLECTED,r({savedGlobalContext:i},En(n)))}}}function En(t){var e=Tn(t)?{duration:F(t.duration),userAction:{id:t.id,measures:t.counts}}:void 0;return{customerContext:Tn(t)?void 0:t.context,rawRumEvent:f({date:J(t.startTime),evt:{category:_t.USER_ACTION,name:t.name},userAction:{type:t.type}},e),startTime:t.startTime}}function vn(t){var e=Tn(t)?{action:{error:{count:t.counts.errorCount},id:t.id,loadingTime:F(t.duration),longTask:{count:t.counts.longTaskCount},resource:{count:t.counts.resourceCount}}}:void 0;return{customerContext:Tn(t)?void 0:t.context,rawRumEvent:f({action:{target:{name:t.name},type:t.type},date:J(t.startTime),type:Rt.ACTION},e),startTime:t.startTime}}function Tn(t){return t.type!==Vt.CUSTOM}function hn(t){if(!on){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:u.NETWORK,stack:yn(r.response,t)||"Failed to load",startTime:r.startTime})}Je().onRequestComplete((function(t){return n(k.XHR,t)})),tn().onRequestComplete((function(t){return n(k.FETCH,t)}))}(t,e),function(t){an=console.error,console.error=A((function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];an.apply(console,o([e],n)),t.notify({message:o(["console error:",e],n).map(gn).join(" "),source:u.CONSOLE,startTime:performance.now()})}))}(e),function(t){un=function(e,n,r){var i=m(e,r,"Uncaught"),o=i.stack,a=i.message,s=i.type;t.notify({message:a,stack:o,type:s,source:u.SOURCE,startTime:performance.now()})},_.subscribe(un)}(e),on=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:u.AGENT,startTime:performance.now()}))})),setInterval((function(){return n=0}),B),r}(t,e)}return on}function gn(t){return"string"==typeof t?t:t instanceof Error?E(R(t)):K(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(n){e.isEnabled("v2_format")?t.notify(yt.RAW_RUM_EVENT_V2_COLLECTED,Rn(n)):t.notify(yt.RAW_RUM_EVENT_COLLECTED,_n(n))})),{addError:function(n,i){var o=n.error,a=n.startTime,u=n.context,s=function(t,e,n){var i=t instanceof Error?R(t):void 0;return r({startTime:e,source:n},m(i,t,"Provided"))}(o,a,n.source);e.isEnabled("v2_format")?t.notify(yt.RAW_RUM_EVENT_V2_COLLECTED,r({customerContext:u,savedGlobalContext:i},Rn(s))):t.notify(yt.RAW_RUM_EVENT_COLLECTED,r({customerContext:u,savedGlobalContext:i},_n(s)))}}}(t,e,hn(e))}function _n(t){return{rawRumEvent:f({date:J(t.startTime),error:{kind:t.type,origin:t.source,stack:t.stack},evt:{category:_t.ERROR},message:t.message},t.resource?{http:{method:t.resource.method,status_code:t.resource.statusCode,url:t.resource.url}}:void 0),startTime:t.startTime}}function Rn(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 On(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(ie).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 wn(t,e,n){t.subscribe(yt.REQUEST_COMPLETED,(function(r){n.isTrackedWithResource()&&(e.isEnabled("v2_format")?t.notify(yt.RAW_RUM_EVENT_V2_COLLECTED,function(t){var e=t.type===k.XHR?M.XHR:M.FETCH,n=On(t),r=n?n.startTime:t.startTime,i=n?In(n):void 0,o=Nn(t),a=f({date:J(r),resource:{type:e,duration:F(t.duration),method:t.method,statusCode:t.status,url:t.url},type:Rt.RESOURCE},o,i);return{startTime:r,rawRumEvent:a}}(r)):t.notify(yt.RAW_RUM_EVENT_COLLECTED,function(t){var e=t.type===k.XHR?M.XHR:M.FETCH,n=On(t),r=n?n.startTime:t.startTime,i=n?An(n):void 0,o=Nn(t),a=f({date:J(r),duration:F(t.duration),evt:{category:_t.RESOURCE},http:{method:t.method,statusCode:t.status,url:t.url},resource:{kind:e}},o,i);return{startTime:r,rawRumEvent:a}}(r)))})),t.subscribe(yt.PERFORMANCE_ENTRY_COLLECTED,(function(r){var i;n.isTrackedWithResource()&&"resource"===r.entryType&&("xmlhttprequest"!==(i=r).initiatorType&&"fetch"!==i.initiatorType)&&(e.isEnabled("v2_format")?t.notify(yt.RAW_RUM_EVENT_V2_COLLECTED,function(t){var e=te(t),n=In(t),r=Ln(t),i=f({date:J(t.startTime),resource:{type:e,url:t.name},type:Rt.RESOURCE},r,n);return{startTime:t.startTime,rawRumEvent:i}}(r)):t.notify(yt.RAW_RUM_EVENT_COLLECTED,function(t){var e=te(t),n=An(t),r=Ln(t),i=f({date:J(t.startTime),evt:{category:_t.RESOURCE},http:{url:t.name},resource:{kind:e}},r,n);return{startTime:t.startTime,rawRumEvent:i}}(r)))}))}function An(t){return{duration:ne(t),http:{performance:re(t)},network:{bytesWritten:ue(t)}}}function In(t){return{resource:r({duration:ne(t),size:ue(t)},re(t))}}function Nn(t){if(t.traceId&&t.spanId)return{_dd:{spanId:t.spanId.toDecimalString(),traceId:t.traceId.toDecimalString()},resource:{id:j()}}}function Ln(t){return t.traceId?{_dd:{traceId:t.traceId}}:void 0}function Dn(t){return void 0===t&&(t=window),sn||("hidden"===document.visibilityState?sn={timeStamp:0}:(sn={timeStamp:1/0},nt(t,x.PAGE_HIDE,(function(t){var e=t.timeStamp;sn.timeStamp=e}),{capture:!0,once:!0}).stop)),sn}function Un(t,e){var n;function i(t){n=r(r({},n),t),e(n)}var o=function(t,e){return{stop:t.subscribe(yt.PERFORMANCE_ENTRY_COLLECTED,(function(t){"navigation"===t.entryType&&e({domComplete:t.domComplete,domContentLoaded:t.domContentLoadedEventEnd,domInteractive:t.domInteractive,loadEventEnd:t.loadEventEnd})})).unsubscribe}}(t,i).stop,a=function(t,e){var n=Dn();return{stop:t.subscribe(yt.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=Dn(),i=1/0,o=rt(e,[x.POINTER_DOWN,x.KEY_DOWN],(function(t){i=t.timeStamp}),{capture:!0,once:!0}).stop,a=t.subscribe(yt.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=Dn();return{stop:t.subscribe(yt.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"}(cn||(cn={}));var xn=3e3,Mn=5*B;function kn(t,e){var n,r=Vn(e,t,cn.INITIAL_LOAD,document.referrer,0),i=r,o=Un(e,(function(t){r.updateTimings(t),r.scheduleUpdate()})).stop;function a(){i.isDifferentView(t)?(i.triggerUpdate(),i.end(),i=Vn(e,t,cn.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()})),nt(window,x.POP_STATE,t)}(a),n=a,nt(window,x.HASH_CHANGE,n),e.subscribe(yt.SESSION_RENEWED,(function(){i.end(),i=Vn(e,t,cn.ROUTE_CHANGE,i.url)})),e.subscribe(yt.BEFORE_UNLOAD,(function(){i.triggerUpdate(),i.end()}));var u=window.setInterval(A((function(){i.triggerUpdate()})),Mn);return{stop:function(){o(),i.end(),clearInterval(u)}}}function Vn(t,e,n,i,o){void 0===o&&(o=performance.now());var a,u,s,c=j(),f={errorCount:0,longTaskCount:0,resourceCount:0,userActionCount:0},d={},l=0,p=r({},e);t.notify(yt.VIEW_CREATED,{id:c,startTime:o,location:p,referrer:i});var m,E=H(A(_),xn,{leading:!1}),v=E.throttled,T=E.cancel,h=St(t,(function(t){f=t,v()})).stop,g=function(t,e){var n=t===cn.INITIAL_LOAD,r=!0,i=[];function o(){!r&&!n&&i.length>0&&e(Math.max.apply(Math,i))}return{setLoadEventEnd: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,v()})),y=g.setActivityLoadingTime,b=g.setLoadEventEnd,C=function(t,e){var n=performance.now();return{stop:Lt(t,(function(t,r){e(t?r-n:void 0)})).stop}}(t,y).stop;function _(){l+=1,t.notify(yt.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})}return Te("layout-shift")?(a=0,m=function(t,e){return{stop:t.subscribe(yt.PERFORMANCE_ENTRY_COLLECTED,(function(t){"layout-shift"!==t.entryType||t.hadRecentInput||e(t.value)})).unsubscribe}}(t,(function(t){a+=t,v()})).stop):m=q,_(),{scheduleUpdate:v,end:function(){s=performance.now(),h(),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(){T(),_()},updateTimings:function(t){d=t,void 0!==t.loadEventEnd&&b(t.loadEventEnd)},updateLocation:function(t){p=r({},t)},get url(){return p.href}}}function Pn(t,e,n){return t.subscribe(yt.VIEW_UPDATED,(function(n){e.isEnabled("v2_format")?t.notify(yt.RAW_RUM_EVENT_V2_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:F(t.timings.domComplete),domContentLoaded:F(t.timings.domContentLoaded),domInteractive:F(t.timings.domInteractive),error:{count:t.eventCounts.errorCount},firstContentfulPaint:F(t.timings.firstContentfulPaint),firstInputDelay:F(t.timings.firstInputDelay),largestContentfulPaint:F(t.timings.largestContentfulPaint),loadEventEnd:F(t.timings.loadEventEnd),loadingTime:F(t.loadingTime),loadingType:t.loadingType,longTask:{count:t.eventCounts.longTaskCount},resource:{count:t.eventCounts.resourceCount},timeSpent:F(t.duration)}},startTime:t.startTime}}(n)):t.notify(yt.RAW_RUM_EVENT_COLLECTED,function(t){return{rawRumEvent:{date:J(t.startTime),duration:F(t.duration),evt:{category:_t.VIEW},rum:{documentVersion:t.documentVersion},view:{loadingTime:F(t.loadingTime),loadingType:t.loadingType,measures:r(r({},t.eventCounts),{domComplete:F(t.timings.domComplete),domContentLoaded:F(t.timings.domContentLoaded),domInteractive:F(t.timings.domInteractive),firstContentfulPaint:F(t.timings.firstContentfulPaint),loadEventEnd:F(t.timings.loadEventEnd)})}},startTime:t.startTime}}(n))})),kn(n,t)}var Bn,Wn="rum";function Hn(t,e){var n=xe(t.cookieOptions,Wn,(function(e){return function(t,e){var n;n=function(t){return t===Bn.NOT_TRACKED||t===Bn.TRACKED_WITH_RESOURCES||t===Bn.TRACKED_WITHOUT_RESOURCES}(e)?e:G(t.sampleRate)?G(t.resourceSampleRate)?Bn.TRACKED_WITH_RESOURCES:Bn.TRACKED_WITHOUT_RESOURCES:Bn.NOT_TRACKED;return{trackingType:n,isTracked:jn(n)}}(t,e)}));return n.renewObservable.subscribe((function(){e.notify(yt.SESSION_RENEWED)})),{getId:n.getId,isTracked:function(){return void 0!==n.getId()&&jn(n.getTrackingType())},isTrackedWithResource:function(){return void 0!==n.getId()&&n.getTrackingType()===Bn.TRACKED_WITH_RESOURCES}}}function jn(t){return t===Bn.TRACKED_WITH_RESOURCES||t===Bn.TRACKED_WITHOUT_RESOURCES}function Gn(t,e){var n=function(t,e){var n,r=o(t.rumEndpoint,(function(){return e.notify(yt.BEFORE_UNLOAD)})),i=t.replica;void 0!==i&&(n=o(i.rumEndpoint));function o(e,n){return new h(new T(e,t.batchBytesLimit,!0),t.maxBatchSize,t.batchBytesLimit,t.maxMessageSize,t.flushTimeout,n)}function a(e){return f(e,t.isEnabled("v2_format")?{application:{id:i.applicationId}}:{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(yt.RUM_EVENT_COLLECTED,(function(t){var e=t.rumEvent,r=t.serverRumEvent;e.evt.category===_t.VIEW?n.upsert(r,e.view.id):n.add(r)})),e.subscribe(yt.RUM_EVENT_V2_COLLECTED,(function(t){var e=t.rumEvent,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"}(Bn||(Bn={}));var Fn={buildMode:"release",datacenter:"us",sdkVersion:"1.26.3"};var qn,Kn,zn,Yn,$n=Xn((function(t,e){var n=new Ot,r=function(t,e){var n=lt(t,e);return{configuration:n,internalMonitoring:w(n)}}(t,Fn),i=r.configuration,o=r.internalMonitoring,u=Hn(i,n);o.setExternalContextProvider((function(){return f({application_id:t.applicationId},c.findView(),e())}));var s=function(t,e,n,r,i,o){var a=function(t,e){var n,r,i,o=[],a=[];t.subscribe(yt.VIEW_CREATED,(function(t){n&&o.unshift({context:c(),endTime:t.startTime,startTime:n.startTime}),n=t,i=e.getId()})),t.subscribe(yt.VIEW_UPDATED,(function(t){n.id===t.id&&(n=t)})),t.subscribe(yt.AUTO_ACTION_CREATED,(function(t){r=t})),t.subscribe(yt.AUTO_ACTION_COMPLETED,(function(t){r&&a.unshift({context:f(),endTime:r.startTime+t.duration,startTime:r.startTime}),r=void 0})),t.subscribe(yt.AUTO_ACTION_DISCARDED,(function(){r=void 0})),t.subscribe(yt.SESSION_RENEWED,(function(){o=[],a=[],n=void 0,r=void 0}));var u=window.setInterval(A((function(){s(o,je),s(a,Ge)})),Fe);function s(t,e){for(var n=performance.now()-e;t.length>0&&t[t.length-1].startTime<n;)t.pop()}function c(){return{sessionId:i,view:{id:n.id,referrer:n.referrer,url:n.location.href}}}function f(){return{userAction:{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}}var l={findAction:function(t){return d(f,a,r,t)},findActionV2:function(t){var e=l.findAction(t);if(e)return{action:{id:e.userAction.id}}},findView:function(t){return d(c,o,n,t)},findViewV2:function(t){var e=l.findView(t);if(e)return{session:{id:e.sessionId},view:e.view}},stop:function(){window.clearInterval(u)}};return l}(n,i),u=Gn(r,n);_e(t,r,n,i,a,o),Re(t,r,n,i,a,o),function(t,e){t.subscribe(yt.PERFORMANCE_ENTRY_COLLECTED,(function(n){if("longtask"===n.entryType)if(e.isEnabled("v2_format")){var r={date:J(n.startTime),longTask:{duration:F(n.duration)},type:Rt.LONG_TASK};t.notify(yt.RAW_RUM_EVENT_V2_COLLECTED,{rawRumEvent:r,startTime:n.startTime})}else{r={date:J(n.startTime),duration:F(n.duration),evt:{category:_t.LONG_TASK}};t.notify(yt.RAW_RUM_EVENT_COLLECTED,{rawRumEvent:r,startTime:n.startTime})}}))}(n,r),wn(n,r,i),Pn(n,r,e);var s=Cn(n,r).addError;return{addAction:mn(n,r).addAction,addError:s,parentContexts:a,stop:function(){u.stop()}}}(t.applicationId,location,n,i,u,e),c=s.parentContexts,d=s.addError,l=s.addAction;return ln(n,i),he(n,i),Yt(n),{addAction:l,addError:d,getInternalContext:function(t,e,n,r){return{get:function(i){if(r.isEnabled("v2_format")){var o=n.findViewV2(i);if(e.isTracked()&&o&&o.session.id){var u=n.findActionV2(i);return a(f({applicationId:t},{sessionId:o.session.id,view:o.view},u?{userAction:{id:u.action.id}}:void 0))}}else{o=n.findView(i);if(e.isTracked()&&o&&o.sessionId)return a(f({applicationId:t},o,n.findAction(i)))}}}}(t.applicationId,u,c,i).get}}));function Xn(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=function(){},a=new Ct,s=function(t){a.add([t,d(i.get())])},c=new Ct,f=function(t){c.add([t,d(i.get())])},l=function(t){var e=r(r({},t),{onReady:function(t){t()}});return Object.defineProperty(e,"_setDebug",{get:function(){return D},enumerable:!1}),e}({init:A((function(e){var r;ht(pt(e))&>()&&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,i.get),s=r.addAction,f=r.addError,o=r.getInternalContext,a.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 f(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 o(t)})),addAction:A((function(t,e){s({name:t,context:d(e),startTime:performance.now(),type:Vt.CUSTOM})})),addUserAction:function(t,e){l.addAction(t,e)},addError:A((function(t,e,n){var r;void 0===n&&(n=u.CUSTOM),n===u.CUSTOM||n===u.NETWORK||n===u.SOURCE?r=n:(console.error("DD_RUM.addError: Invalid source '"+n+"'"),r=u.CUSTOM),f({error:t,context:d(e),source:r,startTime:performance.now()})}))});return l}qn=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}(),zn=$n,Yn=qn[Kn="DD_RUM"],qn[Kn]=zn,Yn&&Yn.q&&Yn.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 Wn})),n.d(e,"makeRumGlobal",(function(){return jn}));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:E(t),type:t.name}:{message:n+" "+z(e),stack:"No stack, consider using an instance of Error",type:t&&t.name}}function E(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 v=/[^\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 v.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&&(nt(window,M.BEFORE_UNLOAD,this.beforeUnloadCallback),nt(document,M.VISIBILITY_CHANGE,(function(){"hidden"===document.visibilityState&&t.flush()})),nt(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:d,stack:[c]},!0)}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){if(t.stack){for(var e,n,r,i,o=/^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,a=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i,u=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,s=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,c=/\((\S*)(?::(\d+))(?::(\d+))\)/,f=t.stack.split("\n"),d=[],l=0,p=f.length;l<p;l+=1){if(o.exec(f[l])){var m=(r=o.exec(f[l]))[2]&&0===r[2].indexOf("native");e=r[2]&&0===r[2].indexOf("eval"),n=c.exec(r[2]),e&&n&&(r[2]=n[1],r[3]=n[2],r[4]=n[3]),i={args:m?[r[2]]:[],column:r[4]?+r[4]:void 0,func:r[1]||g,line:r[3]?+r[3]:void 0,url:m?void 0:r[2]}}else if(u.exec(f[l]))i={args:[],column:(r=u.exec(f[l]))[4]?+r[4]:void 0,func:r[1]||g,line:+r[3],url:r[2]};else{if(!a.exec(f[l]))continue;e=(r=a.exec(f[l]))[3]&&r[3].indexOf(" > eval")>-1,n=s.exec(r[3]),e&&n?(r[3]=n[1],r[4]=n[2],r[5]=void 0):0!==l||r[5]||void 0===t.columnNumber||(d[0].column=t.columnNumber+1),i={args:r[2]?r[2].split(","):[],column:r[5]?+r[5]:void 0,func:r[1]||g,line:r[4]?+r[4]:void 0,url:r[3]}}!i.func&&i.line&&(i.func=g),d.push(i)}if(d.length)return{stack:d,message:t.message,name: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,o,a=/function\s+([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)?\s*\(/i,u=[],s={},c=!1,f=r.caller;f&&!c;f=f.caller)f!==R&&f!==O&&(o={args:[],column:void 0,func:g,line:void 0,url:void 0},i=a.exec(f.toString()),f.name?o.func=f.name:i&&(o.func=i[1]),void 0===o.func&&(o.func=i?i.input.substring(0,i.input.indexOf("{")):void 0),s[""+f]?c=!0:s[""+f]=!0,u.push(o));e&&u.splice(0,e);var d={stack:u,message:t.message,name:t.name};return n(d,t.sourceURL||t.fileName,t.line||t.lineNumber,t.message||t.description),d}function i(n,i){var o,a=void 0===i?0:+i;try{if(o=function(t){var e=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,o=e.split("\n"),a=[],u=0;u<o.length;u+=2){var s=void 0;r.exec(o[u])?s={args:[],column:void 0,func:(n=r.exec(o[u]))[3],line:+n[1],url:n[2]}:i.exec(o[u])&&(s={args:(n=i.exec(o[u]))[5]?n[5].split(","):[],column:+n[2],func:n[3]||n[4],line:+n[1],url:n[6]}),s&&(!s.func&&s.line&&(s.func=g),s.context=[o[u+1]],a.push(s))}if(a.length)return{stack:a,message:t.message,name:t.name}}}(n))return o}catch(e){if(t)throw e}try{if(o=e(n))return o}catch(e){if(t)throw e}try{if(o=function(t){var e=t.message.split("\n");if(!(e.length<4)){var n,r=/^\s*Line (\d+) of linked script ((?:file|https?|blob)\S+)(?:: in function (\S+))?\s*$/i,i=/^\s*Line (\d+) of inline#(\d+) script in ((?:file|https?|blob)\S+)(?:: in function (\S+))?\s*$/i,o=/^\s*Line (\d+) of function script\s*$/i,a=[],u=window&&window.document&&window.document.getElementsByTagName("script"),s=[];for(var c in u)b(u,c)&&!u[c].src&&s.push(u[c]);for(var f=2;f<e.length;f+=2){var d=void 0;if(r.exec(e[f]))d={args:[],column:void 0,func:(n=r.exec(e[f]))[3],line:+n[1],url:n[2]};else if(i.exec(e[f]))d={args:[],column:void 0,func:(n=i.exec(e[f]))[4],line:+n[1],url:n[3]};else if(o.exec(e[f])){n=o.exec(e[f]),d={url:window.location.href.replace(/#.*$/,""),args:[],column:void 0,func:"",line:+n[1]}}d&&(d.func||(d.func=g),d.context=[e[f+1]],a.push(d))}if(a.length)return{stack:a,message:e[0],name:t.name}}}(n))return o}catch(e){if(t)throw e}try{if(o=r(n,a+1))return o}catch(e){if(t)throw e}return{message:n.message,name:n.name,stack:[]}}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:E(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){if(t.origin)return t.origin;var e=t.host.replace(/(:80|:443)$/,"");return t.protocol+"//"+e}function et(t,e){var n=t.match("(?:^|;)\\s*"+e+"\\s*=\\s*([^;]+)");return n?n[1]:void 0}function nt(t,e,n,r){return rt(t,[e],n,r)}function rt(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 it,ot=B;function at(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 ut(t){return et(document.cookie,t)}var st,ct={allowedTracingOrigins:[],maxErrorsByMinute:3e3,maxInternalMonitoringMessagesPerPage:15,resourceSampleRate:100,sampleRate:100,silentMultipleInit:!1,trackInteractions:!1,requestErrorResponseLengthLimit:32768,flushTimeout:30*B,maxBatchSize:50,maxMessageSize:262144,batchBytesLimit:16384},ft={alternate:{logs:"logs",rum:"rum",trace:"trace"},classic:{logs:"browser",rum:"rum",trace:"public-trace"}};function dt(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||ht[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(ht[vt.US]);for(var i=[],o=Object.keys(ft[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://"+mt(t,d,s)+"/v1/input/")}return i}(o,n,void 0!==t.replica),u=r({cookieOptions:lt(t),isEnabled:function(t){return Y(i,t)},logsEndpoint:pt(o,"logs",n),proxyHost:t.proxyHost,rumEndpoint:pt(o,"rum",n),service:t.service,traceEndpoint:pt(o,"trace",n),isIntakeUrl:function(t){return a.some((function(e){return 0===t.indexOf(e)}))}},ct);if(t.internalMonitoringApiKey&&(u.internalMonitoringEndpoint=pt(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:ht[vt.US]});u.replica={applicationId:t.replica.applicationId,internalMonitoringEndpoint:pt(o,"logs",s,"browser-agent-internal-monitoring"),logsEndpoint:pt(o,"logs",s),rumEndpoint:pt(o,"rum",s)}}return u}function lt(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===it){for(var t="dd_site_test_"+V(),e=window.location.hostname.split("."),n=e.pop();e.length&&!ut(t);)n=e.pop()+"."+n,at(t,"test",B,{domain:n});it=n}return it}()),e}function pt(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=mt(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 mt(t,e,n){var r=ft[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,vt={EU:"eu",US:"us"},ht=((st={})[vt.EU]="datadoghq.eu",st[vt.US]="datadoghq.com",st);function Tt(t){return!!function(t){if(void 0===document.cookie||null===document.cookie)return!1;try{var e="dd_cookie_test_"+V();return at(e,"test",B,t),"test"===ut(e)}catch(t){return console.error(t),!1}}(t)||(console.warn("Cookies are not authorized, we will not send any data."),!1)}function gt(){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 yt,bt=1e4,Ct=function(){function t(t){void 0===t&&(t=bt),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"}(yt||(yt={}));var Ot,Rt=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 St(t,e){void 0===e&&(e=G);var n={errorCount:0,longTaskCount:0,resourceCount:0,userActionCount:0},r=t.subscribe(yt.RAW_RUM_EVENT_COLLECTED,(function(t){switch(t.rawRumEvent.type){case Ot.ERROR:n.errorCount+=1,e(n);break;case Ot.ACTION:n.userActionCount+=1,e(n);break;case Ot.LONG_TASK:n.longTaskCount+=1,e(n);break;case Ot.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"}(Ot||(Ot={}));var _t=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}(),wt=100,It=100,At=1e4;function Nt(t,e){var n=function(t){var e,n=new _t,r=[],i=0;function o(){n.notify({isBusy:i>0})}return r.push(t.subscribe(yt.DOM_MUTATED,(function(){return o()}))),r.push(t.subscribe(yt.PERFORMANCE_ENTRY_COLLECTED,(function(t){"resource"===t.entryType&&o()}))),r.push(t.subscribe(yt.REQUEST_STARTED,(function(t){void 0===e&&(e=t.requestIndex),i+=1,o()}))),r.push(t.subscribe(yt.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)})),wt),a=setTimeout(I((function(){return s(!0,performance.now())})),At);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)})),It))})),{stop:u}}(r,i,e).stop;return{stop:function(){o(),i()}}}function Dt(t){return function(t){var e;if(function(){void 0===Ut&&(Ut="closest"in HTMLElement.prototype);return Ut}())e=t.closest("["+Lt+"]");else for(var n=t;n;){if(n.hasAttribute(Lt)){e=n;break}n=n.parentElement}if(!e)return;return Vt(jt(e.getAttribute(Lt).trim()))}(t)||Wt(t,Pt)||Wt(t,Bt)||""}var Lt="data-dd-action-name";var xt,Mt,Ut,kt,Pt=[function(t){if(function(){void 0===Mt&&(Mt="labels"in HTMLInputElement.prototype);return Mt}()){if("labels"in t&&t.labels&&t.labels.length>0)return Ft(t.labels[0])}else if(t.id){var e=t.ownerDocument&&t.ownerDocument.querySelector('label[for="'+t.id.replace('"','\\"')+'"]');return e&&Ft(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 Ft(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(Ft).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 Ft(t.options[0])}],Bt=[function(t){return Ft(t)}],Ht=10;function Wt(t,e){for(var n=t,r=0;r<=Ht&&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(jt(u))}}if("FORM"===n.nodeName)break;n=n.parentElement,r+=1}}function jt(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 Ft(t){if(!t.isContentEditable){if("innerText"in t){var e=t.innerText;if(!function(){if(void 0===xt){var t=document.createElement("style");t.textContent="*";var e=document.createElement("div");e.appendChild(t),document.body.appendChild(e),xt=""===e.innerText,document.body.removeChild(e)}return xt}())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 qt(t){var e=function(t){var e,n;return{create:function(r,i){if(!e){var o=new zt(t,r,i);e=o,n=Nt(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(yt.VIEW_CREATED,(function(){e.discardCurrent()}));var n=nt(window,M.CLICK,(function(t){if(t.target instanceof Element){var n=Dt(t.target);n&&e.create(kt.CLICK,n)}}),{capture:!0}).stop;return{stop:function(){e.discardCurrent(),n()}}}!function(t){t.CLICK="click",t.CUSTOM="custom"}(kt||(kt={}));var Gt,zt=function(){function t(t,e,n){this.lifeCycle=t,this.type=e,this.name=n,this.id=V(),this.startTime=performance.now(),this.eventCountsSubscription=St(t),this.lifeCycle.notify(yt.AUTO_ACTION_CREATED,{id:this.id,startTime:this.startTime})}return t.prototype.complete=function(t){var e=this.eventCountsSubscription.eventCounts;this.lifeCycle.notify(yt.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(yt.AUTO_ACTION_DISCARDED),this.eventCountsSubscription.stop()},t}();function Kt(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(yt.DOM_MUTATED)})))).observe(document.documentElement,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),{stop:function(){e&&e.disconnect()}}}function Yt(t){return Xt(t,tt(window.location)).href}function $t(t){return tt(Xt(t))}function Xt(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 Jt="initial_document",Qt=[[U.DOCUMENT,function(t){return Jt===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 Zt(t){var e=t.name;if(!function(t){try{return!!Xt(t)}catch(t){return!1}}(e))return A('Failed to construct URL for "'+t.name+'"'),U.OTHER;for(var n=function(t){var e=Xt(t).pathname;return"/"===e[0]?e:"/"+e}(e),r=0,i=Qt;r<i.length;r++){var o=i[r],a=o[0];if((0,o[1])(t.initiatorType,n))return a}return U.OTHER}function te(){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 ee(t){var e=ne(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:ie(n,l,e.responseEnd),firstByte:ie(n,d,l)};return f!==r&&(p.connect=ie(n,s,f),te(s,c,f)&&(p.ssl=ie(n,c,f))),u!==r&&(p.dns=ie(n,a,u)),re(t)&&(p.redirect=ie(n,i,o)),p}}function ne(t){if(te(t.startTime,t.fetchStart,t.domainLookupStart,t.domainLookupEnd,t.connectStart,t.connectEnd,t.requestStart,t.responseStart,t.responseEnd)){if(!re(t))return t;var e=t.redirectStart,n=t.redirectEnd;if(e<t.startTime&&(e=t.startTime),n<t.startTime&&(n=t.fetchStart),te(t.startTime,e,n,t.fetchStart))return r(r({},t),{redirectEnd:n,redirectStart:e})}}function re(t){return t.fetchStart!==t.startTime}function ie(t,e,n){return{duration:q(n-e),start:q(e-t)}}function oe(t){if(t.startTime<t.responseStart)return t.decodedBodySize}function ae(t,e){return e&&!t.isIntakeUrl(e)}var ue,se=2*H;function ce(t){var e=function(t){var e=t.querySelector("meta[name=dd-trace-id]"),n=t.querySelector("meta[name=dd-trace-time]");return fe(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=de(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=de(r))return n;if(!le(r))break}}(t);if(!e)return;return fe(et(e,"trace-id"),et(e,"trace-time"))}(t);if(e&&!(e.traceTime<=Date.now()-se))return e.traceId}function fe(t,e){var n=e&&Number(e);if(t&&n)return{traceId:t,traceTime:n}}function de(t){if(t&&function(t){return"#comment"===t.nodeName}(t)){var e=t.data.match(/^\s*DATADOG;(.*?)\s*$/);if(e)return e[1]}}function le(t){return"#text"===t.nodeName}function pe(){return void 0!==window.performance&&"getEntries"in performance}function me(t){return window.PerformanceObserver&&void 0!==PerformanceObserver.supportedEntryTypes&&PerformanceObserver.supportedEntryTypes.includes(t)}function Ee(t,e){var n;if(n=function(n){ge(t,e,n)},ve("interactive",(function(){var t,e={entryType:"resource",initiatorType:Jt,traceId:ce(document)};if(me("navigation")&&performance.getEntriesByType("navigation").length>0){var i=performance.getEntriesByType("navigation")[0];t=r(r({},i.toJSON()),e)}else{var o=he();t=r(r(r({},o),{decodedBodySize:0,duration:o.responseEnd,name:window.location.href,startTime:0}),e)}n(t)})),pe()&&Te(t,e,performance.getEntries()),window.PerformanceObserver){new PerformanceObserver(I((function(n){return Te(t,e,n.getEntries())}))).observe({entryTypes:["resource","navigation","longtask","paint","largest-contentful-paint","first-input","layout-shift"]}),pe()&&"addEventListener"in performance&&performance.addEventListener("resourcetimingbufferfull",(function(){performance.clearResourceTimings()}))}me("navigation")||function(t){function e(){t(r(r({},he()),{entryType:"navigation"}))}ve("complete",(function(){setTimeout(I(e))}))}((function(n){ge(t,e,n)})),me("first-input")||function(t){var e=Date.now(),n=!1,r=rt(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){rt(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){ge(t,e,n)}))}function ve(t,e){if(document.readyState===t||"complete"===document.readyState)e();else{var n="complete"===t?M.LOAD:M.DOM_CONTENT_LOADED;nt(window,n,e,{once:!0})}}function he(){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 Te(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||ge(t,e,n)}))}function ge(t,e,n){(function(t){return"navigation"===t.entryType&&t.loadEventEnd<=0})(n)||function(t,e){return"resource"===e.entryType&&!ae(t,e.name)}(e,n)||t.notify(yt.PERFORMANCE_ENTRY_COLLECTED,n)}function ye(t,e,n,r,i,o){n.subscribe(yt.RAW_RUM_EVENT_COLLECTED,(function(u){var s,f=u.startTime,d=u.rawRumEvent,l=u.savedGlobalContext,p=u.customerContext,m=i.findView(f);if(r.isTracked()&&m&&m.session.id){var E=i.findAction(f),v={_dd:{formatVersion:2},application:{id:t},date:(new Date).getTime(),service:e.service,session:{type:void 0===window._DATADOG_SYNTHETICS_BROWSER?ue.USER:ue.SYNTHETICS}},h=(s=d,-1!==[Ot.ERROR,Ot.RESOURCE,Ot.LONG_TASK].indexOf(s.type)?c(v,m,E,d):c(v,m,d)),T=a(h);T.context=c(l||o(),p),n.notify(yt.RUM_EVENT_COLLECTED,{rumEvent:h,serverRumEvent:T})}}))}!function(t){t.SYNTHETICS="synthetics",t.USER="user"}(ue||(ue={}));var be="_dd",Ce="_dd_r",Oe="_dd_l",Re="rum",Se="logs";var _e="_dd_s",we=15*H,Ie=4*W,Ae=H;function Ne(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}),ot)};return{get:function(){return i?r:(r=ut(t),o(),r)},set:function(n,i){at(t,n,i,e),r=n,o()}}}(_e,t);!function(t){var e=t.get(),n=ut(be),r=ut(Ce),i=ut(Oe);if(!e){var o={};n&&(o.id=n),i&&/^[01]$/.test(i)&&(o[Se]=i),r&&/^[012]$/.test(r)&&(o[Re]=r),Me(o,t)}}(r);var i=new _t,o=xe(r).id,a=j((function(){var t=xe(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())),Me(t,r),s&&o!==t.id&&(o=t.id,i.notify())}),ot).throttled;return a(),function(t){var e=rt(window,[M.CLICK,M.TOUCH_START,M.KEY_DOWN,M.SCROLL],t,{capture:!0,passive:!0}).stop;ke.push(e)}(a),function(t){var e=I((function(){"visible"===document.visibilityState&&t()})),n=nt(document,M.VISIBILITY_CHANGE,e).stop;ke.push(n);var r=window.setInterval(e,Ae);ke.push((function(){clearInterval(r)}))}((function(){Me(xe(r),r)})),{getId:function(){return xe(r).id},getTrackingType:function(){return xe(r)[e]},renewObservable:i}}var De=/^([a-z]+)=([a-z0-9-]+)$/,Le="&";function xe(t){var e=function(t){var e=t.get(),n={};(function(t){return void 0!==t&&(-1!==t.indexOf(Le)||De.test(t))})(e)&&e.split(Le).forEach((function(t){var e=De.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)<Ie)&&(void 0===t.expire||Date.now()<Number(t.expire))}(e)?e:(Ue(t),{})}function Me(t,e){if(n=t,0!==Object.keys(n).length){var n;t.expire=String(Date.now()+we);var r=Z(t).map((function(t){return t[0]+"="+t[1]})).join(Le);e.set(r,we)}else Ue(e)}function Ue(t){t.set("",0)}var ke=[];var Pe,Be=Ie,He=5*H,We=H;var je,Ve,Fe,qe,Ge=[],ze=[];function Ke(){return Pe||(je=XMLHttpRequest.prototype.open,Ve=XMLHttpRequest.prototype.send,XMLHttpRequest.prototype.open=I((function(t,e){return this._datadog_xhr={method:t,startTime:-1,url:Yt(e)},je.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,ze.forEach((function(t){return t(e._datadog_xhr)})))};this.addEventListener("loadend",I(i)),Ge.forEach((function(t){return t(e._datadog_xhr,e)}))}return Ve.apply(this,arguments)})),Pe={beforeSend:function(t){Ge.push(t)},onRequestComplete:function(t){ze.push(t)}}),Pe}var Ye=[],$e=[];function Xe(){return Fe||(!function(){if(!window.fetch)return;qe=window.fetch,window.fetch=I((function(t,e){var n=this,r=e&&e.method||"object"==typeof t&&t.method||"GET",o=Yt("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=E(R(t)),$e.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,$e.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};Ye.forEach((function(t){return t(a)}));var s=qe.call(this,t,a.init);return s.then(I(u),I(u)),s}))}(),Fe={beforeSend:function(t){Ye.push(t)},onRequestComplete:function(t){$e.push(t)}}),Fe}function Je(t){0===t.status&&(t.traceId=void 0,t.spanId=void 0)}function Qe(t,e,n){var r;void 0!==Ze()&&function(t,e){for(var n=$t(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 an,e.spanId=new an,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 Ze(){return window.crypto||window.msCrypto}var tn,en,nn,rn,on,an=function(){function t(){this.buffer=new Uint8Array(8),Ze().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}(),un=1;function sn(t,e){var n=function(t){return{clearTracingIfCancelled:Je,traceFetch:function(e){return Qe(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 Qe(t,e,(function(t){Object.keys(t).forEach((function(e){n.setRequestHeader(e,t[e])}))}))}}}(e);!function(t,e,n){var r=Ke();r.beforeSend((function(r,i){ae(e,r.url)&&(n.traceXhr(r,i),r.requestIndex=cn(),t.notify(yt.REQUEST_STARTED,{requestIndex:r.requestIndex}))})),r.onRequestComplete((function(r){ae(e,r.url)&&(n.clearTracingIfCancelled(r),t.notify(yt.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=Xe();r.beforeSend((function(r){ae(e,r.url)&&(n.traceFetch(r),r.requestIndex=cn(),t.notify(yt.REQUEST_STARTED,{requestIndex:r.requestIndex}))})),r.onRequestComplete((function(r){ae(e,r.url)&&(n.clearTracingIfCancelled(r),t.notify(yt.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 cn(){var t=un;return un+=1,t}function fn(t,e){return t.subscribe(yt.AUTO_ACTION_COMPLETED,(function(e){return t.notify(yt.RAW_RUM_EVENT_COLLECTED,dn(e))})),e.trackInteractions&&qt(t),{addAction:function(e,n){t.notify(yt.RAW_RUM_EVENT_COLLECTED,r({savedGlobalContext:n},dn(e)))}}}function dn(t){var e=ln(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:ln(t)?void 0:t.context,rawRumEvent:c({action:{target:{name:t.name},type:t.type},date:J(t.startTime),type:Ot.ACTION},e),startTime:t.startTime}}function ln(t){return t.type!==kt.CUSTOM}function pn(t){if(!tn){var e=new _t;!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:vn(n)+" error "+r.method+" "+r.url,resource:{method:r.method,statusCode:r.status,url:r.url},source:p.NETWORK,stack:En(r.response,t)||"Failed to load",startTime:r.startTime})}Ke().onRequestComplete((function(t){return n(k.XHR,t)})),Xe().onRequestComplete((function(t){return n(k.FETCH,t)}))}(t,e),function(t){en=console.error,console.error=I((function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];en.apply(console,o([e],n)),t.notify({message:o(["console error:",e],n).map(mn).join(" "),source:p.CONSOLE,startTime:performance.now()})}))}(e),function(t){nn=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(nn)}(e),tn=function(t,e){var n=0,r=new _t;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 tn}function mn(t){return"string"==typeof t?t:t instanceof Error?E(R(t)):z(t,0,2)}function En(t,e){return t&&t.length>e.requestErrorResponseLengthLimit?t.substring(0,e.requestErrorResponseLengthLimit)+"...":t}function vn(t){return k.XHR===t?"XHR":"Fetch"}function hn(t,e){return function(t,e,n){return n.subscribe((function(e){return t.notify(yt.RAW_RUM_EVENT_COLLECTED,Tn(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(yt.RAW_RUM_EVENT_COLLECTED,r({customerContext:a,savedGlobalContext:n},Tn(u)))}}}(t,0,pn(e))}function Tn(t){return{rawRumEvent:{date:J(t.startTime),error:{message:t.message,resource:t.resource,source:t.source,stack:t.stack,type:t.type},type:Ot.ERROR},startTime:t.startTime}}function gn(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(ne).filter((function(e){return n=e,r=t.startTime,i=yn(t),n.startTime>=r&&yn(n)<=i;var n,r,i}));return 1===r.length?r[0]:2===r.length&&yn((n=r)[0])<=n[1].startTime?r[1]:void 0}}}function yn(t){return t.startTime+t.duration}function bn(t,e,n){t.subscribe(yt.REQUEST_COMPLETED,(function(e){n.isTrackedWithResource()&&t.notify(yt.RAW_RUM_EVENT_COLLECTED,function(t){var e=t.type===k.XHR?U.XHR:U.FETCH,n=gn(t),r=n?n.startTime:t.startTime,i=n?Cn(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:Ot.RESOURCE},o,i);return{startTime:r,rawRumEvent:a}}(e))})),t.subscribe(yt.PERFORMANCE_ENTRY_COLLECTED,(function(e){var r;n.isTrackedWithResource()&&"resource"===e.entryType&&("xmlhttprequest"!==(r=e).initiatorType&&"fetch"!==r.initiatorType)&&t.notify(yt.RAW_RUM_EVENT_COLLECTED,function(t){var e=Zt(t),n=Cn(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:Ot.RESOURCE},r,n);return{startTime:t.startTime,rawRumEvent:i}}(e))}))}function Cn(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:oe(t)},ee(t))};var e,n,i,o}function On(t){return void 0===t&&(t=window),rn||("hidden"===document.visibilityState?rn={timeStamp:0}:(rn={timeStamp:1/0},nt(t,M.PAGE_HIDE,(function(t){var e=t.timeStamp;rn.timeStamp=e}),{capture:!0,once:!0}).stop)),rn}function Rn(t,e){var n;function i(t){n=r(r({},n),t),e(n)}var o=function(t,e){return{stop:t.subscribe(yt.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=On();return{stop:t.subscribe(yt.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=On(),i=1/0,o=rt(e,[M.POINTER_DOWN,M.KEY_DOWN],(function(t){i=t.timeStamp}),{capture:!0,once:!0}).stop,a=t.subscribe(yt.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=On();return{stop:t.subscribe(yt.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"}(on||(on={}));var Sn=3e3,_n=5*H;function wn(t,e){var n,r=In(e,t,on.INITIAL_LOAD,document.referrer,0),i=r,o=Rn(e,(function(t){r.updateTimings(t),r.scheduleUpdate()})).stop;function a(){i.isDifferentView(t)?(i.triggerUpdate(),i.end(),i=In(e,t,on.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()})),nt(window,M.POP_STATE,t)}(a),n=a,nt(window,M.HASH_CHANGE,n),e.subscribe(yt.SESSION_RENEWED,(function(){i.end(),i=In(e,t,on.ROUTE_CHANGE,i.url)})),e.subscribe(yt.BEFORE_UNLOAD,(function(){i.triggerUpdate(),i.end()}));var u=window.setInterval(I((function(){i.triggerUpdate()})),_n);return{stop:function(){o(),i.end(),clearInterval(u)}}}function In(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(yt.VIEW_CREATED,{id:c,startTime:o,location:p,referrer:i});var m,E=j(I(O),Sn,{leading:!1}),v=E.throttled,h=E.cancel,T=St(t,(function(t){f=t,v()})).stop,g=function(t,e){var n=t===on.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,v()})),y=g.setActivityLoadingTime,b=g.setLoadEvent,C=function(t,e){var n=performance.now();return{stop:Nt(t,(function(t,r){e(t?r-n:void 0)})).stop}}(t,y).stop;function O(){l+=1,t.notify(yt.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})}return me("layout-shift")?(a=0,m=function(t,e){return{stop:t.subscribe(yt.PERFORMANCE_ENTRY_COLLECTED,(function(t){"layout-shift"!==t.entryType||t.hadRecentInput||e(t.value)})).unsubscribe}}(t,(function(t){a+=t,v()})).stop):m=G,O(),{scheduleUpdate:v,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 An(t,e,n){return t.subscribe(yt.VIEW_UPDATED,(function(e){return t.notify(yt.RAW_RUM_EVENT_COLLECTED,function(t){return{rawRumEvent:{_dd:{documentVersion:t.documentVersion},date:J(t.startTime),type:Ot.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),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))})),wn(n,t)}var Nn,Dn="rum";function Ln(t,e){var n=Ne(t.cookieOptions,Dn,(function(e){return function(t,e){var n;n=function(t){return t===Nn.NOT_TRACKED||t===Nn.TRACKED_WITH_RESOURCES||t===Nn.TRACKED_WITHOUT_RESOURCES}(e)?e:F(t.sampleRate)?F(t.resourceSampleRate)?Nn.TRACKED_WITH_RESOURCES:Nn.TRACKED_WITHOUT_RESOURCES:Nn.NOT_TRACKED;return{trackingType:n,isTracked:xn(n)}}(t,e)}));return n.renewObservable.subscribe((function(){e.notify(yt.SESSION_RENEWED)})),{getId:n.getId,isTracked:function(){return void 0!==n.getId()&&xn(n.getTrackingType())},isTrackedWithResource:function(){return void 0!==n.getId()&&n.getTrackingType()===Nn.TRACKED_WITH_RESOURCES}}}function xn(t){return t===Nn.TRACKED_WITH_RESOURCES||t===Nn.TRACKED_WITHOUT_RESOURCES}function Mn(t,e){var n=function(t,e){var n,r=o(t.rumEndpoint,(function(){return e.notify(yt.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(yt.RUM_EVENT_COLLECTED,(function(t){var e=t.rumEvent,r=t.serverRumEvent;e.type===Ot.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"}(Nn||(Nn={}));var Un={buildMode:"release",datacenter:"us",sdkVersion:"2.0.0"};var kn,Pn,Bn,Hn,Wn=jn((function(t,e){var n=new Rt,r=function(t,e){var n=dt(t,e);return{configuration:n,internalMonitoring:w(n)}}(t,Un),i=r.configuration,o=r.internalMonitoring,u=Ln(i,n);o.setExternalContextProvider((function(){return c({application_id:t.applicationId},f.findView(),e())}));var s=function(t,e,n,r,i,o){var a=function(t,e){var n,r,i,o=[],a=[];t.subscribe(yt.VIEW_CREATED,(function(t){n&&o.unshift({context:c(),endTime:t.startTime,startTime:n.startTime}),n=t,i=e.getId()})),t.subscribe(yt.VIEW_UPDATED,(function(t){n.id===t.id&&(n=t)})),t.subscribe(yt.AUTO_ACTION_CREATED,(function(t){r=t})),t.subscribe(yt.AUTO_ACTION_COMPLETED,(function(t){r&&a.unshift({context:f(),endTime:r.startTime+t.duration,startTime:r.startTime}),r=void 0})),t.subscribe(yt.AUTO_ACTION_DISCARDED,(function(){r=void 0})),t.subscribe(yt.SESSION_RENEWED,(function(){o=[],a=[],n=void 0,r=void 0}));var u=window.setInterval(I((function(){s(o,Be),s(a,He)})),We);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=Mn(r,n);ye(t,r,n,i,a,o),function(t,e){t.subscribe(yt.PERFORMANCE_ENTRY_COLLECTED,(function(e){if("longtask"===e.entryType){var n={date:J(e.startTime),longTask:{duration:q(e.duration)},type:Ot.LONG_TASK};t.notify(yt.RAW_RUM_EVENT_COLLECTED,{rawRumEvent:n,startTime:e.startTime})}}))}(n),bn(n,0,i),An(n,0,e);var s=hn(n,r).addError;return{addAction:fn(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 sn(n,i),Ee(n,i),Kt(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 jn(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=function(){},a=new Ct,u=function(t){a.add([t,f(i.get())])},s=new Ct,c=function(t){s.add([t,f(i.get())])},d=function(t){var e=r(r({},t),{onReady:function(t){t()}});return Object.defineProperty(e,"_setDebug",{get:function(){return L},enumerable:!1}),e}({init:I((function(e){var r;Tt(lt(e))&>()&&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,i.get),u=r.addAction,c=r.addError,o=r.getInternalContext,a.drain((function(t){var e=t[0],n=t[1];return u(e,n)})),s.drain((function(t){var e=t[0],n=t[1];return c(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 o(t)})),addAction:I((function(t,e){u({name:t,context:f(e),startTime:performance.now(),type:kt.CUSTOM})})),addUserAction:function(t,e){d.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),c({error:t,context:f(e),source:r,startTime:performance.now()})}))});return d}kn=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}(),Bn=Wn,Hn=kn[Pn="DD_RUM"],kn[Pn]=Bn,Hn&&Hn.q&&Hn.q.forEach((function(t){return t()}))}]); |
@@ -6,4 +6,4 @@ "use strict"; | ||
datacenter: 'us', | ||
sdkVersion: '1.26.3', | ||
sdkVersion: '2.0.0', | ||
}; | ||
//# sourceMappingURL=buildEnv.js.map |
@@ -8,3 +8,3 @@ import { Configuration, Context } from '@datadog/browser-core'; | ||
addError: ({ error, startTime, context: customerContext, source }: import("../domain/rumEventsCollection/error/errorCollection").ProvidedError, savedGlobalContext?: Context | undefined) => void; | ||
getInternalContext: (startTime?: number | undefined) => import("..").InternalContext | undefined; | ||
getInternalContext: (startTime?: number | undefined) => import("../types").InternalContext | undefined; | ||
}; | ||
@@ -11,0 +11,0 @@ export declare function startRumEventCollection(applicationId: string, location: Location, lifeCycle: LifeCycle, configuration: Configuration, session: RumSession, getGlobalContext: () => Context): { |
@@ -1,2 +0,3 @@ | ||
import { Context, ErrorSource, UserConfiguration } from '@datadog/browser-core'; | ||
import { Context, UserConfiguration } from '@datadog/browser-core'; | ||
import { ProvidedSource } from '../domain/rumEventsCollection/error/errorCollection'; | ||
import { startRum } from './rum'; | ||
@@ -13,6 +14,10 @@ export interface RumUserConfiguration extends UserConfiguration { | ||
setRumGlobalContext: (newContext: Context) => void; | ||
getInternalContext: (startTime?: number | undefined) => import("..").InternalContext | undefined; | ||
getInternalContext: (startTime?: number | undefined) => import("../types").InternalContext | undefined; | ||
addAction: (name: string, context?: Context | undefined) => void; | ||
/** | ||
* @deprecated | ||
* @see addAction | ||
*/ | ||
addUserAction: (name: string, context?: Context | undefined) => void; | ||
addError: (error: unknown, context?: Context | undefined, source?: ErrorSource.NETWORK | ErrorSource.SOURCE | ErrorSource.CUSTOM) => void; | ||
addError: (error: unknown, context?: Context | undefined, source?: ProvidedSource) => void; | ||
} & { | ||
@@ -28,8 +33,12 @@ onReady(callback: () => void): void; | ||
setRumGlobalContext: (newContext: Context) => void; | ||
getInternalContext: (startTime?: number | undefined) => import("..").InternalContext | undefined; | ||
getInternalContext: (startTime?: number | undefined) => import("../types").InternalContext | undefined; | ||
addAction: (name: string, context?: Context | undefined) => void; | ||
/** | ||
* @deprecated | ||
* @see addAction | ||
*/ | ||
addUserAction: (name: string, context?: Context | undefined) => void; | ||
addError: (error: unknown, context?: Context | undefined, source?: ErrorSource.NETWORK | ErrorSource.SOURCE | ErrorSource.CUSTOM) => void; | ||
addError: (error: unknown, context?: Context | undefined, source?: ProvidedSource) => void; | ||
} & { | ||
onReady(callback: () => void): void; | ||
}; |
@@ -60,4 +60,7 @@ "use strict"; | ||
}), | ||
/** | ||
* @deprecated | ||
* @see addAction | ||
*/ | ||
addUserAction: function (name, context) { | ||
// TODO deprecate in v2 | ||
rumGlobal.addAction(name, context); | ||
@@ -64,0 +67,0 @@ }, |
@@ -7,3 +7,2 @@ "use strict"; | ||
var assembly_1 = require("../domain/assembly"); | ||
var assemblyV2_1 = require("../domain/assemblyV2"); | ||
var internalContext_1 = require("../domain/internalContext"); | ||
@@ -34,3 +33,3 @@ var lifeCycle_1 = require("../domain/lifeCycle"); | ||
domMutationCollection_1.startDOMMutationCollection(lifeCycle); | ||
var internalContext = internalContext_1.startInternalContext(userConfiguration.applicationId, session, parentContexts, configuration); | ||
var internalContext = internalContext_1.startInternalContext(userConfiguration.applicationId, session, parentContexts); | ||
return { | ||
@@ -47,3 +46,2 @@ addAction: addAction, | ||
assembly_1.startRumAssembly(applicationId, configuration, lifeCycle, session, parentContexts, getGlobalContext); | ||
assemblyV2_1.startRumAssemblyV2(applicationId, configuration, lifeCycle, session, parentContexts, getGlobalContext); | ||
longTaskCollection_1.startLongTaskCollection(lifeCycle, configuration); | ||
@@ -50,0 +48,0 @@ resourceCollection_1.startResourceCollection(lifeCycle, configuration, session); |
@@ -15,6 +15,11 @@ "use strict"; | ||
var viewContext = parentContexts.findView(startTime); | ||
if (session.isTracked() && viewContext && viewContext.sessionId) { | ||
if (session.isTracked() && viewContext && viewContext.session.id) { | ||
var actionContext = parentContexts.findAction(startTime); | ||
var rumContext = { | ||
applicationId: applicationId, | ||
_dd: { | ||
formatVersion: 2, | ||
}, | ||
application: { | ||
id: applicationId, | ||
}, | ||
date: new Date().getTime(), | ||
@@ -31,3 +36,4 @@ service: configuration.service, | ||
: browser_core_1.combine(rumContext, viewContext, rawRumEvent); | ||
var serverRumEvent = browser_core_1.combine(savedGlobalContext || getGlobalContext(), customerContext, browser_core_1.withSnakeCaseKeys(rumEvent)); | ||
var serverRumEvent = browser_core_1.withSnakeCaseKeys(rumEvent); | ||
serverRumEvent.context = browser_core_1.combine(savedGlobalContext || getGlobalContext(), customerContext); | ||
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RUM_EVENT_COLLECTED, { rumEvent: rumEvent, serverRumEvent: serverRumEvent }); | ||
@@ -39,3 +45,3 @@ } | ||
function needToAssembleWithAction(event) { | ||
return ([types_1.RumEventCategory.ERROR, types_1.RumEventCategory.RESOURCE, types_1.RumEventCategory.LONG_TASK].indexOf(event.evt.category) !== -1); | ||
return [types_1.RumEventType.ERROR, types_1.RumEventType.RESOURCE, types_1.RumEventType.LONG_TASK].indexOf(event.type) !== -1; | ||
} | ||
@@ -42,0 +48,0 @@ function getSessionType() { |
@@ -1,2 +0,1 @@ | ||
import { Configuration } from '@datadog/browser-core'; | ||
import { InternalContext } from '../types'; | ||
@@ -9,4 +8,4 @@ import { ParentContexts } from './parentContexts'; | ||
*/ | ||
export declare function startInternalContext(applicationId: string, session: RumSession, parentContexts: ParentContexts, configuration: Configuration): { | ||
export declare function startInternalContext(applicationId: string, session: RumSession, parentContexts: ParentContexts): { | ||
get: (startTime?: number | undefined) => InternalContext | undefined; | ||
}; |
@@ -8,18 +8,10 @@ "use strict"; | ||
*/ | ||
function startInternalContext(applicationId, session, parentContexts, configuration) { | ||
function startInternalContext(applicationId, session, parentContexts) { | ||
return { | ||
get: function (startTime) { | ||
if (configuration.isEnabled('v2_format')) { | ||
var viewContext = parentContexts.findViewV2(startTime); | ||
if (session.isTracked() && viewContext && viewContext.session.id) { | ||
var actionContext = parentContexts.findActionV2(startTime); | ||
return browser_core_1.withSnakeCaseKeys(browser_core_1.combine({ applicationId: applicationId }, { sessionId: viewContext.session.id, view: viewContext.view }, actionContext ? { userAction: { id: actionContext.action.id } } : undefined)); | ||
} | ||
var viewContext = parentContexts.findView(startTime); | ||
if (session.isTracked() && viewContext && viewContext.session.id) { | ||
var actionContext = parentContexts.findAction(startTime); | ||
return browser_core_1.withSnakeCaseKeys(browser_core_1.combine({ applicationId: applicationId }, { sessionId: viewContext.session.id, view: viewContext.view }, actionContext ? { userAction: { id: actionContext.action.id } } : undefined)); | ||
} | ||
else { | ||
var viewContext = parentContexts.findView(startTime); | ||
if (session.isTracked() && viewContext && viewContext.sessionId) { | ||
return browser_core_1.withSnakeCaseKeys(browser_core_1.combine({ applicationId: applicationId }, viewContext, parentContexts.findAction(startTime))); | ||
} | ||
} | ||
}, | ||
@@ -26,0 +18,0 @@ }; |
import { Context } from '@datadog/browser-core'; | ||
import { RumPerformanceEntry } from '../browser/performanceCollection'; | ||
import { RawRumEvent, RumEvent } from '../types'; | ||
import { RawRumEventV2, RumEventV2 } from '../typesV2'; | ||
import { RequestCompleteEvent, RequestStartEvent } from './requestCollection'; | ||
@@ -21,5 +20,3 @@ import { AutoAction, AutoActionCreatedEvent } from './rumEventsCollection/action/trackActions'; | ||
RAW_RUM_EVENT_COLLECTED = 11, | ||
RAW_RUM_EVENT_V2_COLLECTED = 12, | ||
RUM_EVENT_COLLECTED = 13, | ||
RUM_EVENT_V2_COLLECTED = 14 | ||
RUM_EVENT_COLLECTED = 12 | ||
} | ||
@@ -45,8 +42,2 @@ export interface Subscription { | ||
}): void; | ||
notify(eventType: LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, data: { | ||
startTime: number; | ||
rawRumEvent: RawRumEventV2; | ||
savedGlobalContext?: Context; | ||
customerContext?: Context; | ||
}): void; | ||
notify(eventType: LifeCycleEventType.RUM_EVENT_COLLECTED, data: { | ||
@@ -56,6 +47,2 @@ rumEvent: RumEvent; | ||
}): void; | ||
notify(eventType: LifeCycleEventType.RUM_EVENT_V2_COLLECTED, data: { | ||
rumEvent: RumEventV2; | ||
serverRumEvent: Context; | ||
}): void; | ||
subscribe(eventType: LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, callback: (data: RumPerformanceEntry) => void): Subscription; | ||
@@ -75,8 +62,2 @@ subscribe(eventType: LifeCycleEventType.REQUEST_STARTED, callback: (data: RequestStartEvent) => void): Subscription; | ||
}) => void): Subscription; | ||
subscribe(eventType: LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, callback: (data: { | ||
startTime: number; | ||
rawRumEvent: RawRumEventV2; | ||
savedGlobalContext?: Context; | ||
customerContext?: Context; | ||
}) => void): Subscription; | ||
subscribe(eventType: LifeCycleEventType.RUM_EVENT_COLLECTED, callback: (data: { | ||
@@ -86,6 +67,2 @@ rumEvent: RumEvent; | ||
}) => void): Subscription; | ||
subscribe(eventType: LifeCycleEventType.RUM_EVENT_V2_COLLECTED, callback: (data: { | ||
rumEvent: RumEventV2; | ||
serverRumEvent: Context; | ||
}) => void): Subscription; | ||
} |
@@ -17,5 +17,3 @@ "use strict"; | ||
LifeCycleEventType[LifeCycleEventType["RAW_RUM_EVENT_COLLECTED"] = 11] = "RAW_RUM_EVENT_COLLECTED"; | ||
LifeCycleEventType[LifeCycleEventType["RAW_RUM_EVENT_V2_COLLECTED"] = 12] = "RAW_RUM_EVENT_V2_COLLECTED"; | ||
LifeCycleEventType[LifeCycleEventType["RUM_EVENT_COLLECTED"] = 13] = "RUM_EVENT_COLLECTED"; | ||
LifeCycleEventType[LifeCycleEventType["RUM_EVENT_V2_COLLECTED"] = 14] = "RUM_EVENT_V2_COLLECTED"; | ||
LifeCycleEventType[LifeCycleEventType["RUM_EVENT_COLLECTED"] = 12] = "RUM_EVENT_COLLECTED"; | ||
})(LifeCycleEventType = exports.LifeCycleEventType || (exports.LifeCycleEventType = {})); | ||
@@ -22,0 +20,0 @@ var LifeCycle = /** @class */ (function () { |
import { ActionContext, ViewContext } from '../types'; | ||
import { ActionContextV2, ViewContextV2 } from '../typesV2'; | ||
import { LifeCycle } from './lifeCycle'; | ||
@@ -10,7 +9,5 @@ import { RumSession } from './rumSession'; | ||
findAction: (startTime?: number) => ActionContext | undefined; | ||
findActionV2: (startTime?: number) => ActionContextV2 | undefined; | ||
findView: (startTime?: number) => ViewContext | undefined; | ||
findViewV2: (startTime?: number) => ViewContextV2 | undefined; | ||
stop: () => void; | ||
} | ||
export declare function startParentContexts(lifeCycle: LifeCycle, session: RumSession): ParentContexts; |
@@ -66,3 +66,5 @@ "use strict"; | ||
return { | ||
sessionId: currentSessionId, | ||
session: { | ||
id: currentSessionId, | ||
}, | ||
view: { | ||
@@ -76,3 +78,3 @@ id: currentView.id, | ||
function buildCurrentActionContext() { | ||
return { userAction: { id: currentAction.id } }; | ||
return { action: { id: currentAction.id } }; | ||
} | ||
@@ -97,32 +99,9 @@ function findContext(buildContext, previousContexts, currentContext, startTime) { | ||
} | ||
var parentContexts = { | ||
return { | ||
findAction: function (startTime) { | ||
return findContext(buildCurrentActionContext, previousActions, currentAction, startTime); | ||
}, | ||
findActionV2: function (startTime) { | ||
var actionContext = parentContexts.findAction(startTime); | ||
if (!actionContext) { | ||
return; | ||
} | ||
return { | ||
action: { | ||
id: actionContext.userAction.id, | ||
}, | ||
}; | ||
}, | ||
findView: function (startTime) { | ||
return findContext(buildCurrentViewContext, previousViews, currentView, startTime); | ||
}, | ||
findViewV2: function (startTime) { | ||
var viewContext = parentContexts.findView(startTime); | ||
if (!viewContext) { | ||
return; | ||
} | ||
return { | ||
session: { | ||
id: viewContext.sessionId, | ||
}, | ||
view: viewContext.view, | ||
}; | ||
}, | ||
stop: function () { | ||
@@ -132,5 +111,4 @@ window.clearInterval(clearOldContextsInterval); | ||
}; | ||
return parentContexts; | ||
} | ||
exports.startParentContexts = startParentContexts; | ||
//# sourceMappingURL=parentContexts.js.map |
@@ -6,3 +6,2 @@ "use strict"; | ||
var types_1 = require("../../../types"); | ||
var typesV2_1 = require("../../../typesV2"); | ||
var lifeCycle_1 = require("../../lifeCycle"); | ||
@@ -12,5 +11,3 @@ var trackActions_1 = require("./trackActions"); | ||
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.AUTO_ACTION_COMPLETED, function (action) { | ||
configuration.isEnabled('v2_format') | ||
? lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, processActionV2(action)) | ||
: lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processAction(action)); | ||
return lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processAction(action)); | ||
}); | ||
@@ -22,5 +19,3 @@ if (configuration.trackInteractions) { | ||
addAction: function (action, savedGlobalContext) { | ||
configuration.isEnabled('v2_format') | ||
? lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, tslib_1.__assign({ savedGlobalContext: savedGlobalContext }, processActionV2(action))) | ||
: lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, tslib_1.__assign({ savedGlobalContext: savedGlobalContext }, processAction(action))); | ||
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, tslib_1.__assign({ savedGlobalContext: savedGlobalContext }, processAction(action))); | ||
}, | ||
@@ -33,29 +28,2 @@ }; | ||
? { | ||
duration: browser_core_1.msToNs(action.duration), | ||
userAction: { | ||
id: action.id, | ||
measures: action.counts, | ||
}, | ||
} | ||
: undefined; | ||
var customerContext = !isAutoAction(action) ? action.context : undefined; | ||
var actionEvent = browser_core_1.combine({ | ||
date: browser_core_1.getTimestamp(action.startTime), | ||
evt: { | ||
category: types_1.RumEventCategory.USER_ACTION, | ||
name: action.name, | ||
}, | ||
userAction: { | ||
type: action.type, | ||
}, | ||
}, autoActionProperties); | ||
return { | ||
customerContext: customerContext, | ||
rawRumEvent: actionEvent, | ||
startTime: action.startTime, | ||
}; | ||
} | ||
function processActionV2(action) { | ||
var autoActionProperties = isAutoAction(action) | ||
? { | ||
action: { | ||
@@ -85,3 +53,3 @@ error: { | ||
date: browser_core_1.getTimestamp(action.startTime), | ||
type: typesV2_1.RumEventType.ACTION, | ||
type: types_1.RumEventType.ACTION, | ||
}, autoActionProperties); | ||
@@ -88,0 +56,0 @@ return { |
@@ -1,2 +0,2 @@ | ||
import { Configuration, Context, ErrorSource, Observable, RawError } from '@datadog/browser-core'; | ||
import { Configuration, Context, Observable, RawError } from '@datadog/browser-core'; | ||
import { LifeCycle } from '../../lifeCycle'; | ||
@@ -7,4 +7,5 @@ export interface ProvidedError { | ||
context?: Context; | ||
source: ErrorSource; | ||
source: ProvidedSource; | ||
} | ||
export declare type ProvidedSource = 'custom' | 'network' | 'source'; | ||
export declare function startErrorCollection(lifeCycle: LifeCycle, configuration: Configuration): { | ||
@@ -11,0 +12,0 @@ addError({ error, startTime, context: customerContext, source }: ProvidedError, savedGlobalContext?: Context | undefined): void; |
@@ -6,3 +6,2 @@ "use strict"; | ||
var types_1 = require("../../../types"); | ||
var typesV2_1 = require("../../../typesV2"); | ||
var lifeCycle_1 = require("../../lifeCycle"); | ||
@@ -14,7 +13,3 @@ function startErrorCollection(lifeCycle, configuration) { | ||
function doStartErrorCollection(lifeCycle, configuration, observable) { | ||
observable.subscribe(function (error) { | ||
configuration.isEnabled('v2_format') | ||
? lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, processErrorV2(error)) | ||
: lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processError(error)); | ||
}); | ||
observable.subscribe(function (error) { return lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processError(error)); }); | ||
return { | ||
@@ -24,7 +19,4 @@ addError: function (_a, savedGlobalContext) { | ||
var rawError = computeRawError(error, startTime, source); | ||
configuration.isEnabled('v2_format') | ||
? lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, tslib_1.__assign({ customerContext: customerContext, | ||
savedGlobalContext: savedGlobalContext }, processErrorV2(rawError))) | ||
: lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, tslib_1.__assign({ customerContext: customerContext, | ||
savedGlobalContext: savedGlobalContext }, processError(rawError))); | ||
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, tslib_1.__assign({ customerContext: customerContext, | ||
savedGlobalContext: savedGlobalContext }, processError(rawError))); | ||
}, | ||
@@ -39,28 +31,2 @@ }; | ||
function processError(error) { | ||
var rawRumEvent = browser_core_1.combine({ | ||
date: browser_core_1.getTimestamp(error.startTime), | ||
error: { | ||
kind: error.type, | ||
origin: error.source, | ||
stack: error.stack, | ||
}, | ||
evt: { | ||
category: types_1.RumEventCategory.ERROR, | ||
}, | ||
message: error.message, | ||
}, error.resource | ||
? { | ||
http: { | ||
method: error.resource.method, | ||
status_code: error.resource.statusCode, | ||
url: error.resource.url, | ||
}, | ||
} | ||
: undefined); | ||
return { | ||
rawRumEvent: rawRumEvent, | ||
startTime: error.startTime, | ||
}; | ||
} | ||
function processErrorV2(error) { | ||
var rawRumEvent = { | ||
@@ -75,3 +41,3 @@ date: browser_core_1.getTimestamp(error.startTime), | ||
}, | ||
type: typesV2_1.RumEventType.ERROR, | ||
type: types_1.RumEventType.ERROR, | ||
}; | ||
@@ -78,0 +44,0 @@ return { |
@@ -5,3 +5,2 @@ "use strict"; | ||
var types_1 = require("../../../types"); | ||
var typesV2_1 = require("../../../typesV2"); | ||
var lifeCycle_1 = require("../../lifeCycle"); | ||
@@ -13,28 +12,13 @@ function startLongTaskCollection(lifeCycle, configuration) { | ||
} | ||
if (configuration.isEnabled('v2_format')) { | ||
var rawRumEvent = { | ||
date: browser_core_1.getTimestamp(entry.startTime), | ||
longTask: { | ||
duration: browser_core_1.msToNs(entry.duration), | ||
}, | ||
type: typesV2_1.RumEventType.LONG_TASK, | ||
}; | ||
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, { | ||
rawRumEvent: rawRumEvent, | ||
startTime: entry.startTime, | ||
}); | ||
} | ||
else { | ||
var rawRumEvent = { | ||
date: browser_core_1.getTimestamp(entry.startTime), | ||
var rawRumEvent = { | ||
date: browser_core_1.getTimestamp(entry.startTime), | ||
longTask: { | ||
duration: browser_core_1.msToNs(entry.duration), | ||
evt: { | ||
category: types_1.RumEventCategory.LONG_TASK, | ||
}, | ||
}; | ||
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: rawRumEvent, | ||
startTime: entry.startTime, | ||
}); | ||
} | ||
}, | ||
type: types_1.RumEventType.LONG_TASK, | ||
}; | ||
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: rawRumEvent, | ||
startTime: entry.startTime, | ||
}); | ||
}); | ||
@@ -41,0 +25,0 @@ } |
@@ -6,3 +6,2 @@ "use strict"; | ||
var types_1 = require("../../../types"); | ||
var typesV2_1 = require("../../../typesV2"); | ||
var lifeCycle_1 = require("../../lifeCycle"); | ||
@@ -14,5 +13,3 @@ var matchRequestTiming_1 = require("./matchRequestTiming"); | ||
if (session.isTrackedWithResource()) { | ||
configuration.isEnabled('v2_format') | ||
? lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, processRequestV2(request)) | ||
: lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processRequest(request)); | ||
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processRequest(request)); | ||
} | ||
@@ -22,5 +19,3 @@ }); | ||
if (session.isTrackedWithResource() && entry.entryType === 'resource' && !resourceUtils_1.isRequestKind(entry)) { | ||
configuration.isEnabled('v2_format') | ||
? lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, processResourceEntryV2(entry)) | ||
: lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processResourceEntry(entry)); | ||
lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processResourceEntry(entry)); | ||
} | ||
@@ -31,3 +26,3 @@ }); | ||
function processRequest(request) { | ||
var kind = request.type === browser_core_1.RequestType.XHR ? browser_core_1.ResourceType.XHR : browser_core_1.ResourceType.FETCH; | ||
var type = request.type === browser_core_1.RequestType.XHR ? browser_core_1.ResourceType.XHR : browser_core_1.ResourceType.FETCH; | ||
var matchingTiming = matchRequestTiming_1.matchRequestTiming(request); | ||
@@ -39,26 +34,3 @@ var startTime = matchingTiming ? matchingTiming.startTime : request.startTime; | ||
date: browser_core_1.getTimestamp(startTime), | ||
duration: browser_core_1.msToNs(request.duration), | ||
evt: { | ||
category: types_1.RumEventCategory.RESOURCE, | ||
}, | ||
http: { | ||
method: request.method, | ||
statusCode: request.status, | ||
url: request.url, | ||
}, | ||
resource: { | ||
kind: kind, | ||
}, | ||
}, tracingInfo, correspondingTimingOverrides); | ||
return { startTime: startTime, rawRumEvent: resourceEvent }; | ||
} | ||
function processRequestV2(request) { | ||
var type = request.type === browser_core_1.RequestType.XHR ? browser_core_1.ResourceType.XHR : browser_core_1.ResourceType.FETCH; | ||
var matchingTiming = matchRequestTiming_1.matchRequestTiming(request); | ||
var startTime = matchingTiming ? matchingTiming.startTime : request.startTime; | ||
var correspondingTimingOverrides = matchingTiming ? computePerformanceEntryMetricsV2(matchingTiming) : undefined; | ||
var tracingInfo = computeRequestTracingInfo(request); | ||
var resourceEvent = browser_core_1.combine({ | ||
date: browser_core_1.getTimestamp(startTime), | ||
resource: { | ||
type: type, | ||
@@ -70,3 +42,3 @@ duration: browser_core_1.msToNs(request.duration), | ||
}, | ||
type: typesV2_1.RumEventType.RESOURCE, | ||
type: types_1.RumEventType.RESOURCE, | ||
}, tracingInfo, correspondingTimingOverrides); | ||
@@ -76,3 +48,3 @@ return { startTime: startTime, rawRumEvent: resourceEvent }; | ||
function processResourceEntry(entry) { | ||
var resourceKind = resourceUtils_1.computeResourceKind(entry); | ||
var type = resourceUtils_1.computeResourceKind(entry); | ||
var entryMetrics = computePerformanceEntryMetrics(entry); | ||
@@ -82,25 +54,7 @@ var tracingInfo = computeEntryTracingInfo(entry); | ||
date: browser_core_1.getTimestamp(entry.startTime), | ||
evt: { | ||
category: types_1.RumEventCategory.RESOURCE, | ||
}, | ||
http: { | ||
url: entry.name, | ||
}, | ||
resource: { | ||
kind: resourceKind, | ||
}, | ||
}, tracingInfo, entryMetrics); | ||
return { startTime: entry.startTime, rawRumEvent: resourceEvent }; | ||
} | ||
function processResourceEntryV2(entry) { | ||
var type = resourceUtils_1.computeResourceKind(entry); | ||
var entryMetrics = computePerformanceEntryMetricsV2(entry); | ||
var tracingInfo = computeEntryTracingInfo(entry); | ||
var resourceEvent = browser_core_1.combine({ | ||
date: browser_core_1.getTimestamp(entry.startTime), | ||
resource: { | ||
type: type, | ||
url: entry.name, | ||
}, | ||
type: typesV2_1.RumEventType.RESOURCE, | ||
type: types_1.RumEventType.RESOURCE, | ||
}, tracingInfo, entryMetrics); | ||
@@ -111,13 +65,2 @@ return { startTime: entry.startTime, rawRumEvent: resourceEvent }; | ||
return { | ||
duration: resourceUtils_1.computePerformanceResourceDuration(timing), | ||
http: { | ||
performance: resourceUtils_1.computePerformanceResourceDetails(timing), | ||
}, | ||
network: { | ||
bytesWritten: resourceUtils_1.computeSize(timing), | ||
}, | ||
}; | ||
} | ||
function computePerformanceEntryMetricsV2(timing) { | ||
return { | ||
resource: tslib_1.__assign({ duration: resourceUtils_1.computePerformanceResourceDuration(timing), size: resourceUtils_1.computeSize(timing) }, resourceUtils_1.computePerformanceResourceDetails(timing)), | ||
@@ -124,0 +67,0 @@ }; |
@@ -8,3 +8,3 @@ import { EventEmitter } from '@datadog/browser-core'; | ||
domComplete?: number; | ||
loadEventEnd?: number; | ||
loadEvent?: number; | ||
largestContentfulPaint?: number; | ||
@@ -11,0 +11,0 @@ firstInputDelay?: number; |
@@ -44,3 +44,3 @@ "use strict"; | ||
domInteractive: entry.domInteractive, | ||
loadEventEnd: entry.loadEventEnd, | ||
loadEvent: entry.loadEventEnd, | ||
}); | ||
@@ -47,0 +47,0 @@ } |
@@ -91,3 +91,3 @@ "use strict"; | ||
scheduleViewUpdate(); | ||
}), setActivityLoadingTime = _b.setActivityLoadingTime, setLoadEventEnd = _b.setLoadEventEnd; | ||
}), setActivityLoadingTime = _b.setActivityLoadingTime, setLoadEvent = _b.setLoadEvent; | ||
var stopActivityLoadingTimeTracking = trackActivityLoadingTime(lifeCycle, setActivityLoadingTime).stop; | ||
@@ -142,4 +142,4 @@ var stopCLSTracking; | ||
timings = newTimings; | ||
if (newTimings.loadEventEnd !== undefined) { | ||
setLoadEventEnd(newTimings.loadEventEnd); | ||
if (newTimings.loadEvent !== undefined) { | ||
setLoadEvent(newTimings.loadEvent); | ||
} | ||
@@ -176,7 +176,7 @@ }, | ||
function trackLoadingTime(loadType, callback) { | ||
var isWaitingForLoadEventEnd = loadType === ViewLoadingType.INITIAL_LOAD; | ||
var isWaitingForLoadEvent = loadType === ViewLoadingType.INITIAL_LOAD; | ||
var isWaitingForActivityLoadingTime = true; | ||
var loadingTimeCandidates = []; | ||
function invokeCallbackIfAllCandidatesAreReceived() { | ||
if (!isWaitingForActivityLoadingTime && !isWaitingForLoadEventEnd && loadingTimeCandidates.length > 0) { | ||
if (!isWaitingForActivityLoadingTime && !isWaitingForLoadEvent && loadingTimeCandidates.length > 0) { | ||
callback(Math.max.apply(Math, loadingTimeCandidates)); | ||
@@ -186,6 +186,6 @@ } | ||
return { | ||
setLoadEventEnd: function (loadEventEnd) { | ||
if (isWaitingForLoadEventEnd) { | ||
isWaitingForLoadEventEnd = false; | ||
loadingTimeCandidates.push(loadEventEnd); | ||
setLoadEvent: function (loadEvent) { | ||
if (isWaitingForLoadEvent) { | ||
isWaitingForLoadEvent = false; | ||
loadingTimeCandidates.push(loadEvent); | ||
invokeCallbackIfAllCandidatesAreReceived(); | ||
@@ -192,0 +192,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var browser_core_1 = require("@datadog/browser-core"); | ||
var types_1 = require("../../../types"); | ||
var typesV2_1 = require("../../../typesV2"); | ||
var lifeCycle_1 = require("../../lifeCycle"); | ||
@@ -11,5 +9,3 @@ var trackViews_1 = require("./trackViews"); | ||
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.VIEW_UPDATED, function (view) { | ||
configuration.isEnabled('v2_format') | ||
? lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, processViewUpdateV2(view)) | ||
: lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processViewUpdate(view)); | ||
return lifeCycle.notify(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processViewUpdate(view)); | ||
}); | ||
@@ -21,23 +17,2 @@ return trackViews_1.trackViews(location, lifeCycle); | ||
var viewEvent = { | ||
date: browser_core_1.getTimestamp(view.startTime), | ||
duration: browser_core_1.msToNs(view.duration), | ||
evt: { | ||
category: types_1.RumEventCategory.VIEW, | ||
}, | ||
rum: { | ||
documentVersion: view.documentVersion, | ||
}, | ||
view: { | ||
loadingTime: browser_core_1.msToNs(view.loadingTime), | ||
loadingType: view.loadingType, | ||
measures: tslib_1.__assign(tslib_1.__assign({}, view.eventCounts), { domComplete: browser_core_1.msToNs(view.timings.domComplete), domContentLoaded: browser_core_1.msToNs(view.timings.domContentLoaded), domInteractive: browser_core_1.msToNs(view.timings.domInteractive), firstContentfulPaint: browser_core_1.msToNs(view.timings.firstContentfulPaint), loadEventEnd: browser_core_1.msToNs(view.timings.loadEventEnd) }), | ||
}, | ||
}; | ||
return { | ||
rawRumEvent: viewEvent, | ||
startTime: view.startTime, | ||
}; | ||
} | ||
function processViewUpdateV2(view) { | ||
var viewEvent = { | ||
_dd: { | ||
@@ -47,3 +22,3 @@ documentVersion: view.documentVersion, | ||
date: browser_core_1.getTimestamp(view.startTime), | ||
type: typesV2_1.RumEventType.VIEW, | ||
type: types_1.RumEventType.VIEW, | ||
view: { | ||
@@ -63,3 +38,3 @@ action: { | ||
largestContentfulPaint: browser_core_1.msToNs(view.timings.largestContentfulPaint), | ||
loadEventEnd: browser_core_1.msToNs(view.timings.loadEventEnd), | ||
loadEvent: browser_core_1.msToNs(view.timings.loadEvent), | ||
loadingTime: browser_core_1.msToNs(view.loadingTime), | ||
@@ -66,0 +41,0 @@ loadingType: view.loadingType, |
@@ -5,3 +5,2 @@ "use strict"; | ||
var types_1 = require("../types"); | ||
var typesV2_1 = require("../typesV2"); | ||
var lifeCycle_1 = require("./lifeCycle"); | ||
@@ -18,37 +17,16 @@ function trackEventCounts(lifeCycle, callback) { | ||
var rawRumEvent = _a.rawRumEvent; | ||
switch (rawRumEvent.evt.category) { | ||
case types_1.RumEventCategory.ERROR: | ||
eventCounts.errorCount += 1; | ||
callback(eventCounts); | ||
break; | ||
case types_1.RumEventCategory.USER_ACTION: | ||
eventCounts.userActionCount += 1; | ||
callback(eventCounts); | ||
break; | ||
case types_1.RumEventCategory.LONG_TASK: | ||
eventCounts.longTaskCount += 1; | ||
callback(eventCounts); | ||
break; | ||
case types_1.RumEventCategory.RESOURCE: | ||
eventCounts.resourceCount += 1; | ||
callback(eventCounts); | ||
break; | ||
} | ||
}); | ||
var subscriptionV2 = lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, function (_a) { | ||
var rawRumEvent = _a.rawRumEvent; | ||
switch (rawRumEvent.type) { | ||
case typesV2_1.RumEventType.ERROR: | ||
case types_1.RumEventType.ERROR: | ||
eventCounts.errorCount += 1; | ||
callback(eventCounts); | ||
break; | ||
case typesV2_1.RumEventType.ACTION: | ||
case types_1.RumEventType.ACTION: | ||
eventCounts.userActionCount += 1; | ||
callback(eventCounts); | ||
break; | ||
case typesV2_1.RumEventType.LONG_TASK: | ||
case types_1.RumEventType.LONG_TASK: | ||
eventCounts.longTaskCount += 1; | ||
callback(eventCounts); | ||
break; | ||
case typesV2_1.RumEventType.RESOURCE: | ||
case types_1.RumEventType.RESOURCE: | ||
eventCounts.resourceCount += 1; | ||
@@ -62,3 +40,2 @@ callback(eventCounts); | ||
subscription.unsubscribe(); | ||
subscriptionV2.unsubscribe(); | ||
}, | ||
@@ -65,0 +42,0 @@ eventCounts: eventCounts, |
@@ -1,3 +0,1 @@ | ||
export { Datacenter, ErrorSource } from '@datadog/browser-core'; | ||
export { RumUserConfiguration, RumGlobal, datadogRum } from './boot/rum.entry'; | ||
export { InternalContext, RumEvent, RumEventCategory, RumUserActionEvent, RumViewEvent, RumResourceEvent, } from './types'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var browser_core_1 = require("@datadog/browser-core"); | ||
exports.Datacenter = browser_core_1.Datacenter; | ||
exports.ErrorSource = browser_core_1.ErrorSource; | ||
var rum_entry_1 = require("./boot/rum.entry"); | ||
exports.datadogRum = rum_entry_1.datadogRum; | ||
var types_1 = require("./types"); | ||
exports.RumEventCategory = types_1.RumEventCategory; | ||
//# sourceMappingURL=index.js.map |
@@ -6,3 +6,2 @@ "use strict"; | ||
var types_1 = require("../types"); | ||
var typesV2_1 = require("../typesV2"); | ||
function startRumBatch(configuration, lifeCycle) { | ||
@@ -12,3 +11,3 @@ var batch = makeRumBatch(configuration, lifeCycle); | ||
var rumEvent = _a.rumEvent, serverRumEvent = _a.serverRumEvent; | ||
if (rumEvent.evt.category === types_1.RumEventCategory.VIEW) { | ||
if (rumEvent.type === types_1.RumEventType.VIEW) { | ||
batch.upsert(serverRumEvent, rumEvent.view.id); | ||
@@ -20,11 +19,2 @@ } | ||
}); | ||
lifeCycle.subscribe(lifeCycle_1.LifeCycleEventType.RUM_EVENT_V2_COLLECTED, function (_a) { | ||
var rumEvent = _a.rumEvent, serverRumEvent = _a.serverRumEvent; | ||
if (rumEvent.type === typesV2_1.RumEventType.VIEW) { | ||
batch.upsert(serverRumEvent, rumEvent.view.id); | ||
} | ||
else { | ||
batch.add(serverRumEvent); | ||
} | ||
}); | ||
return { | ||
@@ -50,6 +40,3 @@ stop: function () { | ||
function withReplicaApplicationId(message) { | ||
var applicationIdOverwrite = configuration.isEnabled('v2_format') | ||
? { application: { id: replica.applicationId } } | ||
: { application_id: replica.applicationId }; | ||
return browser_core_1.combine(message, applicationIdOverwrite); | ||
return browser_core_1.combine(message, { application: { id: replica.applicationId } }); | ||
} | ||
@@ -56,0 +43,0 @@ var stopped = false; |
import { Context, ErrorSource, ResourceType } from '@datadog/browser-core'; | ||
import { ActionCounts, ActionType } from './domain/rumEventsCollection/action/trackActions'; | ||
import { PerformanceResourceDetails } from './domain/rumEventsCollection/resource/resourceUtils'; | ||
import { Timings } from './domain/rumEventsCollection/view/trackTimings'; | ||
import { ActionType } from './domain/rumEventsCollection/action/trackActions'; | ||
import { PerformanceResourceDetailsElement } from './domain/rumEventsCollection/resource/resourceUtils'; | ||
import { ViewLoadingType } from './domain/rumEventsCollection/view/trackViews'; | ||
import { EventCounts } from './domain/trackEventCounts'; | ||
export declare enum RumEventCategory { | ||
USER_ACTION = "user_action", | ||
export declare enum RumEventType { | ||
ACTION = "action", | ||
ERROR = "error", | ||
@@ -16,19 +14,18 @@ LONG_TASK = "long_task", | ||
date: number; | ||
duration: number; | ||
evt: { | ||
category: RumEventCategory.RESOURCE; | ||
}; | ||
http: { | ||
performance?: PerformanceResourceDetails; | ||
type: RumEventType.RESOURCE; | ||
resource: { | ||
type: ResourceType; | ||
id?: string; | ||
duration: number; | ||
url: string; | ||
method?: string; | ||
statusCode?: number; | ||
url: string; | ||
size?: number; | ||
redirect?: PerformanceResourceDetailsElement; | ||
dns?: PerformanceResourceDetailsElement; | ||
connect?: PerformanceResourceDetailsElement; | ||
ssl?: PerformanceResourceDetailsElement; | ||
firstByte?: PerformanceResourceDetailsElement; | ||
download?: PerformanceResourceDetailsElement; | ||
}; | ||
network?: { | ||
bytesWritten?: number; | ||
}; | ||
resource: { | ||
kind: ResourceType; | ||
id?: string; | ||
}; | ||
_dd?: { | ||
@@ -41,56 +38,70 @@ traceId: string; | ||
date: number; | ||
http?: { | ||
url: string; | ||
status_code: number; | ||
method: string; | ||
}; | ||
type: RumEventType.ERROR; | ||
error: { | ||
kind?: string; | ||
resource?: { | ||
url: string; | ||
statusCode: number; | ||
method: string; | ||
}; | ||
type?: string; | ||
stack?: string; | ||
origin: ErrorSource; | ||
source: ErrorSource; | ||
message: string; | ||
}; | ||
evt: { | ||
category: RumEventCategory.ERROR; | ||
}; | ||
message: string; | ||
} | ||
export interface RumViewEvent { | ||
date: number; | ||
duration: number; | ||
evt: { | ||
category: RumEventCategory.VIEW; | ||
type: RumEventType.VIEW; | ||
view: { | ||
loadingType: ViewLoadingType; | ||
firstContentfulPaint?: number; | ||
firstInputDelay?: number; | ||
cumulativeLayoutShift?: number; | ||
largestContentfulPaint?: number; | ||
domInteractive?: number; | ||
domContentLoaded?: number; | ||
domComplete?: number; | ||
loadEvent?: number; | ||
loadingTime?: number; | ||
timeSpent: number; | ||
error: Count; | ||
action: Count; | ||
longTask: Count; | ||
resource: Count; | ||
}; | ||
rum: { | ||
_dd: { | ||
documentVersion: number; | ||
}; | ||
view: { | ||
loadingTime?: number; | ||
loadingType: ViewLoadingType; | ||
measures: EventCounts & Timings; | ||
}; | ||
} | ||
interface Count { | ||
count: number; | ||
} | ||
export interface RumLongTaskEvent { | ||
date: number; | ||
duration: number; | ||
evt: { | ||
category: RumEventCategory.LONG_TASK; | ||
type: RumEventType.LONG_TASK; | ||
longTask: { | ||
duration: number; | ||
}; | ||
} | ||
export interface RumUserActionEvent { | ||
export interface RumActionEvent { | ||
date?: number; | ||
duration?: number; | ||
evt: { | ||
category: RumEventCategory.USER_ACTION; | ||
name: string; | ||
}; | ||
userAction: { | ||
type: RumEventType.ACTION; | ||
action: { | ||
id?: string; | ||
type: ActionType; | ||
measures?: ActionCounts; | ||
loadingTime?: number; | ||
error?: Count; | ||
longTask?: Count; | ||
resource?: Count; | ||
target: { | ||
name: string; | ||
}; | ||
}; | ||
} | ||
export declare type RawRumEvent = RumErrorEvent | RumResourceEvent | RumViewEvent | RumLongTaskEvent | RumUserActionEvent; | ||
export declare type RawRumEvent = RumErrorEvent | RumResourceEvent | RumViewEvent | RumLongTaskEvent | RumActionEvent; | ||
export interface RumContext { | ||
applicationId: string; | ||
date: number; | ||
application: { | ||
id: string; | ||
}; | ||
service?: string; | ||
@@ -100,5 +111,10 @@ session: { | ||
}; | ||
_dd: { | ||
formatVersion: 2; | ||
}; | ||
} | ||
export interface ViewContext extends Context { | ||
sessionId: string | undefined; | ||
session: { | ||
id: string | undefined; | ||
}; | ||
view: { | ||
@@ -111,7 +127,7 @@ id: string; | ||
export interface ActionContext extends Context { | ||
userAction: { | ||
action: { | ||
id: string; | ||
}; | ||
} | ||
export declare type RumEvent = RumErrorEvent & ActionContext & ViewContext & RumContext | RumResourceEvent & ActionContext & ViewContext & RumContext | RumViewEvent & ViewContext & RumContext | RumLongTaskEvent & ActionContext & ViewContext & RumContext | RumUserActionEvent & ViewContext & RumContext; | ||
export declare type RumEvent = RumErrorEvent & ActionContext & ViewContext & RumContext | RumResourceEvent & ActionContext & ViewContext & RumContext | RumViewEvent & ViewContext & RumContext | RumLongTaskEvent & ActionContext & ViewContext & RumContext | RumActionEvent & ViewContext & RumContext; | ||
export interface InternalContext { | ||
@@ -129,1 +145,2 @@ application_id: string; | ||
} | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var RumEventCategory; | ||
(function (RumEventCategory) { | ||
RumEventCategory["USER_ACTION"] = "user_action"; | ||
RumEventCategory["ERROR"] = "error"; | ||
RumEventCategory["LONG_TASK"] = "long_task"; | ||
RumEventCategory["VIEW"] = "view"; | ||
RumEventCategory["RESOURCE"] = "resource"; | ||
})(RumEventCategory = exports.RumEventCategory || (exports.RumEventCategory = {})); | ||
var RumEventType; | ||
(function (RumEventType) { | ||
RumEventType["ACTION"] = "action"; | ||
RumEventType["ERROR"] = "error"; | ||
RumEventType["LONG_TASK"] = "long_task"; | ||
RumEventType["VIEW"] = "view"; | ||
RumEventType["RESOURCE"] = "resource"; | ||
})(RumEventType = exports.RumEventType || (exports.RumEventType = {})); | ||
//# sourceMappingURL=types.js.map |
export var buildEnv = { | ||
buildMode: 'release', | ||
datacenter: 'us', | ||
sdkVersion: '1.26.3', | ||
sdkVersion: '2.0.0', | ||
}; | ||
//# sourceMappingURL=buildEnv.js.map |
@@ -8,3 +8,3 @@ import { Configuration, Context } from '@datadog/browser-core'; | ||
addError: ({ error, startTime, context: customerContext, source }: import("../domain/rumEventsCollection/error/errorCollection").ProvidedError, savedGlobalContext?: Context | undefined) => void; | ||
getInternalContext: (startTime?: number | undefined) => import("..").InternalContext | undefined; | ||
getInternalContext: (startTime?: number | undefined) => import("../types").InternalContext | undefined; | ||
}; | ||
@@ -11,0 +11,0 @@ export declare function startRumEventCollection(applicationId: string, location: Location, lifeCycle: LifeCycle, configuration: Configuration, session: RumSession, getGlobalContext: () => Context): { |
@@ -1,2 +0,3 @@ | ||
import { Context, ErrorSource, UserConfiguration } from '@datadog/browser-core'; | ||
import { Context, UserConfiguration } from '@datadog/browser-core'; | ||
import { ProvidedSource } from '../domain/rumEventsCollection/error/errorCollection'; | ||
import { startRum } from './rum'; | ||
@@ -13,6 +14,10 @@ export interface RumUserConfiguration extends UserConfiguration { | ||
setRumGlobalContext: (newContext: Context) => void; | ||
getInternalContext: (startTime?: number | undefined) => import("..").InternalContext | undefined; | ||
getInternalContext: (startTime?: number | undefined) => import("../types").InternalContext | undefined; | ||
addAction: (name: string, context?: Context | undefined) => void; | ||
/** | ||
* @deprecated | ||
* @see addAction | ||
*/ | ||
addUserAction: (name: string, context?: Context | undefined) => void; | ||
addError: (error: unknown, context?: Context | undefined, source?: ErrorSource.NETWORK | ErrorSource.SOURCE | ErrorSource.CUSTOM) => void; | ||
addError: (error: unknown, context?: Context | undefined, source?: ProvidedSource) => void; | ||
} & { | ||
@@ -28,8 +33,12 @@ onReady(callback: () => void): void; | ||
setRumGlobalContext: (newContext: Context) => void; | ||
getInternalContext: (startTime?: number | undefined) => import("..").InternalContext | undefined; | ||
getInternalContext: (startTime?: number | undefined) => import("../types").InternalContext | undefined; | ||
addAction: (name: string, context?: Context | undefined) => void; | ||
/** | ||
* @deprecated | ||
* @see addAction | ||
*/ | ||
addUserAction: (name: string, context?: Context | undefined) => void; | ||
addError: (error: unknown, context?: Context | undefined, source?: ErrorSource.NETWORK | ErrorSource.SOURCE | ErrorSource.CUSTOM) => void; | ||
addError: (error: unknown, context?: Context | undefined, source?: ProvidedSource) => void; | ||
} & { | ||
onReady(callback: () => void): void; | ||
}; |
@@ -58,4 +58,7 @@ import { BoundedBuffer, buildCookieOptions, checkCookiesAuthorized, checkIsNotLocalFile, createContextManager, deepClone, defineGlobal, ErrorSource, getGlobalObject, isPercentage, makeGlobal, monitor, } from '@datadog/browser-core'; | ||
}), | ||
/** | ||
* @deprecated | ||
* @see addAction | ||
*/ | ||
addUserAction: function (name, context) { | ||
// TODO deprecate in v2 | ||
rumGlobal.addAction(name, context); | ||
@@ -62,0 +65,0 @@ }, |
@@ -5,3 +5,2 @@ import { combine, commonInit } from '@datadog/browser-core'; | ||
import { startRumAssembly } from '../domain/assembly'; | ||
import { startRumAssemblyV2 } from '../domain/assemblyV2'; | ||
import { startInternalContext } from '../domain/internalContext'; | ||
@@ -32,3 +31,3 @@ import { LifeCycle } from '../domain/lifeCycle'; | ||
startDOMMutationCollection(lifeCycle); | ||
var internalContext = startInternalContext(userConfiguration.applicationId, session, parentContexts, configuration); | ||
var internalContext = startInternalContext(userConfiguration.applicationId, session, parentContexts); | ||
return { | ||
@@ -44,3 +43,2 @@ addAction: addAction, | ||
startRumAssembly(applicationId, configuration, lifeCycle, session, parentContexts, getGlobalContext); | ||
startRumAssemblyV2(applicationId, configuration, lifeCycle, session, parentContexts, getGlobalContext); | ||
startLongTaskCollection(lifeCycle, configuration); | ||
@@ -47,0 +45,0 @@ startResourceCollection(lifeCycle, configuration, session); |
import { combine, withSnakeCaseKeys } from '@datadog/browser-core'; | ||
import { RumEventCategory } from '../types'; | ||
import { RumEventType } from '../types'; | ||
import { LifeCycleEventType } from './lifeCycle'; | ||
@@ -13,6 +13,11 @@ var SessionType; | ||
var viewContext = parentContexts.findView(startTime); | ||
if (session.isTracked() && viewContext && viewContext.sessionId) { | ||
if (session.isTracked() && viewContext && viewContext.session.id) { | ||
var actionContext = parentContexts.findAction(startTime); | ||
var rumContext = { | ||
applicationId: applicationId, | ||
_dd: { | ||
formatVersion: 2, | ||
}, | ||
application: { | ||
id: applicationId, | ||
}, | ||
date: new Date().getTime(), | ||
@@ -29,3 +34,4 @@ service: configuration.service, | ||
: combine(rumContext, viewContext, rawRumEvent); | ||
var serverRumEvent = combine(savedGlobalContext || getGlobalContext(), customerContext, withSnakeCaseKeys(rumEvent)); | ||
var serverRumEvent = withSnakeCaseKeys(rumEvent); | ||
serverRumEvent.context = combine(savedGlobalContext || getGlobalContext(), customerContext); | ||
lifeCycle.notify(LifeCycleEventType.RUM_EVENT_COLLECTED, { rumEvent: rumEvent, serverRumEvent: serverRumEvent }); | ||
@@ -36,3 +42,3 @@ } | ||
function needToAssembleWithAction(event) { | ||
return ([RumEventCategory.ERROR, RumEventCategory.RESOURCE, RumEventCategory.LONG_TASK].indexOf(event.evt.category) !== -1); | ||
return [RumEventType.ERROR, RumEventType.RESOURCE, RumEventType.LONG_TASK].indexOf(event.type) !== -1; | ||
} | ||
@@ -39,0 +45,0 @@ function getSessionType() { |
@@ -1,2 +0,1 @@ | ||
import { Configuration } from '@datadog/browser-core'; | ||
import { InternalContext } from '../types'; | ||
@@ -9,4 +8,4 @@ import { ParentContexts } from './parentContexts'; | ||
*/ | ||
export declare function startInternalContext(applicationId: string, session: RumSession, parentContexts: ParentContexts, configuration: Configuration): { | ||
export declare function startInternalContext(applicationId: string, session: RumSession, parentContexts: ParentContexts): { | ||
get: (startTime?: number | undefined) => InternalContext | undefined; | ||
}; |
@@ -6,18 +6,10 @@ import { combine, withSnakeCaseKeys } from '@datadog/browser-core'; | ||
*/ | ||
export function startInternalContext(applicationId, session, parentContexts, configuration) { | ||
export function startInternalContext(applicationId, session, parentContexts) { | ||
return { | ||
get: function (startTime) { | ||
if (configuration.isEnabled('v2_format')) { | ||
var viewContext = parentContexts.findViewV2(startTime); | ||
if (session.isTracked() && viewContext && viewContext.session.id) { | ||
var actionContext = parentContexts.findActionV2(startTime); | ||
return withSnakeCaseKeys(combine({ applicationId: applicationId }, { sessionId: viewContext.session.id, view: viewContext.view }, actionContext ? { userAction: { id: actionContext.action.id } } : undefined)); | ||
} | ||
var viewContext = parentContexts.findView(startTime); | ||
if (session.isTracked() && viewContext && viewContext.session.id) { | ||
var actionContext = parentContexts.findAction(startTime); | ||
return withSnakeCaseKeys(combine({ applicationId: applicationId }, { sessionId: viewContext.session.id, view: viewContext.view }, actionContext ? { userAction: { id: actionContext.action.id } } : undefined)); | ||
} | ||
else { | ||
var viewContext = parentContexts.findView(startTime); | ||
if (session.isTracked() && viewContext && viewContext.sessionId) { | ||
return withSnakeCaseKeys(combine({ applicationId: applicationId }, viewContext, parentContexts.findAction(startTime))); | ||
} | ||
} | ||
}, | ||
@@ -24,0 +16,0 @@ }; |
import { Context } from '@datadog/browser-core'; | ||
import { RumPerformanceEntry } from '../browser/performanceCollection'; | ||
import { RawRumEvent, RumEvent } from '../types'; | ||
import { RawRumEventV2, RumEventV2 } from '../typesV2'; | ||
import { RequestCompleteEvent, RequestStartEvent } from './requestCollection'; | ||
@@ -21,5 +20,3 @@ import { AutoAction, AutoActionCreatedEvent } from './rumEventsCollection/action/trackActions'; | ||
RAW_RUM_EVENT_COLLECTED = 11, | ||
RAW_RUM_EVENT_V2_COLLECTED = 12, | ||
RUM_EVENT_COLLECTED = 13, | ||
RUM_EVENT_V2_COLLECTED = 14 | ||
RUM_EVENT_COLLECTED = 12 | ||
} | ||
@@ -45,8 +42,2 @@ export interface Subscription { | ||
}): void; | ||
notify(eventType: LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, data: { | ||
startTime: number; | ||
rawRumEvent: RawRumEventV2; | ||
savedGlobalContext?: Context; | ||
customerContext?: Context; | ||
}): void; | ||
notify(eventType: LifeCycleEventType.RUM_EVENT_COLLECTED, data: { | ||
@@ -56,6 +47,2 @@ rumEvent: RumEvent; | ||
}): void; | ||
notify(eventType: LifeCycleEventType.RUM_EVENT_V2_COLLECTED, data: { | ||
rumEvent: RumEventV2; | ||
serverRumEvent: Context; | ||
}): void; | ||
subscribe(eventType: LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, callback: (data: RumPerformanceEntry) => void): Subscription; | ||
@@ -75,8 +62,2 @@ subscribe(eventType: LifeCycleEventType.REQUEST_STARTED, callback: (data: RequestStartEvent) => void): Subscription; | ||
}) => void): Subscription; | ||
subscribe(eventType: LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, callback: (data: { | ||
startTime: number; | ||
rawRumEvent: RawRumEventV2; | ||
savedGlobalContext?: Context; | ||
customerContext?: Context; | ||
}) => void): Subscription; | ||
subscribe(eventType: LifeCycleEventType.RUM_EVENT_COLLECTED, callback: (data: { | ||
@@ -86,6 +67,2 @@ rumEvent: RumEvent; | ||
}) => void): Subscription; | ||
subscribe(eventType: LifeCycleEventType.RUM_EVENT_V2_COLLECTED, callback: (data: { | ||
rumEvent: RumEventV2; | ||
serverRumEvent: Context; | ||
}) => void): Subscription; | ||
} |
@@ -15,5 +15,3 @@ export var LifeCycleEventType; | ||
LifeCycleEventType[LifeCycleEventType["RAW_RUM_EVENT_COLLECTED"] = 11] = "RAW_RUM_EVENT_COLLECTED"; | ||
LifeCycleEventType[LifeCycleEventType["RAW_RUM_EVENT_V2_COLLECTED"] = 12] = "RAW_RUM_EVENT_V2_COLLECTED"; | ||
LifeCycleEventType[LifeCycleEventType["RUM_EVENT_COLLECTED"] = 13] = "RUM_EVENT_COLLECTED"; | ||
LifeCycleEventType[LifeCycleEventType["RUM_EVENT_V2_COLLECTED"] = 14] = "RUM_EVENT_V2_COLLECTED"; | ||
LifeCycleEventType[LifeCycleEventType["RUM_EVENT_COLLECTED"] = 12] = "RUM_EVENT_COLLECTED"; | ||
})(LifeCycleEventType || (LifeCycleEventType = {})); | ||
@@ -20,0 +18,0 @@ var LifeCycle = /** @class */ (function () { |
import { ActionContext, ViewContext } from '../types'; | ||
import { ActionContextV2, ViewContextV2 } from '../typesV2'; | ||
import { LifeCycle } from './lifeCycle'; | ||
@@ -10,7 +9,5 @@ import { RumSession } from './rumSession'; | ||
findAction: (startTime?: number) => ActionContext | undefined; | ||
findActionV2: (startTime?: number) => ActionContextV2 | undefined; | ||
findView: (startTime?: number) => ViewContext | undefined; | ||
findViewV2: (startTime?: number) => ViewContextV2 | undefined; | ||
stop: () => void; | ||
} | ||
export declare function startParentContexts(lifeCycle: LifeCycle, session: RumSession): ParentContexts; |
@@ -64,3 +64,5 @@ import { monitor, ONE_MINUTE, SESSION_TIME_OUT_DELAY } from '@datadog/browser-core'; | ||
return { | ||
sessionId: currentSessionId, | ||
session: { | ||
id: currentSessionId, | ||
}, | ||
view: { | ||
@@ -74,3 +76,3 @@ id: currentView.id, | ||
function buildCurrentActionContext() { | ||
return { userAction: { id: currentAction.id } }; | ||
return { action: { id: currentAction.id } }; | ||
} | ||
@@ -95,32 +97,9 @@ function findContext(buildContext, previousContexts, currentContext, startTime) { | ||
} | ||
var parentContexts = { | ||
return { | ||
findAction: function (startTime) { | ||
return findContext(buildCurrentActionContext, previousActions, currentAction, startTime); | ||
}, | ||
findActionV2: function (startTime) { | ||
var actionContext = parentContexts.findAction(startTime); | ||
if (!actionContext) { | ||
return; | ||
} | ||
return { | ||
action: { | ||
id: actionContext.userAction.id, | ||
}, | ||
}; | ||
}, | ||
findView: function (startTime) { | ||
return findContext(buildCurrentViewContext, previousViews, currentView, startTime); | ||
}, | ||
findViewV2: function (startTime) { | ||
var viewContext = parentContexts.findView(startTime); | ||
if (!viewContext) { | ||
return; | ||
} | ||
return { | ||
session: { | ||
id: viewContext.sessionId, | ||
}, | ||
view: viewContext.view, | ||
}; | ||
}, | ||
stop: function () { | ||
@@ -130,4 +109,3 @@ window.clearInterval(clearOldContextsInterval); | ||
}; | ||
return parentContexts; | ||
} | ||
//# sourceMappingURL=parentContexts.js.map |
import { __assign } from "tslib"; | ||
import { combine, getTimestamp, msToNs } from '@datadog/browser-core'; | ||
import { RumEventCategory } from '../../../types'; | ||
import { RumEventType } from '../../../typesV2'; | ||
import { RumEventType } from '../../../types'; | ||
import { LifeCycleEventType } from '../../lifeCycle'; | ||
@@ -9,5 +8,3 @@ import { ActionType, trackActions } from './trackActions'; | ||
lifeCycle.subscribe(LifeCycleEventType.AUTO_ACTION_COMPLETED, function (action) { | ||
configuration.isEnabled('v2_format') | ||
? lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, processActionV2(action)) | ||
: lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processAction(action)); | ||
return lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processAction(action)); | ||
}); | ||
@@ -19,5 +16,3 @@ if (configuration.trackInteractions) { | ||
addAction: function (action, savedGlobalContext) { | ||
configuration.isEnabled('v2_format') | ||
? lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, __assign({ savedGlobalContext: savedGlobalContext }, processActionV2(action))) | ||
: lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, __assign({ savedGlobalContext: savedGlobalContext }, processAction(action))); | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, __assign({ savedGlobalContext: savedGlobalContext }, processAction(action))); | ||
}, | ||
@@ -29,29 +24,2 @@ }; | ||
? { | ||
duration: msToNs(action.duration), | ||
userAction: { | ||
id: action.id, | ||
measures: action.counts, | ||
}, | ||
} | ||
: undefined; | ||
var customerContext = !isAutoAction(action) ? action.context : undefined; | ||
var actionEvent = combine({ | ||
date: getTimestamp(action.startTime), | ||
evt: { | ||
category: RumEventCategory.USER_ACTION, | ||
name: action.name, | ||
}, | ||
userAction: { | ||
type: action.type, | ||
}, | ||
}, autoActionProperties); | ||
return { | ||
customerContext: customerContext, | ||
rawRumEvent: actionEvent, | ||
startTime: action.startTime, | ||
}; | ||
} | ||
function processActionV2(action) { | ||
var autoActionProperties = isAutoAction(action) | ||
? { | ||
action: { | ||
@@ -58,0 +26,0 @@ error: { |
@@ -1,2 +0,2 @@ | ||
import { Configuration, Context, ErrorSource, Observable, RawError } from '@datadog/browser-core'; | ||
import { Configuration, Context, Observable, RawError } from '@datadog/browser-core'; | ||
import { LifeCycle } from '../../lifeCycle'; | ||
@@ -7,4 +7,5 @@ export interface ProvidedError { | ||
context?: Context; | ||
source: ErrorSource; | ||
source: ProvidedSource; | ||
} | ||
export declare type ProvidedSource = 'custom' | 'network' | 'source'; | ||
export declare function startErrorCollection(lifeCycle: LifeCycle, configuration: Configuration): { | ||
@@ -11,0 +12,0 @@ addError({ error, startTime, context: customerContext, source }: ProvidedError, savedGlobalContext?: Context | undefined): void; |
import { __assign } from "tslib"; | ||
import { combine, computeStackTrace, formatUnknownError, getTimestamp, startAutomaticErrorCollection, } from '@datadog/browser-core'; | ||
import { RumEventCategory } from '../../../types'; | ||
import { RumEventType } from '../../../typesV2'; | ||
import { computeStackTrace, formatUnknownError, getTimestamp, startAutomaticErrorCollection, } from '@datadog/browser-core'; | ||
import { RumEventType } from '../../../types'; | ||
import { LifeCycleEventType } from '../../lifeCycle'; | ||
@@ -10,7 +9,3 @@ export function startErrorCollection(lifeCycle, configuration) { | ||
export function doStartErrorCollection(lifeCycle, configuration, observable) { | ||
observable.subscribe(function (error) { | ||
configuration.isEnabled('v2_format') | ||
? lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, processErrorV2(error)) | ||
: lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processError(error)); | ||
}); | ||
observable.subscribe(function (error) { return lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processError(error)); }); | ||
return { | ||
@@ -20,7 +15,4 @@ addError: function (_a, savedGlobalContext) { | ||
var rawError = computeRawError(error, startTime, source); | ||
configuration.isEnabled('v2_format') | ||
? lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, __assign({ customerContext: customerContext, | ||
savedGlobalContext: savedGlobalContext }, processErrorV2(rawError))) | ||
: lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, __assign({ customerContext: customerContext, | ||
savedGlobalContext: savedGlobalContext }, processError(rawError))); | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, __assign({ customerContext: customerContext, | ||
savedGlobalContext: savedGlobalContext }, processError(rawError))); | ||
}, | ||
@@ -34,28 +26,2 @@ }; | ||
function processError(error) { | ||
var rawRumEvent = combine({ | ||
date: getTimestamp(error.startTime), | ||
error: { | ||
kind: error.type, | ||
origin: error.source, | ||
stack: error.stack, | ||
}, | ||
evt: { | ||
category: RumEventCategory.ERROR, | ||
}, | ||
message: error.message, | ||
}, error.resource | ||
? { | ||
http: { | ||
method: error.resource.method, | ||
status_code: error.resource.statusCode, | ||
url: error.resource.url, | ||
}, | ||
} | ||
: undefined); | ||
return { | ||
rawRumEvent: rawRumEvent, | ||
startTime: error.startTime, | ||
}; | ||
} | ||
function processErrorV2(error) { | ||
var rawRumEvent = { | ||
@@ -62,0 +28,0 @@ date: getTimestamp(error.startTime), |
import { getTimestamp, msToNs } from '@datadog/browser-core'; | ||
import { RumEventCategory } from '../../../types'; | ||
import { RumEventType } from '../../../typesV2'; | ||
import { RumEventType } from '../../../types'; | ||
import { LifeCycleEventType } from '../../lifeCycle'; | ||
@@ -10,30 +9,15 @@ export function startLongTaskCollection(lifeCycle, configuration) { | ||
} | ||
if (configuration.isEnabled('v2_format')) { | ||
var rawRumEvent = { | ||
date: getTimestamp(entry.startTime), | ||
longTask: { | ||
duration: msToNs(entry.duration), | ||
}, | ||
type: RumEventType.LONG_TASK, | ||
}; | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, { | ||
rawRumEvent: rawRumEvent, | ||
startTime: entry.startTime, | ||
}); | ||
} | ||
else { | ||
var rawRumEvent = { | ||
date: getTimestamp(entry.startTime), | ||
var rawRumEvent = { | ||
date: getTimestamp(entry.startTime), | ||
longTask: { | ||
duration: msToNs(entry.duration), | ||
evt: { | ||
category: RumEventCategory.LONG_TASK, | ||
}, | ||
}; | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: rawRumEvent, | ||
startTime: entry.startTime, | ||
}); | ||
} | ||
}, | ||
type: RumEventType.LONG_TASK, | ||
}; | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: rawRumEvent, | ||
startTime: entry.startTime, | ||
}); | ||
}); | ||
} | ||
//# sourceMappingURL=longTaskCollection.js.map |
import { __assign } from "tslib"; | ||
import { combine, generateUUID, getTimestamp, msToNs, RequestType, ResourceType, } from '@datadog/browser-core'; | ||
import { RumEventCategory } from '../../../types'; | ||
import { RumEventType } from '../../../typesV2'; | ||
import { RumEventType } from '../../../types'; | ||
import { LifeCycleEventType } from '../../lifeCycle'; | ||
@@ -11,5 +10,3 @@ import { matchRequestTiming } from './matchRequestTiming'; | ||
if (session.isTrackedWithResource()) { | ||
configuration.isEnabled('v2_format') | ||
? lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, processRequestV2(request)) | ||
: lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processRequest(request)); | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processRequest(request)); | ||
} | ||
@@ -19,5 +16,3 @@ }); | ||
if (session.isTrackedWithResource() && entry.entryType === 'resource' && !isRequestKind(entry)) { | ||
configuration.isEnabled('v2_format') | ||
? lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, processResourceEntryV2(entry)) | ||
: lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processResourceEntry(entry)); | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processResourceEntry(entry)); | ||
} | ||
@@ -27,3 +22,3 @@ }); | ||
function processRequest(request) { | ||
var kind = request.type === RequestType.XHR ? ResourceType.XHR : ResourceType.FETCH; | ||
var type = request.type === RequestType.XHR ? ResourceType.XHR : ResourceType.FETCH; | ||
var matchingTiming = matchRequestTiming(request); | ||
@@ -35,26 +30,3 @@ var startTime = matchingTiming ? matchingTiming.startTime : request.startTime; | ||
date: getTimestamp(startTime), | ||
duration: msToNs(request.duration), | ||
evt: { | ||
category: RumEventCategory.RESOURCE, | ||
}, | ||
http: { | ||
method: request.method, | ||
statusCode: request.status, | ||
url: request.url, | ||
}, | ||
resource: { | ||
kind: kind, | ||
}, | ||
}, tracingInfo, correspondingTimingOverrides); | ||
return { startTime: startTime, rawRumEvent: resourceEvent }; | ||
} | ||
function processRequestV2(request) { | ||
var type = request.type === RequestType.XHR ? ResourceType.XHR : ResourceType.FETCH; | ||
var matchingTiming = matchRequestTiming(request); | ||
var startTime = matchingTiming ? matchingTiming.startTime : request.startTime; | ||
var correspondingTimingOverrides = matchingTiming ? computePerformanceEntryMetricsV2(matchingTiming) : undefined; | ||
var tracingInfo = computeRequestTracingInfo(request); | ||
var resourceEvent = combine({ | ||
date: getTimestamp(startTime), | ||
resource: { | ||
type: type, | ||
@@ -71,3 +43,3 @@ duration: msToNs(request.duration), | ||
function processResourceEntry(entry) { | ||
var resourceKind = computeResourceKind(entry); | ||
var type = computeResourceKind(entry); | ||
var entryMetrics = computePerformanceEntryMetrics(entry); | ||
@@ -77,21 +49,3 @@ var tracingInfo = computeEntryTracingInfo(entry); | ||
date: getTimestamp(entry.startTime), | ||
evt: { | ||
category: RumEventCategory.RESOURCE, | ||
}, | ||
http: { | ||
url: entry.name, | ||
}, | ||
resource: { | ||
kind: resourceKind, | ||
}, | ||
}, tracingInfo, entryMetrics); | ||
return { startTime: entry.startTime, rawRumEvent: resourceEvent }; | ||
} | ||
function processResourceEntryV2(entry) { | ||
var type = computeResourceKind(entry); | ||
var entryMetrics = computePerformanceEntryMetricsV2(entry); | ||
var tracingInfo = computeEntryTracingInfo(entry); | ||
var resourceEvent = combine({ | ||
date: getTimestamp(entry.startTime), | ||
resource: { | ||
type: type, | ||
@@ -106,13 +60,2 @@ url: entry.name, | ||
return { | ||
duration: computePerformanceResourceDuration(timing), | ||
http: { | ||
performance: computePerformanceResourceDetails(timing), | ||
}, | ||
network: { | ||
bytesWritten: computeSize(timing), | ||
}, | ||
}; | ||
} | ||
function computePerformanceEntryMetricsV2(timing) { | ||
return { | ||
resource: __assign({ duration: computePerformanceResourceDuration(timing), size: computeSize(timing) }, computePerformanceResourceDetails(timing)), | ||
@@ -119,0 +62,0 @@ }; |
@@ -8,3 +8,3 @@ import { EventEmitter } from '@datadog/browser-core'; | ||
domComplete?: number; | ||
loadEventEnd?: number; | ||
loadEvent?: number; | ||
largestContentfulPaint?: number; | ||
@@ -11,0 +11,0 @@ firstInputDelay?: number; |
@@ -41,3 +41,3 @@ import { __assign } from "tslib"; | ||
domInteractive: entry.domInteractive, | ||
loadEventEnd: entry.loadEventEnd, | ||
loadEvent: entry.loadEventEnd, | ||
}); | ||
@@ -44,0 +44,0 @@ } |
@@ -88,3 +88,3 @@ import { __assign } from "tslib"; | ||
scheduleViewUpdate(); | ||
}), setActivityLoadingTime = _b.setActivityLoadingTime, setLoadEventEnd = _b.setLoadEventEnd; | ||
}), setActivityLoadingTime = _b.setActivityLoadingTime, setLoadEvent = _b.setLoadEvent; | ||
var stopActivityLoadingTimeTracking = trackActivityLoadingTime(lifeCycle, setActivityLoadingTime).stop; | ||
@@ -139,4 +139,4 @@ var stopCLSTracking; | ||
timings = newTimings; | ||
if (newTimings.loadEventEnd !== undefined) { | ||
setLoadEventEnd(newTimings.loadEventEnd); | ||
if (newTimings.loadEvent !== undefined) { | ||
setLoadEvent(newTimings.loadEvent); | ||
} | ||
@@ -173,7 +173,7 @@ }, | ||
function trackLoadingTime(loadType, callback) { | ||
var isWaitingForLoadEventEnd = loadType === ViewLoadingType.INITIAL_LOAD; | ||
var isWaitingForLoadEvent = loadType === ViewLoadingType.INITIAL_LOAD; | ||
var isWaitingForActivityLoadingTime = true; | ||
var loadingTimeCandidates = []; | ||
function invokeCallbackIfAllCandidatesAreReceived() { | ||
if (!isWaitingForActivityLoadingTime && !isWaitingForLoadEventEnd && loadingTimeCandidates.length > 0) { | ||
if (!isWaitingForActivityLoadingTime && !isWaitingForLoadEvent && loadingTimeCandidates.length > 0) { | ||
callback(Math.max.apply(Math, loadingTimeCandidates)); | ||
@@ -183,6 +183,6 @@ } | ||
return { | ||
setLoadEventEnd: function (loadEventEnd) { | ||
if (isWaitingForLoadEventEnd) { | ||
isWaitingForLoadEventEnd = false; | ||
loadingTimeCandidates.push(loadEventEnd); | ||
setLoadEvent: function (loadEvent) { | ||
if (isWaitingForLoadEvent) { | ||
isWaitingForLoadEvent = false; | ||
loadingTimeCandidates.push(loadEvent); | ||
invokeCallbackIfAllCandidatesAreReceived(); | ||
@@ -189,0 +189,0 @@ } |
@@ -1,5 +0,3 @@ | ||
import { __assign } from "tslib"; | ||
import { getTimestamp, msToNs } from '@datadog/browser-core'; | ||
import { RumEventCategory } from '../../../types'; | ||
import { RumEventType } from '../../../typesV2'; | ||
import { RumEventType } from '../../../types'; | ||
import { LifeCycleEventType } from '../../lifeCycle'; | ||
@@ -9,5 +7,3 @@ import { trackViews } from './trackViews'; | ||
lifeCycle.subscribe(LifeCycleEventType.VIEW_UPDATED, function (view) { | ||
configuration.isEnabled('v2_format') | ||
? lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, processViewUpdateV2(view)) | ||
: lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processViewUpdate(view)); | ||
return lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processViewUpdate(view)); | ||
}); | ||
@@ -18,23 +14,2 @@ return trackViews(location, lifeCycle); | ||
var viewEvent = { | ||
date: getTimestamp(view.startTime), | ||
duration: msToNs(view.duration), | ||
evt: { | ||
category: RumEventCategory.VIEW, | ||
}, | ||
rum: { | ||
documentVersion: view.documentVersion, | ||
}, | ||
view: { | ||
loadingTime: msToNs(view.loadingTime), | ||
loadingType: view.loadingType, | ||
measures: __assign(__assign({}, view.eventCounts), { domComplete: msToNs(view.timings.domComplete), domContentLoaded: msToNs(view.timings.domContentLoaded), domInteractive: msToNs(view.timings.domInteractive), firstContentfulPaint: msToNs(view.timings.firstContentfulPaint), loadEventEnd: msToNs(view.timings.loadEventEnd) }), | ||
}, | ||
}; | ||
return { | ||
rawRumEvent: viewEvent, | ||
startTime: view.startTime, | ||
}; | ||
} | ||
function processViewUpdateV2(view) { | ||
var viewEvent = { | ||
_dd: { | ||
@@ -59,3 +34,3 @@ documentVersion: view.documentVersion, | ||
largestContentfulPaint: msToNs(view.timings.largestContentfulPaint), | ||
loadEventEnd: msToNs(view.timings.loadEventEnd), | ||
loadEvent: msToNs(view.timings.loadEvent), | ||
loadingTime: msToNs(view.loadingTime), | ||
@@ -62,0 +37,0 @@ loadingType: view.loadingType, |
import { noop } from '@datadog/browser-core'; | ||
import { RumEventCategory } from '../types'; | ||
import { RumEventType } from '../typesV2'; | ||
import { RumEventType } from '../types'; | ||
import { LifeCycleEventType } from './lifeCycle'; | ||
@@ -15,23 +14,2 @@ export function trackEventCounts(lifeCycle, callback) { | ||
var rawRumEvent = _a.rawRumEvent; | ||
switch (rawRumEvent.evt.category) { | ||
case RumEventCategory.ERROR: | ||
eventCounts.errorCount += 1; | ||
callback(eventCounts); | ||
break; | ||
case RumEventCategory.USER_ACTION: | ||
eventCounts.userActionCount += 1; | ||
callback(eventCounts); | ||
break; | ||
case RumEventCategory.LONG_TASK: | ||
eventCounts.longTaskCount += 1; | ||
callback(eventCounts); | ||
break; | ||
case RumEventCategory.RESOURCE: | ||
eventCounts.resourceCount += 1; | ||
callback(eventCounts); | ||
break; | ||
} | ||
}); | ||
var subscriptionV2 = lifeCycle.subscribe(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, function (_a) { | ||
var rawRumEvent = _a.rawRumEvent; | ||
switch (rawRumEvent.type) { | ||
@@ -59,3 +37,2 @@ case RumEventType.ERROR: | ||
subscription.unsubscribe(); | ||
subscriptionV2.unsubscribe(); | ||
}, | ||
@@ -62,0 +39,0 @@ eventCounts: eventCounts, |
@@ -1,3 +0,1 @@ | ||
export { Datacenter, ErrorSource } from '@datadog/browser-core'; | ||
export { RumUserConfiguration, RumGlobal, datadogRum } from './boot/rum.entry'; | ||
export { InternalContext, RumEvent, RumEventCategory, RumUserActionEvent, RumViewEvent, RumResourceEvent, } from './types'; |
@@ -1,4 +0,2 @@ | ||
export { Datacenter, ErrorSource } from '@datadog/browser-core'; | ||
export { datadogRum } from './boot/rum.entry'; | ||
export { RumEventCategory, } from './types'; | ||
//# sourceMappingURL=index.js.map |
import { Batch, combine, HttpRequest } from '@datadog/browser-core'; | ||
import { LifeCycleEventType } from '../domain/lifeCycle'; | ||
import { RumEventCategory } from '../types'; | ||
import { RumEventType } from '../typesV2'; | ||
import { RumEventType } from '../types'; | ||
export function startRumBatch(configuration, lifeCycle) { | ||
@@ -9,11 +8,2 @@ var batch = makeRumBatch(configuration, lifeCycle); | ||
var rumEvent = _a.rumEvent, serverRumEvent = _a.serverRumEvent; | ||
if (rumEvent.evt.category === RumEventCategory.VIEW) { | ||
batch.upsert(serverRumEvent, rumEvent.view.id); | ||
} | ||
else { | ||
batch.add(serverRumEvent); | ||
} | ||
}); | ||
lifeCycle.subscribe(LifeCycleEventType.RUM_EVENT_V2_COLLECTED, function (_a) { | ||
var rumEvent = _a.rumEvent, serverRumEvent = _a.serverRumEvent; | ||
if (rumEvent.type === RumEventType.VIEW) { | ||
@@ -45,6 +35,3 @@ batch.upsert(serverRumEvent, rumEvent.view.id); | ||
function withReplicaApplicationId(message) { | ||
var applicationIdOverwrite = configuration.isEnabled('v2_format') | ||
? { application: { id: replica.applicationId } } | ||
: { application_id: replica.applicationId }; | ||
return combine(message, applicationIdOverwrite); | ||
return combine(message, { application: { id: replica.applicationId } }); | ||
} | ||
@@ -51,0 +38,0 @@ var stopped = false; |
import { Context, ErrorSource, ResourceType } from '@datadog/browser-core'; | ||
import { ActionCounts, ActionType } from './domain/rumEventsCollection/action/trackActions'; | ||
import { PerformanceResourceDetails } from './domain/rumEventsCollection/resource/resourceUtils'; | ||
import { Timings } from './domain/rumEventsCollection/view/trackTimings'; | ||
import { ActionType } from './domain/rumEventsCollection/action/trackActions'; | ||
import { PerformanceResourceDetailsElement } from './domain/rumEventsCollection/resource/resourceUtils'; | ||
import { ViewLoadingType } from './domain/rumEventsCollection/view/trackViews'; | ||
import { EventCounts } from './domain/trackEventCounts'; | ||
export declare enum RumEventCategory { | ||
USER_ACTION = "user_action", | ||
export declare enum RumEventType { | ||
ACTION = "action", | ||
ERROR = "error", | ||
@@ -16,19 +14,18 @@ LONG_TASK = "long_task", | ||
date: number; | ||
duration: number; | ||
evt: { | ||
category: RumEventCategory.RESOURCE; | ||
}; | ||
http: { | ||
performance?: PerformanceResourceDetails; | ||
type: RumEventType.RESOURCE; | ||
resource: { | ||
type: ResourceType; | ||
id?: string; | ||
duration: number; | ||
url: string; | ||
method?: string; | ||
statusCode?: number; | ||
url: string; | ||
size?: number; | ||
redirect?: PerformanceResourceDetailsElement; | ||
dns?: PerformanceResourceDetailsElement; | ||
connect?: PerformanceResourceDetailsElement; | ||
ssl?: PerformanceResourceDetailsElement; | ||
firstByte?: PerformanceResourceDetailsElement; | ||
download?: PerformanceResourceDetailsElement; | ||
}; | ||
network?: { | ||
bytesWritten?: number; | ||
}; | ||
resource: { | ||
kind: ResourceType; | ||
id?: string; | ||
}; | ||
_dd?: { | ||
@@ -41,56 +38,70 @@ traceId: string; | ||
date: number; | ||
http?: { | ||
url: string; | ||
status_code: number; | ||
method: string; | ||
}; | ||
type: RumEventType.ERROR; | ||
error: { | ||
kind?: string; | ||
resource?: { | ||
url: string; | ||
statusCode: number; | ||
method: string; | ||
}; | ||
type?: string; | ||
stack?: string; | ||
origin: ErrorSource; | ||
source: ErrorSource; | ||
message: string; | ||
}; | ||
evt: { | ||
category: RumEventCategory.ERROR; | ||
}; | ||
message: string; | ||
} | ||
export interface RumViewEvent { | ||
date: number; | ||
duration: number; | ||
evt: { | ||
category: RumEventCategory.VIEW; | ||
type: RumEventType.VIEW; | ||
view: { | ||
loadingType: ViewLoadingType; | ||
firstContentfulPaint?: number; | ||
firstInputDelay?: number; | ||
cumulativeLayoutShift?: number; | ||
largestContentfulPaint?: number; | ||
domInteractive?: number; | ||
domContentLoaded?: number; | ||
domComplete?: number; | ||
loadEvent?: number; | ||
loadingTime?: number; | ||
timeSpent: number; | ||
error: Count; | ||
action: Count; | ||
longTask: Count; | ||
resource: Count; | ||
}; | ||
rum: { | ||
_dd: { | ||
documentVersion: number; | ||
}; | ||
view: { | ||
loadingTime?: number; | ||
loadingType: ViewLoadingType; | ||
measures: EventCounts & Timings; | ||
}; | ||
} | ||
interface Count { | ||
count: number; | ||
} | ||
export interface RumLongTaskEvent { | ||
date: number; | ||
duration: number; | ||
evt: { | ||
category: RumEventCategory.LONG_TASK; | ||
type: RumEventType.LONG_TASK; | ||
longTask: { | ||
duration: number; | ||
}; | ||
} | ||
export interface RumUserActionEvent { | ||
export interface RumActionEvent { | ||
date?: number; | ||
duration?: number; | ||
evt: { | ||
category: RumEventCategory.USER_ACTION; | ||
name: string; | ||
}; | ||
userAction: { | ||
type: RumEventType.ACTION; | ||
action: { | ||
id?: string; | ||
type: ActionType; | ||
measures?: ActionCounts; | ||
loadingTime?: number; | ||
error?: Count; | ||
longTask?: Count; | ||
resource?: Count; | ||
target: { | ||
name: string; | ||
}; | ||
}; | ||
} | ||
export declare type RawRumEvent = RumErrorEvent | RumResourceEvent | RumViewEvent | RumLongTaskEvent | RumUserActionEvent; | ||
export declare type RawRumEvent = RumErrorEvent | RumResourceEvent | RumViewEvent | RumLongTaskEvent | RumActionEvent; | ||
export interface RumContext { | ||
applicationId: string; | ||
date: number; | ||
application: { | ||
id: string; | ||
}; | ||
service?: string; | ||
@@ -100,5 +111,10 @@ session: { | ||
}; | ||
_dd: { | ||
formatVersion: 2; | ||
}; | ||
} | ||
export interface ViewContext extends Context { | ||
sessionId: string | undefined; | ||
session: { | ||
id: string | undefined; | ||
}; | ||
view: { | ||
@@ -111,7 +127,7 @@ id: string; | ||
export interface ActionContext extends Context { | ||
userAction: { | ||
action: { | ||
id: string; | ||
}; | ||
} | ||
export declare type RumEvent = RumErrorEvent & ActionContext & ViewContext & RumContext | RumResourceEvent & ActionContext & ViewContext & RumContext | RumViewEvent & ViewContext & RumContext | RumLongTaskEvent & ActionContext & ViewContext & RumContext | RumUserActionEvent & ViewContext & RumContext; | ||
export declare type RumEvent = RumErrorEvent & ActionContext & ViewContext & RumContext | RumResourceEvent & ActionContext & ViewContext & RumContext | RumViewEvent & ViewContext & RumContext | RumLongTaskEvent & ActionContext & ViewContext & RumContext | RumActionEvent & ViewContext & RumContext; | ||
export interface InternalContext { | ||
@@ -129,1 +145,2 @@ application_id: string; | ||
} | ||
export {}; |
@@ -1,9 +0,9 @@ | ||
export var RumEventCategory; | ||
(function (RumEventCategory) { | ||
RumEventCategory["USER_ACTION"] = "user_action"; | ||
RumEventCategory["ERROR"] = "error"; | ||
RumEventCategory["LONG_TASK"] = "long_task"; | ||
RumEventCategory["VIEW"] = "view"; | ||
RumEventCategory["RESOURCE"] = "resource"; | ||
})(RumEventCategory || (RumEventCategory = {})); | ||
export var RumEventType; | ||
(function (RumEventType) { | ||
RumEventType["ACTION"] = "action"; | ||
RumEventType["ERROR"] = "error"; | ||
RumEventType["LONG_TASK"] = "long_task"; | ||
RumEventType["VIEW"] = "view"; | ||
RumEventType["RESOURCE"] = "resource"; | ||
})(RumEventType || (RumEventType = {})); | ||
//# sourceMappingURL=types.js.map |
{ | ||
"name": "@datadog/browser-rum", | ||
"version": "1.26.3", | ||
"version": "2.0.0", | ||
"license": "Apache-2.0", | ||
@@ -16,3 +16,3 @@ "main": "cjs/index.js", | ||
"dependencies": { | ||
"@datadog/browser-core": "1.26.3", | ||
"@datadog/browser-core": "2.0.0", | ||
"tslib": "^1.10.0" | ||
@@ -28,3 +28,3 @@ }, | ||
}, | ||
"gitHead": "a3ff0b6a2f9ff91c4800cb9c4ecaefb87b80e1af" | ||
"gitHead": "a734a69684fd340b8531c0661990c2d01ce33016" | ||
} |
@@ -18,3 +18,3 @@ import { | ||
import { ActionType, CustomAction } from '../domain/rumEventsCollection/action/trackActions' | ||
import { ProvidedError } from '../domain/rumEventsCollection/error/errorCollection' | ||
import { ProvidedError, ProvidedSource } from '../domain/rumEventsCollection/error/errorCollection' | ||
import { startRum } from './rum' | ||
@@ -100,28 +100,25 @@ | ||
/** | ||
* @deprecated | ||
* @see addAction | ||
*/ | ||
addUserAction: (name: string, context?: Context) => { | ||
// TODO deprecate in v2 | ||
rumGlobal.addAction(name, context) | ||
}, | ||
addError: monitor( | ||
( | ||
error: unknown, | ||
context?: Context, | ||
source: ErrorSource.CUSTOM | ErrorSource.NETWORK | ErrorSource.SOURCE = ErrorSource.CUSTOM | ||
) => { | ||
let 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, | ||
context: deepClone(context), | ||
source: checkedSource, | ||
startTime: performance.now(), | ||
}) | ||
addError: monitor((error: unknown, context?: Context, 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), | ||
source: checkedSource, | ||
startTime: performance.now(), | ||
}) | ||
}), | ||
}) | ||
@@ -128,0 +125,0 @@ return rumGlobal |
@@ -32,5 +32,2 @@ import { isIE } from '@datadog/browser-core' | ||
}) | ||
lifeCycle.subscribe(LifeCycleEventType.RUM_EVENT_V2_COLLECTED, ({ serverRumEvent }) => { | ||
serverRumEvents.push(serverRumEvent as any) | ||
}) | ||
return serverRumEvents | ||
@@ -58,30 +55,2 @@ } | ||
it('when the session is renewed, a new view event should be sent (v1)', () => { | ||
let sessionId = '42' | ||
const { lifeCycle } = setupBuilder | ||
.withSession({ | ||
getId: () => sessionId, | ||
isTracked: () => true, | ||
isTrackedWithResource: () => true, | ||
}) | ||
.withConfiguration({ | ||
isEnabled: () => false, | ||
}) | ||
.build() | ||
expect(serverRumEvents.length).toEqual(1) | ||
expect(serverRumEvents[0].evt.category).toEqual('view') | ||
expect(serverRumEvents[0].session_id).toEqual('42') | ||
sessionId = '43' | ||
lifeCycle.notify(LifeCycleEventType.SESSION_RENEWED) | ||
expect(serverRumEvents.length).toEqual(2) | ||
// New view event | ||
expect(serverRumEvents[1].evt.category).toEqual('view') | ||
expect(serverRumEvents[1].session_id).toEqual('43') | ||
expect(serverRumEvents[1].view.id).not.toEqual(serverRumEvents[0].view.id) | ||
}) | ||
it('when the session is renewed, a new view event should be sent', () => { | ||
@@ -140,26 +109,2 @@ let sessionId = '42' | ||
it('should send a view update regularly (v1)', () => { | ||
const { clock } = setupBuilder | ||
.withConfiguration({ | ||
isEnabled: () => false, | ||
}) | ||
.build() | ||
// clear initial events | ||
clock.tick(SESSION_KEEP_ALIVE_INTERVAL * 0.9) | ||
serverRumEvents.length = 0 | ||
clock.tick(SESSION_KEEP_ALIVE_INTERVAL * 0.1) | ||
// view update | ||
expect(serverRumEvents.length).toEqual(1) | ||
expect(serverRumEvents[0].evt.category).toEqual('view') | ||
clock.tick(SESSION_KEEP_ALIVE_INTERVAL) | ||
// view update | ||
expect(serverRumEvents.length).toEqual(2) | ||
expect(serverRumEvents[1].evt.category).toEqual('view') | ||
}) | ||
it('should send a view update regularly', () => { | ||
@@ -166,0 +111,0 @@ const { clock } = setupBuilder.build() |
@@ -5,3 +5,2 @@ import { combine, commonInit, Configuration, Context } from '@datadog/browser-core' | ||
import { startRumAssembly } from '../domain/assembly' | ||
import { startRumAssemblyV2 } from '../domain/assemblyV2' | ||
import { startInternalContext } from '../domain/internalContext' | ||
@@ -51,3 +50,3 @@ import { LifeCycle } from '../domain/lifeCycle' | ||
const internalContext = startInternalContext(userConfiguration.applicationId, session, parentContexts, configuration) | ||
const internalContext = startInternalContext(userConfiguration.applicationId, session, parentContexts) | ||
@@ -72,3 +71,2 @@ return { | ||
startRumAssembly(applicationId, configuration, lifeCycle, session, parentContexts, getGlobalContext) | ||
startRumAssemblyV2(applicationId, configuration, lifeCycle, session, parentContexts, getGlobalContext) | ||
startLongTaskCollection(lifeCycle, configuration) | ||
@@ -75,0 +73,0 @@ startResourceCollection(lifeCycle, configuration, session) |
import { Context } from '@datadog/browser-core' | ||
import { createRawRumEvent } from '../../test/fixtures' | ||
import { setup, TestSetupBuilder } from '../../test/specHelper' | ||
import { RumEventCategory } from '../index' | ||
import { RawRumEvent } from '../types' | ||
import { RumEventType } from '../types' | ||
import { startRumAssembly } from './assembly' | ||
@@ -9,11 +9,14 @@ import { LifeCycle, LifeCycleEventType } from './lifeCycle' | ||
interface ServerRumEvents { | ||
application_id: string | ||
user_action: { | ||
application: { | ||
id: string | ||
} | ||
action: { | ||
id: string | ||
} | ||
context: any | ||
date: number | ||
evt: { | ||
category: string | ||
type: string | ||
session: { | ||
id: string | ||
} | ||
session_id: string | ||
view: { | ||
@@ -24,5 +27,8 @@ id: string | ||
} | ||
network?: { | ||
bytes_written: number | ||
long_task?: { | ||
duration: number | ||
} | ||
_dd: { | ||
format_version: 2 | ||
} | ||
} | ||
@@ -38,17 +44,2 @@ | ||
function generateRawRumEvent( | ||
category: RumEventCategory, | ||
properties?: Partial<RawRumEvent>, | ||
savedGlobalContext?: Context, | ||
customerContext?: Context | ||
) { | ||
const viewEvent = { evt: { category }, ...properties } | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
customerContext, | ||
savedGlobalContext, | ||
rawRumEvent: viewEvent as RawRumEvent, | ||
startTime: 0, | ||
}) | ||
} | ||
beforeEach(() => { | ||
@@ -65,3 +56,3 @@ isTracked = true | ||
findAction: () => ({ | ||
userAction: { | ||
action: { | ||
id: '7890', | ||
@@ -71,3 +62,5 @@ }, | ||
findView: () => ({ | ||
sessionId: viewSessionId, | ||
session: { | ||
id: viewSessionId, | ||
}, | ||
view: { | ||
@@ -97,5 +90,8 @@ id: 'abcde', | ||
it('should have snake cased attributes', () => { | ||
generateRawRumEvent(RumEventCategory.RESOURCE, { network: { bytesWritten: 2 } }) | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: createRawRumEvent(RumEventType.LONG_TASK, { longTask: { duration: 2 } }), | ||
startTime: 0, | ||
}) | ||
expect(serverRumEvents[0].network!.bytes_written).toBe(2) | ||
expect(serverRumEvents[0].long_task!.duration).toBe(2) | ||
}) | ||
@@ -106,3 +102,6 @@ }) | ||
it('should be merged with event attributes', () => { | ||
generateRawRumEvent(RumEventCategory.VIEW) | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: createRawRumEvent(RumEventType.VIEW, undefined), | ||
startTime: 0, | ||
}) | ||
@@ -114,9 +113,15 @@ expect(serverRumEvents[0].view.id).toBeDefined() | ||
it('should be snake cased', () => { | ||
generateRawRumEvent(RumEventCategory.VIEW) | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: createRawRumEvent(RumEventType.VIEW, undefined), | ||
startTime: 0, | ||
}) | ||
expect(serverRumEvents[0].application_id).toBe('appId') | ||
expect(serverRumEvents[0]._dd.format_version).toBe(2) | ||
}) | ||
it('should be overwritten by event attributes', () => { | ||
generateRawRumEvent(RumEventCategory.VIEW, { date: 10 }) | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: createRawRumEvent(RumEventType.VIEW, { date: 10 }), | ||
startTime: 0, | ||
}) | ||
@@ -130,5 +135,8 @@ expect(serverRumEvents[0].date).toBe(10) | ||
globalContext = { bar: 'foo' } | ||
generateRawRumEvent(RumEventCategory.VIEW) | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: createRawRumEvent(RumEventType.VIEW), | ||
startTime: 0, | ||
}) | ||
expect((serverRumEvents[0] as any).bar).toEqual('foo') | ||
expect((serverRumEvents[0].context as any).bar).toEqual('foo') | ||
}) | ||
@@ -138,8 +146,14 @@ | ||
globalContext = { bar: 'foo' } | ||
generateRawRumEvent(RumEventCategory.VIEW) | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: createRawRumEvent(RumEventType.VIEW), | ||
startTime: 0, | ||
}) | ||
delete globalContext.bar | ||
generateRawRumEvent(RumEventCategory.VIEW) | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: createRawRumEvent(RumEventType.VIEW), | ||
startTime: 0, | ||
}) | ||
expect((serverRumEvents[0] as any).bar).toEqual('foo') | ||
expect((serverRumEvents[1] as any).bar).toBeUndefined() | ||
expect((serverRumEvents[0].context as any).bar).toEqual('foo') | ||
expect((serverRumEvents[1].context as any).bar).toBeUndefined() | ||
}) | ||
@@ -149,5 +163,8 @@ | ||
globalContext = { fooBar: 'foo' } | ||
generateRawRumEvent(RumEventCategory.VIEW) | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: createRawRumEvent(RumEventType.VIEW), | ||
startTime: 0, | ||
}) | ||
expect(((serverRumEvents[0] as any) as any).fooBar).toEqual('foo') | ||
expect((serverRumEvents[0].context as any).fooBar).toEqual('foo') | ||
}) | ||
@@ -158,6 +175,10 @@ | ||
generateRawRumEvent(RumEventCategory.VIEW, undefined, { replacedContext: 'a' }) | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: createRawRumEvent(RumEventType.VIEW), | ||
savedGlobalContext: { replacedContext: 'a' }, | ||
startTime: 0, | ||
}) | ||
expect((serverRumEvents[0] as any).replacedContext).toEqual('a') | ||
expect((serverRumEvents[0] as any).addedContext).toEqual(undefined) | ||
expect((serverRumEvents[0].context as any).replacedContext).toEqual('a') | ||
expect((serverRumEvents[0].context as any).addedContext).toEqual(undefined) | ||
}) | ||
@@ -168,11 +189,19 @@ }) | ||
it('should be merged with event attributes', () => { | ||
generateRawRumEvent(RumEventCategory.VIEW, undefined, undefined, { foo: 'bar' }) | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
customerContext: { foo: 'bar' }, | ||
rawRumEvent: createRawRumEvent(RumEventType.VIEW), | ||
startTime: 0, | ||
}) | ||
expect((serverRumEvents[0] as any).foo).toEqual('bar') | ||
expect((serverRumEvents[0].context as any).foo).toEqual('bar') | ||
}) | ||
it('should not be automatically snake cased', () => { | ||
generateRawRumEvent(RumEventCategory.VIEW, undefined, undefined, { fooBar: 'foo' }) | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
customerContext: { fooBar: 'foo' }, | ||
rawRumEvent: createRawRumEvent(RumEventType.VIEW), | ||
startTime: 0, | ||
}) | ||
expect(((serverRumEvents[0] as any) as any).fooBar).toEqual('foo') | ||
expect((serverRumEvents[0].context as any).fooBar).toEqual('foo') | ||
}) | ||
@@ -183,12 +212,24 @@ }) | ||
it('should be added on some event categories', () => { | ||
;[RumEventCategory.RESOURCE, RumEventCategory.LONG_TASK, RumEventCategory.ERROR].forEach((category) => { | ||
generateRawRumEvent(category) | ||
expect(serverRumEvents[0].user_action.id).toBeDefined() | ||
;[RumEventType.RESOURCE, RumEventType.LONG_TASK, RumEventType.ERROR].forEach((category) => { | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: createRawRumEvent(category), | ||
startTime: 0, | ||
}) | ||
expect(serverRumEvents[0].action).toEqual({ id: '7890' }) | ||
serverRumEvents = [] | ||
}) | ||
;[RumEventCategory.VIEW, RumEventCategory.USER_ACTION].forEach((category) => { | ||
generateRawRumEvent(category) | ||
expect(serverRumEvents[0].user_action).not.toBeDefined() | ||
serverRumEvents = [] | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: createRawRumEvent(RumEventType.VIEW), | ||
startTime: 0, | ||
}) | ||
expect(serverRumEvents[0].action).not.toBeDefined() | ||
serverRumEvents = [] | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: createRawRumEvent(RumEventType.ACTION), | ||
startTime: 0, | ||
}) | ||
expect(serverRumEvents[0].action.id).not.toBeDefined() | ||
serverRumEvents = [] | ||
}) | ||
@@ -199,4 +240,6 @@ }) | ||
it('should be merged with event attributes', () => { | ||
generateRawRumEvent(RumEventCategory.USER_ACTION) | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: createRawRumEvent(RumEventType.ACTION), | ||
startTime: 0, | ||
}) | ||
expect(serverRumEvents[0].view).toEqual({ | ||
@@ -207,3 +250,3 @@ id: 'abcde', | ||
}) | ||
expect(serverRumEvents[0].session_id).toEqual('1234') | ||
expect(serverRumEvents[0].session.id).toBe('1234') | ||
}) | ||
@@ -216,3 +259,6 @@ }) | ||
generateRawRumEvent(RumEventCategory.VIEW) | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: createRawRumEvent(RumEventType.VIEW), | ||
startTime: 0, | ||
}) | ||
expect(serverRumEvents.length).toBe(1) | ||
@@ -224,3 +270,6 @@ }) | ||
generateRawRumEvent(RumEventCategory.VIEW) | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: createRawRumEvent(RumEventType.VIEW), | ||
startTime: 0, | ||
}) | ||
expect(serverRumEvents.length).toBe(0) | ||
@@ -232,3 +281,6 @@ }) | ||
generateRawRumEvent(RumEventCategory.VIEW) | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: createRawRumEvent(RumEventType.VIEW), | ||
startTime: 0, | ||
}) | ||
expect(serverRumEvents.length).toBe(1) | ||
@@ -240,3 +292,6 @@ }) | ||
generateRawRumEvent(RumEventCategory.VIEW) | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: createRawRumEvent(RumEventType.VIEW), | ||
startTime: 0, | ||
}) | ||
expect(serverRumEvents.length).toBe(0) | ||
@@ -243,0 +298,0 @@ }) |
import { combine, Configuration, Context, withSnakeCaseKeys } from '@datadog/browser-core' | ||
import { RawRumEvent, RumContext, RumErrorEvent, RumEventCategory, RumLongTaskEvent, RumResourceEvent } from '../types' | ||
import { RawRumEvent, RumContext, RumErrorEvent, RumEventType, RumLongTaskEvent, RumResourceEvent } from '../types' | ||
import { LifeCycle, LifeCycleEventType } from './lifeCycle' | ||
@@ -38,6 +38,11 @@ import { ParentContexts } from './parentContexts' | ||
const viewContext = parentContexts.findView(startTime) | ||
if (session.isTracked() && viewContext && viewContext.sessionId) { | ||
if (session.isTracked() && viewContext && viewContext.session.id) { | ||
const actionContext = parentContexts.findAction(startTime) | ||
const rumContext: RumContext = { | ||
applicationId, | ||
_dd: { | ||
formatVersion: 2, | ||
}, | ||
application: { | ||
id: applicationId, | ||
}, | ||
date: new Date().getTime(), | ||
@@ -54,7 +59,4 @@ service: configuration.service, | ||
: combine(rumContext, viewContext, rawRumEvent) | ||
const serverRumEvent = combine( | ||
savedGlobalContext || getGlobalContext(), | ||
customerContext, | ||
withSnakeCaseKeys(rumEvent) | ||
) | ||
const serverRumEvent = withSnakeCaseKeys(rumEvent) | ||
serverRumEvent.context = combine(savedGlobalContext || getGlobalContext(), customerContext) | ||
lifeCycle.notify(LifeCycleEventType.RUM_EVENT_COLLECTED, { rumEvent, serverRumEvent }) | ||
@@ -67,5 +69,3 @@ } | ||
function needToAssembleWithAction(event: RawRumEvent): event is RumErrorEvent | RumResourceEvent | RumLongTaskEvent { | ||
return ( | ||
[RumEventCategory.ERROR, RumEventCategory.RESOURCE, RumEventCategory.LONG_TASK].indexOf(event.evt.category) !== -1 | ||
) | ||
return [RumEventType.ERROR, RumEventType.RESOURCE, RumEventType.LONG_TASK].indexOf(event.type) !== -1 | ||
} | ||
@@ -72,0 +72,0 @@ |
@@ -13,3 +13,3 @@ import { setup, TestSetupBuilder } from '../../test/specHelper' | ||
findAction: jasmine.createSpy('findAction').and.returnValue({ | ||
userAction: { | ||
action: { | ||
id: '7890', | ||
@@ -19,76 +19,2 @@ }, | ||
findView: jasmine.createSpy('findView').and.returnValue({ | ||
sessionId: '1234', | ||
view: { | ||
id: 'abcde', | ||
referrer: 'referrer', | ||
url: 'url', | ||
}, | ||
}), | ||
} | ||
setupBuilder = setup() | ||
.withParentContexts(parentContextsStub) | ||
.withConfiguration({ | ||
isEnabled: () => false, | ||
}) | ||
.beforeBuild(({ applicationId, session, parentContexts, configuration }) => { | ||
internalContext = startInternalContext(applicationId, session, parentContexts, configuration) | ||
}) | ||
}) | ||
afterEach(() => { | ||
setupBuilder.cleanup() | ||
}) | ||
it('should return current internal context', () => { | ||
setupBuilder.build() | ||
expect(internalContext.get()).toEqual({ | ||
application_id: 'appId', | ||
session_id: '1234', | ||
user_action: { | ||
id: '7890', | ||
}, | ||
view: { | ||
id: 'abcde', | ||
referrer: 'referrer', | ||
url: 'url', | ||
}, | ||
}) | ||
}) | ||
it("should return undefined if the session isn't tracked", () => { | ||
setupBuilder | ||
.withSession({ | ||
getId: () => '1234', | ||
isTracked: () => false, | ||
isTrackedWithResource: () => false, | ||
}) | ||
.build() | ||
expect(internalContext.get()).toEqual(undefined) | ||
}) | ||
it('should return internal context corresponding to startTime', () => { | ||
setupBuilder.build() | ||
internalContext.get(123) | ||
expect(parentContextsStub.findView).toHaveBeenCalledWith(123) | ||
expect(parentContextsStub.findAction).toHaveBeenCalledWith(123) | ||
}) | ||
}) | ||
describe('internal context v2', () => { | ||
let setupBuilder: TestSetupBuilder | ||
let parentContextsStub: Partial<ParentContexts> | ||
let internalContext: ReturnType<typeof startInternalContext> | ||
beforeEach(() => { | ||
parentContextsStub = { | ||
findActionV2: jasmine.createSpy('findAction').and.returnValue({ | ||
action: { | ||
id: '7890', | ||
}, | ||
}), | ||
findViewV2: jasmine.createSpy('findView').and.returnValue({ | ||
session: { | ||
@@ -106,4 +32,4 @@ id: '1234', | ||
.withParentContexts(parentContextsStub) | ||
.beforeBuild(({ applicationId, session, parentContexts, configuration }) => { | ||
internalContext = startInternalContext(applicationId, session, parentContexts, configuration) | ||
.beforeBuild(({ applicationId, session, parentContexts }) => { | ||
internalContext = startInternalContext(applicationId, session, parentContexts) | ||
}) | ||
@@ -150,5 +76,5 @@ }) | ||
expect(parentContextsStub.findViewV2).toHaveBeenCalledWith(123) | ||
expect(parentContextsStub.findActionV2).toHaveBeenCalledWith(123) | ||
expect(parentContextsStub.findView).toHaveBeenCalledWith(123) | ||
expect(parentContextsStub.findAction).toHaveBeenCalledWith(123) | ||
}) | ||
}) |
@@ -1,2 +0,2 @@ | ||
import { combine, Configuration, withSnakeCaseKeys } from '@datadog/browser-core' | ||
import { combine, withSnakeCaseKeys } from '@datadog/browser-core' | ||
import { InternalContext } from '../types' | ||
@@ -10,29 +10,15 @@ import { ParentContexts } from './parentContexts' | ||
*/ | ||
export function startInternalContext( | ||
applicationId: string, | ||
session: RumSession, | ||
parentContexts: ParentContexts, | ||
configuration: Configuration | ||
) { | ||
export function startInternalContext(applicationId: string, session: RumSession, parentContexts: ParentContexts) { | ||
return { | ||
get: (startTime?: number) => { | ||
if (configuration.isEnabled('v2_format')) { | ||
const viewContext = parentContexts.findViewV2(startTime) | ||
if (session.isTracked() && viewContext && viewContext.session.id) { | ||
const actionContext = parentContexts.findActionV2(startTime) | ||
return (withSnakeCaseKeys( | ||
combine( | ||
{ applicationId }, | ||
{ sessionId: viewContext.session.id, view: viewContext.view }, | ||
actionContext ? { userAction: { id: actionContext.action.id } } : undefined | ||
) | ||
) as unknown) as InternalContext | ||
} | ||
} else { | ||
const viewContext = parentContexts.findView(startTime) | ||
if (session.isTracked() && viewContext && viewContext.sessionId) { | ||
return (withSnakeCaseKeys( | ||
combine({ applicationId }, viewContext, parentContexts.findAction(startTime)) | ||
) as unknown) as InternalContext | ||
} | ||
const viewContext = parentContexts.findView(startTime) | ||
if (session.isTracked() && viewContext && viewContext.session.id) { | ||
const actionContext = parentContexts.findAction(startTime) | ||
return (withSnakeCaseKeys( | ||
combine( | ||
{ applicationId }, | ||
{ sessionId: viewContext.session.id, view: viewContext.view }, | ||
actionContext ? { userAction: { id: actionContext.action.id } } : undefined | ||
) | ||
) as unknown) as InternalContext | ||
} | ||
@@ -39,0 +25,0 @@ }, |
import { Context } from '@datadog/browser-core' | ||
import { RumPerformanceEntry } from '../browser/performanceCollection' | ||
import { RawRumEvent, RumEvent } from '../types' | ||
import { RawRumEventV2, RumEventV2 } from '../typesV2' | ||
import { RequestCompleteEvent, RequestStartEvent } from './requestCollection' | ||
import { AutoAction, AutoActionCreatedEvent, CustomAction } from './rumEventsCollection/action/trackActions' | ||
import { AutoAction, AutoActionCreatedEvent } from './rumEventsCollection/action/trackActions' | ||
import { View, ViewCreatedEvent } from './rumEventsCollection/view/trackViews' | ||
@@ -22,5 +21,3 @@ | ||
RAW_RUM_EVENT_COLLECTED, | ||
RAW_RUM_EVENT_V2_COLLECTED, | ||
RUM_EVENT_COLLECTED, | ||
RUM_EVENT_V2_COLLECTED, | ||
} | ||
@@ -58,16 +55,3 @@ | ||
): void | ||
notify( | ||
eventType: LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, | ||
data: { | ||
startTime: number | ||
rawRumEvent: RawRumEventV2 | ||
savedGlobalContext?: Context | ||
customerContext?: Context | ||
} | ||
): void | ||
notify(eventType: LifeCycleEventType.RUM_EVENT_COLLECTED, data: { rumEvent: RumEvent; serverRumEvent: Context }): void | ||
notify( | ||
eventType: LifeCycleEventType.RUM_EVENT_V2_COLLECTED, | ||
data: { rumEvent: RumEventV2; serverRumEvent: Context } | ||
): void | ||
notify(eventType: LifeCycleEventType, data?: any) { | ||
@@ -114,18 +98,5 @@ const eventCallbacks = this.callbacks[eventType] | ||
subscribe( | ||
eventType: LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, | ||
callback: (data: { | ||
startTime: number | ||
rawRumEvent: RawRumEventV2 | ||
savedGlobalContext?: Context | ||
customerContext?: Context | ||
}) => void | ||
): Subscription | ||
subscribe( | ||
eventType: LifeCycleEventType.RUM_EVENT_COLLECTED, | ||
callback: (data: { rumEvent: RumEvent; serverRumEvent: Context }) => void | ||
): Subscription | ||
subscribe( | ||
eventType: LifeCycleEventType.RUM_EVENT_V2_COLLECTED, | ||
callback: (data: { rumEvent: RumEventV2; serverRumEvent: Context }) => void | ||
): Subscription | ||
subscribe(eventType: LifeCycleEventType, callback: (data?: any) => void) { | ||
@@ -132,0 +103,0 @@ if (!this.callbacks[eventType]) { |
@@ -111,9 +111,9 @@ import { setup, TestSetupBuilder } from '../../test/specHelper' | ||
lifeCycle.notify(LifeCycleEventType.VIEW_CREATED, buildViewCreatedEvent()) | ||
expect(parentContexts.findView()!.sessionId).toBe('fake-session') | ||
expect(parentContexts.findView()!.session.id).toBe('fake-session') | ||
sessionId = 'other-session' | ||
expect(parentContexts.findView()!.sessionId).toBe('fake-session') | ||
expect(parentContexts.findView()!.session.id).toBe('fake-session') | ||
lifeCycle.notify(LifeCycleEventType.VIEW_CREATED, buildViewCreatedEvent({ id: 'fake 2' })) | ||
expect(parentContexts.findView()!.sessionId).toBe('other-session') | ||
expect(parentContexts.findView()!.session.id).toBe('other-session') | ||
}) | ||
@@ -135,3 +135,3 @@ }) | ||
expect(parentContexts.findAction()).toBeDefined() | ||
expect(parentContexts.findAction()!.userAction.id).toBe(FAKE_ID) | ||
expect(parentContexts.findAction()!.action.id).toBe(FAKE_ID) | ||
}) | ||
@@ -150,6 +150,6 @@ | ||
expect(parentContexts.findAction(15)!.userAction.id).toBe('action 1') | ||
expect(parentContexts.findAction(20)!.userAction.id).toBe('action 1') | ||
expect(parentContexts.findAction(30)!.userAction.id).toBe('action 2') | ||
expect(parentContexts.findAction(55)!.userAction.id).toBe('action 3') | ||
expect(parentContexts.findAction(15)!.action.id).toBe('action 1') | ||
expect(parentContexts.findAction(20)!.action.id).toBe('action 1') | ||
expect(parentContexts.findAction(30)!.action.id).toBe('action 2') | ||
expect(parentContexts.findAction(55)!.action.id).toBe('action 3') | ||
}) | ||
@@ -156,0 +156,0 @@ |
import { monitor, ONE_MINUTE, SESSION_TIME_OUT_DELAY } from '@datadog/browser-core' | ||
import { ActionContext, ViewContext } from '../types' | ||
import { ActionContextV2, ViewContextV2 } from '../typesV2' | ||
import { LifeCycle, LifeCycleEventType } from './lifeCycle' | ||
@@ -21,5 +20,3 @@ import { AutoAction, AutoActionCreatedEvent } from './rumEventsCollection/action/trackActions' | ||
findAction: (startTime?: number) => ActionContext | undefined | ||
findActionV2: (startTime?: number) => ActionContextV2 | undefined | ||
findView: (startTime?: number) => ViewContext | undefined | ||
findViewV2: (startTime?: number) => ViewContextV2 | undefined | ||
stop: () => void | ||
@@ -99,3 +96,5 @@ } | ||
return { | ||
sessionId: currentSessionId, | ||
session: { | ||
id: currentSessionId, | ||
}, | ||
view: { | ||
@@ -110,3 +109,3 @@ id: currentView!.id, | ||
function buildCurrentActionContext() { | ||
return { userAction: { id: currentAction!.id } } | ||
return { action: { id: currentAction!.id } } | ||
} | ||
@@ -137,32 +136,9 @@ | ||
const parentContexts: ParentContexts = { | ||
return { | ||
findAction: (startTime) => { | ||
return findContext(buildCurrentActionContext, previousActions, currentAction, startTime) | ||
}, | ||
findActionV2: (startTime) => { | ||
const actionContext = parentContexts.findAction(startTime) | ||
if (!actionContext) { | ||
return | ||
} | ||
return { | ||
action: { | ||
id: actionContext.userAction.id, | ||
}, | ||
} | ||
}, | ||
findView: (startTime) => { | ||
return findContext(buildCurrentViewContext, previousViews, currentView, startTime) | ||
}, | ||
findViewV2: (startTime) => { | ||
const viewContext = parentContexts.findView(startTime) | ||
if (!viewContext) { | ||
return | ||
} | ||
return { | ||
session: { | ||
id: viewContext.sessionId, | ||
}, | ||
view: viewContext.view, | ||
} | ||
}, | ||
stop: () => { | ||
@@ -172,3 +148,2 @@ window.clearInterval(clearOldContextsInterval) | ||
} | ||
return parentContexts | ||
} |
import { setup, TestSetupBuilder } from '../../../../test/specHelper' | ||
import { RumEventCategory } from '../../../types' | ||
import { RumEventType } from '../../../typesV2' | ||
import { RumEventType } from '../../../types' | ||
import { LifeCycleEventType } from '../../lifeCycle' | ||
@@ -15,3 +14,3 @@ import { startActionCollection } from './actionCollection' | ||
.withConfiguration({ | ||
isEnabled: () => false, | ||
isEnabled: () => true, | ||
}) | ||
@@ -35,3 +34,3 @@ .beforeBuild(({ lifeCycle, configuration }) => { | ||
duration: 100, | ||
id: 'xxx', | ||
id: 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee', | ||
name: 'foo', | ||
@@ -44,76 +43,2 @@ startTime: 1234, | ||
expect(rawRumEvents[0].rawRumEvent).toEqual({ | ||
date: jasmine.any(Number), | ||
duration: 100 * 1e6, | ||
evt: { | ||
category: RumEventCategory.USER_ACTION, | ||
name: 'foo', | ||
}, | ||
userAction: { | ||
id: 'xxx', | ||
measures: { | ||
errorCount: 10, | ||
longTaskCount: 10, | ||
resourceCount: 10, | ||
}, | ||
type: ActionType.CLICK, | ||
}, | ||
}) | ||
}) | ||
it('should create action from custom action', () => { | ||
const { rawRumEvents } = setupBuilder.build() | ||
addAction({ | ||
name: 'foo', | ||
startTime: 1234, | ||
type: ActionType.CUSTOM, | ||
}) | ||
expect(rawRumEvents[0].startTime).toBe(1234) | ||
expect(rawRumEvents[0].rawRumEvent).toEqual({ | ||
date: jasmine.any(Number), | ||
evt: { | ||
category: RumEventCategory.USER_ACTION, | ||
name: 'foo', | ||
}, | ||
userAction: { | ||
type: ActionType.CUSTOM, | ||
}, | ||
}) | ||
}) | ||
}) | ||
describe('actionCollection v2', () => { | ||
let setupBuilder: TestSetupBuilder | ||
let addAction: ReturnType<typeof startActionCollection>['addAction'] | ||
beforeEach(() => { | ||
setupBuilder = setup() | ||
.withConfiguration({ | ||
isEnabled: () => true, | ||
}) | ||
.beforeBuild(({ lifeCycle, configuration }) => { | ||
;({ addAction } = startActionCollection(lifeCycle, configuration)) | ||
}) | ||
}) | ||
afterEach(() => { | ||
setupBuilder.cleanup() | ||
}) | ||
it('should create action from auto action', () => { | ||
const { lifeCycle, rawRumEventsV2 } = setupBuilder.build() | ||
lifeCycle.notify(LifeCycleEventType.AUTO_ACTION_COMPLETED, { | ||
counts: { | ||
errorCount: 10, | ||
longTaskCount: 10, | ||
resourceCount: 10, | ||
}, | ||
duration: 100, | ||
id: 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee', | ||
name: 'foo', | ||
startTime: 1234, | ||
type: ActionType.CLICK, | ||
}) | ||
expect(rawRumEventsV2[0].startTime).toBe(1234) | ||
expect(rawRumEventsV2[0].rawRumEvent).toEqual({ | ||
action: { | ||
@@ -142,3 +67,3 @@ error: { | ||
it('should create action from custom action', () => { | ||
const { rawRumEventsV2 } = setupBuilder.build() | ||
const { rawRumEvents } = setupBuilder.build() | ||
addAction({ | ||
@@ -150,4 +75,4 @@ name: 'foo', | ||
expect(rawRumEventsV2[0].startTime).toBe(1234) | ||
expect(rawRumEventsV2[0].rawRumEvent).toEqual({ | ||
expect(rawRumEvents[0].startTime).toBe(1234) | ||
expect(rawRumEvents[0].rawRumEvent).toEqual({ | ||
action: { | ||
@@ -154,0 +79,0 @@ target: { |
import { combine, Configuration, Context, getTimestamp, msToNs } from '@datadog/browser-core' | ||
import { RumEventCategory, RumUserActionEvent } from '../../../types' | ||
import { RumActionEventV2, RumEventType } from '../../../typesV2' | ||
import { RumActionEvent, RumEventType } from '../../../types' | ||
import { LifeCycle, LifeCycleEventType } from '../../lifeCycle' | ||
@@ -8,7 +7,5 @@ import { ActionType, AutoAction, CustomAction, trackActions } from './trackActions' | ||
export function startActionCollection(lifeCycle: LifeCycle, configuration: Configuration) { | ||
lifeCycle.subscribe(LifeCycleEventType.AUTO_ACTION_COMPLETED, (action) => { | ||
configuration.isEnabled('v2_format') | ||
? lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, processActionV2(action)) | ||
: lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processAction(action)) | ||
}) | ||
lifeCycle.subscribe(LifeCycleEventType.AUTO_ACTION_COMPLETED, (action) => | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processAction(action)) | ||
) | ||
@@ -21,11 +18,6 @@ if (configuration.trackInteractions) { | ||
addAction(action: CustomAction, savedGlobalContext?: Context) { | ||
configuration.isEnabled('v2_format') | ||
? lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, { | ||
savedGlobalContext, | ||
...processActionV2(action), | ||
}) | ||
: lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
savedGlobalContext, | ||
...processAction(action), | ||
}) | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
savedGlobalContext, | ||
...processAction(action), | ||
}) | ||
}, | ||
@@ -38,33 +30,2 @@ } | ||
? { | ||
duration: msToNs(action.duration), | ||
userAction: { | ||
id: action.id, | ||
measures: action.counts, | ||
}, | ||
} | ||
: undefined | ||
const customerContext = !isAutoAction(action) ? action.context : undefined | ||
const actionEvent: RumUserActionEvent = combine( | ||
{ | ||
date: getTimestamp(action.startTime), | ||
evt: { | ||
category: RumEventCategory.USER_ACTION as const, | ||
name: action.name, | ||
}, | ||
userAction: { | ||
type: action.type, | ||
}, | ||
}, | ||
autoActionProperties | ||
) | ||
return { | ||
customerContext, | ||
rawRumEvent: actionEvent, | ||
startTime: action.startTime, | ||
} | ||
} | ||
function processActionV2(action: AutoAction | CustomAction) { | ||
const autoActionProperties = isAutoAction(action) | ||
? { | ||
action: { | ||
@@ -86,3 +47,3 @@ error: { | ||
const customerContext = !isAutoAction(action) ? action.context : undefined | ||
const actionEvent: RumActionEventV2 = combine( | ||
const actionEvent: RumActionEvent = combine( | ||
{ | ||
@@ -89,0 +50,0 @@ action: { |
import { DOM_EVENT } from '@datadog/browser-core' | ||
import { createRawRumEvent } from '../../../../test/fixtures' | ||
import { setup, TestSetupBuilder } from '../../../../test/specHelper' | ||
import { RumErrorEvent, RumEventCategory } from '../../../types' | ||
import { RumEventType } from '../../../typesV2' | ||
import { RumEventType } from '../../../types' | ||
import { LifeCycle, LifeCycleEventType } from '../../lifeCycle' | ||
@@ -181,3 +180,3 @@ import { PAGE_ACTIVITY_MAX_DURATION, PAGE_ACTIVITY_VALIDATION_DELAY } from '../../trackPageActivities' | ||
const collectedRawRumEvent = { | ||
rawRumEvent: ({ evt: { category: RumEventCategory.ERROR } } as unknown) as RumErrorEvent, | ||
rawRumEvent: createRawRumEvent(RumEventType.ERROR), | ||
startTime: 0, | ||
@@ -205,29 +204,2 @@ } | ||
}) | ||
it('counts errors occurring during the action v2', () => { | ||
const { lifeCycle, clock } = setupBuilder.build() | ||
const collectedRawRumEvent = { | ||
rawRumEvent: createRawRumEvent(RumEventType.ERROR), | ||
startTime: 0, | ||
} | ||
lifeCycle.subscribe(LifeCycleEventType.AUTO_ACTION_COMPLETED, pushEvent) | ||
newClick('test-1') | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, collectedRawRumEvent) | ||
clock.tick(BEFORE_PAGE_ACTIVITY_VALIDATION_DELAY) | ||
lifeCycle.notify(LifeCycleEventType.DOM_MUTATED) | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, collectedRawRumEvent) | ||
clock.tick(EXPIRE_DELAY) | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, collectedRawRumEvent) | ||
expect(events.length).toBe(1) | ||
const action = events[0] as AutoAction | ||
expect(action.counts).toEqual({ | ||
errorCount: 2, | ||
longTaskCount: 0, | ||
resourceCount: 0, | ||
}) | ||
}) | ||
}) |
@@ -1,5 +0,4 @@ | ||
import { Observable, RawError } from '@datadog/browser-core' | ||
import { ErrorSource, Observable, RawError } from '@datadog/browser-core' | ||
import { setup, TestSetupBuilder } from '../../../../test/specHelper' | ||
import { ErrorSource, RumEventCategory } from '../../../index' | ||
import { RumEventType } from '../../../typesV2' | ||
import { RumEventType } from '../../../types' | ||
import { doStartErrorCollection } from './errorCollection' | ||
@@ -15,3 +14,3 @@ | ||
.withConfiguration({ | ||
isEnabled: () => false, | ||
isEnabled: () => true, | ||
}) | ||
@@ -42,10 +41,9 @@ .beforeBuild(({ lifeCycle, configuration }) => { | ||
error: { | ||
kind: 'Error', | ||
origin: ErrorSource.CUSTOM, | ||
message: 'foo', | ||
resource: undefined, | ||
source: ErrorSource.CUSTOM, | ||
stack: jasmine.stringMatching('Error: foo'), | ||
type: 'Error', | ||
}, | ||
evt: { | ||
category: RumEventCategory.ERROR, | ||
}, | ||
message: 'foo', | ||
type: RumEventType.ERROR, | ||
}, | ||
@@ -106,116 +104,2 @@ savedGlobalContext: undefined, | ||
error: { | ||
kind: 'foo', | ||
origin: ErrorSource.NETWORK, | ||
stack: 'bar', | ||
}, | ||
evt: { | ||
category: RumEventCategory.ERROR, | ||
}, | ||
http: { | ||
method: 'GET', | ||
status_code: 500, | ||
url: 'url', | ||
}, | ||
message: 'hello', | ||
}) | ||
}) | ||
}) | ||
}) | ||
describe('error collection v2', () => { | ||
let setupBuilder: TestSetupBuilder | ||
const errorObservable = new Observable<RawError>() | ||
let addError: ReturnType<typeof doStartErrorCollection>['addError'] | ||
beforeEach(() => { | ||
setupBuilder = setup() | ||
.withConfiguration({ | ||
isEnabled: () => true, | ||
}) | ||
.beforeBuild(({ lifeCycle, configuration }) => { | ||
;({ addError } = doStartErrorCollection(lifeCycle, configuration, errorObservable)) | ||
}) | ||
}) | ||
afterEach(() => { | ||
setupBuilder.cleanup() | ||
}) | ||
describe('provided', () => { | ||
it('notifies a raw rum error event', () => { | ||
const { rawRumEventsV2 } = setupBuilder.build() | ||
addError({ | ||
error: new Error('foo'), | ||
source: ErrorSource.CUSTOM, | ||
startTime: 12, | ||
}) | ||
expect(rawRumEventsV2.length).toBe(1) | ||
expect(rawRumEventsV2[0]).toEqual({ | ||
customerContext: undefined, | ||
rawRumEvent: { | ||
date: jasmine.any(Number), | ||
error: { | ||
message: 'foo', | ||
resource: undefined, | ||
source: ErrorSource.CUSTOM, | ||
stack: jasmine.stringMatching('Error: foo'), | ||
type: 'Error', | ||
}, | ||
type: RumEventType.ERROR, | ||
}, | ||
savedGlobalContext: undefined, | ||
startTime: 12, | ||
}) | ||
}) | ||
it('should save the specified customer context', () => { | ||
const { rawRumEventsV2 } = setupBuilder.build() | ||
addError({ | ||
context: { foo: 'bar' }, | ||
error: new Error('foo'), | ||
source: ErrorSource.CUSTOM, | ||
startTime: 12, | ||
}) | ||
expect(rawRumEventsV2[0].customerContext).toEqual({ | ||
foo: 'bar', | ||
}) | ||
}) | ||
it('should save the global context', () => { | ||
const { rawRumEventsV2 } = setupBuilder.build() | ||
addError( | ||
{ | ||
error: new Error('foo'), | ||
source: ErrorSource.CUSTOM, | ||
startTime: 12, | ||
}, | ||
{ foo: 'bar' } | ||
) | ||
expect(rawRumEventsV2[0].savedGlobalContext).toEqual({ | ||
foo: 'bar', | ||
}) | ||
}) | ||
}) | ||
describe('auto', () => { | ||
it('should create error event from collected error', () => { | ||
const { rawRumEventsV2 } = setupBuilder.build() | ||
errorObservable.notify({ | ||
message: 'hello', | ||
resource: { | ||
method: 'GET', | ||
statusCode: 500, | ||
url: 'url', | ||
}, | ||
source: ErrorSource.NETWORK, | ||
stack: 'bar', | ||
startTime: 1234, | ||
type: 'foo', | ||
}) | ||
expect(rawRumEventsV2[0].startTime).toBe(1234) | ||
expect(rawRumEventsV2[0].rawRumEvent).toEqual({ | ||
date: jasmine.any(Number), | ||
error: { | ||
message: 'hello', | ||
@@ -222,0 +106,0 @@ resource: { |
import { | ||
combine, | ||
computeStackTrace, | ||
Configuration, | ||
Context, | ||
ErrorSource, | ||
formatUnknownError, | ||
@@ -13,4 +11,3 @@ getTimestamp, | ||
} from '@datadog/browser-core' | ||
import { RumErrorEvent, RumEventCategory } from '../../../types' | ||
import { RumErrorEventV2, RumEventType } from '../../../typesV2' | ||
import { RumErrorEvent, RumEventType } from '../../../types' | ||
import { LifeCycle, LifeCycleEventType } from '../../lifeCycle' | ||
@@ -22,5 +19,7 @@ | ||
context?: Context | ||
source: ErrorSource | ||
source: ProvidedSource | ||
} | ||
export type ProvidedSource = 'custom' | 'network' | 'source' | ||
export function startErrorCollection(lifeCycle: LifeCycle, configuration: Configuration) { | ||
@@ -35,7 +34,3 @@ return doStartErrorCollection(lifeCycle, configuration, startAutomaticErrorCollection(configuration)) | ||
) { | ||
observable.subscribe((error) => { | ||
configuration.isEnabled('v2_format') | ||
? lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, processErrorV2(error)) | ||
: lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processError(error)) | ||
}) | ||
observable.subscribe((error) => lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processError(error))) | ||
@@ -45,14 +40,7 @@ return { | ||
const rawError = computeRawError(error, startTime, source) | ||
configuration.isEnabled('v2_format') | ||
? lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, { | ||
customerContext, | ||
savedGlobalContext, | ||
...processErrorV2(rawError), | ||
}) | ||
: lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
customerContext, | ||
savedGlobalContext, | ||
...processError(rawError), | ||
}) | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
customerContext, | ||
savedGlobalContext, | ||
...processError(rawError), | ||
}) | ||
}, | ||
@@ -62,3 +50,3 @@ } | ||
function computeRawError(error: unknown, startTime: number, source: ErrorSource): RawError { | ||
function computeRawError(error: unknown, startTime: number, source: ProvidedSource): RawError { | ||
const stackTrace = error instanceof Error ? computeStackTrace(error) : undefined | ||
@@ -69,33 +57,3 @@ return { startTime, source, ...formatUnknownError(stackTrace, error, 'Provided') } | ||
function processError(error: RawError) { | ||
const rawRumEvent: RumErrorEvent = combine( | ||
{ | ||
date: getTimestamp(error.startTime), | ||
error: { | ||
kind: error.type, | ||
origin: error.source, | ||
stack: error.stack, | ||
}, | ||
evt: { | ||
category: RumEventCategory.ERROR as const, | ||
}, | ||
message: error.message, | ||
}, | ||
error.resource | ||
? { | ||
http: { | ||
method: error.resource.method, | ||
status_code: error.resource.statusCode, | ||
url: error.resource.url, | ||
}, | ||
} | ||
: undefined | ||
) | ||
return { | ||
rawRumEvent, | ||
startTime: error.startTime, | ||
} | ||
} | ||
function processErrorV2(error: RawError) { | ||
const rawRumEvent: RumErrorEventV2 = { | ||
const rawRumEvent: RumErrorEvent = { | ||
date: getTimestamp(error.startTime), | ||
@@ -102,0 +60,0 @@ error: { |
import { setup, TestSetupBuilder } from '../../../../test/specHelper' | ||
import { RumPerformanceEntry } from '../../../browser/performanceCollection' | ||
import { RumEventCategory } from '../../../index' | ||
import { RumEventType } from '../../../typesV2' | ||
import { RumEventType } from '../../../types' | ||
import { LifeCycleEventType } from '../../lifeCycle' | ||
@@ -14,3 +13,3 @@ import { startLongTaskCollection } from './longTaskCollection' | ||
.withConfiguration({ | ||
isEnabled: () => false, | ||
isEnabled: () => true, | ||
}) | ||
@@ -50,51 +49,2 @@ .beforeBuild(({ lifeCycle, configuration }) => { | ||
date: jasmine.any(Number), | ||
duration: 100 * 1e6, | ||
evt: { | ||
category: RumEventCategory.LONG_TASK, | ||
}, | ||
}) | ||
}) | ||
}) | ||
describe('long task collection v2', () => { | ||
let setupBuilder: TestSetupBuilder | ||
beforeEach(() => { | ||
setupBuilder = setup() | ||
.withConfiguration({ | ||
isEnabled: () => true, | ||
}) | ||
.beforeBuild(({ lifeCycle, configuration }) => { | ||
startLongTaskCollection(lifeCycle, configuration) | ||
}) | ||
}) | ||
afterEach(() => { | ||
setupBuilder.cleanup() | ||
}) | ||
it('should only listen to long task performance entry', () => { | ||
const { lifeCycle, rawRumEventsV2 } = setupBuilder.build() | ||
;[ | ||
{ duration: 100, entryType: 'longtask', startTime: 1234 }, | ||
{ duration: 100, entryType: 'navigation', startTime: 1234 }, | ||
{ duration: 100, entryType: 'resource', startTime: 1234 }, | ||
{ duration: 100, entryType: 'paint', startTime: 1234 }, | ||
].forEach((entry) => { | ||
lifeCycle.notify(LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, entry as RumPerformanceEntry) | ||
}) | ||
expect(rawRumEventsV2.length).toBe(1) | ||
}) | ||
it('should create raw rum event from performance entry', () => { | ||
const { lifeCycle, rawRumEventsV2 } = setupBuilder.build() | ||
lifeCycle.notify(LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, { | ||
duration: 100, | ||
entryType: 'longtask', | ||
startTime: 1234, | ||
}) | ||
expect(rawRumEventsV2[0].startTime).toBe(1234) | ||
expect(rawRumEventsV2[0].rawRumEvent).toEqual({ | ||
date: jasmine.any(Number), | ||
longTask: { | ||
@@ -101,0 +51,0 @@ duration: 100 * 1e6, |
import { Configuration, getTimestamp, msToNs } from '@datadog/browser-core' | ||
import { RumEventCategory, RumLongTaskEvent } from '../../../types' | ||
import { RumEventType, RumLongTaskEventV2 } from '../../../typesV2' | ||
import { RumEventType, RumLongTaskEvent } from '../../../types' | ||
import { LifeCycle, LifeCycleEventType } from '../../lifeCycle' | ||
@@ -11,28 +10,14 @@ | ||
} | ||
if (configuration.isEnabled('v2_format')) { | ||
const rawRumEvent: RumLongTaskEventV2 = { | ||
date: getTimestamp(entry.startTime), | ||
longTask: { | ||
duration: msToNs(entry.duration), | ||
}, | ||
type: RumEventType.LONG_TASK, | ||
} | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, { | ||
rawRumEvent, | ||
startTime: entry.startTime, | ||
}) | ||
} else { | ||
const rawRumEvent: RumLongTaskEvent = { | ||
date: getTimestamp(entry.startTime), | ||
const rawRumEvent: RumLongTaskEvent = { | ||
date: getTimestamp(entry.startTime), | ||
longTask: { | ||
duration: msToNs(entry.duration), | ||
evt: { | ||
category: RumEventCategory.LONG_TASK, | ||
}, | ||
} | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent, | ||
startTime: entry.startTime, | ||
}) | ||
}, | ||
type: RumEventType.LONG_TASK, | ||
} | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent, | ||
startTime: entry.startTime, | ||
}) | ||
}) | ||
} |
import { RequestType, ResourceType } from '@datadog/browser-core' | ||
import { createResourceEntry } from '../../../../test/fixtures' | ||
import { setup, TestSetupBuilder } from '../../../../test/specHelper' | ||
import { RumEventCategory, RumResourceEvent } from '../../../types' | ||
import { RumEventType, RumResourceEventV2 } from '../../../typesV2' | ||
import { RumEventType, RumResourceEvent } from '../../../types' | ||
import { LifeCycleEventType } from '../../lifeCycle' | ||
import { RequestCompleteEvent } from '../../requestCollection' | ||
import { RumSession } from '../../rumSession' | ||
import { TraceIdentifier } from '../../tracing/tracer' | ||
@@ -24,3 +22,3 @@ import { startResourceCollection } from './resourceCollection' | ||
.withConfiguration({ | ||
isEnabled: () => false, | ||
isEnabled: () => true, | ||
}) | ||
@@ -50,16 +48,9 @@ .beforeBuild(({ lifeCycle, configuration, session }) => { | ||
date: (jasmine.any(Number) as unknown) as number, | ||
duration: 100 * 1e6, | ||
evt: { | ||
category: RumEventCategory.RESOURCE, | ||
}, | ||
http: { | ||
performance: undefined, | ||
resource: { | ||
duration: 100 * 1e6, | ||
size: undefined, | ||
type: ResourceType.OTHER, | ||
url: 'https://resource.com/valid', | ||
}, | ||
network: { | ||
bytesWritten: undefined, | ||
}, | ||
resource: { | ||
kind: ResourceType.OTHER, | ||
}, | ||
type: RumEventType.RESOURCE, | ||
}) | ||
@@ -85,14 +76,10 @@ }) | ||
date: (jasmine.any(Number) as unknown) as number, | ||
duration: 100 * 1e6, | ||
evt: { | ||
category: RumEventCategory.RESOURCE, | ||
}, | ||
http: { | ||
resource: { | ||
duration: 100 * 1e6, | ||
method: 'GET', | ||
statusCode: 200, | ||
type: ResourceType.XHR, | ||
url: 'https://resource.com/valid', | ||
}, | ||
resource: { | ||
kind: ResourceType.XHR, | ||
}, | ||
type: RumEventType.RESOURCE, | ||
}) | ||
@@ -111,3 +98,3 @@ }) | ||
.withConfiguration({ | ||
isEnabled: () => false, | ||
isEnabled: () => true, | ||
}) | ||
@@ -149,3 +136,3 @@ .beforeBuild(({ lifeCycle, configuration, session }) => { | ||
.withConfiguration({ | ||
isEnabled: () => false, | ||
isEnabled: () => true, | ||
}) | ||
@@ -196,3 +183,3 @@ .beforeBuild(({ lifeCycle, configuration, session }) => { | ||
.withConfiguration({ | ||
isEnabled: () => false, | ||
isEnabled: () => true, | ||
}) | ||
@@ -213,3 +200,3 @@ .beforeBuild(({ lifeCycle, configuration, session }) => { | ||
createResourceEntry({ | ||
traceId: 'xxx', | ||
traceId: '1234', | ||
}) | ||
@@ -220,3 +207,3 @@ ) | ||
expect(traceInfo).toBeDefined() | ||
expect(traceInfo.traceId).toBe('xxx') | ||
expect(traceInfo.traceId).toBe('1234') | ||
}) | ||
@@ -242,213 +229,2 @@ | ||
describe('resourceCollection V2', () => { | ||
let setupBuilder: TestSetupBuilder | ||
describe('when resource tracking is enabled', () => { | ||
beforeEach(() => { | ||
setupBuilder = setup() | ||
.withSession({ | ||
getId: () => '1234', | ||
isTracked: () => true, | ||
isTrackedWithResource: () => true, | ||
}) | ||
.withConfiguration({ | ||
isEnabled: () => true, | ||
}) | ||
.beforeBuild(({ lifeCycle, configuration, session }) => { | ||
startResourceCollection(lifeCycle, configuration, session) | ||
}) | ||
}) | ||
afterEach(() => { | ||
setupBuilder.cleanup() | ||
}) | ||
it('should create resource from performance entry', () => { | ||
const { lifeCycle, rawRumEventsV2 } = setupBuilder.build() | ||
lifeCycle.notify( | ||
LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, | ||
createResourceEntry({ | ||
duration: 100, | ||
name: 'https://resource.com/valid', | ||
startTime: 1234, | ||
}) | ||
) | ||
expect(rawRumEventsV2[0].startTime).toBe(1234) | ||
expect(rawRumEventsV2[0].rawRumEvent).toEqual({ | ||
date: (jasmine.any(Number) as unknown) as number, | ||
resource: { | ||
duration: 100 * 1e6, | ||
size: undefined, | ||
type: ResourceType.OTHER, | ||
url: 'https://resource.com/valid', | ||
}, | ||
type: RumEventType.RESOURCE, | ||
}) | ||
}) | ||
it('should create resource from completed request', () => { | ||
const { lifeCycle, rawRumEventsV2 } = setupBuilder.build() | ||
lifeCycle.notify( | ||
LifeCycleEventType.REQUEST_COMPLETED, | ||
createCompletedRequest({ | ||
duration: 100, | ||
method: 'GET', | ||
startTime: 1234, | ||
status: 200, | ||
type: RequestType.XHR, | ||
url: 'https://resource.com/valid', | ||
}) | ||
) | ||
expect(rawRumEventsV2[0].startTime).toBe(1234) | ||
expect(rawRumEventsV2[0].rawRumEvent).toEqual({ | ||
date: (jasmine.any(Number) as unknown) as number, | ||
resource: { | ||
duration: 100 * 1e6, | ||
method: 'GET', | ||
statusCode: 200, | ||
type: ResourceType.XHR, | ||
url: 'https://resource.com/valid', | ||
}, | ||
type: RumEventType.RESOURCE, | ||
}) | ||
}) | ||
}) | ||
describe('when resource tracking is disabled', () => { | ||
beforeEach(() => { | ||
setupBuilder = setup() | ||
.withSession({ | ||
getId: () => '1234', | ||
isTracked: () => true, | ||
isTrackedWithResource: () => false, | ||
}) | ||
.withConfiguration({ | ||
isEnabled: () => true, | ||
}) | ||
.beforeBuild(({ lifeCycle, configuration, session }) => { | ||
startResourceCollection(lifeCycle, configuration, session) | ||
}) | ||
}) | ||
afterEach(() => { | ||
setupBuilder.cleanup() | ||
}) | ||
it('should not create resource from performance entry', () => { | ||
const { lifeCycle, rawRumEventsV2 } = setupBuilder.build() | ||
lifeCycle.notify(LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, createResourceEntry()) | ||
expect(rawRumEventsV2.length).toBe(0) | ||
}) | ||
it('should not create resource from completed request', () => { | ||
const { lifeCycle, rawRumEventsV2 } = setupBuilder.build() | ||
lifeCycle.notify(LifeCycleEventType.REQUEST_COMPLETED, createCompletedRequest()) | ||
expect(rawRumEventsV2.length).toBe(0) | ||
}) | ||
}) | ||
describe('when resource tracking change', () => { | ||
let isTrackedWithResource = true | ||
beforeEach(() => { | ||
setupBuilder = setup() | ||
.withSession({ | ||
getId: () => '1234', | ||
isTracked: () => true, | ||
isTrackedWithResource: () => isTrackedWithResource, | ||
}) | ||
.withConfiguration({ | ||
isEnabled: () => true, | ||
}) | ||
.beforeBuild(({ lifeCycle, configuration, session }) => { | ||
startResourceCollection(lifeCycle, configuration, session) | ||
}) | ||
}) | ||
afterEach(() => { | ||
setupBuilder.cleanup() | ||
}) | ||
it('should enable/disable resource creation from performance entry', () => { | ||
const { lifeCycle, rawRumEventsV2 } = setupBuilder.build() | ||
lifeCycle.notify(LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, createResourceEntry()) | ||
expect(rawRumEventsV2.length).toBe(1) | ||
isTrackedWithResource = false | ||
lifeCycle.notify(LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, createResourceEntry()) | ||
expect(rawRumEventsV2.length).toBe(1) | ||
isTrackedWithResource = true | ||
lifeCycle.notify(LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, createResourceEntry()) | ||
expect(rawRumEventsV2.length).toBe(2) | ||
}) | ||
it('should enable/disable resource creation from completed request', () => { | ||
const { lifeCycle, rawRumEventsV2 } = setupBuilder.build() | ||
lifeCycle.notify(LifeCycleEventType.REQUEST_COMPLETED, createCompletedRequest()) | ||
expect(rawRumEventsV2.length).toBe(1) | ||
isTrackedWithResource = false | ||
lifeCycle.notify(LifeCycleEventType.REQUEST_COMPLETED, createCompletedRequest()) | ||
expect(rawRumEventsV2.length).toBe(1) | ||
isTrackedWithResource = true | ||
lifeCycle.notify(LifeCycleEventType.REQUEST_COMPLETED, createCompletedRequest()) | ||
expect(rawRumEventsV2.length).toBe(2) | ||
}) | ||
}) | ||
describe('tracing info', () => { | ||
beforeEach(() => { | ||
setupBuilder = setup() | ||
.withConfiguration({ | ||
isEnabled: () => true, | ||
}) | ||
.beforeBuild(({ lifeCycle, configuration, session }) => { | ||
startResourceCollection(lifeCycle, configuration, session) | ||
}) | ||
}) | ||
afterEach(() => { | ||
setupBuilder.cleanup() | ||
}) | ||
it('should be processed from traced initial document', () => { | ||
const { lifeCycle, rawRumEventsV2 } = setupBuilder.build() | ||
lifeCycle.notify( | ||
LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, | ||
createResourceEntry({ | ||
traceId: '1234', | ||
}) | ||
) | ||
const traceInfo = (rawRumEventsV2[0].rawRumEvent as RumResourceEventV2)._dd! | ||
expect(traceInfo).toBeDefined() | ||
expect(traceInfo.traceId).toBe('1234') | ||
}) | ||
it('should be processed from completed request', () => { | ||
const { lifeCycle, rawRumEventsV2 } = setupBuilder.build() | ||
lifeCycle.notify( | ||
LifeCycleEventType.REQUEST_COMPLETED, | ||
createCompletedRequest({ | ||
spanId: new TraceIdentifier(), | ||
traceId: new TraceIdentifier(), | ||
}) | ||
) | ||
const traceInfo = (rawRumEventsV2[0].rawRumEvent as RumResourceEventV2)._dd! | ||
expect(traceInfo).toBeDefined() | ||
expect(traceInfo.traceId).toBeDefined() | ||
expect(traceInfo.spanId).toBeDefined() | ||
}) | ||
}) | ||
}) | ||
function createCompletedRequest(details?: Partial<RequestCompleteEvent>): RequestCompleteEvent { | ||
@@ -455,0 +231,0 @@ const request: Partial<RequestCompleteEvent> = { |
@@ -11,4 +11,3 @@ import { | ||
import { RumPerformanceResourceTiming } from '../../../browser/performanceCollection' | ||
import { RumEventCategory, RumResourceEvent } from '../../../types' | ||
import { RumEventType, RumResourceEventV2 } from '../../../typesV2' | ||
import { RumEventType, RumResourceEvent } from '../../../types' | ||
import { LifeCycle, LifeCycleEventType } from '../../lifeCycle' | ||
@@ -29,5 +28,3 @@ import { RequestCompleteEvent } from '../../requestCollection' | ||
if (session.isTrackedWithResource()) { | ||
configuration.isEnabled('v2_format') | ||
? lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, processRequestV2(request)) | ||
: lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processRequest(request)) | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processRequest(request)) | ||
} | ||
@@ -38,5 +35,3 @@ }) | ||
if (session.isTrackedWithResource() && entry.entryType === 'resource' && !isRequestKind(entry)) { | ||
configuration.isEnabled('v2_format') | ||
? lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, processResourceEntryV2(entry)) | ||
: lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processResourceEntry(entry)) | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processResourceEntry(entry)) | ||
} | ||
@@ -47,3 +42,3 @@ }) | ||
function processRequest(request: RequestCompleteEvent) { | ||
const kind = request.type === RequestType.XHR ? ResourceType.XHR : ResourceType.FETCH | ||
const type = request.type === RequestType.XHR ? ResourceType.XHR : ResourceType.FETCH | ||
@@ -56,33 +51,2 @@ const matchingTiming = matchRequestTiming(request) | ||
const resourceEvent: RumResourceEvent = combine( | ||
{ | ||
date: getTimestamp(startTime), | ||
duration: msToNs(request.duration), | ||
evt: { | ||
category: RumEventCategory.RESOURCE as const, | ||
}, | ||
http: { | ||
method: request.method, | ||
statusCode: request.status, | ||
url: request.url, | ||
}, | ||
resource: { | ||
kind, | ||
}, | ||
}, | ||
tracingInfo, | ||
correspondingTimingOverrides | ||
) | ||
return { startTime, rawRumEvent: resourceEvent } | ||
} | ||
function processRequestV2(request: RequestCompleteEvent) { | ||
const type = request.type === RequestType.XHR ? ResourceType.XHR : ResourceType.FETCH | ||
const matchingTiming = matchRequestTiming(request) | ||
const startTime = matchingTiming ? matchingTiming.startTime : request.startTime | ||
const correspondingTimingOverrides = matchingTiming ? computePerformanceEntryMetricsV2(matchingTiming) : undefined | ||
const tracingInfo = computeRequestTracingInfo(request) | ||
const resourceEvent = combine( | ||
@@ -103,34 +67,10 @@ { | ||
) | ||
return { startTime, rawRumEvent: resourceEvent as RumResourceEventV2 } | ||
return { startTime, rawRumEvent: resourceEvent as RumResourceEvent } | ||
} | ||
function processResourceEntry(entry: RumPerformanceResourceTiming) { | ||
const resourceKind = computeResourceKind(entry) | ||
const type = computeResourceKind(entry) | ||
const entryMetrics = computePerformanceEntryMetrics(entry) | ||
const tracingInfo = computeEntryTracingInfo(entry) | ||
const resourceEvent: RumResourceEvent = combine( | ||
{ | ||
date: getTimestamp(entry.startTime), | ||
evt: { | ||
category: RumEventCategory.RESOURCE as const, | ||
}, | ||
http: { | ||
url: entry.name, | ||
}, | ||
resource: { | ||
kind: resourceKind, | ||
}, | ||
}, | ||
tracingInfo, | ||
entryMetrics | ||
) | ||
return { startTime: entry.startTime, rawRumEvent: resourceEvent } | ||
} | ||
function processResourceEntryV2(entry: RumPerformanceResourceTiming) { | ||
const type = computeResourceKind(entry) | ||
const entryMetrics = computePerformanceEntryMetricsV2(entry) | ||
const tracingInfo = computeEntryTracingInfo(entry) | ||
const resourceEvent = combine( | ||
@@ -148,3 +88,3 @@ { | ||
) | ||
return { startTime: entry.startTime, rawRumEvent: resourceEvent as RumResourceEventV2 } | ||
return { startTime: entry.startTime, rawRumEvent: resourceEvent as RumResourceEvent } | ||
} | ||
@@ -154,14 +94,2 @@ | ||
return { | ||
duration: computePerformanceResourceDuration(timing), | ||
http: { | ||
performance: computePerformanceResourceDetails(timing), | ||
}, | ||
network: { | ||
bytesWritten: computeSize(timing), | ||
}, | ||
} | ||
} | ||
function computePerformanceEntryMetricsV2(timing: RumPerformanceResourceTiming) { | ||
return { | ||
resource: { | ||
@@ -168,0 +96,0 @@ duration: computePerformanceResourceDuration(timing), |
@@ -74,3 +74,3 @@ import { createNewEvent, DOM_EVENT, restorePageVisibility, setPageVisibility } from '@datadog/browser-core' | ||
firstInputDelay: 100, | ||
loadEventEnd: 567, | ||
loadEvent: 567, | ||
}) | ||
@@ -105,3 +105,3 @@ }) | ||
domInteractive: 234, | ||
loadEventEnd: 567, | ||
loadEvent: 567, | ||
}) | ||
@@ -108,0 +108,0 @@ }) |
@@ -10,3 +10,3 @@ import { addEventListeners, DOM_EVENT, EventEmitter } from '@datadog/browser-core' | ||
domComplete?: number | ||
loadEventEnd?: number | ||
loadEvent?: number | ||
largestContentfulPaint?: number | ||
@@ -55,3 +55,3 @@ firstInputDelay?: number | ||
domInteractive: entry.domInteractive, | ||
loadEventEnd: entry.loadEventEnd, | ||
loadEvent: entry.loadEventEnd, | ||
}) | ||
@@ -58,0 +58,0 @@ } |
@@ -8,4 +8,3 @@ import { createRawRumEvent } from '../../../../test/fixtures' | ||
} from '../../../browser/performanceCollection' | ||
import { RawRumEvent, RumEventCategory } from '../../../types' | ||
import { RumEventType } from '../../../typesV2' | ||
import { RumEventType } from '../../../types' | ||
import { LifeCycleEventType } from '../../lifeCycle' | ||
@@ -493,3 +492,3 @@ import { | ||
domInteractive: 234, | ||
loadEventEnd: 567, | ||
loadEvent: 567, | ||
}) | ||
@@ -517,3 +516,3 @@ }) | ||
largestContentfulPaint: 789, | ||
loadEventEnd: 567, | ||
loadEvent: 567, | ||
}) | ||
@@ -570,3 +569,3 @@ expect(getViewEvent(2).timings).toEqual({}) | ||
largestContentfulPaint: 789, | ||
loadEventEnd: 567, | ||
loadEvent: 567, | ||
}) | ||
@@ -587,9 +586,2 @@ }) | ||
describe('event counts', () => { | ||
function createFakeCollectedRawRumEvent(category: RumEventCategory) { | ||
return { | ||
rawRumEvent: ({ evt: { category } } as unknown) as RawRumEvent, | ||
startTime: 0, | ||
} | ||
} | ||
it('should track error count', () => { | ||
@@ -600,157 +592,7 @@ const { lifeCycle } = setupBuilder.build() | ||
lifeCycle.notify( | ||
LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, | ||
createFakeCollectedRawRumEvent(RumEventCategory.ERROR) | ||
) | ||
lifeCycle.notify( | ||
LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, | ||
createFakeCollectedRawRumEvent(RumEventCategory.ERROR) | ||
) | ||
history.pushState({}, '', '/bar') | ||
expect(getHandledCount()).toEqual(3) | ||
expect(getViewEvent(1).eventCounts.errorCount).toEqual(2) | ||
expect(getViewEvent(2).eventCounts.errorCount).toEqual(0) | ||
}) | ||
it('should track long task count', () => { | ||
const { lifeCycle } = setupBuilder.build() | ||
expect(getHandledCount()).toEqual(1) | ||
expect(getViewEvent(0).eventCounts.longTaskCount).toEqual(0) | ||
lifeCycle.notify( | ||
LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, | ||
createFakeCollectedRawRumEvent(RumEventCategory.LONG_TASK) | ||
) | ||
history.pushState({}, '', '/bar') | ||
expect(getHandledCount()).toEqual(3) | ||
expect(getViewEvent(1).eventCounts.longTaskCount).toEqual(1) | ||
expect(getViewEvent(2).eventCounts.longTaskCount).toEqual(0) | ||
}) | ||
it('should track resource count', () => { | ||
const { lifeCycle } = setupBuilder.build() | ||
expect(getHandledCount()).toEqual(1) | ||
expect(getViewEvent(0).eventCounts.resourceCount).toEqual(0) | ||
lifeCycle.notify( | ||
LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, | ||
createFakeCollectedRawRumEvent(RumEventCategory.RESOURCE) | ||
) | ||
history.pushState({}, '', '/bar') | ||
expect(getHandledCount()).toEqual(3) | ||
expect(getViewEvent(1).eventCounts.resourceCount).toEqual(1) | ||
expect(getViewEvent(2).eventCounts.resourceCount).toEqual(0) | ||
}) | ||
it('should track action count', () => { | ||
const { lifeCycle } = setupBuilder.build() | ||
expect(getHandledCount()).toEqual(1) | ||
expect(getViewEvent(0).eventCounts.userActionCount).toEqual(0) | ||
lifeCycle.notify( | ||
LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, | ||
createFakeCollectedRawRumEvent(RumEventCategory.USER_ACTION) | ||
) | ||
history.pushState({}, '', '/bar') | ||
expect(getHandledCount()).toEqual(3) | ||
expect(getViewEvent(1).eventCounts.userActionCount).toEqual(1) | ||
expect(getViewEvent(2).eventCounts.userActionCount).toEqual(0) | ||
}) | ||
it('should reset event count when the view changes', () => { | ||
const { lifeCycle } = setupBuilder.build() | ||
expect(getHandledCount()).toEqual(1) | ||
expect(getViewEvent(0).eventCounts.resourceCount).toEqual(0) | ||
lifeCycle.notify( | ||
LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, | ||
createFakeCollectedRawRumEvent(RumEventCategory.RESOURCE) | ||
) | ||
history.pushState({}, '', '/bar') | ||
expect(getHandledCount()).toEqual(3) | ||
expect(getViewEvent(1).eventCounts.resourceCount).toEqual(1) | ||
expect(getViewEvent(2).eventCounts.resourceCount).toEqual(0) | ||
lifeCycle.notify( | ||
LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, | ||
createFakeCollectedRawRumEvent(RumEventCategory.RESOURCE) | ||
) | ||
lifeCycle.notify( | ||
LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, | ||
createFakeCollectedRawRumEvent(RumEventCategory.RESOURCE) | ||
) | ||
history.pushState({}, '', '/baz') | ||
expect(getHandledCount()).toEqual(5) | ||
expect(getViewEvent(3).eventCounts.resourceCount).toEqual(2) | ||
expect(getViewEvent(4).eventCounts.resourceCount).toEqual(0) | ||
}) | ||
it('should update eventCounts when a resource event is collected (throttled)', () => { | ||
const { lifeCycle, clock } = setupBuilder.withFakeClock().build() | ||
expect(getHandledCount()).toEqual(1) | ||
expect(getViewEvent(0).eventCounts).toEqual({ | ||
errorCount: 0, | ||
longTaskCount: 0, | ||
resourceCount: 0, | ||
userActionCount: 0, | ||
}) | ||
lifeCycle.notify( | ||
LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, | ||
createFakeCollectedRawRumEvent(RumEventCategory.RESOURCE) | ||
) | ||
expect(getHandledCount()).toEqual(1) | ||
clock.tick(THROTTLE_VIEW_UPDATE_PERIOD) | ||
expect(getHandledCount()).toEqual(2) | ||
expect(getViewEvent(1).eventCounts).toEqual({ | ||
errorCount: 0, | ||
longTaskCount: 0, | ||
resourceCount: 1, | ||
userActionCount: 0, | ||
}) | ||
}) | ||
it('should not update eventCounts after ending a view', () => { | ||
const { lifeCycle, clock } = setupBuilder.withFakeClock().build() | ||
expect(getHandledCount()).toEqual(1) | ||
lifeCycle.notify( | ||
LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, | ||
createFakeCollectedRawRumEvent(RumEventCategory.RESOURCE) | ||
) | ||
expect(getHandledCount()).toEqual(1) | ||
history.pushState({}, '', '/bar') | ||
expect(getHandledCount()).toEqual(3) | ||
expect(getViewEvent(1).id).toEqual(getViewEvent(0).id) | ||
expect(getViewEvent(2).id).not.toEqual(getViewEvent(0).id) | ||
clock.tick(THROTTLE_VIEW_UPDATE_PERIOD) | ||
expect(getHandledCount()).toEqual(3) | ||
}) | ||
}) | ||
describe('event counts V2', () => { | ||
it('should track error count', () => { | ||
const { lifeCycle } = setupBuilder.build() | ||
expect(getHandledCount()).toEqual(1) | ||
expect(getViewEvent(0).eventCounts.errorCount).toEqual(0) | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, { | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: createRawRumEvent(RumEventType.ERROR), | ||
startTime: 0, | ||
}) | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, { | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: createRawRumEvent(RumEventType.ERROR), | ||
@@ -771,3 +613,3 @@ startTime: 0, | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, { | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: createRawRumEvent(RumEventType.LONG_TASK), | ||
@@ -788,3 +630,3 @@ startTime: 0, | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, { | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: createRawRumEvent(RumEventType.RESOURCE), | ||
@@ -805,3 +647,3 @@ startTime: 0, | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, { | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: createRawRumEvent(RumEventType.ACTION), | ||
@@ -822,3 +664,3 @@ startTime: 0, | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, { | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: createRawRumEvent(RumEventType.RESOURCE), | ||
@@ -833,7 +675,7 @@ startTime: 0, | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, { | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: createRawRumEvent(RumEventType.RESOURCE), | ||
startTime: 0, | ||
}) | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, { | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: createRawRumEvent(RumEventType.RESOURCE), | ||
@@ -859,3 +701,3 @@ startTime: 0, | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, { | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: createRawRumEvent(RumEventType.RESOURCE), | ||
@@ -882,3 +724,3 @@ startTime: 0, | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, { | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: createRawRumEvent(RumEventType.RESOURCE), | ||
@@ -885,0 +727,0 @@ startTime: 0, |
@@ -131,3 +131,3 @@ import { addEventListener, DOM_EVENT, generateUUID, monitor, noop, ONE_MINUTE, throttle } from '@datadog/browser-core' | ||
const { setActivityLoadingTime, setLoadEventEnd } = trackLoadingTime(loadingType, (newLoadingTime) => { | ||
const { setActivityLoadingTime, setLoadEvent } = trackLoadingTime(loadingType, (newLoadingTime) => { | ||
loadingTime = newLoadingTime | ||
@@ -191,4 +191,4 @@ scheduleViewUpdate() | ||
timings = newTimings | ||
if (newTimings.loadEventEnd !== undefined) { | ||
setLoadEventEnd(newTimings.loadEventEnd) | ||
if (newTimings.loadEvent !== undefined) { | ||
setLoadEvent(newTimings.loadEvent) | ||
} | ||
@@ -229,3 +229,3 @@ }, | ||
function trackLoadingTime(loadType: ViewLoadingType, callback: (loadingTime: number) => void) { | ||
let isWaitingForLoadEventEnd = loadType === ViewLoadingType.INITIAL_LOAD | ||
let isWaitingForLoadEvent = loadType === ViewLoadingType.INITIAL_LOAD | ||
let isWaitingForActivityLoadingTime = true | ||
@@ -235,3 +235,3 @@ const loadingTimeCandidates: number[] = [] | ||
function invokeCallbackIfAllCandidatesAreReceived() { | ||
if (!isWaitingForActivityLoadingTime && !isWaitingForLoadEventEnd && loadingTimeCandidates.length > 0) { | ||
if (!isWaitingForActivityLoadingTime && !isWaitingForLoadEvent && loadingTimeCandidates.length > 0) { | ||
callback(Math.max(...loadingTimeCandidates)) | ||
@@ -242,6 +242,6 @@ } | ||
return { | ||
setLoadEventEnd(loadEventEnd: number) { | ||
if (isWaitingForLoadEventEnd) { | ||
isWaitingForLoadEventEnd = false | ||
loadingTimeCandidates.push(loadEventEnd) | ||
setLoadEvent(loadEvent: number) { | ||
if (isWaitingForLoadEvent) { | ||
isWaitingForLoadEvent = false | ||
loadingTimeCandidates.push(loadEvent) | ||
invokeCallbackIfAllCandidatesAreReceived() | ||
@@ -248,0 +248,0 @@ } |
import { setup, TestSetupBuilder } from '../../../../test/specHelper' | ||
import { RumEventCategory } from '../../../types' | ||
import { RumEventType } from '../../../typesV2' | ||
import { RumEventType } from '../../../types' | ||
import { LifeCycleEventType } from '../../lifeCycle' | ||
@@ -14,3 +13,3 @@ import { View, ViewLoadingType } from './trackViews' | ||
.withConfiguration({ | ||
isEnabled: () => false, | ||
isEnabled: () => true, | ||
}) | ||
@@ -29,2 +28,3 @@ .beforeBuild(({ lifeCycle, configuration }) => { | ||
const view = { | ||
cumulativeLayoutShift: 1, | ||
documentVersion: 3, | ||
@@ -49,4 +49,5 @@ duration: 100, | ||
firstContentfulPaint: 10, | ||
firstInputDelay: 12, | ||
largestContentfulPaint: 10, | ||
loadEventEnd: 10, | ||
loadEvent: 10, | ||
}, | ||
@@ -58,78 +59,2 @@ } | ||
expect(rawRumEvents[rawRumEvents.length - 1].rawRumEvent).toEqual({ | ||
date: jasmine.any(Number), | ||
duration: 100 * 1e6, | ||
evt: { | ||
category: RumEventCategory.VIEW, | ||
}, | ||
rum: { | ||
documentVersion: 3, | ||
}, | ||
view: { | ||
loadingTime: 20 * 1e6, | ||
loadingType: ViewLoadingType.INITIAL_LOAD, | ||
measures: { | ||
domComplete: 10 * 1e6, | ||
domContentLoaded: 10 * 1e6, | ||
domInteractive: 10 * 1e6, | ||
errorCount: 10, | ||
firstContentfulPaint: 10 * 1e6, | ||
loadEventEnd: 10 * 1e6, | ||
longTaskCount: 10, | ||
resourceCount: 10, | ||
userActionCount: 10, | ||
}, | ||
}, | ||
}) | ||
}) | ||
}) | ||
describe('viewCollection V2', () => { | ||
let setupBuilder: TestSetupBuilder | ||
beforeEach(() => { | ||
setupBuilder = setup() | ||
.withConfiguration({ | ||
isEnabled: () => true, | ||
}) | ||
.beforeBuild(({ lifeCycle, configuration }) => { | ||
startViewCollection(lifeCycle, configuration, location) | ||
}) | ||
}) | ||
afterEach(() => { | ||
setupBuilder.cleanup() | ||
}) | ||
it('should create view from view update', () => { | ||
const { lifeCycle, rawRumEventsV2 } = setupBuilder.build() | ||
const view = { | ||
cumulativeLayoutShift: 1, | ||
documentVersion: 3, | ||
duration: 100, | ||
eventCounts: { | ||
errorCount: 10, | ||
longTaskCount: 10, | ||
resourceCount: 10, | ||
userActionCount: 10, | ||
}, | ||
id: 'xxx', | ||
loadingTime: 20, | ||
loadingType: ViewLoadingType.INITIAL_LOAD, | ||
location: {}, | ||
referrer: '', | ||
startTime: 1234, | ||
timings: { | ||
domComplete: 10, | ||
domContentLoaded: 10, | ||
domInteractive: 10, | ||
firstContentfulPaint: 10, | ||
firstInputDelay: 12, | ||
largestContentfulPaint: 10, | ||
loadEventEnd: 10, | ||
}, | ||
} | ||
lifeCycle.notify(LifeCycleEventType.VIEW_UPDATED, view as View) | ||
expect(rawRumEventsV2[rawRumEventsV2.length - 1].startTime).toBe(1234) | ||
expect(rawRumEventsV2[rawRumEventsV2.length - 1].rawRumEvent).toEqual({ | ||
_dd: { | ||
@@ -154,3 +79,3 @@ documentVersion: 3, | ||
largestContentfulPaint: 10 * 1e6, | ||
loadEventEnd: 10 * 1e6, | ||
loadEvent: 10 * 1e6, | ||
loadingTime: 20 * 1e6, | ||
@@ -157,0 +82,0 @@ loadingType: ViewLoadingType.INITIAL_LOAD, |
import { Configuration, getTimestamp, msToNs } from '@datadog/browser-core' | ||
import { RumEventCategory, RumViewEvent } from '../../../types' | ||
import { RumEventType, RumViewEventV2 } from '../../../typesV2' | ||
import { RumEventType, RumViewEvent } from '../../../types' | ||
import { LifeCycle, LifeCycleEventType } from '../../lifeCycle' | ||
@@ -8,7 +7,5 @@ import { trackViews, View } from './trackViews' | ||
export function startViewCollection(lifeCycle: LifeCycle, configuration: Configuration, location: Location) { | ||
lifeCycle.subscribe(LifeCycleEventType.VIEW_UPDATED, (view) => { | ||
configuration.isEnabled('v2_format') | ||
? lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, processViewUpdateV2(view)) | ||
: lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processViewUpdate(view)) | ||
}) | ||
lifeCycle.subscribe(LifeCycleEventType.VIEW_UPDATED, (view) => | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processViewUpdate(view)) | ||
) | ||
@@ -20,31 +17,2 @@ return trackViews(location, lifeCycle) | ||
const viewEvent: RumViewEvent = { | ||
date: getTimestamp(view.startTime), | ||
duration: msToNs(view.duration), | ||
evt: { | ||
category: RumEventCategory.VIEW, | ||
}, | ||
rum: { | ||
documentVersion: view.documentVersion, | ||
}, | ||
view: { | ||
loadingTime: msToNs(view.loadingTime), | ||
loadingType: view.loadingType, | ||
measures: { | ||
...view.eventCounts, | ||
domComplete: msToNs(view.timings.domComplete), | ||
domContentLoaded: msToNs(view.timings.domContentLoaded), | ||
domInteractive: msToNs(view.timings.domInteractive), | ||
firstContentfulPaint: msToNs(view.timings.firstContentfulPaint), | ||
loadEventEnd: msToNs(view.timings.loadEventEnd), | ||
}, | ||
}, | ||
} | ||
return { | ||
rawRumEvent: viewEvent, | ||
startTime: view.startTime, | ||
} | ||
} | ||
function processViewUpdateV2(view: View) { | ||
const viewEvent: RumViewEventV2 = { | ||
_dd: { | ||
@@ -69,3 +37,3 @@ documentVersion: view.documentVersion, | ||
largestContentfulPaint: msToNs(view.timings.largestContentfulPaint), | ||
loadEventEnd: msToNs(view.timings.loadEventEnd), | ||
loadEvent: msToNs(view.timings.loadEvent), | ||
loadingTime: msToNs(view.loadingTime), | ||
@@ -72,0 +40,0 @@ loadingType: view.loadingType, |
import { objectValues } from '@datadog/browser-core' | ||
import { RawRumEvent, RumEventCategory } from '../types' | ||
import { RawRumEventV2, RumEventType } from '../typesV2' | ||
import { RawRumEvent, RumEventType } from '../types' | ||
import { LifeCycle, LifeCycleEventType } from './lifeCycle' | ||
@@ -14,5 +13,5 @@ import { EventCounts, trackEventCounts } from './trackEventCounts' | ||
function notifyCollectedRawRumEvent(category: RumEventCategory) { | ||
function notifyCollectedRawRumEvent(type: RumEventType) { | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, { | ||
rawRumEvent: ({ evt: { category } } as unknown) as RawRumEvent, | ||
rawRumEvent: ({ type } as unknown) as RawRumEvent, | ||
startTime: 0, | ||
@@ -24,69 +23,2 @@ }) | ||
const { eventCounts } = trackEventCounts(lifeCycle) | ||
notifyCollectedRawRumEvent(RumEventCategory.ERROR) | ||
expect(eventCounts.errorCount).toBe(1) | ||
}) | ||
it('tracks long tasks', () => { | ||
const { eventCounts } = trackEventCounts(lifeCycle) | ||
notifyCollectedRawRumEvent(RumEventCategory.LONG_TASK) | ||
expect(eventCounts.longTaskCount).toBe(1) | ||
}) | ||
it("doesn't track views", () => { | ||
const { eventCounts } = trackEventCounts(lifeCycle) | ||
notifyCollectedRawRumEvent(RumEventCategory.VIEW) | ||
expect(objectValues(eventCounts).every((value) => value === 0)).toBe(true) | ||
}) | ||
it('tracks actions', () => { | ||
const { eventCounts } = trackEventCounts(lifeCycle) | ||
notifyCollectedRawRumEvent(RumEventCategory.USER_ACTION) | ||
expect(eventCounts.userActionCount).toBe(1) | ||
}) | ||
it('tracks resources', () => { | ||
const { eventCounts } = trackEventCounts(lifeCycle) | ||
notifyCollectedRawRumEvent(RumEventCategory.RESOURCE) | ||
expect(eventCounts.resourceCount).toBe(1) | ||
}) | ||
it('stops tracking when stop is called', () => { | ||
const { eventCounts, stop } = trackEventCounts(lifeCycle) | ||
notifyCollectedRawRumEvent(RumEventCategory.RESOURCE) | ||
expect(eventCounts.resourceCount).toBe(1) | ||
stop() | ||
notifyCollectedRawRumEvent(RumEventCategory.RESOURCE) | ||
expect(eventCounts.resourceCount).toBe(1) | ||
}) | ||
it('invokes a potential callback when a count is increased', () => { | ||
const spy = jasmine.createSpy<(eventCounts: EventCounts) => void>() | ||
trackEventCounts(lifeCycle, spy) | ||
notifyCollectedRawRumEvent(RumEventCategory.RESOURCE) | ||
expect(spy).toHaveBeenCalledTimes(1) | ||
expect(spy.calls.mostRecent().args[0].resourceCount).toBe(1) | ||
notifyCollectedRawRumEvent(RumEventCategory.RESOURCE) | ||
expect(spy).toHaveBeenCalledTimes(2) | ||
expect(spy.calls.mostRecent().args[0].resourceCount).toBe(2) | ||
}) | ||
}) | ||
describe('trackEventCounts v2', () => { | ||
let lifeCycle: LifeCycle | ||
beforeEach(() => { | ||
lifeCycle = new LifeCycle() | ||
}) | ||
function notifyCollectedRawRumEvent(type: RumEventType) { | ||
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, { | ||
rawRumEvent: ({ type } as unknown) as RawRumEventV2, | ||
startTime: 0, | ||
}) | ||
} | ||
it('tracks errors', () => { | ||
const { eventCounts } = trackEventCounts(lifeCycle) | ||
notifyCollectedRawRumEvent(RumEventType.ERROR) | ||
@@ -93,0 +25,0 @@ expect(eventCounts.errorCount).toBe(1) |
import { noop } from '@datadog/browser-core' | ||
import { RumEventCategory } from '../types' | ||
import { RumEventType } from '../typesV2' | ||
import { RumEventType } from '../types' | ||
import { LifeCycle, LifeCycleEventType } from './lifeCycle' | ||
@@ -22,23 +21,2 @@ | ||
const subscription = lifeCycle.subscribe(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, ({ rawRumEvent }): void => { | ||
switch (rawRumEvent.evt.category) { | ||
case RumEventCategory.ERROR: | ||
eventCounts.errorCount += 1 | ||
callback(eventCounts) | ||
break | ||
case RumEventCategory.USER_ACTION: | ||
eventCounts.userActionCount += 1 | ||
callback(eventCounts) | ||
break | ||
case RumEventCategory.LONG_TASK: | ||
eventCounts.longTaskCount += 1 | ||
callback(eventCounts) | ||
break | ||
case RumEventCategory.RESOURCE: | ||
eventCounts.resourceCount += 1 | ||
callback(eventCounts) | ||
break | ||
} | ||
}) | ||
const subscriptionV2 = lifeCycle.subscribe(LifeCycleEventType.RAW_RUM_EVENT_V2_COLLECTED, ({ rawRumEvent }): void => { | ||
switch (rawRumEvent.type) { | ||
@@ -67,3 +45,2 @@ case RumEventType.ERROR: | ||
subscription.unsubscribe() | ||
subscriptionV2.unsubscribe() | ||
}, | ||
@@ -70,0 +47,0 @@ eventCounts, |
@@ -1,10 +0,1 @@ | ||
export { Datacenter, ErrorSource } from '@datadog/browser-core' | ||
export { RumUserConfiguration, RumGlobal, datadogRum } from './boot/rum.entry' | ||
export { | ||
InternalContext, | ||
RumEvent, | ||
RumEventCategory, | ||
RumUserActionEvent, | ||
RumViewEvent, | ||
RumResourceEvent, | ||
} from './types' |
import { Batch, combine, Configuration, Context, HttpRequest } from '@datadog/browser-core' | ||
import { LifeCycle, LifeCycleEventType } from '../domain/lifeCycle' | ||
import { RumEvent, RumEventCategory } from '../types' | ||
import { RumEventType, RumEventV2 } from '../typesV2' | ||
import { RumEvent, RumEventType } from '../types' | ||
@@ -12,13 +11,2 @@ export function startRumBatch(configuration: Configuration, lifeCycle: LifeCycle) { | ||
({ rumEvent, serverRumEvent }: { rumEvent: RumEvent; serverRumEvent: Context }) => { | ||
if (rumEvent.evt.category === RumEventCategory.VIEW) { | ||
batch.upsert(serverRumEvent, rumEvent.view.id) | ||
} else { | ||
batch.add(serverRumEvent) | ||
} | ||
} | ||
) | ||
lifeCycle.subscribe( | ||
LifeCycleEventType.RUM_EVENT_V2_COLLECTED, | ||
({ rumEvent, serverRumEvent }: { rumEvent: RumEventV2; serverRumEvent: Context }) => { | ||
if (rumEvent.type === RumEventType.VIEW) { | ||
@@ -68,6 +56,3 @@ batch.upsert(serverRumEvent, rumEvent.view.id) | ||
function withReplicaApplicationId(message: Context) { | ||
const applicationIdOverwrite = configuration.isEnabled('v2_format') | ||
? { application: { id: replica!.applicationId } } | ||
: { application_id: replica!.applicationId } | ||
return combine(message, applicationIdOverwrite) | ||
return combine(message, { application: { id: replica!.applicationId } }) | ||
} | ||
@@ -74,0 +59,0 @@ |
129
src/types.ts
import { Context, ErrorSource, ResourceType } from '@datadog/browser-core' | ||
import { ActionCounts, ActionType } from './domain/rumEventsCollection/action/trackActions' | ||
import { PerformanceResourceDetails } from './domain/rumEventsCollection/resource/resourceUtils' | ||
import { Timings } from './domain/rumEventsCollection/view/trackTimings' | ||
import { ActionType } from './domain/rumEventsCollection/action/trackActions' | ||
import { PerformanceResourceDetailsElement } from './domain/rumEventsCollection/resource/resourceUtils' | ||
import { ViewLoadingType } from './domain/rumEventsCollection/view/trackViews' | ||
import { EventCounts } from './domain/trackEventCounts' | ||
export enum RumEventCategory { | ||
USER_ACTION = 'user_action', | ||
export enum RumEventType { | ||
ACTION = 'action', | ||
ERROR = 'error', | ||
@@ -18,19 +16,18 @@ LONG_TASK = 'long_task', | ||
date: number | ||
duration: number | ||
evt: { | ||
category: RumEventCategory.RESOURCE | ||
} | ||
http: { | ||
performance?: PerformanceResourceDetails | ||
type: RumEventType.RESOURCE | ||
resource: { | ||
type: ResourceType | ||
id?: string // only for traced requests | ||
duration: number | ||
url: string | ||
method?: string | ||
statusCode?: number | ||
url: string | ||
size?: number | ||
redirect?: PerformanceResourceDetailsElement | ||
dns?: PerformanceResourceDetailsElement | ||
connect?: PerformanceResourceDetailsElement | ||
ssl?: PerformanceResourceDetailsElement | ||
firstByte?: PerformanceResourceDetailsElement | ||
download?: PerformanceResourceDetailsElement | ||
} | ||
network?: { | ||
bytesWritten?: number | ||
} | ||
resource: { | ||
kind: ResourceType | ||
id?: string // only for traced requests | ||
} | ||
_dd?: { | ||
@@ -44,16 +41,14 @@ traceId: string | ||
date: number | ||
http?: { | ||
url: string | ||
status_code: number | ||
method: string | ||
} | ||
type: RumEventType.ERROR | ||
error: { | ||
kind?: string | ||
resource?: { | ||
url: string | ||
statusCode: number | ||
method: string | ||
} | ||
type?: string | ||
stack?: string | ||
origin: ErrorSource | ||
source: ErrorSource | ||
message: string | ||
} | ||
evt: { | ||
category: RumEventCategory.ERROR | ||
} | ||
message: string | ||
} | ||
@@ -63,43 +58,60 @@ | ||
date: number | ||
duration: number | ||
evt: { | ||
category: RumEventCategory.VIEW | ||
type: RumEventType.VIEW | ||
view: { | ||
loadingType: ViewLoadingType | ||
firstContentfulPaint?: number | ||
firstInputDelay?: number | ||
cumulativeLayoutShift?: number | ||
largestContentfulPaint?: number | ||
domInteractive?: number | ||
domContentLoaded?: number | ||
domComplete?: number | ||
loadEvent?: number | ||
loadingTime?: number | ||
timeSpent: number | ||
error: Count | ||
action: Count | ||
longTask: Count | ||
resource: Count | ||
} | ||
rum: { | ||
_dd: { | ||
documentVersion: number | ||
} | ||
view: { | ||
loadingTime?: number | ||
loadingType: ViewLoadingType | ||
measures: EventCounts & Timings | ||
} | ||
} | ||
interface Count { | ||
count: number | ||
} | ||
export interface RumLongTaskEvent { | ||
date: number | ||
duration: number | ||
evt: { | ||
category: RumEventCategory.LONG_TASK | ||
type: RumEventType.LONG_TASK | ||
longTask: { | ||
duration: number | ||
} | ||
} | ||
export interface RumUserActionEvent { | ||
export interface RumActionEvent { | ||
date?: number | ||
duration?: number | ||
evt: { | ||
category: RumEventCategory.USER_ACTION | ||
name: string | ||
} | ||
userAction: { | ||
type: RumEventType.ACTION | ||
action: { | ||
id?: string | ||
type: ActionType | ||
measures?: ActionCounts | ||
loadingTime?: number | ||
error?: Count | ||
longTask?: Count | ||
resource?: Count | ||
target: { | ||
name: string | ||
} | ||
} | ||
} | ||
export type RawRumEvent = RumErrorEvent | RumResourceEvent | RumViewEvent | RumLongTaskEvent | RumUserActionEvent | ||
export type RawRumEvent = RumErrorEvent | RumResourceEvent | RumViewEvent | RumLongTaskEvent | RumActionEvent | ||
export interface RumContext { | ||
applicationId: string | ||
date: number | ||
application: { | ||
id: string | ||
} | ||
service?: string | ||
@@ -109,6 +121,11 @@ session: { | ||
} | ||
_dd: { | ||
formatVersion: 2 | ||
} | ||
} | ||
export interface ViewContext extends Context { | ||
sessionId: string | undefined | ||
session: { | ||
id: string | undefined | ||
} | ||
view: { | ||
@@ -122,3 +139,3 @@ id: string | ||
export interface ActionContext extends Context { | ||
userAction: { | ||
action: { | ||
id: string | ||
@@ -133,3 +150,3 @@ } | ||
| RumLongTaskEvent & ActionContext & ViewContext & RumContext | ||
| RumUserActionEvent & ViewContext & RumContext | ||
| RumActionEvent & ViewContext & RumContext | ||
@@ -136,0 +153,0 @@ export interface InternalContext { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
721862
239
12908
+ Added@datadog/browser-core@2.0.0(transitive)
- Removed@datadog/browser-core@1.26.3(transitive)
Updated@datadog/browser-core@2.0.0