@sentry/node 9.12.0 → 9.14.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 +7 -4
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/integrations/anr/index.js +3 -3
- package/build/cjs/integrations/anr/index.js.map +1 -1
- package/build/cjs/integrations/context.js +3 -3
- package/build/cjs/integrations/context.js.map +1 -1
- package/build/cjs/integrations/http/SentryHttpInstrumentation.js +37 -36
- package/build/cjs/integrations/http/SentryHttpInstrumentation.js.map +1 -1
- package/build/cjs/integrations/local-variables/local-variables-async.js +1 -1
- package/build/cjs/integrations/node-fetch/index.js +11 -7
- package/build/cjs/integrations/node-fetch/index.js.map +1 -1
- package/build/cjs/integrations/tracing/graphql.js +31 -3
- package/build/cjs/integrations/tracing/graphql.js.map +1 -1
- package/build/cjs/integrations/winston.js +151 -0
- package/build/cjs/integrations/winston.js.map +1 -0
- package/build/cjs/logs/capture.js +29 -0
- package/build/cjs/logs/capture.js.map +1 -0
- package/build/cjs/{log.js → logs/exports.js} +8 -30
- package/build/cjs/logs/exports.js.map +1 -0
- package/build/cjs/otel/instrument.js +50 -2
- package/build/cjs/otel/instrument.js.map +1 -1
- package/build/cjs/sdk/index.js +1 -2
- package/build/cjs/sdk/index.js.map +1 -1
- package/build/esm/index.js +4 -4
- package/build/esm/integrations/anr/index.js +1 -1
- package/build/esm/integrations/anr/worker-script.js +2 -2
- package/build/esm/integrations/http/SentryHttpInstrumentation.js +37 -36
- package/build/esm/integrations/http/SentryHttpInstrumentation.js.map +1 -1
- 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/index.js +11 -7
- package/build/esm/integrations/node-fetch/index.js.map +1 -1
- package/build/esm/integrations/tracing/express.js +1 -1
- package/build/esm/integrations/tracing/fastify.js +1 -1
- package/build/esm/integrations/tracing/graphql.js +32 -4
- package/build/esm/integrations/tracing/graphql.js.map +1 -1
- package/build/esm/integrations/tracing/koa.js +1 -1
- package/build/esm/integrations/winston.js +149 -0
- package/build/esm/integrations/winston.js.map +1 -0
- package/build/esm/logs/capture.js +27 -0
- package/build/esm/logs/capture.js.map +1 -0
- package/build/esm/{log.js → logs/exports.js} +2 -25
- package/build/esm/logs/exports.js.map +1 -0
- package/build/esm/otel/instrument.js +50 -2
- package/build/esm/otel/instrument.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/sdk/index.js +1 -2
- package/build/esm/sdk/index.js.map +1 -1
- package/build/types/index.d.ts +3 -3
- package/build/types/index.d.ts.map +1 -1
- package/build/types/integrations/http/SentryHttpInstrumentation.d.ts.map +1 -1
- package/build/types/integrations/node-fetch/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/graphql.d.ts +2 -1
- package/build/types/integrations/tracing/graphql.d.ts.map +1 -1
- package/build/types/integrations/winston.d.ts +44 -0
- package/build/types/integrations/winston.d.ts.map +1 -0
- package/build/types/logs/capture.d.ts +11 -0
- package/build/types/logs/capture.d.ts.map +1 -0
- package/build/{types-ts3.8/log.d.ts → types/logs/exports.d.ts} +150 -158
- package/build/types/logs/exports.d.ts.map +1 -0
- package/build/types/otel/instrument.d.ts +3 -4
- package/build/types/otel/instrument.d.ts.map +1 -1
- package/build/types-ts3.8/index.d.ts +3 -3
- package/build/types-ts3.8/integrations/tracing/graphql.d.ts +2 -1
- package/build/types-ts3.8/integrations/winston.d.ts +44 -0
- package/build/types-ts3.8/logs/capture.d.ts +18 -0
- package/build/{types/log.d.ts → types-ts3.8/logs/exports.d.ts} +150 -151
- package/build/types-ts3.8/otel/instrument.d.ts +3 -4
- package/package.json +4 -4
- package/build/cjs/integrations/console.js +0 -37
- package/build/cjs/integrations/console.js.map +0 -1
- package/build/cjs/log.js.map +0 -1
- package/build/esm/integrations/console.js +0 -35
- package/build/esm/integrations/console.js.map +0 -1
- package/build/esm/log.js.map +0 -1
- package/build/types/integrations/console.d.ts +0 -5
- package/build/types/integrations/console.d.ts.map +0 -1
- package/build/types/log.d.ts.map +0 -1
- package/build/types-ts3.8/integrations/console.d.ts +0 -5
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @sentry/node 9.
|
|
2
|
-
import{Session as t}from"node:inspector";import{workerData as n,parentPort as e}from"node:worker_threads";import{posix as r,sep as o}from"node:path";import*as s from"node:http";import*as i from"node:https";import{Readable as c}from"node:stream";import{createGzip as u}from"node:zlib";import*as a from"node:net";import*as f from"node:tls";const h="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,p=globalThis,l="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,d="9.12.0";function m(){return g(p),p}function g(t){const n=t.__SENTRY__=t.__SENTRY__||{};return n.version=n.version||d,n[d]=n[d]||{}}function y(t,n,e=p){const r=e.__SENTRY__=e.__SENTRY__||{},o=r[d]=r[d]||{};return o[t]||(o[t]=n())}const b=["debug","info","warn","error","log","assert","trace"],_={};function v(t){if(!("console"in p))return t();const n=p.console,e={},r=Object.keys(_);r.forEach((t=>{const r=_[t];e[t]=n[t],n[t]=r}));try{return t()}finally{r.forEach((t=>{n[t]=e[t]}))}}const w=y("logger",(function(){let t=!1;const n={enable:()=>{t=!0},disable:()=>{t=!1},isEnabled:()=>t};return l?b.forEach((e=>{n[e]=(...n)=>{t&&v((()=>{p.console[e](`Sentry Logger [${e}]:`,...n)}))}})):b.forEach((t=>{n[t]=()=>{}})),n})),S=50,$="?",E=/captureMessage|captureException/;function x(t){return t[t.length-1]||{}}const N="<anonymous>";const T=1e3;function C(){return Date.now()/T}const R=function(){const{performance:t}=p;if(!t?.now)return C;const n=Date.now()-t.now(),e=null==t.timeOrigin?n:t.timeOrigin;return()=>(e+t.now())/T}(),k=Object.prototype.toString;function j(t,n){return k.call(t)===`[object ${n}]`}function D(t){return j(t,"String")}function I(t){return j(t,"Object")}function O(t){return Boolean(t?.then&&"function"==typeof t.then)}function A(t,n){try{return t instanceof n}catch(t){return!1}}const P=p,U=80;function M(t,n){const e=t,r=[];if(!e?.tagName)return"";if(P.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&&D(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 L(t,n=0){return"string"!=typeof t||0===n||t.length<=n?t:`${t.slice(0,n)}...`}function B(t){if(function(t){switch(k.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return A(t,Error)}}(t))return{message:t.message,name:t.name,stack:t.stack,...J(t)};if(n=t,"undefined"!=typeof Event&&A(n,Event)){const n={type:t.type,target:G(t.target),currentTarget:G(t.currentTarget),...J(t)};return"undefined"!=typeof CustomEvent&&A(t,CustomEvent)&&(n.detail=t.detail),n}return t;var n}function G(t){try{return n=t,"undefined"!=typeof Element&&A(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||U;for(;e&&s++<r&&(a=M(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 J(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 Y(t=function(){const t=p;return t.crypto||t.msCrypto}()){let n=()=>16*Math.random();try{if(t?.randomUUID)return t.randomUUID().replace(/-/g,"");t?.getRandomValues&&(n=()=>{const n=new Uint8Array(1);return t.getRandomValues(n),n[0]})}catch(t){}return([1e7]+1e3+4e3+8e3+1e11).replace(/[018]/g,(t=>(t^(15&n())>>t/4).toString(16)))}var z;function H(t){return new F((n=>{n(t)}))}!function(t){t[t.PENDING=0]="PENDING";t[t.RESOLVED=1]="RESOLVED";t[t.REJECTED=2]="REJECTED"}(z||(z={}));class F{constructor(t){this.t=z.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===z.PENDING)return;const t=this.o.slice();this.o=[],t.forEach((t=>{t[0]||(this.t===z.RESOLVED&&t[1](this.h),this.t===z.REJECTED&&t[2](this.h),t[0]=!0)}))}i(t){const n=(t,n)=>{this.t===z.PENDING&&(O(n)?n.then(e,r):(this.t=t,this.h=n,this.u()))},e=t=>{n(z.RESOLVED,t)},r=t=>{n(z.REJECTED,t)};try{t(e,r)}catch(t){r(t)}}}function W(t){const n=R(),e={sid:Y(),init:!0,timestamp:n,started:n,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>function(t){return{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&&K(e,t),e}function K(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||R(),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:Y()),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 V(){return Y()}function Z(){return Y().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 Q="_sentrySpan";function X(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,Q,n):delete t[Q]}function tt(t){return t[Q]}class nt{constructor(){this.p=!1,this.l=[],this.m=[],this._=[],this.v=[],this.S={},this.N={},this.T={},this.C={},this.R={},this.k={traceId:V(),sampleRand:Math.random()}}clone(){const t=new nt;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.j=this.j,t.D=this.D,t.I=this.I,t.O=this.O,t.m=[...this.m],t.v=[...this.v],t.R={...this.R},t.k={...this.k},t.A=this.A,t.P=this.P,X(t,tt(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.D&&K(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.O=t,this.U(),this}setLevel(t){return this.j=t,this.U(),this}setTransactionName(t){return this.I=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 nt?n.getScopeData():I(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.j=c),u.length&&(this.O=u),a&&(this.k=a),this}clear(){return this._=[],this.N={},this.T={},this.S={},this.C={},this.j=void 0,this.I=void 0,this.O=void 0,this.D=void 0,X(this,void 0),this.v=[],this.setPropagationContext({traceId:V(),sampleRand:Math.random()}),this.U(),this}addBreadcrumb(t,n){const e="number"==typeof n?n:100;if(e<=0)return this;const r={timestamp:C(),...t,message:t.message?L(t.message,2048):t.message};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.j,fingerprint:this.O||[],eventProcessors:this.m,propagationContext:this.k,sdkProcessingMetadata:this.R,transactionName:this.I,span:tt(this)}}setSDKProcessingMetadata(t){return this.R=q(this.R,t,2),this}setPropagationContext(t){return this.k=t,this}getPropagationContext(){return this.k}captureException(t,n){const e=n?.event_id||Y();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||Y();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||Y();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 et{constructor(t,n){let e,r;e=t||new nt,r=n||new nt,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 rt(){const t=g(m());return t.stack=t.stack||new et(y("defaultCurrentScope",(()=>new nt)),y("defaultIsolationScope",(()=>new nt)))}function ot(t){return rt().withScope(t)}function st(t,n){const e=rt();return e.withScope((()=>(e.getStackTop().scope=t,n(t))))}function it(t){return rt().withScope((()=>t(rt().getIsolationScope())))}function ct(t){const n=g(t);return n.acs?n.acs:{withIsolationScope:it,withScope:ot,withSetScope:st,withSetIsolationScope:(t,n)=>it(n),getCurrentScope:()=>rt().getScope(),getIsolationScope:()=>rt().getIsolationScope()}}function ut(){return ct(m()).getCurrentScope().getClient()}const at="sentry.source",ft="sentry.sample_rate",ht="sentry.op",pt="sentry.origin",lt=0,dt=1,mt="_sentryScope",gt="_sentryIsolationScope";function yt(t){return{scope:t[mt],isolationScope:t[gt]}}const bt="sentry-",_t=/^sentry-/;function vt(t){const n=function(t){if(!t||!D(t)&&!Array.isArray(t))return;if(Array.isArray(t))return t.reduce(((t,n)=>{const e=wt(n);return Object.entries(e).forEach((([n,e])=>{t[n]=e})),t}),{});return wt(t)}(t);if(!n)return;const e=Object.entries(n).reduce(((t,[n,e])=>{if(n.match(_t)){t[n.slice(bt.length)]=e}return t}),{});return Object.keys(e).length>0?e:void 0}function wt(t){return t.split(",").map((t=>t.split("=").map((t=>decodeURIComponent(t.trim()))))).reduce(((t,[n,e])=>(n&&e&&(t[n]=e),t)),{})}const St=1;function $t(t){const{spanId:n,traceId:e,isRemote:r}=t.spanContext(),o=r?n:Tt(t).parent_span_id,s=yt(t).scope;return{parent_span_id:o,span_id:r?s?.getPropagationContext().propagationSpanId||Z():n,trace_id:e}}function Et(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===St,attributes:o,...r}))):void 0}function xt(t){return"number"==typeof t?Nt(t):Array.isArray(t)?t[0]+t[1]/1e9:t instanceof Date?Nt(t.getTime()):R()}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,links:a}=t;return{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[ht],origin:r[pt],links:Et(a)}}return{span_id:n,trace_id:e,start_timestamp:0,data:{}}}function Ct(t){if(t&&t.code!==lt)return t.code===dt?"ok":t.message||"unknown_error"}const Rt="_sentryRootSpan";function kt(t){return t[Rt]||t}const jt="production",Dt="_frozenDsc";function It(t){const n=ut();if(!n)return{};const e=kt(t),r=Tt(e),o=r.data,s=e.spanContext().traceState,i=s?.get("sentry.sample_rate")??o[ft];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&&vt(a);if(f)return c(f);const h=function(t,n){const e=n.getOptions(),{publicKey:r}=n.getDsn()||{},o={environment:e.environment||jt,release:e.release,public_key:r,trace_id:t};return n.emit("createDsc",o),o}(t.spanContext().traceId,n),p=o[at],l=r.description;return"url"!==p&&l&&(h.transaction=l),function(t){if("boolean"==typeof __SENTRY_TRACING__&&!__SENTRY_TRACING__)return!1;const n=t||ut()?.getOptions();return!(!n||null==n.tracesSampleRate&&!n.tracesSampler)}()&&(h.sampled=String(function(t){const{traceFlags:n}=t.spanContext();return n===St}(e)),h.sample_rand=s?.get("sentry.sample_rand")??yt(e).scope?.getPropagationContext().sampleRand.toString()),c(h),n.emit("createDsc",h,e),h}function Ot(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 At(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 I(t)&&"nativeEvent"in t&&"preventDefault"in t&&"stopPropagation"in t}(n))return"[SyntheticEvent]";if("number"==typeof n&&!Number.isFinite(n))return`[${n}]`;if("function"==typeof n)return`[Function: ${function(t){try{return t&&"function"==typeof t&&t.name||N}catch(t){return N}}(n)}]`;if("symbol"==typeof n)return`[${String(n)}]`;if("bigint"==typeof n)return`[BigInt: ${String(n)}]`;const r=function(t){const n=Object.getPrototypeOf(t);return n?.constructor?n.constructor.name:"null prototype"}(n);return/^HTML(\w*)Element$/.test(r)?`[HTMLElement: ${r}]`:`[object ${r}]`}catch(t){return`**non-serializable** (${t})`}var e}(t,n);if(!c.startsWith("[object "))return c;if(n.__sentry_skip_normalization__)return n;const u="number"==typeof n.__sentry_override_normalization_depth__?n.__sentry_override_normalization_depth__:e;if(0===u)return c.replace("object ","");if(s(n))return"[Circular ~]";const a=n;if(a&&"function"==typeof a.toJSON)try{return Pt("",a.toJSON(),u-1,r,o)}catch(t){}const f=Array.isArray(n)?[]:{};let h=0;const p=B(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=g(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(At(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",otel_log:"log_item"};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:Ot(r)},...o&&{trace:o}}}(t,o,r,n);delete t.sdkProcessingMetadata;return Mt(i,[[{type:s},t]])}const Ht="__SENTRY_SUPPRESS_TRACING__";function Ft(t){const n=ct(m());return n.suppressTracing?n.suppressTracing(t):function(...t){const n=ct(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 Wt(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;Object.keys(e).length&&(t.extra={...e,...t.extra});Object.keys(r).length&&(t.tags={...r,...t.tags});Object.keys(o).length&&(t.user={...o,...t.user});Object.keys(s).length&&(t.contexts={...s,...t.contexts});i&&(t.level=i);c&&"transaction"!==t.type&&(t.transaction=c)}(t,n),r&&function(t,n){t.contexts={trace:$t(n),...t.contexts},t.sdkProcessingMetadata={dynamicSamplingContext:It(n),...t.sdkProcessingMetadata};const e=kt(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";const Vt=Symbol.for("SentryBufferFullError");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=Vt,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=>{H(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 H({});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(),h&&w.error("Encountered error running transport request:",t),t})))).then((t=>t),(t=>{if(t===Vt)return h&&w.error("Skipped sending event because buffer is full."),i(),H({});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=n;let gn,yn=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)=>{Ft((()=>{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)}`)});async function En(){if(gn){_n("Sending abnormal session"),K(gn,{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:Ot(n)}},["aggregates"in t?[{type:"sessions"},t]:[{type:"session"},t.toJSON()]])}(gn,mn.dsn,mn.sdkMetadata,mn.tunnel);_n(JSON.stringify(t)),await $n.send(t);try{e?.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(yn>=mn.maxAnrEvents)return;yn+=1,await En(),_n("Sending event");const e={event_id:Y(),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(Wt(t,n),!t.contexts?.trace){const{traceId:e,parentSpanId:r,propagationSpanId:o}=n.propagationContext;t.contexts={trace:{trace_id:e,span_id:o||Z(),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),yn>=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{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.")})))}));e?.on("message",(t=>{t.session&&(gn=W(t.session)),t.debugImages&&(bn=t.debugImages),Cn()}));
|
|
1
|
+
/*! @sentry/node 9.14.0 (0b63710) | https://github.com/getsentry/sentry-javascript */
|
|
2
|
+
import{Session as t}from"node:inspector";import{workerData as n,parentPort as e}from"node:worker_threads";import{posix as r,sep as o}from"node:path";import*as s from"node:http";import*as i from"node:https";import{Readable as c}from"node:stream";import{createGzip as u}from"node:zlib";import*as a from"node:net";import*as f from"node:tls";const h="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,p=globalThis,l="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,d="9.14.0";function m(){return g(p),p}function g(t){const n=t.__SENTRY__=t.__SENTRY__||{};return n.version=n.version||d,n[d]=n[d]||{}}function y(t,n,e=p){const r=e.__SENTRY__=e.__SENTRY__||{},o=r[d]=r[d]||{};return o[t]||(o[t]=n())}const b=["debug","info","warn","error","log","assert","trace"],_={};function v(t){if(!("console"in p))return t();const n=p.console,e={},r=Object.keys(_);r.forEach((t=>{const r=_[t];e[t]=n[t],n[t]=r}));try{return t()}finally{r.forEach((t=>{n[t]=e[t]}))}}const w=y("logger",(function(){let t=!1;const n={enable:()=>{t=!0},disable:()=>{t=!1},isEnabled:()=>t};return l?b.forEach((e=>{n[e]=(...n)=>{t&&v((()=>{p.console[e](`Sentry Logger [${e}]:`,...n)}))}})):b.forEach((t=>{n[t]=()=>{}})),n})),S=50,$="?",E=/captureMessage|captureException/;function x(t){return t[t.length-1]||{}}const N="<anonymous>";const T=Object.prototype.toString;function C(t,n){return T.call(t)===`[object ${n}]`}function R(t){return C(t,"String")}function k(t){return C(t,"Object")}function j(t){return Boolean(t?.then&&"function"==typeof t.then)}function D(t,n){try{return t instanceof n}catch(t){return!1}}const I=p,O=80;function A(t,n){const e=t,r=[];if(!e?.tagName)return"";if(I.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&&R(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,n=0){return"string"!=typeof t||0===n||t.length<=n?t:`${t.slice(0,n)}...`}function U(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,...L(t)};if(n=t,"undefined"!=typeof Event&&D(n,Event)){const n={type:t.type,target:M(t.target),currentTarget:M(t.currentTarget),...L(t)};return"undefined"!=typeof CustomEvent&&D(t,CustomEvent)&&(n.detail=t.detail),n}return t;var n}function M(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||O;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 L(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 B(t=function(){const t=p;return t.crypto||t.msCrypto}()){let n=()=>16*Math.random();try{if(t?.randomUUID)return t.randomUUID().replace(/-/g,"");t?.getRandomValues&&(n=()=>{const n=new Uint8Array(1);return t.getRandomValues(n),n[0]})}catch(t){}return([1e7]+1e3+4e3+8e3+1e11).replace(/[018]/g,(t=>(t^(15&n())>>t/4).toString(16)))}const G=1e3;function J(){return Date.now()/G}const Y=function(){const{performance:t}=p;if(!t?.now)return J;const n=Date.now()-t.now(),e=null==t.timeOrigin?n:t.timeOrigin;return()=>(e+t.now())/G}();function z(t){const n=Y(),e={sid:B(),init:!0,timestamp:n,started:n,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>function(t){return{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&&H(e,t),e}function H(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:B()),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 F(){return B()}function W(){return B().substring(16)}function K(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]=K(r[t],n[t],e-1));return r}const V="_sentrySpan";function Z(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,V,n):delete t[V]}function q(t){return t[V]}class Q{constructor(){this.t=!1,this.o=[],this.i=[],this.u=[],this.h=[],this.p={},this.l={},this.m={},this._={},this.v={},this.S={traceId:F(),sampleRand:Math.random()}}clone(){const t=new Q;return t.u=[...this.u],t.l={...this.l},t.m={...this.m},t._={...this._},this._.flags&&(t._.flags={values:[...this._.flags.values]}),t.p=this.p,t.N=this.N,t.T=this.T,t.C=this.C,t.R=this.R,t.i=[...this.i],t.h=[...this.h],t.v={...this.v},t.S={...this.S},t.k=this.k,t.j=this.j,Z(t,q(this)),t}setClient(t){this.k=t}setLastEventId(t){this.j=t}getClient(){return this.k}lastEventId(){return this.j}addScopeListener(t){this.o.push(t)}addEventProcessor(t){return this.i.push(t),this}setUser(t){return this.p=t||{email:void 0,id:void 0,ip_address:void 0,username:void 0},this.T&&H(this.T,{user:t}),this.D(),this}getUser(){return this.p}setTags(t){return this.l={...this.l,...t},this.D(),this}setTag(t,n){return this.l={...this.l,[t]:n},this.D(),this}setExtras(t){return this.m={...this.m,...t},this.D(),this}setExtra(t,n){return this.m={...this.m,[t]:n},this.D(),this}setFingerprint(t){return this.R=t,this.D(),this}setLevel(t){return this.N=t,this.D(),this}setTransactionName(t){return this.C=t,this.D(),this}setContext(t,n){return null===n?delete this._[t]:this._[t]=n,this.D(),this}setSession(t){return t?this.T=t:delete this.T,this.D(),this}getSession(){return this.T}update(t){if(!t)return this;const n="function"==typeof t?t(this):t,e=n instanceof Q?n.getScopeData():k(n)?t:void 0,{tags:r,extra:o,user:s,contexts:i,level:c,fingerprint:u=[],propagationContext:a}=e||{};return this.l={...this.l,...r},this.m={...this.m,...o},this._={...this._,...i},s&&Object.keys(s).length&&(this.p=s),c&&(this.N=c),u.length&&(this.R=u),a&&(this.S=a),this}clear(){return this.u=[],this.l={},this.m={},this.p={},this._={},this.N=void 0,this.C=void 0,this.R=void 0,this.T=void 0,Z(this,void 0),this.h=[],this.setPropagationContext({traceId:F(),sampleRand:Math.random()}),this.D(),this}addBreadcrumb(t,n){const e="number"==typeof n?n:100;if(e<=0)return this;const r={timestamp:J(),...t,message:t.message?P(t.message,2048):t.message};return this.u.push(r),this.u.length>e&&(this.u=this.u.slice(-e),this.k?.recordDroppedEvent("buffer_overflow","log_item")),this.D(),this}getLastBreadcrumb(){return this.u[this.u.length-1]}clearBreadcrumbs(){return this.u=[],this.D(),this}addAttachment(t){return this.h.push(t),this}clearAttachments(){return this.h=[],this}getScopeData(){return{breadcrumbs:this.u,attachments:this.h,contexts:this._,tags:this.l,extra:this.m,user:this.p,level:this.N,fingerprint:this.R||[],eventProcessors:this.i,propagationContext:this.S,sdkProcessingMetadata:this.v,transactionName:this.C,span:q(this)}}setSDKProcessingMetadata(t){return this.v=K(this.v,t,2),this}setPropagationContext(t){return this.S=t,this}getPropagationContext(){return this.S}captureException(t,n){const e=n?.event_id||B();if(!this.k)return w.warn("No client configured on scope - will not capture exception!"),e;const r=new Error("Sentry syntheticException");return this.k.captureException(t,{originalException:t,syntheticException:r,...n,event_id:e},this),e}captureMessage(t,n,e){const r=e?.event_id||B();if(!this.k)return w.warn("No client configured on scope - will not capture message!"),r;const o=new Error(t);return this.k.captureMessage(t,n,{originalException:t,syntheticException:o,...e,event_id:r},this),r}captureEvent(t,n){const e=n?.event_id||B();return this.k?(this.k.captureEvent(t,{...n,event_id:e},this),e):(w.warn("No client configured on scope - will not capture event!"),e)}D(){this.t||(this.t=!0,this.o.forEach((t=>{t(this)})),this.t=!1)}}class X{constructor(t,n){let e,r;e=t||new Q,r=n||new Q,this.I=[{scope:e}],this.O=r}withScope(t){const n=this.A();let e;try{e=t(n)}catch(t){throw this.P(),t}return j(e)?e.then((t=>(this.P(),t)),(t=>{throw this.P(),t})):(this.P(),e)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this.O}getStackTop(){return this.I[this.I.length-1]}A(){const t=this.getScope().clone();return this.I.push({client:this.getClient(),scope:t}),t}P(){return!(this.I.length<=1)&&!!this.I.pop()}}function tt(){const t=g(m());return t.stack=t.stack||new X(y("defaultCurrentScope",(()=>new Q)),y("defaultIsolationScope",(()=>new Q)))}function nt(t){return tt().withScope(t)}function et(t,n){const e=tt();return e.withScope((()=>(e.getStackTop().scope=t,n(t))))}function rt(t){return tt().withScope((()=>t(tt().getIsolationScope())))}function ot(t){const n=g(t);return n.acs?n.acs:{withIsolationScope:rt,withScope:nt,withSetScope:et,withSetIsolationScope:(t,n)=>rt(n),getCurrentScope:()=>tt().getScope(),getIsolationScope:()=>tt().getIsolationScope()}}function st(){return ot(m()).getCurrentScope().getClient()}const it="sentry.source",ct="sentry.sample_rate",ut="sentry.op",at="sentry.origin",ft=0,ht=1,pt="_sentryScope",lt="_sentryIsolationScope";function dt(t){return{scope:t[pt],isolationScope:t[lt]}}const mt="sentry-",gt=/^sentry-/;function yt(t){const n=function(t){if(!t||!R(t)&&!Array.isArray(t))return;if(Array.isArray(t))return t.reduce(((t,n)=>{const e=bt(n);return Object.entries(e).forEach((([n,e])=>{t[n]=e})),t}),{});return bt(t)}(t);if(!n)return;const e=Object.entries(n).reduce(((t,[n,e])=>{if(n.match(gt)){t[n.slice(mt.length)]=e}return t}),{});return Object.keys(e).length>0?e:void 0}function bt(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 vt(t){const{spanId:n,traceId:e,isRemote:r}=t.spanContext(),o=r?n:Et(t).parent_span_id,s=dt(t).scope;return{parent_span_id:o,span_id:r?s?.getPropagationContext().propagationSpanId||W():n,trace_id:e}}function wt(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 St(t){return"number"==typeof t?$t(t):Array.isArray(t)?t[0]+t[1]/1e9:t instanceof Date?$t(t.getTime()):Y()}function $t(t){return t>9999999999?t/1e3:t}function Et(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{span_id:n,trace_id:e,data:r,description:s,parent_span_id:c,start_timestamp:St(o),timestamp:St(i)||void 0,status:xt(u),op:r[ut],origin:r[at],links:wt(a)}}return{span_id:n,trace_id:e,start_timestamp:0,data:{}}}function xt(t){if(t&&t.code!==ft)return t.code===ht?"ok":t.message||"unknown_error"}const Nt="_sentryRootSpan";function Tt(t){return t[Nt]||t}const Ct="production",Rt="_frozenDsc";function kt(t){const n=st();if(!n)return{};const e=Tt(t),r=Et(e),o=r.data,s=e.spanContext().traceState,i=s?.get("sentry.sample_rate")??o[ct];function c(t){return"number"!=typeof i&&"string"!=typeof i||(t.sample_rate=`${i}`),t}const u=e[Rt];if(u)return c(u);const a=s?.get("sentry.dsc"),f=a&&yt(a);if(f)return c(f);const h=function(t,n){const e=n.getOptions(),{publicKey:r}=n.getDsn()||{},o={environment:e.environment||Ct,release:e.release,public_key:r,trace_id:t};return n.emit("createDsc",o),o}(t.spanContext().traceId,n),p=o[it],l=r.description;return"url"!==p&&l&&(h.transaction=l),function(t){if("boolean"==typeof __SENTRY_TRACING__&&!__SENTRY_TRACING__)return!1;const n=t||st()?.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")??dt(e).scope?.getPropagationContext().sampleRand.toString()),c(h),n.emit("createDsc",h,e),h}function jt(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 Dt(t,n=100,e=1/0){try{return It("",t,n,e)}catch(t){return{ERROR:`**non-serializable** (${t})`}}}function It(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.U)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.M))return"[VueViewModel]";if(function(t){return k(t)&&"nativeEvent"in t&&"preventDefault"in t&&"stopPropagation"in t}(n))return"[SyntheticEvent]";if("number"==typeof n&&!Number.isFinite(n))return`[${n}]`;if("function"==typeof n)return`[Function: ${function(t){try{return t&&"function"==typeof t&&t.name||N}catch(t){return N}}(n)}]`;if("symbol"==typeof n)return`[${String(n)}]`;if("bigint"==typeof n)return`[BigInt: ${String(n)}]`;const r=function(t){const n=Object.getPrototypeOf(t);return n?.constructor?n.constructor.name:"null prototype"}(n);return/^HTML(\w*)Element$/.test(r)?`[HTMLElement: ${r}]`:`[object ${r}]`}catch(t){return`**non-serializable** (${t})`}var e}(t,n);if(!c.startsWith("[object "))return c;if(n.__sentry_skip_normalization__)return n;const u="number"==typeof n.__sentry_override_normalization_depth__?n.__sentry_override_normalization_depth__:e;if(0===u)return c.replace("object ","");if(s(n))return"[Circular ~]";const a=n;if(a&&"function"==typeof a.toJSON)try{return It("",a.toJSON(),u-1,r,o)}catch(t){}const f=Array.isArray(n)?[]:{};let h=0;const p=U(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]=It(t,n,u-1,r,o),h++}return i(n),f}function Ot(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 At(t,n=[]){return[t,n]}function Pt(t,n){const e=t[1];for(const t of e){if(n(t,t[0].type))return!0}return!1}function Ut(t){const n=g(p);return n.encodePolyfill?n.encodePolyfill(t):(new TextEncoder).encode(t)}function Mt(t){const[n,e]=t;let r=JSON.stringify(n);function o(t){"string"==typeof r?r="string"==typeof t?r+t:[Ut(r),t]:r.push("string"==typeof t?Ut(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(Dt(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 Lt={session:"session",sessions:"session",attachment:"attachment",transaction:"transaction",event:"error",client_report:"internal",user_report:"default",profile:"profile",profile_chunk:"profile",replay_event:"replay",replay_recording:"replay",check_in:"monitor",feedback:"feedback",span:"span",raw_security:"security",otel_log:"log_item"};function Bt(t){if(!t?.sdk)return;const{name:n,version:e}=t.sdk;return{name:n,version:e}}function Gt(t,n,e,r){const o=Bt(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:jt(r)},...o&&{trace:o}}}(t,o,r,n);delete t.sdkProcessingMetadata;return At(i,[[{type:s},t]])}const Jt="__SENTRY_SUPPRESS_TRACING__";function Yt(t){const n=ot(m());return n.suppressTracing?n.suppressTracing(t):function(...t){const n=ot(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({[Jt]:!0}),t())))}var zt;function Ht(t){return new Ft((n=>{n(t)}))}!function(t){t[t.PENDING=0]="PENDING";t[t.RESOLVED=1]="RESOLVED";t[t.REJECTED=2]="REJECTED"}(zt||(zt={}));class Ft{constructor(t){this.L=zt.PENDING,this.B=[],this.G(t)}then(t,n){return new Ft(((e,r)=>{this.B.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.J()}))}catch(t){return this.then((t=>t),t)}finally(t){return new Ft(((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)}))}))}J(){if(this.L===zt.PENDING)return;const t=this.B.slice();this.B=[],t.forEach((t=>{t[0]||(this.L===zt.RESOLVED&&t[1](this.Y),this.L===zt.REJECTED&&t[2](this.Y),t[0]=!0)}))}G(t){const n=(t,n)=>{this.L===zt.PENDING&&(j(n)?n.then(e,r):(this.L=t,this.Y=n,this.J()))},e=t=>{n(zt.RESOLVED,t)},r=t=>{n(zt.REJECTED,t)};try{t(e,r)}catch(t){r(t)}}}function Wt(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;Object.keys(e).length&&(t.extra={...e,...t.extra});Object.keys(r).length&&(t.tags={...r,...t.tags});Object.keys(o).length&&(t.user={...o,...t.user});Object.keys(s).length&&(t.contexts={...s,...t.contexts});i&&(t.level=i);c&&"transaction"!==t.type&&(t.transaction=c)}(t,n),r&&function(t,n){t.contexts={trace:vt(n),...t.contexts},t.sdkProcessingMetadata={dynamicSamplingContext:kt(n),...t.sdkProcessingMetadata};const e=Tt(n),r=Et(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";const Vt=Symbol.for("SentryBufferFullError");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=Vt,new Ft(((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 Ft(((e,r)=>{let o=n.length;if(!o)return e(!0);const s=setTimeout((()=>{t&&t>0&&e(!1)}),t);n.forEach((t=>{Ht(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(Pt(t,((t,n)=>{const e=function(t){return Lt[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 Ht({});const s=At(t[0],o),i=t=>{Pt(s,((t,n)=>{}))};return e.add((()=>n({body:Mt(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(),h&&w.error("Encountered error running transport request:",t),t})))).then((t=>t),(t=>{if(t===Vt)return h&&w.error("Skipped sending event because buffer is full."),i(),Ht({});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=n;let gn,yn=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)=>{Yt((()=>{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)}`)});async function En(){if(gn){_n("Sending abnormal session"),H(gn,{status:"abnormal",abnormal_mechanism:"anr_foreground",release:mn.release,environment:mn.environment});const t=function(t,n,e,r){const o=Bt(e);return At({sent_at:(new Date).toISOString(),...o&&{sdk:o},...!!r&&n&&{dsn:jt(n)}},["aggregates"in t?[{type:"sessions"},t]:[{type:"session"},t.toJSON()]])}(gn,mn.dsn,mn.sdkMetadata,mn.tunnel);_n(JSON.stringify(t)),await $n.send(t);try{e?.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=Ot(t.filename,mn.appRootPath));return n}async function Nn(t,n){if(yn>=mn.maxAnrEvents)return;yn+=1,await En(),_n("Sending event");const e={event_id:B(),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(Wt(t,n),!t.contexts?.trace){const{traceId:e,parentSpanId:r,propagationSpanId:o}=n.propagationContext;t.contexts={trace:{trace_id:e,span_id:o||W(),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[Ot(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=Gt(e,mn.dsn,mn.sdkMetadata,mn.tunnel);_n(JSON.stringify(r)),await $n.send(r),await $n.flush(2e3),yn>=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{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.")})))}));e?.on("message",(t=>{t.session&&(gn=z(t.session)),t.debugImages&&(bn=t.debugImages),Cn()}));
|
|
@@ -9,6 +9,8 @@ import { getRequestInfo } from './vendor/getRequestInfo.js';
|
|
|
9
9
|
|
|
10
10
|
/* eslint-disable max-lines */
|
|
11
11
|
|
|
12
|
+
const INSTRUMENTATION_NAME = '@sentry/instrumentation-http';
|
|
13
|
+
|
|
12
14
|
// We only want to capture request bodies up to 1mb.
|
|
13
15
|
const MAX_BODY_BYTE_LENGTH = 1024 * 1024;
|
|
14
16
|
|
|
@@ -27,7 +29,7 @@ const MAX_BODY_BYTE_LENGTH = 1024 * 1024;
|
|
|
27
29
|
*/
|
|
28
30
|
class SentryHttpInstrumentation extends InstrumentationBase {
|
|
29
31
|
constructor(config = {}) {
|
|
30
|
-
super(
|
|
32
|
+
super(INSTRUMENTATION_NAME, VERSION, config);
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
/** @inheritdoc */
|
|
@@ -283,12 +285,9 @@ function getBreadcrumbData(request) {
|
|
|
283
285
|
* This way, we only read the body if the user also consumes the body, ensuring we do not change any behavior in unexpected ways.
|
|
284
286
|
*/
|
|
285
287
|
function patchRequestToCaptureBody(req, isolationScope) {
|
|
288
|
+
let bodyByteLength = 0;
|
|
286
289
|
const chunks = [];
|
|
287
290
|
|
|
288
|
-
function getChunksSize() {
|
|
289
|
-
return chunks.reduce((acc, chunk) => acc + chunk.byteLength, 0);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
291
|
/**
|
|
293
292
|
* We need to keep track of the original callbacks, in order to be able to remove listeners again.
|
|
294
293
|
* Since `off` depends on having the exact same function reference passed in, we need to be able to map
|
|
@@ -302,41 +301,28 @@ function patchRequestToCaptureBody(req, isolationScope) {
|
|
|
302
301
|
apply: (target, thisArg, args) => {
|
|
303
302
|
const [event, listener, ...restArgs] = args;
|
|
304
303
|
|
|
305
|
-
if (
|
|
306
|
-
|
|
307
|
-
apply: (target, thisArg, args) => {
|
|
308
|
-
// If we have already read more than the max body length, we stop adding chunks
|
|
309
|
-
// To avoid growing the memory indefinitely if a response is e.g. streamed
|
|
310
|
-
if (getChunksSize() < MAX_BODY_BYTE_LENGTH) {
|
|
311
|
-
const chunk = args[0] ;
|
|
312
|
-
chunks.push(chunk);
|
|
313
|
-
} else if (DEBUG_BUILD) {
|
|
314
|
-
logger.log(
|
|
315
|
-
`Dropping request body chunk because it maximum body length of ${MAX_BODY_BYTE_LENGTH}b is exceeded.`,
|
|
316
|
-
);
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
return Reflect.apply(target, thisArg, args);
|
|
320
|
-
},
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
callbackMap.set(listener, callback);
|
|
324
|
-
|
|
325
|
-
return Reflect.apply(target, thisArg, [event, callback, ...restArgs]);
|
|
304
|
+
if (DEBUG_BUILD) {
|
|
305
|
+
logger.log(INSTRUMENTATION_NAME, 'Patching request.on', event);
|
|
326
306
|
}
|
|
327
307
|
|
|
328
|
-
if (event === '
|
|
308
|
+
if (event === 'data') {
|
|
329
309
|
const callback = new Proxy(listener, {
|
|
330
310
|
apply: (target, thisArg, args) => {
|
|
331
311
|
try {
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
312
|
+
const chunk = args[0] ;
|
|
313
|
+
const bufferifiedChunk = Buffer.from(chunk);
|
|
314
|
+
|
|
315
|
+
if (bodyByteLength < MAX_BODY_BYTE_LENGTH) {
|
|
316
|
+
chunks.push(bufferifiedChunk);
|
|
317
|
+
bodyByteLength += bufferifiedChunk.byteLength;
|
|
318
|
+
} else if (DEBUG_BUILD) {
|
|
319
|
+
logger.log(
|
|
320
|
+
INSTRUMENTATION_NAME,
|
|
321
|
+
`Dropping request body chunk because maximum body length of ${MAX_BODY_BYTE_LENGTH}b is exceeded.`,
|
|
322
|
+
);
|
|
337
323
|
}
|
|
338
|
-
} catch {
|
|
339
|
-
|
|
324
|
+
} catch (err) {
|
|
325
|
+
DEBUG_BUILD && logger.error(INSTRUMENTATION_NAME, 'Encountered error while storing body chunk.');
|
|
340
326
|
}
|
|
341
327
|
|
|
342
328
|
return Reflect.apply(target, thisArg, args);
|
|
@@ -370,8 +356,23 @@ function patchRequestToCaptureBody(req, isolationScope) {
|
|
|
370
356
|
return Reflect.apply(target, thisArg, args);
|
|
371
357
|
},
|
|
372
358
|
});
|
|
373
|
-
|
|
374
|
-
|
|
359
|
+
|
|
360
|
+
req.on('end', () => {
|
|
361
|
+
try {
|
|
362
|
+
const body = Buffer.concat(chunks).toString('utf-8');
|
|
363
|
+
if (body) {
|
|
364
|
+
isolationScope.setSDKProcessingMetadata({ normalizedRequest: { data: body } });
|
|
365
|
+
}
|
|
366
|
+
} catch (error) {
|
|
367
|
+
if (DEBUG_BUILD) {
|
|
368
|
+
logger.error(INSTRUMENTATION_NAME, 'Error building captured request body', error);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
} catch (error) {
|
|
373
|
+
if (DEBUG_BUILD) {
|
|
374
|
+
logger.error(INSTRUMENTATION_NAME, 'Error patching request to capture body', error);
|
|
375
|
+
}
|
|
375
376
|
}
|
|
376
377
|
}
|
|
377
378
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SentryHttpInstrumentation.js","sources":["../../../../src/integrations/http/SentryHttpInstrumentation.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport { context, propagation } from '@opentelemetry/api';\nimport { VERSION } from '@opentelemetry/core';\nimport type { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';\nimport type { AggregationCounts, Client, RequestEventData, SanitizedRequestData, Scope } from '@sentry/core';\nimport {\n addBreadcrumb,\n generateSpanId,\n getBreadcrumbLogLevelFromHttpStatusCode,\n getClient,\n getCurrentScope,\n getIsolationScope,\n getSanitizedUrlString,\n httpRequestToRequestData,\n logger,\n parseUrl,\n stripUrlQueryAndFragment,\n withIsolationScope,\n} from '@sentry/core';\nimport type * as http from 'node:http';\nimport type { IncomingMessage, RequestOptions } from 'node:http';\nimport type * as https from 'node:https';\nimport type { EventEmitter } from 'node:stream';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { getRequestUrl } from '../../utils/getRequestUrl';\nimport { stealthWrap } from './utils';\nimport { getRequestInfo } from './vendor/getRequestInfo';\n\ntype Http = typeof http;\ntype Https = typeof https;\n\nexport type SentryHttpInstrumentationOptions = InstrumentationConfig & {\n /**\n * Whether breadcrumbs should be recorded for requests.\n *\n * @default `true`\n */\n breadcrumbs?: boolean;\n\n /**\n * Whether to extract the trace ID from the `sentry-trace` header for incoming requests.\n * By default this is done by the HttpInstrumentation, but if that is not added (e.g. because tracing is disabled, ...)\n * then this instrumentation can take over.\n *\n * @default `false`\n */\n extractIncomingTraceFromHeader?: boolean;\n\n /**\n * Do not capture breadcrumbs for outgoing HTTP requests to URLs where the given callback returns `true`.\n * For the scope of this instrumentation, this callback only controls breadcrumb creation.\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 * @param request Contains the {@type RequestOptions} object used to make the outgoing request.\n */\n ignoreOutgoingRequests?: (url: string, request: RequestOptions) => boolean;\n\n /**\n * Do not capture the request body for incoming HTTP requests to URLs where the given callback returns `true`.\n * This can be useful for long running requests where the body is not needed and we want to avoid capturing it.\n *\n * @param url Contains the entire URL, including query string (if any), protocol, host, etc. of the outgoing request.\n * @param request Contains the {@type RequestOptions} object used to make the outgoing request.\n */\n ignoreIncomingRequestBody?: (url: string, request: RequestOptions) => boolean;\n\n /**\n * Whether the integration should create [Sessions](https://docs.sentry.io/product/releases/health/#sessions) for incoming requests to track the health and crash-free rate of your releases in Sentry.\n * Read more about Release Health: https://docs.sentry.io/product/releases/health/\n *\n * Defaults to `true`.\n */\n trackIncomingRequestsAsSessions?: boolean;\n\n /**\n * Number of milliseconds until sessions tracked with `trackIncomingRequestsAsSessions` will be flushed as a session aggregate.\n *\n * Defaults to `60000` (60s).\n */\n sessionFlushingDelayMS?: number;\n};\n\n// We only want to capture request bodies up to 1mb.\nconst MAX_BODY_BYTE_LENGTH = 1024 * 1024;\n\n/**\n * This custom HTTP instrumentation is used to isolate incoming requests and annotate them with additional information.\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 * Important note: Contrary to other OTEL instrumentation, this one cannot be unwrapped.\n * It only does minimal things though and does not emit any spans.\n *\n * This is heavily inspired & adapted from:\n * https://github.com/open-telemetry/opentelemetry-js/blob/f8ab5592ddea5cba0a3b33bf8d74f27872c0367f/experimental/packages/opentelemetry-instrumentation-http/src/http.ts\n */\nexport class SentryHttpInstrumentation extends InstrumentationBase<SentryHttpInstrumentationOptions> {\n public constructor(config: SentryHttpInstrumentationOptions = {}) {\n super('@sentry/instrumentation-http', VERSION, config);\n }\n\n /** @inheritdoc */\n public init(): [InstrumentationNodeModuleDefinition, InstrumentationNodeModuleDefinition] {\n return [this._getHttpsInstrumentation(), this._getHttpInstrumentation()];\n }\n\n /** Get the instrumentation for the http module. */\n private _getHttpInstrumentation(): InstrumentationNodeModuleDefinition {\n return new InstrumentationNodeModuleDefinition(\n 'http',\n ['*'],\n (moduleExports: Http): Http => {\n // Patch incoming requests for request isolation\n stealthWrap(moduleExports.Server.prototype, 'emit', this._getPatchIncomingRequestFunction());\n\n // Patch outgoing requests for breadcrumbs\n const patchedRequest = stealthWrap(moduleExports, 'request', this._getPatchOutgoingRequestFunction());\n stealthWrap(moduleExports, 'get', this._getPatchOutgoingGetFunction(patchedRequest));\n\n return moduleExports;\n },\n () => {\n // no unwrap here\n },\n );\n }\n\n /** Get the instrumentation for the https module. */\n private _getHttpsInstrumentation(): InstrumentationNodeModuleDefinition {\n return new InstrumentationNodeModuleDefinition(\n 'https',\n ['*'],\n (moduleExports: Https): Https => {\n // Patch incoming requests for request isolation\n stealthWrap(moduleExports.Server.prototype, 'emit', this._getPatchIncomingRequestFunction());\n\n // Patch outgoing requests for breadcrumbs\n const patchedRequest = stealthWrap(moduleExports, 'request', this._getPatchOutgoingRequestFunction());\n stealthWrap(moduleExports, 'get', this._getPatchOutgoingGetFunction(patchedRequest));\n\n return moduleExports;\n },\n () => {\n // no unwrap here\n },\n );\n }\n\n /**\n * Patch the incoming request function for request isolation.\n */\n private _getPatchIncomingRequestFunction(): (\n original: (event: string, ...args: unknown[]) => boolean,\n ) => (this: unknown, event: string, ...args: unknown[]) => boolean {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const instrumentation = this;\n const { ignoreIncomingRequestBody } = instrumentation.getConfig();\n\n return (\n original: (event: string, ...args: unknown[]) => boolean,\n ): ((this: unknown, event: string, ...args: unknown[]) => boolean) => {\n return function incomingRequest(this: unknown, ...args: [event: string, ...args: unknown[]]): boolean {\n // Only traces request events\n if (args[0] !== 'request') {\n return original.apply(this, args);\n }\n\n instrumentation._diag.debug('http instrumentation for incoming request');\n\n const isolationScope = getIsolationScope().clone();\n const request = args[1] as http.IncomingMessage;\n const response = args[2] as http.OutgoingMessage;\n\n const normalizedRequest = httpRequestToRequestData(request);\n\n // request.ip is non-standard but some frameworks set this\n const ipAddress = (request as { ip?: string }).ip || request.socket?.remoteAddress;\n\n const url = request.url || '/';\n if (!ignoreIncomingRequestBody?.(url, request)) {\n patchRequestToCaptureBody(request, isolationScope);\n }\n\n // Update the isolation scope, isolate this request\n isolationScope.setSDKProcessingMetadata({ normalizedRequest, ipAddress });\n\n // attempt to update the scope's `transactionName` based on the request URL\n // Ideally, framework instrumentations coming after the HttpInstrumentation\n // update the transactionName once we get a parameterized route.\n const httpMethod = (request.method || 'GET').toUpperCase();\n const httpTarget = stripUrlQueryAndFragment(url);\n\n const bestEffortTransactionName = `${httpMethod} ${httpTarget}`;\n\n isolationScope.setTransactionName(bestEffortTransactionName);\n\n if (instrumentation.getConfig().trackIncomingRequestsAsSessions !== false) {\n recordRequestSession({\n requestIsolationScope: isolationScope,\n response,\n sessionFlushingDelayMS: instrumentation.getConfig().sessionFlushingDelayMS ?? 60_000,\n });\n }\n\n return withIsolationScope(isolationScope, () => {\n // Set a new propagationSpanId for this request\n // We rely on the fact that `withIsolationScope()` will implicitly also fork the current scope\n // This way we can save an \"unnecessary\" `withScope()` invocation\n getCurrentScope().getPropagationContext().propagationSpanId = generateSpanId();\n\n // If we don't want to extract the trace from the header, we can skip this\n if (!instrumentation.getConfig().extractIncomingTraceFromHeader) {\n return original.apply(this, args);\n }\n\n const ctx = propagation.extract(context.active(), normalizedRequest.headers);\n return context.with(ctx, () => {\n return original.apply(this, args);\n });\n });\n };\n };\n }\n\n /**\n * Patch the outgoing request function for breadcrumbs.\n */\n private _getPatchOutgoingRequestFunction(): (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n original: (...args: any[]) => http.ClientRequest,\n ) => (options: URL | http.RequestOptions | string, ...args: unknown[]) => http.ClientRequest {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const instrumentation = this;\n\n return (original: (...args: unknown[]) => http.ClientRequest): ((...args: unknown[]) => http.ClientRequest) => {\n return function outgoingRequest(this: unknown, ...args: unknown[]): http.ClientRequest {\n instrumentation._diag.debug('http instrumentation for outgoing requests');\n\n // Making a copy to avoid mutating the original args array\n // We need to access and reconstruct the request options object passed to `ignoreOutgoingRequests`\n // so that it matches what Otel instrumentation passes to `ignoreOutgoingRequestHook`.\n // @see https://github.com/open-telemetry/opentelemetry-js/blob/7293e69c1e55ca62e15d0724d22605e61bd58952/experimental/packages/opentelemetry-instrumentation-http/src/http.ts#L756-L789\n const argsCopy = [...args];\n\n const options = argsCopy.shift() as URL | http.RequestOptions | string;\n\n const extraOptions =\n typeof argsCopy[0] === 'object' && (typeof options === 'string' || options instanceof URL)\n ? (argsCopy.shift() as http.RequestOptions)\n : undefined;\n\n const { optionsParsed } = getRequestInfo(instrumentation._diag, options, extraOptions);\n\n const request = original.apply(this, args) as ReturnType<typeof http.request>;\n\n request.prependListener('response', (response: http.IncomingMessage) => {\n const _breadcrumbs = instrumentation.getConfig().breadcrumbs;\n const breadCrumbsEnabled = typeof _breadcrumbs === 'undefined' ? true : _breadcrumbs;\n\n const _ignoreOutgoingRequests = instrumentation.getConfig().ignoreOutgoingRequests;\n const shouldCreateBreadcrumb =\n typeof _ignoreOutgoingRequests === 'function'\n ? !_ignoreOutgoingRequests(getRequestUrl(request), optionsParsed)\n : true;\n\n if (breadCrumbsEnabled && shouldCreateBreadcrumb) {\n addRequestBreadcrumb(request, response);\n }\n });\n\n return request;\n };\n };\n }\n\n /** Path the outgoing get function for breadcrumbs. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private _getPatchOutgoingGetFunction(clientRequest: (...args: any[]) => http.ClientRequest) {\n return (_original: unknown): ((...args: unknown[]) => http.ClientRequest) => {\n // Re-implement http.get. This needs to be done (instead of using\n // getPatchOutgoingRequestFunction to patch it) because we need to\n // set the trace context header before the returned http.ClientRequest is\n // ended. The Node.js docs state that the only differences between\n // request and get are that (1) get defaults to the HTTP GET method and\n // (2) the returned request object is ended immediately. The former is\n // already true (at least in supported Node versions up to v10), so we\n // simply follow the latter. Ref:\n // https://nodejs.org/dist/latest/docs/api/http.html#http_http_get_options_callback\n // https://github.com/googleapis/cloud-trace-nodejs/blob/master/src/instrumentations/instrumentation-http.ts#L198\n return function outgoingGetRequest(...args: unknown[]): http.ClientRequest {\n const req = clientRequest(...args);\n req.end();\n return req;\n };\n };\n }\n}\n\n/** Add a breadcrumb for outgoing requests. */\nfunction addRequestBreadcrumb(request: http.ClientRequest, response: http.IncomingMessage): 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: http.ClientRequest): Partial<SanitizedRequestData> {\n try {\n // `request.host` does not contain the port, but the host header does\n const host = request.getHeader('host') || request.host;\n const url = new URL(request.path, `${request.protocol}//${host}`);\n const parsedUrl = parseUrl(url.toString());\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\n/**\n * This method patches the request object to capture the body.\n * Instead of actually consuming the streamed body ourselves, which has potential side effects,\n * we monkey patch `req.on('data')` to intercept the body chunks.\n * This way, we only read the body if the user also consumes the body, ensuring we do not change any behavior in unexpected ways.\n */\nfunction patchRequestToCaptureBody(req: IncomingMessage, isolationScope: Scope): void {\n const chunks: Buffer[] = [];\n\n function getChunksSize(): number {\n return chunks.reduce((acc, chunk) => acc + chunk.byteLength, 0);\n }\n\n /**\n * We need to keep track of the original callbacks, in order to be able to remove listeners again.\n * Since `off` depends on having the exact same function reference passed in, we need to be able to map\n * original listeners to our wrapped ones.\n */\n const callbackMap = new WeakMap();\n\n try {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n req.on = new Proxy(req.on, {\n apply: (target, thisArg, args: Parameters<typeof req.on>) => {\n const [event, listener, ...restArgs] = args;\n\n if (event === 'data') {\n const callback = new Proxy(listener, {\n apply: (target, thisArg, args: Parameters<typeof listener>) => {\n // If we have already read more than the max body length, we stop adding chunks\n // To avoid growing the memory indefinitely if a response is e.g. streamed\n if (getChunksSize() < MAX_BODY_BYTE_LENGTH) {\n const chunk = args[0] as Buffer;\n chunks.push(chunk);\n } else if (DEBUG_BUILD) {\n logger.log(\n `Dropping request body chunk because it maximum body length of ${MAX_BODY_BYTE_LENGTH}b is exceeded.`,\n );\n }\n\n return Reflect.apply(target, thisArg, args);\n },\n });\n\n callbackMap.set(listener, callback);\n\n return Reflect.apply(target, thisArg, [event, callback, ...restArgs]);\n }\n\n if (event === 'end') {\n const callback = new Proxy(listener, {\n apply: (target, thisArg, args) => {\n try {\n const body = Buffer.concat(chunks).toString('utf-8');\n\n if (body) {\n const normalizedRequest = { data: body } satisfies RequestEventData;\n isolationScope.setSDKProcessingMetadata({ normalizedRequest });\n }\n } catch {\n // ignore errors here\n }\n\n return Reflect.apply(target, thisArg, args);\n },\n });\n\n callbackMap.set(listener, callback);\n\n return Reflect.apply(target, thisArg, [event, callback, ...restArgs]);\n }\n\n return Reflect.apply(target, thisArg, args);\n },\n });\n\n // Ensure we also remove callbacks correctly\n // eslint-disable-next-line @typescript-eslint/unbound-method\n req.off = new Proxy(req.off, {\n apply: (target, thisArg, args: Parameters<typeof req.off>) => {\n const [, listener] = args;\n\n const callback = callbackMap.get(listener);\n if (callback) {\n callbackMap.delete(listener);\n\n const modifiedArgs = args.slice();\n modifiedArgs[1] = callback;\n return Reflect.apply(target, thisArg, modifiedArgs);\n }\n\n return Reflect.apply(target, thisArg, args);\n },\n });\n } catch {\n // ignore errors if we can't patch stuff\n }\n}\n\n/**\n * Starts a session and tracks it in the context of a given isolation scope.\n * When the passed response is finished, the session is put into a task and is\n * aggregated with other sessions that may happen in a certain time window\n * (sessionFlushingDelayMs).\n *\n * The sessions are always aggregated by the client that is on the current scope\n * at the time of ending the response (if there is one).\n */\n// Exported for unit tests\nexport function recordRequestSession({\n requestIsolationScope,\n response,\n sessionFlushingDelayMS,\n}: {\n requestIsolationScope: Scope;\n response: EventEmitter;\n sessionFlushingDelayMS?: number;\n}): void {\n requestIsolationScope.setSDKProcessingMetadata({\n requestSession: { status: 'ok' },\n });\n response.once('close', () => {\n // We need to grab the client off the current scope instead of the isolation scope because the isolation scope doesn't hold any client out of the box.\n const client = getClient();\n const requestSession = requestIsolationScope.getScopeData().sdkProcessingMetadata.requestSession;\n\n if (client && requestSession) {\n DEBUG_BUILD && logger.debug(`Recorded request session with status: ${requestSession.status}`);\n\n const roundedDate = new Date();\n roundedDate.setSeconds(0, 0);\n const dateBucketKey = roundedDate.toISOString();\n\n const existingClientAggregate = clientToRequestSessionAggregatesMap.get(client);\n const bucket = existingClientAggregate?.[dateBucketKey] || { exited: 0, crashed: 0, errored: 0 };\n bucket[({ ok: 'exited', crashed: 'crashed', errored: 'errored' } as const)[requestSession.status]]++;\n\n if (existingClientAggregate) {\n existingClientAggregate[dateBucketKey] = bucket;\n } else {\n DEBUG_BUILD && logger.debug('Opened new request session aggregate.');\n const newClientAggregate = { [dateBucketKey]: bucket };\n clientToRequestSessionAggregatesMap.set(client, newClientAggregate);\n\n const flushPendingClientAggregates = (): void => {\n clearTimeout(timeout);\n unregisterClientFlushHook();\n clientToRequestSessionAggregatesMap.delete(client);\n\n const aggregatePayload: AggregationCounts[] = Object.entries(newClientAggregate).map(\n ([timestamp, value]) => ({\n started: timestamp,\n exited: value.exited,\n errored: value.errored,\n crashed: value.crashed,\n }),\n );\n client.sendSession({ aggregates: aggregatePayload });\n };\n\n const unregisterClientFlushHook = client.on('flush', () => {\n DEBUG_BUILD && logger.debug('Sending request session aggregate due to client flush');\n flushPendingClientAggregates();\n });\n const timeout = setTimeout(() => {\n DEBUG_BUILD && logger.debug('Sending request session aggregate due to flushing schedule');\n flushPendingClientAggregates();\n }, sessionFlushingDelayMS).unref();\n }\n }\n });\n}\n\nconst clientToRequestSessionAggregatesMap = new Map<\n Client,\n { [timestampRoundedToSeconds: string]: { exited: number; crashed: number; errored: number } }\n>();\n"],"names":[],"mappings":";;;;;;;;;AAAA;;AAqFA;AACA,MAAM,oBAAqB,GAAE,IAAK,GAAE,IAAI;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,yBAAA,SAAkC,mBAAmB,CAAmC;AACrG,GAAS,WAAW,CAAC,MAAM,GAAqC,EAAE,EAAE;AACpE,IAAI,KAAK,CAAC,8BAA8B,EAAE,OAAO,EAAE,MAAM,CAAC;AAC1D;;AAEA;AACA,GAAS,IAAI,GAA+E;AAC5F,IAAI,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,EAAE,IAAI,CAAC,uBAAuB,EAAE,CAAC;AAC5E;;AAEA;AACA,GAAU,uBAAuB,GAAwC;AACzE,IAAI,OAAO,IAAI,mCAAmC;AAClD,MAAM,MAAM;AACZ,MAAM,CAAC,GAAG,CAAC;AACX,MAAM,CAAC,aAAa,KAAiB;AACrC;AACA,QAAQ,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,gCAAgC,EAAE,CAAC;;AAEpG;AACA,QAAQ,MAAM,cAAA,GAAiB,WAAW,CAAC,aAAa,EAAE,SAAS,EAAE,IAAI,CAAC,gCAAgC,EAAE,CAAC;AAC7G,QAAQ,WAAW,CAAC,aAAa,EAAE,KAAK,EAAE,IAAI,CAAC,4BAA4B,CAAC,cAAc,CAAC,CAAC;;AAE5F,QAAQ,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strumentation.js","sources":["../../../../src/integrations/http/SentryHttpInstrumentation.ts"],"sourcesContent":["/* eslint-disable max-lines */\nimport { context, propagation } from '@opentelemetry/api';\nimport { VERSION } from '@opentelemetry/core';\nimport type { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';\nimport type { AggregationCounts, Client, SanitizedRequestData, Scope } from '@sentry/core';\nimport {\n addBreadcrumb,\n generateSpanId,\n getBreadcrumbLogLevelFromHttpStatusCode,\n getClient,\n getCurrentScope,\n getIsolationScope,\n getSanitizedUrlString,\n httpRequestToRequestData,\n logger,\n parseUrl,\n stripUrlQueryAndFragment,\n withIsolationScope,\n} from '@sentry/core';\nimport type * as http from 'node:http';\nimport type { IncomingMessage, RequestOptions } from 'node:http';\nimport type * as https from 'node:https';\nimport type { EventEmitter } from 'node:stream';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { getRequestUrl } from '../../utils/getRequestUrl';\nimport { stealthWrap } from './utils';\nimport { getRequestInfo } from './vendor/getRequestInfo';\n\ntype Http = typeof http;\ntype Https = typeof https;\n\nconst INSTRUMENTATION_NAME = '@sentry/instrumentation-http';\n\nexport type SentryHttpInstrumentationOptions = InstrumentationConfig & {\n /**\n * Whether breadcrumbs should be recorded for requests.\n *\n * @default `true`\n */\n breadcrumbs?: boolean;\n\n /**\n * Whether to extract the trace ID from the `sentry-trace` header for incoming requests.\n * By default this is done by the HttpInstrumentation, but if that is not added (e.g. because tracing is disabled, ...)\n * then this instrumentation can take over.\n *\n * @default `false`\n */\n extractIncomingTraceFromHeader?: boolean;\n\n /**\n * Do not capture breadcrumbs for outgoing HTTP requests to URLs where the given callback returns `true`.\n * For the scope of this instrumentation, this callback only controls breadcrumb creation.\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 * @param request Contains the {@type RequestOptions} object used to make the outgoing request.\n */\n ignoreOutgoingRequests?: (url: string, request: RequestOptions) => boolean;\n\n /**\n * Do not capture the request body for incoming HTTP requests to URLs where the given callback returns `true`.\n * This can be useful for long running requests where the body is not needed and we want to avoid capturing it.\n *\n * @param url Contains the entire URL, including query string (if any), protocol, host, etc. of the outgoing request.\n * @param request Contains the {@type RequestOptions} object used to make the outgoing request.\n */\n ignoreIncomingRequestBody?: (url: string, request: RequestOptions) => boolean;\n\n /**\n * Whether the integration should create [Sessions](https://docs.sentry.io/product/releases/health/#sessions) for incoming requests to track the health and crash-free rate of your releases in Sentry.\n * Read more about Release Health: https://docs.sentry.io/product/releases/health/\n *\n * Defaults to `true`.\n */\n trackIncomingRequestsAsSessions?: boolean;\n\n /**\n * Number of milliseconds until sessions tracked with `trackIncomingRequestsAsSessions` will be flushed as a session aggregate.\n *\n * Defaults to `60000` (60s).\n */\n sessionFlushingDelayMS?: number;\n};\n\n// We only want to capture request bodies up to 1mb.\nconst MAX_BODY_BYTE_LENGTH = 1024 * 1024;\n\n/**\n * This custom HTTP instrumentation is used to isolate incoming requests and annotate them with additional information.\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 * Important note: Contrary to other OTEL instrumentation, this one cannot be unwrapped.\n * It only does minimal things though and does not emit any spans.\n *\n * This is heavily inspired & adapted from:\n * https://github.com/open-telemetry/opentelemetry-js/blob/f8ab5592ddea5cba0a3b33bf8d74f27872c0367f/experimental/packages/opentelemetry-instrumentation-http/src/http.ts\n */\nexport class SentryHttpInstrumentation extends InstrumentationBase<SentryHttpInstrumentationOptions> {\n public constructor(config: SentryHttpInstrumentationOptions = {}) {\n super(INSTRUMENTATION_NAME, VERSION, config);\n }\n\n /** @inheritdoc */\n public init(): [InstrumentationNodeModuleDefinition, InstrumentationNodeModuleDefinition] {\n return [this._getHttpsInstrumentation(), this._getHttpInstrumentation()];\n }\n\n /** Get the instrumentation for the http module. */\n private _getHttpInstrumentation(): InstrumentationNodeModuleDefinition {\n return new InstrumentationNodeModuleDefinition(\n 'http',\n ['*'],\n (moduleExports: Http): Http => {\n // Patch incoming requests for request isolation\n stealthWrap(moduleExports.Server.prototype, 'emit', this._getPatchIncomingRequestFunction());\n\n // Patch outgoing requests for breadcrumbs\n const patchedRequest = stealthWrap(moduleExports, 'request', this._getPatchOutgoingRequestFunction());\n stealthWrap(moduleExports, 'get', this._getPatchOutgoingGetFunction(patchedRequest));\n\n return moduleExports;\n },\n () => {\n // no unwrap here\n },\n );\n }\n\n /** Get the instrumentation for the https module. */\n private _getHttpsInstrumentation(): InstrumentationNodeModuleDefinition {\n return new InstrumentationNodeModuleDefinition(\n 'https',\n ['*'],\n (moduleExports: Https): Https => {\n // Patch incoming requests for request isolation\n stealthWrap(moduleExports.Server.prototype, 'emit', this._getPatchIncomingRequestFunction());\n\n // Patch outgoing requests for breadcrumbs\n const patchedRequest = stealthWrap(moduleExports, 'request', this._getPatchOutgoingRequestFunction());\n stealthWrap(moduleExports, 'get', this._getPatchOutgoingGetFunction(patchedRequest));\n\n return moduleExports;\n },\n () => {\n // no unwrap here\n },\n );\n }\n\n /**\n * Patch the incoming request function for request isolation.\n */\n private _getPatchIncomingRequestFunction(): (\n original: (event: string, ...args: unknown[]) => boolean,\n ) => (this: unknown, event: string, ...args: unknown[]) => boolean {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const instrumentation = this;\n const { ignoreIncomingRequestBody } = instrumentation.getConfig();\n\n return (\n original: (event: string, ...args: unknown[]) => boolean,\n ): ((this: unknown, event: string, ...args: unknown[]) => boolean) => {\n return function incomingRequest(this: unknown, ...args: [event: string, ...args: unknown[]]): boolean {\n // Only traces request events\n if (args[0] !== 'request') {\n return original.apply(this, args);\n }\n\n instrumentation._diag.debug('http instrumentation for incoming request');\n\n const isolationScope = getIsolationScope().clone();\n const request = args[1] as http.IncomingMessage;\n const response = args[2] as http.OutgoingMessage;\n\n const normalizedRequest = httpRequestToRequestData(request);\n\n // request.ip is non-standard but some frameworks set this\n const ipAddress = (request as { ip?: string }).ip || request.socket?.remoteAddress;\n\n const url = request.url || '/';\n if (!ignoreIncomingRequestBody?.(url, request)) {\n patchRequestToCaptureBody(request, isolationScope);\n }\n\n // Update the isolation scope, isolate this request\n isolationScope.setSDKProcessingMetadata({ normalizedRequest, ipAddress });\n\n // attempt to update the scope's `transactionName` based on the request URL\n // Ideally, framework instrumentations coming after the HttpInstrumentation\n // update the transactionName once we get a parameterized route.\n const httpMethod = (request.method || 'GET').toUpperCase();\n const httpTarget = stripUrlQueryAndFragment(url);\n\n const bestEffortTransactionName = `${httpMethod} ${httpTarget}`;\n\n isolationScope.setTransactionName(bestEffortTransactionName);\n\n if (instrumentation.getConfig().trackIncomingRequestsAsSessions !== false) {\n recordRequestSession({\n requestIsolationScope: isolationScope,\n response,\n sessionFlushingDelayMS: instrumentation.getConfig().sessionFlushingDelayMS ?? 60_000,\n });\n }\n\n return withIsolationScope(isolationScope, () => {\n // Set a new propagationSpanId for this request\n // We rely on the fact that `withIsolationScope()` will implicitly also fork the current scope\n // This way we can save an \"unnecessary\" `withScope()` invocation\n getCurrentScope().getPropagationContext().propagationSpanId = generateSpanId();\n\n // If we don't want to extract the trace from the header, we can skip this\n if (!instrumentation.getConfig().extractIncomingTraceFromHeader) {\n return original.apply(this, args);\n }\n\n const ctx = propagation.extract(context.active(), normalizedRequest.headers);\n return context.with(ctx, () => {\n return original.apply(this, args);\n });\n });\n };\n };\n }\n\n /**\n * Patch the outgoing request function for breadcrumbs.\n */\n private _getPatchOutgoingRequestFunction(): (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n original: (...args: any[]) => http.ClientRequest,\n ) => (options: URL | http.RequestOptions | string, ...args: unknown[]) => http.ClientRequest {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const instrumentation = this;\n\n return (original: (...args: unknown[]) => http.ClientRequest): ((...args: unknown[]) => http.ClientRequest) => {\n return function outgoingRequest(this: unknown, ...args: unknown[]): http.ClientRequest {\n instrumentation._diag.debug('http instrumentation for outgoing requests');\n\n // Making a copy to avoid mutating the original args array\n // We need to access and reconstruct the request options object passed to `ignoreOutgoingRequests`\n // so that it matches what Otel instrumentation passes to `ignoreOutgoingRequestHook`.\n // @see https://github.com/open-telemetry/opentelemetry-js/blob/7293e69c1e55ca62e15d0724d22605e61bd58952/experimental/packages/opentelemetry-instrumentation-http/src/http.ts#L756-L789\n const argsCopy = [...args];\n\n const options = argsCopy.shift() as URL | http.RequestOptions | string;\n\n const extraOptions =\n typeof argsCopy[0] === 'object' && (typeof options === 'string' || options instanceof URL)\n ? (argsCopy.shift() as http.RequestOptions)\n : undefined;\n\n const { optionsParsed } = getRequestInfo(instrumentation._diag, options, extraOptions);\n\n const request = original.apply(this, args) as ReturnType<typeof http.request>;\n\n request.prependListener('response', (response: http.IncomingMessage) => {\n const _breadcrumbs = instrumentation.getConfig().breadcrumbs;\n const breadCrumbsEnabled = typeof _breadcrumbs === 'undefined' ? true : _breadcrumbs;\n\n const _ignoreOutgoingRequests = instrumentation.getConfig().ignoreOutgoingRequests;\n const shouldCreateBreadcrumb =\n typeof _ignoreOutgoingRequests === 'function'\n ? !_ignoreOutgoingRequests(getRequestUrl(request), optionsParsed)\n : true;\n\n if (breadCrumbsEnabled && shouldCreateBreadcrumb) {\n addRequestBreadcrumb(request, response);\n }\n });\n\n return request;\n };\n };\n }\n\n /** Path the outgoing get function for breadcrumbs. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private _getPatchOutgoingGetFunction(clientRequest: (...args: any[]) => http.ClientRequest) {\n return (_original: unknown): ((...args: unknown[]) => http.ClientRequest) => {\n // Re-implement http.get. This needs to be done (instead of using\n // getPatchOutgoingRequestFunction to patch it) because we need to\n // set the trace context header before the returned http.ClientRequest is\n // ended. The Node.js docs state that the only differences between\n // request and get are that (1) get defaults to the HTTP GET method and\n // (2) the returned request object is ended immediately. The former is\n // already true (at least in supported Node versions up to v10), so we\n // simply follow the latter. Ref:\n // https://nodejs.org/dist/latest/docs/api/http.html#http_http_get_options_callback\n // https://github.com/googleapis/cloud-trace-nodejs/blob/master/src/instrumentations/instrumentation-http.ts#L198\n return function outgoingGetRequest(...args: unknown[]): http.ClientRequest {\n const req = clientRequest(...args);\n req.end();\n return req;\n };\n };\n }\n}\n\n/** Add a breadcrumb for outgoing requests. */\nfunction addRequestBreadcrumb(request: http.ClientRequest, response: http.IncomingMessage): 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: http.ClientRequest): Partial<SanitizedRequestData> {\n try {\n // `request.host` does not contain the port, but the host header does\n const host = request.getHeader('host') || request.host;\n const url = new URL(request.path, `${request.protocol}//${host}`);\n const parsedUrl = parseUrl(url.toString());\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\n/**\n * This method patches the request object to capture the body.\n * Instead of actually consuming the streamed body ourselves, which has potential side effects,\n * we monkey patch `req.on('data')` to intercept the body chunks.\n * This way, we only read the body if the user also consumes the body, ensuring we do not change any behavior in unexpected ways.\n */\nfunction patchRequestToCaptureBody(req: IncomingMessage, isolationScope: Scope): void {\n let bodyByteLength = 0;\n const chunks: Buffer[] = [];\n\n /**\n * We need to keep track of the original callbacks, in order to be able to remove listeners again.\n * Since `off` depends on having the exact same function reference passed in, we need to be able to map\n * original listeners to our wrapped ones.\n */\n const callbackMap = new WeakMap();\n\n try {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n req.on = new Proxy(req.on, {\n apply: (target, thisArg, args: Parameters<typeof req.on>) => {\n const [event, listener, ...restArgs] = args;\n\n if (DEBUG_BUILD) {\n logger.log(INSTRUMENTATION_NAME, 'Patching request.on', event);\n }\n\n if (event === 'data') {\n const callback = new Proxy(listener, {\n apply: (target, thisArg, args: Parameters<typeof listener>) => {\n try {\n const chunk = args[0] as Buffer | string;\n const bufferifiedChunk = Buffer.from(chunk);\n\n if (bodyByteLength < MAX_BODY_BYTE_LENGTH) {\n chunks.push(bufferifiedChunk);\n bodyByteLength += bufferifiedChunk.byteLength;\n } else if (DEBUG_BUILD) {\n logger.log(\n INSTRUMENTATION_NAME,\n `Dropping request body chunk because maximum body length of ${MAX_BODY_BYTE_LENGTH}b is exceeded.`,\n );\n }\n } catch (err) {\n DEBUG_BUILD && logger.error(INSTRUMENTATION_NAME, 'Encountered error while storing body chunk.');\n }\n\n return Reflect.apply(target, thisArg, args);\n },\n });\n\n callbackMap.set(listener, callback);\n\n return Reflect.apply(target, thisArg, [event, callback, ...restArgs]);\n }\n\n return Reflect.apply(target, thisArg, args);\n },\n });\n\n // Ensure we also remove callbacks correctly\n // eslint-disable-next-line @typescript-eslint/unbound-method\n req.off = new Proxy(req.off, {\n apply: (target, thisArg, args: Parameters<typeof req.off>) => {\n const [, listener] = args;\n\n const callback = callbackMap.get(listener);\n if (callback) {\n callbackMap.delete(listener);\n\n const modifiedArgs = args.slice();\n modifiedArgs[1] = callback;\n return Reflect.apply(target, thisArg, modifiedArgs);\n }\n\n return Reflect.apply(target, thisArg, args);\n },\n });\n\n req.on('end', () => {\n try {\n const body = Buffer.concat(chunks).toString('utf-8');\n if (body) {\n isolationScope.setSDKProcessingMetadata({ normalizedRequest: { data: body } });\n }\n } catch (error) {\n if (DEBUG_BUILD) {\n logger.error(INSTRUMENTATION_NAME, 'Error building captured request body', error);\n }\n }\n });\n } catch (error) {\n if (DEBUG_BUILD) {\n logger.error(INSTRUMENTATION_NAME, 'Error patching request to capture body', error);\n }\n }\n}\n\n/**\n * Starts a session and tracks it in the context of a given isolation scope.\n * When the passed response is finished, the session is put into a task and is\n * aggregated with other sessions that may happen in a certain time window\n * (sessionFlushingDelayMs).\n *\n * The sessions are always aggregated by the client that is on the current scope\n * at the time of ending the response (if there is one).\n */\n// Exported for unit tests\nexport function recordRequestSession({\n requestIsolationScope,\n response,\n sessionFlushingDelayMS,\n}: {\n requestIsolationScope: Scope;\n response: EventEmitter;\n sessionFlushingDelayMS?: number;\n}): void {\n requestIsolationScope.setSDKProcessingMetadata({\n requestSession: { status: 'ok' },\n });\n response.once('close', () => {\n // We need to grab the client off the current scope instead of the isolation scope because the isolation scope doesn't hold any client out of the box.\n const client = getClient();\n const requestSession = requestIsolationScope.getScopeData().sdkProcessingMetadata.requestSession;\n\n if (client && requestSession) {\n DEBUG_BUILD && logger.debug(`Recorded request session with status: ${requestSession.status}`);\n\n const roundedDate = new Date();\n roundedDate.setSeconds(0, 0);\n const dateBucketKey = roundedDate.toISOString();\n\n const existingClientAggregate = clientToRequestSessionAggregatesMap.get(client);\n const bucket = existingClientAggregate?.[dateBucketKey] || { exited: 0, crashed: 0, errored: 0 };\n bucket[({ ok: 'exited', crashed: 'crashed', errored: 'errored' } as const)[requestSession.status]]++;\n\n if (existingClientAggregate) {\n existingClientAggregate[dateBucketKey] = bucket;\n } else {\n DEBUG_BUILD && logger.debug('Opened new request session aggregate.');\n const newClientAggregate = { [dateBucketKey]: bucket };\n clientToRequestSessionAggregatesMap.set(client, newClientAggregate);\n\n const flushPendingClientAggregates = (): void => {\n clearTimeout(timeout);\n unregisterClientFlushHook();\n clientToRequestSessionAggregatesMap.delete(client);\n\n const aggregatePayload: AggregationCounts[] = Object.entries(newClientAggregate).map(\n ([timestamp, value]) => ({\n started: timestamp,\n exited: value.exited,\n errored: value.errored,\n crashed: value.crashed,\n }),\n );\n client.sendSession({ aggregates: aggregatePayload });\n };\n\n const unregisterClientFlushHook = client.on('flush', () => {\n DEBUG_BUILD && logger.debug('Sending request session aggregate due to client flush');\n flushPendingClientAggregates();\n });\n const timeout = setTimeout(() => {\n DEBUG_BUILD && logger.debug('Sending request session aggregate due to flushing schedule');\n flushPendingClientAggregates();\n }, sessionFlushingDelayMS).unref();\n }\n }\n });\n}\n\nconst clientToRequestSessionAggregatesMap = new Map<\n Client,\n { [timestampRoundedToSeconds: string]: { exited: number; crashed: number; errored: number } }\n>();\n"],"names":[],"mappings":";;;;;;;;;AAAA;;AAgCA,MAAM,oBAAA,GAAuB,8BAA8B;;AAuD3D;AACA,MAAM,oBAAqB,GAAE,IAAK,GAAE,IAAI;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,yBAAA,SAAkC,mBAAmB,CAAmC;AACrG,GAAS,WAAW,CAAC,MAAM,GAAqC,EAAE,EAAE;AACpE,IAAI,KAAK,CAAC,oBAAoB,EAAE,OAAO,EAAE,MAAM,CAAC;AAChD;;AAEA;AACA,GAAS,IAAI,GAA+E;AAC5F,IAAI,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,EAAE,IAAI,CAAC,uBAAuB,EAAE,CAAC;AAC5E;;AAEA;AACA,GAAU,uBAAuB,GAAwC;AACzE,IAAI,OAAO,IAAI,mCAAmC;AAClD,MAAM,MAAM;AACZ,MAAM,CAAC,GAAG,CAAC;AACX,MAAM,CAAC,aAAa,KAAiB;AACrC;AACA,QAAQ,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,gCAAgC,EAAE,CAAC;;AAEpG;AACA,QAAQ,MAAM,cAAA,GAAiB,WAAW,CAAC,aAAa,EAAE,SAAS,EAAE,IAAI,CAAC,gCAAgC,EAAE,CAAC;AAC7G,QAAQ,WAAW,CAAC,aAAa,EAAE,KAAK,EAAE,IAAI,CAAC,4BAA4B,CAAC,cAAc,CAAC,CAAC;;AAE5F,QAAQ,OAAO,aAAa;AAC5B,OAAO;AACP,MAAM,MAAM;A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DebuggerEnabled } 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 = 'LyohIEBzZW50cnkvbm9kZSA5LjE0LjAgKDBiNjM3MTApIHwgaHR0cHM6Ly9naXRodWIuY29tL2dldHNlbnRyeS9zZW50cnktamF2YXNjcmlwdCAqLwppbXBvcnR7U2Vzc2lvbiBhcyBlfWZyb20ibm9kZTppbnNwZWN0b3IvcHJvbWlzZXMiO2ltcG9ydHt3b3JrZXJEYXRhIGFzIHR9ZnJvbSJub2RlOndvcmtlcl90aHJlYWRzIjtjb25zdCBuPWdsb2JhbFRoaXMsbz0idW5kZWZpbmVkIj09dHlwZW9mIF9fU0VOVFJZX0RFQlVHX198fF9fU0VOVFJZX0RFQlVHX18saT0iOS4xNC4wIjtjb25zdCBhPVsiZGVidWciLCJpbmZvIiwid2FybiIsImVycm9yIiwibG9nIiwiYXNzZXJ0IiwidHJhY2UiXSxzPXt9O2Z1bmN0aW9uIGMoZSl7aWYoISgiY29uc29sZSJpbiBuKSlyZXR1cm4gZSgpO2NvbnN0IHQ9bi5jb25zb2xlLG89e30saT1PYmplY3Qua2V5cyhzKTtpLmZvckVhY2goKGU9Pntjb25zdCBuPXNbZV07b1tlXT10W2VdLHRbZV09bn0pKTt0cnl7cmV0dXJuIGUoKX1maW5hbGx5e2kuZm9yRWFjaCgoZT0+e3RbZV09b1tlXX0pKX19IWZ1bmN0aW9uKGUsdCxvPW4pe2NvbnN0IGE9by5fX1NFTlRSWV9fPW8uX19TRU5UUllfX3x8e30scz1hW2ldPWFbaV18fHt9O3NbZV18fChzW2VdPXQoKSl9KCJsb2dnZXIiLChmdW5jdGlvbigpe2xldCBlPSExO2NvbnN0IHQ9e2VuYWJsZTooKT0+e2U9ITB9LGRpc2FibGU6KCk9PntlPSExfSxp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3N0YXRlOm8/ImFsbCI6InVuY2F1Z2h0In0pLG8pe2NvbnN0IGU9dS5tYXhFeGNlcHRpb25zUGVyU2Vjb25kfHw1MDtwPWZ1bmN0aW9uKGUsdCxuKXtsZXQgbz0wLGk9NSxhPTA7cmV0dXJuIHNldEludGVydmFsKCgoKT0+ezA9PT1hP28+ZSYmKGkqPTIsbihpKSxpPjg2NDAwJiYoaT04NjQwMCksYT1pKTooYS09MSwwPT09YSYmdCgpKSxvPTB9KSwxZTMpLnVucmVmKCksKCk9PntvKz0xfX0oZSwoYXN5bmMoKT0+e2woIlJhdGUtbGltaXQgbGlmdGVkLiIpLGF3YWl0IHQucG9zdCgiRGVidWdnZXIuc2V0UGF1c2VPbkV4Y2VwdGlvbnMiLHtzdGF0ZToiYWxsIn0pfSksKGFzeW5jIGU9PntsKGBSYXRlLWxpbWl0IGV4Y2VlZGVkLiBEaXNhYmxpbmcgY2FwdHVyaW5nIG9mIGNhdWdodCBleGNlcHRpb25zIGZvciAke2V9IHNlY29uZHMuYCksYXdhaXQgdC5wb3N0KCJEZWJ1Z2dlci5zZXRQYXVzZU9uRXhjZXB0aW9ucyIse3N0YXRlOiJ1bmNhdWdodCJ9KX0pKX19KSgpLmNhdGNoKChlPT57bCgiRmFpbGVkIHRvIHN0YXJ0IGRlYnVnZ2VyIixlKX0pKSxzZXRJbnRlcnZhbCgoKCk9Pnt9KSwxZTQpOw==';
|
|
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__,i="9.
|
|
1
|
+
/*! @sentry/node 9.14.0 (0b63710) | 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__,i="9.14.0";const a=["debug","info","warn","error","log","assert","trace"],s={};function c(e){if(!("console"in n))return e();const t=n.console,o={},i=Object.keys(s);i.forEach((e=>{const n=s[e];o[e]=t[e],t[e]=n}));try{return e()}finally{i.forEach((e=>{t[e]=o[e]}))}}!function(e,t,o=n){const a=o.__SENTRY__=o.__SENTRY__||{},s=a[i]=a[i]||{};s[e]||(s[e]=t())}("logger",(function(){let e=!1;const t={enable:()=>{e=!0},disable:()=>{e=!1},isEnabled:()=>e};return o?a.forEach((o=>{t[o]=(...t)=>{e&&c((()=>{n.console[o](`Sentry Logger [${o}]:`,...t)}))}})):a.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 i=await e.post("Runtime.getProperties",{objectId:t,ownProperties:!0});o[n]=i.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 i=await e.post("Runtime.getProperties",{objectId:t,ownProperties:!0});o[n]=i.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 i=[];for(let t=0;t<o.length;t++){const{scopeChain:n,functionName:a,this:s}=o[t],c=n.find((e=>"local"===e.type)),r="global"!==s.className&&s.className?`${s.className}.${a}`:a;if(void 0===c?.object.objectId)i[t]={function:r};else{const n=await b(e,c.object.objectId);i[t]={function:r,vars:n}}}await e.post("Runtime.callFunctionOn",{functionDeclaration:`function() { this.${r} = this.${r} || ${JSON.stringify(i)}; }`,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,i=5,a=0;return setInterval((()=>{0===a?o>e&&(i*=2,n(i),i>86400&&(i=86400),a=i):(a-=1,0===a&&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);
|
|
@@ -5,14 +5,19 @@ import { SentryNodeFetchInstrumentation } from './SentryNodeFetchInstrumentation
|
|
|
5
5
|
|
|
6
6
|
const INTEGRATION_NAME = 'NodeFetch';
|
|
7
7
|
|
|
8
|
-
const instrumentOtelNodeFetch = generateInstrumentOnce(
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const instrumentOtelNodeFetch = generateInstrumentOnce(
|
|
9
|
+
INTEGRATION_NAME,
|
|
10
|
+
UndiciInstrumentation,
|
|
11
|
+
(options) => {
|
|
12
|
+
return getConfigWithDefaults(options);
|
|
13
|
+
},
|
|
14
|
+
);
|
|
11
15
|
|
|
12
16
|
const instrumentSentryNodeFetch = generateInstrumentOnce(
|
|
13
17
|
`${INTEGRATION_NAME}.sentry`,
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
SentryNodeFetchInstrumentation,
|
|
19
|
+
(options) => {
|
|
20
|
+
return options;
|
|
16
21
|
},
|
|
17
22
|
);
|
|
18
23
|
|
|
@@ -24,8 +29,7 @@ const _nativeNodeFetchIntegration = ((options = {}) => {
|
|
|
24
29
|
|
|
25
30
|
// This is the "regular" OTEL instrumentation that emits spans
|
|
26
31
|
if (instrumentSpans) {
|
|
27
|
-
|
|
28
|
-
instrumentOtelNodeFetch(instrumentationConfig);
|
|
32
|
+
instrumentOtelNodeFetch(options);
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
// This is the Sentry-specific instrumentation that creates breadcrumbs & propagates traces
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/integrations/node-fetch/index.ts"],"sourcesContent":["import type { UndiciInstrumentationConfig } from '@opentelemetry/instrumentation-undici';\nimport { UndiciInstrumentation } from '@opentelemetry/instrumentation-undici';\nimport type { IntegrationFn } from '@sentry/core';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, defineIntegration, getClient } from '@sentry/core';\nimport { generateInstrumentOnce } from '../../otel/instrument';\nimport type { NodeClient } from '../../sdk/client';\nimport type { NodeClientOptions } from '../../types';\nimport
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/integrations/node-fetch/index.ts"],"sourcesContent":["import type { UndiciInstrumentationConfig } from '@opentelemetry/instrumentation-undici';\nimport { UndiciInstrumentation } from '@opentelemetry/instrumentation-undici';\nimport type { IntegrationFn } from '@sentry/core';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, defineIntegration, getClient } from '@sentry/core';\nimport { generateInstrumentOnce } from '../../otel/instrument';\nimport type { NodeClient } from '../../sdk/client';\nimport type { NodeClientOptions } from '../../types';\nimport { SentryNodeFetchInstrumentation } from './SentryNodeFetchInstrumentation';\n\nconst INTEGRATION_NAME = 'NodeFetch';\n\ninterface NodeFetchOptions {\n /**\n * Whether breadcrumbs should be recorded for requests.\n * Defaults to true\n */\n breadcrumbs?: boolean;\n\n /**\n * If set to false, do not emit any spans.\n * This will ensure that the default UndiciInstrumentation from OpenTelemetry is not setup,\n * only the Sentry-specific instrumentation for breadcrumbs & trace propagation is applied.\n *\n * If `skipOpenTelemetrySetup: true` is configured, this defaults to `false`, otherwise it defaults to `true`.\n */\n spans?: boolean;\n\n /**\n * Do not capture spans or breadcrumbs for outgoing fetch requests to URLs where the given callback returns `true`.\n * This controls both span & breadcrumb creation - spans will be non recording if tracing is disabled.\n */\n ignoreOutgoingRequests?: (url: string) => boolean;\n}\n\nconst instrumentOtelNodeFetch = generateInstrumentOnce(\n INTEGRATION_NAME,\n UndiciInstrumentation,\n (options: NodeFetchOptions) => {\n return getConfigWithDefaults(options);\n },\n);\n\nconst instrumentSentryNodeFetch = generateInstrumentOnce(\n `${INTEGRATION_NAME}.sentry`,\n SentryNodeFetchInstrumentation,\n (options: NodeFetchOptions) => {\n return options;\n },\n);\n\nconst _nativeNodeFetchIntegration = ((options: NodeFetchOptions = {}) => {\n return {\n name: 'NodeFetch',\n setupOnce() {\n const instrumentSpans = _shouldInstrumentSpans(options, getClient<NodeClient>()?.getOptions());\n\n // This is the \"regular\" OTEL instrumentation that emits spans\n if (instrumentSpans) {\n instrumentOtelNodeFetch(options);\n }\n\n // This is the Sentry-specific instrumentation that creates breadcrumbs & propagates traces\n // This must be registered after the OTEL one, to ensure that the core trace propagation logic takes presedence\n // Otherwise, the sentry-trace header may be set multiple times\n instrumentSentryNodeFetch(options);\n },\n };\n}) satisfies IntegrationFn;\n\nexport const nativeNodeFetchIntegration = defineIntegration(_nativeNodeFetchIntegration);\n\n// Matching the behavior of the base instrumentation\nfunction getAbsoluteUrl(origin: string, path: string = '/'): string {\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\nfunction _shouldInstrumentSpans(options: NodeFetchOptions, clientOptions: Partial<NodeClientOptions> = {}): boolean {\n // If `spans` is passed in, it takes precedence\n // Else, we by default emit spans, unless `skipOpenTelemetrySetup` is set to `true`\n return typeof options.spans === 'boolean' ? options.spans : !clientOptions.skipOpenTelemetrySetup;\n}\n\nfunction getConfigWithDefaults(options: Partial<NodeFetchOptions> = {}): UndiciInstrumentationConfig {\n const instrumentationConfig = {\n requireParentforSpans: false,\n ignoreRequestHook: request => {\n const url = getAbsoluteUrl(request.origin, request.path);\n const _ignoreOutgoingRequests = options.ignoreOutgoingRequests;\n const shouldIgnore = _ignoreOutgoingRequests && url && _ignoreOutgoingRequests(url);\n\n return !!shouldIgnore;\n },\n startSpanHook: () => {\n return {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.node_fetch',\n };\n },\n } satisfies UndiciInstrumentationConfig;\n\n return instrumentationConfig;\n}\n"],"names":[],"mappings":";;;;;AASA,MAAM,gBAAA,GAAmB,WAAW;;AAyBpC,MAAM,uBAAA,GAA0B,sBAAsB;AACtD,EAAE,gBAAgB;AAClB,EAAE,qBAAqB;AACvB,EAAE,CAAC,OAAO,KAAuB;AACjC,IAAI,OAAO,qBAAqB,CAAC,OAAO,CAAC;AACzC,GAAG;AACH,CAAC;;AAED,MAAM,yBAAA,GAA4B,sBAAsB;AACxD,EAAE,CAAC,EAAA,gBAAA,CAAA,OAAA,CAAA;AACA,EAAA,8BAAA;AACA,EAAA,CAAA,OAAA,KAAA;AACA,IAAA,OAAA,OAAA;AACA,GAAA;AACA,CAAA;;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AACA;;AAEA,SAAA,qBAAA,CAAA,OAAA,GAAA,EAAA,EAAA;AACA,EAAA,MAAA,qBAAA,GAAA;AACA,IAAA,qBAAA,EAAA,KAAA;AACA,IAAA,iBAAA,EAAA,OAAA,IAAA;AACA,MAAA,MAAA,GAAA,GAAA,cAAA,CAAA,OAAA,CAAA,MAAA,EAAA,OAAA,CAAA,IAAA,CAAA;AACA,MAAA,MAAA,uBAAA,GAAA,OAAA,CAAA,sBAAA;AACA,MAAA,MAAA,YAAA,GAAA,uBAAA,IAAA,GAAA,IAAA,uBAAA,CAAA,GAAA,CAAA;;AAEA,MAAA,OAAA,CAAA,CAAA,YAAA;AACA,KAAA;AACA,IAAA,aAAA,EAAA,MAAA;AACA,MAAA,OAAA;AACA,QAAA,CAAA,gCAAA,GAAA,2BAAA;AACA,OAAA;AACA,KAAA;AACA,GAAA;;AAEA,EAAA,OAAA,qBAAA;AACA;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express';
|
|
2
|
-
import { defineIntegration, getIsolationScope, getDefaultIsolationScope, logger, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_OP
|
|
2
|
+
import { defineIntegration, httpRequestToRequestData, getIsolationScope, captureException, getDefaultIsolationScope, logger, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_OP } from '@sentry/core';
|
|
3
3
|
import { DEBUG_BUILD } from '../../debug-build.js';
|
|
4
4
|
import { generateInstrumentOnce } from '../../otel/instrument.js';
|
|
5
5
|
import { addOriginToSpan } from '../../utils/addOriginToSpan.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FastifyInstrumentation } from '@opentelemetry/instrumentation-fastify';
|
|
2
|
-
import { defineIntegration,
|
|
2
|
+
import { defineIntegration, captureException, getIsolationScope, getClient, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
|
|
3
3
|
import { generateInstrumentOnce } from '../../otel/instrument.js';
|
|
4
4
|
import { ensureIsWrapped } from '../../utils/ensureIsWrapped.js';
|
|
5
5
|
|