UNPKG

@dash0hq/sdk-web

Version:

Dash0's Web SDK to collect telemetry from end-users' web browsers

3 lines (2 loc) 44 kB
function t(){}o("log");var e=o("info"),n=o("warn"),r=o("error"),i=o("debug");function o(e){return"undefined"==typeof console||"function"!=typeof console.log||"function"!=typeof console.log.apply?t:console[e]&&"function"==typeof console[e].apply?function(){console[e].apply(console,arguments)}:function(){console.log.apply(console,arguments)}}var a=Object.prototype.hasOwnProperty;function u(t,e){return a.call(t,e)}var s="undefined"!=typeof window?window:void 0,c=null==s?void 0:s.document,l=null==s?void 0:s.navigator,f="undefined"!=typeof location?location:void 0,d=(null==s?void 0:s.performance)||(null==s?void 0:s.webkitPerformance)||(null==s?void 0:s.msPerformance)||(null==s?void 0:s.mozPerformance);null==s||s.encodeURIComponent;var v=null==s?void 0:s.fetch,p=function(){try{var t;return null!==(t=null==s?void 0:s.localStorage)&&void 0!==t?t:null}catch(t){return null}}(),h=function(){try{var t;return null!==(t=null==s?void 0:s.sessionStorage)&&void 0!==t?t:null}catch(t){return null}}(),m=Array(32);function y(t){for(var e=0;e<2*t;e++)m[e]=Math.floor(16*Math.random())+48,m[e]>=58&&(m[e]+=39);return String.fromCharCode.apply(null,m.slice(0,2*t))}function g(t,e,n){t.addEventListener?t.addEventListener(e,n,!1):t.attachEvent&&t.attachEvent("on"+e,n)}var b=null!=p&&"function"==typeof p.getItem&&"function"==typeof p.setItem;function E(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function T(t,e,n,r,i,o,a){try{var u=t[o](a),s=u.value}catch(t){return void n(t)}u.done?e(s):Promise.resolve(s).then(r,i)}function w(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function a(t){T(o,r,i,a,u,"next",t)}function u(t){T(o,r,i,a,u,"throw",t)}a(void 0)}))}}function S(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=C(t))||e){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw o}}}}function A(){A=function(){return e};var t,e={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(t,e,n){t[e]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",s=o.toStringTag||"@@toStringTag";function c(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,n){return t[e]=n}}function l(t,e,n,r){var o=e&&e.prototype instanceof y?e:y,a=Object.create(o.prototype),u=new x(r||[]);return i(a,"_invoke",{value:O(t,n,u)}),a}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var d="suspendedStart",v="suspendedYield",p="executing",h="completed",m={};function y(){}function g(){}function b(){}var E={};c(E,a,(function(){return this}));var T=Object.getPrototypeOf,w=T&&T(T(R([])));w&&w!==n&&r.call(w,a)&&(E=w);var S=b.prototype=y.prototype=Object.create(E);function N(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function I(t,e){function n(i,o,a,u){var s=f(t[i],t,o);if("throw"!==s.type){var c=s.arg,l=c.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(l).then((function(t){c.value=t,a(c)}),(function(t){return n("throw",t,a,u)}))}u(s.arg)}var o;i(this,"_invoke",{value:function(t,r){function i(){return new e((function(e,i){n(t,r,e,i)}))}return o=o?o.then(i,i):i()}})}function O(e,n,r){var i=d;return function(o,a){if(i===p)throw Error("Generator is already running");if(i===h){if("throw"===o)throw a;return{value:t,done:!0}}for(r.method=o,r.arg=a;;){var u=r.delegate;if(u){var s=C(u,r);if(s){if(s===m)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===d)throw i=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=p;var c=f(e,n,r);if("normal"===c.type){if(i=r.done?h:v,c.arg===m)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=h,r.method="throw",r.arg=c.arg)}}}function C(e,n){var r=n.method,i=e.iterator[r];if(i===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,C(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),m;var o=f(i,e.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,m;var a=o.arg;return a?a.done?(n[e.resultName]=a.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,m):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function R(e){if(e||""===e){var n=e[a];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function n(){for(;++i<e.length;)if(r.call(e,i))return n.value=e[i],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}throw new TypeError(typeof e+" is not iterable")}return g.prototype=b,i(S,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=c(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,c(t,s,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},N(I.prototype),c(I.prototype,u,(function(){return this})),e.AsyncIterator=I,e.async=function(t,n,r,i,o){void 0===o&&(o=Promise);var a=new I(l(t,n,r,i),o);return e.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},N(S),c(S,s,"Generator"),c(S,a,(function(){return this})),c(S,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},e.values=R,x.prototype={constructor:x,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(_),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function i(r,i){return u.type="throw",u.arg=e,n.next=r,i&&(n.method="next",n.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,m):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),_(n),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;_(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:R(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),m}},e}function N(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o,a,u=[],s=!0,c=!1;try{if(o=(n=n.call(t)).next,0===e);else for(;!(s=(r=o.call(n)).done)&&(u.push(r.value),u.length!==e);s=!0);}catch(t){c=!0,i=t}finally{try{if(!s&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return u}}(t,e)||C(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function I(t){return function(t){if(Array.isArray(t))return E(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||C(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(t){return O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},O(t)}function C(t,e){if(t){if("string"==typeof t)return E(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?E(t,e):void 0}}function L(){return(new Date).getTime()}function _(){var t=R();return t?String(1e6*(d.now()+t)):x(new Date)}function x(t){return"object"===O(t)?x(t.getTime()):String(t)+"000000"}function R(){var t,e=null==d?void 0:d.timeOrigin;"number"!=typeof e&&(e=null==d||null===(t=d.timing)||void 0===t?void 0:t.fetchStart);return e}var k={setTimeout:null==s?void 0:s.setTimeout,clearTimeout:null==s?void 0:s.clearTimeout,setInterval:null==s?void 0:s.setInterval,clearInterval:null==s?void 0:s.clearInterval},D=null!=s&&null!=s.Zone&&null!=s.Zone.root&&"function"==typeof s.Zone.root.run;function P(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return M.apply("setTimeout",arguments)}function j(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return M.apply("setInterval",arguments)}function M(){var t,e=this;if(D)try{var r=Array.prototype.slice.apply(arguments);return s.Zone.root.run(k[e],s,r)}catch(t){n("Failed to execute %s inside of zone (via Zone.js). Falling back to execution inside currently active zone.",e,t)}return null===(t=k[e])||void 0===t?void 0:t.apply(s,arguments)}D&&i("Discovered Zone.js globals. Will attempt to register all timers inside the root Zone.");d&&d.getEntriesByType;var U=d&&"function"==typeof s.PerformanceObserver&&"function"==typeof d.now,F=Object.freeze({CONNECT_END:"connectEnd",CONNECT_START:"connectStart",DECODED_BODY_SIZE:"decodedBodySize",DOM_COMPLETE:"domComplete",DOM_CONTENT_LOADED_EVENT_END:"domContentLoadedEventEnd",DOM_CONTENT_LOADED_EVENT_START:"domContentLoadedEventStart",DOM_INTERACTIVE:"domInteractive",DOMAIN_LOOKUP_END:"domainLookupEnd",DOMAIN_LOOKUP_START:"domainLookupStart",ENCODED_BODY_SIZE:"encodedBodySize",FETCH_START:"fetchStart",LOAD_EVENT_END:"loadEventEnd",LOAD_EVENT_START:"loadEventStart",NAVIGATION_START:"navigationStart",REDIRECT_END:"redirectEnd",REDIRECT_START:"redirectStart",REQUEST_START:"requestStart",RESPONSE_END:"responseEnd",RESPONSE_START:"responseStart",SECURE_CONNECTION_START:"secureConnectionStart",START_TIME:"startTime",UNLOAD_EVENT_END:"unloadEventEnd",UNLOAD_EVENT_START:"unloadEventStart"});function V(e){return U?{start:function(){n=d.now();try{var t,e=null==s?void 0:s.PerformanceObserver;if(e)null===(t=o=new e(f))||void 0===t||t.observe({type:"resource"})}catch(t){}u=P(p,6e5)},end:function(){r=d.now(),h(),i||!B()?l():(g(c,"visibilitychange",v),a=P(l,e.maxWaitForResourceMillis))},cancel:p}:function(e){var n=0;return{start:function(){n=L()},end:function(){return e({duration:L()-n})},cancel:t}}(e.onEnd);var n,r,i,o,a,u;function l(){var t;p(),null!==(t=i)&&void 0!==t&&t.duration&&i.duration<864e5?e.onEnd({resource:i,duration:Math.round(i.duration)}):e.onEnd({resource:i,duration:Math.round(r-n)})}function f(t){var o=t.getEntriesByType("resource").find((function(t){var i=t;return i.startTime>=n&&(!r||r+e.maxToleranceForResourceTimingsMillis>=i.responseEnd)&&e.resourceMatcher(i)}));o&&(i=o,r&&l())}function v(){B()||l()}function p(){!function(){if(o){try{var t;null===(t=o)||void 0===t||t.disconnect()}catch(t){}o=void 0}}(),a&&(clearTimeout(a),a=void 0),h(),function(){if(!c)return;t=c,e="visibilitychange",n=v,t.removeEventListener?t.removeEventListener(e,n,!1):t.detachEvent&&t.detachEvent("on"+e,n);var t,e,n}()}function h(){u&&(clearTimeout(u),u=void 0)}}function B(){return"visible"===(null==c?void 0:c.visibilityState)||"prerender"===(null==c?void 0:c.visibilityState)}var H="undefined";function q(t){return Math.round(100*t)/100}function z(t){var e;return"string"!=typeof t?t:new URL(t,null!==(e=null==c?void 0:c.baseURI)&&void 0!==e?e:null==f?void 0:f.href)}function W(t){try{return z(t).origin===("undefined"!=typeof location?location.origin:void 0)}catch(t){return!1}}var G=Symbol.for("INSTRUMENTED_BY_DASH0");function K(t,e,n){var r=t[e];r?(!0===r[G]&&i("".concat(String(e)," has already been instrumented, skipping")),function(t){t[G]=!0}(r),t[e]=n(r)):i("".concat(String(e)," is not defined, unable to instrument"))}var Z={endpoints:[],resource:{attributes:[]},scope:{name:"dash0-web-sdk",version:"0.5.3",attributes:[]},signalAttributes:[],ignoreUrls:[],ignoreErrorMessages:[],wrapEventHandlers:!0,wrapTimers:!0,propagateTraceHeadersCorsURLs:[],maxWaitForResourceTimingsMillis:1e4,maxToleranceForResourceTimingsMillis:3e3,headersToCapture:[],pageViewInstrumentation:{trackVirtualPageViews:!0}},Y="service.name",Q="service.version",X="deployment.environment.name",$="deployment.name",J="deployment.id",tt="event.name",et="page.load.id",nt="user_agent.original",rt="user.id",it="user.name",ot="user.full_name",at="user.email",ut="user.hash",st="user.roles",ct="exception.message",lt="exception.type",ft="exception.stacktrace",dt="url.full",vt={UNSPECIFIED:0,TRACE:1,DEBUG:5,INFO:9,WARN:13,ERROR:17,FATAL:21},pt=0,ht=1,mt="pushState",yt="replaceState",gt="d0_session",bt="#",Et=864e5,Tt=null;function wt(t,e){if(b){t||(t=108e5),e||(e=216e5),t=Math.min(t,Et),e=Math.min(e,Et);try{var r=function(t){return b&&p?p.getItem(t):null}(gt),o=function(t){if(!t)return null;var e=t.split(bt);if(e.length<3)return null;var n=e[0],r=parseInt(e[1],10),i=parseInt(e[2],10);if(!n||isNaN(r)||isNaN(i))return null;return{id:n,startTime:r,lastActivityTime:i}}(r);o&&!function(t,e,n){var r=L()-e;if(t.lastActivityTime<r)return!1;var i=L()-n;return t.startTime>=i}(o,t,e)&&(o=null),o?o.lastActivityTime=L():o={id:y(16),startTime:L(),lastActivityTime:L()},function(t,e){b&&p&&p.setItem(t,e)}(gt,function(t){return t.id+bt+t.startTime+bt+t.lastActivityTime}(o)),Tt=o.id}catch(t){n("Failed to record session information",t)}}else i("Storage API is not available and session tracking is therefore not supported.")}function St(){if(Tt=null,b)try{!function(t){b&&p&&p.removeItem(t)}(gt)}catch(t){e("Failed to terminate session",t)}}var At,Nt=-1,It=function(t){addEventListener("pageshow",(function(e){e.persisted&&(Nt=e.timeStamp,t(e))}),!0)},Ot=function(){var t=self.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0];if(t&&t.responseStart>0&&t.responseStart<performance.now())return t},Ct=function(){var t=Ot();return t&&t.activationStart||0},Lt=function(t,e){var n=Ot(),r="navigate";return Nt>=0?r="back-forward-cache":n&&(document.prerendering||Ct()>0?r="prerender":document.wasDiscarded?r="restore":n.type&&(r=n.type.replace(/_/g,"-"))),{name:t,value:void 0===e?-1:e,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:r}},_t=function(t,e,n){try{if(PerformanceObserver.supportedEntryTypes.includes(t)){var r=new PerformanceObserver((function(t){Promise.resolve().then((function(){e(t.getEntries())}))}));return r.observe(Object.assign({type:t,buffered:!0},n||{})),r}}catch(t){}},xt=function(t,e,n,r){var i,o;return function(a){e.value>=0&&(a||r)&&((o=e.value-(i||0))||void 0===i)&&(i=e.value,e.delta=o,e.rating=function(t,e){return t>e[1]?"poor":t>e[0]?"needs-improvement":"good"}(e.value,n),t(e))}},Rt=function(t){requestAnimationFrame((function(){return requestAnimationFrame((function(){return t()}))}))},kt=function(t){document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&t()}))},Dt=function(t){var e=!1;return function(){e||(t(),e=!0)}},Pt=-1,jt=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},Mt=function(t){"hidden"===document.visibilityState&&Pt>-1&&(Pt="visibilitychange"===t.type?t.timeStamp:0,Ft())},Ut=function(){addEventListener("visibilitychange",Mt,!0),addEventListener("prerenderingchange",Mt,!0)},Ft=function(){removeEventListener("visibilitychange",Mt,!0),removeEventListener("prerenderingchange",Mt,!0)},Vt=function(){return Pt<0&&(Pt=jt(),Ut(),It((function(){setTimeout((function(){Pt=jt(),Ut()}),0)}))),{get firstHiddenTime(){return Pt}}},Bt=function(t){document.prerendering?addEventListener("prerenderingchange",(function(){return t()}),!0):t()},Ht=[1800,3e3],qt=[.1,.25],zt=function(t,e){e=e||{},function(t,e){e=e||{},Bt((function(){var n,r=Vt(),i=Lt("FCP"),o=_t("paint",(function(t){t.forEach((function(t){"first-contentful-paint"===t.name&&(o.disconnect(),t.startTime<r.firstHiddenTime&&(i.value=Math.max(t.startTime-Ct(),0),i.entries.push(t),n(!0)))}))}));o&&(n=xt(t,i,Ht,e.reportAllChanges),It((function(r){i=Lt("FCP"),n=xt(t,i,Ht,e.reportAllChanges),Rt((function(){i.value=performance.now()-r.timeStamp,n(!0)}))})))}))}(Dt((function(){var n,r=Lt("CLS",0),i=0,o=[],a=function(t){t.forEach((function(t){if(!t.hadRecentInput){var e=o[0],n=o[o.length-1];i&&t.startTime-n.startTime<1e3&&t.startTime-e.startTime<5e3?(i+=t.value,o.push(t)):(i=t.value,o=[t])}})),i>r.value&&(r.value=i,r.entries=o,n())},u=_t("layout-shift",a);u&&(n=xt(t,r,qt,e.reportAllChanges),kt((function(){a(u.takeRecords()),n(!0)})),It((function(){i=0,r=Lt("CLS",0),n=xt(t,r,qt,e.reportAllChanges),Rt((function(){return n()}))})),setTimeout(n,0))})))},Wt=0,Gt=1/0,Kt=0,Zt=function(t){t.forEach((function(t){t.interactionId&&(Gt=Math.min(Gt,t.interactionId),Kt=Math.max(Kt,t.interactionId),Wt=Kt?(Kt-Gt)/7+1:0)}))},Yt=function(){return At?Wt:performance.interactionCount||0},Qt=function(){"interactionCount"in performance||At||(At=_t("event",Zt,{type:"event",buffered:!0,durationThreshold:0}))},Xt=[],$t=new Map,Jt=0,te=[],ee=function(t){if(te.forEach((function(e){return e(t)})),t.interactionId||"first-input"===t.entryType){var e=Xt[Xt.length-1],n=$t.get(t.interactionId);if(n||Xt.length<10||t.duration>e.latency){if(n)t.duration>n.latency?(n.entries=[t],n.latency=t.duration):t.duration===n.latency&&t.startTime===n.entries[0].startTime&&n.entries.push(t);else{var r={id:t.interactionId,latency:t.duration,entries:[t]};$t.set(r.id,r),Xt.push(r)}Xt.sort((function(t,e){return e.latency-t.latency})),Xt.length>10&&Xt.splice(10).forEach((function(t){return $t.delete(t.id)}))}}},ne=function(t){var e=self.requestIdleCallback||self.setTimeout,n=-1;return t=Dt(t),"hidden"===document.visibilityState?t():(n=e(t),kt(t)),n},re=[200,500],ie=function(t,e){"PerformanceEventTiming"in self&&"interactionId"in PerformanceEventTiming.prototype&&(e=e||{},Bt((function(){var n;Qt();var r,i=Lt("INP"),o=function(t){ne((function(){t.forEach(ee);var e=function(){var t=Math.min(Xt.length-1,Math.floor((Yt()-Jt)/50));return Xt[t]}();e&&e.latency!==i.value&&(i.value=e.latency,i.entries=e.entries,r())}))},a=_t("event",o,{durationThreshold:null!==(n=e.durationThreshold)&&void 0!==n?n:40});r=xt(t,i,re,e.reportAllChanges),a&&(a.observe({type:"first-input",buffered:!0}),kt((function(){o(a.takeRecords()),r(!0)})),It((function(){Jt=Yt(),Xt.length=0,$t.clear(),i=Lt("INP"),r=xt(t,i,re,e.reportAllChanges)})))})))},oe=[2500,4e3],ae={},ue=!1;function se(t){var e,n,r=[];return n=i,ue&&n(),c&&s&&(g(c,"visibilitychange",(function(){"visible"!==c.visibilityState&&n()})),g(s,"pagehide",(function(){ue=!0,n()})),g(s,"beforeunload",(function(){ue=!0,n()}))),{send:function(n){"visible"===(null==c?void 0:c.visibilityState)?(r.push(n),r.length>=15?i():null==e&&(e=P(i,1e3))):t([n])}};function i(){null!=e&&(clearTimeout(e),e=null),r.length>0&&(t(r.slice()),r.length=0)}}function ce(t,e){return le.apply(this,arguments)}function le(){return le=w(A().mark((function e(r,i){var o,a,u,s;return A().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=JSON.stringify(i),a=o,u=o.length,s=!1,"undefined"==typeof CompressionStream){e.next=10;break}return e.next=7,fe(o);case 7:a=e.sent,u=a.byteLength,s=!0;case 10:return e.next=12,Promise.all(Z.endpoints.map(function(){var e=w(A().mark((function e(i){var o,c,l;return A().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,(o=new URL(i.url)).pathname=o.pathname+(o.pathname.endsWith("/")?r.substring(1):r),c={"Content-Type":"application/json",Authorization:"Bearer ".concat(i.authToken)},i.dataset&&(c["Dash0-Dataset"]=i.dataset),s&&(c["Content-Encoding"]="gzip"),v){e.next=9;break}return n("Unable to send telemetry, fetch is not defined"),e.abrupt("return");case 9:return e.next=11,v(o,{method:"POST",headers:c,body:a,keepalive:u<=6e4});case 11:(l=e.sent).text().catch(t),l.ok||n("Failed to send telemetry to ".concat(o,": ").concat(l.status," ").concat(l.statusText)),e.next=19;break;case 16:e.prev=16,e.t0=e.catch(0),n("Error sending telemetry to ".concat(i.url).concat(r,":"),e.t0);case 19:case"end":return e.stop()}}),e,null,[[0,16]])})));return function(t){return e.apply(this,arguments)}}()));case 12:case"end":return e.stop()}}),e)}))),le.apply(this,arguments)}function fe(t){return de.apply(this,arguments)}function de(){return(de=w(A().mark((function t(e){var n,r,i;return A().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Blob([e]),r=n.stream(),i=r.pipeThrough(new CompressionStream("gzip")),t.abrupt("return",new Response(i).arrayBuffer());case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var ve,pe=se((function(t){ce("/v1/logs",{resourceLogs:[{resource:Z.resource,scopeLogs:[{scope:Z.scope,logRecords:t}]}]}).catch((function(t){r("Failed to transmit logs",t)}))})),he=se((function(t){ce("/v1/traces",{resourceSpans:[{resource:Z.resource,scopeSpans:[{scope:Z.scope,spans:t}]}]}).catch((function(t){r("Failed to transmit spans",t)}))}));function me(){var t,e,n,r,i,o,a;return ve||(e=(t={maxCalls:8096,maxCallsPerTenMinutes:4096,maxCallsPerTenSeconds:128}).maxCalls,n=t.maxCallsPerTenMinutes,r=t.maxCallsPerTenSeconds,i=0,o=0,a=0,j((function(){o=0}),6e5),j((function(){a=0}),1e4),ve=function(){return++i>e||++o>n||++a>r}),ve()}function ye(t){me()?i("Transport rate limit. Will not send item.",t):pe.send(t)}function ge(t){me()?i("Transport rate limit. Will not send item.",t):he.send(t)}var be=["stringValue","boolValue","intValue","doubleValue","arrayValue","kvlistValue","bytesValue"];function Ee(t){if(null!=t){var e={};return Array.isArray(t)?e.arrayValue={values:t.map((function(t){return Ee(t)}))}:"string"==typeof t?e.stringValue=t:"number"==typeof t?e.doubleValue=t:"boolean"==typeof t?e.boolValue=t:!function(t){if(null==t||"object"!==O(t))return!1;var e=Object.keys(t);return 1===e.length&&be.includes(e[0])}(t)?"object"===O(t)&&(e.kvlistValue={values:Object.entries(t).map((function(t){var e=N(t,2);return Te(e[0],e[1])}))}):e=t,e}}function Te(t,e){return{key:t,value:Ee(e)}}function we(t,e,n){t.push(Te(e,n))}function Se(t,e){var n=t.findIndex((function(t){return t.key===e}));-1!==n&&t.splice(n,1)}var Ae="traceparent",Ne=/^00-([a-f0-9]{32})-([a-f0-9]{16})-[0-9]{1,2}$/;function Ie(){var t,e,n=((null===(t=Array.from(null!==(e=null==c?void 0:c.getElementsByTagName("meta"))&&void 0!==e?e:[]).find((function(t){var e;return(null===(e=t.getAttribute("name"))||void 0===e?void 0:e.toLowerCase())===Ae})))||void 0===t?void 0:t.content.trim())||"").match(Ne)||function(){var t=d.getEntriesByType("navigation")[0];if(!t)return"";if(!t.serverTiming)return"";return function(t){var e,n=S(t);try{for(n.s();!(e=n.n()).done;){var r=e.value;if(r.name===Ae)return r.description.trim()}}catch(t){n.e(t)}finally{n.f()}return""}(t.serverTiming)}().match(Ne);if(n)return{traceId:n[1],spanId:n[2]}}function Oe(t,e,n){t.call(e,"traceparent","00-".concat(n.traceId,"-").concat(n.traceId,"-02"))}function Ce(t,e,n){var r=t;return e&&(r.status=e),r.endTimeUnixNano=null!=n?String(Math.round(parseInt(r.startTimeUnixNano)+n)):_(),r}function Le(t,e,n,r){var i=void 0,o=void 0;"string"==typeof n?i=n:Array.isArray(n)&&(o=n),t.events.push({name:e,timeUnixNano:null!=i?i:_(),attributes:null!=o?o:[]})}var _e=null!=h&&"function"==typeof h.getItem&&"function"==typeof h.setItem;var xe="d0_tab",Re=null;function ke(){if(_e)try{var t=function(t){return _e&&h?h.getItem(t):null}(xe);if(t)return void(Re=t);Re=y(8),function(t,e){_e&&h&&h.setItem(t,e)}(xe,Re)}catch(t){n("Failed to record tab ID information",t)}else i("Storage API is not available and tab tracking is therefore not supported.")}function De(t,e){for(var n,r,i,o,a,u=0;u<Z.signalAttributes.length;u++)t.push(Z.signalAttributes[u]);!function(t,e){try{var n=z(e);n.username&&(n.username="REDACTED"),n.password&&(n.password="REDACTED"),we(t,dt,n.href),we(t,"url.path",n.pathname),we(t,"url.domain",n.hostname),we(t,"url.scheme",n.protocol.replace(":","")),n.hash&&we(t,"url.fragment",n.hash.replace("#","")),n.search&&we(t,"url.query",n.search.replace("?",""))}catch(n){we(t,dt,String(e))}}(t,null!==(n=null!==(r=null==e?void 0:e.url)&&void 0!==r?r:null==s?void 0:s.location.href)&&void 0!==n?n:H),Tt&&we(t,"session.id",Tt),Re&&we(t,"browser.tab.id",Re),we(t,"browser.window.width",null!==(i=null==s?void 0:s.innerWidth)&&void 0!==i?i:H),we(t,"browser.window.height",null!==(o=null==s?void 0:s.innerHeight)&&void 0!==o?o:H);var c=null==l||null===(a=l.connection)||void 0===a?void 0:a.effectiveType;c&&we(t,"network.connection.subtype",c)}function Pe(){!function(t,e){e=e||{},Bt((function(){var n,r=Vt(),i=Lt("LCP"),o=function(t){e.reportAllChanges||(t=t.slice(-1)),t.forEach((function(t){t.startTime<r.firstHiddenTime&&(i.value=Math.max(t.startTime-Ct(),0),i.entries=[t],n())}))},a=_t("largest-contentful-paint",o);if(a){n=xt(t,i,oe,e.reportAllChanges);var u=Dt((function(){ae[i.id]||(o(a.takeRecords()),a.disconnect(),ae[i.id]=!0,n(!0))}));["keydown","click"].forEach((function(t){addEventListener(t,(function(){return ne(u)}),{once:!0,capture:!0})})),kt(u),It((function(r){i=Lt("LCP"),n=xt(t,i,oe,e.reportAllChanges),Rt((function(){i.value=performance.now()-r.timeStamp,ae[i.id]=!0,n(!0)}))}))}}))}(je),ie(je),zt(je)}function je(t){var e=[];we(e,tt,"browser.web_vital");var n=[];we(n,"name",t.name),we(n,"value",q(t.value)),we(n,"delta",q(t.delta));var r={timeUnixNano:_(),attributes:e,severityNumber:vt.INFO,severityText:"INFO",body:{kvlistValue:{values:n}}};De(r.attributes),ye(r)}function Me(t,e){for(var n=0,r=t.length;n<r;n++)if(t[n].test(e))return!0;return!1}var Ue="data:";function Fe(t){return!t||(!(t=String(t))||(null==t.substring||t.substring(0,5).toLowerCase()===Ue||(!!function(t){for(var e=t.toLowerCase(),n=0,r=Z.endpoints.length;n<r;n++){var i=Z.endpoints[n];if(e.startsWith(i.url))return!0}return!1}(t)||Me(Z.ignoreUrls,t))))}var Ve,Be=0,He=0,qe={},ze=!1;function We(){ze=!0}function Ge(t,e){t&&Ke("string"==typeof t?{message:t,opts:e}:{message:t.message,type:t.name,stack:t.stack,opts:e})}function Ke(t){var e=t.message,n=t.type,r=t.stack,i=t.opts;if(e&&!(Be>100)&&!function(t){return!t||Me(Z.ignoreErrorMessages,t)}(e)){He>=20&&(qe={},He=0);var o=(e=String(e).substring(0,300))+(r=function(t){return String(t||"").split("\n").slice(0,30).join("\n")}(r))+(null==s?void 0:s.location.href),a=qe[o];if(a)a.seenCount++;else{var u=[];we(u,tt,"browser.error"),we(u,ct,e),n&&we(u,lt,n),r&&we(u,ft,r),null!=i&&i.componentStack&&we(u,"exception.component_stack",null==i?void 0:i.componentStack.substring(0,2048)),De(u),a={seenCount:1,transmittedCount:0,log:{timeUnixNano:_(),attributes:u,severityNumber:vt.ERROR,severityText:"ERROR",body:{stringValue:e}}},qe[o]=a,He++}!function(){if(Ve)return;Ve=setTimeout(Ze,1e3)}()}}function Ze(){for(var t in Ve&&(clearTimeout(Ve),Ve=null),qe)if(u(qe,t)){var e=qe[t];e.seenCount>e.transmittedCount&&(ye(e.log),Be++)}qe={},He=0}var Ye="Unhandled promise rejection: ",Qe="<unavailable because Promise wasn't rejected with an Error object>";function Xe(t){null==t.reason?Ge({message:Ye+"<no reason defined>",stack:Qe}):"string"==typeof t.reason.message?Ge({message:Ye+t.reason.message,stack:"string"==typeof t.reason.stack?t.reason.stack:Qe}):"object"!==O(t.reason)&&Ge({message:Ye+t.reason,stack:Qe})}var $e="__dash0OriginalFunctions";function Je(t,e){for(var n=t[$e],r=0;r<n.length;r++){if(tn(n[r].valuesForEqualityCheck,e))return r}return-1}function tn(t,e){if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function en(t,e,n,r,i){return function(t,e,n){if(!t)return e;var r=t[$e]=t[$e]||[],i=Je(t,n);return-1!==i?r[i].wrappedFunction:(r.push({wrappedFunction:e,valuesForEqualityCheck:n}),e)}(t,e,nn(n,r,i))}function nn(t,e,n){return[t,e,rn(n)]}function rn(t){return null!=t&&("object"===O(t)?Boolean(t.capture):Boolean(t))}function on(t,e,n,r,i){return function(t,e,n){var r=null==t?void 0:t[$e];if(null==r)return n;var i=Je(t,e);if(-1===i)return n;var o=r[i];return r.splice(i,1),o.wrappedFunction}(t,nn(e,n,r),i)}function an(){Z.wrapEventHandlers&&function(t){if(!t||"function"!=typeof t.prototype.addEventListener||"function"!=typeof t.prototype.removeEventListener)return;var e=t.prototype.addEventListener,n=t.prototype.removeEventListener;t.prototype.addEventListener=function(t,n,r){if("function"!=typeof n)return e.apply(this,arguments);for(var i=new Array(arguments.length),o=0;o<arguments.length;o++)i[o]=arguments[o];return i[1]=function(){try{return n.apply(this,arguments)}catch(t){throw reportError(t),We(),t}},i[1]=en(this,i[1],t,n,r),e.apply(this,i)},t.prototype.removeEventListener=function(t,e,r){if("function"!=typeof e)return n.apply(this,arguments);for(var i=new Array(arguments.length),o=0;o<arguments.length;o++)i[o]=arguments[o];return i[1]=on(this,t,e,r,e),n.apply(this,i)}}(null==s?void 0:s.EventTarget)}function un(t){var e=null==s?void 0:s[t];"function"==typeof e&&(s[t]=function(t){for(var n=new Array(arguments.length),r=0;r<arguments.length;r++)n[r]=arguments[r];return n[0]=function(t){if("function"!=typeof t)return t;return function(){try{return t.apply(this,arguments)}catch(t){throw reportError(t),We(),t}}}(t),e.apply(this,n)})}function sn(){!function(){if(s){var t=s.onerror;s.onerror=function(e,n,r,i,o){if(ze)return ze=!1,"function"==typeof t?t.apply(this,arguments):void 0;var a=o&&o.stack;return a||(a="at "+n+" "+r,null!=i&&(a+=":"+i)),Ke({message:String(e),stack:a}),"function"==typeof t?t.apply(this,arguments):void 0}}}(),"function"==typeof(null==s?void 0:s.addEventListener)&&s.addEventListener("unhandledrejection",Xe),an(),function(){if(Z.wrapTimers){if(D)return void n("We discovered a usage of Zone.js. In order to avoid any incompatibility issues timer wrapping is not going to be enabled.");un("setTimeout"),un("setInterval")}}()}var cn=["GET","HEAD","POST","PUT","DELETE","CONNECT","OPTIONS","TRACE","PATCH"];function ln(t){return cn.includes(t)}function fn(t,e){var n=0!==e.startTime;dn(t,F.FETCH_START,e,n),dn(t,F.DOMAIN_LOOKUP_START,e,n),dn(t,F.DOMAIN_LOOKUP_END,e,n),dn(t,F.CONNECT_START,e,n),dn(t,F.SECURE_CONNECTION_START,e,n),dn(t,F.CONNECT_END,e,n),dn(t,F.REQUEST_START,e,n),dn(t,F.RESPONSE_START,e,n),dn(t,F.RESPONSE_END,e,n)}function dn(t,e,n){var r,i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];!(e in n)||"number"!=typeof n[e]||i&&0===n[e]||Le(t,e,(r=n[e],String(Math.round(1e6*(r+R())))))}function vn(t,e){var n=e.encodedBodySize;null!=n&&we(t.attributes,"http.response.body.size",n)}function pn(t){return function(){var e=w(A().mark((function e(n,r){var o,a,u,s,c,l,f,d,v,p,h,m,g,b;return A().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(u=r?Object.assign({},r):r,s=null,null!==(o=u)&&void 0!==o&&o.body&&(s=u.body,u.body=void 0),c=new Request(n,u),s&&u&&(u.body=s),!Fe(l=c.url)){e.next=9;break}return i("Not creating span for fetch call because the url is ignored, URL: ".concat(l)),e.abrupt("return",t(n instanceof Request?c:n,r));case 9:return f=null!==(a=c.method)&&void 0!==a?a:"GET",d=ln(f),v=ln(f.toUpperCase()),p=v?f.toUpperCase():"_OTHER",E="HTTP ".concat(p),De((h={traceId:y(16),spanId:y(8),name:E,kind:3,startTimeUnixNano:_(),attributes:[],events:[],links:[],status:{code:0}}).attributes,{url:l}),hn(n,r),we(h.attributes,"http.request.method",p),d||we(h.attributes,"http.request.method_original",f),(W(l)||Me(Z.propagateTraceHeadersCorsURLs,l))&&(null!==(m=u)&&void 0!==m&&m.headers?(u.headers=new Headers(u.headers),Oe(u.headers.append,u.headers,h)):n instanceof Request?Oe(c.headers.append,c.headers,h):(u||(u={}),u.headers=new Headers,Oe(u.headers.append,u.headers,h))),mn(c.headers,h,(function(t){return e=t,"".concat("http.request.header",".").concat(e.toLowerCase());var e})),g=V({resourceMatcher:function(t){var e=t.initiatorType,n=t.name;return("fetch"===e||"xmlhttprequest"===e)&&n===z(l).href},maxWaitForResourceMillis:Z.maxWaitForResourceTimingsMillis,maxToleranceForResourceTimingsMillis:Z.maxToleranceForResourceTimingsMillis,onEnd:function(t){var e=t.duration,n=t.resource;n&&(fn(h,n),vn(h,n)),ge(Ce(h,void 0,1e6*e))}}),g.start(),e.prev=23,e.next=26,t(n instanceof Request?c:n,u);case 26:return b=e.sent,yn(h,b),gn(b).then((function(){return g.end()})).catch((function(t){g.cancel(),bn(h,t)})),e.abrupt("return",b);case 32:throw e.prev=32,e.t0=e.catch(23),g.cancel(),bn(h,e.t0),e.t0;case 37:case"end":return e.stop()}var E}),e,null,[[23,32]])})));return function(t,n){return e.apply(this,arguments)}}()}function hn(t,e,n){try{return void 0}catch(n){i("failed to analyze request for GraphQL insights",n,t,e)}}function mn(t,e,n){try{t.forEach((function(t,r){Z.headersToCapture.some((function(t){return t.test(r)}))&&we(e.attributes,n(r),t)}))}catch(t){i("unable to capture http headers due to CORS policy")}}function yn(t,e){var n=e.status;!function(t,e,n){t.status={code:e,message:n}}(t,n>=200&&n<400?0:2,e.statusText),we(t.attributes,"http.response.status_code",String(n)),mn(e.headers,t,(function(t){return e=t,"".concat("http.response.header",".").concat(e.toLowerCase());var e}))}function gn(t){return new Promise((function(e){var n=t.clone().body;if(!n)return e();var r=n.getReader(),i=function(){var t=w(A().mark((function t(){var n;return A().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.read();case 2:if(n=t.sent,!n.done){t.next=6;break}return t.abrupt("return",e());case 6:return t.abrupt("return",i());case 7:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();return i()}))}function bn(t,e){!function(t,e){var n=[];"string"==typeof e?we(n,ct,e):e&&(e.code?we(n,lt,e.code.toString()):e.name&&we(n,lt,e.name),e.message&&we(n,ct,e.message),e.stack&&we(n,ft,e.stack),Le(t,"exception",n))}(t,e),ge(Ce(t,function(t){return{code:2,message:t&&"object"===O(t)&&"message"in t?t.message:String(t)}}(e),void 0))}function En(t,e,n,r){var i,o,a=function(t){var e,n,r;return t&&null!==(e=null===(n=(r=Z.pageViewInstrumentation).generateMetadata)||void 0===n?void 0:n.call(r,t))&&void 0!==e?e:{}}(e),u=[];we(u,tt,"browser.page_view"),a.attributes&&Object.entries(a.attributes).forEach((function(t){var e=N(t,2),n=e[0],r=e[1];return we(u,n,r)})),De(u,{url:e});var s=[];we(s,"title",null!==(i=null!==(o=a.title)&&void 0!==o?o:null==c?void 0:c.title)&&void 0!==i?i:H),null!=c&&c.referrer&&we(s,"referrer",c.referrer),we(s,"type",n?ht:pt),we(s,"change_state",r?yt:mt);var l={timeUnixNano:t,attributes:u,severityNumber:vt.INFO,severityText:"INFO",body:{kvlistValue:{values:s}}},f=Ie();f&&(l.traceId=f.traceId,l.spanId=f.spanId),ye(l)}function Tn(){var t=null==s?void 0:s.performance.getEntriesByType("navigation")[0];if(t){var e=[];we(e,tt,"browser.navigation_timing");var n=[];we(n,"name",t.name),wn(n,t,"responseStatus"),wn(n,t,"fetchStart"),wn(n,t,"requestStart"),wn(n,t,"responseStart"),wn(n,t,"domInteractive"),wn(n,t,"domContentLoadedEventEnd"),wn(n,t,"domComplete"),wn(n,t,"loadEventEnd"),wn(n,t,"transferSize"),wn(n,t,"encodedBodySize"),wn(n,t,"decodedBodySize");var r={timeUnixNano:Sn(),attributes:e,severityNumber:vt.INFO,severityText:"INFO",body:{kvlistValue:{values:n}}};De(r.attributes);var o=Ie();o&&(r.traceId=o.traceId,r.spanId=o.spanId),ye(r)}else i("Navigation timings not available. Cannot emit navigation timing log")}function wn(t,e,n){var r=e[n];"number"!=typeof r||isNaN(r)||we(t,n,Number.isInteger(r)?r:q(r))}function Sn(){return x(Math.round(R()))}var An={},Nn=!1,In=!1;function On(){Ln(null==s?void 0:s.location.href)}function Cn(t){Ln(t.newURL)}function Ln(t,e){var n;if(t)try{var r=new URL(t,null==s?void 0:s.location.href);((n=r).pathname!==An.path||!In&&n.search!==An.search||!Nn&&n.hash!==An.hash)&&(_n(r),En(_(),r,!0,Boolean(e)))}catch(t){i("Failed to handle url change",t)}}function _n(t){An.path=t.pathname,An.search=t.search,An.hash=t.hash}function xn(){!function(){try{En(Sn(),null!=s&&s.location.href?new URL(null==s?void 0:s.location.href):void 0)}catch(t){r("Failed to transmit initial page view event",t)}if("complete"===(null==c?void 0:c.readyState))return Tn();s&&g(s,"load",(function(){setTimeout(Tn,0)}))}(),function(){var t,e,n,r;if(s&&s.history){if(Z.pageViewInstrumentation.trackVirtualPageViews){In=null!==(t=null===(e=Z.pageViewInstrumentation.ignoreParts)||void 0===e?void 0:e.includes("SEARCH"))&&void 0!==t&&t,Nn=null!==(n=null===(r=Z.pageViewInstrumentation.ignoreParts)||void 0===r?void 0:r.includes("HASH"))&&void 0!==n&&n,K(s.history,"replaceState",(function(t){return function(e,n,r){return Ln(r?String(r):void 0,!0),t.apply(this,[e,n,r])}})),K(s.history,"pushState",(function(t){return function(e,n,r){return Ln(r?String(r):void 0),t.apply(this,[e,n,r])}})),s.addEventListener("hashchange",Cn),s.addEventListener("popstate",On);try{_n(new URL(s.location.href))}catch(t){}}}else i("Browser does not support history API, skipping instrumentation")}()}var Rn=function(t){if("object"===O(t)&&null!==t){if("function"==typeof Object.getPrototypeOf){var e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}return"[object Object]"===Object.prototype.toString.call(t)}return!1},kn=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.reduce((function(t,e){if(void 0===e)return t;if(Array.isArray(e))throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");return Object.keys(e).forEach((function(n){["__proto__","constructor","prototype"].includes(n)||(Array.isArray(t[n])&&Array.isArray(e[n])?t[n]=kn.options.mergeArrays?kn.options.uniqueArrayItems?Array.from(new Set(t[n].concat(e[n]))):[].concat(I(t[n]),I(e[n])):e[n]:Rn(t[n])&&Rn(e[n])?t[n]=kn(t[n],e[n]):!Rn(t[n])&&Rn(e[n])?t[n]=kn(e[n],void 0):t[n]=void 0===e[n]?kn.options.allowUndefinedOverrides?e[n]:t[n]:e[n])})),t}),{})},Dn={allowUndefinedOverrides:!0,mergeArrays:!0,uniqueArrayItems:!0};kn.options=Dn,kn.withOptions=function(t){kn.options=Object.assign(Object.assign({},Dn),t);for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];var i=kn.apply(void 0,n);return kn.options=Dn,i};var Pn=!1;function jn(t){Pn?i("Dash0 SDK is being reinitialized, skipping ..."):null!=s?"function"==typeof v&&d&&d.getEntriesByType?(Z.endpoints=t.endpoint instanceof Array?t.endpoint:[t.endpoint],0!==Z.endpoints.length?(Object.assign(Z,kn(Z,function(t,e){var n,r={},i=S(e);try{for(i.s();!(n=i.n()).done;){var o=n.value;o in t&&(r[o]=t[o])}}catch(t){i.e(t)}finally{i.f()}return r}(t,["ignoreUrls","ignoreErrorMessages","wrapEventHandlers","wrapTimers","propagateTraceHeadersCorsURLs","maxWaitForResourceTimingsMillis","maxToleranceForResourceTimingsMillis","headersToCapture","pageViewInstrumentation"]))),function(t){we(Z.resource.attributes,Y,t.serviceName),t.serviceVersion&&we(Z.resource.attributes,Q,t.serviceVersion);var e=function(t){if(t.environment)return t.environment;try{var e;return null===(e=process)||void 0===e||null===(e=e.env)||void 0===e?void 0:e.NEXT_PUBLIC_VERCEL_ENV}catch(t){return}}(t);e&&we(Z.resource.attributes,X,e);var n=function(t){if(t.deploymentName)return t.deploymentName;try{var e;return null===(e=process)||void 0===e||null===(e=e.env)||void 0===e?void 0:e.NEXT_PUBLIC_VERCEL_TARGET_ENV}catch(t){return}}(t);n&&we(Z.resource.attributes,$,n);var r=function(t){if(t.deploymentId)return t.deploymentId;try{var e;return null===(e=process)||void 0===e||null===(e=e.env)||void 0===e?void 0:e.NEXT_PUBLIC_VERCEL_BRANCH_URL}catch(t){return}}(t);r&&we(Z.resource.attributes,J,r)}(t),function(t){var e;we(Z.signalAttributes,et,y(16)),we(Z.signalAttributes,nt,null!==(e=null==l?void 0:l.userAgent)&&void 0!==e?e:H),t.additionalSignalAttributes&&Object.entries(t.additionalSignalAttributes).forEach((function(t){var e=N(t,2),n=e[0],r=e[1];we(Z.signalAttributes,n,r)}))}(t),ke(),wt(t.sessionInactivityTimeoutMillis,t.sessionTerminationTimeoutMillis),xn(),Pe(),sn(),s&&s.fetch&&s.Request?K(s,"fetch",pn):i("Browser does not support the Fetch API, skipping instrumentation"),Pn=!0):n("No telemetry endpoint configured. Aborting Dash0 Web SDK initialization process.")):i("Stopping Dash0 Web SDK initialization. This browser does not support the necessary APIs"):i("Looks like we are not running in a browser context. Stopping Dash0 Web SDK initialization.")}function Mn(t,e){Se(Z.signalAttributes,rt),null!=t&&we(Z.signalAttributes,rt,t),Se(Z.signalAttributes,it),null!=(null==e?void 0:e.name)&&we(Z.signalAttributes,it,e.name),Se(Z.signalAttributes,ot),null!=(null==e?void 0:e.fullName)&&we(Z.signalAttributes,ot,e.fullName),Se(Z.signalAttributes,at),null!=(null==e?void 0:e.email)&&we(Z.signalAttributes,at,e.email),Se(Z.signalAttributes,ut),null!=(null==e?void 0:e.hash)&&we(Z.signalAttributes,ut,e.hash),Se(Z.signalAttributes,st),null!=(null==e?void 0:e.roles)&&we(Z.signalAttributes,st,e.roles)}function Un(){i("Dash0 Web SDK configuration state:",Z)}function Fn(t,e){we(Z.signalAttributes,t,e)}function Vn(t){Se(Z.signalAttributes,t)}function Bn(t,e){var n,r=[];De(r),Object.entries(null!==(n=null==e?void 0:e.attributes)&&void 0!==n?n:{}).forEach((function(t){var e=N(t,2),n=e[0],i=e[1];return we(r,n,i)})),we(r,tt,t),ye({timeUnixNano:null!=(null==e?void 0:e.timestamp)?x(e.timestamp):_(),attributes:r,body:Ee(null==e?void 0:e.data),severityText:null==e?void 0:e.severity,severityNumber:null!=e&&e.severity?vt[e.severity]:void 0})}function Hn(t,e){Ge(t,e)}function qn(t){i("".concat("Initializing Dash0 Web SDK"," (via package)")),jn(t)}export{Fn as addSignalAttribute,Un as debug,Mn as identify,qn as init,Vn as removeSignalAttribute,Hn as reportError,Bn as sendEvent,St as terminateSession}; //# sourceMappingURL=dash0.js.map