@sentry/node 8.39.0-dev.0 → 8.39.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 +3 -2
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/integrations/anr/index.js +1 -1
- package/build/cjs/integrations/anr/index.js.map +1 -1
- package/build/cjs/integrations/{processThread.js → childProcess.js} +11 -4
- package/build/cjs/integrations/childProcess.js.map +1 -0
- package/build/cjs/integrations/http/SentryHttpInstrumentation.js +157 -2
- 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/local-variables/local-variables-async.js.map +1 -1
- package/build/cjs/integrations/tracing/mongo.js +47 -0
- package/build/cjs/integrations/tracing/mongo.js.map +1 -1
- package/build/cjs/integrations/tracing/nest/helpers.js +17 -0
- package/build/cjs/integrations/tracing/nest/helpers.js.map +1 -1
- package/build/cjs/integrations/tracing/nest/nest.js +6 -0
- package/build/cjs/integrations/tracing/nest/nest.js.map +1 -1
- package/build/cjs/integrations/tracing/nest/sentry-nest-event-instrumentation.js +118 -0
- package/build/cjs/integrations/tracing/nest/sentry-nest-event-instrumentation.js.map +1 -0
- package/build/cjs/sdk/index.js +2 -2
- package/build/cjs/sdk/index.js.map +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/integrations/anr/index.js +1 -1
- package/build/esm/integrations/anr/index.js.map +1 -1
- package/build/esm/integrations/anr/worker-script.js +2 -2
- package/build/esm/integrations/{processThread.js → childProcess.js} +11 -5
- package/build/esm/integrations/childProcess.js.map +1 -0
- package/build/esm/integrations/http/SentryHttpInstrumentation.js +158 -3
- 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/local-variables-async.js.map +1 -1
- package/build/esm/integrations/local-variables/worker-script.js +2 -2
- package/build/esm/integrations/tracing/mongo.js +47 -1
- package/build/esm/integrations/tracing/mongo.js.map +1 -1
- package/build/esm/integrations/tracing/nest/helpers.js +17 -1
- package/build/esm/integrations/tracing/nest/helpers.js.map +1 -1
- package/build/esm/integrations/tracing/nest/nest.js +6 -0
- package/build/esm/integrations/tracing/nest/nest.js.map +1 -1
- package/build/esm/integrations/tracing/nest/sentry-nest-event-instrumentation.js +116 -0
- package/build/esm/integrations/tracing/nest/sentry-nest-event-instrumentation.js.map +1 -0
- package/build/esm/package.json +1 -1
- package/build/esm/sdk/index.js +2 -2
- package/build/esm/sdk/index.js.map +1 -1
- package/build/types/index.d.ts +2 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/integrations/childProcess.d.ts +20 -0
- package/build/types/integrations/childProcess.d.ts.map +1 -0
- package/build/types/integrations/http/SentryHttpInstrumentation.d.ts.map +1 -1
- package/build/types/integrations/tracing/mongo.d.ts +4 -0
- package/build/types/integrations/tracing/mongo.d.ts.map +1 -1
- package/build/types/integrations/tracing/nest/helpers.d.ts +8 -0
- package/build/types/integrations/tracing/nest/helpers.d.ts.map +1 -1
- package/build/types/integrations/tracing/nest/nest.d.ts.map +1 -1
- package/build/types/integrations/tracing/nest/sentry-nest-event-instrumentation.d.ts +27 -0
- package/build/types/integrations/tracing/nest/sentry-nest-event-instrumentation.d.ts.map +1 -0
- package/build/types/integrations/tracing/nest/types.d.ts +8 -0
- package/build/types/integrations/tracing/nest/types.d.ts.map +1 -1
- package/build/types/transports/http-module.d.ts +3 -1
- package/build/types/transports/http-module.d.ts.map +1 -1
- package/build/types-ts3.8/index.d.ts +2 -2
- package/build/types-ts3.8/integrations/childProcess.d.ts +20 -0
- package/build/types-ts3.8/integrations/tracing/mongo.d.ts +4 -0
- package/build/types-ts3.8/integrations/tracing/nest/helpers.d.ts +8 -0
- package/build/types-ts3.8/integrations/tracing/nest/sentry-nest-event-instrumentation.d.ts +27 -0
- package/build/types-ts3.8/integrations/tracing/nest/types.d.ts +8 -0
- package/build/types-ts3.8/transports/http-module.d.ts +2 -1
- package/package.json +5 -5
- package/build/cjs/integrations/processThread.js.map +0 -1
- package/build/esm/integrations/processThread.js.map +0 -1
- package/build/types/integrations/processThread.d.ts +0 -14
- package/build/types/integrations/processThread.d.ts.map +0 -1
- package/build/types-ts3.8/integrations/processThread.d.ts +0 -14
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @sentry/node 8.39.0
|
|
2
|
-
import{Session as t}from"node:inspector";import{parentPort as n,workerData as e}from"node:worker_threads";import{posix as r,sep as o}from"node:path";import*as s from"node:http";import*as i from"node:https";import{Readable as c}from"node:stream";import{createGzip as u}from"node:zlib";import*as a from"node:net";import*as f from"node:tls";const h=Object.prototype.toString;function p(t,n){return h.call(t)===`[object ${n}]`}function d(t){return p(t,"String")}function l(t){return p(t,"Object")}function m(t){return Boolean(t&&t.then&&"function"==typeof t.then)}function y(t,n){try{return t instanceof n}catch(t){return!1}}const g="8.39.0-dev.0",b=globalThis;function _(t,n,e){const r=b,o=r.__SENTRY__=r.__SENTRY__||{},s=o[g]=o[g]||{};return s[t]||(s[t]=n())}const v=b,w=80;function S(t,n){const e=t,r=[];if(!e||!e.tagName)return"";if(v.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&&n.length?n.filter((t=>e.getAttribute(t))).map((t=>[t,e.getAttribute(t)])):null;if(o&&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("")}const $="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,E=["debug","info","warn","error","log","assert","trace"],x={};function N(t){if(!("console"in b))return t();const n=b.console,e={},r=Object.keys(x);r.forEach((t=>{const r=x[t];e[t]=n[t],n[t]=r}));try{return t()}finally{r.forEach((t=>{n[t]=e[t]}))}}const C=_("logger",(function(){let t=!1;const n={enable:()=>{t=!0},disable:()=>{t=!1},isEnabled:()=>t};return $?E.forEach((e=>{n[e]=(...n)=>{t&&N((()=>{b.console[e](`Sentry Logger [${e}]:`,...n)}))}})):E.forEach((t=>{n[t]=()=>{}})),n}));function T(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}`}class k extends Error{constructor(t,n="warn"){super(t),this.message=t,this.name=new.target.prototype.constructor.name,Object.setPrototypeOf(this,new.target.prototype),this.logLevel=n}}function R(t){if(function(t){switch(h.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return y(t,Error)}}(t))return{message:t.message,name:t.name,stack:t.stack,...D(t)};if(n=t,"undefined"!=typeof Event&&y(n,Event)){const n={type:t.type,target:j(t.target),currentTarget:j(t.currentTarget),...D(t)};return"undefined"!=typeof CustomEvent&&y(t,CustomEvent)&&(n.detail=t.detail),n}return t;var n}function j(t){try{return n=t,"undefined"!=typeof Element&&y(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||w;for(;e&&s++<r&&(a=S(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 D(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 O(t){return A(t,new Map)}function A(t,n){if(function(t){if(!l(t))return!1;try{const n=Object.getPrototypeOf(t).constructor.name;return!n||"Object"===n}catch(t){return!0}}(t)){const e=n.get(t);if(void 0!==e)return e;const r={};n.set(t,r);for(const e of Object.getOwnPropertyNames(t))void 0!==t[e]&&(r[e]=A(t[e],n));return r}if(Array.isArray(t)){const e=n.get(t);if(void 0!==e)return e;const r=[];return n.set(t,r),t.forEach((t=>{r.push(A(t,n))})),r}return t}const I=50,P="?",U=/captureMessage|captureException/;function M(t){return t[t.length-1]||{}}const L="<anonymous>";const B=1e3;function G(){return Date.now()/B}const J=function(){const{performance:t}=b;if(!t||!t.now)return G;const n=Date.now()-t.now(),e=null==t.timeOrigin?n:t.timeOrigin;return()=>(e+t.now())/B}();function Y(){const t=b,n=t.crypto||t.msCrypto;let e=()=>16*Math.random();try{if(n&&n.randomUUID)return n.randomUUID().replace(/-/g,"");n&&n.getRandomValues&&(e=()=>{const t=new Uint8Array(1);return n.getRandomValues(t),t[0]})}catch(t){}return([1e7]+1e3+4e3+8e3+1e11).replace(/[018]/g,(t=>(t^(15&e())>>t/4).toString(16)))}function z(t,n=100,e=1/0){try{return H("",t,n,e)}catch(t){return{ERROR:`**non-serializable** (${t})`}}}function H(t,n,e=1/0,r=1/0,o=function(){const t="function"==typeof WeakSet,n=t?new WeakSet:[];return[function(e){if(t)return!!n.has(e)||(n.add(e),!1);for(let t=0;t<n.length;t++)if(n[t]===e)return!0;return n.push(e),!1},function(e){if(t)n.delete(e);else for(let t=0;t<n.length;t++)if(n[t]===e){n.splice(t,1);break}}]}()){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.t)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.o))return"[VueViewModel]";if(function(t){return l(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||L}catch(t){return L}}(n)}]`;if("symbol"==typeof n)return`[${String(n)}]`;if("bigint"==typeof n)return`[BigInt: ${String(n)}]`;const r=function(t){const n=Object.getPrototypeOf(t);return n?n.constructor.name:"null prototype"}(n);return/^HTML(\w*)Element$/.test(r)?`[HTMLElement: ${r}]`:`[object ${r}]`}catch(t){return`**non-serializable** (${t})`}var e}(t,n);if(!c.startsWith("[object "))return c;if(n.__sentry_skip_normalization__)return n;const u="number"==typeof n.__sentry_override_normalization_depth__?n.__sentry_override_normalization_depth__:e;if(0===u)return c.replace("object ","");if(s(n))return"[Circular ~]";const a=n;if(a&&"function"==typeof a.toJSON)try{return H("",a.toJSON(),u-1,r,o)}catch(t){}const f=Array.isArray(n)?[]:{};let h=0;const p=R(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]=H(t,n,u-1,r,o),h++}return i(n),f}function W(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:///")}(()=>{const{performance:t}=b;if(!t||!t.now)return;const n=36e5,e=t.now(),r=Date.now(),o=t.timeOrigin?Math.abs(t.timeOrigin+e-r):n,s=o<n,i=t.timing&&t.timing.navigationStart,c="number"==typeof i?Math.abs(i+e-r):n;(s||c<n)&&(o<=c&&t.timeOrigin)})();const F=/^(\S+:\\|\/?)([\s\S]*?)((?:\.{1,2}|[^/\\]+?|)(\.[^./\\]*|))(?:[/\\]*)$/;function K(t){const n=function(t){const n=t.length>1024?`<truncated>${t.slice(-1024)}`:t,e=F.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):"."}var V;function Z(t){return new q((n=>{n(t)}))}!function(t){t[t.PENDING=0]="PENDING";t[t.RESOLVED=1]="RESOLVED";t[t.REJECTED=2]="REJECTED"}(V||(V={}));class q{constructor(t){q.prototype.__init.call(this),q.prototype.__init2.call(this),q.prototype.__init3.call(this),q.prototype.__init4.call(this),this.i=V.PENDING,this.u=[];try{t(this.h,this.p)}catch(t){this.p(t)}}then(t,n){return new q(((e,r)=>{this.u.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.l()}))}catch(t){return this.then((t=>t),t)}finally(t){return new q(((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)}))}))}__init(){this.h=t=>{this.m(V.RESOLVED,t)}}__init2(){this.p=t=>{this.m(V.REJECTED,t)}}__init3(){this.m=(t,n)=>{this.i===V.PENDING&&(m(n)?n.then(this.h,this.p):(this.i=t,this._=n,this.l()))}}__init4(){this.l=()=>{if(this.i===V.PENDING)return;const t=this.u.slice();this.u=[],t.forEach((t=>{t[0]||(this.i===V.RESOLVED&&t[1](this._),this.i===V.REJECTED&&t[2](this._),t[0]=!0)}))}}}function Q(t){const n=[];function e(t){return n.splice(n.indexOf(t),1)[0]||Promise.resolve(void 0)}return{$:n,add:function(r){if(!(void 0===t||n.length<t))return o=new k("Not adding Promise because buffer limit was reached."),new q(((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 q(((e,r)=>{let o=n.length;if(!o)return e(!0);const s=setTimeout((()=>{t&&t>0&&e(!1)}),t);n.forEach((t=>{Z(t).then((()=>{--o||(clearTimeout(s),e(!0))}),r)}))}))}}}function X(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 tt="sentry-",nt=/^sentry-/;function et(t){const n=function(t){if(!t||!d(t)&&!Array.isArray(t))return;if(Array.isArray(t))return t.reduce(((t,n)=>{const e=rt(n);return Object.entries(e).forEach((([n,e])=>{t[n]=e})),t}),{});return rt(t)}(t);if(!n)return;const e=Object.entries(n).reduce(((t,[n,e])=>{if(n.match(nt)){t[n.slice(tt.length)]=e}return t}),{});return Object.keys(e).length>0?e:void 0}function rt(t){return t.split(",").map((t=>t.split("=").map((t=>decodeURIComponent(t.trim()))))).reduce(((t,[n,e])=>(n&&e&&(t[n]=e),t)),{})}function ot(t,n=[]){return[t,n]}function st(t,n){const e=t[1];for(const t of e){if(n(t,t[0].type))return!0}return!1}function it(t){return b.__SENTRY__&&b.__SENTRY__.encodePolyfill?b.__SENTRY__.encodePolyfill(t):(new TextEncoder).encode(t)}function ct(t){const[n,e]=t;let r=JSON.stringify(n);function o(t){"string"==typeof r?r="string"==typeof t?r+t:[it(r),t]:r.push("string"==typeof t?it(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(z(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 ut={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",statsd:"metric_bucket"};function at(t){if(!t||!t.sdk)return;const{name:n,version:e}=t.sdk;return{name:n,version:e}}const ft=6e4;function ht(t,{statusCode:n,headers:e},r=Date.now()){const o={...t},s=e&&e["x-sentry-rate-limits"],i=e&&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)?ft:r-n}(i,r):429===n&&(o.all=r+6e4);return o}function pt(){return{traceId:Y(),spanId:Y().substring(16)}}const dt="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__;function lt(){return mt(b),b}function mt(t){const n=t.__SENTRY__=t.__SENTRY__||{};return n.version=n.version||g,n[g]=n[g]||{}}function yt(t){const n=J(),e={sid:Y(),init:!0,timestamp:n,started:n,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>function(t){return O({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&>(e,t),e}function gt(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||J(),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)}const bt="_sentrySpan";function _t(t,n){n?function(t,n,e){try{Object.defineProperty(t,n,{value:e,writable:!0,configurable:!0})}catch(e){$&&C.log(`Failed to add non-enumerable property "${n}" to object`,t)}}(t,bt,n):delete t[bt]}function vt(t){return t[bt]}class wt{constructor(){this.v=!1,this.S=[],this.N=[],this.C=[],this.T=[],this.k={},this.R={},this.j={},this.D={},this.O={},this.A=pt()}clone(){const t=new wt;return t.C=[...this.C],t.R={...this.R},t.j={...this.j},t.D={...this.D},t.k=this.k,t.I=this.I,t.P=this.P,t.U=this.U,t.M=this.M,t.N=[...this.N],t.L=this.L,t.T=[...this.T],t.O={...this.O},t.A={...this.A},t.B=this.B,t.G=this.G,_t(t,vt(this)),t}setClient(t){this.B=t}setLastEventId(t){this.G=t}getClient(){return this.B}lastEventId(){return this.G}addScopeListener(t){this.S.push(t)}addEventProcessor(t){return this.N.push(t),this}setUser(t){return this.k=t||{email:void 0,id:void 0,ip_address:void 0,username:void 0},this.P&>(this.P,{user:t}),this.J(),this}getUser(){return this.k}getRequestSession(){return this.L}setRequestSession(t){return this.L=t,this}setTags(t){return this.R={...this.R,...t},this.J(),this}setTag(t,n){return this.R={...this.R,[t]:n},this.J(),this}setExtras(t){return this.j={...this.j,...t},this.J(),this}setExtra(t,n){return this.j={...this.j,[t]:n},this.J(),this}setFingerprint(t){return this.M=t,this.J(),this}setLevel(t){return this.I=t,this.J(),this}setTransactionName(t){return this.U=t,this.J(),this}setContext(t,n){return null===n?delete this.D[t]:this.D[t]=n,this.J(),this}setSession(t){return t?this.P=t:delete this.P,this.J(),this}getSession(){return this.P}update(t){if(!t)return this;const n="function"==typeof t?t(this):t,[e,r]=n instanceof St?[n.getScopeData(),n.getRequestSession()]:l(n)?[t,t.requestSession]:[],{tags:o,extra:s,user:i,contexts:c,level:u,fingerprint:a=[],propagationContext:f}=e||{};return this.R={...this.R,...o},this.j={...this.j,...s},this.D={...this.D,...c},i&&Object.keys(i).length&&(this.k=i),u&&(this.I=u),a.length&&(this.M=a),f&&(this.A=f),r&&(this.L=r),this}clear(){return this.C=[],this.R={},this.j={},this.k={},this.D={},this.I=void 0,this.U=void 0,this.M=void 0,this.L=void 0,this.P=void 0,_t(this,void 0),this.T=[],this.A=pt(),this.J(),this}addBreadcrumb(t,n){const e="number"==typeof n?n:100;if(e<=0)return this;const r={timestamp:G(),...t},o=this.C;return o.push(r),this.C=o.length>e?o.slice(-e):o,this.J(),this}getLastBreadcrumb(){return this.C[this.C.length-1]}clearBreadcrumbs(){return this.C=[],this.J(),this}addAttachment(t){return this.T.push(t),this}clearAttachments(){return this.T=[],this}getScopeData(){return{breadcrumbs:this.C,attachments:this.T,contexts:this.D,tags:this.R,extra:this.j,user:this.k,level:this.I,fingerprint:this.M||[],eventProcessors:this.N,propagationContext:this.A,sdkProcessingMetadata:this.O,transactionName:this.U,span:vt(this)}}setSDKProcessingMetadata(t){return this.O={...this.O,...t},this}setPropagationContext(t){return this.A=t,this}getPropagationContext(){return this.A}captureException(t,n){const e=n&&n.event_id?n.event_id:Y();if(!this.B)return C.warn("No client configured on scope - will not capture exception!"),e;const r=new Error("Sentry syntheticException");return this.B.captureException(t,{originalException:t,syntheticException:r,...n,event_id:e},this),e}captureMessage(t,n,e){const r=e&&e.event_id?e.event_id:Y();if(!this.B)return C.warn("No client configured on scope - will not capture message!"),r;const o=new Error(t);return this.B.captureMessage(t,n,{originalException:t,syntheticException:o,...e,event_id:r},this),r}captureEvent(t,n){const e=n&&n.event_id?n.event_id:Y();return this.B?(this.B.captureEvent(t,{...n,event_id:e},this),e):(C.warn("No client configured on scope - will not capture event!"),e)}J(){this.v||(this.v=!0,this.S.forEach((t=>{t(this)})),this.v=!1)}}const St=wt;class $t{constructor(t,n){let e,r;e=t||new St,r=n||new St,this.Y=[{scope:e}],this.H=r}withScope(t){const n=this.W();let e;try{e=t(n)}catch(t){throw this.F(),t}return m(e)?e.then((t=>(this.F(),t)),(t=>{throw this.F(),t})):(this.F(),e)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this.H}getStackTop(){return this.Y[this.Y.length-1]}W(){const t=this.getScope().clone();return this.Y.push({client:this.getClient(),scope:t}),t}F(){return!(this.Y.length<=1)&&!!this.Y.pop()}}function Et(){const t=mt(lt());return t.stack=t.stack||new $t(_("defaultCurrentScope",(()=>new St)),_("defaultIsolationScope",(()=>new St)))}function xt(t){return Et().withScope(t)}function Nt(t,n){const e=Et();return e.withScope((()=>(e.getStackTop().scope=t,n(t))))}function Ct(t){return Et().withScope((()=>t(Et().getIsolationScope())))}function Tt(t){const n=mt(t);return n.acs?n.acs:{withIsolationScope:Ct,withScope:xt,withSetScope:Nt,withSetIsolationScope:(t,n)=>Ct(n),getCurrentScope:()=>Et().getScope(),getIsolationScope:()=>Et().getIsolationScope()}}function kt(){return Tt(lt()).getCurrentScope().getClient()}const Rt="_sentryMetrics";function jt(t){const n=t[Rt];if(!n)return;const e={};for(const[,[t,r]]of n){(e[t]||(e[t]=[])).push(O(r))}return e}const Dt="sentry.source",Ot="sentry.sample_rate",At="sentry.op",It="sentry.origin",Pt=0,Ut=1,Mt=1;function Lt(t){const{spanId:n,traceId:e}=t.spanContext(),{parent_span_id:r}=Jt(t);return O({parent_span_id:r,span_id:n,trace_id:e})}function Bt(t){return"number"==typeof t?Gt(t):Array.isArray(t)?t[0]+t[1]/1e9:t instanceof Date?Gt(t.getTime()):J()}function Gt(t){return t>9999999999?t/1e3:t}function Jt(t){if(function(t){return"function"==typeof t.getSpanJSON}(t))return t.getSpanJSON();try{const{spanId:n,traceId:e}=t.spanContext();if(function(t){const n=t;return!!(n.attributes&&n.startTime&&n.name&&n.endTime&&n.status)}(t)){const{attributes:r,startTime:o,name:s,endTime:i,parentSpanId:c,status:u}=t;return O({span_id:n,trace_id:e,data:r,description:s,parent_span_id:c,start_timestamp:Bt(o),timestamp:Bt(i)||void 0,status:Yt(u),op:r[At],origin:r[It],_metrics_summary:jt(t)})}return{span_id:n,trace_id:e}}catch(t){return{}}}function Yt(t){if(t&&t.code!==Pt)return t.code===Ut?"ok":t.message||"unknown_error"}const zt="_sentryRootSpan";function Ht(t){return t[zt]||t}const Wt="production",Ft="_frozenDsc";function Kt(t){const n=kt();if(!n)return{};const e=function(t,n){const e=n.getOptions(),{publicKey:r}=n.getDsn()||{},o=O({environment:e.environment||Wt,release:e.release,public_key:r,trace_id:t});return n.emit("createDsc",o),o}(Jt(t).trace_id||"",n),r=Ht(t),o=r[Ft];if(o)return o;const s=r.spanContext().traceState,i=s&&s.get("sentry.dsc"),c=i&&et(i);if(c)return c;const u=Jt(r),a=u.data||{},f=a[Ot];null!=f&&(e.sample_rate=`${f}`);const h=a[Dt],p=u.description;return"url"!==h&&p&&(e.transaction=p),function(t){if("boolean"==typeof __SENTRY_TRACING__&&!__SENTRY_TRACING__)return!1;const n=kt(),e=n&&n.getOptions();return!!e&&(e.enableTracing||"tracesSampleRate"in e||"tracesSampler"in e)}()&&(e.sampled=String(function(t){const{traceFlags:n}=t.spanContext();return n===Mt}(r))),n.emit("createDsc",e,r),e}function Vt(t,n,e,r){const o=at(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&&e.sdk);const i=function(t,n,e,r){const o=t.sdkProcessingMetadata&&t.sdkProcessingMetadata.dynamicSamplingContext;return{event_id:t.event_id,sent_at:(new Date).toISOString(),...n&&{sdk:n},...!!e&&r&&{dsn:T(r)},...o&&{trace:O({...o})}}}(t,o,r,n);delete t.sdkProcessingMetadata;return ot(i,[[{type:s},t]])}const Zt="__SENTRY_SUPPRESS_TRACING__";function qt(t){const n=Tt(lt());return n.suppressTracing?n.suppressTracing(t):function(...t){const n=Tt(lt());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({[Zt]:!0}),t())))}function Qt(t,n){const{fingerprint:e,span:r,breadcrumbs:o,sdkProcessingMetadata:s}=n;!function(t,n){const{extra:e,tags:r,user:o,contexts:s,level:i,transactionName:c}=n,u=O(e);u&&Object.keys(u).length&&(t.extra={...u,...t.extra});const a=O(r);a&&Object.keys(a).length&&(t.tags={...a,...t.tags});const f=O(o);f&&Object.keys(f).length&&(t.user={...f,...t.user});const h=O(s);h&&Object.keys(h).length&&(t.contexts={...h,...t.contexts});i&&(t.level=i);c&&"transaction"!==t.type&&(t.transaction=c)}(t,n),r&&function(t,n){t.contexts={trace:Lt(n),...t.contexts},t.sdkProcessingMetadata={dynamicSamplingContext:Kt(n),...t.sdkProcessingMetadata};const e=Ht(n),r=Jt(e).description;r&&!t.transaction&&"transaction"===t.type&&(t.transaction=r)}(t,r),function(t,n){t.fingerprint=t.fingerprint?function(t){return Array.isArray(t)?t:[t]}(t.fingerprint):[],n&&(t.fingerprint=t.fingerprint.concat(n));t.fingerprint&&!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 Xt="7";function tn(t,n){return e={sentry_key:t.publicKey,sentry_version:Xt,...n&&{sentry_client:`${n.name}/${n.version}`}},Object.keys(e).map((t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`)).join("&");var e}const nn=64;function en(t,n,e=Q(t.bufferSize||nn)){let r={};return{send:function(t){const o=[];if(st(t,((t,n)=>{const e=function(t){return ut[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 Z({});const s=ot(t[0],o),i=t=>{st(s,((t,n)=>{}))};return e.add((()=>n({body:ct(s)}).then((t=>(void 0!==t.statusCode&&(t.statusCode<200||t.statusCode>=300)&&dt&&C.warn(`Sentry responded with status code ${t.statusCode} to sent event.`),r=ht(r,t),t)),(t=>{throw i(),t})))).then((t=>t),(t=>{if(t instanceof k)return dt&&C.error("Skipped sending event because buffer is full."),i(),Z({});throw t}))},flush:t=>e.drain(t)}}const rn=Symbol("AgentBaseInternalState");class on extends s.Agent{[rn];options;keepAlive;constructor(t){super(t),this[rn]={}}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[rn].currentSocket=o,super.createSocket(t,n,e)}),e)}createConnection(){const t=this[rn].currentSocket;if(this[rn].currentSocket=void 0,!t)throw new Error("No socket was returned in the `connect()` function");return t}get defaultPort(){return this[rn].defaultPort??("https:"===this.protocol?443:80)}set defaultPort(t){this[rn]&&(this[rn].defaultPort=t)}get protocol(){return this[rn].protocol??(this.isSecureEndpoint()?"https:":"http:")}set protocol(t){this[rn]&&(this[rn].protocol=t)}}function sn(...t){C.log("[https-proxy-agent:parse-proxy-response]",...t)}function cn(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 sn("have not received end of HTTP headers yet..."),void s();const f=u.slice(0,a).toString("ascii").split("\r\n"),h=f.shift();if(!h)return t.destroy(),e(new Error("No header received from proxy CONNECT response"));const p=h.split(" "),d=+(p[1]||0),l=p.slice(2).join(" "),m={};for(const n of f){if(!n)continue;const r=n.indexOf(":");if(-1===r)return t.destroy(),e(new Error(`Invalid header from proxy CONNECT response: "${n}"`));const o=n.slice(0,r).toLowerCase(),s=n.slice(r+1).trimStart(),i=m[o];"string"==typeof i?m[o]=[i,s]:Array.isArray(i)?i.push(s):m[o]=s}sn("got proxy server response: %o %o",h,m),i(),n({connect:{statusCode:d,statusText:l,headers:m},buffered:u})}(c):t.once("readable",s)}function i(){t.removeListener("end",c),t.removeListener("error",u),t.removeListener("readable",s)}function c(){i(),sn("onend"),e(new Error("Proxy connection ended before receiving CONNECT response"))}function u(t){i(),sn("onerror %o",t),e(t)}t.on("error",u),t.on("end",c),s()}))}function un(...t){C.log("[https-proxy-agent]",...t)}class an extends on{static protocols=["http","https"];proxy;proxyHeaders;connectOpts;constructor(t,n){super(n),this.options={},this.proxy="string"==typeof t?new URL(t):t,this.proxyHeaders=n?.headers??{},un("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?hn(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){un("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 un("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=cn(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",fn),n.secureEndpoint){un("Upgrading socket connection to TLS");const t=n.servername||n.host;return f.connect({...hn(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=>{un("Replaying proxy buffer for failed request"),t.push(h),t.push(null)})),p}}function fn(t){t.resume()}function hn(t,...n){const e={};let r;for(r in t)n.includes(r)||(e[r]=t[r]);return e}const pn=32768;function dn(t){return t.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}const ln=e;let mn,yn=!1,gn={};function bn(t){ln.debug&&console.log(`[ANR Worker] ${t}`)}var _n,vn,wn;const Sn=function(t){let n;try{n=new URL(t.url)}catch(n){return N((()=>{console.warn("[@sentry/node]: Invalid dsn or tunnel option, will not send any events. The tunnel option must be a full URL when used.")})),en(t,(()=>Promise.resolve({})))}const e="https:"===n.protocol,r=function(t,n){const{no_proxy:e}=process.env;return e&&e.split(",").some((n=>t.host.endsWith(n)||t.hostname.endsWith(n)))?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 an(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)=>{qt((()=>{let d=function(t){return new c({read(){this.push(t),this.push(null)}})}(f.body);const l={...t.headers};f.body.length>pn&&(l["content-encoding"]="gzip",d=d.pipe(u()));const m=n.request({method:"POST",agent:e,headers:l,hostname:r,path:`${o}${a}`,port:s,protocol:i,ca:t.caCerts},(t=>{t.on("data",(()=>{})),t.on("end",(()=>{})),t.setEncoding("utf8");const n=t.headers["retry-after"]??null,e=t.headers["x-sentry-rate-limits"]??null;h({statusCode:t.statusCode,headers:{"retry-after":n,"x-sentry-rate-limits":Array.isArray(e)?e[0]||null:e}})}));m.on("error",p),d.pipe(m)}))}))}}(t,t.httpModule??o,f);return en(t,h)}({url:(_n=ln.dsn,vn=ln.tunnel,wn=ln.sdkMetadata.sdk,vn||`${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/`}(_n)}?${tn(_n,wn)}`),recordDroppedEvent:()=>{}});async function $n(){if(mn){bn("Sending abnormal session"),gt(mn,{status:"abnormal",abnormal_mechanism:"anr_foreground"});const t=function(t,n,e,r){const o=at(e);return ot({sent_at:(new Date).toISOString(),...o&&{sdk:o},...!!r&&n&&{dsn:T(n)}},["aggregates"in t?[{type:"sessions"},t]:[{type:"session"},t.toJSON()]])}(mn,ln.dsn,ln.sdkMetadata,ln.tunnel);bn(JSON.stringify(t)),await Sn.send(t);try{n?.postMessage("session-ended")}catch(t){}}}function En(t){if(!t)return;const n=function(t){if(!t.length)return[];const n=Array.from(t);return/sentryWrapped/.test(M(n).function||"")&&n.pop(),n.reverse(),U.test(M(n).function||"")&&(n.pop(),U.test(M(n).function||"")&&n.pop()),n.slice(0,I).map((t=>({...t,filename:t.filename||M(n).filename,function:t.function||P})))}(t);if(ln.appRootPath)for(const t of n)t.filename&&(t.filename=W(t.filename,ln.appRootPath));return n}async function xn(t,n){if(yn)return;yn=!0,await $n(),bn("Sending event");const e={event_id:Y(),contexts:ln.contexts,release:ln.release,environment:ln.environment,dist:ln.dist,platform:"node",level:"error",exception:{values:[{type:"ApplicationNotResponding",value:`Application Not Responding for at least ${ln.anrThreshold} ms`,stacktrace:{frames:En(t)},mechanism:{type:"ANR"}}]},tags:ln.staticTags};n&&function(t,n){if(Qt(t,n),!t.contexts?.trace){const{traceId:e,spanId:r,parentSpanId:o}=n.propagationContext;t.contexts={trace:{trace_id:e,span_id:r,parent_span_id:o},...t.contexts}}}(e,n),function(t){if(0===Object.keys(gn).length)return;const n=new Map;for(const e of t.exception?.values||[])for(const t of e.stacktrace?.frames||[]){const e=t.abs_path||t.filename;e&&gn[e]&&n.set(e,gn[e])}if(n.size>0){const e=[];for(const[t,r]of n.entries())e.push({type:"sourcemap",code_file:t,debug_id:r});t.debug_meta={images:e}}}(e);const r=Vt(e,ln.dsn,ln.sdkMetadata,ln.tunnel);bn(JSON.stringify(r)),await Sn.send(r),await Sn.flush(2e3),setTimeout((()=>{process.exit(0)}),5e3)}let Nn;if(bn("Started"),ln.captureStackTrace){bn("Connecting to debugger");const n=new t;n.connectToMainThread(),bn("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{bn("Debugger paused");const s=[...t.params.callFrames],i=ln.appRootPath?function(t=(process.argv[1]?K(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)),s||(s=".");const u=s.lastIndexOf("/node_modules");if(u>-1)return`${s.slice(u+14).replace(/\//g,".")}:${i}`;if(s.startsWith(e)){let t=s.slice(e.length+1).replace(/\//g,".");return t&&(t+=":"),t+=i,t}return i}}(ln.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 O({filename:r,module:e(r),function:t.functionName||P,colno:o,lineno:s,in_app:r?X(r):void 0})}(t,e.get(t.location.scriptId),i))),u=setTimeout((()=>{xn(c).then(null,(()=>{bn("Sending ANR event failed.")}))}),5e3);n.post("Runtime.evaluate",{expression:"global.__SENTRY_GET_SCOPES__();",silent:!0,returnByValue:!0},((t,e)=>{t&&bn(`Error executing script: '${t.message}'`),clearTimeout(u);const r=e&&e.result?e.result.value:void 0;n.post("Debugger.resume"),n.post("Debugger.disable"),xn(c,r).then(null,(()=>{bn("Sending ANR event failed.")}))}))}catch(t){throw n.post("Debugger.resume"),n.post("Debugger.disable"),t}})),Nn=()=>{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()}}}),ln.pollInterval,ln.anrThreshold,(function(){bn("Watchdog timeout"),Nn?(bn("Pausing debugger to capture stack trace"),Nn()):(bn("Capturing event without a stack trace"),xn().then(null,(()=>{bn("Sending ANR event failed on watchdog timeout.")})))}));n?.on("message",(t=>{t.session&&(mn=yt(t.session)),t.debugImages&&(gn=t.debugImages),Cn()}));
|
|
1
|
+
/*! @sentry/node 8.39.0 (c52478d) | https://github.com/getsentry/sentry-javascript */
|
|
2
|
+
import{Session as t}from"node:inspector";import{parentPort as n,workerData as e}from"node:worker_threads";import{posix as r,sep as o}from"node:path";import*as s from"node:http";import*as i from"node:https";import{Readable as c}from"node:stream";import{createGzip as u}from"node:zlib";import*as a from"node:net";import*as f from"node:tls";const h=Object.prototype.toString;function p(t,n){return h.call(t)===`[object ${n}]`}function l(t){return p(t,"String")}function d(t){return p(t,"Object")}function m(t){return Boolean(t&&t.then&&"function"==typeof t.then)}function y(t,n){try{return t instanceof n}catch(t){return!1}}const g="8.39.0",b=globalThis;function _(t,n,e){const r=b,o=r.__SENTRY__=r.__SENTRY__||{},s=o[g]=o[g]||{};return s[t]||(s[t]=n())}const v=b,w=80;function S(t,n){const e=t,r=[];if(!e||!e.tagName)return"";if(v.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&&n.length?n.filter((t=>e.getAttribute(t))).map((t=>[t,e.getAttribute(t)])):null;if(o&&o.length)o.forEach((t=>{r.push(`[${t[0]}="${t[1]}"]`)}));else{e.id&&r.push(`#${e.id}`);const t=e.className;if(t&&l(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("")}const $="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,E=["debug","info","warn","error","log","assert","trace"],x={};function N(t){if(!("console"in b))return t();const n=b.console,e={},r=Object.keys(x);r.forEach((t=>{const r=x[t];e[t]=n[t],n[t]=r}));try{return t()}finally{r.forEach((t=>{n[t]=e[t]}))}}const C=_("logger",(function(){let t=!1;const n={enable:()=>{t=!0},disable:()=>{t=!1},isEnabled:()=>t};return $?E.forEach((e=>{n[e]=(...n)=>{t&&N((()=>{b.console[e](`Sentry Logger [${e}]:`,...n)}))}})):E.forEach((t=>{n[t]=()=>{}})),n}));function T(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}`}class k extends Error{constructor(t,n="warn"){super(t),this.message=t,this.name=new.target.prototype.constructor.name,Object.setPrototypeOf(this,new.target.prototype),this.logLevel=n}}function R(t){if(function(t){switch(h.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return y(t,Error)}}(t))return{message:t.message,name:t.name,stack:t.stack,...D(t)};if(n=t,"undefined"!=typeof Event&&y(n,Event)){const n={type:t.type,target:j(t.target),currentTarget:j(t.currentTarget),...D(t)};return"undefined"!=typeof CustomEvent&&y(t,CustomEvent)&&(n.detail=t.detail),n}return t;var n}function j(t){try{return n=t,"undefined"!=typeof Element&&y(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||w;for(;e&&s++<r&&(a=S(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 D(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 O(t){return A(t,new Map)}function A(t,n){if(function(t){if(!d(t))return!1;try{const n=Object.getPrototypeOf(t).constructor.name;return!n||"Object"===n}catch(t){return!0}}(t)){const e=n.get(t);if(void 0!==e)return e;const r={};n.set(t,r);for(const e of Object.getOwnPropertyNames(t))void 0!==t[e]&&(r[e]=A(t[e],n));return r}if(Array.isArray(t)){const e=n.get(t);if(void 0!==e)return e;const r=[];return n.set(t,r),t.forEach((t=>{r.push(A(t,n))})),r}return t}const I=50,P="?",U=/captureMessage|captureException/;function M(t){return t[t.length-1]||{}}const L="<anonymous>";const B=1e3;function G(){return Date.now()/B}const J=function(){const{performance:t}=b;if(!t||!t.now)return G;const n=Date.now()-t.now(),e=null==t.timeOrigin?n:t.timeOrigin;return()=>(e+t.now())/B}();function Y(){const t=b,n=t.crypto||t.msCrypto;let e=()=>16*Math.random();try{if(n&&n.randomUUID)return n.randomUUID().replace(/-/g,"");n&&n.getRandomValues&&(e=()=>{const t=new Uint8Array(1);return n.getRandomValues(t),t[0]})}catch(t){}return([1e7]+1e3+4e3+8e3+1e11).replace(/[018]/g,(t=>(t^(15&e())>>t/4).toString(16)))}function z(t,n=100,e=1/0){try{return H("",t,n,e)}catch(t){return{ERROR:`**non-serializable** (${t})`}}}function H(t,n,e=1/0,r=1/0,o=function(){const t="function"==typeof WeakSet,n=t?new WeakSet:[];return[function(e){if(t)return!!n.has(e)||(n.add(e),!1);for(let t=0;t<n.length;t++)if(n[t]===e)return!0;return n.push(e),!1},function(e){if(t)n.delete(e);else for(let t=0;t<n.length;t++)if(n[t]===e){n.splice(t,1);break}}]}()){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.t)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.o))return"[VueViewModel]";if(function(t){return d(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||L}catch(t){return L}}(n)}]`;if("symbol"==typeof n)return`[${String(n)}]`;if("bigint"==typeof n)return`[BigInt: ${String(n)}]`;const r=function(t){const n=Object.getPrototypeOf(t);return n?n.constructor.name:"null prototype"}(n);return/^HTML(\w*)Element$/.test(r)?`[HTMLElement: ${r}]`:`[object ${r}]`}catch(t){return`**non-serializable** (${t})`}var e}(t,n);if(!c.startsWith("[object "))return c;if(n.__sentry_skip_normalization__)return n;const u="number"==typeof n.__sentry_override_normalization_depth__?n.__sentry_override_normalization_depth__:e;if(0===u)return c.replace("object ","");if(s(n))return"[Circular ~]";const a=n;if(a&&"function"==typeof a.toJSON)try{return H("",a.toJSON(),u-1,r,o)}catch(t){}const f=Array.isArray(n)?[]:{};let h=0;const p=R(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]=H(t,n,u-1,r,o),h++}return i(n),f}function W(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:///")}(()=>{const{performance:t}=b;if(!t||!t.now)return;const n=36e5,e=t.now(),r=Date.now(),o=t.timeOrigin?Math.abs(t.timeOrigin+e-r):n,s=o<n,i=t.timing&&t.timing.navigationStart,c="number"==typeof i?Math.abs(i+e-r):n;(s||c<n)&&(o<=c&&t.timeOrigin)})();const F=/^(\S+:\\|\/?)([\s\S]*?)((?:\.{1,2}|[^/\\]+?|)(\.[^./\\]*|))(?:[/\\]*)$/;function K(t){const n=function(t){const n=t.length>1024?`<truncated>${t.slice(-1024)}`:t,e=F.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):"."}var V;function Z(t){return new q((n=>{n(t)}))}!function(t){t[t.PENDING=0]="PENDING";t[t.RESOLVED=1]="RESOLVED";t[t.REJECTED=2]="REJECTED"}(V||(V={}));class q{constructor(t){q.prototype.__init.call(this),q.prototype.__init2.call(this),q.prototype.__init3.call(this),q.prototype.__init4.call(this),this.i=V.PENDING,this.u=[];try{t(this.h,this.p)}catch(t){this.p(t)}}then(t,n){return new q(((e,r)=>{this.u.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.l()}))}catch(t){return this.then((t=>t),t)}finally(t){return new q(((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)}))}))}__init(){this.h=t=>{this.m(V.RESOLVED,t)}}__init2(){this.p=t=>{this.m(V.REJECTED,t)}}__init3(){this.m=(t,n)=>{this.i===V.PENDING&&(m(n)?n.then(this.h,this.p):(this.i=t,this._=n,this.l()))}}__init4(){this.l=()=>{if(this.i===V.PENDING)return;const t=this.u.slice();this.u=[],t.forEach((t=>{t[0]||(this.i===V.RESOLVED&&t[1](this._),this.i===V.REJECTED&&t[2](this._),t[0]=!0)}))}}}function Q(t){const n=[];function e(t){return n.splice(n.indexOf(t),1)[0]||Promise.resolve(void 0)}return{$:n,add:function(r){if(!(void 0===t||n.length<t))return o=new k("Not adding Promise because buffer limit was reached."),new q(((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 q(((e,r)=>{let o=n.length;if(!o)return e(!0);const s=setTimeout((()=>{t&&t>0&&e(!1)}),t);n.forEach((t=>{Z(t).then((()=>{--o||(clearTimeout(s),e(!0))}),r)}))}))}}}function X(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 tt="sentry-",nt=/^sentry-/;function et(t){const n=function(t){if(!t||!l(t)&&!Array.isArray(t))return;if(Array.isArray(t))return t.reduce(((t,n)=>{const e=rt(n);return Object.entries(e).forEach((([n,e])=>{t[n]=e})),t}),{});return rt(t)}(t);if(!n)return;const e=Object.entries(n).reduce(((t,[n,e])=>{if(n.match(nt)){t[n.slice(tt.length)]=e}return t}),{});return Object.keys(e).length>0?e:void 0}function rt(t){return t.split(",").map((t=>t.split("=").map((t=>decodeURIComponent(t.trim()))))).reduce(((t,[n,e])=>(n&&e&&(t[n]=e),t)),{})}function ot(t,n=[]){return[t,n]}function st(t,n){const e=t[1];for(const t of e){if(n(t,t[0].type))return!0}return!1}function it(t){return b.__SENTRY__&&b.__SENTRY__.encodePolyfill?b.__SENTRY__.encodePolyfill(t):(new TextEncoder).encode(t)}function ct(t){const[n,e]=t;let r=JSON.stringify(n);function o(t){"string"==typeof r?r="string"==typeof t?r+t:[it(r),t]:r.push("string"==typeof t?it(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(z(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 ut={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",statsd:"metric_bucket"};function at(t){if(!t||!t.sdk)return;const{name:n,version:e}=t.sdk;return{name:n,version:e}}const ft=6e4;function ht(t,{statusCode:n,headers:e},r=Date.now()){const o={...t},s=e&&e["x-sentry-rate-limits"],i=e&&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)?ft:r-n}(i,r):429===n&&(o.all=r+6e4);return o}function pt(){return{traceId:Y(),spanId:Y().substring(16)}}const lt="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__;function dt(){return mt(b),b}function mt(t){const n=t.__SENTRY__=t.__SENTRY__||{};return n.version=n.version||g,n[g]=n[g]||{}}function yt(t){const n=J(),e={sid:Y(),init:!0,timestamp:n,started:n,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>function(t){return O({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&>(e,t),e}function gt(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||J(),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)}const bt="_sentrySpan";function _t(t,n){n?function(t,n,e){try{Object.defineProperty(t,n,{value:e,writable:!0,configurable:!0})}catch(e){$&&C.log(`Failed to add non-enumerable property "${n}" to object`,t)}}(t,bt,n):delete t[bt]}function vt(t){return t[bt]}class wt{constructor(){this.v=!1,this.S=[],this.N=[],this.C=[],this.T=[],this.k={},this.R={},this.j={},this.D={},this.O={},this.A=pt()}clone(){const t=new wt;return t.C=[...this.C],t.R={...this.R},t.j={...this.j},t.D={...this.D},t.k=this.k,t.I=this.I,t.P=this.P,t.U=this.U,t.M=this.M,t.N=[...this.N],t.L=this.L,t.T=[...this.T],t.O={...this.O},t.A={...this.A},t.B=this.B,t.G=this.G,_t(t,vt(this)),t}setClient(t){this.B=t}setLastEventId(t){this.G=t}getClient(){return this.B}lastEventId(){return this.G}addScopeListener(t){this.S.push(t)}addEventProcessor(t){return this.N.push(t),this}setUser(t){return this.k=t||{email:void 0,id:void 0,ip_address:void 0,username:void 0},this.P&>(this.P,{user:t}),this.J(),this}getUser(){return this.k}getRequestSession(){return this.L}setRequestSession(t){return this.L=t,this}setTags(t){return this.R={...this.R,...t},this.J(),this}setTag(t,n){return this.R={...this.R,[t]:n},this.J(),this}setExtras(t){return this.j={...this.j,...t},this.J(),this}setExtra(t,n){return this.j={...this.j,[t]:n},this.J(),this}setFingerprint(t){return this.M=t,this.J(),this}setLevel(t){return this.I=t,this.J(),this}setTransactionName(t){return this.U=t,this.J(),this}setContext(t,n){return null===n?delete this.D[t]:this.D[t]=n,this.J(),this}setSession(t){return t?this.P=t:delete this.P,this.J(),this}getSession(){return this.P}update(t){if(!t)return this;const n="function"==typeof t?t(this):t,[e,r]=n instanceof St?[n.getScopeData(),n.getRequestSession()]:d(n)?[t,t.requestSession]:[],{tags:o,extra:s,user:i,contexts:c,level:u,fingerprint:a=[],propagationContext:f}=e||{};return this.R={...this.R,...o},this.j={...this.j,...s},this.D={...this.D,...c},i&&Object.keys(i).length&&(this.k=i),u&&(this.I=u),a.length&&(this.M=a),f&&(this.A=f),r&&(this.L=r),this}clear(){return this.C=[],this.R={},this.j={},this.k={},this.D={},this.I=void 0,this.U=void 0,this.M=void 0,this.L=void 0,this.P=void 0,_t(this,void 0),this.T=[],this.A=pt(),this.J(),this}addBreadcrumb(t,n){const e="number"==typeof n?n:100;if(e<=0)return this;const r={timestamp:G(),...t},o=this.C;return o.push(r),this.C=o.length>e?o.slice(-e):o,this.J(),this}getLastBreadcrumb(){return this.C[this.C.length-1]}clearBreadcrumbs(){return this.C=[],this.J(),this}addAttachment(t){return this.T.push(t),this}clearAttachments(){return this.T=[],this}getScopeData(){return{breadcrumbs:this.C,attachments:this.T,contexts:this.D,tags:this.R,extra:this.j,user:this.k,level:this.I,fingerprint:this.M||[],eventProcessors:this.N,propagationContext:this.A,sdkProcessingMetadata:this.O,transactionName:this.U,span:vt(this)}}setSDKProcessingMetadata(t){return this.O={...this.O,...t},this}setPropagationContext(t){return this.A=t,this}getPropagationContext(){return this.A}captureException(t,n){const e=n&&n.event_id?n.event_id:Y();if(!this.B)return C.warn("No client configured on scope - will not capture exception!"),e;const r=new Error("Sentry syntheticException");return this.B.captureException(t,{originalException:t,syntheticException:r,...n,event_id:e},this),e}captureMessage(t,n,e){const r=e&&e.event_id?e.event_id:Y();if(!this.B)return C.warn("No client configured on scope - will not capture message!"),r;const o=new Error(t);return this.B.captureMessage(t,n,{originalException:t,syntheticException:o,...e,event_id:r},this),r}captureEvent(t,n){const e=n&&n.event_id?n.event_id:Y();return this.B?(this.B.captureEvent(t,{...n,event_id:e},this),e):(C.warn("No client configured on scope - will not capture event!"),e)}J(){this.v||(this.v=!0,this.S.forEach((t=>{t(this)})),this.v=!1)}}const St=wt;class $t{constructor(t,n){let e,r;e=t||new St,r=n||new St,this.Y=[{scope:e}],this.H=r}withScope(t){const n=this.W();let e;try{e=t(n)}catch(t){throw this.F(),t}return m(e)?e.then((t=>(this.F(),t)),(t=>{throw this.F(),t})):(this.F(),e)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this.H}getStackTop(){return this.Y[this.Y.length-1]}W(){const t=this.getScope().clone();return this.Y.push({client:this.getClient(),scope:t}),t}F(){return!(this.Y.length<=1)&&!!this.Y.pop()}}function Et(){const t=mt(dt());return t.stack=t.stack||new $t(_("defaultCurrentScope",(()=>new St)),_("defaultIsolationScope",(()=>new St)))}function xt(t){return Et().withScope(t)}function Nt(t,n){const e=Et();return e.withScope((()=>(e.getStackTop().scope=t,n(t))))}function Ct(t){return Et().withScope((()=>t(Et().getIsolationScope())))}function Tt(t){const n=mt(t);return n.acs?n.acs:{withIsolationScope:Ct,withScope:xt,withSetScope:Nt,withSetIsolationScope:(t,n)=>Ct(n),getCurrentScope:()=>Et().getScope(),getIsolationScope:()=>Et().getIsolationScope()}}function kt(){return Tt(dt()).getCurrentScope().getClient()}const Rt="_sentryMetrics";function jt(t){const n=t[Rt];if(!n)return;const e={};for(const[,[t,r]]of n){(e[t]||(e[t]=[])).push(O(r))}return e}const Dt="sentry.source",Ot="sentry.sample_rate",At="sentry.op",It="sentry.origin",Pt=0,Ut=1,Mt=1;function Lt(t){const{spanId:n,traceId:e}=t.spanContext(),{parent_span_id:r}=Jt(t);return O({parent_span_id:r,span_id:n,trace_id:e})}function Bt(t){return"number"==typeof t?Gt(t):Array.isArray(t)?t[0]+t[1]/1e9:t instanceof Date?Gt(t.getTime()):J()}function Gt(t){return t>9999999999?t/1e3:t}function Jt(t){if(function(t){return"function"==typeof t.getSpanJSON}(t))return t.getSpanJSON();try{const{spanId:n,traceId:e}=t.spanContext();if(function(t){const n=t;return!!(n.attributes&&n.startTime&&n.name&&n.endTime&&n.status)}(t)){const{attributes:r,startTime:o,name:s,endTime:i,parentSpanId:c,status:u}=t;return O({span_id:n,trace_id:e,data:r,description:s,parent_span_id:c,start_timestamp:Bt(o),timestamp:Bt(i)||void 0,status:Yt(u),op:r[At],origin:r[It],_metrics_summary:jt(t)})}return{span_id:n,trace_id:e}}catch(t){return{}}}function Yt(t){if(t&&t.code!==Pt)return t.code===Ut?"ok":t.message||"unknown_error"}const zt="_sentryRootSpan";function Ht(t){return t[zt]||t}const Wt="production",Ft="_frozenDsc";function Kt(t){const n=kt();if(!n)return{};const e=function(t,n){const e=n.getOptions(),{publicKey:r}=n.getDsn()||{},o=O({environment:e.environment||Wt,release:e.release,public_key:r,trace_id:t});return n.emit("createDsc",o),o}(Jt(t).trace_id||"",n),r=Ht(t),o=r[Ft];if(o)return o;const s=r.spanContext().traceState,i=s&&s.get("sentry.dsc"),c=i&&et(i);if(c)return c;const u=Jt(r),a=u.data||{},f=a[Ot];null!=f&&(e.sample_rate=`${f}`);const h=a[Dt],p=u.description;return"url"!==h&&p&&(e.transaction=p),function(t){if("boolean"==typeof __SENTRY_TRACING__&&!__SENTRY_TRACING__)return!1;const n=kt(),e=n&&n.getOptions();return!!e&&(e.enableTracing||"tracesSampleRate"in e||"tracesSampler"in e)}()&&(e.sampled=String(function(t){const{traceFlags:n}=t.spanContext();return n===Mt}(r))),n.emit("createDsc",e,r),e}function Vt(t,n,e,r){const o=at(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&&e.sdk);const i=function(t,n,e,r){const o=t.sdkProcessingMetadata&&t.sdkProcessingMetadata.dynamicSamplingContext;return{event_id:t.event_id,sent_at:(new Date).toISOString(),...n&&{sdk:n},...!!e&&r&&{dsn:T(r)},...o&&{trace:O({...o})}}}(t,o,r,n);delete t.sdkProcessingMetadata;return ot(i,[[{type:s},t]])}const Zt="__SENTRY_SUPPRESS_TRACING__";function qt(t){const n=Tt(dt());return n.suppressTracing?n.suppressTracing(t):function(...t){const n=Tt(dt());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({[Zt]:!0}),t())))}function Qt(t,n){const{fingerprint:e,span:r,breadcrumbs:o,sdkProcessingMetadata:s}=n;!function(t,n){const{extra:e,tags:r,user:o,contexts:s,level:i,transactionName:c}=n,u=O(e);u&&Object.keys(u).length&&(t.extra={...u,...t.extra});const a=O(r);a&&Object.keys(a).length&&(t.tags={...a,...t.tags});const f=O(o);f&&Object.keys(f).length&&(t.user={...f,...t.user});const h=O(s);h&&Object.keys(h).length&&(t.contexts={...h,...t.contexts});i&&(t.level=i);c&&"transaction"!==t.type&&(t.transaction=c)}(t,n),r&&function(t,n){t.contexts={trace:Lt(n),...t.contexts},t.sdkProcessingMetadata={dynamicSamplingContext:Kt(n),...t.sdkProcessingMetadata};const e=Ht(n),r=Jt(e).description;r&&!t.transaction&&"transaction"===t.type&&(t.transaction=r)}(t,r),function(t,n){t.fingerprint=t.fingerprint?function(t){return Array.isArray(t)?t:[t]}(t.fingerprint):[],n&&(t.fingerprint=t.fingerprint.concat(n));t.fingerprint&&!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 Xt="7";function tn(t,n){return e={sentry_key:t.publicKey,sentry_version:Xt,...n&&{sentry_client:`${n.name}/${n.version}`}},Object.keys(e).map((t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`)).join("&");var e}const nn=64;function en(t,n,e=Q(t.bufferSize||nn)){let r={};return{send:function(t){const o=[];if(st(t,((t,n)=>{const e=function(t){return ut[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 Z({});const s=ot(t[0],o),i=t=>{st(s,((t,n)=>{}))};return e.add((()=>n({body:ct(s)}).then((t=>(void 0!==t.statusCode&&(t.statusCode<200||t.statusCode>=300)&<&&C.warn(`Sentry responded with status code ${t.statusCode} to sent event.`),r=ht(r,t),t)),(t=>{throw i(),t})))).then((t=>t),(t=>{if(t instanceof k)return lt&&C.error("Skipped sending event because buffer is full."),i(),Z({});throw t}))},flush:t=>e.drain(t)}}const rn=Symbol("AgentBaseInternalState");class on extends s.Agent{[rn];options;keepAlive;constructor(t){super(t),this[rn]={}}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[rn].currentSocket=o,super.createSocket(t,n,e)}),e)}createConnection(){const t=this[rn].currentSocket;if(this[rn].currentSocket=void 0,!t)throw new Error("No socket was returned in the `connect()` function");return t}get defaultPort(){return this[rn].defaultPort??("https:"===this.protocol?443:80)}set defaultPort(t){this[rn]&&(this[rn].defaultPort=t)}get protocol(){return this[rn].protocol??(this.isSecureEndpoint()?"https:":"http:")}set protocol(t){this[rn]&&(this[rn].protocol=t)}}function sn(...t){C.log("[https-proxy-agent:parse-proxy-response]",...t)}function cn(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 sn("have not received end of HTTP headers yet..."),void s();const f=u.slice(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}sn("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(),sn("onend"),e(new Error("Proxy connection ended before receiving CONNECT response"))}function u(t){i(),sn("onerror %o",t),e(t)}t.on("error",u),t.on("end",c),s()}))}function un(...t){C.log("[https-proxy-agent]",...t)}class an extends on{static protocols=["http","https"];proxy;proxyHeaders;connectOpts;constructor(t,n){super(n),this.options={},this.proxy="string"==typeof t?new URL(t):t,this.proxyHeaders=n?.headers??{},un("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?hn(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){un("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 un("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=cn(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",fn),n.secureEndpoint){un("Upgrading socket connection to TLS");const t=n.servername||n.host;return f.connect({...hn(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=>{un("Replaying proxy buffer for failed request"),t.push(h),t.push(null)})),p}}function fn(t){t.resume()}function hn(t,...n){const e={};let r;for(r in t)n.includes(r)||(e[r]=t[r]);return e}const pn=32768;function ln(t){return t.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}const dn=e;let mn,yn=!1,gn={};function bn(t){dn.debug&&console.log(`[ANR Worker] ${t}`)}var _n,vn,wn;const Sn=function(t){let n;try{n=new URL(t.url)}catch(n){return N((()=>{console.warn("[@sentry/node]: Invalid dsn or tunnel option, will not send any events. The tunnel option must be a full URL when used.")})),en(t,(()=>Promise.resolve({})))}const e="https:"===n.protocol,r=function(t,n){const{no_proxy:e}=process.env;return e&&e.split(",").some((n=>t.host.endsWith(n)||t.hostname.endsWith(n)))?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 an(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)=>{qt((()=>{let l=function(t){return new c({read(){this.push(t),this.push(null)}})}(f.body);const d={...t.headers};f.body.length>pn&&(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 en(t,h)}({url:(_n=dn.dsn,vn=dn.tunnel,wn=dn.sdkMetadata.sdk,vn||`${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/`}(_n)}?${tn(_n,wn)}`),recordDroppedEvent:()=>{}});async function $n(){if(mn){bn("Sending abnormal session"),gt(mn,{status:"abnormal",abnormal_mechanism:"anr_foreground"});const t=function(t,n,e,r){const o=at(e);return ot({sent_at:(new Date).toISOString(),...o&&{sdk:o},...!!r&&n&&{dsn:T(n)}},["aggregates"in t?[{type:"sessions"},t]:[{type:"session"},t.toJSON()]])}(mn,dn.dsn,dn.sdkMetadata,dn.tunnel);bn(JSON.stringify(t)),await Sn.send(t);try{n?.postMessage("session-ended")}catch(t){}}}function En(t){if(!t)return;const n=function(t){if(!t.length)return[];const n=Array.from(t);return/sentryWrapped/.test(M(n).function||"")&&n.pop(),n.reverse(),U.test(M(n).function||"")&&(n.pop(),U.test(M(n).function||"")&&n.pop()),n.slice(0,I).map((t=>({...t,filename:t.filename||M(n).filename,function:t.function||P})))}(t);if(dn.appRootPath)for(const t of n)t.filename&&(t.filename=W(t.filename,dn.appRootPath));return n}async function xn(t,n){if(yn)return;yn=!0,await $n(),bn("Sending event");const e={event_id:Y(),contexts:dn.contexts,release:dn.release,environment:dn.environment,dist:dn.dist,platform:"node",level:"error",exception:{values:[{type:"ApplicationNotResponding",value:`Application Not Responding for at least ${dn.anrThreshold} ms`,stacktrace:{frames:En(t)},mechanism:{type:"ANR"}}]},tags:dn.staticTags};n&&function(t,n){if(Qt(t,n),!t.contexts?.trace){const{traceId:e,spanId:r,parentSpanId:o}=n.propagationContext;t.contexts={trace:{trace_id:e,span_id:r,parent_span_id:o},...t.contexts}}}(e,n),function(t){if(0===Object.keys(gn).length)return;const n=new Map;for(const e of t.exception?.values||[])for(const t of e.stacktrace?.frames||[]){const e=t.abs_path||t.filename;e&&gn[e]&&n.set(e,gn[e])}if(n.size>0){const e=[];for(const[t,r]of n.entries())e.push({type:"sourcemap",code_file:t,debug_id:r});t.debug_meta={images:e}}}(e);const r=Vt(e,dn.dsn,dn.sdkMetadata,dn.tunnel);bn(JSON.stringify(r)),await Sn.send(r),await Sn.flush(2e3),setTimeout((()=>{process.exit(0)}),5e3)}let Nn;if(bn("Started"),dn.captureStackTrace){bn("Connecting to debugger");const n=new t;n.connectToMainThread(),bn("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{bn("Debugger paused");const s=[...t.params.callFrames],i=dn.appRootPath?function(t=(process.argv[1]?K(process.argv[1]):process.cwd()),n="\\"===o){const e=n?ln(t):t;return t=>{if(!t)return;const o=n?ln(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)),s||(s=".");const u=s.lastIndexOf("/node_modules");if(u>-1)return`${s.slice(u+14).replace(/\//g,".")}:${i}`;if(s.startsWith(e)){let t=s.slice(e.length+1).replace(/\//g,".");return t&&(t+=":"),t+=i,t}return i}}(dn.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 O({filename:r,module:e(r),function:t.functionName||P,colno:o,lineno:s,in_app:r?X(r):void 0})}(t,e.get(t.location.scriptId),i))),u=setTimeout((()=>{xn(c).then(null,(()=>{bn("Sending ANR event failed.")}))}),5e3);n.post("Runtime.evaluate",{expression:"global.__SENTRY_GET_SCOPES__();",silent:!0,returnByValue:!0},((t,e)=>{t&&bn(`Error executing script: '${t.message}'`),clearTimeout(u);const r=e&&e.result?e.result.value:void 0;n.post("Debugger.resume"),n.post("Debugger.disable"),xn(c,r).then(null,(()=>{bn("Sending ANR event failed.")}))}))}catch(t){throw n.post("Debugger.resume"),n.post("Debugger.disable"),t}})),Nn=()=>{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()}}}),dn.pollInterval,dn.anrThreshold,(function(){bn("Watchdog timeout"),Nn?(bn("Pausing debugger to capture stack trace"),Nn()):(bn("Capturing event without a stack trace"),xn().then(null,(()=>{bn("Sending ANR event failed on watchdog timeout.")})))}));n?.on("message",(t=>{t.session&&(mn=yt(t.session)),t.debugImages&&(gn=t.debugImages),Cn()}));
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import * as diagnosticsChannel from 'node:diagnostics_channel';
|
|
2
2
|
import { defineIntegration, addBreadcrumb } from '@sentry/core';
|
|
3
3
|
|
|
4
|
+
// TODO(v9): Update this name and mention in migration docs.
|
|
4
5
|
const INTEGRATION_NAME = 'ProcessAndThreadBreadcrumbs';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Capture breadcrumbs for child processes and worker threads.
|
|
9
|
+
*/
|
|
10
|
+
const childProcessIntegration = defineIntegration((options = {}) => {
|
|
7
11
|
return {
|
|
8
12
|
name: INTEGRATION_NAME,
|
|
9
13
|
setup(_client) {
|
|
@@ -22,12 +26,14 @@ const _processThreadBreadcrumbIntegration = ((options = {}) => {
|
|
|
22
26
|
});
|
|
23
27
|
},
|
|
24
28
|
};
|
|
25
|
-
})
|
|
29
|
+
});
|
|
26
30
|
|
|
27
31
|
/**
|
|
28
32
|
* Capture breadcrumbs for child processes and worker threads.
|
|
33
|
+
*
|
|
34
|
+
* @deprecated Use `childProcessIntegration` integration instead. Functionally they are the same. `processThreadBreadcrumbIntegration` will be removed in the next major version.
|
|
29
35
|
*/
|
|
30
|
-
const processThreadBreadcrumbIntegration =
|
|
36
|
+
const processThreadBreadcrumbIntegration = childProcessIntegration;
|
|
31
37
|
|
|
32
38
|
function captureChildProcessEvents(child, options) {
|
|
33
39
|
let hasExited = false;
|
|
@@ -92,5 +98,5 @@ function captureWorkerThreadEvents(worker) {
|
|
|
92
98
|
});
|
|
93
99
|
}
|
|
94
100
|
|
|
95
|
-
export { processThreadBreadcrumbIntegration };
|
|
96
|
-
//# sourceMappingURL=
|
|
101
|
+
export { childProcessIntegration, processThreadBreadcrumbIntegration };
|
|
102
|
+
//# sourceMappingURL=childProcess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"childProcess.js","sources":["../../../src/integrations/childProcess.ts"],"sourcesContent":["import type { ChildProcess } from 'node:child_process';\nimport * as diagnosticsChannel from 'node:diagnostics_channel';\nimport type { Worker } from 'node:worker_threads';\nimport { addBreadcrumb, defineIntegration } from '@sentry/core';\n\ninterface Options {\n /**\n * Whether to include child process arguments in breadcrumbs data.\n *\n * @default false\n */\n includeChildProcessArgs?: boolean;\n}\n\n// TODO(v9): Update this name and mention in migration docs.\nconst INTEGRATION_NAME = 'ProcessAndThreadBreadcrumbs';\n\n/**\n * Capture breadcrumbs for child processes and worker threads.\n */\nexport const childProcessIntegration = defineIntegration((options: Options = {}) => {\n return {\n name: INTEGRATION_NAME,\n setup(_client) {\n // eslint-disable-next-line deprecation/deprecation\n diagnosticsChannel.channel('child_process').subscribe((event: unknown) => {\n if (event && typeof event === 'object' && 'process' in event) {\n captureChildProcessEvents(event.process as ChildProcess, options);\n }\n });\n\n // eslint-disable-next-line deprecation/deprecation\n diagnosticsChannel.channel('worker_threads').subscribe((event: unknown) => {\n if (event && typeof event === 'object' && 'worker' in event) {\n captureWorkerThreadEvents(event.worker as Worker);\n }\n });\n },\n };\n});\n\n/**\n * Capture breadcrumbs for child processes and worker threads.\n *\n * @deprecated Use `childProcessIntegration` integration instead. Functionally they are the same. `processThreadBreadcrumbIntegration` will be removed in the next major version.\n */\nexport const processThreadBreadcrumbIntegration = childProcessIntegration;\n\nfunction captureChildProcessEvents(child: ChildProcess, options: Options): void {\n let hasExited = false;\n let data: Record<string, unknown> | undefined;\n\n child\n .on('spawn', () => {\n // This is Sentry getting macOS OS context\n if (child.spawnfile === '/usr/bin/sw_vers') {\n hasExited = true;\n return;\n }\n\n data = { spawnfile: child.spawnfile };\n if (options.includeChildProcessArgs) {\n data.spawnargs = child.spawnargs;\n }\n })\n .on('exit', code => {\n if (!hasExited) {\n hasExited = true;\n\n // Only log for non-zero exit codes\n if (code !== null && code !== 0) {\n addBreadcrumb({\n category: 'child_process',\n message: `Child process exited with code '${code}'`,\n level: 'warning',\n data,\n });\n }\n }\n })\n .on('error', error => {\n if (!hasExited) {\n hasExited = true;\n\n addBreadcrumb({\n category: 'child_process',\n message: `Child process errored with '${error.message}'`,\n level: 'error',\n data,\n });\n }\n });\n}\n\nfunction captureWorkerThreadEvents(worker: Worker): void {\n let threadId: number | undefined;\n\n worker\n .on('online', () => {\n threadId = worker.threadId;\n })\n .on('error', error => {\n addBreadcrumb({\n category: 'worker_thread',\n message: `Worker thread errored with '${error.message}'`,\n level: 'error',\n data: { threadId },\n });\n });\n}\n"],"names":[],"mappings":";;;AAcA;AACA,MAAM,gBAAA,GAAmB,6BAA6B;;AAEtD;AACA;AACA;AACa,MAAA,uBAAA,GAA0B,iBAAiB,CAAC,CAAC,OAAO,GAAY,EAAE,KAAK;AACpF,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,CAAC,OAAO,EAAE;AACnB;AACA,MAAM,kBAAkB,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,KAAc;AAChF,QAAQ,IAAI,KAAM,IAAG,OAAO,KAAA,KAAU,QAAA,IAAY,SAAA,IAAa,KAAK,EAAE;AACtE,UAAU,yBAAyB,CAAC,KAAK,CAAC,OAAQ,GAAiB,OAAO,CAAC;AAC3E;AACA,OAAO,CAAC;;AAER;AACA,MAAM,kBAAkB,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,KAAc;AACjF,QAAQ,IAAI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,eAAe;AACnC,UAAU,OAAO,EAAE,CAAC,4BAA4B,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AAClE,UAAU,KAAK,EAAE,OAAO;AACxB,UAAU,IAAI;AACd,SAAS,CAAC;AACV;AACA,KAAK,CAAC;AACN;;AAEA,SAAS,yBAAyB,CAAC,MAAM,EAAgB;AACzD,EAAE,IAAI,QAAQ;;AAEd,EAAE;AACF,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM;AACxB,MAAM,QAAS,GAAE,MAAM,CAAC,QAAQ;AAChC,KAAK;AACL,KAAK,EAAE,CAAC,OAAO,EAAE,SAAS;AAC1B,MAAM,aAAa,CAAC;AACpB,QAAQ,QAAQ,EAAE,eAAe;AACjC,QAAQ,OAAO,EAAE,CAAC,4BAA4B,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AAChE,QAAQ,KAAK,EAAE,OAAO;AACtB,QAAQ,IAAI,EAAE,EAAE,QAAA,EAAU;AAC1B,OAAO,CAAC;AACR,KAAK,CAAC;AACN;;;;"}
|
|
@@ -2,9 +2,13 @@ import { VERSION } from '@opentelemetry/core';
|
|
|
2
2
|
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
|
|
3
3
|
import { getRequestInfo } from '@opentelemetry/instrumentation-http';
|
|
4
4
|
import { getIsolationScope, getClient, withIsolationScope, addBreadcrumb } from '@sentry/core';
|
|
5
|
-
import { stripUrlQueryAndFragment, getBreadcrumbLogLevelFromHttpStatusCode, parseUrl, getSanitizedUrlString } from '@sentry/utils';
|
|
5
|
+
import { stripUrlQueryAndFragment, getBreadcrumbLogLevelFromHttpStatusCode, parseUrl, getSanitizedUrlString, logger } from '@sentry/utils';
|
|
6
|
+
import { DEBUG_BUILD } from '../../debug-build.js';
|
|
6
7
|
import { getRequestUrl } from '../../utils/getRequestUrl.js';
|
|
7
8
|
|
|
9
|
+
// We only want to capture request bodies up to 1mb.
|
|
10
|
+
const MAX_BODY_BYTE_LENGTH = 1024 * 1024;
|
|
11
|
+
|
|
8
12
|
/**
|
|
9
13
|
* This custom HTTP instrumentation is used to isolate incoming requests and annotate them with additional information.
|
|
10
14
|
* It does not emit any spans.
|
|
@@ -94,8 +98,27 @@ class SentryHttpInstrumentation extends InstrumentationBase {
|
|
|
94
98
|
|
|
95
99
|
const isolationScope = getIsolationScope().clone();
|
|
96
100
|
|
|
101
|
+
const headers = request.headers;
|
|
102
|
+
const host = headers.host || '<no host>';
|
|
103
|
+
const protocol = request.socket && (request.socket ).encrypted ? 'https' : 'http';
|
|
104
|
+
const originalUrl = request.url || '';
|
|
105
|
+
const absoluteUrl = originalUrl.startsWith(protocol) ? originalUrl : `${protocol}://${host}${originalUrl}`;
|
|
106
|
+
|
|
107
|
+
// This is non-standard, but may be set on e.g. Next.js or Express requests
|
|
108
|
+
const cookies = (request ).cookies;
|
|
109
|
+
|
|
110
|
+
const normalizedRequest = {
|
|
111
|
+
url: absoluteUrl,
|
|
112
|
+
method: request.method,
|
|
113
|
+
query_string: extractQueryParams(request),
|
|
114
|
+
headers: headersToDict(request.headers),
|
|
115
|
+
cookies,
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
patchRequestToCaptureBody(request, normalizedRequest);
|
|
119
|
+
|
|
97
120
|
// Update the isolation scope, isolate this request
|
|
98
|
-
isolationScope.setSDKProcessingMetadata({ request });
|
|
121
|
+
isolationScope.setSDKProcessingMetadata({ request, normalizedRequest });
|
|
99
122
|
|
|
100
123
|
const client = getClient();
|
|
101
124
|
if (client && client.getOptions().autoSessionTracking) {
|
|
@@ -277,10 +300,142 @@ function getBreadcrumbData(request) {
|
|
|
277
300
|
}
|
|
278
301
|
|
|
279
302
|
return data;
|
|
280
|
-
} catch (
|
|
303
|
+
} catch (e2) {
|
|
281
304
|
return {};
|
|
282
305
|
}
|
|
283
306
|
}
|
|
284
307
|
|
|
308
|
+
/**
|
|
309
|
+
* This method patches the request object to capture the body.
|
|
310
|
+
* Instead of actually consuming the streamed body ourselves, which has potential side effects,
|
|
311
|
+
* we monkey patch `req.on('data')` to intercept the body chunks.
|
|
312
|
+
* This way, we only read the body if the user also consumes the body, ensuring we do not change any behavior in unexpected ways.
|
|
313
|
+
*/
|
|
314
|
+
function patchRequestToCaptureBody(req, normalizedRequest) {
|
|
315
|
+
const chunks = [];
|
|
316
|
+
|
|
317
|
+
function getChunksSize() {
|
|
318
|
+
return chunks.reduce((acc, chunk) => acc + chunk.byteLength, 0);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* We need to keep track of the original callbacks, in order to be able to remove listeners again.
|
|
323
|
+
* Since `off` depends on having the exact same function reference passed in, we need to be able to map
|
|
324
|
+
* original listeners to our wrapped ones.
|
|
325
|
+
*/
|
|
326
|
+
const callbackMap = new WeakMap();
|
|
327
|
+
|
|
328
|
+
try {
|
|
329
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
330
|
+
req.on = new Proxy(req.on, {
|
|
331
|
+
apply: (target, thisArg, args) => {
|
|
332
|
+
const [event, listener, ...restArgs] = args;
|
|
333
|
+
|
|
334
|
+
if (event === 'data') {
|
|
335
|
+
const callback = new Proxy(listener, {
|
|
336
|
+
apply: (target, thisArg, args) => {
|
|
337
|
+
// If we have already read more than the max body length, we stop addiing chunks
|
|
338
|
+
// To avoid growing the memory indefinitely if a respons is e.g. streamed
|
|
339
|
+
if (getChunksSize() < MAX_BODY_BYTE_LENGTH) {
|
|
340
|
+
const chunk = args[0] ;
|
|
341
|
+
chunks.push(chunk);
|
|
342
|
+
} else if (DEBUG_BUILD) {
|
|
343
|
+
logger.log(
|
|
344
|
+
`Dropping request body chunk because it maximum body length of ${MAX_BODY_BYTE_LENGTH}b is exceeded.`,
|
|
345
|
+
);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
return Reflect.apply(target, thisArg, args);
|
|
349
|
+
},
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
callbackMap.set(listener, callback);
|
|
353
|
+
|
|
354
|
+
return Reflect.apply(target, thisArg, [event, callback, ...restArgs]);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
if (event === 'end') {
|
|
358
|
+
const callback = new Proxy(listener, {
|
|
359
|
+
apply: (target, thisArg, args) => {
|
|
360
|
+
try {
|
|
361
|
+
const body = Buffer.concat(chunks).toString('utf-8');
|
|
362
|
+
|
|
363
|
+
// We mutate the passed in normalizedRequest and add the body to it
|
|
364
|
+
if (body) {
|
|
365
|
+
normalizedRequest.data = body;
|
|
366
|
+
}
|
|
367
|
+
} catch (e3) {
|
|
368
|
+
// ignore errors here
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
return Reflect.apply(target, thisArg, args);
|
|
372
|
+
},
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
callbackMap.set(listener, callback);
|
|
376
|
+
|
|
377
|
+
return Reflect.apply(target, thisArg, [event, callback, ...restArgs]);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
return Reflect.apply(target, thisArg, args);
|
|
381
|
+
},
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
// Ensure we also remove callbacks correctly
|
|
385
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
386
|
+
req.off = new Proxy(req.off, {
|
|
387
|
+
apply: (target, thisArg, args) => {
|
|
388
|
+
const [, listener] = args;
|
|
389
|
+
|
|
390
|
+
const callback = callbackMap.get(listener);
|
|
391
|
+
if (callback) {
|
|
392
|
+
callbackMap.delete(listener);
|
|
393
|
+
|
|
394
|
+
const modifiedArgs = args.slice();
|
|
395
|
+
modifiedArgs[1] = callback;
|
|
396
|
+
return Reflect.apply(target, thisArg, modifiedArgs);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
return Reflect.apply(target, thisArg, args);
|
|
400
|
+
},
|
|
401
|
+
});
|
|
402
|
+
} catch (e4) {
|
|
403
|
+
// ignore errors if we can't patch stuff
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function extractQueryParams(req) {
|
|
408
|
+
// req.url is path and query string
|
|
409
|
+
if (!req.url) {
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
try {
|
|
414
|
+
// The `URL` constructor can't handle internal URLs of the form `/some/path/here`, so stick a dummy protocol and
|
|
415
|
+
// hostname as the base. Since the point here is just to grab the query string, it doesn't matter what we use.
|
|
416
|
+
const queryParams = new URL(req.url, 'http://dogs.are.great').search.slice(1);
|
|
417
|
+
return queryParams.length ? queryParams : undefined;
|
|
418
|
+
} catch (e5) {
|
|
419
|
+
return undefined;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
function headersToDict(reqHeaders) {
|
|
424
|
+
const headers = Object.create(null);
|
|
425
|
+
|
|
426
|
+
try {
|
|
427
|
+
Object.entries(reqHeaders).forEach(([key, value]) => {
|
|
428
|
+
if (typeof value === 'string') {
|
|
429
|
+
headers[key] = value;
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
} catch (e) {
|
|
433
|
+
DEBUG_BUILD &&
|
|
434
|
+
logger.warn('Sentry failed extracting headers from a request object. If you see this, please file an issue.');
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
return headers;
|
|
438
|
+
}
|
|
439
|
+
|
|
285
440
|
export { SentryHttpInstrumentation };
|
|
286
441
|
//# sourceMappingURL=SentryHttpInstrumentation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SentryHttpInstrumentation.js","sources":["../../../../src/integrations/http/SentryHttpInstrumentation.ts"],"sourcesContent":["import type * as http from 'node:http';\nimport type { RequestOptions } from 'node:http';\nimport type * as https from 'node:https';\nimport { VERSION } from '@opentelemetry/core';\nimport type { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';\nimport { getRequestInfo } from '@opentelemetry/instrumentation-http';\nimport { addBreadcrumb, getClient, getIsolationScope, withIsolationScope } from '@sentry/core';\nimport type { SanitizedRequestData } from '@sentry/types';\nimport {\n getBreadcrumbLogLevelFromHttpStatusCode,\n getSanitizedUrlString,\n parseUrl,\n stripUrlQueryAndFragment,\n} from '@sentry/utils';\nimport type { NodeClient } from '../../sdk/client';\nimport { getRequestUrl } from '../../utils/getRequestUrl';\n\ntype Http = typeof http;\ntype Https = typeof https;\n\ntype SentryHttpInstrumentationOptions = InstrumentationConfig & {\n /**\n * Whether breadcrumbs should be recorded for requests.\n *\n * @default `true`\n */\n breadcrumbs?: boolean;\n\n /**\n * Do not capture breadcrumbs 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/**\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\n return (\n original: (event: string, ...args: unknown[]) => boolean,\n ): ((this: unknown, event: string, ...args: unknown[]) => boolean) => {\n return function incomingRequest(this: unknown, event: string, ...args: unknown[]): boolean {\n // Only traces request events\n if (event !== 'request') {\n return original.apply(this, [event, ...args]);\n }\n\n instrumentation._diag.debug('http instrumentation for incoming request');\n\n const request = args[0] as http.IncomingMessage;\n\n const isolationScope = getIsolationScope().clone();\n\n // Update the isolation scope, isolate this request\n isolationScope.setSDKProcessingMetadata({ request });\n\n const client = getClient<NodeClient>();\n if (client && client.getOptions().autoSessionTracking) {\n isolationScope.setRequestSession({ status: 'ok' });\n }\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(request.url || '/');\n\n const bestEffortTransactionName = `${httpMethod} ${httpTarget}`;\n\n isolationScope.setTransactionName(bestEffortTransactionName);\n\n return withIsolationScope(isolationScope, () => {\n return original.apply(this, [event, ...args]);\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(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/**\n * This is a minimal version of `wrap` from shimmer:\n * https://github.com/othiym23/shimmer/blob/master/index.js\n *\n * In contrast to the original implementation, this version does not allow to unwrap,\n * and does not make it clear that the method is wrapped.\n * This is necessary because we want to wrap the http module with our own code,\n * while still allowing to use the HttpInstrumentation from OTEL.\n *\n * Without this, if we'd just use `wrap` from shimmer, the OTEL instrumentation would remove our wrapping,\n * because it only allows any module to be wrapped a single time.\n */\nfunction stealthWrap<Nodule extends object, FieldName extends keyof Nodule>(\n nodule: Nodule,\n name: FieldName,\n wrapper: (original: Nodule[FieldName]) => Nodule[FieldName],\n): Nodule[FieldName] {\n const original = nodule[name];\n const wrapped = wrapper(original);\n\n defineProperty(nodule, name, wrapped);\n return wrapped;\n}\n\n// Sets a property on an object, preserving its enumerability.\nfunction defineProperty<Nodule extends object, FieldName extends keyof Nodule>(\n obj: Nodule,\n name: FieldName,\n value: Nodule[FieldName],\n): void {\n const enumerable = !!obj[name] && Object.prototype.propertyIsEnumerable.call(obj, name);\n\n Object.defineProperty(obj, name, {\n configurable: true,\n enumerable: enumerable,\n writable: true,\n value: value,\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"],"names":[],"mappings":";;;;;;;AAyCA;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,IAA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A,GAAA,CAAA,OAAA,CAAA,EAAA;AACA,IAAA,OAAA,EAAA;AACA;AACA;;;;"}
|
|
1
|
+
{"version":3,"file":"SentryHttpInstrumentation.js","sources":["../../../../src/integrations/http/SentryHttpInstrumentation.ts"],"sourcesContent":["import type * as http from 'node:http';\nimport type { IncomingMessage, RequestOptions } from 'node:http';\nimport type * as https from 'node:https';\nimport { VERSION } from '@opentelemetry/core';\nimport type { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';\nimport { getRequestInfo } from '@opentelemetry/instrumentation-http';\nimport { addBreadcrumb, getClient, getIsolationScope, withIsolationScope } from '@sentry/core';\nimport type { PolymorphicRequest, RequestEventData, SanitizedRequestData } from '@sentry/types';\nimport {\n getBreadcrumbLogLevelFromHttpStatusCode,\n getSanitizedUrlString,\n logger,\n parseUrl,\n stripUrlQueryAndFragment,\n} from '@sentry/utils';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport type { NodeClient } from '../../sdk/client';\nimport { getRequestUrl } from '../../utils/getRequestUrl';\n\ntype Http = typeof http;\ntype Https = typeof https;\n\ntype SentryHttpInstrumentationOptions = InstrumentationConfig & {\n /**\n * Whether breadcrumbs should be recorded for requests.\n *\n * @default `true`\n */\n breadcrumbs?: boolean;\n\n /**\n * Do not capture breadcrumbs 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// 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\n return (\n original: (event: string, ...args: unknown[]) => boolean,\n ): ((this: unknown, event: string, ...args: unknown[]) => boolean) => {\n return function incomingRequest(this: unknown, event: string, ...args: unknown[]): boolean {\n // Only traces request events\n if (event !== 'request') {\n return original.apply(this, [event, ...args]);\n }\n\n instrumentation._diag.debug('http instrumentation for incoming request');\n\n const request = args[0] as http.IncomingMessage;\n\n const isolationScope = getIsolationScope().clone();\n\n const headers = request.headers;\n const host = headers.host || '<no host>';\n const protocol = request.socket && (request.socket as { encrypted?: boolean }).encrypted ? 'https' : 'http';\n const originalUrl = request.url || '';\n const absoluteUrl = originalUrl.startsWith(protocol) ? originalUrl : `${protocol}://${host}${originalUrl}`;\n\n // This is non-standard, but may be set on e.g. Next.js or Express requests\n const cookies = (request as PolymorphicRequest).cookies;\n\n const normalizedRequest: RequestEventData = {\n url: absoluteUrl,\n method: request.method,\n query_string: extractQueryParams(request),\n headers: headersToDict(request.headers),\n cookies,\n };\n\n patchRequestToCaptureBody(request, normalizedRequest);\n\n // Update the isolation scope, isolate this request\n isolationScope.setSDKProcessingMetadata({ request, normalizedRequest });\n\n const client = getClient<NodeClient>();\n if (client && client.getOptions().autoSessionTracking) {\n isolationScope.setRequestSession({ status: 'ok' });\n }\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(request.url || '/');\n\n const bestEffortTransactionName = `${httpMethod} ${httpTarget}`;\n\n isolationScope.setTransactionName(bestEffortTransactionName);\n\n return withIsolationScope(isolationScope, () => {\n return original.apply(this, [event, ...args]);\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(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/**\n * This is a minimal version of `wrap` from shimmer:\n * https://github.com/othiym23/shimmer/blob/master/index.js\n *\n * In contrast to the original implementation, this version does not allow to unwrap,\n * and does not make it clear that the method is wrapped.\n * This is necessary because we want to wrap the http module with our own code,\n * while still allowing to use the HttpInstrumentation from OTEL.\n *\n * Without this, if we'd just use `wrap` from shimmer, the OTEL instrumentation would remove our wrapping,\n * because it only allows any module to be wrapped a single time.\n */\nfunction stealthWrap<Nodule extends object, FieldName extends keyof Nodule>(\n nodule: Nodule,\n name: FieldName,\n wrapper: (original: Nodule[FieldName]) => Nodule[FieldName],\n): Nodule[FieldName] {\n const original = nodule[name];\n const wrapped = wrapper(original);\n\n defineProperty(nodule, name, wrapped);\n return wrapped;\n}\n\n// Sets a property on an object, preserving its enumerability.\nfunction defineProperty<Nodule extends object, FieldName extends keyof Nodule>(\n obj: Nodule,\n name: FieldName,\n value: Nodule[FieldName],\n): void {\n const enumerable = !!obj[name] && Object.prototype.propertyIsEnumerable.call(obj, name);\n\n Object.defineProperty(obj, name, {\n configurable: true,\n enumerable: enumerable,\n writable: true,\n value: value,\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, normalizedRequest: RequestEventData): 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 addiing chunks\n // To avoid growing the memory indefinitely if a respons 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 // We mutate the passed in normalizedRequest and add the body to it\n if (body) {\n normalizedRequest.data = body;\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\nfunction extractQueryParams(req: IncomingMessage): string | undefined {\n // req.url is path and query string\n if (!req.url) {\n return;\n }\n\n try {\n // The `URL` constructor can't handle internal URLs of the form `/some/path/here`, so stick a dummy protocol and\n // hostname as the base. Since the point here is just to grab the query string, it doesn't matter what we use.\n const queryParams = new URL(req.url, 'http://dogs.are.great').search.slice(1);\n return queryParams.length ? queryParams : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction headersToDict(reqHeaders: Record<string, string | string[] | undefined>): Record<string, string> {\n const headers: Record<string, string> = Object.create(null);\n\n try {\n Object.entries(reqHeaders).forEach(([key, value]) => {\n if (typeof value === 'string') {\n headers[key] = value;\n }\n });\n } catch (e) {\n DEBUG_BUILD &&\n logger.warn('Sentry failed extracting headers from a request object. If you see this, please file an issue.');\n }\n\n return headers;\n}\n"],"names":[],"mappings":";;;;;;;;AA2CA;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,OAAO,aAAa;AAC5B,OAAO;AACP,MAAM,MAAM;AACZ;AACA,OAAO;AACP,KAAK;AACL;;AAEA;AACA,GAAU,wBAAwB,GAAwC;AAC1E,IAAI,OAAO,IAAI,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CAAA,GAAA,KAAA;AACA;AACA,KAAA,CAAA;AACA,GAAA,CAAA,OAAA,CAAA,EAAA;AACA,IAAA,WAAA;AACA,MAAA,MAAA,CAAA,IAAA,CAAA,gGAAA,CAAA;AACA;;AAEA,EAAA,OAAA,OAAA;AACA;;;;"}
|
|
@@ -5,7 +5,7 @@ import { logger } from '@sentry/utils';
|
|
|
5
5
|
import { LOCAL_VARIABLES_KEY, functionNamesMatch } from './common.js';
|
|
6
6
|
|
|
7
7
|
// This string is a placeholder that gets overwritten with the worker code.
|
|
8
|
-
const base64WorkerScript = '
|
|
8
|
+
const base64WorkerScript = 'LyohIEBzZW50cnkvbm9kZSA4LjM5LjAgKGM1MjQ3OGQpIHwgaHR0cHM6Ly9naXRodWIuY29tL2dldHNlbnRyeS9zZW50cnktamF2YXNjcmlwdCAqLwppbXBvcnR7U2Vzc2lvbiBhcyBlfWZyb20ibm9kZTppbnNwZWN0b3IvcHJvbWlzZXMiO2ltcG9ydHt3b3JrZXJEYXRhIGFzIHR9ZnJvbSJub2RlOndvcmtlcl90aHJlYWRzIjtjb25zdCBuPSI4LjM5LjAiLG89Z2xvYmFsVGhpcztjb25zdCBpPSJ1bmRlZmluZWQiPT10eXBlb2YgX19TRU5UUllfREVCVUdfX3x8X19TRU5UUllfREVCVUdfXyxhPVsiZGVidWciLCJpbmZvIiwid2FybiIsImVycm9yIiwibG9nIiwiYXNzZXJ0IiwidHJhY2UiXSxzPXt9O2Z1bmN0aW9uIGMoZSl7aWYoISgiY29uc29sZSJpbiBvKSlyZXR1cm4gZSgpO2NvbnN0IHQ9by5jb25zb2xlLG49e30saT1PYmplY3Qua2V5cyhzKTtpLmZvckVhY2goKGU9Pntjb25zdCBvPXNbZV07bltlXT10W2VdLHRbZV09b30pKTt0cnl7cmV0dXJuIGUoKX1maW5hbGx5e2kuZm9yRWFjaCgoZT0+e3RbZV09bltlXX0pKX19IWZ1bmN0aW9uKGUsdCxpKXtjb25zdCBhPW8scz1hLl9fU0VOVFJ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