@sailfish-ai/sf-veritas 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -0
- package/dist/{contextManager-D2ijKL-E.js → contextManager-C2ONL8XY.js} +68 -61
- package/dist/contextManager-CL0Qs7uI.cjs +1 -0
- 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-BUJ13zxm.js +474 -0
- package/dist/runtimeConfig-xahsyRmN.cjs +5 -0
- package/dist/sf-veritas.cjs +13 -13
- package/dist/sf-veritas.mjs +1664 -575
- package/dist/types/constants.d.ts +13 -0
- package/dist/types/contextManager.d.ts +15 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/patches/asyncQueues/_stubs/bee-queue.d.ts +10 -0
- package/dist/types/patches/asyncQueues/_stubs/rabbitmq.d.ts +11 -0
- package/dist/types/patches/asyncQueues/_stubs/sqs.d.ts +9 -0
- package/dist/types/patches/asyncQueues/asyncQueueTracer.d.ts +127 -0
- package/dist/types/patches/asyncQueues/asyncQueues.bench.d.ts +1 -0
- package/dist/types/patches/asyncQueues/bullmq.d.ts +27 -0
- package/dist/types/patches/asyncQueues/bullmqPro.d.ts +3 -0
- package/dist/types/patches/asyncQueues/confluentKafkaJs.d.ts +3 -0
- package/dist/types/patches/asyncQueues/index.d.ts +15 -0
- package/dist/types/patches/asyncQueues/kafkajs.d.ts +7 -0
- package/dist/types/requestTransmitter.d.ts +30 -0
- package/dist/types/setupConfig.d.ts +19 -0
- package/dist/types/urlMatch.d.ts +19 -0
- package/dist/worker-pool-capture.cjs +1 -1
- package/dist/worker-pool-capture.mjs +1 -1
- package/dist/{workerPoolSpanCapture-DzCJnMDA.cjs → workerPoolSpanCapture-C3T98kWy.cjs} +1 -1
- package/dist/{workerPoolSpanCapture-hyxgVqUF.js → workerPoolSpanCapture-DL8wfDIr.js} +1 -1
- package/package.json +2 -1
- package/dist/contextManager-BsolAr_q.cjs +0 -1
- package/dist/runtimeConfig-C4mv7SVM.js +0 -484
- package/dist/runtimeConfig-XIm4yAFB.cjs +0 -6
package/README.md
CHANGED
|
@@ -280,6 +280,41 @@ By following these steps, you can seamlessly integrate `sf-veritas` into your No
|
|
|
280
280
|
|
|
281
281
|
## Release Notes
|
|
282
282
|
|
|
283
|
+
### 0.3.2-alpha1
|
|
284
|
+
|
|
285
|
+
**Bug fix — outbound trace-header format matches Python**
|
|
286
|
+
|
|
287
|
+
Pre-0.3.2, the SDK emitted `X-Sf3-Rid = ${traceId}/${pageVisitUUID}/${networkUUID}`, producing a 5-segment string when `traceId` already had 3 segments (always, since `getOrSetSfTraceId()` returns either `session/page/request` for inbound-traced requests or `nonsession-applogs-v3/<apiKey>/<uuid>` for fresh ones). Server-side parsers that split on `/` and take `[0]`, `[1]`, `[last]` interpreted the string as garbage for nonsession-applogs traces — `sessionId` came out as the literal string `"nonsession-applogs-v3"` (identical for every nonsession customer) and `pageVisitId` as the customer's API key.
|
|
288
|
+
|
|
289
|
+
0.3.2 matches Python's `thread_local.py:1349` contract:
|
|
290
|
+
|
|
291
|
+
- **`X-Sf3-Rid`** is 3 segments: `<first-2-segments-of-trace>/<fresh-uuid>`.
|
|
292
|
+
- Session inbound: `session/page/<newUUID>` (newUUID unique per outbound).
|
|
293
|
+
- Nonsession: `nonsession-applogs-v3/<apiKey>/<newUUID>`.
|
|
294
|
+
- **`X-Sf4-Prid`** (new) carries the full parent trace id, mirroring Python's `PARENT_SESSION_ID_HEADER`. Server-side code can use this for parent-chain reconstruction.
|
|
295
|
+
|
|
296
|
+
**Feature — `domainsToPropagateHeadersTo` allowlist**
|
|
297
|
+
|
|
298
|
+
New `SetupOptions.domainsToPropagateHeadersTo` option (`string[]`, default `["*"]`). Enumerates domains whose outbound requests receive the tracing header. Supports the same wildcard syntax as the jsts-frontend matcher (`*`, `*.example.com`, `api.example.com/v1/*`, `example.com:8080`).
|
|
299
|
+
|
|
300
|
+
Interaction with existing `domainsToNotPropagateHeadersTo` and `DEFAULT_DOMAINS_TO_EXCLUDE`: **deny wins on conflict**. Exact decision logic:
|
|
301
|
+
|
|
302
|
+
```
|
|
303
|
+
propagate = matches(url, allowlist)
|
|
304
|
+
&& NOT matches(url, denylist)
|
|
305
|
+
&& NOT matches(url, DEFAULT_DOMAINS_TO_EXCLUDE)
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
Default `["*"]` preserves pre-0.3.2 behavior (all domains allowed, defaults/denylist still block). Set to `[]` to block every outbound propagation.
|
|
309
|
+
|
|
310
|
+
**Feature-parity audit published**
|
|
311
|
+
|
|
312
|
+
A detailed comparison of this package with the Python Sailfish SDK is now tracked in [`PYTHON_PARITY_GAPS.md`](./PYTHON_PARITY_GAPS.md). 12 gaps are enumerated with priority and effort for future PR planning — including queue instrumentation (BullMQ, Kafka), `reinitializeAfterFork()`, local-variable capture in exceptions, and manual-dispatch APIs.
|
|
313
|
+
|
|
314
|
+
**Test coverage**
|
|
315
|
+
|
|
316
|
+
+44 new tests (wildcard matcher matrix, trace-header format, allow-list decision logic). Full suite: 357 → ~400 passing.
|
|
317
|
+
|
|
283
318
|
### 0.3.1
|
|
284
319
|
|
|
285
320
|
**Critical fix — GraphQL error passthrough**
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
var G = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var r = (n, e, t) =>
|
|
4
|
-
import { AsyncLocalStorage as
|
|
5
|
-
import { execFile as
|
|
2
|
+
var H = (n, e, t) => e in n ? G(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var r = (n, e, t) => H(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { AsyncLocalStorage as P } from "async_hooks";
|
|
5
|
+
import { execFile as V } from "child_process";
|
|
6
6
|
import { existsSync as m } from "fs";
|
|
7
|
-
import * as
|
|
7
|
+
import * as k from "fs/promises";
|
|
8
8
|
import * as N from "os";
|
|
9
9
|
const a = [];
|
|
10
10
|
for (let n = 0; n < 256; ++n) a.push((n + 256).toString(16).slice(1));
|
|
11
|
-
let
|
|
12
|
-
const
|
|
11
|
+
let T;
|
|
12
|
+
const F = new Uint8Array(16), A = { randomUUID: typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto) };
|
|
13
13
|
function C(n, e, t) {
|
|
14
14
|
if (A.randomUUID && !n) return A.randomUUID();
|
|
15
15
|
const s = (n = n || {}).random ?? n.rng?.() ?? (function() {
|
|
16
|
-
if (!
|
|
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
|
|
20
|
+
return T(F);
|
|
21
21
|
})();
|
|
22
22
|
if (s.length < 16) throw new Error("Random bytes length must be >= 16");
|
|
23
23
|
return s[6] = 15 & s[6] | 64, s[8] = 63 & s[8] | 128, (function(o, i = 0) {
|
|
24
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
|
})(s);
|
|
26
26
|
}
|
|
27
|
-
class
|
|
27
|
+
class B {
|
|
28
28
|
constructor(e) {
|
|
29
29
|
r(this, "apiKey");
|
|
30
30
|
r(this, "apiGraphqlEndpoint");
|
|
@@ -37,6 +37,7 @@ class w {
|
|
|
37
37
|
r(this, "profilingMaxDepth");
|
|
38
38
|
r(this, "profilingMaxVariableSizeKb");
|
|
39
39
|
r(this, "domainsToNotPropagateHeadersTo");
|
|
40
|
+
r(this, "domainsToPropagateHeadersTo");
|
|
40
41
|
r(this, "nodeModulesToCollectLocalVariablesOn");
|
|
41
42
|
r(this, "printConfigurationStatuses");
|
|
42
43
|
r(this, "logLevel");
|
|
@@ -63,33 +64,34 @@ class w {
|
|
|
63
64
|
r(this, "captureResponseBody");
|
|
64
65
|
r(this, "requestBodyLimitBytes");
|
|
65
66
|
r(this, "responseBodyLimitBytes");
|
|
67
|
+
r(this, "bullmqBulkAggregateMode");
|
|
66
68
|
r(this, "retryOnClientError");
|
|
67
69
|
r(this, "_serviceIdentificationReceived", !1);
|
|
68
70
|
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;
|
|
69
71
|
const t = process.env.GITHUB_REPOSITORY?.split("/");
|
|
70
|
-
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();
|
|
72
|
+
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();
|
|
71
73
|
const s = (function() {
|
|
72
74
|
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 } };
|
|
73
75
|
})();
|
|
74
76
|
this.infrastructureType = s.type, this.infrastructureDetails = s.details;
|
|
75
77
|
const o = (function() {
|
|
76
|
-
const b = [{ 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" }],
|
|
77
|
-
for (const { pkg:
|
|
78
|
-
require.resolve(
|
|
78
|
+
const b = [{ 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();
|
|
79
|
+
for (const { pkg: I, name: R } of b) if (!_.has(R)) try {
|
|
80
|
+
require.resolve(I), l.push(R), _.add(R);
|
|
79
81
|
} catch {
|
|
80
82
|
}
|
|
81
83
|
if (typeof process < "u") {
|
|
82
|
-
if (!
|
|
83
|
-
let
|
|
84
|
+
if (!_.has("nuxtjs") && globalThis._importMeta_ !== void 0) {
|
|
85
|
+
let I = !1;
|
|
84
86
|
try {
|
|
85
|
-
(globalThis._importMeta_?.url || "").includes(".output/server") && (
|
|
87
|
+
(globalThis._importMeta_?.url || "").includes(".output/server") && (I = !0);
|
|
86
88
|
} catch {
|
|
87
89
|
}
|
|
88
|
-
|
|
90
|
+
I && (l.unshift("nuxtjs"), _.add("nuxtjs"));
|
|
89
91
|
}
|
|
90
|
-
!
|
|
92
|
+
!_.has("meteorjs") && process.env.METEOR_SHELL_DIR && (l.unshift("meteorjs"), _.add("meteorjs"));
|
|
91
93
|
}
|
|
92
|
-
return { framework:
|
|
94
|
+
return { framework: l.length > 0 ? l[0] : null, additionalFrameworks: l.slice(1), serviceRole: l.includes("nextjs") || l.includes("nuxtjs") ? "fullstack" : "backend" };
|
|
93
95
|
})();
|
|
94
96
|
this.framework = o.framework ?? void 0, this.additionalFrameworks = o.additionalFrameworks, this.serviceRole = o.serviceRole;
|
|
95
97
|
const i = process.env.SF_LOG_IGNORE_REGEX;
|
|
@@ -97,12 +99,12 @@ class w {
|
|
|
97
99
|
this.logIgnoreRegex = new RegExp(i);
|
|
98
100
|
} catch {
|
|
99
101
|
}
|
|
100
|
-
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";
|
|
102
|
+
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";
|
|
101
103
|
const c = parseInt(process.env.SF_NETWORKHOP_REQUEST_LIMIT_MB || "1", 10);
|
|
102
104
|
this.requestBodyLimitBytes = 1024 * (isNaN(c) ? 1 : c) * 1024;
|
|
103
105
|
const p = parseInt(process.env.SF_NETWORKHOP_RESPONSE_LIMIT_MB || "1", 10);
|
|
104
106
|
this.responseBodyLimitBytes = 1024 * (isNaN(p) ? 1 : p) * 1024;
|
|
105
|
-
const
|
|
107
|
+
const u = (process.env.SF_RETRY_ON_CLIENT_ERROR || "").toLowerCase(), M = u === "all" || u === "idempotent" || u === "none" ? u : void 0;
|
|
106
108
|
this.retryOnClientError = M ?? e.retryOnClientError ?? "all";
|
|
107
109
|
}
|
|
108
110
|
getPackageVersion() {
|
|
@@ -115,19 +117,19 @@ class w {
|
|
|
115
117
|
this._serviceIdentificationReceived = e;
|
|
116
118
|
}
|
|
117
119
|
}
|
|
118
|
-
async function
|
|
120
|
+
async function X(n) {
|
|
119
121
|
if (!(n.gitOrg && n.gitRepo && n.gitProvider)) try {
|
|
120
122
|
const e = await (async function() {
|
|
121
123
|
let t = "";
|
|
122
124
|
try {
|
|
123
125
|
t = await new Promise((s, o) => {
|
|
124
|
-
|
|
126
|
+
V("git", ["remote", "get-url", "origin"], { timeout: 3e3 }, (i, c) => {
|
|
125
127
|
i ? o(i) : s((c || "").trim());
|
|
126
128
|
});
|
|
127
129
|
});
|
|
128
130
|
} catch {
|
|
129
131
|
try {
|
|
130
|
-
const s = (await
|
|
132
|
+
const s = (await k.readFile(".git/config", "utf-8")).match(/\[remote "origin"\][^[]*url\s*=\s*(.+)/m);
|
|
131
133
|
s && (t = s[1].trim());
|
|
132
134
|
} catch {
|
|
133
135
|
}
|
|
@@ -140,8 +142,8 @@ async function q(n) {
|
|
|
140
142
|
} else {
|
|
141
143
|
const p = s.indexOf(":");
|
|
142
144
|
if (p > 0) {
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
+
const u = s.substring(p + 1).replace(/\.git$/, "").split("/");
|
|
146
|
+
u.length >= 2 && (i = u[0], c = u[1]);
|
|
145
147
|
}
|
|
146
148
|
}
|
|
147
149
|
return { org: i, repo: c, provider: o };
|
|
@@ -151,24 +153,24 @@ async function q(n) {
|
|
|
151
153
|
} catch {
|
|
152
154
|
}
|
|
153
155
|
}
|
|
154
|
-
const
|
|
156
|
+
const U = Symbol.for("sailfish.sf_config");
|
|
155
157
|
function x() {
|
|
156
|
-
return globalThis[
|
|
158
|
+
return globalThis[U];
|
|
157
159
|
}
|
|
158
|
-
function
|
|
160
|
+
function z(n) {
|
|
159
161
|
const e = x();
|
|
160
162
|
if (e) return { config: e };
|
|
161
|
-
const t = new
|
|
163
|
+
const t = new B(n);
|
|
162
164
|
return (function(s) {
|
|
163
|
-
globalThis[
|
|
165
|
+
globalThis[U] = s;
|
|
164
166
|
})(t), t.sfDebug && console.log("[[getOrCreateConfig]] Created global config:", t), { config: t };
|
|
165
167
|
}
|
|
166
|
-
function
|
|
168
|
+
function f() {
|
|
167
169
|
const n = x();
|
|
168
170
|
if (!n) throw new Error("Configuration has not been initialized. Call getOrCreateConfig(options) first.");
|
|
169
171
|
return n;
|
|
170
172
|
}
|
|
171
|
-
const D = Symbol.for("sf.ctx.storeAls"),
|
|
173
|
+
const D = Symbol.for("sf.ctx.storeAls"), d = globalThis, O = d[D] ?? (d[D] = new P()), w = "nonsession-applogs", K = ["identitytoolkit.googleapis.com", "t.co", "*.twitter.com", "*.gravatar.com", "*.googleapis.com", "*.amazonaws.com", "*.smooch.io", "*.zendesk.com"], L = Symbol.for("sf.ctx.als"), E = d[L] ?? (d[L] = new P()), y = Symbol.for("sf.ctx.sessionRegistry"), h = d[y] ?? (d[y] = /* @__PURE__ */ new Map()), v = { handledExceptions: /* @__PURE__ */ new Set(), reentrancyGuardLoggingActive: !1, reentrancyGuardLoggingPreActive: !1, reentrancyGuardPrintActive: !1, reentrancyGuardPrintPreActive: !1, reentrancyGuardExceptionActive: !1, reentrancyGuardExceptionPreActive: !1, excludedDomains: new Set(K), supportedDomains: /* @__PURE__ */ new Set() }, g = class g {
|
|
172
174
|
constructor() {
|
|
173
175
|
}
|
|
174
176
|
current() {
|
|
@@ -186,32 +188,36 @@ const D = Symbol.for("sf.ctx.storeAls"), u = globalThis, O = u[D] ?? (u[D] = new
|
|
|
186
188
|
return O.run(o, t);
|
|
187
189
|
}
|
|
188
190
|
static getInstance() {
|
|
189
|
-
return
|
|
191
|
+
return d[g.GLOBAL_MANAGER_SYMBOL] || (d[g.GLOBAL_MANAGER_SYMBOL] = new g()), d[g.GLOBAL_MANAGER_SYMBOL];
|
|
190
192
|
}
|
|
191
193
|
getCurrentContext() {
|
|
192
|
-
return
|
|
194
|
+
return E.getStore() || v;
|
|
193
195
|
}
|
|
194
196
|
setCurrentContext(e) {
|
|
195
|
-
const t =
|
|
196
|
-
|
|
197
|
+
const t = E.getStore() || v;
|
|
198
|
+
E.enterWith({ ...t, ...e });
|
|
197
199
|
}
|
|
198
200
|
ensureSession(e) {
|
|
199
|
-
let t =
|
|
200
|
-
return t || (t = { ...
|
|
201
|
+
let t = h.get(e);
|
|
202
|
+
return t || (t = { ...v }, h.set(e, t)), t;
|
|
201
203
|
}
|
|
202
204
|
getContextFor(e) {
|
|
203
|
-
return
|
|
205
|
+
return h.get(e) ?? v;
|
|
204
206
|
}
|
|
205
207
|
updateContextFor(e, t) {
|
|
206
208
|
const s = this.ensureSession(e);
|
|
207
|
-
|
|
209
|
+
h.set(e, { ...s, ...t });
|
|
208
210
|
}
|
|
209
211
|
runWithSession(e, t) {
|
|
210
212
|
const s = { ...this.ensureSession(e) };
|
|
211
|
-
return
|
|
213
|
+
return E.run(s, t);
|
|
212
214
|
}
|
|
213
215
|
deleteSession(e) {
|
|
214
|
-
|
|
216
|
+
h.delete(e);
|
|
217
|
+
}
|
|
218
|
+
runScoped(e, t) {
|
|
219
|
+
const s = E.getStore() ?? v, o = { ...s, handledExceptions: new Set(s.handledExceptions), excludedDomains: new Set(s.excludedDomains), supportedDomains: new Set(s.supportedDomains), ...e };
|
|
220
|
+
return E.run(o, t);
|
|
215
221
|
}
|
|
216
222
|
getTraceId() {
|
|
217
223
|
return this.getCurrentContext().traceId;
|
|
@@ -236,11 +242,11 @@ const D = Symbol.for("sf.ctx.storeAls"), u = globalThis, O = u[D] ?? (u[D] = new
|
|
|
236
242
|
}
|
|
237
243
|
getOrSetSfTraceId(e, t = !1) {
|
|
238
244
|
let s = this.getTraceId();
|
|
239
|
-
return s || (s = e || (t ? C() :
|
|
245
|
+
return s || (s = e || (t ? C() : `${w}-v3/${f().apiKey}/${C()}`), this.setTraceId(s), f().sfDebug && console.log(" Created new trace ID:", s), s);
|
|
240
246
|
}
|
|
241
247
|
getOrSetPageVisitUUID() {
|
|
242
248
|
let e = this.getPageVisitUUID();
|
|
243
|
-
return e || (e = C(), this.setPageVisitUUID(e),
|
|
249
|
+
return e || (e = C(), this.setPageVisitUUID(e), f().sfDebug && console.log(" Created new page visit UUID:", e), e);
|
|
244
250
|
}
|
|
245
251
|
getHandledExceptions() {
|
|
246
252
|
return this.getCurrentContext().handledExceptions;
|
|
@@ -271,25 +277,26 @@ const D = Symbol.for("sf.ctx.storeAls"), u = globalThis, O = u[D] ?? (u[D] = new
|
|
|
271
277
|
this.updateContextFor(e, { pageVisitUUID: t });
|
|
272
278
|
}
|
|
273
279
|
};
|
|
274
|
-
r(
|
|
275
|
-
let
|
|
276
|
-
function
|
|
277
|
-
const e = { ...
|
|
278
|
-
|
|
280
|
+
r(g, "GLOBAL_MANAGER_SYMBOL", Symbol.for("sf.ctx.manager"));
|
|
281
|
+
let S = g;
|
|
282
|
+
function J(n) {
|
|
283
|
+
const e = { ...S.getInstance().getCurrentContext() };
|
|
284
|
+
E.run(e, () => {
|
|
279
285
|
n();
|
|
280
286
|
});
|
|
281
287
|
}
|
|
282
|
-
function
|
|
283
|
-
return
|
|
288
|
+
function Q() {
|
|
289
|
+
return S.getInstance().getCurrentFunctionSpanId();
|
|
284
290
|
}
|
|
285
291
|
export {
|
|
286
|
-
|
|
287
|
-
|
|
292
|
+
S as C,
|
|
293
|
+
K as D,
|
|
294
|
+
w as N,
|
|
288
295
|
x as a,
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
296
|
+
Q as b,
|
|
297
|
+
z as c,
|
|
298
|
+
X as d,
|
|
299
|
+
f as g,
|
|
300
|
+
J as r,
|
|
294
301
|
C as v
|
|
295
302
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const y=require("async_hooks"),k=require("child_process"),O=require("fs"),F=require("fs/promises"),H=require("os");function P(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=P(F),m=P(H),i=[];for(let s=0;s<256;++s)i.push((s+256).toString(16).slice(1));let R;const w=new Uint8Array(16),N={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function h(s,e,t){if(N.randomUUID&&!s)return N.randomUUID();const r=(s=s||{}).random??s.rng?.()??(function(){if(!R){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");R=crypto.getRandomValues.bind(crypto)}return R(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(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 B{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;_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=h(),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||O.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||""}}:O.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 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"}],d=[],E=new Set;for(const{pkg:v,name:S}of G)if(!E.has(S))try{require.resolve(v),d.push(S),E.add(S)}catch{}if(typeof process<"u"){if(!E.has("nuxtjs")&&globalThis._importMeta_!==void 0){let v=!1;try{(globalThis._importMeta_?.url||"").includes(".output/server")&&(v=!0)}catch{}v&&(d.unshift("nuxtjs"),E.add("nuxtjs"))}!E.has("meteorjs")&&process.env.METEOR_SHELL_DIR&&(d.unshift("meteorjs"),E.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=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",this.bullmqBulkAggregateMode=process.env.SF_BULLMQ_BULK_AGGREGATE==="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;const u=(process.env.SF_RETRY_ON_CLIENT_ERROR||"").toLowerCase(),b=u==="all"||u==="idempotent"||u==="none"?u:void 0;this.retryOnClientError=b??e.retryOnClientError??"all"}getPackageVersion(){return"0.2.14"}get serviceIdentificationReceived(){return this._serviceIdentificationReceived}setServiceIdentificationReceived(e){this._serviceIdentificationReceived=e}}const U=Symbol.for("sailfish.sf_config");function f(){return globalThis[U]}function C(){const s=f();if(!s)throw new Error("Configuration has not been initialized. Call getOrCreateConfig(options) first.");return s}const A=Symbol.for("sf.ctx.storeAls"),p=globalThis,T=p[A]??(p[A]=new y.AsyncLocalStorage),x="nonsession-applogs",M=["identitytoolkit.googleapis.com","t.co","*.twitter.com","*.gravatar.com","*.googleapis.com","*.amazonaws.com","*.smooch.io","*.zendesk.com"],D=Symbol.for("sf.ctx.als"),g=p[D]??(p[D]=new y.AsyncLocalStorage),L=Symbol.for("sf.ctx.sessionRegistry"),_=p[L]??(p[L]=new Map),I={handledExceptions:new Set,reentrancyGuardLoggingActive:!1,reentrancyGuardLoggingPreActive:!1,reentrancyGuardPrintActive:!1,reentrancyGuardPrintPreActive:!1,reentrancyGuardExceptionActive:!1,reentrancyGuardExceptionPreActive:!1,excludedDomains:new Set(M),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,n=new Map(r);for(const[o,a]of Object.entries(e))n.set(o,a);return T.run(n,t)}static getInstance(){return p[l.GLOBAL_MANAGER_SYMBOL]||(p[l.GLOBAL_MANAGER_SYMBOL]=new l),p[l.GLOBAL_MANAGER_SYMBOL]}getCurrentContext(){return g.getStore()||I}setCurrentContext(e){const t=g.getStore()||I;g.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 g.run(r,t)}deleteSession(e){_.delete(e)}runScoped(e,t){const r=g.getStore()??I,n={...r,handledExceptions:new Set(r.handledExceptions),excludedDomains:new Set(r.excludedDomains),supportedDomains:new Set(r.supportedDomains),...e};return g.run(n,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 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?h():`${x}-v3/${C().apiKey}/${h()}`),this.setTraceId(r),C().sfDebug&&console.log(" Created new trace ID:",r),r)}getOrSetPageVisitUUID(){let e=this.getPageVisitUUID();return e||(e=h(),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=l,exports.DEFAULT_DOMAINS_TO_EXCLUDE=M,exports.NONSESSION_APPLOGS=x,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)=>{k.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 u=r.substring(c+1).replace(/\.git$/,"").split("/");u.length>=2&&(o=u[0],a=u[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 l.getInstance().getCurrentFunctionSpanId()},exports.getGlobalConfigUnsafe=f,exports.getOrCreateConfig=function(s){const e=f();if(e)return{config:e};const t=new B(s);return(function(r){globalThis[U]=r})(t),t.sfDebug&&console.log("[[getOrCreateConfig]] Created global config:",t),{config:t}},exports.runWithContext=function(s){const e={...l.getInstance().getCurrentContext()};g.run(e,()=>{s()})},exports.v4=h;
|
|
@@ -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-xahsyRmN.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-BUJ13zxm.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-xahsyRmN.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-BUJ13zxm.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-xahsyRmN.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-BUJ13zxm.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-xahsyRmN.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-BUJ13zxm.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-xahsyRmN.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-BUJ13zxm.js";
|
|
5
5
|
import * as P from "path";
|
|
6
6
|
import { dirname as T } from "path";
|
|
7
7
|
import { fileURLToPath as f } from "url";
|