@sailfish-ai/sf-veritas 0.4.1 → 0.5.2-alpha0
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/README.md +19 -0
- package/dist/contextManager-B4JXc4ak.cjs +1 -0
- package/dist/{contextManager-CE9FcHd2.js → contextManager-BSAjnoti.js} +153 -149
- package/dist/plugins/funcspanEsbuildPlugin.cjs +1 -1
- package/dist/plugins/funcspanEsbuildPlugin.mjs +1 -1
- package/dist/plugins/funcspanRollupPlugin.cjs +1 -1
- package/dist/plugins/funcspanRollupPlugin.mjs +1 -1
- package/dist/plugins/funcspanTscPlugin.cjs +1 -1
- package/dist/plugins/funcspanTscPlugin.mjs +1 -1
- package/dist/plugins/funcspanVitePlugin.cjs +1 -1
- package/dist/plugins/funcspanVitePlugin.mjs +1 -1
- package/dist/plugins/funcspanWebpackPlugin.cjs +1 -1
- package/dist/plugins/funcspanWebpackPlugin.mjs +1 -1
- package/dist/{runtimeConfig-BgTE3gmS.cjs → runtimeConfig-D18ZMMnT.cjs} +1 -1
- package/dist/{runtimeConfig-B6ERoLRD.js → runtimeConfig-Dmaavj6j.js} +1 -1
- package/dist/sf-veritas.cjs +13 -13
- package/dist/sf-veritas.mjs +1551 -1200
- package/dist/telemetryWorker.cjs +1 -1
- package/dist/types/baseTransmitter.d.ts +8 -11
- package/dist/types/contextManager.d.ts +0 -1
- package/dist/types/funcSpanCapture.d.ts +2 -0
- package/dist/types/funcSpanConfig.d.ts +60 -5
- package/dist/types/functionSpanCaptureRules.d.ts +133 -0
- package/dist/types/functionSpanCaptureSession.d.ts +77 -0
- package/dist/types/functionSpanTransmitter.d.ts +22 -3
- package/dist/types/setupConfig.d.ts +2 -0
- package/dist/types/uplinkClient.d.ts +20 -0
- package/dist/types/uuidPool.d.ts +31 -0
- package/dist/worker-pool-capture.cjs +1 -1
- package/dist/worker-pool-capture.mjs +1 -1
- package/dist/workerPoolSpanCapture-DDrqOj7z.cjs +83 -0
- package/dist/workerPoolSpanCapture-SpiqdLu-.js +709 -0
- package/package.json +4 -2
- package/dist/contextManager-B1hI1vbB.cjs +0 -1
- package/dist/workerPoolSpanCapture-B5AjE5B9.js +0 -575
- package/dist/workerPoolSpanCapture-CVp5eCI6.cjs +0 -83
package/README.md
CHANGED
|
@@ -278,6 +278,25 @@ addOrUpdateMetadata("user-123", { birthday: "2000-01-01" }, true);
|
|
|
278
278
|
|
|
279
279
|
By following these steps, you can seamlessly integrate `sf-veritas` into your Node.js project and start capturing LEaPS (Logs, Exceptions, and Print Statements) effectively!
|
|
280
280
|
|
|
281
|
+
## Debug Mode
|
|
282
|
+
|
|
283
|
+
Sailfish supports a server-triggered debug mode that turns on full
|
|
284
|
+
function-span capture (arguments, return values, timings) for a
|
|
285
|
+
time-bounded, budget-bounded window — for live backend services
|
|
286
|
+
(Kafka consumers, message-queue workers, cron jobs).
|
|
287
|
+
|
|
288
|
+
The collector holds a Node WebSocket connection to the Sailfish backend
|
|
289
|
+
via the `ws` package. When the UI enables debug for a service identifier,
|
|
290
|
+
the rule list is broadcast to every pod of that service simultaneously
|
|
291
|
+
via Redis pub/sub on the backend, applied through a process-wide override
|
|
292
|
+
on the funcSpan resolver. Rules support per-function targeting,
|
|
293
|
+
argument-value conditions (`==`, `!=`, `<=`, `starts_with`, etc.), child-call
|
|
294
|
+
propagation, and per-rule sample rates.
|
|
295
|
+
|
|
296
|
+
Disable via `SF_DEBUG_MODE_DISABLED=true`. See
|
|
297
|
+
[`docs/docs-enterprise/debug-mode.md`](../../docs/docs-enterprise/debug-mode.md)
|
|
298
|
+
for the full user-facing description, rule schema, and limitations.
|
|
299
|
+
|
|
281
300
|
## Release Notes
|
|
282
301
|
|
|
283
302
|
### 0.3.2-alpha1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const A=require("async_hooks"),V=require("child_process"),N=require("fs"),F=require("fs/promises"),w=require("os");function x(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const B=x(F),m=x(w),i=[];for(let n=0;n<256;++n)i.push((n+256).toString(16).slice(1));let f;const W=new Uint8Array(16),L={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function v(n,e,t){if(L.randomUUID&&!n)return L.randomUUID();const r=(n=n||{}).random??n.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(W)})();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(s,o=0){return(i[s[o+0]]+i[s[o+1]]+i[s[o+2]]+i[s[o+3]]+"-"+i[s[o+4]]+i[s[o+5]]+"-"+i[s[o+6]]+i[s[o+7]]+"-"+i[s[o+8]]+i[s[o+9]]+"-"+i[s[o+10]]+i[s[o+11]]+i[s[o+12]]+i[s[o+13]]+i[s[o+14]]+i[s[o+15]]).toLowerCase()})(r)}class K{apiKey;apiGraphqlEndpoint;sfDebug;serviceIdentifier;serviceVersion;serviceUUID;serviceAdditionalMetadata;profilingModeEnabled;profilingMaxDepth;profilingMaxVariableSizeKb;domainsToNotPropagateHeadersTo;domainsToPropagateHeadersTo;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;bullmqBulkAggregateMode;retryOnClientError;dataSensitivityLevel;exceptionCaptureLocals;uplinkEnable;uplinkUrl;_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=v(),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.domainsToPropagateHeadersTo=e?.domainsToPropagateHeadersTo!==void 0?e.domainsToPropagateHeadersTo:["*"],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||N.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||""}}:N.existsSync("/.dockerenv")?{type:"Docker",details:{}}:{type:"Unknown",details:{os:m.platform(),arch:m.arch(),nodeVersion:process.version}}})();this.infrastructureType=r.type,this.infrastructureDetails=r.details;const s=(function(){const H=[{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=[],g=new Set;for(const{pkg:h,name:C}of H)if(!g.has(C))try{require.resolve(h),d.push(C),g.add(C)}catch{}if(typeof process<"u"){if(!g.has("nuxtjs")&&globalThis._importMeta_!==void 0){let h=!1;try{(globalThis._importMeta_?.url||"").includes(".output/server")&&(h=!0)}catch{}h&&(d.unshift("nuxtjs"),g.add("nuxtjs"))}!g.has("meteorjs")&&process.env.METEOR_SHELL_DIR&&(d.unshift("meteorjs"),g.add("meteorjs"))}return{framework:d.length>0?d[0]:null,additionalFrameworks:d.slice(1),serviceRole:d.includes("nextjs")||d.includes("nuxtjs")?"fullstack":"backend"}})();this.framework=s.framework??void 0,this.additionalFrameworks=s.additionalFrameworks,this.serviceRole=s.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",this.bullmqBulkAggregateMode=process.env.SF_BULLMQ_BULK_AGGREGATE==="true";const c=parseInt(process.env.SF_NETWORKHOP_REQUEST_LIMIT_MB||"1",10);this.requestBodyLimitBytes=1024*(isNaN(c)?1:c)*1024;const p=parseInt(process.env.SF_NETWORKHOP_RESPONSE_LIMIT_MB||"1",10);this.responseBodyLimitBytes=1024*(isNaN(p)?1:p)*1024;const u=(process.env.SF_RETRY_ON_CLIENT_ERROR||"").toLowerCase(),k=u==="all"||u==="idempotent"||u==="none"?u:void 0;this.retryOnClientError=k??e.retryOnClientError??"all",this.dataSensitivityLevel=process.env.SAILFISH_DATA_SENSITIVITY_LEVEL||"standard",this.exceptionCaptureLocals=process.env.SAILFISH_EXCEPTION_CAPTURE_LOCALS!=="false",this.uplinkEnable=process.env.SF_UPLINK_ENABLE!=="false",this.uplinkUrl=process.env.SF_UPLINK_URL||""}getPackageVersion(){return"0.2.14"}get serviceIdentificationReceived(){return this._serviceIdentificationReceived}setServiceIdentificationReceived(e){this._serviceIdentificationReceived=e}}const M=Symbol.for("sailfish.sf_config");function O(){return globalThis[M]}function S(){const n=O();if(!n)throw new Error("Configuration has not been initialized. Call getOrCreateConfig(options) first.");return n}const y=Symbol.for("sf.ctx.storeAls"),a=globalThis,T=a[y]??(a[y]=new A.AsyncLocalStorage),b="nonsession-applogs",G=["identitytoolkit.googleapis.com","t.co","*.twitter.com","*.gravatar.com","*.googleapis.com","*.amazonaws.com","*.smooch.io","*.zendesk.com"],D=Symbol.for("sf.ctx.als"),E=a[D]??(a[D]=new A.AsyncLocalStorage),P=Symbol.for("sf.ctx.fnSpanAls"),R=a[P]??(a[P]=new A.AsyncLocalStorage),U=Symbol.for("sf.ctx.sessionRegistry"),_=a[U]??(a[U]=new Map),I={handledExceptions:new Set,reentrancyGuardLoggingActive:!1,reentrancyGuardLoggingPreActive:!1,reentrancyGuardPrintActive:!1,reentrancyGuardPrintPreActive:!1,reentrancyGuardExceptionActive:!1,reentrancyGuardExceptionPreActive:!1,excludedDomains:new Set(G),supportedDomains:new Set};class l{static GLOBAL_MANAGER_SYMBOL=Symbol.for("sf.ctx.manager");constructor(){}current(){return T.getStore()}ensureStore(){const e=this.current();if(e)return e;const t=new Map;return T.enterWith(t),t}runWith(e,t){const r=this.current()??new Map,s=new Map(r);for(const[o,c]of Object.entries(e))s.set(o,c);return T.run(s,t)}static getInstance(){return a[l.GLOBAL_MANAGER_SYMBOL]||(a[l.GLOBAL_MANAGER_SYMBOL]=new l),a[l.GLOBAL_MANAGER_SYMBOL]}getCurrentContext(){return E.getStore()||I}setCurrentContext(e){const t=E.getStore()||I;E.enterWith({...t,...e})}ensureSession(e){let t=_.get(e);return t||(t={...I},_.set(e,t)),t}getContextFor(e){return _.get(e)??I}updateContextFor(e,t){const r=this.ensureSession(e);_.set(e,{...r,...t})}runWithSession(e,t){const r={...this.ensureSession(e)};return E.run(r,t)}deleteSession(e){_.delete(e)}runScoped(e,t){const r=E.getStore()??I,s={...r,handledExceptions:new Set(r.handledExceptions),excludedDomains:new Set(r.excludedDomains),supportedDomains:new Set(r.supportedDomains),...e};return E.run(s,t)}getTraceId(){return this.getCurrentContext().traceId}getPageVisitUUID(){return this.getCurrentContext().pageVisitUUID}setTraceId(e){this.setCurrentContext({traceId:e})}setPageVisitUUID(e){this.setCurrentContext({pageVisitUUID:e})}getCurrentFunctionSpanId(){return R.getStore()}setCurrentFunctionSpanId(e){R.enterWith(e)}clearCurrentFunctionSpanId(){R.enterWith(void 0)}getOrSetSfTraceId(e,t=!1){let r=this.getTraceId();return r||(r=e||(t?v():`${b}-v3/${S().apiKey}/${v()}`),this.setTraceId(r),S().sfDebug&&console.log(" Created new trace ID:",r),r)}getOrSetPageVisitUUID(){let e=this.getPageVisitUUID();return e||(e=v(),this.setPageVisitUUID(e),S().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=l,exports.DEFAULT_DOMAINS_TO_EXCLUDE=G,exports.NONSESSION_APPLOGS=b,exports.backfillGitInfoAsync=async function(n){if(!(n.gitOrg&&n.gitRepo&&n.gitProvider))try{const e=await(async function(){let t="";try{t=await new Promise((r,s)=>{V.execFile("git",["remote","get-url","origin"],{timeout:3e3},(o,c)=>{o?s(o):r((c||"").trim())})})}catch{try{const r=(await B.readFile(".git/config","utf-8")).match(/\[remote "origin"\][^[]*url\s*=\s*(.+)/m);r&&(t=r[1].trim())}catch{}}return t?(function(r){let s,o,c;if(r.includes("github.com")?s="github":r.includes("gitlab.com")?s="gitlab":r.includes("bitbucket.org")&&(s="bitbucket"),r.startsWith("https://")||r.startsWith("http://")){const p=r.split("/");p.length>=5&&(o=p[3],c=p[4].replace(/\.git$/,""))}else{const p=r.indexOf(":");if(p>0){const u=r.substring(p+1).replace(/\.git$/,"").split("/");u.length>=2&&(o=u[0],c=u[1])}}return{org:o,repo:c,provider:s}})(t):{}})();n.gitOrg||(n.gitOrg=e.org),n.gitRepo||(n.gitRepo=e.repo),n.gitProvider||(n.gitProvider=e.provider)}catch{}},exports.getConfig=S,exports.getCurrentFunctionSpanId=function(){return l.getInstance().getCurrentFunctionSpanId()},exports.getGlobalConfigUnsafe=O,exports.getOrCreateConfig=function(n){const e=O();if(e)return{config:e};const t=new K(n);(function(s){globalThis[M]=s})(t);const r=globalThis;return r.__sf_configEpoch=(r.__sf_configEpoch??0)+1,t.sfDebug&&console.log("[[getOrCreateConfig]] Created global config:",t),{config:t}},exports.runWithContext=function(n){const e={...l.getInstance().getCurrentContext()};E.run(e,()=>{n()})},exports.v4=v;
|
|
@@ -1,113 +1,115 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { AsyncLocalStorage as
|
|
5
|
-
import { execFile as
|
|
6
|
-
import { existsSync as
|
|
7
|
-
import * as
|
|
8
|
-
import * as
|
|
1
|
+
var H = Object.defineProperty;
|
|
2
|
+
var V = (o, e, t) => e in o ? H(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var s = (o, e, t) => V(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { AsyncLocalStorage as N } from "async_hooks";
|
|
5
|
+
import { execFile as F } from "child_process";
|
|
6
|
+
import { existsSync as A } from "fs";
|
|
7
|
+
import * as B from "fs/promises";
|
|
8
|
+
import * as L from "os";
|
|
9
9
|
const a = [];
|
|
10
|
-
for (let
|
|
10
|
+
for (let o = 0; o < 256; ++o) a.push((o + 256).toString(16).slice(1));
|
|
11
11
|
let T;
|
|
12
|
-
const
|
|
13
|
-
function
|
|
14
|
-
if (
|
|
15
|
-
const
|
|
12
|
+
const w = new Uint8Array(16), D = { randomUUID: typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto) };
|
|
13
|
+
function S(o, e, t) {
|
|
14
|
+
if (D.randomUUID && !o) return D.randomUUID();
|
|
15
|
+
const r = (o = o || {}).random ?? o.rng?.() ?? (function() {
|
|
16
16
|
if (!T) {
|
|
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
18
|
T = crypto.getRandomValues.bind(crypto);
|
|
19
19
|
}
|
|
20
|
-
return T(
|
|
20
|
+
return T(w);
|
|
21
21
|
})();
|
|
22
|
-
if (
|
|
23
|
-
return
|
|
24
|
-
return (a[
|
|
25
|
-
})(
|
|
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(n, i = 0) {
|
|
24
|
+
return (a[n[i + 0]] + a[n[i + 1]] + a[n[i + 2]] + a[n[i + 3]] + "-" + a[n[i + 4]] + a[n[i + 5]] + "-" + a[n[i + 6]] + a[n[i + 7]] + "-" + a[n[i + 8]] + a[n[i + 9]] + "-" + a[n[i + 10]] + a[n[i + 11]] + a[n[i + 12]] + a[n[i + 13]] + a[n[i + 14]] + a[n[i + 15]]).toLowerCase();
|
|
25
|
+
})(r);
|
|
26
26
|
}
|
|
27
|
-
class
|
|
27
|
+
class K {
|
|
28
28
|
constructor(e) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
this
|
|
29
|
+
s(this, "apiKey");
|
|
30
|
+
s(this, "apiGraphqlEndpoint");
|
|
31
|
+
s(this, "sfDebug");
|
|
32
|
+
s(this, "serviceIdentifier");
|
|
33
|
+
s(this, "serviceVersion");
|
|
34
|
+
s(this, "serviceUUID");
|
|
35
|
+
s(this, "serviceAdditionalMetadata");
|
|
36
|
+
s(this, "profilingModeEnabled");
|
|
37
|
+
s(this, "profilingMaxDepth");
|
|
38
|
+
s(this, "profilingMaxVariableSizeKb");
|
|
39
|
+
s(this, "domainsToNotPropagateHeadersTo");
|
|
40
|
+
s(this, "domainsToPropagateHeadersTo");
|
|
41
|
+
s(this, "nodeModulesToCollectLocalVariablesOn");
|
|
42
|
+
s(this, "printConfigurationStatuses");
|
|
43
|
+
s(this, "logLevel");
|
|
44
|
+
s(this, "stackDepthLocals");
|
|
45
|
+
s(this, "stackDepthCodeTraceDepth");
|
|
46
|
+
s(this, "packageLibraryType");
|
|
47
|
+
s(this, "version");
|
|
48
|
+
s(this, "gitSha");
|
|
49
|
+
s(this, "gitOrg");
|
|
50
|
+
s(this, "gitRepo");
|
|
51
|
+
s(this, "gitProvider");
|
|
52
|
+
s(this, "serviceDisplayName");
|
|
53
|
+
s(this, "infrastructureType");
|
|
54
|
+
s(this, "infrastructureDetails");
|
|
55
|
+
s(this, "framework");
|
|
56
|
+
s(this, "additionalFrameworks");
|
|
57
|
+
s(this, "serviceRole");
|
|
58
|
+
s(this, "setupInterceptorsFile");
|
|
59
|
+
s(this, "setupInterceptorsLine");
|
|
60
|
+
s(this, "logIgnoreRegex");
|
|
61
|
+
s(this, "captureRequestHeaders");
|
|
62
|
+
s(this, "captureResponseHeaders");
|
|
63
|
+
s(this, "captureRequestBody");
|
|
64
|
+
s(this, "captureResponseBody");
|
|
65
|
+
s(this, "requestBodyLimitBytes");
|
|
66
|
+
s(this, "responseBodyLimitBytes");
|
|
67
|
+
s(this, "bullmqBulkAggregateMode");
|
|
68
|
+
s(this, "retryOnClientError");
|
|
69
|
+
s(this, "dataSensitivityLevel");
|
|
70
|
+
s(this, "exceptionCaptureLocals");
|
|
71
|
+
s(this, "uplinkEnable");
|
|
72
|
+
s(this, "uplinkUrl");
|
|
73
|
+
s(this, "_serviceIdentificationReceived", !1);
|
|
74
|
+
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 = S(), 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;
|
|
73
75
|
const t = process.env.GITHUB_REPOSITORY?.split("/");
|
|
74
76
|
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.domainsToPropagateHeadersTo = e?.domainsToPropagateHeadersTo !== void 0 ? e.domainsToPropagateHeadersTo : ["*"], 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();
|
|
75
|
-
const
|
|
76
|
-
return process.env.KUBERNETES_SERVICE_HOST ||
|
|
77
|
+
const r = (function() {
|
|
78
|
+
return process.env.KUBERNETES_SERVICE_HOST || A("/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 || "" } } : A("/.dockerenv") ? { type: "Docker", details: {} } : { type: "Unknown", details: { os: L.platform(), arch: L.arch(), nodeVersion: process.version } };
|
|
77
79
|
})();
|
|
78
|
-
this.infrastructureType =
|
|
79
|
-
const
|
|
80
|
-
const
|
|
81
|
-
for (const { pkg:
|
|
82
|
-
require.resolve(
|
|
80
|
+
this.infrastructureType = r.type, this.infrastructureDetails = r.details;
|
|
81
|
+
const n = (function() {
|
|
82
|
+
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" }], l = [], _ = /* @__PURE__ */ new Set();
|
|
83
|
+
for (const { pkg: I, name: R } of G) if (!_.has(R)) try {
|
|
84
|
+
require.resolve(I), l.push(R), _.add(R);
|
|
83
85
|
} catch {
|
|
84
86
|
}
|
|
85
87
|
if (typeof process < "u") {
|
|
86
88
|
if (!_.has("nuxtjs") && globalThis._importMeta_ !== void 0) {
|
|
87
|
-
let
|
|
89
|
+
let I = !1;
|
|
88
90
|
try {
|
|
89
|
-
(globalThis._importMeta_?.url || "").includes(".output/server") && (
|
|
91
|
+
(globalThis._importMeta_?.url || "").includes(".output/server") && (I = !0);
|
|
90
92
|
} catch {
|
|
91
93
|
}
|
|
92
|
-
|
|
94
|
+
I && (l.unshift("nuxtjs"), _.add("nuxtjs"));
|
|
93
95
|
}
|
|
94
96
|
!_.has("meteorjs") && process.env.METEOR_SHELL_DIR && (l.unshift("meteorjs"), _.add("meteorjs"));
|
|
95
97
|
}
|
|
96
98
|
return { framework: l.length > 0 ? l[0] : null, additionalFrameworks: l.slice(1), serviceRole: l.includes("nextjs") || l.includes("nuxtjs") ? "fullstack" : "backend" };
|
|
97
99
|
})();
|
|
98
|
-
this.framework =
|
|
100
|
+
this.framework = n.framework ?? void 0, this.additionalFrameworks = n.additionalFrameworks, this.serviceRole = n.serviceRole;
|
|
99
101
|
const i = process.env.SF_LOG_IGNORE_REGEX;
|
|
100
102
|
if (i) try {
|
|
101
103
|
this.logIgnoreRegex = new RegExp(i);
|
|
102
104
|
} catch {
|
|
103
105
|
}
|
|
104
106
|
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", this.bullmqBulkAggregateMode = process.env.SF_BULLMQ_BULK_AGGREGATE === "true";
|
|
105
|
-
const
|
|
106
|
-
this.requestBodyLimitBytes = 1024 * (isNaN(
|
|
107
|
-
const
|
|
108
|
-
this.responseBodyLimitBytes = 1024 * (isNaN(
|
|
109
|
-
const u = (process.env.SF_RETRY_ON_CLIENT_ERROR || "").toLowerCase(),
|
|
110
|
-
this.retryOnClientError =
|
|
107
|
+
const p = parseInt(process.env.SF_NETWORKHOP_REQUEST_LIMIT_MB || "1", 10);
|
|
108
|
+
this.requestBodyLimitBytes = 1024 * (isNaN(p) ? 1 : p) * 1024;
|
|
109
|
+
const d = parseInt(process.env.SF_NETWORKHOP_RESPONSE_LIMIT_MB || "1", 10);
|
|
110
|
+
this.responseBodyLimitBytes = 1024 * (isNaN(d) ? 1 : d) * 1024;
|
|
111
|
+
const u = (process.env.SF_RETRY_ON_CLIENT_ERROR || "").toLowerCase(), k = u === "all" || u === "idempotent" || u === "none" ? u : void 0;
|
|
112
|
+
this.retryOnClientError = k ?? e.retryOnClientError ?? "all", this.dataSensitivityLevel = process.env.SAILFISH_DATA_SENSITIVITY_LEVEL || "standard", this.exceptionCaptureLocals = process.env.SAILFISH_EXCEPTION_CAPTURE_LOCALS !== "false", this.uplinkEnable = process.env.SF_UPLINK_ENABLE !== "false", this.uplinkUrl = process.env.SF_UPLINK_URL || "";
|
|
111
113
|
}
|
|
112
114
|
getPackageVersion() {
|
|
113
115
|
return "0.2.14";
|
|
@@ -119,60 +121,62 @@ class B {
|
|
|
119
121
|
this._serviceIdentificationReceived = e;
|
|
120
122
|
}
|
|
121
123
|
}
|
|
122
|
-
async function
|
|
123
|
-
if (!(
|
|
124
|
+
async function J(o) {
|
|
125
|
+
if (!(o.gitOrg && o.gitRepo && o.gitProvider)) try {
|
|
124
126
|
const e = await (async function() {
|
|
125
127
|
let t = "";
|
|
126
128
|
try {
|
|
127
|
-
t = await new Promise((
|
|
128
|
-
|
|
129
|
-
i ?
|
|
129
|
+
t = await new Promise((r, n) => {
|
|
130
|
+
F("git", ["remote", "get-url", "origin"], { timeout: 3e3 }, (i, p) => {
|
|
131
|
+
i ? n(i) : r((p || "").trim());
|
|
130
132
|
});
|
|
131
133
|
});
|
|
132
134
|
} catch {
|
|
133
135
|
try {
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
+
const r = (await B.readFile(".git/config", "utf-8")).match(/\[remote "origin"\][^[]*url\s*=\s*(.+)/m);
|
|
137
|
+
r && (t = r[1].trim());
|
|
136
138
|
} catch {
|
|
137
139
|
}
|
|
138
140
|
}
|
|
139
|
-
return t ? (function(
|
|
140
|
-
let
|
|
141
|
-
if (
|
|
142
|
-
const
|
|
143
|
-
|
|
141
|
+
return t ? (function(r) {
|
|
142
|
+
let n, i, p;
|
|
143
|
+
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://")) {
|
|
144
|
+
const d = r.split("/");
|
|
145
|
+
d.length >= 5 && (i = d[3], p = d[4].replace(/\.git$/, ""));
|
|
144
146
|
} else {
|
|
145
|
-
const
|
|
146
|
-
if (
|
|
147
|
-
const u =
|
|
148
|
-
u.length >= 2 && (i = u[0],
|
|
147
|
+
const d = r.indexOf(":");
|
|
148
|
+
if (d > 0) {
|
|
149
|
+
const u = r.substring(d + 1).replace(/\.git$/, "").split("/");
|
|
150
|
+
u.length >= 2 && (i = u[0], p = u[1]);
|
|
149
151
|
}
|
|
150
152
|
}
|
|
151
|
-
return { org: i, repo:
|
|
153
|
+
return { org: i, repo: p, provider: n };
|
|
152
154
|
})(t) : {};
|
|
153
155
|
})();
|
|
154
|
-
|
|
156
|
+
o.gitOrg || (o.gitOrg = e.org), o.gitRepo || (o.gitRepo = e.repo), o.gitProvider || (o.gitProvider = e.provider);
|
|
155
157
|
} catch {
|
|
156
158
|
}
|
|
157
159
|
}
|
|
158
|
-
const
|
|
159
|
-
function
|
|
160
|
-
return globalThis[
|
|
160
|
+
const M = Symbol.for("sailfish.sf_config");
|
|
161
|
+
function b() {
|
|
162
|
+
return globalThis[M];
|
|
161
163
|
}
|
|
162
|
-
function
|
|
163
|
-
const e =
|
|
164
|
+
function Q(o) {
|
|
165
|
+
const e = b();
|
|
164
166
|
if (e) return { config: e };
|
|
165
|
-
const t = new
|
|
166
|
-
|
|
167
|
-
globalThis[
|
|
168
|
-
})(t)
|
|
167
|
+
const t = new K(o);
|
|
168
|
+
(function(n) {
|
|
169
|
+
globalThis[M] = n;
|
|
170
|
+
})(t);
|
|
171
|
+
const r = globalThis;
|
|
172
|
+
return r.__sf_configEpoch = (r.__sf_configEpoch ?? 0) + 1, t.sfDebug && console.log("[[getOrCreateConfig]] Created global config:", t), { config: t };
|
|
169
173
|
}
|
|
170
174
|
function f() {
|
|
171
|
-
const
|
|
172
|
-
if (!
|
|
173
|
-
return
|
|
175
|
+
const o = b();
|
|
176
|
+
if (!o) throw new Error("Configuration has not been initialized. Call getOrCreateConfig(options) first.");
|
|
177
|
+
return o;
|
|
174
178
|
}
|
|
175
|
-
const
|
|
179
|
+
const y = Symbol.for("sf.ctx.storeAls"), c = globalThis, O = c[y] ?? (c[y] = new N()), W = "nonsession-applogs", Y = ["identitytoolkit.googleapis.com", "t.co", "*.twitter.com", "*.gravatar.com", "*.googleapis.com", "*.amazonaws.com", "*.smooch.io", "*.zendesk.com"], U = Symbol.for("sf.ctx.als"), E = c[U] ?? (c[U] = new N()), P = Symbol.for("sf.ctx.fnSpanAls"), m = c[P] ?? (c[P] = new N()), x = Symbol.for("sf.ctx.sessionRegistry"), v = c[x] ?? (c[x] = /* @__PURE__ */ new Map()), h = { handledExceptions: /* @__PURE__ */ new Set(), reentrancyGuardLoggingActive: !1, reentrancyGuardLoggingPreActive: !1, reentrancyGuardPrintActive: !1, reentrancyGuardPrintPreActive: !1, reentrancyGuardExceptionActive: !1, reentrancyGuardExceptionPreActive: !1, excludedDomains: new Set(Y), supportedDomains: /* @__PURE__ */ new Set() }, g = class g {
|
|
176
180
|
constructor() {
|
|
177
181
|
}
|
|
178
182
|
current() {
|
|
@@ -185,41 +189,41 @@ const L = Symbol.for("sf.ctx.storeAls"), d = globalThis, O = d[L] ?? (d[L] = new
|
|
|
185
189
|
return O.enterWith(t), t;
|
|
186
190
|
}
|
|
187
191
|
runWith(e, t) {
|
|
188
|
-
const
|
|
189
|
-
for (const [i,
|
|
190
|
-
return O.run(
|
|
192
|
+
const r = this.current() ?? /* @__PURE__ */ new Map(), n = new Map(r);
|
|
193
|
+
for (const [i, p] of Object.entries(e)) n.set(i, p);
|
|
194
|
+
return O.run(n, t);
|
|
191
195
|
}
|
|
192
196
|
static getInstance() {
|
|
193
|
-
return
|
|
197
|
+
return c[g.GLOBAL_MANAGER_SYMBOL] || (c[g.GLOBAL_MANAGER_SYMBOL] = new g()), c[g.GLOBAL_MANAGER_SYMBOL];
|
|
194
198
|
}
|
|
195
199
|
getCurrentContext() {
|
|
196
|
-
return E.getStore() ||
|
|
200
|
+
return E.getStore() || h;
|
|
197
201
|
}
|
|
198
202
|
setCurrentContext(e) {
|
|
199
|
-
const t = E.getStore() ||
|
|
203
|
+
const t = E.getStore() || h;
|
|
200
204
|
E.enterWith({ ...t, ...e });
|
|
201
205
|
}
|
|
202
206
|
ensureSession(e) {
|
|
203
|
-
let t =
|
|
204
|
-
return t || (t = { ...
|
|
207
|
+
let t = v.get(e);
|
|
208
|
+
return t || (t = { ...h }, v.set(e, t)), t;
|
|
205
209
|
}
|
|
206
210
|
getContextFor(e) {
|
|
207
|
-
return
|
|
211
|
+
return v.get(e) ?? h;
|
|
208
212
|
}
|
|
209
213
|
updateContextFor(e, t) {
|
|
210
|
-
const
|
|
211
|
-
|
|
214
|
+
const r = this.ensureSession(e);
|
|
215
|
+
v.set(e, { ...r, ...t });
|
|
212
216
|
}
|
|
213
217
|
runWithSession(e, t) {
|
|
214
|
-
const
|
|
215
|
-
return E.run(
|
|
218
|
+
const r = { ...this.ensureSession(e) };
|
|
219
|
+
return E.run(r, t);
|
|
216
220
|
}
|
|
217
221
|
deleteSession(e) {
|
|
218
|
-
|
|
222
|
+
v.delete(e);
|
|
219
223
|
}
|
|
220
224
|
runScoped(e, t) {
|
|
221
|
-
const
|
|
222
|
-
return E.run(
|
|
225
|
+
const r = E.getStore() ?? h, n = { ...r, handledExceptions: new Set(r.handledExceptions), excludedDomains: new Set(r.excludedDomains), supportedDomains: new Set(r.supportedDomains), ...e };
|
|
226
|
+
return E.run(n, t);
|
|
223
227
|
}
|
|
224
228
|
getTraceId() {
|
|
225
229
|
return this.getCurrentContext().traceId;
|
|
@@ -234,21 +238,21 @@ const L = Symbol.for("sf.ctx.storeAls"), d = globalThis, O = d[L] ?? (d[L] = new
|
|
|
234
238
|
this.setCurrentContext({ pageVisitUUID: e });
|
|
235
239
|
}
|
|
236
240
|
getCurrentFunctionSpanId() {
|
|
237
|
-
return
|
|
241
|
+
return m.getStore();
|
|
238
242
|
}
|
|
239
243
|
setCurrentFunctionSpanId(e) {
|
|
240
|
-
|
|
244
|
+
m.enterWith(e);
|
|
241
245
|
}
|
|
242
246
|
clearCurrentFunctionSpanId() {
|
|
243
|
-
|
|
247
|
+
m.enterWith(void 0);
|
|
244
248
|
}
|
|
245
249
|
getOrSetSfTraceId(e, t = !1) {
|
|
246
|
-
let
|
|
247
|
-
return
|
|
250
|
+
let r = this.getTraceId();
|
|
251
|
+
return r || (r = e || (t ? S() : `${W}-v3/${f().apiKey}/${S()}`), this.setTraceId(r), f().sfDebug && console.log(" Created new trace ID:", r), r);
|
|
248
252
|
}
|
|
249
253
|
getOrSetPageVisitUUID() {
|
|
250
254
|
let e = this.getPageVisitUUID();
|
|
251
|
-
return e || (e =
|
|
255
|
+
return e || (e = S(), this.setPageVisitUUID(e), f().sfDebug && console.log(" Created new page visit UUID:", e), e);
|
|
252
256
|
}
|
|
253
257
|
getHandledExceptions() {
|
|
254
258
|
return this.getCurrentContext().handledExceptions;
|
|
@@ -279,26 +283,26 @@ const L = Symbol.for("sf.ctx.storeAls"), d = globalThis, O = d[L] ?? (d[L] = new
|
|
|
279
283
|
this.updateContextFor(e, { pageVisitUUID: t });
|
|
280
284
|
}
|
|
281
285
|
};
|
|
282
|
-
|
|
283
|
-
let
|
|
284
|
-
function
|
|
285
|
-
const e = { ...
|
|
286
|
+
s(g, "GLOBAL_MANAGER_SYMBOL", Symbol.for("sf.ctx.manager"));
|
|
287
|
+
let C = g;
|
|
288
|
+
function $(o) {
|
|
289
|
+
const e = { ...C.getInstance().getCurrentContext() };
|
|
286
290
|
E.run(e, () => {
|
|
287
|
-
|
|
291
|
+
o();
|
|
288
292
|
});
|
|
289
293
|
}
|
|
290
|
-
function
|
|
291
|
-
return
|
|
294
|
+
function Z() {
|
|
295
|
+
return C.getInstance().getCurrentFunctionSpanId();
|
|
292
296
|
}
|
|
293
297
|
export {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
298
|
+
C,
|
|
299
|
+
Y as D,
|
|
300
|
+
W as N,
|
|
301
|
+
b as a,
|
|
302
|
+
Z as b,
|
|
303
|
+
Q as c,
|
|
304
|
+
J as d,
|
|
301
305
|
f as g,
|
|
302
|
-
|
|
303
|
-
|
|
306
|
+
$ as r,
|
|
307
|
+
S as v
|
|
304
308
|
};
|
|
@@ -1 +1 @@
|
|
|
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-
|
|
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-D18ZMMnT.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,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync as r } from "fs";
|
|
2
2
|
import { t as c } from "../funcSpanTransformer-S_WeAt_m.js";
|
|
3
3
|
import { t as p } from "../consoleLocationTransformer-DZu_9MDA.js";
|
|
4
|
-
import { s as f } from "../runtimeConfig-
|
|
4
|
+
import { s as f } from "../runtimeConfig-Dmaavj6j.js";
|
|
5
5
|
function j(a = {}) {
|
|
6
6
|
try {
|
|
7
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() {
|
|
@@ -1 +1 @@
|
|
|
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-
|
|
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-D18ZMMnT.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,6 +1,6 @@
|
|
|
1
1
|
import { t as c } from "../funcSpanTransformer-S_WeAt_m.js";
|
|
2
2
|
import { t as p } from "../consoleLocationTransformer-DZu_9MDA.js";
|
|
3
|
-
import { s as f } from "../runtimeConfig-
|
|
3
|
+
import { s as f } from "../runtimeConfig-Dmaavj6j.js";
|
|
4
4
|
function h(r = {}) {
|
|
5
5
|
try {
|
|
6
6
|
if (f()) return console.warn("[FuncSpan Rollup Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"), { name: "sailfish-funcspan-rollup-disabled" };
|
|
@@ -1 +1 @@
|
|
|
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-
|
|
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-D18ZMMnT.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;
|
|
@@ -3,7 +3,7 @@ import { sync as _ } from "glob";
|
|
|
3
3
|
import { resolve as D } from "path";
|
|
4
4
|
import { t as T } from "../funcSpanTransformer-S_WeAt_m.js";
|
|
5
5
|
import { t as U } from "../consoleLocationTransformer-DZu_9MDA.js";
|
|
6
|
-
import { s as $ } from "../runtimeConfig-
|
|
6
|
+
import { s as $ } from "../runtimeConfig-Dmaavj6j.js";
|
|
7
7
|
async function v(n = {}) {
|
|
8
8
|
try {
|
|
9
9
|
if ($()) return void console.warn("[FuncSpan TSC Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../funcSpanTransformer-D0W2t41q.cjs"),a=require("../consoleLocationTransformer-BSSB5msZ.cjs"),f=require("../runtimeConfig-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../funcSpanTransformer-D0W2t41q.cjs"),a=require("../consoleLocationTransformer-BSSB5msZ.cjs"),f=require("../runtimeConfig-D18ZMMnT.cjs");exports.funcspanVitePlugin=function(l={}){try{if(f.shouldEnableRuntimeHooks())return console.warn("[FuncSpan Vite Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"),{name:"sailfish-funcspan-vite-disabled"}}catch{}const{enabled:c=!0,includeNodeModules:t=[],debug:o=!1}=l;return{name:"sailfish-funcspan-vite",enforce:"pre",async transform(s,e){if(!c||!e.match(/\.(js|ts|jsx|tsx)$/)||e.startsWith("\0")||e.includes("node_modules")&&!t.some(n=>e.includes(`node_modules/${n}`))||e.includes("@sailfish-ai/sf-veritas")||e.includes("jsts-backend/dist"))return null;try{let n=s,i=!1;const u=await d.transformFunctionSpans(n,e,{projectRoot:process.cwd(),includeNodeModules:t,debug:o});u.modified&&(n=u.code,i=!0);const r=await a.transformConsoleLocations(n,e,{projectRoot:process.cwd(),includeNodeModules:t,debug:o});if(r.modified&&(n=r.code,i=!0),i)return{code:n,map:null}}catch(n){o&&console.error(`[FuncSpan Vite] Error transforming ${e}:`,n)}return null}}};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as d } from "../funcSpanTransformer-S_WeAt_m.js";
|
|
2
2
|
import { t as a } from "../consoleLocationTransformer-DZu_9MDA.js";
|
|
3
|
-
import { s as f } from "../runtimeConfig-
|
|
3
|
+
import { s as f } from "../runtimeConfig-Dmaavj6j.js";
|
|
4
4
|
function g(l = {}) {
|
|
5
5
|
try {
|
|
6
6
|
if (f()) return console.warn("[FuncSpan Vite Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation"), { name: "sailfish-funcspan-vite-disabled" };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("../runtimeConfig-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("../runtimeConfig-D18ZMMnT.cjs"),a=require("path"),P=require("url");function m(r){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const n in r)if(n!=="default"){const t=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(o,n,t.get?t:{enumerable:!0,get:()=>r[n]})}}return o.default=r,Object.freeze(o)}const f=m(a);class u{options;constructor(o={}){this.options={enabled:!0,includeNodeModules:[],debug:!1,enableWorkerPoolTracking:!1,workerPoolTrackDns:!1,workerPoolTrackFs:!1,workerPoolTrackCrypto:!1,workerPoolTrackZlib:!1,...o}}apply(o){try{if(b.shouldEnableRuntimeHooks())return void console.warn("[FuncSpan Webpack Plugin] Runtime mode active - build plugin DISABLED to prevent double-instrumentation")}catch{}const{enabled:n,includeNodeModules:t,debug:c}=this.options;if(!n)return;const l="FuncspanWebpackPlugin";o.hooks.compilation.tap(l,s=>{s.hooks.buildModule.tap(l,i=>{i.resource&&i.resource.match(/\.(js|ts|jsx|tsx)$/)&&(!i.resource.includes("node_modules")||t?.some(e=>i.resource.includes(`node_modules/${e}`)))}),o.webpack.NormalModule.getCompilationHooks(s).loader.tap(l,(i,e)=>{if(!e.resource||!e.resource.match(/\.(js|ts|jsx|tsx)$/)||e.resource.includes("node_modules")&&!t?.some(p=>e.resource.includes(`node_modules/${p}`)))return;const d=typeof __dirname<"u"?__dirname:a.dirname(P.fileURLToPath(require("node:url").pathToFileURL(__filename).href)),k=f.join(d,"funcspanWebpackLoader.cjs");e.loaders.push({loader:k,options:{projectRoot:o.context,includeNodeModules:t,debug:c,enableWorkerPoolTracking:this.options.enableWorkerPoolTracking,workerPoolTrackDns:this.options.workerPoolTrackDns,workerPoolTrackFs:this.options.workerPoolTrackFs,workerPoolTrackCrypto:this.options.workerPoolTrackCrypto,workerPoolTrackZlib:this.options.workerPoolTrackZlib}})})}),c&&console.log("[FuncSpan Webpack] Plugin initialized")}}exports.FuncspanWebpackPlugin=u,exports.default=u;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var k = Object.defineProperty;
|
|
2
2
|
var m = (r, o, s) => o in r ? k(r, o, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[o] = s;
|
|
3
3
|
var c = (r, o, s) => m(r, typeof o != "symbol" ? o + "" : o, s);
|
|
4
|
-
import { s as b } from "../runtimeConfig-
|
|
4
|
+
import { s as b } from "../runtimeConfig-Dmaavj6j.js";
|
|
5
5
|
import * as P from "path";
|
|
6
6
|
import { dirname as T } from "path";
|
|
7
7
|
import { fileURLToPath as f } from "url";
|