@sentry/node 9.6.0 → 9.7.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/integrations/anr/index.js +1 -1
- package/build/cjs/integrations/http/SentryHttpInstrumentation.js +159 -63
- package/build/cjs/integrations/http/SentryHttpInstrumentation.js.map +1 -1
- package/build/cjs/integrations/http/SentryHttpInstrumentationBeforeOtel.js +115 -0
- package/build/cjs/integrations/http/SentryHttpInstrumentationBeforeOtel.js.map +1 -0
- package/build/cjs/integrations/http/index.js +21 -10
- package/build/cjs/integrations/http/index.js.map +1 -1
- package/build/cjs/integrations/http/utils.js +44 -0
- package/build/cjs/integrations/http/utils.js.map +1 -0
- package/build/cjs/integrations/local-variables/local-variables-async.js +1 -1
- package/build/cjs/integrations/tracing/graphql.js +0 -3
- package/build/cjs/integrations/tracing/graphql.js.map +1 -1
- package/build/cjs/integrations/tracing/index.js +9 -9
- package/build/cjs/integrations/tracing/index.js.map +1 -1
- package/build/cjs/sdk/index.js +8 -8
- package/build/cjs/sdk/index.js.map +1 -1
- package/build/cjs/sdk/initOtel.js +4 -5
- package/build/cjs/sdk/initOtel.js.map +1 -1
- package/build/esm/integrations/anr/index.js +2 -2
- package/build/esm/integrations/anr/worker-script.js +2 -2
- package/build/esm/integrations/console.js +1 -1
- package/build/esm/integrations/fs.js +1 -1
- package/build/esm/integrations/http/SentryHttpInstrumentation.js +154 -58
- package/build/esm/integrations/http/SentryHttpInstrumentation.js.map +1 -1
- package/build/esm/integrations/http/SentryHttpInstrumentationBeforeOtel.js +113 -0
- package/build/esm/integrations/http/SentryHttpInstrumentationBeforeOtel.js.map +1 -0
- package/build/esm/integrations/http/index.js +21 -10
- package/build/esm/integrations/http/index.js.map +1 -1
- package/build/esm/integrations/http/utils.js +42 -0
- package/build/esm/integrations/http/utils.js.map +1 -0
- package/build/esm/integrations/local-variables/local-variables-async.js +1 -1
- package/build/esm/integrations/local-variables/worker-script.js +2 -2
- package/build/esm/integrations/tracing/connect.js +1 -1
- package/build/esm/integrations/tracing/express.js +1 -1
- package/build/esm/integrations/tracing/fastify.js +1 -1
- package/build/esm/integrations/tracing/graphql.js +1 -4
- package/build/esm/integrations/tracing/graphql.js.map +1 -1
- package/build/esm/integrations/tracing/hapi/index.js +1 -1
- package/build/esm/integrations/tracing/index.js +18 -18
- package/build/esm/integrations/tracing/koa.js +1 -1
- package/build/esm/integrations/tracing/redis.js +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/sdk/client.js +1 -1
- package/build/esm/sdk/index.js +1 -1
- package/build/esm/sdk/initOtel.js +8 -9
- package/build/esm/sdk/initOtel.js.map +1 -1
- package/build/types/integrations/http/SentryHttpInstrumentation.d.ts +20 -4
- package/build/types/integrations/http/SentryHttpInstrumentation.d.ts.map +1 -1
- package/build/types/integrations/http/SentryHttpInstrumentationBeforeOtel.d.ts +17 -0
- package/build/types/integrations/http/SentryHttpInstrumentationBeforeOtel.d.ts.map +1 -0
- package/build/types/integrations/http/index.d.ts.map +1 -1
- package/build/types/integrations/http/utils.d.ts +14 -0
- package/build/types/integrations/http/utils.d.ts.map +1 -0
- package/build/types/integrations/tracing/graphql.d.ts.map +1 -1
- package/build/types/sdk/initOtel.d.ts.map +1 -1
- package/build/types-ts3.8/integrations/http/SentryHttpInstrumentation.d.ts +20 -4
- package/build/types-ts3.8/integrations/http/SentryHttpInstrumentationBeforeOtel.d.ts +20 -0
- package/build/types-ts3.8/integrations/http/utils.d.ts +14 -0
- package/package.json +4 -4
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @sentry/node 9.
|
|
2
|
-
import{Session as t}from"node:inspector";import{parentPort as n,workerData as e}from"node:worker_threads";import{posix as r,sep as o}from"node:path";import*as s from"node:http";import*as i from"node:https";import{Readable as c}from"node:stream";import{createGzip as u}from"node:zlib";import*as a from"node:net";import*as f from"node:tls";const h="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,p=globalThis,l="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,d="9.6.0";function m(){return g(p),p}function g(t){const n=t.__SENTRY__=t.__SENTRY__||{};return n.version=n.version||d,n[d]=n[d]||{}}function y(t,n,e=p){const r=e.__SENTRY__=e.__SENTRY__||{},o=r[d]=r[d]||{};return o[t]||(o[t]=n())}const b=["debug","info","warn","error","log","assert","trace"],_={};function v(t){if(!("console"in p))return t();const n=p.console,e={},r=Object.keys(_);r.forEach((t=>{const r=_[t];e[t]=n[t],n[t]=r}));try{return t()}finally{r.forEach((t=>{n[t]=e[t]}))}}const w=y("logger",(function(){let t=!1;const n={enable:()=>{t=!0},disable:()=>{t=!1},isEnabled:()=>t};return l?b.forEach((e=>{n[e]=(...n)=>{t&&v((()=>{p.console[e](`Sentry Logger [${e}]:`,...n)}))}})):b.forEach((t=>{n[t]=()=>{}})),n})),S=50,$="?",E=/captureMessage|captureException/;function x(t){return t[t.length-1]||{}}const N="<anonymous>";const T=Object.prototype.toString;function C(t,n){return T.call(t)===`[object ${n}]`}function j(t){return C(t,"String")}function R(t){return C(t,"Object")}function k(t){return Boolean(t?.then&&"function"==typeof t.then)}function O(t,n){try{return t instanceof n}catch(t){return!1}}const D=p,I=80;function A(t,n){const e=t,r=[];if(!e?.tagName)return"";if(D.HTMLElement&&e instanceof HTMLElement&&e.dataset){if(e.dataset.sentryComponent)return e.dataset.sentryComponent;if(e.dataset.sentryElement)return e.dataset.sentryElement}r.push(e.tagName.toLowerCase());const o=n?.length?n.filter((t=>e.getAttribute(t))).map((t=>[t,e.getAttribute(t)])):null;if(o?.length)o.forEach((t=>{r.push(`[${t[0]}="${t[1]}"]`)}));else{e.id&&r.push(`#${e.id}`);const t=e.className;if(t&&j(t)){const n=t.split(/\s+/);for(const t of n)r.push(`.${t}`)}}const s=["aria-label","type","name","title","alt"];for(const t of s){const n=e.getAttribute(t);n&&r.push(`[${t}="${n}"]`)}return r.join("")}function P(t){if(function(t){switch(T.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return O(t,Error)}}(t))return{message:t.message,name:t.name,stack:t.stack,...M(t)};if(n=t,"undefined"!=typeof Event&&O(n,Event)){const n={type:t.type,target:U(t.target),currentTarget:U(t.currentTarget),...M(t)};return"undefined"!=typeof CustomEvent&&O(t,CustomEvent)&&(n.detail=t.detail),n}return t;var n}function U(t){try{return n=t,"undefined"!=typeof Element&&O(n,Element)?function(t,n={}){if(!t)return"<unknown>";try{let e=t;const r=5,o=[];let s=0,i=0;const c=" > ",u=c.length;let a;const f=Array.isArray(n)?n:n.keyAttrs,h=!Array.isArray(n)&&n.maxStringLength||I;for(;e&&s++<r&&(a=A(e,f),!("html"===a||s>1&&i+o.length*u+a.length>=h));)o.push(a),i+=a.length,e=e.parentNode;return o.reverse().join(c)}catch(t){return"<unknown>"}}(t):Object.prototype.toString.call(t)}catch(t){return"<unknown>"}var n}function M(t){if("object"==typeof t&&null!==t){const n={};for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}return{}}function L(t){return B(t,new Map)}function B(t,n){if(function(t){if(!R(t))return!1;try{const n=Object.getPrototypeOf(t).constructor.name;return!n||"Object"===n}catch{return!0}}(t)){const e=n.get(t);if(void 0!==e)return e;const r={};n.set(t,r);for(const e of Object.getOwnPropertyNames(t))void 0!==t[e]&&(r[e]=B(t[e],n));return r}if(Array.isArray(t)){const e=n.get(t);if(void 0!==e)return e;const r=[];return n.set(t,r),t.forEach((t=>{r.push(B(t,n))})),r}return t}const G=1e3;function J(){return Date.now()/G}const Y=function(){const{performance:t}=p;if(!t?.now)return J;const n=Date.now()-t.now(),e=null==t.timeOrigin?n:t.timeOrigin;return()=>(e+t.now())/G}();function z(t=function(){const t=p;return t.crypto||t.msCrypto}()){let n=()=>16*Math.random();try{if(t?.randomUUID)return t.randomUUID().replace(/-/g,"");t?.getRandomValues&&(n=()=>{const n=new Uint8Array(1);return t.getRandomValues(n),n[0]})}catch(t){}return([1e7]+1e3+4e3+8e3+1e11).replace(/[018]/g,(t=>(t^(15&n())>>t/4).toString(16)))}var H;function W(t){return new F((n=>{n(t)}))}!function(t){t[t.PENDING=0]="PENDING";t[t.RESOLVED=1]="RESOLVED";t[t.REJECTED=2]="REJECTED"}(H||(H={}));class F{constructor(t){this.t=H.PENDING,this.o=[],this.i(t)}then(t,n){return new F(((e,r)=>{this.o.push([!1,n=>{if(t)try{e(t(n))}catch(t){r(t)}else e(n)},t=>{if(n)try{e(n(t))}catch(t){r(t)}else r(t)}]),this.u()}))}catch(t){return this.then((t=>t),t)}finally(t){return new F(((n,e)=>{let r,o;return this.then((n=>{o=!1,r=n,t&&t()}),(n=>{o=!0,r=n,t&&t()})).then((()=>{o?e(r):n(r)}))}))}u(){if(this.t===H.PENDING)return;const t=this.o.slice();this.o=[],t.forEach((t=>{t[0]||(this.t===H.RESOLVED&&t[1](this.h),this.t===H.REJECTED&&t[2](this.h),t[0]=!0)}))}i(t){const n=(t,n)=>{this.t===H.PENDING&&(k(n)?n.then(e,r):(this.t=t,this.h=n,this.u()))},e=t=>{n(H.RESOLVED,t)},r=t=>{n(H.REJECTED,t)};try{t(e,r)}catch(t){r(t)}}}function K(t){const n=Y(),e={sid:z(),init:!0,timestamp:n,started:n,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>function(t){return L({sid:`${t.sid}`,init:t.init,started:new Date(1e3*t.started).toISOString(),timestamp:new Date(1e3*t.timestamp).toISOString(),status:t.status,errors:t.errors,did:"number"==typeof t.did||"string"==typeof t.did?`${t.did}`:void 0,duration:t.duration,abnormal_mechanism:t.abnormal_mechanism,attrs:{release:t.release,environment:t.environment,ip_address:t.ipAddress,user_agent:t.userAgent}})}(e)};return t&&V(e,t),e}function V(t,n={}){if(n.user&&(!t.ipAddress&&n.user.ip_address&&(t.ipAddress=n.user.ip_address),t.did||n.did||(t.did=n.user.id||n.user.email||n.user.username)),t.timestamp=n.timestamp||Y(),n.abnormal_mechanism&&(t.abnormal_mechanism=n.abnormal_mechanism),n.ignoreDuration&&(t.ignoreDuration=n.ignoreDuration),n.sid&&(t.sid=32===n.sid.length?n.sid:z()),void 0!==n.init&&(t.init=n.init),!t.did&&n.did&&(t.did=`${n.did}`),"number"==typeof n.started&&(t.started=n.started),t.ignoreDuration)t.duration=void 0;else if("number"==typeof n.duration)t.duration=n.duration;else{const n=t.timestamp-t.started;t.duration=n>=0?n:0}n.release&&(t.release=n.release),n.environment&&(t.environment=n.environment),!t.ipAddress&&n.ipAddress&&(t.ipAddress=n.ipAddress),!t.userAgent&&n.userAgent&&(t.userAgent=n.userAgent),"number"==typeof n.errors&&(t.errors=n.errors),n.status&&(t.status=n.status)}function Z(){return z()}function q(){return z().substring(16)}function Q(t,n,e=2){if(!n||"object"!=typeof n||e<=0)return n;if(t&&0===Object.keys(n).length)return t;const r={...t};for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=Q(r[t],n[t],e-1));return r}const X="_sentrySpan";function tt(t,n){n?function(t,n,e){try{Object.defineProperty(t,n,{value:e,writable:!0,configurable:!0})}catch(e){l&&w.log(`Failed to add non-enumerable property "${n}" to object`,t)}}(t,X,n):delete t[X]}function nt(t){return t[X]}class et{constructor(){this.p=!1,this.l=[],this.m=[],this._=[],this.v=[],this.S={},this.N={},this.T={},this.C={},this.j={},this.R={traceId:Z(),sampleRand:Math.random()}}clone(){const t=new et;return t._=[...this._],t.N={...this.N},t.T={...this.T},t.C={...this.C},this.C.flags&&(t.C.flags={values:[...this.C.flags.values]}),t.S=this.S,t.k=this.k,t.O=this.O,t.D=this.D,t.I=this.I,t.m=[...this.m],t.v=[...this.v],t.j={...this.j},t.R={...this.R},t.A=this.A,t.P=this.P,tt(t,nt(this)),t}setClient(t){this.A=t}setLastEventId(t){this.P=t}getClient(){return this.A}lastEventId(){return this.P}addScopeListener(t){this.l.push(t)}addEventProcessor(t){return this.m.push(t),this}setUser(t){return this.S=t||{email:void 0,id:void 0,ip_address:void 0,username:void 0},this.O&&V(this.O,{user:t}),this.U(),this}getUser(){return this.S}setTags(t){return this.N={...this.N,...t},this.U(),this}setTag(t,n){return this.N={...this.N,[t]:n},this.U(),this}setExtras(t){return this.T={...this.T,...t},this.U(),this}setExtra(t,n){return this.T={...this.T,[t]:n},this.U(),this}setFingerprint(t){return this.I=t,this.U(),this}setLevel(t){return this.k=t,this.U(),this}setTransactionName(t){return this.D=t,this.U(),this}setContext(t,n){return null===n?delete this.C[t]:this.C[t]=n,this.U(),this}setSession(t){return t?this.O=t:delete this.O,this.U(),this}getSession(){return this.O}update(t){if(!t)return this;const n="function"==typeof t?t(this):t,e=n instanceof et?n.getScopeData():R(n)?t:void 0,{tags:r,extra:o,user:s,contexts:i,level:c,fingerprint:u=[],propagationContext:a}=e||{};return this.N={...this.N,...r},this.T={...this.T,...o},this.C={...this.C,...i},s&&Object.keys(s).length&&(this.S=s),c&&(this.k=c),u.length&&(this.I=u),a&&(this.R=a),this}clear(){return this._=[],this.N={},this.T={},this.S={},this.C={},this.k=void 0,this.D=void 0,this.I=void 0,this.O=void 0,tt(this,void 0),this.v=[],this.setPropagationContext({traceId:Z(),sampleRand:Math.random()}),this.U(),this}addBreadcrumb(t,n){const e="number"==typeof n?n:100;if(e<=0)return this;const r={timestamp:J(),...t};return this._.push(r),this._.length>e&&(this._=this._.slice(-e),this.A?.recordDroppedEvent("buffer_overflow","log_item")),this.U(),this}getLastBreadcrumb(){return this._[this._.length-1]}clearBreadcrumbs(){return this._=[],this.U(),this}addAttachment(t){return this.v.push(t),this}clearAttachments(){return this.v=[],this}getScopeData(){return{breadcrumbs:this._,attachments:this.v,contexts:this.C,tags:this.N,extra:this.T,user:this.S,level:this.k,fingerprint:this.I||[],eventProcessors:this.m,propagationContext:this.R,sdkProcessingMetadata:this.j,transactionName:this.D,span:nt(this)}}setSDKProcessingMetadata(t){return this.j=Q(this.j,t,2),this}setPropagationContext(t){return this.R=t,this}getPropagationContext(){return this.R}captureException(t,n){const e=n?.event_id||z();if(!this.A)return w.warn("No client configured on scope - will not capture exception!"),e;const r=new Error("Sentry syntheticException");return this.A.captureException(t,{originalException:t,syntheticException:r,...n,event_id:e},this),e}captureMessage(t,n,e){const r=e?.event_id||z();if(!this.A)return w.warn("No client configured on scope - will not capture message!"),r;const o=new Error(t);return this.A.captureMessage(t,n,{originalException:t,syntheticException:o,...e,event_id:r},this),r}captureEvent(t,n){const e=n?.event_id||z();return this.A?(this.A.captureEvent(t,{...n,event_id:e},this),e):(w.warn("No client configured on scope - will not capture event!"),e)}U(){this.p||(this.p=!0,this.l.forEach((t=>{t(this)})),this.p=!1)}}class rt{constructor(t,n){let e,r;e=t||new et,r=n||new et,this.M=[{scope:e}],this.L=r}withScope(t){const n=this.B();let e;try{e=t(n)}catch(t){throw this.G(),t}return k(e)?e.then((t=>(this.G(),t)),(t=>{throw this.G(),t})):(this.G(),e)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this.L}getStackTop(){return this.M[this.M.length-1]}B(){const t=this.getScope().clone();return this.M.push({client:this.getClient(),scope:t}),t}G(){return!(this.M.length<=1)&&!!this.M.pop()}}function ot(){const t=g(m());return t.stack=t.stack||new rt(y("defaultCurrentScope",(()=>new et)),y("defaultIsolationScope",(()=>new et)))}function st(t){return ot().withScope(t)}function it(t,n){const e=ot();return e.withScope((()=>(e.getStackTop().scope=t,n(t))))}function ct(t){return ot().withScope((()=>t(ot().getIsolationScope())))}function ut(t){const n=g(t);return n.acs?n.acs:{withIsolationScope:ct,withScope:st,withSetScope:it,withSetIsolationScope:(t,n)=>ct(n),getCurrentScope:()=>ot().getScope(),getIsolationScope:()=>ot().getIsolationScope()}}function at(){return ut(m()).getCurrentScope().getClient()}const ft="sentry.source",ht="sentry.sample_rate",pt="sentry.op",lt="sentry.origin",dt=0,mt=1,gt="_sentryScope",yt="_sentryIsolationScope";function bt(t){return{scope:t[gt],isolationScope:t[yt]}}const _t="sentry-",vt=/^sentry-/;function wt(t){const n=function(t){if(!t||!j(t)&&!Array.isArray(t))return;if(Array.isArray(t))return t.reduce(((t,n)=>{const e=St(n);return Object.entries(e).forEach((([n,e])=>{t[n]=e})),t}),{});return St(t)}(t);if(!n)return;const e=Object.entries(n).reduce(((t,[n,e])=>{if(n.match(vt)){t[n.slice(_t.length)]=e}return t}),{});return Object.keys(e).length>0?e:void 0}function St(t){return t.split(",").map((t=>t.split("=").map((t=>decodeURIComponent(t.trim()))))).reduce(((t,[n,e])=>(n&&e&&(t[n]=e),t)),{})}const $t=1;function Et(t){const{spanId:n,traceId:e,isRemote:r}=t.spanContext(),o=r?n:Ct(t).parent_span_id,s=bt(t).scope;return L({parent_span_id:o,span_id:r?s?.getPropagationContext().propagationSpanId||q():n,trace_id:e})}function xt(t){return t&&t.length>0?t.map((({context:{spanId:t,traceId:n,traceFlags:e,...r},attributes:o})=>({span_id:t,trace_id:n,sampled:e===$t,attributes:o,...r}))):void 0}function Nt(t){return"number"==typeof t?Tt(t):Array.isArray(t)?t[0]+t[1]/1e9:t instanceof Date?Tt(t.getTime()):Y()}function Tt(t){return t>9999999999?t/1e3:t}function Ct(t){if(function(t){return"function"==typeof t.getSpanJSON}(t))return t.getSpanJSON();const{spanId:n,traceId:e}=t.spanContext();if(function(t){const n=t;return!!(n.attributes&&n.startTime&&n.name&&n.endTime&&n.status)}(t)){const{attributes:r,startTime:o,name:s,endTime:i,parentSpanId:c,status:u,links:a}=t;return L({span_id:n,trace_id:e,data:r,description:s,parent_span_id:c,start_timestamp:Nt(o),timestamp:Nt(i)||void 0,status:jt(u),op:r[pt],origin:r[lt],links:xt(a)})}return{span_id:n,trace_id:e,start_timestamp:0,data:{}}}function jt(t){if(t&&t.code!==dt)return t.code===mt?"ok":t.message||"unknown_error"}const Rt="_sentryRootSpan";function kt(t){return t[Rt]||t}const Ot="production",Dt="_frozenDsc";function It(t){const n=at();if(!n)return{};const e=kt(t),r=Ct(e),o=r.data,s=e.spanContext().traceState,i=s?.get("sentry.sample_rate")??o[ht];function c(t){return"number"!=typeof i&&"string"!=typeof i||(t.sample_rate=`${i}`),t}const u=e[Dt];if(u)return c(u);const a=s?.get("sentry.dsc"),f=a&&wt(a);if(f)return c(f);const h=function(t,n){const e=n.getOptions(),{publicKey:r}=n.getDsn()||{},o=L({environment:e.environment||Ot,release:e.release,public_key:r,trace_id:t});return n.emit("createDsc",o),o}(t.spanContext().traceId,n),p=o[ft],l=r.description;return"url"!==p&&l&&(h.transaction=l),function(t){if("boolean"==typeof __SENTRY_TRACING__&&!__SENTRY_TRACING__)return!1;const n=t||at()?.getOptions();return!(!n||null==n.tracesSampleRate&&!n.tracesSampler)}()&&(h.sampled=String(function(t){const{traceFlags:n}=t.spanContext();return n===$t}(e)),h.sample_rand=s?.get("sentry.sample_rand")??bt(e).scope?.getPropagationContext().sampleRand.toString()),c(h),n.emit("createDsc",h,e),h}function At(t,n=!1){const{host:e,path:r,pass:o,port:s,projectId:i,protocol:c,publicKey:u}=t;return`${c}://${u}${n&&o?`:${o}`:""}@${e}${s?`:${s}`:""}/${r?`${r}/`:r}${i}`}function Pt(t,n=100,e=1/0){try{return Ut("",t,n,e)}catch(t){return{ERROR:`**non-serializable** (${t})`}}}function Ut(t,n,e=1/0,r=1/0,o=function(){const t=new WeakSet;function n(n){return!!t.has(n)||(t.add(n),!1)}function e(n){t.delete(n)}return[n,e]}()){const[s,i]=o;if(null==n||["boolean","string"].includes(typeof n)||"number"==typeof n&&Number.isFinite(n))return n;const c=function(t,n){try{if("domain"===t&&n&&"object"==typeof n&&n.J)return"[Domain]";if("domainEmitter"===t)return"[DomainEmitter]";if("undefined"!=typeof global&&n===global)return"[Global]";if("undefined"!=typeof window&&n===window)return"[Window]";if("undefined"!=typeof document&&n===document)return"[Document]";if("object"==typeof(e=n)&&null!==e&&(e.__isVue||e.Y))return"[VueViewModel]";if(function(t){return R(t)&&"nativeEvent"in t&&"preventDefault"in t&&"stopPropagation"in t}(n))return"[SyntheticEvent]";if("number"==typeof n&&!Number.isFinite(n))return`[${n}]`;if("function"==typeof n)return`[Function: ${function(t){try{return t&&"function"==typeof t&&t.name||N}catch(t){return N}}(n)}]`;if("symbol"==typeof n)return`[${String(n)}]`;if("bigint"==typeof n)return`[BigInt: ${String(n)}]`;const r=function(t){const n=Object.getPrototypeOf(t);return n?.constructor?n.constructor.name:"null prototype"}(n);return/^HTML(\w*)Element$/.test(r)?`[HTMLElement: ${r}]`:`[object ${r}]`}catch(t){return`**non-serializable** (${t})`}var e}(t,n);if(!c.startsWith("[object "))return c;if(n.__sentry_skip_normalization__)return n;const u="number"==typeof n.__sentry_override_normalization_depth__?n.__sentry_override_normalization_depth__:e;if(0===u)return c.replace("object ","");if(s(n))return"[Circular ~]";const a=n;if(a&&"function"==typeof a.toJSON)try{return Ut("",a.toJSON(),u-1,r,o)}catch(t){}const f=Array.isArray(n)?[]:{};let h=0;const p=P(n);for(const t in p){if(!Object.prototype.hasOwnProperty.call(p,t))continue;if(h>=r){f[t]="[MaxProperties ~]";break}const n=p[t];f[t]=Ut(t,n,u-1,r,o),h++}return i(n),f}function Mt(t,n){const e=n.replace(/\\/g,"/").replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");let r=t;try{r=decodeURI(t)}catch(t){}return r.replace(/\\/g,"/").replace(/webpack:\/?/g,"").replace(new RegExp(`(file://)?/*${e}/*`,"ig"),"app:///")}function Lt(t,n=[]){return[t,n]}function Bt(t,n){const e=t[1];for(const t of e){if(n(t,t[0].type))return!0}return!1}function Gt(t){const n=g(p);return n.encodePolyfill?n.encodePolyfill(t):(new TextEncoder).encode(t)}function Jt(t){const[n,e]=t;let r=JSON.stringify(n);function o(t){"string"==typeof r?r="string"==typeof t?r+t:[Gt(r),t]:r.push("string"==typeof t?Gt(t):t)}for(const t of e){const[n,e]=t;if(o(`\n${JSON.stringify(n)}\n`),"string"==typeof e||e instanceof Uint8Array)o(e);else{let t;try{t=JSON.stringify(e)}catch(n){t=JSON.stringify(Pt(e))}o(t)}}return"string"==typeof r?r:function(t){const n=t.reduce(((t,n)=>t+n.length),0),e=new Uint8Array(n);let r=0;for(const n of t)e.set(n,r),r+=n.length;return e}(r)}const Yt={session:"session",sessions:"session",attachment:"attachment",transaction:"transaction",event:"error",client_report:"internal",user_report:"default",profile:"profile",profile_chunk:"profile",replay_event:"replay",replay_recording:"replay",check_in:"monitor",feedback:"feedback",span:"span",raw_security:"security",otel_log:"log_item"};function zt(t){if(!t?.sdk)return;const{name:n,version:e}=t.sdk;return{name:n,version:e}}function Ht(t,n,e,r){const o=zt(e),s=t.type&&"replay_event"!==t.type?t.type:"event";!function(t,n){n&&(t.sdk=t.sdk||{},t.sdk.name=t.sdk.name||n.name,t.sdk.version=t.sdk.version||n.version,t.sdk.integrations=[...t.sdk.integrations||[],...n.integrations||[]],t.sdk.packages=[...t.sdk.packages||[],...n.packages||[]])}(t,e?.sdk);const i=function(t,n,e,r){const o=t.sdkProcessingMetadata?.dynamicSamplingContext;return{event_id:t.event_id,sent_at:(new Date).toISOString(),...n&&{sdk:n},...!!e&&r&&{dsn:At(r)},...o&&{trace:L({...o})}}}(t,o,r,n);delete t.sdkProcessingMetadata;return Lt(i,[[{type:s},t]])}const Wt="__SENTRY_SUPPRESS_TRACING__";function Ft(t){const n=ut(m());return n.suppressTracing?n.suppressTracing(t):function(...t){const n=ut(m());if(2===t.length){const[e,r]=t;return e?n.withSetScope(e,r):n.withScope(r)}return n.withScope(t[0])}((n=>(n.setSDKProcessingMetadata({[Wt]:!0}),t())))}function Kt(t,n){const{fingerprint:e,span:r,breadcrumbs:o,sdkProcessingMetadata:s}=n;!function(t,n){const{extra:e,tags:r,user:o,contexts:s,level:i,transactionName:c}=n,u=L(e);Object.keys(u).length&&(t.extra={...u,...t.extra});const a=L(r);Object.keys(a).length&&(t.tags={...a,...t.tags});const f=L(o);Object.keys(f).length&&(t.user={...f,...t.user});const h=L(s);Object.keys(h).length&&(t.contexts={...h,...t.contexts});i&&(t.level=i);c&&"transaction"!==t.type&&(t.transaction=c)}(t,n),r&&function(t,n){t.contexts={trace:Et(n),...t.contexts},t.sdkProcessingMetadata={dynamicSamplingContext:It(n),...t.sdkProcessingMetadata};const e=kt(n),r=Ct(e).description;r&&!t.transaction&&"transaction"===t.type&&(t.transaction=r)}(t,r),function(t,n){t.fingerprint=t.fingerprint?Array.isArray(t.fingerprint)?t.fingerprint:[t.fingerprint]:[],n&&(t.fingerprint=t.fingerprint.concat(n));t.fingerprint.length||delete t.fingerprint}(t,e),function(t,n){const e=[...t.breadcrumbs||[],...n];t.breadcrumbs=e.length?e:void 0}(t,o),function(t,n){t.sdkProcessingMetadata={...t.sdkProcessingMetadata,...n}}(t,s)}const Vt="7";class Zt extends Error{constructor(t,n="warn"){super(t),this.message=t,this.logLevel=n}}function qt(t){const n=[];function e(t){return n.splice(n.indexOf(t),1)[0]||Promise.resolve(void 0)}return{$:n,add:function(r){if(!(void 0===t||n.length<t))return o=new Zt("Not adding Promise because buffer limit was reached."),new F(((t,n)=>{n(o)}));var o;const s=r();return-1===n.indexOf(s)&&n.push(s),s.then((()=>e(s))).then(null,(()=>e(s).then(null,(()=>{})))),s},drain:function(t){return new F(((e,r)=>{let o=n.length;if(!o)return e(!0);const s=setTimeout((()=>{t&&t>0&&e(!1)}),t);n.forEach((t=>{W(t).then((()=>{--o||(clearTimeout(s),e(!0))}),r)}))}))}}}const Qt=6e4;function Xt(t,{statusCode:n,headers:e},r=Date.now()){const o={...t},s=e?.["x-sentry-rate-limits"],i=e?.["retry-after"];if(s)for(const t of s.trim().split(",")){const[n,e,,,s]=t.split(":",5),i=parseInt(n,10),c=1e3*(isNaN(i)?60:i);if(e)for(const t of e.split(";"))"metric_bucket"===t&&s&&!s.split(";").includes("custom")||(o[t]=r+c);else o.all=r+c}else i?o.all=r+function(t,n=Date.now()){const e=parseInt(`${t}`,10);if(!isNaN(e))return 1e3*e;const r=Date.parse(`${t}`);return isNaN(r)?Qt:r-n}(i,r):429===n&&(o.all=r+6e4);return o}const tn=64;function nn(t,n,e=qt(t.bufferSize||tn)){let r={};return{send:function(t){const o=[];if(Bt(t,((t,n)=>{const e=function(t){return Yt[t]}(n);(function(t,n,e=Date.now()){return function(t,n){return t[n]||t.all||0}(t,n)>e})(r,e)||o.push(t)})),0===o.length)return W({});const s=Lt(t[0],o),i=t=>{Bt(s,((t,n)=>{}))};return e.add((()=>n({body:Jt(s)}).then((t=>(void 0!==t.statusCode&&(t.statusCode<200||t.statusCode>=300)&&h&&w.warn(`Sentry responded with status code ${t.statusCode} to sent event.`),r=Xt(r,t),t)),(t=>{throw i(),t})))).then((t=>t),(t=>{if(t instanceof Zt)return h&&w.error("Skipped sending event because buffer is full."),i(),W({});throw t}))},flush:t=>e.drain(t)}}const en=/^(\S+:\\|\/?)([\s\S]*?)((?:\.{1,2}|[^/\\]+?|)(\.[^./\\]*|))(?:[/\\]*)$/;function rn(t){const n=function(t){const n=t.length>1024?`<truncated>${t.slice(-1024)}`:t,e=en.exec(n);return e?e.slice(1):[]}(t),e=n[0]||"";let r=n[1];return e||r?(r&&(r=r.slice(0,r.length-1)),e+r):"."}function on(t,n=!1){return!(n||t&&!t.startsWith("/")&&!t.match(/^[A-Z]:/)&&!t.startsWith(".")&&!t.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//))&&void 0!==t&&!t.includes("node_modules/")}const sn=Symbol("AgentBaseInternalState");class cn extends s.Agent{constructor(t){super(t),this[sn]={}}isSecureEndpoint(t){if(t){if("boolean"==typeof t.secureEndpoint)return t.secureEndpoint;if("string"==typeof t.protocol)return"https:"===t.protocol}const{stack:n}=new Error;return"string"==typeof n&&n.split("\n").some((t=>-1!==t.indexOf("(https.js:")||-1!==t.indexOf("node:https:")))}createSocket(t,n,e){const r={...n,secureEndpoint:this.isSecureEndpoint(n)};Promise.resolve().then((()=>this.connect(t,r))).then((o=>{if(o instanceof s.Agent)return o.addRequest(t,r);this[sn].currentSocket=o,super.createSocket(t,n,e)}),e)}createConnection(){const t=this[sn].currentSocket;if(this[sn].currentSocket=void 0,!t)throw new Error("No socket was returned in the `connect()` function");return t}get defaultPort(){return this[sn].defaultPort??("https:"===this.protocol?443:80)}set defaultPort(t){this[sn]&&(this[sn].defaultPort=t)}get protocol(){return this[sn].protocol??(this.isSecureEndpoint()?"https:":"http:")}set protocol(t){this[sn]&&(this[sn].protocol=t)}}function un(...t){w.log("[https-proxy-agent:parse-proxy-response]",...t)}function an(t){return new Promise(((n,e)=>{let r=0;const o=[];function s(){const c=t.read();c?function(c){o.push(c),r+=c.length;const u=Buffer.concat(o,r),a=u.indexOf("\r\n\r\n");if(-1===a)return un("have not received end of HTTP headers yet..."),void s();const f=u.subarray(0,a).toString("ascii").split("\r\n"),h=f.shift();if(!h)return t.destroy(),e(new Error("No header received from proxy CONNECT response"));const p=h.split(" "),l=+(p[1]||0),d=p.slice(2).join(" "),m={};for(const n of f){if(!n)continue;const r=n.indexOf(":");if(-1===r)return t.destroy(),e(new Error(`Invalid header from proxy CONNECT response: "${n}"`));const o=n.slice(0,r).toLowerCase(),s=n.slice(r+1).trimStart(),i=m[o];"string"==typeof i?m[o]=[i,s]:Array.isArray(i)?i.push(s):m[o]=s}un("got proxy server response: %o %o",h,m),i(),n({connect:{statusCode:l,statusText:d,headers:m},buffered:u})}(c):t.once("readable",s)}function i(){t.removeListener("end",c),t.removeListener("error",u),t.removeListener("readable",s)}function c(){i(),un("onend"),e(new Error("Proxy connection ended before receiving CONNECT response"))}function u(t){i(),un("onerror %o",t),e(t)}t.on("error",u),t.on("end",c),s()}))}function fn(...t){w.log("[https-proxy-agent]",...t)}class hn extends cn{static __initStatic(){this.protocols=["http","https"]}constructor(t,n){super(n),this.options={},this.proxy="string"==typeof t?new URL(t):t,this.proxyHeaders=n?.headers??{},fn("Creating new HttpsProxyAgent instance: %o",this.proxy.href);const e=(this.proxy.hostname||this.proxy.host).replace(/^\[|\]$/g,""),r=this.proxy.port?parseInt(this.proxy.port,10):"https:"===this.proxy.protocol?443:80;this.connectOpts={ALPNProtocols:["http/1.1"],...n?ln(n,"headers"):null,host:e,port:r}}async connect(t,n){const{proxy:e}=this;if(!n.host)throw new TypeError('No "host" provided');let r;if("https:"===e.protocol){fn("Creating `tls.Socket`: %o",this.connectOpts);const t=this.connectOpts.servername||this.connectOpts.host;r=f.connect({...this.connectOpts,servername:t&&a.isIP(t)?void 0:t})}else fn("Creating `net.Socket`: %o",this.connectOpts),r=a.connect(this.connectOpts);const o="function"==typeof this.proxyHeaders?this.proxyHeaders():{...this.proxyHeaders},s=a.isIPv6(n.host)?`[${n.host}]`:n.host;let i=`CONNECT ${s}:${n.port} HTTP/1.1\r\n`;if(e.username||e.password){const t=`${decodeURIComponent(e.username)}:${decodeURIComponent(e.password)}`;o["Proxy-Authorization"]=`Basic ${Buffer.from(t).toString("base64")}`}o.Host=`${s}:${n.port}`,o["Proxy-Connection"]||(o["Proxy-Connection"]=this.keepAlive?"Keep-Alive":"close");for(const t of Object.keys(o))i+=`${t}: ${o[t]}\r\n`;const c=an(r);r.write(`${i}\r\n`);const{connect:u,buffered:h}=await c;if(t.emit("proxyConnect",u),this.emit("proxyConnect",u,t),200===u.statusCode){if(t.once("socket",pn),n.secureEndpoint){fn("Upgrading socket connection to TLS");const t=n.servername||n.host;return f.connect({...ln(n,"host","path","port"),socket:r,servername:a.isIP(t)?void 0:t})}return r}r.destroy();const p=new a.Socket({writable:!1});return p.readable=!0,t.once("socket",(t=>{fn("Replaying proxy buffer for failed request"),t.push(h),t.push(null)})),p}}function pn(t){t.resume()}function ln(t,...n){const e={};let r;for(r in t)n.includes(r)||(e[r]=t[r]);return e}hn.__initStatic();const dn=32768;function mn(t){return t.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}const gn=e;let yn,bn=0,_n={};function vn(t){gn.debug&&console.log(`[ANR Worker] ${t}`)}var wn,Sn,$n;const En=function(t){let n;try{n=new URL(t.url)}catch(n){return v((()=>{console.warn("[@sentry/node]: Invalid dsn or tunnel option, will not send any events. The tunnel option must be a full URL when used.")})),nn(t,(()=>Promise.resolve({})))}const e="https:"===n.protocol,r=function(t,n){const{no_proxy:e}=process.env,r=e?.split(",").some((n=>t.host.endsWith(n)||t.hostname.endsWith(n)));return r?void 0:n}(n,t.proxy||(e?process.env.https_proxy:void 0)||process.env.http_proxy),o=e?i:s,a=void 0!==t.keepAlive&&t.keepAlive,f=r?new hn(r):new o.Agent({keepAlive:a,maxSockets:30,timeout:2e3}),h=function(t,n,e){const{hostname:r,pathname:o,port:s,protocol:i,search:a}=new URL(t.url);return function(f){return new Promise(((h,p)=>{Ft((()=>{let l=function(t){return new c({read(){this.push(t),this.push(null)}})}(f.body);const d={...t.headers};f.body.length>dn&&(d["content-encoding"]="gzip",l=l.pipe(u()));const m=n.request({method:"POST",agent:e,headers:d,hostname:r,path:`${o}${a}`,port:s,protocol:i,ca:t.caCerts},(t=>{t.on("data",(()=>{})),t.on("end",(()=>{})),t.setEncoding("utf8");const n=t.headers["retry-after"]??null,e=t.headers["x-sentry-rate-limits"]??null;h({statusCode:t.statusCode,headers:{"retry-after":n,"x-sentry-rate-limits":Array.isArray(e)?e[0]||null:e}})}));m.on("error",p),l.pipe(m)}))}))}}(t,t.httpModule??o,f);return nn(t,h)}({url:(wn=gn.dsn,Sn=gn.tunnel,$n=gn.sdkMetadata.sdk,Sn||`${function(t){return`${function(t){const n=t.protocol?`${t.protocol}:`:"",e=t.port?`:${t.port}`:"";return`${n}//${t.host}${e}${t.path?`/${t.path}`:""}/api/`}(t)}${t.projectId}/envelope/`}(wn)}?${function(t,n){const e={sentry_version:Vt};return t.publicKey&&(e.sentry_key=t.publicKey),n&&(e.sentry_client=`${n.name}/${n.version}`),new URLSearchParams(e).toString()}(wn,$n)}`),recordDroppedEvent:()=>{}});async function xn(){if(yn){vn("Sending abnormal session"),V(yn,{status:"abnormal",abnormal_mechanism:"anr_foreground",release:gn.release,environment:gn.environment});const t=function(t,n,e,r){const o=zt(e);return Lt({sent_at:(new Date).toISOString(),...o&&{sdk:o},...!!r&&n&&{dsn:At(n)}},["aggregates"in t?[{type:"sessions"},t]:[{type:"session"},t.toJSON()]])}(yn,gn.dsn,gn.sdkMetadata,gn.tunnel);vn(JSON.stringify(t)),await En.send(t);try{n?.postMessage("session-ended")}catch(t){}}}function Nn(t){if(!t)return;const n=function(t){if(!t.length)return[];const n=Array.from(t);return/sentryWrapped/.test(x(n).function||"")&&n.pop(),n.reverse(),E.test(x(n).function||"")&&(n.pop(),E.test(x(n).function||"")&&n.pop()),n.slice(0,S).map((t=>({...t,filename:t.filename||x(n).filename,function:t.function||$})))}(t);if(gn.appRootPath)for(const t of n)t.filename&&(t.filename=Mt(t.filename,gn.appRootPath));return n}async function Tn(t,n){if(bn>=gn.maxAnrEvents)return;bn+=1,await xn(),vn("Sending event");const e={event_id:z(),contexts:gn.contexts,release:gn.release,environment:gn.environment,dist:gn.dist,platform:"node",level:"error",exception:{values:[{type:"ApplicationNotResponding",value:`Application Not Responding for at least ${gn.anrThreshold} ms`,stacktrace:{frames:Nn(t)},mechanism:{type:"ANR"}}]},tags:gn.staticTags};n&&function(t,n){if(Kt(t,n),!t.contexts?.trace){const{traceId:e,parentSpanId:r,propagationSpanId:o}=n.propagationContext;t.contexts={trace:{trace_id:e,span_id:o||q(),parent_span_id:r},...t.contexts}}}(e,n),function(t){if(0===Object.keys(_n).length)return;const n=gn.appRootPath?{}:_n;if(gn.appRootPath)for(const[t,e]of Object.entries(_n))n[Mt(t,gn.appRootPath)]=e;const e=new Map;for(const r of t.exception?.values||[])for(const t of r.stacktrace?.frames||[]){const r=t.abs_path||t.filename;r&&n[r]&&e.set(r,n[r])}if(e.size>0){const n=[];for(const[t,r]of e.entries())n.push({type:"sourcemap",code_file:t,debug_id:r});t.debug_meta={images:n}}}(e);const r=Ht(e,gn.dsn,gn.sdkMetadata,gn.tunnel);vn(JSON.stringify(r)),await En.send(r),await En.flush(2e3),bn>=gn.maxAnrEvents&&setTimeout((()=>{process.exit(0)}),5e3)}let Cn;if(vn("Started"),gn.captureStackTrace){vn("Connecting to debugger");const n=new t;n.connectToMainThread(),vn("Connected to debugger");const e=new Map;n.on("Debugger.scriptParsed",(t=>{e.set(t.params.scriptId,t.params.url)})),n.on("Debugger.paused",(t=>{if("other"===t.params.reason)try{vn("Debugger paused");const s=[...t.params.callFrames],i=gn.appRootPath?function(t=(process.argv[1]?rn(process.argv[1]):process.cwd()),n="\\"===o){const e=n?mn(t):t;return t=>{if(!t)return;const o=n?mn(t):t;let{dir:s,base:i,ext:c}=r.parse(o);".js"!==c&&".mjs"!==c&&".cjs"!==c||(i=i.slice(0,-1*c.length));const u=decodeURIComponent(i);s||(s=".");const a=s.lastIndexOf("/node_modules");if(a>-1)return`${s.slice(a+14).replace(/\//g,".")}:${u}`;if(s.startsWith(e)){const t=s.slice(e.length+1).replace(/\//g,".");return t?`${t}:${u}`:u}return u}}(gn.appRootPath):()=>{},c=s.map((t=>function(t,n,e){const r=n?n.replace(/^file:\/\//,""):void 0,o=t.location.columnNumber?t.location.columnNumber+1:void 0,s=t.location.lineNumber?t.location.lineNumber+1:void 0;return L({filename:r,module:e(r),function:t.functionName||$,colno:o,lineno:s,in_app:r?on(r):void 0})}(t,e.get(t.location.scriptId),i))),u=setTimeout((()=>{Tn(c).then(null,(()=>{vn("Sending ANR event failed.")}))}),5e3);n.post("Runtime.evaluate",{expression:"global.__SENTRY_GET_SCOPES__();",silent:!0,returnByValue:!0},((t,e)=>{t&&vn(`Error executing script: '${t.message}'`),clearTimeout(u);const r=e?.result?e.result.value:void 0;n.post("Debugger.resume"),n.post("Debugger.disable"),Tn(c,r).then(null,(()=>{vn("Sending ANR event failed.")}))}))}catch(t){throw n.post("Debugger.resume"),n.post("Debugger.disable"),t}})),Cn=()=>{try{n.post("Debugger.enable",(()=>{n.post("Debugger.pause")}))}catch(t){}}}const{poll:jn}=function(t,n,e,r){const o=t();let s=!1,i=!0;return setInterval((()=>{const t=o.getTimeMs();!1===s&&t>n+e&&(s=!0,i&&r()),t<n+e&&(s=!1)}),20),{poll:()=>{o.reset()},enabled:t=>{i=t}}}((function(){let t=process.hrtime();return{getTimeMs:()=>{const[n,e]=process.hrtime(t);return Math.floor(1e3*n+e/1e6)},reset:()=>{t=process.hrtime()}}}),gn.pollInterval,gn.anrThreshold,(function(){vn("Watchdog timeout"),Cn?(vn("Pausing debugger to capture stack trace"),Cn()):(vn("Capturing event without a stack trace"),Tn().then(null,(()=>{vn("Sending ANR event failed on watchdog timeout.")})))}));n?.on("message",(t=>{t.session&&(yn=K(t.session)),t.debugImages&&(_n=t.debugImages),jn()}));
|
|
1
|
+
/*! @sentry/node 9.7.0-alpha.0 (c047605) | https://github.com/getsentry/sentry-javascript */
|
|
2
|
+
import{Session as t}from"node:inspector";import{workerData as n,parentPort as e}from"node:worker_threads";import{posix as r,sep as o}from"node:path";import*as s from"node:http";import*as i from"node:https";import{Readable as c}from"node:stream";import{createGzip as u}from"node:zlib";import*as a from"node:net";import*as f from"node:tls";const h="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,p=globalThis,l="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,d="9.7.0-alpha.0";function m(){return g(p),p}function g(t){const n=t.__SENTRY__=t.__SENTRY__||{};return n.version=n.version||d,n[d]=n[d]||{}}function y(t,n,e=p){const r=e.__SENTRY__=e.__SENTRY__||{},o=r[d]=r[d]||{};return o[t]||(o[t]=n())}const b=["debug","info","warn","error","log","assert","trace"],_={};function v(t){if(!("console"in p))return t();const n=p.console,e={},r=Object.keys(_);r.forEach((t=>{const r=_[t];e[t]=n[t],n[t]=r}));try{return t()}finally{r.forEach((t=>{n[t]=e[t]}))}}const w=y("logger",(function(){let t=!1;const n={enable:()=>{t=!0},disable:()=>{t=!1},isEnabled:()=>t};return l?b.forEach((e=>{n[e]=(...n)=>{t&&v((()=>{p.console[e](`Sentry Logger [${e}]:`,...n)}))}})):b.forEach((t=>{n[t]=()=>{}})),n})),S=50,$="?",E=/captureMessage|captureException/;function x(t){return t[t.length-1]||{}}const N="<anonymous>";const T=Object.prototype.toString;function C(t,n){return T.call(t)===`[object ${n}]`}function j(t){return C(t,"String")}function R(t){return C(t,"Object")}function k(t){return Boolean(t?.then&&"function"==typeof t.then)}function O(t,n){try{return t instanceof n}catch(t){return!1}}const D=p,I=80;function A(t,n){const e=t,r=[];if(!e?.tagName)return"";if(D.HTMLElement&&e instanceof HTMLElement&&e.dataset){if(e.dataset.sentryComponent)return e.dataset.sentryComponent;if(e.dataset.sentryElement)return e.dataset.sentryElement}r.push(e.tagName.toLowerCase());const o=n?.length?n.filter((t=>e.getAttribute(t))).map((t=>[t,e.getAttribute(t)])):null;if(o?.length)o.forEach((t=>{r.push(`[${t[0]}="${t[1]}"]`)}));else{e.id&&r.push(`#${e.id}`);const t=e.className;if(t&&j(t)){const n=t.split(/\s+/);for(const t of n)r.push(`.${t}`)}}const s=["aria-label","type","name","title","alt"];for(const t of s){const n=e.getAttribute(t);n&&r.push(`[${t}="${n}"]`)}return r.join("")}function P(t){if(function(t){switch(T.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return O(t,Error)}}(t))return{message:t.message,name:t.name,stack:t.stack,...M(t)};if(n=t,"undefined"!=typeof Event&&O(n,Event)){const n={type:t.type,target:U(t.target),currentTarget:U(t.currentTarget),...M(t)};return"undefined"!=typeof CustomEvent&&O(t,CustomEvent)&&(n.detail=t.detail),n}return t;var n}function U(t){try{return n=t,"undefined"!=typeof Element&&O(n,Element)?function(t,n={}){if(!t)return"<unknown>";try{let e=t;const r=5,o=[];let s=0,i=0;const c=" > ",u=c.length;let a;const f=Array.isArray(n)?n:n.keyAttrs,h=!Array.isArray(n)&&n.maxStringLength||I;for(;e&&s++<r&&(a=A(e,f),!("html"===a||s>1&&i+o.length*u+a.length>=h));)o.push(a),i+=a.length,e=e.parentNode;return o.reverse().join(c)}catch(t){return"<unknown>"}}(t):Object.prototype.toString.call(t)}catch(t){return"<unknown>"}var n}function M(t){if("object"==typeof t&&null!==t){const n={};for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e]);return n}return{}}function L(t){return B(t,new Map)}function B(t,n){if(function(t){if(!R(t))return!1;try{const n=Object.getPrototypeOf(t).constructor.name;return!n||"Object"===n}catch{return!0}}(t)){const e=n.get(t);if(void 0!==e)return e;const r={};n.set(t,r);for(const e of Object.getOwnPropertyNames(t))void 0!==t[e]&&(r[e]=B(t[e],n));return r}if(Array.isArray(t)){const e=n.get(t);if(void 0!==e)return e;const r=[];return n.set(t,r),t.forEach((t=>{r.push(B(t,n))})),r}return t}const G=1e3;function J(){return Date.now()/G}const Y=function(){const{performance:t}=p;if(!t?.now)return J;const n=Date.now()-t.now(),e=null==t.timeOrigin?n:t.timeOrigin;return()=>(e+t.now())/G}();function z(t=function(){const t=p;return t.crypto||t.msCrypto}()){let n=()=>16*Math.random();try{if(t?.randomUUID)return t.randomUUID().replace(/-/g,"");t?.getRandomValues&&(n=()=>{const n=new Uint8Array(1);return t.getRandomValues(n),n[0]})}catch(t){}return([1e7]+1e3+4e3+8e3+1e11).replace(/[018]/g,(t=>(t^(15&n())>>t/4).toString(16)))}var H;function W(t){return new F((n=>{n(t)}))}!function(t){t[t.PENDING=0]="PENDING";t[t.RESOLVED=1]="RESOLVED";t[t.REJECTED=2]="REJECTED"}(H||(H={}));class F{constructor(t){this.t=H.PENDING,this.o=[],this.i(t)}then(t,n){return new F(((e,r)=>{this.o.push([!1,n=>{if(t)try{e(t(n))}catch(t){r(t)}else e(n)},t=>{if(n)try{e(n(t))}catch(t){r(t)}else r(t)}]),this.u()}))}catch(t){return this.then((t=>t),t)}finally(t){return new F(((n,e)=>{let r,o;return this.then((n=>{o=!1,r=n,t&&t()}),(n=>{o=!0,r=n,t&&t()})).then((()=>{o?e(r):n(r)}))}))}u(){if(this.t===H.PENDING)return;const t=this.o.slice();this.o=[],t.forEach((t=>{t[0]||(this.t===H.RESOLVED&&t[1](this.h),this.t===H.REJECTED&&t[2](this.h),t[0]=!0)}))}i(t){const n=(t,n)=>{this.t===H.PENDING&&(k(n)?n.then(e,r):(this.t=t,this.h=n,this.u()))},e=t=>{n(H.RESOLVED,t)},r=t=>{n(H.REJECTED,t)};try{t(e,r)}catch(t){r(t)}}}function K(t){const n=Y(),e={sid:z(),init:!0,timestamp:n,started:n,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>function(t){return L({sid:`${t.sid}`,init:t.init,started:new Date(1e3*t.started).toISOString(),timestamp:new Date(1e3*t.timestamp).toISOString(),status:t.status,errors:t.errors,did:"number"==typeof t.did||"string"==typeof t.did?`${t.did}`:void 0,duration:t.duration,abnormal_mechanism:t.abnormal_mechanism,attrs:{release:t.release,environment:t.environment,ip_address:t.ipAddress,user_agent:t.userAgent}})}(e)};return t&&V(e,t),e}function V(t,n={}){if(n.user&&(!t.ipAddress&&n.user.ip_address&&(t.ipAddress=n.user.ip_address),t.did||n.did||(t.did=n.user.id||n.user.email||n.user.username)),t.timestamp=n.timestamp||Y(),n.abnormal_mechanism&&(t.abnormal_mechanism=n.abnormal_mechanism),n.ignoreDuration&&(t.ignoreDuration=n.ignoreDuration),n.sid&&(t.sid=32===n.sid.length?n.sid:z()),void 0!==n.init&&(t.init=n.init),!t.did&&n.did&&(t.did=`${n.did}`),"number"==typeof n.started&&(t.started=n.started),t.ignoreDuration)t.duration=void 0;else if("number"==typeof n.duration)t.duration=n.duration;else{const n=t.timestamp-t.started;t.duration=n>=0?n:0}n.release&&(t.release=n.release),n.environment&&(t.environment=n.environment),!t.ipAddress&&n.ipAddress&&(t.ipAddress=n.ipAddress),!t.userAgent&&n.userAgent&&(t.userAgent=n.userAgent),"number"==typeof n.errors&&(t.errors=n.errors),n.status&&(t.status=n.status)}function Z(){return z()}function q(){return z().substring(16)}function Q(t,n,e=2){if(!n||"object"!=typeof n||e<=0)return n;if(t&&0===Object.keys(n).length)return t;const r={...t};for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=Q(r[t],n[t],e-1));return r}const X="_sentrySpan";function tt(t,n){n?function(t,n,e){try{Object.defineProperty(t,n,{value:e,writable:!0,configurable:!0})}catch(e){l&&w.log(`Failed to add non-enumerable property "${n}" to object`,t)}}(t,X,n):delete t[X]}function nt(t){return t[X]}class et{constructor(){this.p=!1,this.l=[],this.m=[],this._=[],this.v=[],this.S={},this.N={},this.T={},this.C={},this.j={},this.R={traceId:Z(),sampleRand:Math.random()}}clone(){const t=new et;return t._=[...this._],t.N={...this.N},t.T={...this.T},t.C={...this.C},this.C.flags&&(t.C.flags={values:[...this.C.flags.values]}),t.S=this.S,t.k=this.k,t.O=this.O,t.D=this.D,t.I=this.I,t.m=[...this.m],t.v=[...this.v],t.j={...this.j},t.R={...this.R},t.A=this.A,t.P=this.P,tt(t,nt(this)),t}setClient(t){this.A=t}setLastEventId(t){this.P=t}getClient(){return this.A}lastEventId(){return this.P}addScopeListener(t){this.l.push(t)}addEventProcessor(t){return this.m.push(t),this}setUser(t){return this.S=t||{email:void 0,id:void 0,ip_address:void 0,username:void 0},this.O&&V(this.O,{user:t}),this.U(),this}getUser(){return this.S}setTags(t){return this.N={...this.N,...t},this.U(),this}setTag(t,n){return this.N={...this.N,[t]:n},this.U(),this}setExtras(t){return this.T={...this.T,...t},this.U(),this}setExtra(t,n){return this.T={...this.T,[t]:n},this.U(),this}setFingerprint(t){return this.I=t,this.U(),this}setLevel(t){return this.k=t,this.U(),this}setTransactionName(t){return this.D=t,this.U(),this}setContext(t,n){return null===n?delete this.C[t]:this.C[t]=n,this.U(),this}setSession(t){return t?this.O=t:delete this.O,this.U(),this}getSession(){return this.O}update(t){if(!t)return this;const n="function"==typeof t?t(this):t,e=n instanceof et?n.getScopeData():R(n)?t:void 0,{tags:r,extra:o,user:s,contexts:i,level:c,fingerprint:u=[],propagationContext:a}=e||{};return this.N={...this.N,...r},this.T={...this.T,...o},this.C={...this.C,...i},s&&Object.keys(s).length&&(this.S=s),c&&(this.k=c),u.length&&(this.I=u),a&&(this.R=a),this}clear(){return this._=[],this.N={},this.T={},this.S={},this.C={},this.k=void 0,this.D=void 0,this.I=void 0,this.O=void 0,tt(this,void 0),this.v=[],this.setPropagationContext({traceId:Z(),sampleRand:Math.random()}),this.U(),this}addBreadcrumb(t,n){const e="number"==typeof n?n:100;if(e<=0)return this;const r={timestamp:J(),...t};return this._.push(r),this._.length>e&&(this._=this._.slice(-e),this.A?.recordDroppedEvent("buffer_overflow","log_item")),this.U(),this}getLastBreadcrumb(){return this._[this._.length-1]}clearBreadcrumbs(){return this._=[],this.U(),this}addAttachment(t){return this.v.push(t),this}clearAttachments(){return this.v=[],this}getScopeData(){return{breadcrumbs:this._,attachments:this.v,contexts:this.C,tags:this.N,extra:this.T,user:this.S,level:this.k,fingerprint:this.I||[],eventProcessors:this.m,propagationContext:this.R,sdkProcessingMetadata:this.j,transactionName:this.D,span:nt(this)}}setSDKProcessingMetadata(t){return this.j=Q(this.j,t,2),this}setPropagationContext(t){return this.R=t,this}getPropagationContext(){return this.R}captureException(t,n){const e=n?.event_id||z();if(!this.A)return w.warn("No client configured on scope - will not capture exception!"),e;const r=new Error("Sentry syntheticException");return this.A.captureException(t,{originalException:t,syntheticException:r,...n,event_id:e},this),e}captureMessage(t,n,e){const r=e?.event_id||z();if(!this.A)return w.warn("No client configured on scope - will not capture message!"),r;const o=new Error(t);return this.A.captureMessage(t,n,{originalException:t,syntheticException:o,...e,event_id:r},this),r}captureEvent(t,n){const e=n?.event_id||z();return this.A?(this.A.captureEvent(t,{...n,event_id:e},this),e):(w.warn("No client configured on scope - will not capture event!"),e)}U(){this.p||(this.p=!0,this.l.forEach((t=>{t(this)})),this.p=!1)}}class rt{constructor(t,n){let e,r;e=t||new et,r=n||new et,this.M=[{scope:e}],this.L=r}withScope(t){const n=this.B();let e;try{e=t(n)}catch(t){throw this.G(),t}return k(e)?e.then((t=>(this.G(),t)),(t=>{throw this.G(),t})):(this.G(),e)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this.L}getStackTop(){return this.M[this.M.length-1]}B(){const t=this.getScope().clone();return this.M.push({client:this.getClient(),scope:t}),t}G(){return!(this.M.length<=1)&&!!this.M.pop()}}function ot(){const t=g(m());return t.stack=t.stack||new rt(y("defaultCurrentScope",(()=>new et)),y("defaultIsolationScope",(()=>new et)))}function st(t){return ot().withScope(t)}function it(t,n){const e=ot();return e.withScope((()=>(e.getStackTop().scope=t,n(t))))}function ct(t){return ot().withScope((()=>t(ot().getIsolationScope())))}function ut(t){const n=g(t);return n.acs?n.acs:{withIsolationScope:ct,withScope:st,withSetScope:it,withSetIsolationScope:(t,n)=>ct(n),getCurrentScope:()=>ot().getScope(),getIsolationScope:()=>ot().getIsolationScope()}}function at(){return ut(m()).getCurrentScope().getClient()}const ft="sentry.source",ht="sentry.sample_rate",pt="sentry.op",lt="sentry.origin",dt=0,mt=1,gt="_sentryScope",yt="_sentryIsolationScope";function bt(t){return{scope:t[gt],isolationScope:t[yt]}}const _t="sentry-",vt=/^sentry-/;function wt(t){const n=function(t){if(!t||!j(t)&&!Array.isArray(t))return;if(Array.isArray(t))return t.reduce(((t,n)=>{const e=St(n);return Object.entries(e).forEach((([n,e])=>{t[n]=e})),t}),{});return St(t)}(t);if(!n)return;const e=Object.entries(n).reduce(((t,[n,e])=>{if(n.match(vt)){t[n.slice(_t.length)]=e}return t}),{});return Object.keys(e).length>0?e:void 0}function St(t){return t.split(",").map((t=>t.split("=").map((t=>decodeURIComponent(t.trim()))))).reduce(((t,[n,e])=>(n&&e&&(t[n]=e),t)),{})}const $t=1;function Et(t){const{spanId:n,traceId:e,isRemote:r}=t.spanContext(),o=r?n:Ct(t).parent_span_id,s=bt(t).scope;return L({parent_span_id:o,span_id:r?s?.getPropagationContext().propagationSpanId||q():n,trace_id:e})}function xt(t){return t&&t.length>0?t.map((({context:{spanId:t,traceId:n,traceFlags:e,...r},attributes:o})=>({span_id:t,trace_id:n,sampled:e===$t,attributes:o,...r}))):void 0}function Nt(t){return"number"==typeof t?Tt(t):Array.isArray(t)?t[0]+t[1]/1e9:t instanceof Date?Tt(t.getTime()):Y()}function Tt(t){return t>9999999999?t/1e3:t}function Ct(t){if(function(t){return"function"==typeof t.getSpanJSON}(t))return t.getSpanJSON();const{spanId:n,traceId:e}=t.spanContext();if(function(t){const n=t;return!!(n.attributes&&n.startTime&&n.name&&n.endTime&&n.status)}(t)){const{attributes:r,startTime:o,name:s,endTime:i,parentSpanId:c,status:u,links:a}=t;return L({span_id:n,trace_id:e,data:r,description:s,parent_span_id:c,start_timestamp:Nt(o),timestamp:Nt(i)||void 0,status:jt(u),op:r[pt],origin:r[lt],links:xt(a)})}return{span_id:n,trace_id:e,start_timestamp:0,data:{}}}function jt(t){if(t&&t.code!==dt)return t.code===mt?"ok":t.message||"unknown_error"}const Rt="_sentryRootSpan";function kt(t){return t[Rt]||t}const Ot="production",Dt="_frozenDsc";function It(t){const n=at();if(!n)return{};const e=kt(t),r=Ct(e),o=r.data,s=e.spanContext().traceState,i=s?.get("sentry.sample_rate")??o[ht];function c(t){return"number"!=typeof i&&"string"!=typeof i||(t.sample_rate=`${i}`),t}const u=e[Dt];if(u)return c(u);const a=s?.get("sentry.dsc"),f=a&&wt(a);if(f)return c(f);const h=function(t,n){const e=n.getOptions(),{publicKey:r}=n.getDsn()||{},o=L({environment:e.environment||Ot,release:e.release,public_key:r,trace_id:t});return n.emit("createDsc",o),o}(t.spanContext().traceId,n),p=o[ft],l=r.description;return"url"!==p&&l&&(h.transaction=l),function(t){if("boolean"==typeof __SENTRY_TRACING__&&!__SENTRY_TRACING__)return!1;const n=t||at()?.getOptions();return!(!n||null==n.tracesSampleRate&&!n.tracesSampler)}()&&(h.sampled=String(function(t){const{traceFlags:n}=t.spanContext();return n===$t}(e)),h.sample_rand=s?.get("sentry.sample_rand")??bt(e).scope?.getPropagationContext().sampleRand.toString()),c(h),n.emit("createDsc",h,e),h}function At(t,n=!1){const{host:e,path:r,pass:o,port:s,projectId:i,protocol:c,publicKey:u}=t;return`${c}://${u}${n&&o?`:${o}`:""}@${e}${s?`:${s}`:""}/${r?`${r}/`:r}${i}`}function Pt(t,n=100,e=1/0){try{return Ut("",t,n,e)}catch(t){return{ERROR:`**non-serializable** (${t})`}}}function Ut(t,n,e=1/0,r=1/0,o=function(){const t=new WeakSet;function n(n){return!!t.has(n)||(t.add(n),!1)}function e(n){t.delete(n)}return[n,e]}()){const[s,i]=o;if(null==n||["boolean","string"].includes(typeof n)||"number"==typeof n&&Number.isFinite(n))return n;const c=function(t,n){try{if("domain"===t&&n&&"object"==typeof n&&n.J)return"[Domain]";if("domainEmitter"===t)return"[DomainEmitter]";if("undefined"!=typeof global&&n===global)return"[Global]";if("undefined"!=typeof window&&n===window)return"[Window]";if("undefined"!=typeof document&&n===document)return"[Document]";if("object"==typeof(e=n)&&null!==e&&(e.__isVue||e.Y))return"[VueViewModel]";if(function(t){return R(t)&&"nativeEvent"in t&&"preventDefault"in t&&"stopPropagation"in t}(n))return"[SyntheticEvent]";if("number"==typeof n&&!Number.isFinite(n))return`[${n}]`;if("function"==typeof n)return`[Function: ${function(t){try{return t&&"function"==typeof t&&t.name||N}catch(t){return N}}(n)}]`;if("symbol"==typeof n)return`[${String(n)}]`;if("bigint"==typeof n)return`[BigInt: ${String(n)}]`;const r=function(t){const n=Object.getPrototypeOf(t);return n?.constructor?n.constructor.name:"null prototype"}(n);return/^HTML(\w*)Element$/.test(r)?`[HTMLElement: ${r}]`:`[object ${r}]`}catch(t){return`**non-serializable** (${t})`}var e}(t,n);if(!c.startsWith("[object "))return c;if(n.__sentry_skip_normalization__)return n;const u="number"==typeof n.__sentry_override_normalization_depth__?n.__sentry_override_normalization_depth__:e;if(0===u)return c.replace("object ","");if(s(n))return"[Circular ~]";const a=n;if(a&&"function"==typeof a.toJSON)try{return Ut("",a.toJSON(),u-1,r,o)}catch(t){}const f=Array.isArray(n)?[]:{};let h=0;const p=P(n);for(const t in p){if(!Object.prototype.hasOwnProperty.call(p,t))continue;if(h>=r){f[t]="[MaxProperties ~]";break}const n=p[t];f[t]=Ut(t,n,u-1,r,o),h++}return i(n),f}function Mt(t,n){const e=n.replace(/\\/g,"/").replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");let r=t;try{r=decodeURI(t)}catch(t){}return r.replace(/\\/g,"/").replace(/webpack:\/?/g,"").replace(new RegExp(`(file://)?/*${e}/*`,"ig"),"app:///")}function Lt(t,n=[]){return[t,n]}function Bt(t,n){const e=t[1];for(const t of e){if(n(t,t[0].type))return!0}return!1}function Gt(t){const n=g(p);return n.encodePolyfill?n.encodePolyfill(t):(new TextEncoder).encode(t)}function Jt(t){const[n,e]=t;let r=JSON.stringify(n);function o(t){"string"==typeof r?r="string"==typeof t?r+t:[Gt(r),t]:r.push("string"==typeof t?Gt(t):t)}for(const t of e){const[n,e]=t;if(o(`\n${JSON.stringify(n)}\n`),"string"==typeof e||e instanceof Uint8Array)o(e);else{let t;try{t=JSON.stringify(e)}catch(n){t=JSON.stringify(Pt(e))}o(t)}}return"string"==typeof r?r:function(t){const n=t.reduce(((t,n)=>t+n.length),0),e=new Uint8Array(n);let r=0;for(const n of t)e.set(n,r),r+=n.length;return e}(r)}const Yt={session:"session",sessions:"session",attachment:"attachment",transaction:"transaction",event:"error",client_report:"internal",user_report:"default",profile:"profile",profile_chunk:"profile",replay_event:"replay",replay_recording:"replay",check_in:"monitor",feedback:"feedback",span:"span",raw_security:"security",otel_log:"log_item"};function zt(t){if(!t?.sdk)return;const{name:n,version:e}=t.sdk;return{name:n,version:e}}function Ht(t,n,e,r){const o=zt(e),s=t.type&&"replay_event"!==t.type?t.type:"event";!function(t,n){n&&(t.sdk=t.sdk||{},t.sdk.name=t.sdk.name||n.name,t.sdk.version=t.sdk.version||n.version,t.sdk.integrations=[...t.sdk.integrations||[],...n.integrations||[]],t.sdk.packages=[...t.sdk.packages||[],...n.packages||[]])}(t,e?.sdk);const i=function(t,n,e,r){const o=t.sdkProcessingMetadata?.dynamicSamplingContext;return{event_id:t.event_id,sent_at:(new Date).toISOString(),...n&&{sdk:n},...!!e&&r&&{dsn:At(r)},...o&&{trace:L({...o})}}}(t,o,r,n);delete t.sdkProcessingMetadata;return Lt(i,[[{type:s},t]])}const Wt="__SENTRY_SUPPRESS_TRACING__";function Ft(t){const n=ut(m());return n.suppressTracing?n.suppressTracing(t):function(...t){const n=ut(m());if(2===t.length){const[e,r]=t;return e?n.withSetScope(e,r):n.withScope(r)}return n.withScope(t[0])}((n=>(n.setSDKProcessingMetadata({[Wt]:!0}),t())))}function Kt(t,n){const{fingerprint:e,span:r,breadcrumbs:o,sdkProcessingMetadata:s}=n;!function(t,n){const{extra:e,tags:r,user:o,contexts:s,level:i,transactionName:c}=n,u=L(e);Object.keys(u).length&&(t.extra={...u,...t.extra});const a=L(r);Object.keys(a).length&&(t.tags={...a,...t.tags});const f=L(o);Object.keys(f).length&&(t.user={...f,...t.user});const h=L(s);Object.keys(h).length&&(t.contexts={...h,...t.contexts});i&&(t.level=i);c&&"transaction"!==t.type&&(t.transaction=c)}(t,n),r&&function(t,n){t.contexts={trace:Et(n),...t.contexts},t.sdkProcessingMetadata={dynamicSamplingContext:It(n),...t.sdkProcessingMetadata};const e=kt(n),r=Ct(e).description;r&&!t.transaction&&"transaction"===t.type&&(t.transaction=r)}(t,r),function(t,n){t.fingerprint=t.fingerprint?Array.isArray(t.fingerprint)?t.fingerprint:[t.fingerprint]:[],n&&(t.fingerprint=t.fingerprint.concat(n));t.fingerprint.length||delete t.fingerprint}(t,e),function(t,n){const e=[...t.breadcrumbs||[],...n];t.breadcrumbs=e.length?e:void 0}(t,o),function(t,n){t.sdkProcessingMetadata={...t.sdkProcessingMetadata,...n}}(t,s)}const Vt="7";class Zt extends Error{constructor(t,n="warn"){super(t),this.message=t,this.logLevel=n}}function qt(t){const n=[];function e(t){return n.splice(n.indexOf(t),1)[0]||Promise.resolve(void 0)}return{$:n,add:function(r){if(!(void 0===t||n.length<t))return o=new Zt("Not adding Promise because buffer limit was reached."),new F(((t,n)=>{n(o)}));var o;const s=r();return-1===n.indexOf(s)&&n.push(s),s.then((()=>e(s))).then(null,(()=>e(s).then(null,(()=>{})))),s},drain:function(t){return new F(((e,r)=>{let o=n.length;if(!o)return e(!0);const s=setTimeout((()=>{t&&t>0&&e(!1)}),t);n.forEach((t=>{W(t).then((()=>{--o||(clearTimeout(s),e(!0))}),r)}))}))}}}const Qt=6e4;function Xt(t,{statusCode:n,headers:e},r=Date.now()){const o={...t},s=e?.["x-sentry-rate-limits"],i=e?.["retry-after"];if(s)for(const t of s.trim().split(",")){const[n,e,,,s]=t.split(":",5),i=parseInt(n,10),c=1e3*(isNaN(i)?60:i);if(e)for(const t of e.split(";"))"metric_bucket"===t&&s&&!s.split(";").includes("custom")||(o[t]=r+c);else o.all=r+c}else i?o.all=r+function(t,n=Date.now()){const e=parseInt(`${t}`,10);if(!isNaN(e))return 1e3*e;const r=Date.parse(`${t}`);return isNaN(r)?Qt:r-n}(i,r):429===n&&(o.all=r+6e4);return o}const tn=64;function nn(t,n,e=qt(t.bufferSize||tn)){let r={};return{send:function(t){const o=[];if(Bt(t,((t,n)=>{const e=function(t){return Yt[t]}(n);(function(t,n,e=Date.now()){return function(t,n){return t[n]||t.all||0}(t,n)>e})(r,e)||o.push(t)})),0===o.length)return W({});const s=Lt(t[0],o),i=t=>{Bt(s,((t,n)=>{}))};return e.add((()=>n({body:Jt(s)}).then((t=>(void 0!==t.statusCode&&(t.statusCode<200||t.statusCode>=300)&&h&&w.warn(`Sentry responded with status code ${t.statusCode} to sent event.`),r=Xt(r,t),t)),(t=>{throw i(),t})))).then((t=>t),(t=>{if(t instanceof Zt)return h&&w.error("Skipped sending event because buffer is full."),i(),W({});throw t}))},flush:t=>e.drain(t)}}const en=/^(\S+:\\|\/?)([\s\S]*?)((?:\.{1,2}|[^/\\]+?|)(\.[^./\\]*|))(?:[/\\]*)$/;function rn(t){const n=function(t){const n=t.length>1024?`<truncated>${t.slice(-1024)}`:t,e=en.exec(n);return e?e.slice(1):[]}(t),e=n[0]||"";let r=n[1];return e||r?(r&&(r=r.slice(0,r.length-1)),e+r):"."}function on(t,n=!1){return!(n||t&&!t.startsWith("/")&&!t.match(/^[A-Z]:/)&&!t.startsWith(".")&&!t.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//))&&void 0!==t&&!t.includes("node_modules/")}const sn=Symbol("AgentBaseInternalState");class cn extends s.Agent{constructor(t){super(t),this[sn]={}}isSecureEndpoint(t){if(t){if("boolean"==typeof t.secureEndpoint)return t.secureEndpoint;if("string"==typeof t.protocol)return"https:"===t.protocol}const{stack:n}=new Error;return"string"==typeof n&&n.split("\n").some((t=>-1!==t.indexOf("(https.js:")||-1!==t.indexOf("node:https:")))}createSocket(t,n,e){const r={...n,secureEndpoint:this.isSecureEndpoint(n)};Promise.resolve().then((()=>this.connect(t,r))).then((o=>{if(o instanceof s.Agent)return o.addRequest(t,r);this[sn].currentSocket=o,super.createSocket(t,n,e)}),e)}createConnection(){const t=this[sn].currentSocket;if(this[sn].currentSocket=void 0,!t)throw new Error("No socket was returned in the `connect()` function");return t}get defaultPort(){return this[sn].defaultPort??("https:"===this.protocol?443:80)}set defaultPort(t){this[sn]&&(this[sn].defaultPort=t)}get protocol(){return this[sn].protocol??(this.isSecureEndpoint()?"https:":"http:")}set protocol(t){this[sn]&&(this[sn].protocol=t)}}function un(...t){w.log("[https-proxy-agent:parse-proxy-response]",...t)}function an(t){return new Promise(((n,e)=>{let r=0;const o=[];function s(){const c=t.read();c?function(c){o.push(c),r+=c.length;const u=Buffer.concat(o,r),a=u.indexOf("\r\n\r\n");if(-1===a)return un("have not received end of HTTP headers yet..."),void s();const f=u.subarray(0,a).toString("ascii").split("\r\n"),h=f.shift();if(!h)return t.destroy(),e(new Error("No header received from proxy CONNECT response"));const p=h.split(" "),l=+(p[1]||0),d=p.slice(2).join(" "),m={};for(const n of f){if(!n)continue;const r=n.indexOf(":");if(-1===r)return t.destroy(),e(new Error(`Invalid header from proxy CONNECT response: "${n}"`));const o=n.slice(0,r).toLowerCase(),s=n.slice(r+1).trimStart(),i=m[o];"string"==typeof i?m[o]=[i,s]:Array.isArray(i)?i.push(s):m[o]=s}un("got proxy server response: %o %o",h,m),i(),n({connect:{statusCode:l,statusText:d,headers:m},buffered:u})}(c):t.once("readable",s)}function i(){t.removeListener("end",c),t.removeListener("error",u),t.removeListener("readable",s)}function c(){i(),un("onend"),e(new Error("Proxy connection ended before receiving CONNECT response"))}function u(t){i(),un("onerror %o",t),e(t)}t.on("error",u),t.on("end",c),s()}))}function fn(...t){w.log("[https-proxy-agent]",...t)}class hn extends cn{static __initStatic(){this.protocols=["http","https"]}constructor(t,n){super(n),this.options={},this.proxy="string"==typeof t?new URL(t):t,this.proxyHeaders=n?.headers??{},fn("Creating new HttpsProxyAgent instance: %o",this.proxy.href);const e=(this.proxy.hostname||this.proxy.host).replace(/^\[|\]$/g,""),r=this.proxy.port?parseInt(this.proxy.port,10):"https:"===this.proxy.protocol?443:80;this.connectOpts={ALPNProtocols:["http/1.1"],...n?ln(n,"headers"):null,host:e,port:r}}async connect(t,n){const{proxy:e}=this;if(!n.host)throw new TypeError('No "host" provided');let r;if("https:"===e.protocol){fn("Creating `tls.Socket`: %o",this.connectOpts);const t=this.connectOpts.servername||this.connectOpts.host;r=f.connect({...this.connectOpts,servername:t&&a.isIP(t)?void 0:t})}else fn("Creating `net.Socket`: %o",this.connectOpts),r=a.connect(this.connectOpts);const o="function"==typeof this.proxyHeaders?this.proxyHeaders():{...this.proxyHeaders},s=a.isIPv6(n.host)?`[${n.host}]`:n.host;let i=`CONNECT ${s}:${n.port} HTTP/1.1\r\n`;if(e.username||e.password){const t=`${decodeURIComponent(e.username)}:${decodeURIComponent(e.password)}`;o["Proxy-Authorization"]=`Basic ${Buffer.from(t).toString("base64")}`}o.Host=`${s}:${n.port}`,o["Proxy-Connection"]||(o["Proxy-Connection"]=this.keepAlive?"Keep-Alive":"close");for(const t of Object.keys(o))i+=`${t}: ${o[t]}\r\n`;const c=an(r);r.write(`${i}\r\n`);const{connect:u,buffered:h}=await c;if(t.emit("proxyConnect",u),this.emit("proxyConnect",u,t),200===u.statusCode){if(t.once("socket",pn),n.secureEndpoint){fn("Upgrading socket connection to TLS");const t=n.servername||n.host;return f.connect({...ln(n,"host","path","port"),socket:r,servername:a.isIP(t)?void 0:t})}return r}r.destroy();const p=new a.Socket({writable:!1});return p.readable=!0,t.once("socket",(t=>{fn("Replaying proxy buffer for failed request"),t.push(h),t.push(null)})),p}}function pn(t){t.resume()}function ln(t,...n){const e={};let r;for(r in t)n.includes(r)||(e[r]=t[r]);return e}hn.__initStatic();const dn=32768;function mn(t){return t.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}const gn=n;let yn,bn=0,_n={};function vn(t){gn.debug&&console.log(`[ANR Worker] ${t}`)}var wn,Sn,$n;const En=function(t){let n;try{n=new URL(t.url)}catch(n){return v((()=>{console.warn("[@sentry/node]: Invalid dsn or tunnel option, will not send any events. The tunnel option must be a full URL when used.")})),nn(t,(()=>Promise.resolve({})))}const e="https:"===n.protocol,r=function(t,n){const{no_proxy:e}=process.env,r=e?.split(",").some((n=>t.host.endsWith(n)||t.hostname.endsWith(n)));return r?void 0:n}(n,t.proxy||(e?process.env.https_proxy:void 0)||process.env.http_proxy),o=e?i:s,a=void 0!==t.keepAlive&&t.keepAlive,f=r?new hn(r):new o.Agent({keepAlive:a,maxSockets:30,timeout:2e3}),h=function(t,n,e){const{hostname:r,pathname:o,port:s,protocol:i,search:a}=new URL(t.url);return function(f){return new Promise(((h,p)=>{Ft((()=>{let l=function(t){return new c({read(){this.push(t),this.push(null)}})}(f.body);const d={...t.headers};f.body.length>dn&&(d["content-encoding"]="gzip",l=l.pipe(u()));const m=n.request({method:"POST",agent:e,headers:d,hostname:r,path:`${o}${a}`,port:s,protocol:i,ca:t.caCerts},(t=>{t.on("data",(()=>{})),t.on("end",(()=>{})),t.setEncoding("utf8");const n=t.headers["retry-after"]??null,e=t.headers["x-sentry-rate-limits"]??null;h({statusCode:t.statusCode,headers:{"retry-after":n,"x-sentry-rate-limits":Array.isArray(e)?e[0]||null:e}})}));m.on("error",p),l.pipe(m)}))}))}}(t,t.httpModule??o,f);return nn(t,h)}({url:(wn=gn.dsn,Sn=gn.tunnel,$n=gn.sdkMetadata.sdk,Sn||`${function(t){return`${function(t){const n=t.protocol?`${t.protocol}:`:"",e=t.port?`:${t.port}`:"";return`${n}//${t.host}${e}${t.path?`/${t.path}`:""}/api/`}(t)}${t.projectId}/envelope/`}(wn)}?${function(t,n){const e={sentry_version:Vt};return t.publicKey&&(e.sentry_key=t.publicKey),n&&(e.sentry_client=`${n.name}/${n.version}`),new URLSearchParams(e).toString()}(wn,$n)}`)});async function xn(){if(yn){vn("Sending abnormal session"),V(yn,{status:"abnormal",abnormal_mechanism:"anr_foreground",release:gn.release,environment:gn.environment});const t=function(t,n,e,r){const o=zt(e);return Lt({sent_at:(new Date).toISOString(),...o&&{sdk:o},...!!r&&n&&{dsn:At(n)}},["aggregates"in t?[{type:"sessions"},t]:[{type:"session"},t.toJSON()]])}(yn,gn.dsn,gn.sdkMetadata,gn.tunnel);vn(JSON.stringify(t)),await En.send(t);try{e?.postMessage("session-ended")}catch(t){}}}function Nn(t){if(!t)return;const n=function(t){if(!t.length)return[];const n=Array.from(t);return/sentryWrapped/.test(x(n).function||"")&&n.pop(),n.reverse(),E.test(x(n).function||"")&&(n.pop(),E.test(x(n).function||"")&&n.pop()),n.slice(0,S).map((t=>({...t,filename:t.filename||x(n).filename,function:t.function||$})))}(t);if(gn.appRootPath)for(const t of n)t.filename&&(t.filename=Mt(t.filename,gn.appRootPath));return n}async function Tn(t,n){if(bn>=gn.maxAnrEvents)return;bn+=1,await xn(),vn("Sending event");const e={event_id:z(),contexts:gn.contexts,release:gn.release,environment:gn.environment,dist:gn.dist,platform:"node",level:"error",exception:{values:[{type:"ApplicationNotResponding",value:`Application Not Responding for at least ${gn.anrThreshold} ms`,stacktrace:{frames:Nn(t)},mechanism:{type:"ANR"}}]},tags:gn.staticTags};n&&function(t,n){if(Kt(t,n),!t.contexts?.trace){const{traceId:e,parentSpanId:r,propagationSpanId:o}=n.propagationContext;t.contexts={trace:{trace_id:e,span_id:o||q(),parent_span_id:r},...t.contexts}}}(e,n),function(t){if(0===Object.keys(_n).length)return;const n=gn.appRootPath?{}:_n;if(gn.appRootPath)for(const[t,e]of Object.entries(_n))n[Mt(t,gn.appRootPath)]=e;const e=new Map;for(const r of t.exception?.values||[])for(const t of r.stacktrace?.frames||[]){const r=t.abs_path||t.filename;r&&n[r]&&e.set(r,n[r])}if(e.size>0){const n=[];for(const[t,r]of e.entries())n.push({type:"sourcemap",code_file:t,debug_id:r});t.debug_meta={images:n}}}(e);const r=Ht(e,gn.dsn,gn.sdkMetadata,gn.tunnel);vn(JSON.stringify(r)),await En.send(r),await En.flush(2e3),bn>=gn.maxAnrEvents&&setTimeout((()=>{process.exit(0)}),5e3)}let Cn;if(vn("Started"),gn.captureStackTrace){vn("Connecting to debugger");const n=new t;n.connectToMainThread(),vn("Connected to debugger");const e=new Map;n.on("Debugger.scriptParsed",(t=>{e.set(t.params.scriptId,t.params.url)})),n.on("Debugger.paused",(t=>{if("other"===t.params.reason)try{vn("Debugger paused");const s=[...t.params.callFrames],i=gn.appRootPath?function(t=(process.argv[1]?rn(process.argv[1]):process.cwd()),n="\\"===o){const e=n?mn(t):t;return t=>{if(!t)return;const o=n?mn(t):t;let{dir:s,base:i,ext:c}=r.parse(o);".js"!==c&&".mjs"!==c&&".cjs"!==c||(i=i.slice(0,-1*c.length));const u=decodeURIComponent(i);s||(s=".");const a=s.lastIndexOf("/node_modules");if(a>-1)return`${s.slice(a+14).replace(/\//g,".")}:${u}`;if(s.startsWith(e)){const t=s.slice(e.length+1).replace(/\//g,".");return t?`${t}:${u}`:u}return u}}(gn.appRootPath):()=>{},c=s.map((t=>function(t,n,e){const r=n?n.replace(/^file:\/\//,""):void 0,o=t.location.columnNumber?t.location.columnNumber+1:void 0,s=t.location.lineNumber?t.location.lineNumber+1:void 0;return L({filename:r,module:e(r),function:t.functionName||$,colno:o,lineno:s,in_app:r?on(r):void 0})}(t,e.get(t.location.scriptId),i))),u=setTimeout((()=>{Tn(c).then(null,(()=>{vn("Sending ANR event failed.")}))}),5e3);n.post("Runtime.evaluate",{expression:"global.__SENTRY_GET_SCOPES__();",silent:!0,returnByValue:!0},((t,e)=>{t&&vn(`Error executing script: '${t.message}'`),clearTimeout(u);const r=e?.result?e.result.value:void 0;n.post("Debugger.resume"),n.post("Debugger.disable"),Tn(c,r).then(null,(()=>{vn("Sending ANR event failed.")}))}))}catch(t){throw n.post("Debugger.resume"),n.post("Debugger.disable"),t}})),Cn=()=>{try{n.post("Debugger.enable",(()=>{n.post("Debugger.pause")}))}catch(t){}}}const{poll:jn}=function(t,n,e,r){const o=t();let s=!1,i=!0;return setInterval((()=>{const t=o.getTimeMs();!1===s&&t>n+e&&(s=!0,i&&r()),t<n+e&&(s=!1)}),20),{poll:()=>{o.reset()},enabled:t=>{i=t}}}((function(){let t=process.hrtime();return{getTimeMs:()=>{const[n,e]=process.hrtime(t);return Math.floor(1e3*n+e/1e6)},reset:()=>{t=process.hrtime()}}}),gn.pollInterval,gn.anrThreshold,(function(){vn("Watchdog timeout"),Cn?(vn("Pausing debugger to capture stack trace"),Cn()):(vn("Capturing event without a stack trace"),Tn().then(null,(()=>{vn("Sending ANR event failed on watchdog timeout.")})))}));e?.on("message",(t=>{t.session&&(yn=K(t.session)),t.debugImages&&(_n=t.debugImages),jn()}));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as util from 'node:util';
|
|
2
|
-
import { defineIntegration, addConsoleInstrumentationHandler, getClient, addBreadcrumb,
|
|
2
|
+
import { defineIntegration, addConsoleInstrumentationHandler, getClient, addBreadcrumb, truncate, severityLevelFromString } from '@sentry/core';
|
|
3
3
|
|
|
4
4
|
const INTEGRATION_NAME = 'Console';
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FsInstrumentation } from '@opentelemetry/instrumentation-fs';
|
|
2
|
-
import { defineIntegration,
|
|
2
|
+
import { defineIntegration, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_OP } from '@sentry/core';
|
|
3
3
|
import { generateInstrumentOnce } from '../otel/instrument.js';
|
|
4
4
|
|
|
5
5
|
const INTEGRATION_NAME = 'FileSystem';
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
import { propagation, context } from '@opentelemetry/api';
|
|
1
2
|
import { VERSION } from '@opentelemetry/core';
|
|
2
3
|
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
|
|
3
|
-
import { getIsolationScope, httpRequestToRequestData, stripUrlQueryAndFragment, withIsolationScope,
|
|
4
|
+
import { LRUMap, getIsolationScope, httpRequestToRequestData, stripUrlQueryAndFragment, withIsolationScope, generateSpanId, getCurrentScope, logger, getClient, getTraceData, getBreadcrumbLogLevelFromHttpStatusCode, addBreadcrumb, parseBaggageHeader, objectToBaggageHeader, parseUrl, getSanitizedUrlString } from '@sentry/core';
|
|
5
|
+
import { shouldPropagateTraceForUrl } from '@sentry/opentelemetry';
|
|
4
6
|
import { DEBUG_BUILD } from '../../debug-build.js';
|
|
5
7
|
import { getRequestUrl } from '../../utils/getRequestUrl.js';
|
|
8
|
+
import { stealthWrap } from './utils.js';
|
|
6
9
|
import { getRequestInfo } from './vendor/getRequestInfo.js';
|
|
7
10
|
|
|
11
|
+
/* eslint-disable max-lines */
|
|
12
|
+
|
|
8
13
|
// We only want to capture request bodies up to 1mb.
|
|
9
14
|
const MAX_BODY_BYTE_LENGTH = 1024 * 1024;
|
|
10
15
|
|
|
@@ -22,8 +27,10 @@ const MAX_BODY_BYTE_LENGTH = 1024 * 1024;
|
|
|
22
27
|
* https://github.com/open-telemetry/opentelemetry-js/blob/f8ab5592ddea5cba0a3b33bf8d74f27872c0367f/experimental/packages/opentelemetry-instrumentation-http/src/http.ts
|
|
23
28
|
*/
|
|
24
29
|
class SentryHttpInstrumentation extends InstrumentationBase {
|
|
30
|
+
|
|
25
31
|
constructor(config = {}) {
|
|
26
32
|
super('@sentry/instrumentation-http', VERSION, config);
|
|
33
|
+
this._propagationDecisionMap = new LRUMap(100);
|
|
27
34
|
}
|
|
28
35
|
|
|
29
36
|
/** @inheritdoc */
|
|
@@ -85,17 +92,17 @@ class SentryHttpInstrumentation extends InstrumentationBase {
|
|
|
85
92
|
return (
|
|
86
93
|
original,
|
|
87
94
|
) => {
|
|
88
|
-
return function incomingRequest(
|
|
95
|
+
return function incomingRequest( ...args) {
|
|
89
96
|
// Only traces request events
|
|
90
|
-
if (
|
|
91
|
-
return original.apply(this,
|
|
97
|
+
if (args[0] !== 'request') {
|
|
98
|
+
return original.apply(this, args);
|
|
92
99
|
}
|
|
93
100
|
|
|
94
101
|
instrumentation._diag.debug('http instrumentation for incoming request');
|
|
95
102
|
|
|
96
103
|
const isolationScope = getIsolationScope().clone();
|
|
97
|
-
const request = args[
|
|
98
|
-
const response = args[
|
|
104
|
+
const request = args[1] ;
|
|
105
|
+
const response = args[2] ;
|
|
99
106
|
|
|
100
107
|
const normalizedRequest = httpRequestToRequestData(request);
|
|
101
108
|
|
|
@@ -126,10 +133,19 @@ class SentryHttpInstrumentation extends InstrumentationBase {
|
|
|
126
133
|
}
|
|
127
134
|
|
|
128
135
|
return withIsolationScope(isolationScope, () => {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
136
|
+
// Set a new propagationSpanId for this request
|
|
137
|
+
// We rely on the fact that `withIsolationScope()` will implicitly also fork the current scope
|
|
138
|
+
// This way we can save an "unnecessary" `withScope()` invocation
|
|
139
|
+
getCurrentScope().getPropagationContext().propagationSpanId = generateSpanId();
|
|
140
|
+
|
|
141
|
+
// If we don't want to extract the trace from the header, we can skip this
|
|
142
|
+
if (!instrumentation.getConfig().extractIncomingTraceFromHeader) {
|
|
143
|
+
return original.apply(this, args);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const ctx = propagation.extract(context.active(), normalizedRequest.headers);
|
|
147
|
+
return context.with(ctx, () => {
|
|
148
|
+
return original.apply(this, args);
|
|
133
149
|
});
|
|
134
150
|
});
|
|
135
151
|
};
|
|
@@ -153,18 +169,23 @@ class SentryHttpInstrumentation extends InstrumentationBase {
|
|
|
153
169
|
// We need to access and reconstruct the request options object passed to `ignoreOutgoingRequests`
|
|
154
170
|
// so that it matches what Otel instrumentation passes to `ignoreOutgoingRequestHook`.
|
|
155
171
|
// @see https://github.com/open-telemetry/opentelemetry-js/blob/7293e69c1e55ca62e15d0724d22605e61bd58952/experimental/packages/opentelemetry-instrumentation-http/src/http.ts#L756-L789
|
|
156
|
-
const argsCopy = [...args];
|
|
172
|
+
const argsCopy = [...args] ;
|
|
157
173
|
|
|
158
|
-
const options = argsCopy
|
|
174
|
+
const options = argsCopy[0];
|
|
175
|
+
const extraOptions = typeof argsCopy[1] === 'object' ? argsCopy[1] : undefined;
|
|
159
176
|
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
? (argsCopy.shift() )
|
|
163
|
-
: undefined;
|
|
177
|
+
const { optionsParsed, origin, pathname } = getRequestInfo(instrumentation._diag, options, extraOptions);
|
|
178
|
+
const url = getAbsoluteUrl(origin, pathname);
|
|
164
179
|
|
|
165
|
-
|
|
180
|
+
// This will be undefined if there are no changed headers
|
|
181
|
+
const mergedHeaders = instrumentation.getConfig().propagateTraceInOutgoingRequests
|
|
182
|
+
? getMergedHeadersForRequestOptions(url, optionsParsed, instrumentation._propagationDecisionMap)
|
|
183
|
+
: undefined;
|
|
166
184
|
|
|
167
|
-
|
|
185
|
+
// If we are not proapgating traces, we skip touching the args for the request at all
|
|
186
|
+
const request = mergedHeaders
|
|
187
|
+
? original.apply(this, getOutgoingRequestArgsWithHeaders(argsCopy, mergedHeaders))
|
|
188
|
+
: original.apply(this, args);
|
|
168
189
|
|
|
169
190
|
request.prependListener('response', (response) => {
|
|
170
191
|
const _breadcrumbs = instrumentation.getConfig().breadcrumbs;
|
|
@@ -209,46 +230,6 @@ class SentryHttpInstrumentation extends InstrumentationBase {
|
|
|
209
230
|
}
|
|
210
231
|
}
|
|
211
232
|
|
|
212
|
-
/**
|
|
213
|
-
* This is a minimal version of `wrap` from shimmer:
|
|
214
|
-
* https://github.com/othiym23/shimmer/blob/master/index.js
|
|
215
|
-
*
|
|
216
|
-
* In contrast to the original implementation, this version does not allow to unwrap,
|
|
217
|
-
* and does not make it clear that the method is wrapped.
|
|
218
|
-
* This is necessary because we want to wrap the http module with our own code,
|
|
219
|
-
* while still allowing to use the HttpInstrumentation from OTEL.
|
|
220
|
-
*
|
|
221
|
-
* Without this, if we'd just use `wrap` from shimmer, the OTEL instrumentation would remove our wrapping,
|
|
222
|
-
* because it only allows any module to be wrapped a single time.
|
|
223
|
-
*/
|
|
224
|
-
function stealthWrap(
|
|
225
|
-
nodule,
|
|
226
|
-
name,
|
|
227
|
-
wrapper,
|
|
228
|
-
) {
|
|
229
|
-
const original = nodule[name];
|
|
230
|
-
const wrapped = wrapper(original);
|
|
231
|
-
|
|
232
|
-
defineProperty(nodule, name, wrapped);
|
|
233
|
-
return wrapped;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// Sets a property on an object, preserving its enumerability.
|
|
237
|
-
function defineProperty(
|
|
238
|
-
obj,
|
|
239
|
-
name,
|
|
240
|
-
value,
|
|
241
|
-
) {
|
|
242
|
-
const enumerable = !!obj[name] && Object.prototype.propertyIsEnumerable.call(obj, name);
|
|
243
|
-
|
|
244
|
-
Object.defineProperty(obj, name, {
|
|
245
|
-
configurable: true,
|
|
246
|
-
enumerable: enumerable,
|
|
247
|
-
writable: true,
|
|
248
|
-
value: value,
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
|
|
252
233
|
/** Add a breadcrumb for outgoing requests. */
|
|
253
234
|
function addRequestBreadcrumb(request, response) {
|
|
254
235
|
const data = getBreadcrumbData(request);
|
|
@@ -474,5 +455,120 @@ const clientToRequestSessionAggregatesMap = new Map
|
|
|
474
455
|
|
|
475
456
|
();
|
|
476
457
|
|
|
458
|
+
/**
|
|
459
|
+
* If there are any headers to be added for this request, this will return the full merged headers object.
|
|
460
|
+
* Else, it will return void.
|
|
461
|
+
*/
|
|
462
|
+
function getMergedHeadersForRequestOptions(
|
|
463
|
+
url,
|
|
464
|
+
options,
|
|
465
|
+
propagationDecisionMap,
|
|
466
|
+
) {
|
|
467
|
+
// Manually add the trace headers, if it applies
|
|
468
|
+
// Note: We do not use `propagation.inject()` here, because our propagator relies on an active span
|
|
469
|
+
// Which we do not have in this case
|
|
470
|
+
const tracePropagationTargets = getClient()?.getOptions().tracePropagationTargets;
|
|
471
|
+
const addedHeaders = shouldPropagateTraceForUrl(url, tracePropagationTargets, propagationDecisionMap)
|
|
472
|
+
? getTraceData()
|
|
473
|
+
: undefined;
|
|
474
|
+
|
|
475
|
+
if (!addedHeaders) {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
const headers = options.headers || {};
|
|
480
|
+
|
|
481
|
+
const { 'sentry-trace': sentryTrace, baggage } = addedHeaders;
|
|
482
|
+
|
|
483
|
+
// We do not want to overwrite existing header here, if it was already set
|
|
484
|
+
if (sentryTrace && !headers['sentry-trace']) {
|
|
485
|
+
headers['sentry-trace'] = sentryTrace;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
// For baggage, we make sure to merge this into a possibly existing header
|
|
489
|
+
if (baggage) {
|
|
490
|
+
headers['baggage'] = mergeBaggageHeaders(headers['baggage'], baggage);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
return headers;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
function getAbsoluteUrl(origin, path = '/') {
|
|
497
|
+
try {
|
|
498
|
+
const url = new URL(path, origin);
|
|
499
|
+
return url.toString();
|
|
500
|
+
} catch {
|
|
501
|
+
// fallback: Construct it on our own
|
|
502
|
+
const url = `${origin}`;
|
|
503
|
+
|
|
504
|
+
if (url.endsWith('/') && path.startsWith('/')) {
|
|
505
|
+
return `${url}${path.slice(1)}`;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
if (!url.endsWith('/') && !path.startsWith('/')) {
|
|
509
|
+
return `${url}/${path.slice(1)}`;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
return `${url}${path}`;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
function mergeBaggageHeaders(
|
|
517
|
+
existing,
|
|
518
|
+
baggage,
|
|
519
|
+
) {
|
|
520
|
+
if (!existing) {
|
|
521
|
+
return baggage;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
const existingBaggageEntries = parseBaggageHeader(existing);
|
|
525
|
+
const newBaggageEntries = parseBaggageHeader(baggage);
|
|
526
|
+
|
|
527
|
+
if (!newBaggageEntries) {
|
|
528
|
+
return existing;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
// Existing entries take precedence, ensuring order remains stable for minimal changes
|
|
532
|
+
const mergedBaggageEntries = { ...existingBaggageEntries };
|
|
533
|
+
Object.entries(newBaggageEntries).forEach(([key, value]) => {
|
|
534
|
+
if (!mergedBaggageEntries[key]) {
|
|
535
|
+
mergedBaggageEntries[key] = value;
|
|
536
|
+
}
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
return objectToBaggageHeader(mergedBaggageEntries);
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
function getOutgoingRequestArgsWithHeaders(originalArgs, headers) {
|
|
543
|
+
const argsCopy = [...originalArgs] ;
|
|
544
|
+
|
|
545
|
+
const arg1 = argsCopy[0];
|
|
546
|
+
|
|
547
|
+
// If the first argument is a string or URL, we need to merge the headers into the options object, which is optional
|
|
548
|
+
if (typeof arg1 === 'string' || arg1 instanceof URL) {
|
|
549
|
+
const arg2 = argsCopy[1];
|
|
550
|
+
|
|
551
|
+
// If the second argument is an object, we just overwrite the headers there
|
|
552
|
+
if (typeof arg2 === 'object') {
|
|
553
|
+
argsCopy[1] = {
|
|
554
|
+
...arg2,
|
|
555
|
+
headers,
|
|
556
|
+
};
|
|
557
|
+
return argsCopy;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// Else, we need to insert a new object as second argument and insert the headers there
|
|
561
|
+
argsCopy.splice(1, 0, { headers });
|
|
562
|
+
return argsCopy;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
// If the first argument is an object, we just overwrite the headers there
|
|
566
|
+
argsCopy[0] = {
|
|
567
|
+
...arg1,
|
|
568
|
+
headers,
|
|
569
|
+
};
|
|
570
|
+
return argsCopy;
|
|
571
|
+
}
|
|
572
|
+
|
|
477
573
|
export { SentryHttpInstrumentation, recordRequestSession };
|
|
478
574
|
//# sourceMappingURL=SentryHttpInstrumentation.js.map
|