@sailfish-ai/sf-veritas 0.2.20 → 0.3.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.
Files changed (40) hide show
  1. package/dist/consoleLocationTransformer-BSSB5msZ.cjs +1 -0
  2. package/dist/consoleLocationTransformer-DZu_9MDA.js +51 -0
  3. package/dist/contextManager-0D8uHQ1_.cjs +1 -0
  4. package/dist/{contextManager-Dw7Yot7r.js → contextManager-RxrMXs5c.js} +106 -83
  5. package/dist/plugins/funcspanEsbuildPlugin.cjs +1 -1
  6. package/dist/plugins/funcspanEsbuildPlugin.mjs +20 -16
  7. package/dist/plugins/funcspanRollupPlugin.cjs +1 -1
  8. package/dist/plugins/funcspanRollupPlugin.mjs +17 -13
  9. package/dist/plugins/funcspanTscPlugin.cjs +1 -1
  10. package/dist/plugins/funcspanTscPlugin.mjs +34 -30
  11. package/dist/plugins/funcspanVitePlugin.cjs +1 -1
  12. package/dist/plugins/funcspanVitePlugin.mjs +16 -12
  13. package/dist/plugins/funcspanWebpackLoader.cjs +1 -1
  14. package/dist/plugins/funcspanWebpackLoader.mjs +55 -50
  15. package/dist/plugins/funcspanWebpackPlugin.cjs +1 -1
  16. package/dist/plugins/funcspanWebpackPlugin.mjs +1 -1
  17. package/dist/runtimeConfig-BZ61efqE.js +485 -0
  18. package/dist/runtimeConfig-CWpFWsmz.cjs +6 -0
  19. package/dist/sf-veritas.cjs +25 -13
  20. package/dist/sf-veritas.mjs +453 -393
  21. package/dist/telemetryWorker.cjs +1 -0
  22. package/dist/types/dataTransmitter.d.ts +6 -5
  23. package/dist/types/exceptionTransmitter.d.ts +2 -1
  24. package/dist/types/frameworkDetection.d.ts +18 -0
  25. package/dist/types/networkHopTransmitter.d.ts +2 -1
  26. package/dist/types/networkRequestTransmitter.d.ts +2 -1
  27. package/dist/types/plugins/consoleLocationTransformer.d.ts +37 -0
  28. package/dist/types/requestUtils.d.ts +17 -6
  29. package/dist/types/setupConfig.d.ts +3 -0
  30. package/dist/types/sourceLocation.d.ts +19 -19
  31. package/dist/types/telemetryWorker.d.ts +1 -0
  32. package/dist/worker-pool-capture.cjs +1 -1
  33. package/dist/worker-pool-capture.mjs +1 -1
  34. package/dist/workerPoolSpanCapture-Bg5av6gn.cjs +83 -0
  35. package/dist/{workerPoolSpanCapture-Dm4Reseo.js → workerPoolSpanCapture-BjdZn3LE.js} +222 -168
  36. package/package.json +1 -1
  37. package/dist/contextManager-DQMeQfS_.cjs +0 -1
  38. package/dist/runtimeConfig-Bfqf33tO.js +0 -444
  39. package/dist/runtimeConfig-DmD4lUhG.cjs +0 -9
  40. package/dist/workerPoolSpanCapture-CAM2z9Jx.cjs +0 -83
@@ -0,0 +1 @@
1
+ "use strict";const O=require("@babel/parser"),b=require("@babel/traverse"),T=require("@babel/generator"),v=require("@babel/types"),h=require("path"),w=require("fs"),x=require("./source-map-rHHEdpre.cjs");function M(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const n in r)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:()=>r[n]})}}return e.default=r,Object.freeze(e)}const i=M(v),P=b.default||b,I=T.default||T,$="__sf:",_=new Set(["log","error","warn","info","debug"]),E=[/instrumentation\.(ts|js|tsx|jsx)$/,/unifiedInterceptor\.(ts|js)$/];exports.transformConsoleLocations=async function(r,e,n={}){const{projectRoot:s=process.cwd(),includeNodeModules:C=[],debug:d=!1}=n;if(e.includes("node_modules")&&!C.some(o=>e.includes(`node_modules/${o}`)))return{code:r,modified:!1,callsTransformed:0};if(e.includes("sf-veritas")||e.includes("@sailfish-ai")||e.includes("jsts-backend")||e.includes("jsts-frontend"))return{code:r,modified:!1,callsTransformed:0};if(E.some(o=>o.test(e)))return{code:r,modified:!1,callsTransformed:0};const c=h.relative(s,e).replace(/\\/g,"/");let f;d&&console.log(`[ConsoleLocation Transform] Processing: ${c}`);try{f=O.parse(r,{sourceType:"module",plugins:["typescript","jsx","decorators-legacy","classProperties","objectRestSpread","asyncGenerators","dynamicImport","optionalCatchBinding","optionalChaining","nullishCoalescingOperator"]})}catch(o){return d&&console.error(`[ConsoleLocation Transform] Parse error in ${c}:`,o),{code:r,modified:!1,callsTransformed:0}}let m=null;try{const o=w.readFileSync(`${e}.map`,"utf-8");m=await new x.sourceMapExports.SourceMapConsumer(JSON.parse(o))}catch{}let l=0;if(P(f,{CallExpression(o){const{callee:a}=o.node;if(!(i.isMemberExpression(a)&&i.isIdentifier(a.object,{name:"console"})&&i.isIdentifier(a.property)&&_.has(a.property.name)))return;const p=o.node.arguments;if(p.length>0){const t=p[p.length-1];if(i.isStringLiteral(t)&&t.value.startsWith($))return}const u=o.node.loc,g=((t,L)=>{if(m){const y=m.originalPositionFor({line:t,column:L});if(y.line!==null)return{line:y.line,source:y.source||void 0}}return{line:t}})(u?u.start.line:0,u?u.start.column:0),S=g.source?h.relative(s,g.source).replace(/\\/g,"/"):c,q=`${$}${S}:${g.line}`;o.node.arguments.push(i.stringLiteral(q)),l++}}),l===0)return{code:r,modified:!1,callsTransformed:0};const j=I(f,{retainLines:!0,compact:!1,sourceMaps:!0,sourceFileName:e},r);return d&&console.log(`[ConsoleLocation Transform] ✅ Transformed ${l} console calls in ${c}`),{code:j.code,map:j.map,modified:!0,callsTransformed:l}};
@@ -0,0 +1,51 @@
1
+ import { parse as w } from "@babel/parser";
2
+ import y from "@babel/traverse";
3
+ import T from "@babel/generator";
4
+ import * as n from "@babel/types";
5
+ import { relative as $ } from "path";
6
+ import { readFileSync as v } from "fs";
7
+ import { s as I } from "./source-map-Cr6YkjTd.js";
8
+ const M = y.default || y, P = T.default || T, j = "__sf:", _ = /* @__PURE__ */ new Set(["log", "error", "warn", "info", "debug"]), F = [/instrumentation\.(ts|js|tsx|jsx)$/, /unifiedInterceptor\.(ts|js)$/];
9
+ async function G(s, o, C = {}) {
10
+ const { projectRoot: g = process.cwd(), includeNodeModules: b = [], debug: c = !1 } = C;
11
+ if (o.includes("node_modules") && !b.some((e) => o.includes(`node_modules/${e}`))) return { code: s, modified: !1, callsTransformed: 0 };
12
+ if (o.includes("sf-veritas") || o.includes("@sailfish-ai") || o.includes("jsts-backend") || o.includes("jsts-frontend")) return { code: s, modified: !1, callsTransformed: 0 };
13
+ if (F.some((e) => e.test(o))) return { code: s, modified: !1, callsTransformed: 0 };
14
+ const t = $(g, o).replace(/\\/g, "/");
15
+ let d;
16
+ c && console.log(`[ConsoleLocation Transform] Processing: ${t}`);
17
+ try {
18
+ d = w(s, { sourceType: "module", plugins: ["typescript", "jsx", "decorators-legacy", "classProperties", "objectRestSpread", "asyncGenerators", "dynamicImport", "optionalCatchBinding", "optionalChaining", "nullishCoalescingOperator"] });
19
+ } catch (e) {
20
+ return c && console.error(`[ConsoleLocation Transform] Parse error in ${t}:`, e), { code: s, modified: !1, callsTransformed: 0 };
21
+ }
22
+ let m = null;
23
+ try {
24
+ const e = v(`${o}.map`, "utf-8");
25
+ m = await new I.SourceMapConsumer(JSON.parse(e));
26
+ } catch {
27
+ }
28
+ let i = 0;
29
+ if (M(d, { CallExpression(e) {
30
+ const { callee: a } = e.node;
31
+ if (!(n.isMemberExpression(a) && n.isIdentifier(a.object, { name: "console" }) && n.isIdentifier(a.property) && _.has(a.property.name))) return;
32
+ const u = e.node.arguments;
33
+ if (u.length > 0) {
34
+ const r = u[u.length - 1];
35
+ if (n.isStringLiteral(r) && r.value.startsWith(j)) return;
36
+ }
37
+ const l = e.node.loc, f = ((r, S) => {
38
+ if (m) {
39
+ const p = m.originalPositionFor({ line: r, column: S });
40
+ if (p.line !== null) return { line: p.line, source: p.source || void 0 };
41
+ }
42
+ return { line: r };
43
+ })(l ? l.start.line : 0, l ? l.start.column : 0), x = f.source ? $(g, f.source).replace(/\\/g, "/") : t, L = `${j}${x}:${f.line}`;
44
+ e.node.arguments.push(n.stringLiteral(L)), i++;
45
+ } }), i === 0) return { code: s, modified: !1, callsTransformed: 0 };
46
+ const h = P(d, { retainLines: !0, compact: !1, sourceMaps: !0, sourceFileName: o }, s);
47
+ return c && console.log(`[ConsoleLocation Transform] ✅ Transformed ${i} console calls in ${t}`), { code: h.code, map: h.map, modified: !0, callsTransformed: i };
48
+ }
49
+ export {
50
+ G as t
51
+ };
@@ -0,0 +1 @@
1
+ "use strict";const L=require("async_hooks"),x=require("child_process"),T=require("fs"),b=require("fs/promises"),G=require("os");function U(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const V=U(b),N=U(G),i=[];for(let s=0;s<256;++s)i.push((s+256).toString(16).slice(1));let f;const k=new Uint8Array(16),A={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function I(s,e,t){if(A.randomUUID&&!s)return A.randomUUID();const r=(s=s||{}).random??s.rng?.()??(function(){if(!f){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");f=crypto.getRandomValues.bind(crypto)}return f(k)})();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=15&r[6]|64,r[8]=63&r[8]|128,(function(n,o=0){return(i[n[o+0]]+i[n[o+1]]+i[n[o+2]]+i[n[o+3]]+"-"+i[n[o+4]]+i[n[o+5]]+"-"+i[n[o+6]]+i[n[o+7]]+"-"+i[n[o+8]]+i[n[o+9]]+"-"+i[n[o+10]]+i[n[o+11]]+i[n[o+12]]+i[n[o+13]]+i[n[o+14]]+i[n[o+15]]).toLowerCase()})(r)}class F{apiKey;apiGraphqlEndpoint;sfDebug;serviceIdentifier;serviceVersion;serviceUUID;serviceAdditionalMetadata;profilingModeEnabled;profilingMaxDepth;profilingMaxVariableSizeKb;domainsToNotPropagateHeadersTo;nodeModulesToCollectLocalVariablesOn;printConfigurationStatuses;logLevel;stackDepthLocals;stackDepthCodeTraceDepth;packageLibraryType;version;gitSha;gitOrg;gitRepo;gitProvider;serviceDisplayName;infrastructureType;infrastructureDetails;framework;additionalFrameworks;serviceRole;setupInterceptorsFile;setupInterceptorsLine;logIgnoreRegex;captureRequestHeaders;captureResponseHeaders;captureRequestBody;captureResponseBody;requestBodyLimitBytes;responseBodyLimitBytes;_serviceIdentificationReceived=!1;constructor(e){this.apiKey=e.apiKey,this.apiGraphqlEndpoint=e?.apiGraphqlEndpoint||process.env.SAILFISH_GRAPHQL_ENDPOINT||"https://api-service.sailfishqa.com/graphql/",this.sfDebug=e?.debug===!0||process.env.SF_DEBUG==="true",this.serviceIdentifier=e?.serviceIdentifier||process.env.SERVICE_IDENTIFIER,this.serviceUUID=I(),this.serviceVersion=e?.serviceVersion||process.env.SERVICE_VERSION,this.gitSha=e?.gitSha||process.env.GIT_SHA||process.env.GITHUB_SHA||process.env.CI_COMMIT_SHA||process.env.BITBUCKET_COMMIT||process.env.VERCEL_GIT_COMMIT_SHA||process.env.CIRCLE_SHA1||process.env.HEROKU_SLUG_COMMIT||process.env.RENDER_GIT_COMMIT||process.env.RAILWAY_GIT_COMMIT_SHA||process.env.CODEBUILD_RESOLVED_SOURCE_VERSION;const t=process.env.GITHUB_REPOSITORY?.split("/");this.gitOrg=e?.gitOrg||process.env.GIT_ORG||(t&&t.length>=2?t[0]:void 0)||process.env.CI_PROJECT_NAMESPACE||process.env.BITBUCKET_REPO_OWNER||process.env.VERCEL_GIT_REPO_OWNER||process.env.CIRCLE_PROJECT_USERNAME,this.gitRepo=e?.gitRepo||process.env.GIT_REPO||(t&&t.length>=2?t.slice(1).join("/"):void 0)||process.env.CI_PROJECT_NAME||process.env.BITBUCKET_REPO_SLUG||process.env.VERCEL_GIT_REPO_SLUG||process.env.CIRCLE_PROJECT_REPONAME,this.gitProvider=e?.gitProvider||process.env.GIT_PROVIDER||(process.env.GITHUB_ACTIONS?"github":void 0)||(process.env.GITLAB_CI?"gitlab":void 0)||(process.env.BITBUCKET_PIPELINE_UUID?"bitbucket":void 0)||(process.env.CIRCLECI?"circleci":void 0),this.serviceDisplayName=e?.serviceDisplayName||process.env.SERVICE_DISPLAY_NAME,this.serviceAdditionalMetadata=e?.serviceAdditionalMetadata||{},this.profilingModeEnabled=e?.profilingModeEnabled??!1,this.profilingMaxDepth=e?.profilingMaxDepth??5,this.profilingMaxVariableSizeKb=e?.profilingMaxVariableSizeKb??25,this.domainsToNotPropagateHeadersTo=e?.domainsToNotPropagateHeadersTo||[],this.nodeModulesToCollectLocalVariablesOn=e?.nodeModulesToCollectLocalVariablesOn||["_all_"],this.printConfigurationStatuses=process.env.PRINT_CONFIGURATION_STATUSES||"true",this.logLevel=process.env.LOG_LEVEL||"INFO",this.stackDepthLocals=process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS!==void 0?parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS,10):5,isNaN(this.stackDepthLocals)&&(this.stackDepthLocals=-1),this.stackDepthCodeTraceDepth=process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH!==void 0?parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH,10):-1,isNaN(this.stackDepthCodeTraceDepth)&&(this.stackDepthCodeTraceDepth=-1),this.packageLibraryType="JS/TS BACKEND",this.version=this.getPackageVersion();const r=(function(){return process.env.KUBERNETES_SERVICE_HOST||T.existsSync("/var/run/secrets/kubernetes.io/serviceaccount/token")?{type:"Kubernetes",details:{namespace:process.env.POD_NAMESPACE||"",podName:process.env.HOSTNAME||"",nodeName:process.env.NODE_NAME||""}}:process.env.AWS_LAMBDA_FUNCTION_NAME?{type:"AWS Lambda",details:{functionName:process.env.AWS_LAMBDA_FUNCTION_NAME||"",region:process.env.AWS_REGION||"",runtime:process.env.AWS_EXECUTION_ENV||""}}:process.env.AWS_EXECUTION_ENV?{type:"AWS",details:{executionEnv:process.env.AWS_EXECUTION_ENV||"",region:process.env.AWS_REGION||""}}:process.env.GOOGLE_CLOUD_PROJECT?{type:"Google Cloud",details:{project:process.env.GOOGLE_CLOUD_PROJECT||""}}:process.env.AZURE_FUNCTIONS_ENVIRONMENT?{type:"Azure Functions",details:{environment:process.env.AZURE_FUNCTIONS_ENVIRONMENT||""}}:process.env.VERCEL?{type:"Vercel",details:{env:process.env.VERCEL_ENV||"",region:process.env.VERCEL_REGION||""}}:process.env.NETLIFY?{type:"Netlify",details:{}}:process.env.FLY_APP_NAME?{type:"Fly.io",details:{appName:process.env.FLY_APP_NAME||"",region:process.env.FLY_REGION||""}}:process.env.RENDER_SERVICE_ID?{type:"Render",details:{serviceId:process.env.RENDER_SERVICE_ID||""}}:process.env.RAILWAY_ENVIRONMENT?{type:"Railway",details:{environment:process.env.RAILWAY_ENVIRONMENT||""}}:T.existsSync("/.dockerenv")?{type:"Docker",details:{}}:{type:"Unknown",details:{os:N.platform(),arch:N.arch(),nodeVersion:process.version}}})();this.infrastructureType=r.type,this.infrastructureDetails=r.details;const n=(function(){const g=[{pkg:"@nestjs/core",name:"nestjs"},{pkg:"@apollo/server",name:"apollo-server"},{pkg:"apollo-server",name:"apollo-server"},{pkg:"mercurius",name:"mercurius"},{pkg:"next",name:"nextjs"},{pkg:"nuxt",name:"nuxtjs"},{pkg:"express",name:"express"},{pkg:"fastify",name:"fastify"},{pkg:"koa",name:"koa"},{pkg:"@hapi/hapi",name:"hapi"},{pkg:"hono",name:"hono"}],u=[],l=new Set;for(const{pkg:h,name:S}of g)if(!l.has(S))try{require.resolve(h),u.push(S),l.add(S)}catch{}if(typeof process<"u"){if(!l.has("nuxtjs")&&globalThis._importMeta_!==void 0){let h=!1;try{(globalThis._importMeta_?.url||"").includes(".output/server")&&(h=!0)}catch{}h&&(u.unshift("nuxtjs"),l.add("nuxtjs"))}!l.has("meteorjs")&&process.env.METEOR_SHELL_DIR&&(u.unshift("meteorjs"),l.add("meteorjs"))}return{framework:u.length>0?u[0]:null,additionalFrameworks:u.slice(1),serviceRole:u.includes("nextjs")||u.includes("nuxtjs")?"fullstack":"backend"}})();this.framework=n.framework??void 0,this.additionalFrameworks=n.additionalFrameworks,this.serviceRole=n.serviceRole;const o=process.env.SF_LOG_IGNORE_REGEX;if(o)try{this.logIgnoreRegex=new RegExp(o)}catch{}this.captureRequestHeaders=process.env.SF_NETWORKHOP_CAPTURE_REQUEST_HEADERS==="true",this.captureResponseHeaders=process.env.SF_NETWORKHOP_CAPTURE_RESPONSE_HEADERS==="true",this.captureRequestBody=process.env.SF_NETWORKHOP_CAPTURE_REQUEST_BODY==="true",this.captureResponseBody=process.env.SF_NETWORKHOP_CAPTURE_RESPONSE_BODY==="true";const a=parseInt(process.env.SF_NETWORKHOP_REQUEST_LIMIT_MB||"1",10);this.requestBodyLimitBytes=1024*(isNaN(a)?1:a)*1024;const c=parseInt(process.env.SF_NETWORKHOP_RESPONSE_LIMIT_MB||"1",10);this.responseBodyLimitBytes=1024*(isNaN(c)?1:c)*1024}getPackageVersion(){return"0.2.14"}get serviceIdentificationReceived(){return this._serviceIdentificationReceived}setServiceIdentificationReceived(e){this._serviceIdentificationReceived=e}}const P=Symbol.for("sailfish.sf_config");function O(){return globalThis[P]}function C(){const s=O();if(!s)throw new Error("Configuration has not been initialized. Call getOrCreateConfig(options) first.");return s}const m=Symbol.for("sf.ctx.storeAls"),p=globalThis,R=p[m]??(p[m]=new L.AsyncLocalStorage),M=["identitytoolkit.googleapis.com","t.co","*.twitter.com","*.gravatar.com","*.googleapis.com","*.amazonaws.com","*.smooch.io","*.zendesk.com"],D=Symbol.for("sf.ctx.als"),_=p[D]??(p[D]=new L.AsyncLocalStorage),y=Symbol.for("sf.ctx.sessionRegistry"),E=p[y]??(p[y]=new Map),v={handledExceptions:new Set,reentrancyGuardLoggingActive:!1,reentrancyGuardLoggingPreActive:!1,reentrancyGuardPrintActive:!1,reentrancyGuardPrintPreActive:!1,reentrancyGuardExceptionActive:!1,reentrancyGuardExceptionPreActive:!1,excludedDomains:new Set(M),supportedDomains:new Set};class d{static GLOBAL_MANAGER_SYMBOL=Symbol.for("sf.ctx.manager");constructor(){}current(){return R.getStore()}ensureStore(){const e=this.current();if(e)return e;const t=new Map;return R.enterWith(t),t}runWith(e,t){const r=this.current()??new Map,n=new Map(r);for(const[o,a]of Object.entries(e))n.set(o,a);return R.run(n,t)}static getInstance(){return p[d.GLOBAL_MANAGER_SYMBOL]||(p[d.GLOBAL_MANAGER_SYMBOL]=new d),p[d.GLOBAL_MANAGER_SYMBOL]}getCurrentContext(){return _.getStore()||v}setCurrentContext(e){const t=_.getStore()||v;_.enterWith({...t,...e})}ensureSession(e){let t=E.get(e);return t||(t={...v},E.set(e,t)),t}getContextFor(e){return E.get(e)??v}updateContextFor(e,t){const r=this.ensureSession(e);E.set(e,{...r,...t})}runWithSession(e,t){const r={...this.ensureSession(e)};return _.run(r,t)}deleteSession(e){E.delete(e)}getTraceId(){return this.getCurrentContext().traceId}getPageVisitUUID(){return this.getCurrentContext().pageVisitUUID}setTraceId(e){this.setCurrentContext({traceId:e})}setPageVisitUUID(e){this.setCurrentContext({pageVisitUUID:e})}getCurrentFunctionSpanId(){return this.getCurrentContext().currentFunctionSpanId}setCurrentFunctionSpanId(e){this.setCurrentContext({currentFunctionSpanId:e})}clearCurrentFunctionSpanId(){this.setCurrentContext({currentFunctionSpanId:void 0})}getOrSetSfTraceId(e,t=!1){let r=this.getTraceId();return r||(r=e||(t?I():`nonsession-applogs-v3/${C().apiKey}/${I()}`),this.setTraceId(r),C().sfDebug&&console.log(" Created new trace ID:",r),r)}getOrSetPageVisitUUID(){let e=this.getPageVisitUUID();return e||(e=I(),this.setPageVisitUUID(e),C().sfDebug&&console.log(" Created new page visit UUID:",e),e)}getHandledExceptions(){return this.getCurrentContext().handledExceptions}markExceptionHandled(e){const t=this.getHandledExceptions();t.add(e),this.setCurrentContext({handledExceptions:t})}hasHandledException(e){return this.getHandledExceptions().has(e)}resetHandledExceptions(){this.setCurrentContext({handledExceptions:new Set})}getExcludedDomains(){return this.getCurrentContext().excludedDomains}getSupportedDomains(){return this.getCurrentContext().supportedDomains}addSupportedDomains(e){this.getCurrentContext().supportedDomains.add(e.toLowerCase().trim())}setTraceIdFor(e,t){this.updateContextFor(e,{traceId:t})}setPageVisitUUIDFor(e,t){this.updateContextFor(e,{pageVisitUUID:t})}}exports.ContextManager=d,exports.DEFAULT_DOMAINS_TO_EXCLUDE=M,exports.backfillGitInfoAsync=async function(s){if(!(s.gitOrg&&s.gitRepo&&s.gitProvider))try{const e=await(async function(){let t="";try{t=await new Promise((r,n)=>{x.execFile("git",["remote","get-url","origin"],{timeout:3e3},(o,a)=>{o?n(o):r((a||"").trim())})})}catch{try{const r=(await V.readFile(".git/config","utf-8")).match(/\[remote "origin"\][^[]*url\s*=\s*(.+)/m);r&&(t=r[1].trim())}catch{}}return t?(function(r){let n,o,a;if(r.includes("github.com")?n="github":r.includes("gitlab.com")?n="gitlab":r.includes("bitbucket.org")&&(n="bitbucket"),r.startsWith("https://")||r.startsWith("http://")){const c=r.split("/");c.length>=5&&(o=c[3],a=c[4].replace(/\.git$/,""))}else{const c=r.indexOf(":");if(c>0){const g=r.substring(c+1).replace(/\.git$/,"").split("/");g.length>=2&&(o=g[0],a=g[1])}}return{org:o,repo:a,provider:n}})(t):{}})();s.gitOrg||(s.gitOrg=e.org),s.gitRepo||(s.gitRepo=e.repo),s.gitProvider||(s.gitProvider=e.provider)}catch{}},exports.getConfig=C,exports.getCurrentFunctionSpanId=function(){return d.getInstance().getCurrentFunctionSpanId()},exports.getGlobalConfigUnsafe=O,exports.getOrCreateConfig=function(s){const e=O();if(e)return{config:e};const t=new F(s);return(function(r){globalThis[P]=r})(t),t.sfDebug&&console.log("[[getOrCreateConfig]] Created global config:",t),{config:t}},exports.runWithContext=function(s){const e={...d.getInstance().getCurrentContext()};_.run(e,()=>{s()})},exports.v4=I;
@@ -1,30 +1,30 @@
1
- var y = Object.defineProperty;
2
- var U = (n, e, t) => e in n ? y(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var s = (n, e, t) => U(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { AsyncLocalStorage as D } from "async_hooks";
5
- import { execFile as P } from "child_process";
6
- import { existsSync as R } from "fs";
7
- import * as M from "fs/promises";
8
- import * as T from "os";
9
- const c = [];
10
- for (let n = 0; n < 256; ++n) c.push((n + 256).toString(16).slice(1));
11
- let v;
12
- const b = new Uint8Array(16), O = { randomUUID: typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto) };
13
- function I(n, e, t) {
14
- if (O.randomUUID && !n) return O.randomUUID();
1
+ var M = Object.defineProperty;
2
+ var b = (n, e, t) => e in n ? M(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var s = (n, e, t) => b(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import { AsyncLocalStorage as U } from "async_hooks";
5
+ import { execFile as G } from "child_process";
6
+ import { existsSync as m } from "fs";
7
+ import * as V from "fs/promises";
8
+ import * as N from "os";
9
+ const a = [];
10
+ for (let n = 0; n < 256; ++n) a.push((n + 256).toString(16).slice(1));
11
+ let f;
12
+ const k = new Uint8Array(16), A = { randomUUID: typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto) };
13
+ function C(n, e, t) {
14
+ if (A.randomUUID && !n) return A.randomUUID();
15
15
  const r = (n = n || {}).random ?? n.rng?.() ?? (function() {
16
- if (!v) {
16
+ if (!f) {
17
17
  if (typeof crypto > "u" || !crypto.getRandomValues) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
18
- v = crypto.getRandomValues.bind(crypto);
18
+ f = crypto.getRandomValues.bind(crypto);
19
19
  }
20
- return v(b);
20
+ return f(k);
21
21
  })();
22
22
  if (r.length < 16) throw new Error("Random bytes length must be >= 16");
23
- return r[6] = 15 & r[6] | 64, r[8] = 63 & r[8] | 128, (function(i, o = 0) {
24
- return (c[i[o + 0]] + c[i[o + 1]] + c[i[o + 2]] + c[i[o + 3]] + "-" + c[i[o + 4]] + c[i[o + 5]] + "-" + c[i[o + 6]] + c[i[o + 7]] + "-" + c[i[o + 8]] + c[i[o + 9]] + "-" + c[i[o + 10]] + c[i[o + 11]] + c[i[o + 12]] + c[i[o + 13]] + c[i[o + 14]] + c[i[o + 15]]).toLowerCase();
23
+ return r[6] = 15 & r[6] | 64, r[8] = 63 & r[8] | 128, (function(o, i = 0) {
24
+ return (a[o[i + 0]] + a[o[i + 1]] + a[o[i + 2]] + a[o[i + 3]] + "-" + a[o[i + 4]] + a[o[i + 5]] + "-" + a[o[i + 6]] + a[o[i + 7]] + "-" + a[o[i + 8]] + a[o[i + 9]] + "-" + a[o[i + 10]] + a[o[i + 11]] + a[o[i + 12]] + a[o[i + 13]] + a[o[i + 14]] + a[o[i + 15]]).toLowerCase();
25
25
  })(r);
26
26
  }
27
- class x {
27
+ class F {
28
28
  constructor(e) {
29
29
  s(this, "apiKey");
30
30
  s(this, "apiGraphqlEndpoint");
@@ -51,6 +51,9 @@ class x {
51
51
  s(this, "serviceDisplayName");
52
52
  s(this, "infrastructureType");
53
53
  s(this, "infrastructureDetails");
54
+ s(this, "framework");
55
+ s(this, "additionalFrameworks");
56
+ s(this, "serviceRole");
54
57
  s(this, "setupInterceptorsFile");
55
58
  s(this, "setupInterceptorsLine");
56
59
  s(this, "logIgnoreRegex");
@@ -61,23 +64,43 @@ class x {
61
64
  s(this, "requestBodyLimitBytes");
62
65
  s(this, "responseBodyLimitBytes");
63
66
  s(this, "_serviceIdentificationReceived", !1);
64
- this.apiKey = e.apiKey, this.apiGraphqlEndpoint = e?.apiGraphqlEndpoint || process.env.SAILFISH_GRAPHQL_ENDPOINT || "https://api-service.sailfishqa.com/graphql/", this.sfDebug = e?.debug === !0 || process.env.SF_DEBUG === "true", this.serviceIdentifier = e?.serviceIdentifier || process.env.SERVICE_IDENTIFIER, this.serviceUUID = I(), this.serviceVersion = e?.serviceVersion || process.env.SERVICE_VERSION, this.gitSha = e?.gitSha || process.env.GIT_SHA || process.env.GITHUB_SHA || process.env.CI_COMMIT_SHA || process.env.BITBUCKET_COMMIT || process.env.VERCEL_GIT_COMMIT_SHA || process.env.CIRCLE_SHA1 || process.env.HEROKU_SLUG_COMMIT || process.env.RENDER_GIT_COMMIT || process.env.RAILWAY_GIT_COMMIT_SHA || process.env.CODEBUILD_RESOLVED_SOURCE_VERSION;
67
+ this.apiKey = e.apiKey, this.apiGraphqlEndpoint = e?.apiGraphqlEndpoint || process.env.SAILFISH_GRAPHQL_ENDPOINT || "https://api-service.sailfishqa.com/graphql/", this.sfDebug = e?.debug === !0 || process.env.SF_DEBUG === "true", this.serviceIdentifier = e?.serviceIdentifier || process.env.SERVICE_IDENTIFIER, this.serviceUUID = C(), this.serviceVersion = e?.serviceVersion || process.env.SERVICE_VERSION, this.gitSha = e?.gitSha || process.env.GIT_SHA || process.env.GITHUB_SHA || process.env.CI_COMMIT_SHA || process.env.BITBUCKET_COMMIT || process.env.VERCEL_GIT_COMMIT_SHA || process.env.CIRCLE_SHA1 || process.env.HEROKU_SLUG_COMMIT || process.env.RENDER_GIT_COMMIT || process.env.RAILWAY_GIT_COMMIT_SHA || process.env.CODEBUILD_RESOLVED_SOURCE_VERSION;
65
68
  const t = process.env.GITHUB_REPOSITORY?.split("/");
66
69
  this.gitOrg = e?.gitOrg || process.env.GIT_ORG || (t && t.length >= 2 ? t[0] : void 0) || process.env.CI_PROJECT_NAMESPACE || process.env.BITBUCKET_REPO_OWNER || process.env.VERCEL_GIT_REPO_OWNER || process.env.CIRCLE_PROJECT_USERNAME, this.gitRepo = e?.gitRepo || process.env.GIT_REPO || (t && t.length >= 2 ? t.slice(1).join("/") : void 0) || process.env.CI_PROJECT_NAME || process.env.BITBUCKET_REPO_SLUG || process.env.VERCEL_GIT_REPO_SLUG || process.env.CIRCLE_PROJECT_REPONAME, this.gitProvider = e?.gitProvider || process.env.GIT_PROVIDER || (process.env.GITHUB_ACTIONS ? "github" : void 0) || (process.env.GITLAB_CI ? "gitlab" : void 0) || (process.env.BITBUCKET_PIPELINE_UUID ? "bitbucket" : void 0) || (process.env.CIRCLECI ? "circleci" : void 0), this.serviceDisplayName = e?.serviceDisplayName || process.env.SERVICE_DISPLAY_NAME, this.serviceAdditionalMetadata = e?.serviceAdditionalMetadata || {}, this.profilingModeEnabled = e?.profilingModeEnabled ?? !1, this.profilingMaxDepth = e?.profilingMaxDepth ?? 5, this.profilingMaxVariableSizeKb = e?.profilingMaxVariableSizeKb ?? 25, this.domainsToNotPropagateHeadersTo = e?.domainsToNotPropagateHeadersTo || [], this.nodeModulesToCollectLocalVariablesOn = e?.nodeModulesToCollectLocalVariablesOn || ["_all_"], this.printConfigurationStatuses = process.env.PRINT_CONFIGURATION_STATUSES || "true", this.logLevel = process.env.LOG_LEVEL || "INFO", this.stackDepthLocals = process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS !== void 0 ? parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_LOCALS, 10) : 5, isNaN(this.stackDepthLocals) && (this.stackDepthLocals = -1), this.stackDepthCodeTraceDepth = process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH !== void 0 ? parseInt(process.env.SAILFISH_EXCEPTION_STACK_DEPTH_CODE_TRACE_DEPTH, 10) : -1, isNaN(this.stackDepthCodeTraceDepth) && (this.stackDepthCodeTraceDepth = -1), this.packageLibraryType = "JS/TS BACKEND", this.version = this.getPackageVersion();
67
70
  const r = (function() {
68
- return process.env.KUBERNETES_SERVICE_HOST || R("/var/run/secrets/kubernetes.io/serviceaccount/token") ? { type: "Kubernetes", details: { namespace: process.env.POD_NAMESPACE || "", podName: process.env.HOSTNAME || "", nodeName: process.env.NODE_NAME || "" } } : process.env.AWS_LAMBDA_FUNCTION_NAME ? { type: "AWS Lambda", details: { functionName: process.env.AWS_LAMBDA_FUNCTION_NAME || "", region: process.env.AWS_REGION || "", runtime: process.env.AWS_EXECUTION_ENV || "" } } : process.env.AWS_EXECUTION_ENV ? { type: "AWS", details: { executionEnv: process.env.AWS_EXECUTION_ENV || "", region: process.env.AWS_REGION || "" } } : process.env.GOOGLE_CLOUD_PROJECT ? { type: "Google Cloud", details: { project: process.env.GOOGLE_CLOUD_PROJECT || "" } } : process.env.AZURE_FUNCTIONS_ENVIRONMENT ? { type: "Azure Functions", details: { environment: process.env.AZURE_FUNCTIONS_ENVIRONMENT || "" } } : process.env.VERCEL ? { type: "Vercel", details: { env: process.env.VERCEL_ENV || "", region: process.env.VERCEL_REGION || "" } } : process.env.NETLIFY ? { type: "Netlify", details: {} } : process.env.FLY_APP_NAME ? { type: "Fly.io", details: { appName: process.env.FLY_APP_NAME || "", region: process.env.FLY_REGION || "" } } : process.env.RENDER_SERVICE_ID ? { type: "Render", details: { serviceId: process.env.RENDER_SERVICE_ID || "" } } : process.env.RAILWAY_ENVIRONMENT ? { type: "Railway", details: { environment: process.env.RAILWAY_ENVIRONMENT || "" } } : R("/.dockerenv") ? { type: "Docker", details: {} } : { type: "Unknown", details: { os: T.platform(), arch: T.arch(), nodeVersion: process.version } };
71
+ return process.env.KUBERNETES_SERVICE_HOST || m("/var/run/secrets/kubernetes.io/serviceaccount/token") ? { type: "Kubernetes", details: { namespace: process.env.POD_NAMESPACE || "", podName: process.env.HOSTNAME || "", nodeName: process.env.NODE_NAME || "" } } : process.env.AWS_LAMBDA_FUNCTION_NAME ? { type: "AWS Lambda", details: { functionName: process.env.AWS_LAMBDA_FUNCTION_NAME || "", region: process.env.AWS_REGION || "", runtime: process.env.AWS_EXECUTION_ENV || "" } } : process.env.AWS_EXECUTION_ENV ? { type: "AWS", details: { executionEnv: process.env.AWS_EXECUTION_ENV || "", region: process.env.AWS_REGION || "" } } : process.env.GOOGLE_CLOUD_PROJECT ? { type: "Google Cloud", details: { project: process.env.GOOGLE_CLOUD_PROJECT || "" } } : process.env.AZURE_FUNCTIONS_ENVIRONMENT ? { type: "Azure Functions", details: { environment: process.env.AZURE_FUNCTIONS_ENVIRONMENT || "" } } : process.env.VERCEL ? { type: "Vercel", details: { env: process.env.VERCEL_ENV || "", region: process.env.VERCEL_REGION || "" } } : process.env.NETLIFY ? { type: "Netlify", details: {} } : process.env.FLY_APP_NAME ? { type: "Fly.io", details: { appName: process.env.FLY_APP_NAME || "", region: process.env.FLY_REGION || "" } } : process.env.RENDER_SERVICE_ID ? { type: "Render", details: { serviceId: process.env.RENDER_SERVICE_ID || "" } } : process.env.RAILWAY_ENVIRONMENT ? { type: "Railway", details: { environment: process.env.RAILWAY_ENVIRONMENT || "" } } : m("/.dockerenv") ? { type: "Docker", details: {} } : { type: "Unknown", details: { os: N.platform(), arch: N.arch(), nodeVersion: process.version } };
69
72
  })();
70
73
  this.infrastructureType = r.type, this.infrastructureDetails = r.details;
74
+ const o = (function() {
75
+ const g = [{ pkg: "@nestjs/core", name: "nestjs" }, { pkg: "@apollo/server", name: "apollo-server" }, { pkg: "apollo-server", name: "apollo-server" }, { pkg: "mercurius", name: "mercurius" }, { pkg: "next", name: "nextjs" }, { pkg: "nuxt", name: "nuxtjs" }, { pkg: "express", name: "express" }, { pkg: "fastify", name: "fastify" }, { pkg: "koa", name: "koa" }, { pkg: "@hapi/hapi", name: "hapi" }, { pkg: "hono", name: "hono" }], d = [], l = /* @__PURE__ */ new Set();
76
+ for (const { pkg: h, name: R } of g) if (!l.has(R)) try {
77
+ require.resolve(h), d.push(R), l.add(R);
78
+ } catch {
79
+ }
80
+ if (typeof process < "u") {
81
+ if (!l.has("nuxtjs") && globalThis._importMeta_ !== void 0) {
82
+ let h = !1;
83
+ try {
84
+ (globalThis._importMeta_?.url || "").includes(".output/server") && (h = !0);
85
+ } catch {
86
+ }
87
+ h && (d.unshift("nuxtjs"), l.add("nuxtjs"));
88
+ }
89
+ !l.has("meteorjs") && process.env.METEOR_SHELL_DIR && (d.unshift("meteorjs"), l.add("meteorjs"));
90
+ }
91
+ return { framework: d.length > 0 ? d[0] : null, additionalFrameworks: d.slice(1), serviceRole: d.includes("nextjs") || d.includes("nuxtjs") ? "fullstack" : "backend" };
92
+ })();
93
+ this.framework = o.framework ?? void 0, this.additionalFrameworks = o.additionalFrameworks, this.serviceRole = o.serviceRole;
71
94
  const i = process.env.SF_LOG_IGNORE_REGEX;
72
95
  if (i) try {
73
96
  this.logIgnoreRegex = new RegExp(i);
74
97
  } catch {
75
98
  }
76
99
  this.captureRequestHeaders = process.env.SF_NETWORKHOP_CAPTURE_REQUEST_HEADERS === "true", this.captureResponseHeaders = process.env.SF_NETWORKHOP_CAPTURE_RESPONSE_HEADERS === "true", this.captureRequestBody = process.env.SF_NETWORKHOP_CAPTURE_REQUEST_BODY === "true", this.captureResponseBody = process.env.SF_NETWORKHOP_CAPTURE_RESPONSE_BODY === "true";
77
- const o = parseInt(process.env.SF_NETWORKHOP_REQUEST_LIMIT_MB || "1", 10);
78
- this.requestBodyLimitBytes = 1024 * (isNaN(o) ? 1 : o) * 1024;
79
- const a = parseInt(process.env.SF_NETWORKHOP_RESPONSE_LIMIT_MB || "1", 10);
80
- this.responseBodyLimitBytes = 1024 * (isNaN(a) ? 1 : a) * 1024;
100
+ const c = parseInt(process.env.SF_NETWORKHOP_REQUEST_LIMIT_MB || "1", 10);
101
+ this.requestBodyLimitBytes = 1024 * (isNaN(c) ? 1 : c) * 1024;
102
+ const p = parseInt(process.env.SF_NETWORKHOP_RESPONSE_LIMIT_MB || "1", 10);
103
+ this.responseBodyLimitBytes = 1024 * (isNaN(p) ? 1 : p) * 1024;
81
104
  }
82
105
  getPackageVersion() {
83
106
  return "0.2.14";
@@ -89,103 +112,103 @@ class x {
89
112
  this._serviceIdentificationReceived = e;
90
113
  }
91
114
  }
92
- async function w(n) {
115
+ async function j(n) {
93
116
  if (!(n.gitOrg && n.gitRepo && n.gitProvider)) try {
94
117
  const e = await (async function() {
95
118
  let t = "";
96
119
  try {
97
- t = await new Promise((r, i) => {
98
- P("git", ["remote", "get-url", "origin"], { timeout: 3e3 }, (o, a) => {
99
- o ? i(o) : r((a || "").trim());
120
+ t = await new Promise((r, o) => {
121
+ G("git", ["remote", "get-url", "origin"], { timeout: 3e3 }, (i, c) => {
122
+ i ? o(i) : r((c || "").trim());
100
123
  });
101
124
  });
102
125
  } catch {
103
126
  try {
104
- const r = (await M.readFile(".git/config", "utf-8")).match(/\[remote "origin"\][^[]*url\s*=\s*(.+)/m);
127
+ const r = (await V.readFile(".git/config", "utf-8")).match(/\[remote "origin"\][^[]*url\s*=\s*(.+)/m);
105
128
  r && (t = r[1].trim());
106
129
  } catch {
107
130
  }
108
131
  }
109
132
  return t ? (function(r) {
110
- let i, o, a;
111
- if (r.includes("github.com") ? i = "github" : r.includes("gitlab.com") ? i = "gitlab" : r.includes("bitbucket.org") && (i = "bitbucket"), r.startsWith("https://") || r.startsWith("http://")) {
112
- const d = r.split("/");
113
- d.length >= 5 && (o = d[3], a = d[4].replace(/\.git$/, ""));
133
+ let o, i, c;
134
+ if (r.includes("github.com") ? o = "github" : r.includes("gitlab.com") ? o = "gitlab" : r.includes("bitbucket.org") && (o = "bitbucket"), r.startsWith("https://") || r.startsWith("http://")) {
135
+ const p = r.split("/");
136
+ p.length >= 5 && (i = p[3], c = p[4].replace(/\.git$/, ""));
114
137
  } else {
115
- const d = r.indexOf(":");
116
- if (d > 0) {
117
- const C = r.substring(d + 1).replace(/\.git$/, "").split("/");
118
- C.length >= 2 && (o = C[0], a = C[1]);
138
+ const p = r.indexOf(":");
139
+ if (p > 0) {
140
+ const g = r.substring(p + 1).replace(/\.git$/, "").split("/");
141
+ g.length >= 2 && (i = g[0], c = g[1]);
119
142
  }
120
143
  }
121
- return { org: o, repo: a, provider: i };
144
+ return { org: i, repo: c, provider: o };
122
145
  })(t) : {};
123
146
  })();
124
147
  n.gitOrg || (n.gitOrg = e.org), n.gitRepo || (n.gitRepo = e.repo), n.gitProvider || (n.gitProvider = e.provider);
125
148
  } catch {
126
149
  }
127
150
  }
128
- const L = Symbol.for("sailfish.sf_config");
129
- function m() {
130
- return globalThis[L];
151
+ const P = Symbol.for("sailfish.sf_config");
152
+ function x() {
153
+ return globalThis[P];
131
154
  }
132
- function W(n) {
133
- const e = m();
155
+ function Y(n) {
156
+ const e = x();
134
157
  if (e) return { config: e };
135
- const t = new x(n);
158
+ const t = new F(n);
136
159
  return (function(r) {
137
- globalThis[L] = r;
160
+ globalThis[P] = r;
138
161
  })(t), t.sfDebug && console.log("[[getOrCreateConfig]] Created global config:", t), { config: t };
139
162
  }
140
- function h() {
141
- const n = m();
163
+ function T() {
164
+ const n = x();
142
165
  if (!n) throw new Error("Configuration has not been initialized. Call getOrCreateConfig(options) first.");
143
166
  return n;
144
167
  }
145
- const f = Symbol.for("sf.ctx.storeAls"), p = globalThis, S = p[f] ?? (p[f] = new D()), G = ["identitytoolkit.googleapis.com", "t.co", "*.twitter.com", "*.gravatar.com", "*.googleapis.com", "*.amazonaws.com", "*.smooch.io", "*.zendesk.com"], N = Symbol.for("sf.ctx.als"), g = p[N] ?? (p[N] = new D()), A = Symbol.for("sf.ctx.sessionRegistry"), E = p[A] ?? (p[A] = /* @__PURE__ */ new Map()), l = { handledExceptions: /* @__PURE__ */ new Set(), reentrancyGuardLoggingActive: !1, reentrancyGuardLoggingPreActive: !1, reentrancyGuardPrintActive: !1, reentrancyGuardPrintPreActive: !1, reentrancyGuardExceptionActive: !1, reentrancyGuardExceptionPreActive: !1, excludedDomains: new Set(G), supportedDomains: /* @__PURE__ */ new Set() }, u = class u {
168
+ const D = Symbol.for("sf.ctx.storeAls"), u = globalThis, O = u[D] ?? (u[D] = new U()), H = ["identitytoolkit.googleapis.com", "t.co", "*.twitter.com", "*.gravatar.com", "*.googleapis.com", "*.amazonaws.com", "*.smooch.io", "*.zendesk.com"], L = Symbol.for("sf.ctx.als"), I = u[L] ?? (u[L] = new U()), y = Symbol.for("sf.ctx.sessionRegistry"), _ = u[y] ?? (u[y] = /* @__PURE__ */ new Map()), v = { handledExceptions: /* @__PURE__ */ new Set(), reentrancyGuardLoggingActive: !1, reentrancyGuardLoggingPreActive: !1, reentrancyGuardPrintActive: !1, reentrancyGuardPrintPreActive: !1, reentrancyGuardExceptionActive: !1, reentrancyGuardExceptionPreActive: !1, excludedDomains: new Set(H), supportedDomains: /* @__PURE__ */ new Set() }, E = class E {
146
169
  constructor() {
147
170
  }
148
171
  current() {
149
- return S.getStore();
172
+ return O.getStore();
150
173
  }
151
174
  ensureStore() {
152
175
  const e = this.current();
153
176
  if (e) return e;
154
177
  const t = /* @__PURE__ */ new Map();
155
- return S.enterWith(t), t;
178
+ return O.enterWith(t), t;
156
179
  }
157
180
  runWith(e, t) {
158
- const r = this.current() ?? /* @__PURE__ */ new Map(), i = new Map(r);
159
- for (const [o, a] of Object.entries(e)) i.set(o, a);
160
- return S.run(i, t);
181
+ const r = this.current() ?? /* @__PURE__ */ new Map(), o = new Map(r);
182
+ for (const [i, c] of Object.entries(e)) o.set(i, c);
183
+ return O.run(o, t);
161
184
  }
162
185
  static getInstance() {
163
- return p[u.GLOBAL_MANAGER_SYMBOL] || (p[u.GLOBAL_MANAGER_SYMBOL] = new u()), p[u.GLOBAL_MANAGER_SYMBOL];
186
+ return u[E.GLOBAL_MANAGER_SYMBOL] || (u[E.GLOBAL_MANAGER_SYMBOL] = new E()), u[E.GLOBAL_MANAGER_SYMBOL];
164
187
  }
165
188
  getCurrentContext() {
166
- return g.getStore() || l;
189
+ return I.getStore() || v;
167
190
  }
168
191
  setCurrentContext(e) {
169
- const t = g.getStore() || l;
170
- g.enterWith({ ...t, ...e });
192
+ const t = I.getStore() || v;
193
+ I.enterWith({ ...t, ...e });
171
194
  }
172
195
  ensureSession(e) {
173
- let t = E.get(e);
174
- return t || (t = { ...l }, E.set(e, t)), t;
196
+ let t = _.get(e);
197
+ return t || (t = { ...v }, _.set(e, t)), t;
175
198
  }
176
199
  getContextFor(e) {
177
- return E.get(e) ?? l;
200
+ return _.get(e) ?? v;
178
201
  }
179
202
  updateContextFor(e, t) {
180
203
  const r = this.ensureSession(e);
181
- E.set(e, { ...r, ...t });
204
+ _.set(e, { ...r, ...t });
182
205
  }
183
206
  runWithSession(e, t) {
184
207
  const r = { ...this.ensureSession(e) };
185
- return g.run(r, t);
208
+ return I.run(r, t);
186
209
  }
187
210
  deleteSession(e) {
188
- E.delete(e);
211
+ _.delete(e);
189
212
  }
190
213
  getTraceId() {
191
214
  return this.getCurrentContext().traceId;
@@ -210,11 +233,11 @@ const f = Symbol.for("sf.ctx.storeAls"), p = globalThis, S = p[f] ?? (p[f] = new
210
233
  }
211
234
  getOrSetSfTraceId(e, t = !1) {
212
235
  let r = this.getTraceId();
213
- return r || (r = e || (t ? I() : `nonsession-applogs-v3/${h().apiKey}/${I()}`), this.setTraceId(r), h().sfDebug && console.log(" Created new trace ID:", r), r);
236
+ return r || (r = e || (t ? C() : `nonsession-applogs-v3/${T().apiKey}/${C()}`), this.setTraceId(r), T().sfDebug && console.log(" Created new trace ID:", r), r);
214
237
  }
215
238
  getOrSetPageVisitUUID() {
216
239
  let e = this.getPageVisitUUID();
217
- return e || (e = I(), this.setPageVisitUUID(e), h().sfDebug && console.log(" Created new page visit UUID:", e), e);
240
+ return e || (e = C(), this.setPageVisitUUID(e), T().sfDebug && console.log(" Created new page visit UUID:", e), e);
218
241
  }
219
242
  getHandledExceptions() {
220
243
  return this.getCurrentContext().handledExceptions;
@@ -245,25 +268,25 @@ const f = Symbol.for("sf.ctx.storeAls"), p = globalThis, S = p[f] ?? (p[f] = new
245
268
  this.updateContextFor(e, { pageVisitUUID: t });
246
269
  }
247
270
  };
248
- s(u, "GLOBAL_MANAGER_SYMBOL", Symbol.for("sf.ctx.manager"));
249
- let _ = u;
250
- function K(n) {
251
- const e = { ..._.getInstance().getCurrentContext() };
252
- g.run(e, () => {
271
+ s(E, "GLOBAL_MANAGER_SYMBOL", Symbol.for("sf.ctx.manager"));
272
+ let S = E;
273
+ function q(n) {
274
+ const e = { ...S.getInstance().getCurrentContext() };
275
+ I.run(e, () => {
253
276
  n();
254
277
  });
255
278
  }
256
- function k() {
257
- return _.getInstance().getCurrentFunctionSpanId();
279
+ function X() {
280
+ return S.getInstance().getCurrentFunctionSpanId();
258
281
  }
259
282
  export {
260
- _ as C,
261
- G as D,
262
- m as a,
263
- k as b,
264
- W as c,
265
- w as d,
266
- h as g,
267
- K as r,
268
- I as v
283
+ S as C,
284
+ H as D,
285
+ x as a,
286
+ X as b,
287
+ Y as c,
288
+ j as d,
289
+ T as g,
290
+ q as r,
291
+ C as v
269
292
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("fs"),r=require("../funcSpanTransformer-D0W2t41q.cjs"),c=require("../runtimeConfig-DmD4lUhG.cjs");function l(o={}){try{if(c.shouldEnableRuntimeHooks())return console.warn("[FuncSpan Esbuild Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"),{name:"sailfish-funcspan-esbuild-disabled",setup(){}}}catch{}const{enabled:a=!0,includeNodeModules:i=[],debug:t=!1}=o;return{name:"sailfish-funcspan-esbuild",setup(u){a&&(u.onLoad({filter:/\.(js|ts|jsx|tsx)$/},async e=>{if(e.path.includes("node_modules")&&!i.some(n=>e.path.includes(`node_modules/${n}`))||e.path.includes("@sailfish-ai/sf-veritas")||e.path.includes("jsts-backend/dist"))return null;try{const n=d.readFileSync(e.path,"utf-8"),s=await r.transformFunctionSpans(n,e.path,{projectRoot:process.cwd(),includeNodeModules:i,debug:t});if(s.modified)return{contents:s.code,loader:e.path.endsWith(".ts")||e.path.endsWith(".tsx")?"ts":"js"}}catch(n){t&&console.error(`[FuncSpan Esbuild] Error transforming ${e.path}:`,n)}return null}),t&&console.log("[FuncSpan Esbuild] Plugin initialized"))}}}exports.default=l,exports.funcspanEsbuildPlugin=l;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("fs"),p=require("../funcSpanTransformer-D0W2t41q.cjs"),f=require("../consoleLocationTransformer-BSSB5msZ.cjs"),h=require("../runtimeConfig-CWpFWsmz.cjs");function d(a={}){try{if(h.shouldEnableRuntimeHooks())return console.warn("[FuncSpan Esbuild Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"),{name:"sailfish-funcspan-esbuild-disabled",setup(){}}}catch{}const{enabled:r=!0,includeNodeModules:i=[],debug:s=!1}=a;return{name:"sailfish-funcspan-esbuild",setup(u){r&&(u.onLoad({filter:/\.(js|ts|jsx|tsx)$/},async e=>{if(e.path.includes("node_modules")&&!i.some(n=>e.path.includes(`node_modules/${n}`))||e.path.includes("@sailfish-ai/sf-veritas")||e.path.includes("jsts-backend/dist"))return null;try{let n=c.readFileSync(e.path,"utf-8"),o=!1;const t=await p.transformFunctionSpans(n,e.path,{projectRoot:process.cwd(),includeNodeModules:i,debug:s});t.modified&&(n=t.code,o=!0);const l=await f.transformConsoleLocations(n,e.path,{projectRoot:process.cwd(),includeNodeModules:i,debug:s});if(l.modified&&(n=l.code,o=!0),o)return{contents:n,loader:e.path.endsWith(".ts")||e.path.endsWith(".tsx")?"ts":"js"}}catch(n){s&&console.error(`[FuncSpan Esbuild] Error transforming ${e.path}:`,n)}return null}),s&&console.log("[FuncSpan Esbuild] Plugin initialized"))}}}exports.default=d,exports.funcspanEsbuildPlugin=d;
@@ -1,27 +1,31 @@
1
- import { readFileSync as l } from "fs";
2
- import { t as d } from "../funcSpanTransformer-S_WeAt_m.js";
3
- import { s as r } from "../runtimeConfig-Bfqf33tO.js";
4
- function h(o = {}) {
1
+ import { readFileSync as r } from "fs";
2
+ import { t as c } from "../funcSpanTransformer-S_WeAt_m.js";
3
+ import { t as p } from "../consoleLocationTransformer-DZu_9MDA.js";
4
+ import { s as f } from "../runtimeConfig-BZ61efqE.js";
5
+ function j(a = {}) {
5
6
  try {
6
- if (r()) return console.warn("[FuncSpan Esbuild Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"), { name: "sailfish-funcspan-esbuild-disabled", setup() {
7
+ if (f()) return console.warn("[FuncSpan Esbuild Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"), { name: "sailfish-funcspan-esbuild-disabled", setup() {
7
8
  } };
8
9
  } catch {
9
10
  }
10
- const { enabled: a = !0, includeNodeModules: i = [], debug: t = !1 } = o;
11
- return { name: "sailfish-funcspan-esbuild", setup(s) {
12
- a && (s.onLoad({ filter: /\.(js|ts|jsx|tsx)$/ }, async (n) => {
13
- if (n.path.includes("node_modules") && !i.some((e) => n.path.includes(`node_modules/${e}`)) || n.path.includes("@sailfish-ai/sf-veritas") || n.path.includes("jsts-backend/dist")) return null;
11
+ const { enabled: l = !0, includeNodeModules: i = [], debug: n = !1 } = a;
12
+ return { name: "sailfish-funcspan-esbuild", setup(t) {
13
+ l && (t.onLoad({ filter: /\.(js|ts|jsx|tsx)$/ }, async (e) => {
14
+ if (e.path.includes("node_modules") && !i.some((s) => e.path.includes(`node_modules/${s}`)) || e.path.includes("@sailfish-ai/sf-veritas") || e.path.includes("jsts-backend/dist")) return null;
14
15
  try {
15
- const e = l(n.path, "utf-8"), u = await d(e, n.path, { projectRoot: process.cwd(), includeNodeModules: i, debug: t });
16
- if (u.modified) return { contents: u.code, loader: n.path.endsWith(".ts") || n.path.endsWith(".tsx") ? "ts" : "js" };
17
- } catch (e) {
18
- t && console.error(`[FuncSpan Esbuild] Error transforming ${n.path}:`, e);
16
+ let s = r(e.path, "utf-8"), o = !1;
17
+ const d = await c(s, e.path, { projectRoot: process.cwd(), includeNodeModules: i, debug: n });
18
+ d.modified && (s = d.code, o = !0);
19
+ const u = await p(s, e.path, { projectRoot: process.cwd(), includeNodeModules: i, debug: n });
20
+ if (u.modified && (s = u.code, o = !0), o) return { contents: s, loader: e.path.endsWith(".ts") || e.path.endsWith(".tsx") ? "ts" : "js" };
21
+ } catch (s) {
22
+ n && console.error(`[FuncSpan Esbuild] Error transforming ${e.path}:`, s);
19
23
  }
20
24
  return null;
21
- }), t && console.log("[FuncSpan Esbuild] Plugin initialized"));
25
+ }), n && console.log("[FuncSpan Esbuild] Plugin initialized"));
22
26
  } };
23
27
  }
24
28
  export {
25
- h as default,
26
- h as funcspanEsbuildPlugin
29
+ j as default,
30
+ j as funcspanEsbuildPlugin
27
31
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("../funcSpanTransformer-D0W2t41q.cjs"),a=require("../runtimeConfig-DmD4lUhG.cjs");function s(o={}){try{if(a.shouldEnableRuntimeHooks())return console.warn("[FuncSpan Rollup Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"),{name:"sailfish-funcspan-rollup-disabled"}}catch{}const{enabled:t=!0,includeNodeModules:l=[],debug:u=!1}=o;return{name:"sailfish-funcspan-rollup",async transform(r,e){if(!t||!e.match(/\.(js|ts|jsx|tsx)$/)||e.includes("node_modules")&&!l.some(n=>e.includes(`node_modules/${n}`))||e.includes("@sailfish-ai/sf-veritas")||e.includes("jsts-backend/dist"))return null;try{const n=await i.transformFunctionSpans(r,e,{projectRoot:process.cwd(),includeNodeModules:l,debug:u});if(n.modified)return{code:n.code,map:n.map||null}}catch(n){u&&console.error(`[FuncSpan Rollup] Error transforming ${e}:`,n)}return null}}}exports.default=s,exports.funcspanRollupPlugin=s;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("../funcSpanTransformer-D0W2t41q.cjs"),p=require("../consoleLocationTransformer-BSSB5msZ.cjs"),m=require("../runtimeConfig-CWpFWsmz.cjs");function d(a={}){try{if(m.shouldEnableRuntimeHooks())return console.warn("[FuncSpan Rollup Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"),{name:"sailfish-funcspan-rollup-disabled"}}catch{}const{enabled:c=!0,includeNodeModules:o=[],debug:u=!1}=a;return{name:"sailfish-funcspan-rollup",async transform(s,n){if(!c||!n.match(/\.(js|ts|jsx|tsx)$/)||n.includes("node_modules")&&!o.some(e=>n.includes(`node_modules/${e}`))||n.includes("@sailfish-ai/sf-veritas")||n.includes("jsts-backend/dist"))return null;try{let e=s,l=null,r=!1;const t=await f.transformFunctionSpans(e,n,{projectRoot:process.cwd(),includeNodeModules:o,debug:u});t.modified&&(e=t.code,l=t.map,r=!0);const i=await p.transformConsoleLocations(e,n,{projectRoot:process.cwd(),includeNodeModules:o,debug:u});if(i.modified&&(e=i.code,l=i.map,r=!0),r)return{code:e,map:l||null}}catch(e){u&&console.error(`[FuncSpan Rollup] Error transforming ${n}:`,e)}return null}}}exports.default=d,exports.funcspanRollupPlugin=d;
@@ -1,23 +1,27 @@
1
- import { t as i } from "../funcSpanTransformer-S_WeAt_m.js";
2
- import { s as r } from "../runtimeConfig-Bfqf33tO.js";
3
- function c(o = {}) {
1
+ import { t as c } from "../funcSpanTransformer-S_WeAt_m.js";
2
+ import { t as p } from "../consoleLocationTransformer-DZu_9MDA.js";
3
+ import { s as f } from "../runtimeConfig-BZ61efqE.js";
4
+ function h(r = {}) {
4
5
  try {
5
- if (r()) return console.warn("[FuncSpan Rollup Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"), { name: "sailfish-funcspan-rollup-disabled" };
6
+ if (f()) return console.warn("[FuncSpan Rollup Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"), { name: "sailfish-funcspan-rollup-disabled" };
6
7
  } catch {
7
8
  }
8
- const { enabled: t = !0, includeNodeModules: l = [], debug: u = !1 } = o;
9
- return { name: "sailfish-funcspan-rollup", async transform(s, n) {
10
- if (!t || !n.match(/\.(js|ts|jsx|tsx)$/) || n.includes("node_modules") && !l.some((e) => n.includes(`node_modules/${e}`)) || n.includes("@sailfish-ai/sf-veritas") || n.includes("jsts-backend/dist")) return null;
9
+ const { enabled: a = !0, includeNodeModules: o = [], debug: l = !1 } = r;
10
+ return { name: "sailfish-funcspan-rollup", async transform(d, e) {
11
+ if (!a || !e.match(/\.(js|ts|jsx|tsx)$/) || e.includes("node_modules") && !o.some((n) => e.includes(`node_modules/${n}`)) || e.includes("@sailfish-ai/sf-veritas") || e.includes("jsts-backend/dist")) return null;
11
12
  try {
12
- const e = await i(s, n, { projectRoot: process.cwd(), includeNodeModules: l, debug: u });
13
- if (e.modified) return { code: e.code, map: e.map || null };
14
- } catch (e) {
15
- u && console.error(`[FuncSpan Rollup] Error transforming ${n}:`, e);
13
+ let n = d, s = null, u = !1;
14
+ const t = await c(n, e, { projectRoot: process.cwd(), includeNodeModules: o, debug: l });
15
+ t.modified && (n = t.code, s = t.map, u = !0);
16
+ const i = await p(n, e, { projectRoot: process.cwd(), includeNodeModules: o, debug: l });
17
+ if (i.modified && (n = i.code, s = i.map, u = !0), u) return { code: n, map: s || null };
18
+ } catch (n) {
19
+ l && console.error(`[FuncSpan Rollup] Error transforming ${e}:`, n);
16
20
  }
17
21
  return null;
18
22
  } };
19
23
  }
20
24
  export {
21
- c as default,
22
- c as funcspanRollupPlugin
25
+ h as default,
26
+ h as funcspanRollupPlugin
23
27
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("fs"),_=require("glob"),N=require("path"),m=require("../funcSpanTransformer-D0W2t41q.cjs"),T=require("../runtimeConfig-DmD4lUhG.cjs");async function S(n={}){try{if(T.shouldEnableRuntimeHooks())return void console.warn("[FuncSpan TSC Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation")}catch{}const{outDir:f="dist",include:F=["**/*.js"],exclude:g=["**/*.test.js","**/*.spec.js","**/__tests__/**"],projectRoot:c=process.cwd(),includeNodeModules:C=[],debug:s=!1}=n,u=N.resolve(c,f);console.log("[FuncSpan TSC] Starting post-build function instrumentation..."),console.log(`[FuncSpan TSC] Output directory: ${u}`),console.log(`[FuncSpan TSC] Project root: ${c}`);const r=[];for(const e of F){const t=_.sync(e,{cwd:u,absolute:!0,ignore:g});r.push(...t)}console.log(`[FuncSpan TSC] Found ${r.length} JavaScript files to process`);let l=0,a=0;for(const e of r)try{const t=i.readFileSync(e,"utf-8"),o=await m.transformFunctionSpans(t,e,{projectRoot:c,includeNodeModules:C,debug:s});if(o.modified){if(i.writeFileSync(e,o.code,"utf-8"),o.map){const p=`${e}.map`;i.writeFileSync(p,JSON.stringify(o.map),"utf-8"),s&&console.log(`[FuncSpan TSC] Generated source map: ${p}`)}l++,a+=o.functionsWrapped,s&&console.log(`[FuncSpan TSC] Modified: ${e} (${o.functionsWrapped} functions)`)}}catch(t){console.error(`[FuncSpan TSC] Error processing ${e}:`,t)}console.log(`[FuncSpan TSC] ✅ Completed: Modified ${l} files, wrapped ${a} functions`)}async function d(){const n={outDir:process.env.SF_FUNCSPAN_OUT_DIR||"dist",debug:process.env.SF_FUNCSPAN_DEBUG==="true",includeNodeModules:process.env.SF_FUNCSPAN_INCLUDE_NODE_MODULES?process.env.SF_FUNCSPAN_INCLUDE_NODE_MODULES.split(","):[]};await S(n)}require.main===module&&d().catch(n=>{console.error("[FuncSpan TSC] Fatal error:",n),process.exit(1)}),exports.cli=d,exports.processTscFiles=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("fs"),T=require("glob"),y=require("path"),D=require("../funcSpanTransformer-D0W2t41q.cjs"),b=require("../consoleLocationTransformer-BSSB5msZ.cjs"),v=require("../runtimeConfig-CWpFWsmz.cjs");async function C(n={}){try{if(v.shouldEnableRuntimeHooks())return void console.warn("[FuncSpan TSC Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation")}catch{}const{outDir:N="dist",include:_=["**/*.js"],exclude:m=["**/*.test.js","**/*.spec.js","**/__tests__/**"],projectRoot:c=process.cwd(),includeNodeModules:d=[],debug:s=!1}=n,p=y.resolve(c,N);console.log("[FuncSpan TSC] Starting post-build function instrumentation..."),console.log(`[FuncSpan TSC] Output directory: ${p}`),console.log(`[FuncSpan TSC] Project root: ${c}`);const i=[];for(const o of _){const e=T.sync(o,{cwd:p,absolute:!0,ignore:m});i.push(...e)}console.log(`[FuncSpan TSC] Found ${i.length} JavaScript files to process`);let S=0,f=0;for(const o of i)try{let e=a.readFileSync(o,"utf-8"),r=null,u=!1;const t=await D.transformFunctionSpans(e,o,{projectRoot:c,includeNodeModules:d,debug:s});t.modified&&(e=t.code,r=t.map,u=!0);const l=await b.transformConsoleLocations(e,o,{projectRoot:c,includeNodeModules:d,debug:s});if(l.modified&&(e=l.code,r=l.map,u=!0),u){if(a.writeFileSync(o,e,"utf-8"),r){const F=`${o}.map`;a.writeFileSync(F,JSON.stringify(r),"utf-8"),s&&console.log(`[FuncSpan TSC] Generated source map: ${F}`)}S++,f+=t.functionsWrapped,s&&console.log(`[FuncSpan TSC] Modified: ${o} (${t.functionsWrapped} functions)`)}}catch(e){console.error(`[FuncSpan TSC] Error processing ${o}:`,e)}console.log(`[FuncSpan TSC] ✅ Completed: Modified ${S} files, wrapped ${f} functions`)}async function g(){const n={outDir:process.env.SF_FUNCSPAN_OUT_DIR||"dist",debug:process.env.SF_FUNCSPAN_DEBUG==="true",includeNodeModules:process.env.SF_FUNCSPAN_INCLUDE_NODE_MODULES?process.env.SF_FUNCSPAN_INCLUDE_NODE_MODULES.split(","):[]};await C(n)}require.main===module&&g().catch(n=>{console.error("[FuncSpan TSC] Fatal error:",n),process.exit(1)}),exports.cli=g,exports.processTscFiles=C;