@sentry/node 9.0.1 → 9.1.1-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/index.js +22 -22
- package/build/cjs/integrations/anr/index.js +1 -1
- package/build/cjs/integrations/local-variables/local-variables-async.js +1 -1
- package/build/cjs/integrations/node-fetch/SentryNodeFetchInstrumentation.js +272 -0
- package/build/cjs/integrations/node-fetch/SentryNodeFetchInstrumentation.js.map +1 -0
- package/build/cjs/integrations/node-fetch/index.js +85 -0
- package/build/cjs/integrations/node-fetch/index.js.map +1 -0
- package/build/cjs/nodeVersion.js +2 -0
- package/build/cjs/nodeVersion.js.map +1 -1
- package/build/cjs/sdk/index.js +6 -6
- package/build/cjs/sdk/index.js.map +1 -1
- package/build/cjs/utils/baggage.js +36 -0
- package/build/cjs/utils/baggage.js.map +1 -0
- package/build/esm/index.js +1 -1
- package/build/esm/integrations/anr/index.js +1 -1
- package/build/esm/integrations/anr/worker-script.js +2 -2
- 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/node-fetch/SentryNodeFetchInstrumentation.js +270 -0
- package/build/esm/integrations/node-fetch/SentryNodeFetchInstrumentation.js.map +1 -0
- package/build/esm/integrations/node-fetch/index.js +83 -0
- package/build/esm/integrations/node-fetch/index.js.map +1 -0
- package/build/esm/nodeVersion.js +2 -1
- package/build/esm/nodeVersion.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/sdk/index.js +1 -1
- package/build/esm/utils/baggage.js +34 -0
- package/build/esm/utils/baggage.js.map +1 -0
- package/build/types/integrations/node-fetch/SentryNodeFetchInstrumentation.d.ts +51 -0
- package/build/types/integrations/node-fetch/SentryNodeFetchInstrumentation.d.ts.map +1 -0
- package/build/{types-ts3.8/integrations/node-fetch.d.ts → types/integrations/node-fetch/index.d.ts} +23 -15
- package/build/types/integrations/node-fetch/index.d.ts.map +1 -0
- package/build/types/integrations/node-fetch/types.d.ts +32 -0
- package/build/types/integrations/node-fetch/types.d.ts.map +1 -0
- package/build/types/nodeVersion.d.ts +1 -0
- package/build/types/nodeVersion.d.ts.map +1 -1
- package/build/types/utils/baggage.d.ts +6 -0
- package/build/types/utils/baggage.d.ts.map +1 -0
- package/build/types-ts3.8/integrations/node-fetch/SentryNodeFetchInstrumentation.d.ts +51 -0
- package/build/{types/integrations/node-fetch.d.ts → types-ts3.8/integrations/node-fetch/index.d.ts} +23 -15
- package/build/types-ts3.8/integrations/node-fetch/types.d.ts +31 -0
- package/build/types-ts3.8/nodeVersion.d.ts +1 -0
- package/build/types-ts3.8/utils/baggage.d.ts +6 -0
- package/package.json +4 -4
- package/build/cjs/integrations/node-fetch.js +0 -132
- package/build/cjs/integrations/node-fetch.js.map +0 -1
- package/build/esm/integrations/node-fetch.js +0 -130
- package/build/esm/integrations/node-fetch.js.map +0 -1
- package/build/types/integrations/node-fetch.d.ts.map +0 -1
|
@@ -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.0.1";function m(){return y(p),p}function y(t){const n=t.__SENTRY__=t.__SENTRY__||{};return n.version=n.version||d,n[d]=n[d]||{}}function g(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=g("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 O(t){return Boolean(t?.then&&"function"==typeof t.then)}function D(t,n){try{return t instanceof n}catch(t){return!1}}const k=p,A=80;function I(t,n){const e=t,r=[];if(!e?.tagName)return"";if(k.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 D(t,Error)}}(t))return{message:t.message,name:t.name,stack:t.stack,...M(t)};if(n=t,"undefined"!=typeof Event&&D(n,Event)){const n={type:t.type,target:U(t.target),currentTarget:U(t.currentTarget),...M(t)};return"undefined"!=typeof CustomEvent&&D(t,CustomEvent)&&(n.detail=t.detail),n}return t;var n}function U(t){try{return n=t,"undefined"!=typeof Element&&D(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||A;for(;e&&s++<r&&(a=I(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(){const t=p,n=t.crypto||t.msCrypto;let e=()=>16*Math.random();try{if(n?.randomUUID)return n.randomUUID().replace(/-/g,"");n?.getRandomValues&&(e=()=>{const t=new Uint8Array(1);return n.getRandomValues(t),t[0]})}catch(t){}return([1e7]+1e3+4e3+8e3+1e11).replace(/[018]/g,(t=>(t^(15&e())>>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&&(O(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.O=this.O,t.D=this.D,t.k=this.k,t.A=this.A,t.m=[...this.m],t.v=[...this.v],t.j={...this.j},t.R={...this.R},t.I=this.I,t.P=this.P,tt(t,nt(this)),t}setClient(t){this.I=t}setLastEventId(t){this.P=t}getClient(){return this.I}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.D&&V(this.D,{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.A=t,this.U(),this}setLevel(t){return this.O=t,this.U(),this}setTransactionName(t){return this.k=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.D=t:delete this.D,this.U(),this}getSession(){return this.D}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.O=c),u.length&&(this.A=u),a&&(this.R=a),this}clear(){return this._=[],this.N={},this.T={},this.S={},this.C={},this.O=void 0,this.k=void 0,this.A=void 0,this.D=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.I?.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.O,fingerprint:this.A||[],eventProcessors:this.m,propagationContext:this.R,sdkProcessingMetadata:this.j,transactionName:this.k,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.I)return w.warn("No client configured on scope - will not capture exception!"),e;const r=new Error("Sentry syntheticException");return this.I.captureException(t,{originalException:t,syntheticException:r,...n,event_id:e},this),e}captureMessage(t,n,e){const r=e?.event_id||z();if(!this.I)return w.warn("No client configured on scope - will not capture message!"),r;const o=new Error(t);return this.I.captureMessage(t,n,{originalException:t,syntheticException:o,...e,event_id:r},this),r}captureEvent(t,n){const e=n?.event_id||z();return this.I?(this.I.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 O(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=y(m());return t.stack=t.stack||new rt(g("defaultCurrentScope",(()=>new et)),g("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=y(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,yt="_sentryScope",gt="_sentryIsolationScope";function bt(t){return{scope:t[yt],isolationScope:t[gt]}}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:Tt(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"number"==typeof t?Nt(t):Array.isArray(t)?t[0]+t[1]/1e9:t instanceof Date?Nt(t.getTime()):Y()}function Nt(t){return t>9999999999?t/1e3:t}function Tt(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}=t;return L({span_id:n,trace_id:e,data:r,description:s,parent_span_id:c,start_timestamp:xt(o),timestamp:xt(i)||void 0,status:Ct(u),op:r[pt],origin:r[lt]})}return{span_id:n,trace_id:e,start_timestamp:0,data:{}}}function Ct(t){if(t&&t.code!==dt)return t.code===mt?"ok":t.message||"unknown_error"}const jt="_sentryRootSpan";function Rt(t){return t[jt]||t}const Ot="production",Dt="_frozenDsc";function kt(t){const n=at();if(!n)return{};const e=Rt(t),r=Tt(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 It(t,n=100,e=1/0){try{return Pt("",t,n,e)}catch(t){return{ERROR:`**non-serializable** (${t})`}}}function Pt(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?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 Pt("",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]=Pt(t,n,u-1,r,o),h++}return i(n),f}function Ut(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 Mt(t,n=[]){return[t,n]}function Lt(t,n){const e=t[1];for(const t of e){if(n(t,t[0].type))return!0}return!1}function Bt(t){const n=y(p);return n.encodePolyfill?n.encodePolyfill(t):(new TextEncoder).encode(t)}function Gt(t){const[n,e]=t;let r=JSON.stringify(n);function o(t){"string"==typeof r?r="string"==typeof t?r+t:[Bt(r),t]:r.push("string"==typeof t?Bt(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(It(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 Jt={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"};function Yt(t){if(!t?.sdk)return;const{name:n,version:e}=t.sdk;return{name:n,version:e}}function zt(t,n,e,r){const o=Yt(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 Mt(i,[[{type:s},t]])}const Ht="__SENTRY_SUPPRESS_TRACING__";function Wt(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({[Ht]:!0}),t())))}function Ft(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:kt(n),...t.sdkProcessingMetadata};const e=Rt(n),r=Tt(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 Kt="7";class Vt extends Error{constructor(t,n="warn"){super(t),this.message=t,this.logLevel=n}}function Zt(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 Vt("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 Qt(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 Xt=64;function tn(t,n,e=Zt(t.bufferSize||Xt)){let r={};return{send:function(t){const o=[];if(Lt(t,((t,n)=>{const e=function(t){return Jt[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=Mt(t[0],o),i=t=>{Lt(s,((t,n)=>{}))};return e.add((()=>n({body:Gt(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=Qt(r,t),t)),(t=>{throw i(),t})))).then((t=>t),(t=>{if(t instanceof Vt)return h&&w.error("Skipped sending event because buffer is full."),i(),W({});throw t}))},flush:t=>e.drain(t)}}const nn=/^(\S+:\\|\/?)([\s\S]*?)((?:\.{1,2}|[^/\\]+?|)(\.[^./\\]*|))(?:[/\\]*)$/;function en(t){const n=function(t){const n=t.length>1024?`<truncated>${t.slice(-1024)}`:t,e=nn.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 rn(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 on=Symbol("AgentBaseInternalState");class sn extends s.Agent{constructor(t){super(t),this[on]={}}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[on].currentSocket=o,super.createSocket(t,n,e)}),e)}createConnection(){const t=this[on].currentSocket;if(this[on].currentSocket=void 0,!t)throw new Error("No socket was returned in the `connect()` function");return t}get defaultPort(){return this[on].defaultPort??("https:"===this.protocol?443:80)}set defaultPort(t){this[on]&&(this[on].defaultPort=t)}get protocol(){return this[on].protocol??(this.isSecureEndpoint()?"https:":"http:")}set protocol(t){this[on]&&(this[on].protocol=t)}}function cn(...t){w.log("[https-proxy-agent:parse-proxy-response]",...t)}function un(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 cn("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}cn("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(),cn("onend"),e(new Error("Proxy connection ended before receiving CONNECT response"))}function u(t){i(),cn("onerror %o",t),e(t)}t.on("error",u),t.on("end",c),s()}))}function an(...t){w.log("[https-proxy-agent]",...t)}class fn extends sn{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??{},an("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?pn(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){an("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 an("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=un(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",hn),n.secureEndpoint){an("Upgrading socket connection to TLS");const t=n.servername||n.host;return f.connect({...pn(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=>{an("Replaying proxy buffer for failed request"),t.push(h),t.push(null)})),p}}function hn(t){t.resume()}function pn(t,...n){const e={};let r;for(r in t)n.includes(r)||(e[r]=t[r]);return e}fn.__initStatic();const ln=32768;function dn(t){return t.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}const mn=e;let yn,gn=0,bn={};function _n(t){mn.debug&&console.log(`[ANR Worker] ${t}`)}var vn,wn,Sn;const $n=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.")})),tn(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 fn(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)=>{Wt((()=>{let l=function(t){return new c({read(){this.push(t),this.push(null)}})}(f.body);const d={...t.headers};f.body.length>ln&&(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 tn(t,h)}({url:(vn=mn.dsn,wn=mn.tunnel,Sn=mn.sdkMetadata.sdk,wn||`${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/`}(vn)}?${function(t,n){const e={sentry_version:Kt};return t.publicKey&&(e.sentry_key=t.publicKey),n&&(e.sentry_client=`${n.name}/${n.version}`),new URLSearchParams(e).toString()}(vn,Sn)}`),recordDroppedEvent:()=>{}});async function En(){if(yn){_n("Sending abnormal session"),V(yn,{status:"abnormal",abnormal_mechanism:"anr_foreground",release:mn.release,environment:mn.environment});const t=function(t,n,e,r){const o=Yt(e);return Mt({sent_at:(new Date).toISOString(),...o&&{sdk:o},...!!r&&n&&{dsn:At(n)}},["aggregates"in t?[{type:"sessions"},t]:[{type:"session"},t.toJSON()]])}(yn,mn.dsn,mn.sdkMetadata,mn.tunnel);_n(JSON.stringify(t)),await $n.send(t);try{n?.postMessage("session-ended")}catch(t){}}}function xn(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(mn.appRootPath)for(const t of n)t.filename&&(t.filename=Ut(t.filename,mn.appRootPath));return n}async function Nn(t,n){if(gn>=mn.maxAnrEvents)return;gn+=1,await En(),_n("Sending event");const e={event_id:z(),contexts:mn.contexts,release:mn.release,environment:mn.environment,dist:mn.dist,platform:"node",level:"error",exception:{values:[{type:"ApplicationNotResponding",value:`Application Not Responding for at least ${mn.anrThreshold} ms`,stacktrace:{frames:xn(t)},mechanism:{type:"ANR"}}]},tags:mn.staticTags};n&&function(t,n){if(Ft(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(bn).length)return;const n=mn.appRootPath?{}:bn;if(mn.appRootPath)for(const[t,e]of Object.entries(bn))n[Ut(t,mn.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=zt(e,mn.dsn,mn.sdkMetadata,mn.tunnel);_n(JSON.stringify(r)),await $n.send(r),await $n.flush(2e3),gn>=mn.maxAnrEvents&&setTimeout((()=>{process.exit(0)}),5e3)}let Tn;if(_n("Started"),mn.captureStackTrace){_n("Connecting to debugger");const n=new t;n.connectToMainThread(),_n("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{_n("Debugger paused");const s=[...t.params.callFrames],i=mn.appRootPath?function(t=(process.argv[1]?en(process.argv[1]):process.cwd()),n="\\"===o){const e=n?dn(t):t;return t=>{if(!t)return;const o=n?dn(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}}(mn.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?rn(r):void 0})}(t,e.get(t.location.scriptId),i))),u=setTimeout((()=>{Nn(c).then(null,(()=>{_n("Sending ANR event failed.")}))}),5e3);n.post("Runtime.evaluate",{expression:"global.__SENTRY_GET_SCOPES__();",silent:!0,returnByValue:!0},((t,e)=>{t&&_n(`Error executing script: '${t.message}'`),clearTimeout(u);const r=e?.result?e.result.value:void 0;n.post("Debugger.resume"),n.post("Debugger.disable"),Nn(c,r).then(null,(()=>{_n("Sending ANR event failed.")}))}))}catch(t){throw n.post("Debugger.resume"),n.post("Debugger.disable"),t}})),Tn=()=>{try{n.post("Debugger.enable",(()=>{n.post("Debugger.pause")}))}catch(t){}}}const{poll:Cn}=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()}}}),mn.pollInterval,mn.anrThreshold,(function(){_n("Watchdog timeout"),Tn?(_n("Pausing debugger to capture stack trace"),Tn()):(_n("Capturing event without a stack trace"),Nn().then(null,(()=>{_n("Sending ANR event failed on watchdog timeout.")})))}));n?.on("message",(t=>{t.session&&(yn=K(t.session)),t.debugImages&&(bn=t.debugImages),Cn()}));
|
|
1
|
+
/*! @sentry/node 9.1.1-alpha.0 (e07a7e8) | https://github.com/getsentry/sentry-javascript */
|
|
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,d="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,l="9.1.1-alpha.0";function m(){return g(p),p}function g(t){const n=t.__SENTRY__=t.__SENTRY__||{};return n.version=n.version||l,n[l]=n[l]||{}}function y(t,n,e=p){const r=e.__SENTRY__=e.__SENTRY__||{},o=r[l]=r[l]||{};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 d?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(){const t=p,n=t.crypto||t.msCrypto;let e=()=>16*Math.random();try{if(n?.randomUUID)return n.randomUUID().replace(/-/g,"");n?.getRandomValues&&(e=()=>{const t=new Uint8Array(1);return n.getRandomValues(t),t[0]})}catch(t){}return([1e7]+1e3+4e3+8e3+1e11).replace(/[018]/g,(t=>(t^(15&e())>>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){d&&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",dt="sentry.origin",lt=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[dt],links:xt(a)})}return{span_id:n,trace_id:e,start_timestamp:0,data:{}}}function jt(t){if(t&&t.code!==lt)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],d=r.description;return"url"!==p&&d&&(h.transaction=d),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?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"};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(" "),d=+(p[1]||0),l=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:d,statusText:l,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?dn(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({...dn(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 dn(t,...n){const e={};let r;for(r in t)n.includes(r)||(e[r]=t[r]);return e}hn.__initStatic();const ln=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 d=function(t){return new c({read(){this.push(t),this.push(null)}})}(f.body);const l={...t.headers};f.body.length>ln&&(l["content-encoding"]="gzip",d=d.pipe(u()));const m=n.request({method:"POST",agent:e,headers:l,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),d.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()}));
|
|
@@ -4,7 +4,7 @@ import { isDebuggerEnabled } from '../../utils/debug.js';
|
|
|
4
4
|
import { LOCAL_VARIABLES_KEY, functionNamesMatch } from './common.js';
|
|
5
5
|
|
|
6
6
|
// This string is a placeholder that gets overwritten with the worker code.
|
|
7
|
-
const base64WorkerScript = '
|
|
7
|
+
const base64WorkerScript = 'LyohIEBzZW50cnkvbm9kZSA5LjEuMS1hbHBoYS4wIChlMDdhN2U4KSB8IGh0dHBzOi8vZ2l0aHViLmNvbS9nZXRzZW50cnkvc2VudHJ5LWphdmFzY3JpcHQgKi8KaW1wb3J0e1Nlc3Npb24gYXMgZX1mcm9tIm5vZGU6aW5zcGVjdG9yL3Byb21pc2VzIjtpbXBvcnR7d29ya2VyRGF0YSBhcyB0fWZyb20ibm9kZTp3b3JrZXJfdGhyZWFkcyI7Y29uc3Qgbj1nbG9iYWxUaGlzLG89InVuZGVmaW5lZCI9PXR5cGVvZiBfX1NFTlRSWV9ERUJVR19ffHxfX1NFTlRSWV9ERUJVR19fLGE9IjkuMS4xLWFscGhhLjAiO2NvbnN0IGk9WyJkZWJ1ZyIsImluZm8iLCJ3YXJuIiwiZXJyb3IiLCJsb2ciLCJhc3NlcnQiLCJ0cmFjZSJdLHM9e307ZnVuY3Rpb24gYyhlKXtpZighKCJjb25zb2xlImluIG4pKXJldHVybiBlKCk7Y29uc3QgdD1u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cnQgZGVidWdnZXIiLGUpfSkpLHNldEludGVydmFsKCgoKT0+e30pLDFlNCk7';
|
|
8
8
|
|
|
9
9
|
function log(...args) {
|
|
10
10
|
logger.log('[LocalVariables]', ...args);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @sentry/node 9.
|
|
2
|
-
import{Session as e}from"node:inspector/promises";import{workerData as t}from"node:worker_threads";const n=globalThis,o="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,
|
|
1
|
+
/*! @sentry/node 9.1.1-alpha.0 (e07a7e8) | https://github.com/getsentry/sentry-javascript */
|
|
2
|
+
import{Session as e}from"node:inspector/promises";import{workerData as t}from"node:worker_threads";const n=globalThis,o="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,a="9.1.1-alpha.0";const i=["debug","info","warn","error","log","assert","trace"],s={};function c(e){if(!("console"in n))return e();const t=n.console,o={},a=Object.keys(s);a.forEach((e=>{const n=s[e];o[e]=t[e],t[e]=n}));try{return e()}finally{a.forEach((e=>{t[e]=o[e]}))}}!function(e,t,o=n){const i=o.__SENTRY__=o.__SENTRY__||{},s=i[a]=i[a]||{};s[e]||(s[e]=t())}("logger",(function(){let e=!1;const t={enable:()=>{e=!0},disable:()=>{e=!1},isEnabled:()=>e};return o?i.forEach((o=>{t[o]=(...t)=>{e&&c((()=>{n.console[o](`Sentry Logger [${o}]:`,...t)}))}})):i.forEach((e=>{t[e]=()=>{}})),t}));const r="__SENTRY_ERROR_LOCAL_VARIABLES__";const u=t;function l(...e){u.debug&&c((()=>console.log("[LocalVariables Worker]",...e)))}async function f(e,t,n,o){const a=await e.post("Runtime.getProperties",{objectId:t,ownProperties:!0});o[n]=a.result.filter((e=>"length"!==e.name&&!isNaN(parseInt(e.name,10)))).sort(((e,t)=>parseInt(e.name,10)-parseInt(t.name,10))).map((e=>e.value?.value))}async function g(e,t,n,o){const a=await e.post("Runtime.getProperties",{objectId:t,ownProperties:!0});o[n]=a.result.map((e=>[e.name,e.value?.value])).reduce(((e,[t,n])=>(e[t]=n,e)),{})}function d(e,t){e.value&&("value"in e.value?void 0===e.value.value||null===e.value.value?t[e.name]=`<${e.value.value}>`:t[e.name]=e.value.value:"description"in e.value&&"function"!==e.value.type?t[e.name]=`<${e.value.description}>`:"undefined"===e.value.type&&(t[e.name]="<undefined>"))}async function b(e,t){const n=await e.post("Runtime.getProperties",{objectId:t,ownProperties:!0}),o={};for(const t of n.result)if(t.value?.objectId&&"Array"===t.value.className){const n=t.value.objectId;await f(e,n,t.name,o)}else if(t.value?.objectId&&"Object"===t.value.className){const n=t.value.objectId;await g(e,n,t.name,o)}else t.value&&d(t,o);return o}let p;(async function(){const t=new e;t.connectToMainThread(),l("Connected to main thread");let n=!1;t.on("Debugger.resumed",(()=>{n=!1})),t.on("Debugger.paused",(e=>{n=!0,async function(e,{reason:t,data:{objectId:n},callFrames:o}){if("exception"!==t&&"promiseRejection"!==t)return;if(p?.(),null==n)return;const a=[];for(let t=0;t<o.length;t++){const{scopeChain:n,functionName:i,this:s}=o[t],c=n.find((e=>"local"===e.type)),r="global"!==s.className&&s.className?`${s.className}.${i}`:i;if(void 0===c?.object.objectId)a[t]={function:r};else{const n=await b(e,c.object.objectId);a[t]={function:r,vars:n}}}await e.post("Runtime.callFunctionOn",{functionDeclaration:`function() { this.${r} = this.${r} || ${JSON.stringify(a)}; }`,silent:!0,objectId:n}),await e.post("Runtime.releaseObject",{objectId:n})}(t,e.params).then((async()=>{n&&await t.post("Debugger.resume")}),(async e=>{n&&await t.post("Debugger.resume")}))})),await t.post("Debugger.enable");const o=!1!==u.captureAllExceptions;if(await t.post("Debugger.setPauseOnExceptions",{state:o?"all":"uncaught"}),o){const e=u.maxExceptionsPerSecond||50;p=function(e,t,n){let o=0,a=5,i=0;return setInterval((()=>{0===i?o>e&&(a*=2,n(a),a>86400&&(a=86400),i=a):(i-=1,0===i&&t()),o=0}),1e3).unref(),()=>{o+=1}}(e,(async()=>{l("Rate-limit lifted."),await t.post("Debugger.setPauseOnExceptions",{state:"all"})}),(async e=>{l(`Rate-limit exceeded. Disabling capturing of caught exceptions for ${e} seconds.`),await t.post("Debugger.setPauseOnExceptions",{state:"uncaught"})}))}})().catch((e=>{l("Failed to start debugger",e)})),setInterval((()=>{}),1e4);
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { VERSION } from '@opentelemetry/core';
|
|
2
|
+
import { InstrumentationBase } from '@opentelemetry/instrumentation';
|
|
3
|
+
import { LRUMap, getClient, getTraceData, getBreadcrumbLogLevelFromHttpStatusCode, addBreadcrumb, parseUrl, getSanitizedUrlString } from '@sentry/core';
|
|
4
|
+
import { shouldPropagateTraceForUrl } from '@sentry/opentelemetry';
|
|
5
|
+
import * as diagch from 'diagnostics_channel';
|
|
6
|
+
import { NODE_MAJOR, NODE_MINOR } from '../../nodeVersion.js';
|
|
7
|
+
import { mergeBaggageHeaders } from '../../utils/baggage.js';
|
|
8
|
+
|
|
9
|
+
const SENTRY_TRACE_HEADER = 'sentry-trace';
|
|
10
|
+
const SENTRY_BAGGAGE_HEADER = 'baggage';
|
|
11
|
+
|
|
12
|
+
// For baggage, we make sure to merge this into a possibly existing header
|
|
13
|
+
const BAGGAGE_HEADER_REGEX = /baggage: (.*)\r\n/;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* This custom node-fetch instrumentation is used to instrument outgoing fetch requests.
|
|
17
|
+
* It does not emit any spans.
|
|
18
|
+
*
|
|
19
|
+
* The reason this is isolated from the OpenTelemetry instrumentation is that users may overwrite this,
|
|
20
|
+
* which would lead to Sentry not working as expected.
|
|
21
|
+
*
|
|
22
|
+
* This is heavily inspired & adapted from:
|
|
23
|
+
* https://github.com/open-telemetry/opentelemetry-js-contrib/blob/28e209a9da36bc4e1f8c2b0db7360170ed46cb80/plugins/node/instrumentation-undici/src/undici.ts
|
|
24
|
+
*/
|
|
25
|
+
class SentryNodeFetchInstrumentation extends InstrumentationBase {
|
|
26
|
+
// Keep ref to avoid https://github.com/nodejs/node/issues/42170 bug and for
|
|
27
|
+
// unsubscribing.
|
|
28
|
+
|
|
29
|
+
constructor(config = {}) {
|
|
30
|
+
super('@sentry/instrumentation-node-fetch', VERSION, config);
|
|
31
|
+
this._channelSubs = [];
|
|
32
|
+
this._propagationDecisionMap = new LRUMap(100);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** No need to instrument files/modules. */
|
|
36
|
+
init() {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Disable the instrumentation. */
|
|
41
|
+
disable() {
|
|
42
|
+
super.disable();
|
|
43
|
+
this._channelSubs.forEach(sub => sub.unsubscribe());
|
|
44
|
+
this._channelSubs = [];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Enable the instrumentation. */
|
|
48
|
+
enable() {
|
|
49
|
+
// "enabled" handling is currently a bit messy with InstrumentationBase.
|
|
50
|
+
// If constructed with `{enabled: false}`, this `.enable()` is still called,
|
|
51
|
+
// and `this.getConfig().enabled !== this.isEnabled()`, creating confusion.
|
|
52
|
+
//
|
|
53
|
+
// For now, this class will setup for instrumenting if `.enable()` is
|
|
54
|
+
// called, but use `this.getConfig().enabled` to determine if
|
|
55
|
+
// instrumentation should be generated. This covers the more likely common
|
|
56
|
+
// case of config being given a construction time, rather than later via
|
|
57
|
+
// `instance.enable()`, `.disable()`, or `.setConfig()` calls.
|
|
58
|
+
super.enable();
|
|
59
|
+
|
|
60
|
+
// This method is called by the super-class constructor before ours is
|
|
61
|
+
// called. So we need to ensure the property is initalized.
|
|
62
|
+
this._channelSubs = this._channelSubs || [];
|
|
63
|
+
|
|
64
|
+
// Avoid to duplicate subscriptions
|
|
65
|
+
if (this._channelSubs.length > 0) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
this._subscribeToChannel('undici:request:create', this._onRequestCreated.bind(this));
|
|
70
|
+
this._subscribeToChannel('undici:request:headers', this._onResponseHeaders.bind(this));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* This method is called when a request is created.
|
|
75
|
+
* You can still mutate the request here before it is sent.
|
|
76
|
+
*/
|
|
77
|
+
_onRequestCreated({ request }) {
|
|
78
|
+
const config = this.getConfig();
|
|
79
|
+
const enabled = config.enabled !== false;
|
|
80
|
+
|
|
81
|
+
if (!enabled) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Add trace propagation headers
|
|
86
|
+
const url = getAbsoluteUrl(request.origin, request.path);
|
|
87
|
+
const _ignoreOutgoingRequests = config.ignoreOutgoingRequests;
|
|
88
|
+
const shouldIgnore = _ignoreOutgoingRequests && url && _ignoreOutgoingRequests(url);
|
|
89
|
+
|
|
90
|
+
if (shouldIgnore) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Manually add the trace headers, if it applies
|
|
95
|
+
// Note: We do not use `propagation.inject()` here, because our propagator relies on an active span
|
|
96
|
+
// Which we do not have in this case
|
|
97
|
+
// The propagator _may_ overwrite this, but this should be fine as it is the same data
|
|
98
|
+
const tracePropagationTargets = getClient()?.getOptions().tracePropagationTargets;
|
|
99
|
+
const addedHeaders = shouldPropagateTraceForUrl(url, tracePropagationTargets, this._propagationDecisionMap)
|
|
100
|
+
? getTraceData()
|
|
101
|
+
: undefined;
|
|
102
|
+
|
|
103
|
+
if (!addedHeaders) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const { 'sentry-trace': sentryTrace, baggage } = addedHeaders;
|
|
108
|
+
|
|
109
|
+
// We do not want to overwrite existing headers here
|
|
110
|
+
// If the core UndiciInstrumentation is registered, it will already have set the headers
|
|
111
|
+
// We do not want to add any then
|
|
112
|
+
if (Array.isArray(request.headers)) {
|
|
113
|
+
const requestHeaders = request.headers;
|
|
114
|
+
|
|
115
|
+
// We do not want to overwrite existing header here, if it was already set
|
|
116
|
+
if (sentryTrace && !requestHeaders.includes(SENTRY_TRACE_HEADER)) {
|
|
117
|
+
requestHeaders.push(SENTRY_TRACE_HEADER, sentryTrace);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// For baggage, we make sure to merge this into a possibly existing header
|
|
121
|
+
const existingBaggagePos = requestHeaders.findIndex(header => header === SENTRY_BAGGAGE_HEADER);
|
|
122
|
+
if (baggage && existingBaggagePos === -1) {
|
|
123
|
+
requestHeaders.push(SENTRY_BAGGAGE_HEADER, baggage);
|
|
124
|
+
} else if (baggage) {
|
|
125
|
+
const existingBaggage = requestHeaders[existingBaggagePos + 1];
|
|
126
|
+
const merged = mergeBaggageHeaders(existingBaggage, baggage);
|
|
127
|
+
if (merged) {
|
|
128
|
+
requestHeaders[existingBaggagePos + 1] = merged;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
} else {
|
|
132
|
+
const requestHeaders = request.headers;
|
|
133
|
+
// We do not want to overwrite existing header here, if it was already set
|
|
134
|
+
if (sentryTrace && !requestHeaders.includes(`${SENTRY_TRACE_HEADER}:`)) {
|
|
135
|
+
request.headers += `${SENTRY_TRACE_HEADER}: ${sentryTrace}\r\n`;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const existingBaggage = request.headers.match(BAGGAGE_HEADER_REGEX)?.[1];
|
|
139
|
+
if (baggage && !existingBaggage) {
|
|
140
|
+
request.headers += `${SENTRY_BAGGAGE_HEADER}: ${baggage}\r\n`;
|
|
141
|
+
} else if (baggage) {
|
|
142
|
+
const merged = mergeBaggageHeaders(existingBaggage, baggage);
|
|
143
|
+
if (merged) {
|
|
144
|
+
request.headers = request.headers.replace(BAGGAGE_HEADER_REGEX, `baggage: ${merged}\r\n`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* This method is called when a response is received.
|
|
152
|
+
*/
|
|
153
|
+
_onResponseHeaders({ request, response }) {
|
|
154
|
+
const config = this.getConfig();
|
|
155
|
+
const enabled = config.enabled !== false;
|
|
156
|
+
|
|
157
|
+
if (!enabled) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const _breadcrumbs = config.breadcrumbs;
|
|
162
|
+
const breadCrumbsEnabled = typeof _breadcrumbs === 'undefined' ? true : _breadcrumbs;
|
|
163
|
+
|
|
164
|
+
const _ignoreOutgoingRequests = config.ignoreOutgoingRequests;
|
|
165
|
+
const shouldCreateBreadcrumb =
|
|
166
|
+
typeof _ignoreOutgoingRequests === 'function'
|
|
167
|
+
? !_ignoreOutgoingRequests(getAbsoluteUrl(request.origin, request.path))
|
|
168
|
+
: true;
|
|
169
|
+
|
|
170
|
+
if (breadCrumbsEnabled && shouldCreateBreadcrumb) {
|
|
171
|
+
addRequestBreadcrumb(request, response);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Subscribe to a diagnostics channel. */
|
|
176
|
+
_subscribeToChannel(
|
|
177
|
+
diagnosticChannel,
|
|
178
|
+
onMessage,
|
|
179
|
+
) {
|
|
180
|
+
// `diagnostics_channel` had a ref counting bug until v18.19.0.
|
|
181
|
+
// https://github.com/nodejs/node/pull/47520
|
|
182
|
+
const useNewSubscribe = NODE_MAJOR > 18 || (NODE_MAJOR === 18 && NODE_MINOR >= 19);
|
|
183
|
+
|
|
184
|
+
let unsubscribe;
|
|
185
|
+
if (useNewSubscribe) {
|
|
186
|
+
diagch.subscribe?.(diagnosticChannel, onMessage);
|
|
187
|
+
unsubscribe = () => diagch.unsubscribe?.(diagnosticChannel, onMessage);
|
|
188
|
+
} else {
|
|
189
|
+
const channel = diagch.channel(diagnosticChannel);
|
|
190
|
+
channel.subscribe(onMessage);
|
|
191
|
+
unsubscribe = () => channel.unsubscribe(onMessage);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
this._channelSubs.push({
|
|
195
|
+
name: diagnosticChannel,
|
|
196
|
+
unsubscribe,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** Add a breadcrumb for outgoing requests. */
|
|
202
|
+
function addRequestBreadcrumb(request, response) {
|
|
203
|
+
const data = getBreadcrumbData(request);
|
|
204
|
+
|
|
205
|
+
const statusCode = response.statusCode;
|
|
206
|
+
const level = getBreadcrumbLogLevelFromHttpStatusCode(statusCode);
|
|
207
|
+
|
|
208
|
+
addBreadcrumb(
|
|
209
|
+
{
|
|
210
|
+
category: 'http',
|
|
211
|
+
data: {
|
|
212
|
+
status_code: statusCode,
|
|
213
|
+
...data,
|
|
214
|
+
},
|
|
215
|
+
type: 'http',
|
|
216
|
+
level,
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
event: 'response',
|
|
220
|
+
request,
|
|
221
|
+
response,
|
|
222
|
+
},
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function getBreadcrumbData(request) {
|
|
227
|
+
try {
|
|
228
|
+
const url = getAbsoluteUrl(request.origin, request.path);
|
|
229
|
+
const parsedUrl = parseUrl(url);
|
|
230
|
+
|
|
231
|
+
const data = {
|
|
232
|
+
url: getSanitizedUrlString(parsedUrl),
|
|
233
|
+
'http.method': request.method || 'GET',
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
if (parsedUrl.search) {
|
|
237
|
+
data['http.query'] = parsedUrl.search;
|
|
238
|
+
}
|
|
239
|
+
if (parsedUrl.hash) {
|
|
240
|
+
data['http.fragment'] = parsedUrl.hash;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return data;
|
|
244
|
+
} catch {
|
|
245
|
+
return {};
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function getAbsoluteUrl(origin, path = '/') {
|
|
250
|
+
try {
|
|
251
|
+
const url = new URL(path, origin);
|
|
252
|
+
return url.toString();
|
|
253
|
+
} catch {
|
|
254
|
+
// fallback: Construct it on our own
|
|
255
|
+
const url = `${origin}`;
|
|
256
|
+
|
|
257
|
+
if (url.endsWith('/') && path.startsWith('/')) {
|
|
258
|
+
return `${url}${path.slice(1)}`;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (!url.endsWith('/') && !path.startsWith('/')) {
|
|
262
|
+
return `${url}/${path.slice(1)}`;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return `${url}${path}`;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export { SentryNodeFetchInstrumentation };
|
|
270
|
+
//# sourceMappingURL=SentryNodeFetchInstrumentation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SentryNodeFetchInstrumentation.js","sources":["../../../../src/integrations/node-fetch/SentryNodeFetchInstrumentation.ts"],"sourcesContent":["import { VERSION } from '@opentelemetry/core';\nimport type { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport { InstrumentationBase } from '@opentelemetry/instrumentation';\nimport type { SanitizedRequestData } from '@sentry/core';\nimport { LRUMap, getClient, getTraceData } from '@sentry/core';\nimport { addBreadcrumb, getBreadcrumbLogLevelFromHttpStatusCode, getSanitizedUrlString, parseUrl } from '@sentry/core';\nimport { shouldPropagateTraceForUrl } from '@sentry/opentelemetry';\nimport * as diagch from 'diagnostics_channel';\nimport { NODE_MAJOR, NODE_MINOR } from '../../nodeVersion';\nimport { mergeBaggageHeaders } from '../../utils/baggage';\nimport type { UndiciRequest, UndiciResponse } from './types';\n\nconst SENTRY_TRACE_HEADER = 'sentry-trace';\nconst SENTRY_BAGGAGE_HEADER = 'baggage';\n\n// For baggage, we make sure to merge this into a possibly existing header\nconst BAGGAGE_HEADER_REGEX = /baggage: (.*)\\r\\n/;\n\nexport type SentryNodeFetchInstrumentationOptions = InstrumentationConfig & {\n /**\n * Whether breadcrumbs should be recorded for requests.\n *\n * @default `true`\n */\n breadcrumbs?: boolean;\n\n /**\n * Do not capture breadcrumbs or inject headers for outgoing fetch requests to URLs where the given callback returns `true`.\n * The same option can be passed to the top-level httpIntegration where it controls both, breadcrumb and\n * span creation.\n *\n * @param url Contains the entire URL, including query string (if any), protocol, host, etc. of the outgoing request.\n */\n ignoreOutgoingRequests?: (url: string) => boolean;\n};\n\ninterface ListenerRecord {\n name: string;\n unsubscribe: () => void;\n}\n\n/**\n * This custom node-fetch instrumentation is used to instrument outgoing fetch requests.\n * It does not emit any spans.\n *\n * The reason this is isolated from the OpenTelemetry instrumentation is that users may overwrite this,\n * which would lead to Sentry not working as expected.\n *\n * This is heavily inspired & adapted from:\n * https://github.com/open-telemetry/opentelemetry-js-contrib/blob/28e209a9da36bc4e1f8c2b0db7360170ed46cb80/plugins/node/instrumentation-undici/src/undici.ts\n */\nexport class SentryNodeFetchInstrumentation extends InstrumentationBase<SentryNodeFetchInstrumentationOptions> {\n // Keep ref to avoid https://github.com/nodejs/node/issues/42170 bug and for\n // unsubscribing.\n private _channelSubs: Array<ListenerRecord>;\n private _propagationDecisionMap: LRUMap<string, boolean>;\n\n public constructor(config: SentryNodeFetchInstrumentationOptions = {}) {\n super('@sentry/instrumentation-node-fetch', VERSION, config);\n this._channelSubs = [];\n this._propagationDecisionMap = new LRUMap<string, boolean>(100);\n }\n\n /** No need to instrument files/modules. */\n public init(): void {\n return undefined;\n }\n\n /** Disable the instrumentation. */\n public disable(): void {\n super.disable();\n this._channelSubs.forEach(sub => sub.unsubscribe());\n this._channelSubs = [];\n }\n\n /** Enable the instrumentation. */\n public enable(): void {\n // \"enabled\" handling is currently a bit messy with InstrumentationBase.\n // If constructed with `{enabled: false}`, this `.enable()` is still called,\n // and `this.getConfig().enabled !== this.isEnabled()`, creating confusion.\n //\n // For now, this class will setup for instrumenting if `.enable()` is\n // called, but use `this.getConfig().enabled` to determine if\n // instrumentation should be generated. This covers the more likely common\n // case of config being given a construction time, rather than later via\n // `instance.enable()`, `.disable()`, or `.setConfig()` calls.\n super.enable();\n\n // This method is called by the super-class constructor before ours is\n // called. So we need to ensure the property is initalized.\n this._channelSubs = this._channelSubs || [];\n\n // Avoid to duplicate subscriptions\n if (this._channelSubs.length > 0) {\n return;\n }\n\n this._subscribeToChannel('undici:request:create', this._onRequestCreated.bind(this));\n this._subscribeToChannel('undici:request:headers', this._onResponseHeaders.bind(this));\n }\n\n /**\n * This method is called when a request is created.\n * You can still mutate the request here before it is sent.\n */\n private _onRequestCreated({ request }: { request: UndiciRequest }): void {\n const config = this.getConfig();\n const enabled = config.enabled !== false;\n\n if (!enabled) {\n return;\n }\n\n // Add trace propagation headers\n const url = getAbsoluteUrl(request.origin, request.path);\n const _ignoreOutgoingRequests = config.ignoreOutgoingRequests;\n const shouldIgnore = _ignoreOutgoingRequests && url && _ignoreOutgoingRequests(url);\n\n if (shouldIgnore) {\n return;\n }\n\n // Manually add the trace headers, if it applies\n // Note: We do not use `propagation.inject()` here, because our propagator relies on an active span\n // Which we do not have in this case\n // The propagator _may_ overwrite this, but this should be fine as it is the same data\n const tracePropagationTargets = getClient()?.getOptions().tracePropagationTargets;\n const addedHeaders = shouldPropagateTraceForUrl(url, tracePropagationTargets, this._propagationDecisionMap)\n ? getTraceData()\n : undefined;\n\n if (!addedHeaders) {\n return;\n }\n\n const { 'sentry-trace': sentryTrace, baggage } = addedHeaders;\n\n // We do not want to overwrite existing headers here\n // If the core UndiciInstrumentation is registered, it will already have set the headers\n // We do not want to add any then\n if (Array.isArray(request.headers)) {\n const requestHeaders = request.headers;\n\n // We do not want to overwrite existing header here, if it was already set\n if (sentryTrace && !requestHeaders.includes(SENTRY_TRACE_HEADER)) {\n requestHeaders.push(SENTRY_TRACE_HEADER, sentryTrace);\n }\n\n // For baggage, we make sure to merge this into a possibly existing header\n const existingBaggagePos = requestHeaders.findIndex(header => header === SENTRY_BAGGAGE_HEADER);\n if (baggage && existingBaggagePos === -1) {\n requestHeaders.push(SENTRY_BAGGAGE_HEADER, baggage);\n } else if (baggage) {\n const existingBaggage = requestHeaders[existingBaggagePos + 1];\n const merged = mergeBaggageHeaders(existingBaggage, baggage);\n if (merged) {\n requestHeaders[existingBaggagePos + 1] = merged;\n }\n }\n } else {\n const requestHeaders = request.headers;\n // We do not want to overwrite existing header here, if it was already set\n if (sentryTrace && !requestHeaders.includes(`${SENTRY_TRACE_HEADER}:`)) {\n request.headers += `${SENTRY_TRACE_HEADER}: ${sentryTrace}\\r\\n`;\n }\n\n const existingBaggage = request.headers.match(BAGGAGE_HEADER_REGEX)?.[1];\n if (baggage && !existingBaggage) {\n request.headers += `${SENTRY_BAGGAGE_HEADER}: ${baggage}\\r\\n`;\n } else if (baggage) {\n const merged = mergeBaggageHeaders(existingBaggage, baggage);\n if (merged) {\n request.headers = request.headers.replace(BAGGAGE_HEADER_REGEX, `baggage: ${merged}\\r\\n`);\n }\n }\n }\n }\n\n /**\n * This method is called when a response is received.\n */\n private _onResponseHeaders({ request, response }: { request: UndiciRequest; response: UndiciResponse }): void {\n const config = this.getConfig();\n const enabled = config.enabled !== false;\n\n if (!enabled) {\n return;\n }\n\n const _breadcrumbs = config.breadcrumbs;\n const breadCrumbsEnabled = typeof _breadcrumbs === 'undefined' ? true : _breadcrumbs;\n\n const _ignoreOutgoingRequests = config.ignoreOutgoingRequests;\n const shouldCreateBreadcrumb =\n typeof _ignoreOutgoingRequests === 'function'\n ? !_ignoreOutgoingRequests(getAbsoluteUrl(request.origin, request.path))\n : true;\n\n if (breadCrumbsEnabled && shouldCreateBreadcrumb) {\n addRequestBreadcrumb(request, response);\n }\n }\n\n /** Subscribe to a diagnostics channel. */\n private _subscribeToChannel(\n diagnosticChannel: string,\n onMessage: (message: unknown, name: string | symbol) => void,\n ): void {\n // `diagnostics_channel` had a ref counting bug until v18.19.0.\n // https://github.com/nodejs/node/pull/47520\n const useNewSubscribe = NODE_MAJOR > 18 || (NODE_MAJOR === 18 && NODE_MINOR >= 19);\n\n let unsubscribe: () => void;\n if (useNewSubscribe) {\n diagch.subscribe?.(diagnosticChannel, onMessage);\n unsubscribe = () => diagch.unsubscribe?.(diagnosticChannel, onMessage);\n } else {\n const channel = diagch.channel(diagnosticChannel);\n channel.subscribe(onMessage);\n unsubscribe = () => channel.unsubscribe(onMessage);\n }\n\n this._channelSubs.push({\n name: diagnosticChannel,\n unsubscribe,\n });\n }\n}\n\n/** Add a breadcrumb for outgoing requests. */\nfunction addRequestBreadcrumb(request: UndiciRequest, response: UndiciResponse): void {\n const data = getBreadcrumbData(request);\n\n const statusCode = response.statusCode;\n const level = getBreadcrumbLogLevelFromHttpStatusCode(statusCode);\n\n addBreadcrumb(\n {\n category: 'http',\n data: {\n status_code: statusCode,\n ...data,\n },\n type: 'http',\n level,\n },\n {\n event: 'response',\n request,\n response,\n },\n );\n}\n\nfunction getBreadcrumbData(request: UndiciRequest): Partial<SanitizedRequestData> {\n try {\n const url = getAbsoluteUrl(request.origin, request.path);\n const parsedUrl = parseUrl(url);\n\n const data: Partial<SanitizedRequestData> = {\n url: getSanitizedUrlString(parsedUrl),\n 'http.method': request.method || 'GET',\n };\n\n if (parsedUrl.search) {\n data['http.query'] = parsedUrl.search;\n }\n if (parsedUrl.hash) {\n data['http.fragment'] = parsedUrl.hash;\n }\n\n return data;\n } catch {\n return {};\n }\n}\n\nfunction getAbsoluteUrl(origin: string, path: string = '/'): string {\n try {\n const url = new URL(path, origin);\n return url.toString();\n } catch {\n // fallback: Construct it on our own\n const url = `${origin}`;\n\n if (url.endsWith('/') && path.startsWith('/')) {\n return `${url}${path.slice(1)}`;\n }\n\n if (!url.endsWith('/') && !path.startsWith('/')) {\n return `${url}/${path.slice(1)}`;\n }\n\n return `${url}${path}`;\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAYA,MAAM,mBAAA,GAAsB,cAAc;AAC1C,MAAM,qBAAA,GAAwB,SAAS;;AAEvC;AACA,MAAM,oBAAA,GAAuB,mBAAmB;;AAyBhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,8BAAA,SAAuC,mBAAmB,CAAwC;AAC/G;AACA;;AAIA,GAAS,WAAW,CAAC,MAAM,G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ACA,GAAA,CAAA,MAAA;AACA;AACA,IAAA,MAAA,GAAA,GAAA,CAAA,EAAA,MAAA,CAAA,CAAA;;AAEA,IAAA,IAAA,GAAA,CAAA,QAAA,CAAA,GAAA,CAAA,IAAA,IAAA,CAAA,UAAA,CAAA,GAAA,CAAA,EAAA;AACA,MAAA,OAAA,CAAA,EAAA,GAAA,CAAA,EAAA,IAAA,CAAA,KAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACA;;AAEA,IAAA,IAAA,CAAA,GAAA,CAAA,QAAA,CAAA,GAAA,CAAA,IAAA,CAAA,IAAA,CAAA,UAAA,CAAA,GAAA,CAAA,EAAA;AACA,MAAA,OAAA,CAAA,EAAA,GAAA,CAAA,CAAA,EAAA,IAAA,CAAA,KAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACA;;AAEA,IAAA,OAAA,CAAA,EAAA,GAAA,CAAA,EAAA,IAAA,CAAA,CAAA;AACA;AACA;;;;"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { UndiciInstrumentation } from '@opentelemetry/instrumentation-undici';
|
|
2
|
+
import { defineIntegration, getClient, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
|
|
3
|
+
import { generateInstrumentOnce } from '../../otel/instrument.js';
|
|
4
|
+
import { SentryNodeFetchInstrumentation } from './SentryNodeFetchInstrumentation.js';
|
|
5
|
+
|
|
6
|
+
const INTEGRATION_NAME = 'NodeFetch';
|
|
7
|
+
|
|
8
|
+
const instrumentOtelNodeFetch = generateInstrumentOnce(INTEGRATION_NAME, config => {
|
|
9
|
+
return new UndiciInstrumentation(config);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const instrumentSentryNodeFetch = generateInstrumentOnce(
|
|
13
|
+
`${INTEGRATION_NAME}.sentry`,
|
|
14
|
+
config => {
|
|
15
|
+
return new SentryNodeFetchInstrumentation(config);
|
|
16
|
+
},
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const _nativeNodeFetchIntegration = ((options = {}) => {
|
|
20
|
+
return {
|
|
21
|
+
name: 'NodeFetch',
|
|
22
|
+
setupOnce() {
|
|
23
|
+
const instrumentSpans = _shouldInstrumentSpans(options, getClient()?.getOptions());
|
|
24
|
+
|
|
25
|
+
// This is the "regular" OTEL instrumentation that emits spans
|
|
26
|
+
if (instrumentSpans) {
|
|
27
|
+
const instrumentationConfig = getConfigWithDefaults(options);
|
|
28
|
+
instrumentOtelNodeFetch(instrumentationConfig);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// This is the Sentry-specific instrumentation that creates breadcrumbs & propagates traces
|
|
32
|
+
// This must be registered after the OTEL one, to ensure that the core trace propagation logic takes presedence
|
|
33
|
+
// Otherwise, the sentry-trace header may be set multiple times
|
|
34
|
+
instrumentSentryNodeFetch(options);
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}) ;
|
|
38
|
+
|
|
39
|
+
const nativeNodeFetchIntegration = defineIntegration(_nativeNodeFetchIntegration);
|
|
40
|
+
|
|
41
|
+
// Matching the behavior of the base instrumentation
|
|
42
|
+
function getAbsoluteUrl(origin, path = '/') {
|
|
43
|
+
const url = `${origin}`;
|
|
44
|
+
|
|
45
|
+
if (url.endsWith('/') && path.startsWith('/')) {
|
|
46
|
+
return `${url}${path.slice(1)}`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (!url.endsWith('/') && !path.startsWith('/')) {
|
|
50
|
+
return `${url}/${path.slice(1)}`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return `${url}${path}`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function _shouldInstrumentSpans(options, clientOptions = {}) {
|
|
57
|
+
// If `spans` is passed in, it takes precedence
|
|
58
|
+
// Else, we by default emit spans, unless `skipOpenTelemetrySetup` is set to `true`
|
|
59
|
+
return typeof options.spans === 'boolean' ? options.spans : !clientOptions.skipOpenTelemetrySetup;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function getConfigWithDefaults(options = {}) {
|
|
63
|
+
const instrumentationConfig = {
|
|
64
|
+
requireParentforSpans: false,
|
|
65
|
+
ignoreRequestHook: request => {
|
|
66
|
+
const url = getAbsoluteUrl(request.origin, request.path);
|
|
67
|
+
const _ignoreOutgoingRequests = options.ignoreOutgoingRequests;
|
|
68
|
+
const shouldIgnore = _ignoreOutgoingRequests && url && _ignoreOutgoingRequests(url);
|
|
69
|
+
|
|
70
|
+
return !!shouldIgnore;
|
|
71
|
+
},
|
|
72
|
+
startSpanHook: () => {
|
|
73
|
+
return {
|
|
74
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.node_fetch',
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
} ;
|
|
78
|
+
|
|
79
|
+
return instrumentationConfig;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export { nativeNodeFetchIntegration };
|
|
83
|
+
//# sourceMappingURL=index.js.map
|