@sailfish-ai/sf-veritas 0.2.5 → 0.2.6
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/dist/plugins/funcspanWebpackLoader.cjs +1 -1
- package/dist/plugins/funcspanWebpackLoader.mjs +65 -8
- package/dist/plugins/funcspanWebpackPlugin.cjs +1 -1
- package/dist/plugins/funcspanWebpackPlugin.mjs +24 -24
- package/dist/sf-veritas.cjs +16 -98
- package/dist/sf-veritas.mjs +532 -1207
- package/dist/types/plugins/funcspanWebpackPlugin.d.ts +20 -0
- package/dist/types/plugins/workerPoolTransformer.d.ts +42 -0
- package/dist/types/worker-pool-capture.d.ts +9 -0
- package/dist/worker-pool-capture.cjs +1 -0
- package/dist/worker-pool-capture.mjs +4 -0
- package/dist/workerPoolSpanCapture-BOnYC4s3.js +705 -0
- package/dist/workerPoolSpanCapture-CNEouInA.cjs +83 -0
- package/package.json +6 -1
package/dist/sf-veritas.mjs
CHANGED
|
@@ -1,257 +1,17 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
1
|
+
var Ae = Object.defineProperty;
|
|
2
|
+
var fe = (o, e, t) => e in o ? Ae(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var A = (o, e, t) => fe(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { B as F, g as d, n as W, C as N, s as ye, a as Ze, D as Ge, b as le, p as de, v as Ie, d as $, e as ue, f as Se, m as R, c as _, h as Be, i as X, j as We, k as Ce, t as E, F as ve } from "./workerPoolSpanCapture-BOnYC4s3.js";
|
|
5
|
+
import { r as Ct } from "./workerPoolSpanCapture-BOnYC4s3.js";
|
|
6
|
+
import * as L from "fs";
|
|
7
|
+
import { readFileSync as pe, appendFileSync as Ne } from "fs";
|
|
8
|
+
import { s as me } from "./funcSpanTransformer-sqmZLAcs.js";
|
|
9
|
+
import { t as mt } from "./funcSpanTransformer-sqmZLAcs.js";
|
|
10
|
+
import { Worker as Fe, threadId as J } from "worker_threads";
|
|
11
|
+
import { createRequire as we } from "node:module";
|
|
11
12
|
import * as G from "path";
|
|
12
|
-
import { glob as
|
|
13
|
-
|
|
14
|
-
for (let n = 0; n < 256; ++n) N.push((n + 256).toString(16).slice(1));
|
|
15
|
-
let ne;
|
|
16
|
-
const Qe = new Uint8Array(16), fe = { randomUUID: typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto) };
|
|
17
|
-
function w(n, e, t) {
|
|
18
|
-
if (fe.randomUUID && !n) return fe.randomUUID();
|
|
19
|
-
const s = (n = n || {}).random ?? n.rng?.() ?? (function() {
|
|
20
|
-
if (!ne) {
|
|
21
|
-
if (typeof crypto > "u" || !crypto.getRandomValues) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
22
|
-
ne = crypto.getRandomValues.bind(crypto);
|
|
23
|
-
}
|
|
24
|
-
return ne(Qe);
|
|
25
|
-
})();
|
|
26
|
-
if (s.length < 16) throw new Error("Random bytes length must be >= 16");
|
|
27
|
-
return s[6] = 15 & s[6] | 64, s[8] = 63 & s[8] | 128, (function(r, a = 0) {
|
|
28
|
-
return (N[r[a + 0]] + N[r[a + 1]] + N[r[a + 2]] + N[r[a + 3]] + "-" + N[r[a + 4]] + N[r[a + 5]] + "-" + N[r[a + 6]] + N[r[a + 7]] + "-" + N[r[a + 8]] + N[r[a + 9]] + "-" + N[r[a + 10]] + N[r[a + 11]] + N[r[a + 12]] + N[r[a + 13]] + N[r[a + 14]] + N[r[a + 15]]).toLowerCase();
|
|
29
|
-
})(s);
|
|
30
|
-
}
|
|
31
|
-
class qe {
|
|
32
|
-
constructor(e) {
|
|
33
|
-
C(this, "apiKey");
|
|
34
|
-
C(this, "apiGraphqlEndpoint");
|
|
35
|
-
C(this, "sfDebug");
|
|
36
|
-
C(this, "serviceIdentifier");
|
|
37
|
-
C(this, "serviceVersion");
|
|
38
|
-
C(this, "serviceUUID");
|
|
39
|
-
C(this, "serviceAdditionalMetadata");
|
|
40
|
-
C(this, "profilingModeEnabled");
|
|
41
|
-
C(this, "profilingMaxDepth");
|
|
42
|
-
C(this, "profilingMaxVariableSizeKb");
|
|
43
|
-
C(this, "domainsToNotPropagateHeadersTo");
|
|
44
|
-
C(this, "nodeModulesToCollectLocalVariablesOn");
|
|
45
|
-
C(this, "printConfigurationStatuses");
|
|
46
|
-
C(this, "logLevel");
|
|
47
|
-
C(this, "stackDepthLocals");
|
|
48
|
-
C(this, "stackDepthCodeTraceDepth");
|
|
49
|
-
C(this, "packageLibraryType");
|
|
50
|
-
C(this, "version");
|
|
51
|
-
C(this, "gitSha");
|
|
52
|
-
C(this, "_serviceIdentificationReceived", !1);
|
|
53
|
-
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 = w(), this.serviceVersion = e?.serviceVersion || process.env.SERVICE_VERSION, this.gitSha = e?.gitSha || process.env.GIT_SHA || process.env.VERCEL_GIT_COMMIT_SHA, 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();
|
|
54
|
-
}
|
|
55
|
-
getPackageVersion() {
|
|
56
|
-
return "0.1.15";
|
|
57
|
-
}
|
|
58
|
-
get serviceIdentificationReceived() {
|
|
59
|
-
return this._serviceIdentificationReceived;
|
|
60
|
-
}
|
|
61
|
-
setServiceIdentificationReceived(e) {
|
|
62
|
-
this._serviceIdentificationReceived = e;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
const $e = Symbol.for("sailfish.sf_config");
|
|
66
|
-
function H() {
|
|
67
|
-
return globalThis[$e];
|
|
68
|
-
}
|
|
69
|
-
function et(n) {
|
|
70
|
-
const e = H();
|
|
71
|
-
if (e) return { config: e };
|
|
72
|
-
const t = new qe(n);
|
|
73
|
-
return (function(s) {
|
|
74
|
-
globalThis[$e] = s;
|
|
75
|
-
})(t), t.sfDebug && console.log("[[getOrCreateConfig]] Created global config:", t), { config: t };
|
|
76
|
-
}
|
|
77
|
-
function d() {
|
|
78
|
-
const n = H();
|
|
79
|
-
if (!n) throw new Error("Configuration has not been initialized. Call getOrCreateConfig(options) first.");
|
|
80
|
-
return n;
|
|
81
|
-
}
|
|
82
|
-
const be = Symbol.for("sf.ctx.storeAls"), _ = globalThis, re = _[be] ?? (_[be] = new pe()), Ue = ["identitytoolkit.googleapis.com", "t.co", "*.twitter.com", "*.gravatar.com", "*.googleapis.com", "*.amazonaws.com", "*.smooch.io", "*.zendesk.com"], Ae = Symbol.for("sf.ctx.als"), k = _[Ae] ?? (_[Ae] = new pe()), ye = Symbol.for("sf.ctx.sessionRegistry"), K = _[ye] ?? (_[ye] = /* @__PURE__ */ new Map()), L = { handledExceptions: /* @__PURE__ */ new Set(), reentrancyGuardLoggingActive: !1, reentrancyGuardLoggingPreActive: !1, reentrancyGuardPrintActive: !1, reentrancyGuardPrintPreActive: !1, reentrancyGuardExceptionActive: !1, reentrancyGuardExceptionPreActive: !1, excludedDomains: new Set(Ue), supportedDomains: /* @__PURE__ */ new Set() }, R = class R {
|
|
83
|
-
constructor() {
|
|
84
|
-
}
|
|
85
|
-
current() {
|
|
86
|
-
return re.getStore();
|
|
87
|
-
}
|
|
88
|
-
ensureStore() {
|
|
89
|
-
const e = this.current();
|
|
90
|
-
if (e) return e;
|
|
91
|
-
const t = /* @__PURE__ */ new Map();
|
|
92
|
-
return re.enterWith(t), t;
|
|
93
|
-
}
|
|
94
|
-
runWith(e, t) {
|
|
95
|
-
const s = this.current() ?? /* @__PURE__ */ new Map(), r = new Map(s);
|
|
96
|
-
for (const [a, o] of Object.entries(e)) r.set(a, o);
|
|
97
|
-
return re.run(r, t);
|
|
98
|
-
}
|
|
99
|
-
static getInstance() {
|
|
100
|
-
return _[R.GLOBAL_MANAGER_SYMBOL] || (_[R.GLOBAL_MANAGER_SYMBOL] = new R()), _[R.GLOBAL_MANAGER_SYMBOL];
|
|
101
|
-
}
|
|
102
|
-
getCurrentContext() {
|
|
103
|
-
return k.getStore() || L;
|
|
104
|
-
}
|
|
105
|
-
setCurrentContext(e) {
|
|
106
|
-
const t = k.getStore() || L;
|
|
107
|
-
k.enterWith({ ...t, ...e });
|
|
108
|
-
}
|
|
109
|
-
ensureSession(e) {
|
|
110
|
-
let t = K.get(e);
|
|
111
|
-
return t || (t = { ...L }, K.set(e, t)), t;
|
|
112
|
-
}
|
|
113
|
-
getContextFor(e) {
|
|
114
|
-
return K.get(e) ?? L;
|
|
115
|
-
}
|
|
116
|
-
updateContextFor(e, t) {
|
|
117
|
-
const s = this.ensureSession(e);
|
|
118
|
-
K.set(e, { ...s, ...t });
|
|
119
|
-
}
|
|
120
|
-
runWithSession(e, t) {
|
|
121
|
-
const s = { ...this.ensureSession(e) };
|
|
122
|
-
return k.run(s, t);
|
|
123
|
-
}
|
|
124
|
-
deleteSession(e) {
|
|
125
|
-
K.delete(e);
|
|
126
|
-
}
|
|
127
|
-
getTraceId() {
|
|
128
|
-
return this.getCurrentContext().traceId;
|
|
129
|
-
}
|
|
130
|
-
getPageVisitUUID() {
|
|
131
|
-
return this.getCurrentContext().pageVisitUUID;
|
|
132
|
-
}
|
|
133
|
-
setTraceId(e) {
|
|
134
|
-
this.setCurrentContext({ traceId: e });
|
|
135
|
-
}
|
|
136
|
-
setPageVisitUUID(e) {
|
|
137
|
-
this.setCurrentContext({ pageVisitUUID: e });
|
|
138
|
-
}
|
|
139
|
-
getCurrentFunctionSpanId() {
|
|
140
|
-
return this.getCurrentContext().currentFunctionSpanId;
|
|
141
|
-
}
|
|
142
|
-
setCurrentFunctionSpanId(e) {
|
|
143
|
-
this.setCurrentContext({ currentFunctionSpanId: e });
|
|
144
|
-
}
|
|
145
|
-
clearCurrentFunctionSpanId() {
|
|
146
|
-
this.setCurrentContext({ currentFunctionSpanId: void 0 });
|
|
147
|
-
}
|
|
148
|
-
getOrSetSfTraceId(e, t = !1) {
|
|
149
|
-
let s = this.getTraceId();
|
|
150
|
-
return s || (s = e || (t ? w() : `nonsession-applogs-v3/${d().apiKey}/${w()}`), this.setTraceId(s), d().sfDebug && console.log(" Created new trace ID:", s), s);
|
|
151
|
-
}
|
|
152
|
-
getOrSetPageVisitUUID() {
|
|
153
|
-
let e = this.getPageVisitUUID();
|
|
154
|
-
return e || (e = w(), this.setPageVisitUUID(e), d().sfDebug && console.log(" Created new page visit UUID:", e), e);
|
|
155
|
-
}
|
|
156
|
-
getHandledExceptions() {
|
|
157
|
-
return this.getCurrentContext().handledExceptions;
|
|
158
|
-
}
|
|
159
|
-
markExceptionHandled(e) {
|
|
160
|
-
const t = this.getHandledExceptions();
|
|
161
|
-
t.add(e), this.setCurrentContext({ handledExceptions: t });
|
|
162
|
-
}
|
|
163
|
-
hasHandledException(e) {
|
|
164
|
-
return this.getHandledExceptions().has(e);
|
|
165
|
-
}
|
|
166
|
-
resetHandledExceptions() {
|
|
167
|
-
this.setCurrentContext({ handledExceptions: /* @__PURE__ */ new Set() });
|
|
168
|
-
}
|
|
169
|
-
getExcludedDomains() {
|
|
170
|
-
return this.getCurrentContext().excludedDomains;
|
|
171
|
-
}
|
|
172
|
-
getSupportedDomains() {
|
|
173
|
-
return this.getCurrentContext().supportedDomains;
|
|
174
|
-
}
|
|
175
|
-
addSupportedDomains(e) {
|
|
176
|
-
this.getCurrentContext().supportedDomains.add(e.toLowerCase().trim());
|
|
177
|
-
}
|
|
178
|
-
setTraceIdFor(e, t) {
|
|
179
|
-
this.updateContextFor(e, { traceId: t });
|
|
180
|
-
}
|
|
181
|
-
setPageVisitUUIDFor(e, t) {
|
|
182
|
-
this.updateContextFor(e, { pageVisitUUID: t });
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
C(R, "GLOBAL_MANAGER_SYMBOL", Symbol.for("sf.ctx.manager"));
|
|
186
|
-
let v = R;
|
|
187
|
-
function $t(n) {
|
|
188
|
-
const e = { ...v.getInstance().getCurrentContext() };
|
|
189
|
-
k.run(e, () => {
|
|
190
|
-
n();
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
function oe() {
|
|
194
|
-
return v.getInstance().getCurrentFunctionSpanId();
|
|
195
|
-
}
|
|
196
|
-
class $ {
|
|
197
|
-
constructor() {
|
|
198
|
-
C(this, "apiKey");
|
|
199
|
-
C(this, "endpoint");
|
|
200
|
-
C(this, "queryType", "mutation");
|
|
201
|
-
C(this, "operationName", "");
|
|
202
|
-
C(this, "serviceUUID", d().serviceUUID);
|
|
203
|
-
C(this, "contextManager");
|
|
204
|
-
this.apiKey = d().apiKey, this.endpoint = d().apiGraphqlEndpoint, this.contextManager = v.getInstance();
|
|
205
|
-
}
|
|
206
|
-
get queryName() {
|
|
207
|
-
return this.operationName ? this.operationName.charAt(0).toLowerCase() + this.operationName.slice(1) : "";
|
|
208
|
-
}
|
|
209
|
-
getDefaultVariables() {
|
|
210
|
-
const e = Date.now().toString(), t = this.contextManager.getOrSetSfTraceId(), s = this.contextManager.getCurrentFunctionSpanId();
|
|
211
|
-
return { apiKey: this.apiKey, serviceUuid: this.serviceUUID, sessionId: t, timestampMs: e, parentSpanId: s };
|
|
212
|
-
}
|
|
213
|
-
getVariables(e = {}) {
|
|
214
|
-
return { ...this.getDefaultVariables(), ...e };
|
|
215
|
-
}
|
|
216
|
-
setOperationName(e) {
|
|
217
|
-
this.operationName = e;
|
|
218
|
-
}
|
|
219
|
-
setEndpoint(e) {
|
|
220
|
-
this.endpoint = e;
|
|
221
|
-
}
|
|
222
|
-
setServiceUUID(e) {
|
|
223
|
-
this.serviceUUID = e;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
const tt = fetch;
|
|
227
|
-
let P = !1;
|
|
228
|
-
async function W(n, e, t, s) {
|
|
229
|
-
try {
|
|
230
|
-
const r = d();
|
|
231
|
-
let a;
|
|
232
|
-
try {
|
|
233
|
-
a = JSON.stringify({ query: t, variables: s, operationName: e });
|
|
234
|
-
} catch {
|
|
235
|
-
a = JSON.stringify({ query: t, operationName: e });
|
|
236
|
-
}
|
|
237
|
-
P = !0, tt(n, { method: "POST", headers: { "Content-Type": "application/json" }, body: a }).then(async (o) => {
|
|
238
|
-
if (P = !1, !o.ok) return void (r.sfDebug && console.error(`GraphQL request failed with status ${o.status} for ${e}`));
|
|
239
|
-
const i = await o.json();
|
|
240
|
-
i.errors?.length ? (function(c, l, g) {
|
|
241
|
-
const u = c && typeof c == "object" && !Array.isArray(c) ? Object.keys(c)[0] : void 0;
|
|
242
|
-
console.error(u === "identifyServiceDetails" ? `IdentifyServiceDetails NOT sent successfully for service: UUID=${g.serviceUUID}` : `GraphQL request failed with errors: ${JSON.stringify(l)} for operation key ${u}`);
|
|
243
|
-
})(i.data, i.errors, r) : r.sfDebug && (function(c, l, g) {
|
|
244
|
-
const u = c && typeof c == "object" && !Array.isArray(c) ? Object.keys(c)[0] : void 0, I = c[u] || !1;
|
|
245
|
-
u === "identifyServiceDetails" && (g.setServiceIdentificationReceived(I), d().sfDebug && console.log(`IdentifyServiceDetails sent successfully for service: UUID=${g.serviceUUID}; serviceIdentificationReceived=${u === "identifyServiceDetails" ? I : "N/A"}`));
|
|
246
|
-
})(i.data, 0, r);
|
|
247
|
-
}).catch((o) => {
|
|
248
|
-
P = !1, r.sfDebug && (console.error(`[RequestUtils] Fetch error for ${e} to ${n}:`, o), o.cause && console.error("[RequestUtils] Error cause:", o.cause));
|
|
249
|
-
});
|
|
250
|
-
} catch (r) {
|
|
251
|
-
P = !1, d().sfDebug && console.error("Error sending data to GraphQL server:", r);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
class X extends $ {
|
|
13
|
+
import { glob as Ve } from "glob";
|
|
14
|
+
class Y extends F {
|
|
255
15
|
constructor() {
|
|
256
16
|
super(), this.setOperationName("IdentifyServiceDetails");
|
|
257
17
|
}
|
|
@@ -291,38 +51,38 @@ class X extends $ {
|
|
|
291
51
|
W(this.endpoint, this.operationName, e, t);
|
|
292
52
|
}
|
|
293
53
|
}
|
|
294
|
-
function
|
|
54
|
+
function He(o) {
|
|
295
55
|
try {
|
|
296
|
-
return JSON.stringify(
|
|
56
|
+
return JSON.stringify(o), !0;
|
|
297
57
|
} catch {
|
|
298
58
|
return !1;
|
|
299
59
|
}
|
|
300
60
|
}
|
|
301
|
-
class
|
|
61
|
+
class Ye extends F {
|
|
302
62
|
constructor() {
|
|
303
63
|
super();
|
|
304
|
-
|
|
64
|
+
A(this, "serviceIdentifier", new Y());
|
|
305
65
|
this.setOperationName("CollectMetadata");
|
|
306
66
|
}
|
|
307
67
|
async sendAppIdentifier() {
|
|
308
68
|
this.serviceIdentifier.doSend({});
|
|
309
69
|
}
|
|
310
|
-
async doSend(t, s,
|
|
311
|
-
this.sendAppIdentifier(), this.send(t, s,
|
|
312
|
-
}
|
|
313
|
-
async send(t, s,
|
|
314
|
-
if (!s && !
|
|
315
|
-
let
|
|
316
|
-
if (!
|
|
317
|
-
const c = (function(
|
|
318
|
-
const
|
|
319
|
-
if (
|
|
320
|
-
return { traitsJson: JSON.stringify(
|
|
70
|
+
async doSend(t, s, n, i) {
|
|
71
|
+
this.sendAppIdentifier(), this.send(t, s, n, i);
|
|
72
|
+
}
|
|
73
|
+
async send(t, s, n, i) {
|
|
74
|
+
if (!s && !i) throw new Error('Must pass in either traits or traits_json to "add_or_update_traits"');
|
|
75
|
+
let g = [];
|
|
76
|
+
if (!i) {
|
|
77
|
+
const c = (function(a) {
|
|
78
|
+
const l = {}, I = [];
|
|
79
|
+
if (a) for (const [p, C] of Object.entries(a)) He(C) ? l[p] = C : I.push(p);
|
|
80
|
+
return { traitsJson: JSON.stringify(l), excludedFields: I };
|
|
321
81
|
})(s);
|
|
322
|
-
|
|
82
|
+
i = c.traitsJson, g = c.excludedFields;
|
|
323
83
|
}
|
|
324
|
-
const
|
|
325
|
-
W(this.endpoint, this.operationName, this.getQuery(),
|
|
84
|
+
const r = this.getVariables({ userId: t, traitsJson: i, excludedFields: g, override: n, library: d().packageLibraryType, version: d().version });
|
|
85
|
+
W(this.endpoint, this.operationName, this.getQuery(), r);
|
|
326
86
|
}
|
|
327
87
|
getQuery() {
|
|
328
88
|
return `
|
|
@@ -332,23 +92,23 @@ class rt extends $ {
|
|
|
332
92
|
`;
|
|
333
93
|
}
|
|
334
94
|
}
|
|
335
|
-
class
|
|
95
|
+
class he {
|
|
336
96
|
constructor(e) {
|
|
337
|
-
|
|
338
|
-
this.apiKey = e, this.metadataTransmitter = new
|
|
97
|
+
A(this, "metadataTransmitter");
|
|
98
|
+
this.apiKey = e, this.metadataTransmitter = new Ye();
|
|
339
99
|
}
|
|
340
|
-
identify(e, t, s,
|
|
341
|
-
t || s ? this.addOrUpdateMetadata(e, t, s,
|
|
100
|
+
identify(e, t, s, n = !1) {
|
|
101
|
+
t || s ? this.addOrUpdateMetadata(e, t, s, n) : this.addOrUpdateMetadata(e, {}, void 0, n);
|
|
342
102
|
}
|
|
343
|
-
addOrUpdateMetadata(e, t = {}, s,
|
|
103
|
+
addOrUpdateMetadata(e, t = {}, s, n = !1) {
|
|
344
104
|
if (!t && !s) throw new Error('Must pass in either traits or traitsJson to "addOrUpdateMetadata"');
|
|
345
|
-
d().sfDebug && console.log(" [[DEBUG - addOrUpdateMetadata]] Starting operation"), d().sfDebug && console.log(" addOrUpdateMetadata...SENDING DATA...", e, t, s), this.metadataTransmitter.doSend(e, t,
|
|
105
|
+
d().sfDebug && console.log(" [[DEBUG - addOrUpdateMetadata]] Starting operation"), d().sfDebug && console.log(" addOrUpdateMetadata...SENDING DATA...", e, t, s), this.metadataTransmitter.doSend(e, t, n, s);
|
|
346
106
|
}
|
|
347
107
|
}
|
|
348
|
-
class
|
|
108
|
+
class Q extends F {
|
|
349
109
|
constructor() {
|
|
350
110
|
super();
|
|
351
|
-
|
|
111
|
+
A(this, "serviceIdentifier", new Y());
|
|
352
112
|
}
|
|
353
113
|
async sendAppIdentifier() {
|
|
354
114
|
this.serviceIdentifier.doSend({});
|
|
@@ -358,8 +118,8 @@ class Ie extends $ {
|
|
|
358
118
|
}
|
|
359
119
|
async send(t) {
|
|
360
120
|
try {
|
|
361
|
-
const s = Array.isArray(t) ? t : [t, "default"],
|
|
362
|
-
W(this.endpoint, this.operationName, this.getQuery(),
|
|
121
|
+
const s = Array.isArray(t) ? t : [t, "default"], n = this.getVariables({ contents: s[0], level: s[1] });
|
|
122
|
+
W(this.endpoint, this.operationName, this.getQuery(), n);
|
|
363
123
|
} catch (s) {
|
|
364
124
|
d().sfDebug && console.error("🚨 Error in send():", s);
|
|
365
125
|
}
|
|
@@ -388,17 +148,17 @@ class Ie extends $ {
|
|
|
388
148
|
`;
|
|
389
149
|
}
|
|
390
150
|
}
|
|
391
|
-
const
|
|
392
|
-
class
|
|
393
|
-
constructor({ file: e, line: t, function: s, code:
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
this.file = e, this.line = t, this.function = s, this.code =
|
|
151
|
+
const S = {};
|
|
152
|
+
class V {
|
|
153
|
+
constructor({ file: e, line: t, function: s, code: n, locals: i = {}, offender: g = !1, column: r }) {
|
|
154
|
+
A(this, "file");
|
|
155
|
+
A(this, "line");
|
|
156
|
+
A(this, "function");
|
|
157
|
+
A(this, "code");
|
|
158
|
+
A(this, "locals");
|
|
159
|
+
A(this, "offender");
|
|
160
|
+
A(this, "column");
|
|
161
|
+
this.file = e, this.line = t, this.function = s, this.code = n, this.locals = i, this.offender = g, this.column = r;
|
|
402
162
|
}
|
|
403
163
|
toDict() {
|
|
404
164
|
const e = { file: this.file, line: this.line, function: this.function, code: this.code, locals: Object.fromEntries(Object.entries(this.locals).map(([t, s]) => [t, String(s)])) };
|
|
@@ -408,198 +168,198 @@ class Y {
|
|
|
408
168
|
return JSON.stringify(this.toDict());
|
|
409
169
|
}
|
|
410
170
|
}
|
|
411
|
-
class
|
|
171
|
+
class k {
|
|
412
172
|
static encode(e) {
|
|
413
|
-
return e instanceof
|
|
173
|
+
return e instanceof V ? e.toDict() : Array.isArray(e) ? e.map((t) => k.encode(t)) : typeof e == "object" && e !== null ? JSON.stringify(e) : e;
|
|
414
174
|
}
|
|
415
175
|
static stringify(e) {
|
|
416
|
-
return JSON.stringify(
|
|
176
|
+
return JSON.stringify(k.encode(e), (t, s) => s instanceof V ? s.toDict() : s);
|
|
417
177
|
}
|
|
418
178
|
}
|
|
419
|
-
let
|
|
420
|
-
function
|
|
179
|
+
let B, w = 0;
|
|
180
|
+
function Re(o) {
|
|
421
181
|
d().sfDebug && console.log("Initializing Exception Interceptor...");
|
|
422
182
|
try {
|
|
423
|
-
const
|
|
424
|
-
if (
|
|
425
|
-
const c = process.env || {},
|
|
426
|
-
if (
|
|
427
|
-
const
|
|
428
|
-
if (["local", "dev", "development"].includes(
|
|
429
|
-
if (["KUBERNETES_SERVICE_HOST", "AWS_EXECUTION_ENV", "ECS_CONTAINER_METADATA_URI", "ECS_CONTAINER_METADATA_URI_V4", "GAE_ENV", "K_SERVICE", "GOOGLE_CLOUD_PROJECT", "WEBSITE_INSTANCE_ID", "VERCEL", "NETLIFY", "DYNO", "RENDER", "FLY_APP_NAME", "RAILWAY_STATIC_URL", "CF_PAGES", "CLOUDFLARE"].some((
|
|
430
|
-
const
|
|
431
|
-
return
|
|
183
|
+
const r = (function() {
|
|
184
|
+
if (B !== void 0) return B;
|
|
185
|
+
const c = process.env || {}, a = ne(c.SF_IS_LOCAL);
|
|
186
|
+
if (a !== void 0) return B = a;
|
|
187
|
+
const l = (c.SF_ENV || c.NODE_ENV || "").toLowerCase();
|
|
188
|
+
if (["local", "dev", "development"].includes(l)) return B = !0;
|
|
189
|
+
if (["KUBERNETES_SERVICE_HOST", "AWS_EXECUTION_ENV", "ECS_CONTAINER_METADATA_URI", "ECS_CONTAINER_METADATA_URI_V4", "GAE_ENV", "K_SERVICE", "GOOGLE_CLOUD_PROJECT", "WEBSITE_INSTANCE_ID", "VERCEL", "NETLIFY", "DYNO", "RENDER", "FLY_APP_NAME", "RAILWAY_STATIC_URL", "CF_PAGES", "CLOUDFLARE"].some((p) => !!c[p])) return B = !1;
|
|
190
|
+
const I = (S.hostname?.() || c.HOSTNAME || "").toLowerCase();
|
|
191
|
+
return I === "localhost" || I.endsWith(".local") || I.includes("local") ? B = !0 : B = !1;
|
|
432
192
|
})();
|
|
433
|
-
|
|
434
|
-
if (
|
|
435
|
-
|
|
436
|
-
const
|
|
437
|
-
if (
|
|
193
|
+
o?.setSupplementalFields?.({ isFromLocalService: r }), (async function(c) {
|
|
194
|
+
if (te) return;
|
|
195
|
+
te = !0;
|
|
196
|
+
const a = process.env || {};
|
|
197
|
+
if (ne(a.SF_IS_LOCAL) === void 0)
|
|
438
198
|
try {
|
|
439
|
-
await (async function(
|
|
440
|
-
const
|
|
441
|
-
return (await Promise.allSettled([
|
|
442
|
-
})(150) &&
|
|
199
|
+
await (async function(l) {
|
|
200
|
+
const I = D("http://169.254.169.254/latest/meta-data/", {}, l), p = D("http://metadata.google.internal/computeMetadata/v1/instance/", { "Metadata-Flavor": "Google" }, l), C = D("http://169.254.169.254/metadata/instance?api-version=2021-02-01", { Metadata: "true" }, l);
|
|
201
|
+
return (await Promise.allSettled([I, p, C])).some((u) => u.status === "fulfilled" && (u.value === "ok" || u.value === "http_error"));
|
|
202
|
+
})(150) && B && (B = !1, c?.setSupplementalFields?.({ isFromLocalService: !1 }));
|
|
443
203
|
} catch {
|
|
444
204
|
}
|
|
445
|
-
})(
|
|
205
|
+
})(o).catch(() => {
|
|
446
206
|
});
|
|
447
207
|
} catch {
|
|
448
208
|
}
|
|
449
|
-
const e = new xe(new URL("data:application/javascript;base64,aW1wb3J0IHsgU2Vzc2lvbiB9IGZyb20gImluc3BlY3Rvci9wcm9taXNlcyI7CmltcG9ydCB7IHBhcmVudFBvcnQsIHdvcmtlckRhdGEgfSBmcm9tICJ3b3JrZXJfdGhyZWFkcyI7CgpnbG9iYWwuc2ZEZWJ1ZyA9IHVuZGVmaW5lZDsKZ2xvYmFsLnN0YWNrRGVwdGhMb2NhbHMgPSB1bmRlZmluZWQ7Cmdsb2JhbC5ub2RlTW9kdWxlc1RvQ29sbGVjdExvY2FsVmFyaWFibGVzT24gPSB1bmRlZmluZWQ7CgovKioKICogUHJvY2Vzc2VzIGNhbGwgZnJhbWVzIGZyb20gYW4gZXhjZXB0aW9uIGFuZCBwb3N0cyB0aGVtIHZpYSB0aGUgV29ya2Vy4oCZcyBwYXJlbnRQb3J0LgogKgogKiBAcGFyYW0g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uuc3BsaXQoIlxuIik7CiAgICAgICAgICAgIGNvZGUgPSBzb3VyY2VMaW5lc1tsb2NhdGlvbi5saW5lTnVtYmVyXSB8fCAiPG5vdCBjYXB0dXJlZD4iOwogICAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBmZXRjaCBzY3JpcHQgc291cmNlOiIsIGVycik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIC8vIEZldGNoIGxvY2FsIHZhcmlhYmxlcyBpZiB0aGVyZSdzIGFuIG9iamVjdElkCiAgICAgICAgY29uc3QgbG9jYWxzID0gbG9jYWxTY29wZT8ub2JqZWN0Py5vYmplY3RJZAogICAgICAgICAgPyBhd2FpdCBmZXRjaExvY2FsVmFyaWFibGVzKHNlc3Npb24sIGxvY2FsU2NvcGUub2JqZWN0Lm9iamVjdElkKQogICAgICAgICAgOiB7fTsKCiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGZ1bmN0aW9uOiBmdW5jdGlvbk5hbWUgfHwgIjxhbm9ueW1vdXM+IiwKICAgICAgICAgIGxvY2FscywKICAgICAgICAgIGZpbGUsCiAgICAgICAgICBsaW5lOiBsb2NhdGlvbj8ubGluZU51bWJlciB8fCAwLAogICAgICAgICAgY29kZSwKICAgICAgICB9OwogICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgY29uc29sZS5lcnJvcigiW1dvcmtlcl0gRXJyb3IgcHJvY2Vzc2luZyBjYWxsIGZyYW1lOiIsIGVycm9yKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGZ1bmN0aW9uOiAiPGVycm9yPiIsCiAgICAgICAgICBsb2NhbHM6IHt9LAogICAgICAgICAgZmlsZ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KICAgICAgICB9IGVsc2UgewogICAgICAgICAgZmlsZSA9ICI8dW5rbm93bj4iOwogICAgICAgIH0KCiAgICAgICAgLy8gSWYgd2UgaGF2ZSBhIHZhbGlkIGxvY2F0aW9uIGFuZCBzY3JpcHRJZCwgZmV0Y2ggdGhlIGNvZGUgbGluZQogICAgICAgIGlmIChsb2NhdGlvbiAmJiBsb2NhdGlvbi5zY3JpcHRJZCkgewogICAgICAgICAgY29uc3Qgc2NyaXB0SWQgPSBsb2NhdGlvbi5zY3JpcHRJZDsKICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgIGNvbnN0IHsgc2NyaXB0U291cmNlIH0gPSBhd2FpdCBzZXNzaW9uLnBvc3QoCiAgICAgICAgICAgICAgIkRlYnVnZ2VyLmdldFNjcmlwdFNvdXJjZSIsCiAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgc2NyaXB0SWQsCiAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgKTsKICAgICAgICAgICAgY29uc3Qgc291cmNlTGluZXMgPSBzY3JpcHRTb3VyY2Uuc3BsaXQoIlxuIik7CiAgICAgICAgICAgIGNvZGUgPSBzb3VyY2VMaW5lc1tsb2NhdGlvbi5saW5lTnVtYmVyXSB8fCAiPG5vdCBjYXB0dXJlZD4iOwogICAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBmZXRjaCBzY3JpcHQgc291cmNlOiIsIGVycik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIC8vIEZldGNoIGxvY2FsIHZhcmlhYmxlcyBpZiB0aGVyZSdzIGFuIG9iamVjdElkCiAgICAgICAgY29uc3QgbG9jYWxzID0gbG9jYWxTY29wZT8ub2JqZWN0Py5vYmplY3RJZAogICAgICAgICAgPyBhd2FpdCBmZXRjaExvY2FsVmFyaWFibGVzKHNlc3Npb24sIGxvY2FsU2NvcGUub2JqZWN0Lm9iamVjdElkKQogICAgICAgICAgOiB7fTsKCiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGZ1bmN0aW9uOiBmdW5jdGlvbk5hbWUgfHwgIjxhbm9ueW1vdXM+IiwKICAgICAgICAgIGxvY2FscywKICAgICAgICAgIGZpbGUsCiAgICAgICAgICBsaW5lOiBsb2NhdGlvbj8ubGluZU51bWJlciB8fCAwLAogICAgICAgICAgY29kZSwKICAgICAgICB9OwogICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgY29uc29sZS5lcnJvcigiW1dvcmtlcl0gRXJyb3IgcHJvY2Vzc2luZyBjYWxsIGZyYW1lOiIsIGVycm9yKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGZ1bmN0aW9uOiAiPGVycm9yPiIsCiAgICAgICAgICBsb2NhbHM6IHt9LAogICAgICAgICAgZmlsZTogIjx1bmtub3duPiIsCiAgICAgICAgICBsaW5lOiAwLAogICAgICAgICAgY29kZTogIjxub3QgY2FwdHVyZWQ+IiwKICAgICAgICB9OwogICAgICB9CiAgICB9KSwKICApOwogIC8vIFBvc3QgZXhjZXB0aW9uIGRhdGEKICBwYXJlbnRQb3J0Py5wb3N0TWVzc2FnZSh7IHR5cGU6ICJleGNlcHRpb24iLCBmcmFtZXMgfSk7Cn0KCi8qKgogKiBIYW5kbGVzIHRoZSAicGF1c2VkIiBzdGF0ZSBvZiB0aGUgZGVidWdnZXIgYW5kIHByb2Nlc3NlcyBleGNlcHRpb25zIG9yIHByb21pc2UgcmVqZWN0aW9ucy4KICogQHBhcmFtIHtTZXNzaW9ufSBzZXNzaW9uIC0gVGhlIGRlYnVnZ2luZyBzZXNzaW9uIGluc3RhbmNlLgogKiBAcGFyYW0ge29iamVjdH0gcGFyYW1zIC0gUGFyYW1ldGVycy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c2lvbiwgaWQsIHByb3AubmFtZSwgdmFyaWFibGVzKTsKICAgICAgICB9IGVsc2UgaWYgKHByb3A/LnZhbHVlKSB7CiAgICAgICAgICB1bnJvbGxPdGhlcihwcm9wLCB2YXJpYWJsZXMpOwogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4gdmFyaWFibGVzOwogICAgfQogIH0gY2F0Y2ggKGVycikgewogICAgaWYgKGdsb2JhbC5zZkRlYnVnKSB7CiAgICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBmZXRjaCBsb2NhbCB2YXJpYWJsZXM6IiwgZXJyKTsKICAgIH0KICAgIHJldHVybiB7fTsKICB9Cn0KCnN0YXJ0RGVidWdnZXIoKS5jYXRjaCgoZXJyb3IpID0+IHsKICBpZiAoZ2xvYmFsLnNmRGVidWcpIHsKICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBzdGFydCBkZWJ1Z2dlcjoiLCBlcnJvcik7CiAgfQp9KTsKCi8vIEtlZXAgdGhlIHdvcmtlciBhbGl2ZQpzZXRJbnRlcnZhbCgoKSA9PiB7fSwgMTAwMDApOwo="), { workerData: { captureAllExceptions: !0 } });
|
|
450
210
|
let t = null;
|
|
451
211
|
const s = /* @__PURE__ */ new WeakMap();
|
|
452
|
-
e.on("message", (
|
|
453
|
-
if (typeof
|
|
454
|
-
const { frames: c } =
|
|
455
|
-
if (!
|
|
456
|
-
const
|
|
457
|
-
return
|
|
458
|
-
`).slice(1).map((
|
|
459
|
-
const
|
|
460
|
-
if (
|
|
461
|
-
const [,
|
|
462
|
-
return new
|
|
212
|
+
e.on("message", (r) => {
|
|
213
|
+
if (typeof r == "string" && d().sfDebug && console.log(`[Worker] ${r}`), r.readyToGetParameters && e.postMessage({ sfDebug: d().sfDebug, stackDepthLocals: d().stackDepthLocals, nodeModulesToCollectLocalVariablesOn: d().nodeModulesToCollectLocalVariablesOn }), r.type === "exception") {
|
|
214
|
+
const { frames: c } = r, a = t;
|
|
215
|
+
if (!a) return;
|
|
216
|
+
const l = s.get(a), I = (function(C) {
|
|
217
|
+
return C ? C.split(`
|
|
218
|
+
`).slice(1).map((u) => {
|
|
219
|
+
const m = /at (.+?) \((.+):(\d+):(\d+)\)/.exec(u) || /at (.+):(\d+):(\d+)/.exec(u);
|
|
220
|
+
if (m) {
|
|
221
|
+
const [, h, Z, b, y] = m;
|
|
222
|
+
return new V({ function: h || "<anonymous>", locals: {}, file: Z || "<unknown>", line: parseInt(b, 10) || 0, code: "<not captured>", column: parseInt(y) || 0 });
|
|
463
223
|
}
|
|
464
|
-
return new
|
|
224
|
+
return new V({ function: "<unknown>", locals: {}, file: "<unknown>", line: 0, code: "<not captured>", column: 0 });
|
|
465
225
|
}) : [];
|
|
466
|
-
})(
|
|
467
|
-
const
|
|
468
|
-
let
|
|
469
|
-
for (let b = 0; b <
|
|
470
|
-
const y =
|
|
471
|
-
if (
|
|
472
|
-
for (let
|
|
473
|
-
const
|
|
474
|
-
if (
|
|
475
|
-
|
|
226
|
+
})(a.stack), p = (function(C, u) {
|
|
227
|
+
const m = [];
|
|
228
|
+
let h = -1, Z = -1;
|
|
229
|
+
for (let b = 0; b < C.length; b++) {
|
|
230
|
+
const y = Je(C[b].file);
|
|
231
|
+
if (Z = b, y !== "<unknown>") {
|
|
232
|
+
for (let f = 0; f < u.length; f++) {
|
|
233
|
+
const v = u[f];
|
|
234
|
+
if (be(v, y) || typeof v.file == "string" && v.file.includes(y)) {
|
|
235
|
+
h = f, w = 0, d().sfDebug && console.log(`✅ Matched Frame Found: ${y} @ Debugger Frame ${f}`);
|
|
476
236
|
break;
|
|
477
237
|
}
|
|
478
238
|
}
|
|
479
|
-
if (
|
|
239
|
+
if (h !== -1) break;
|
|
480
240
|
}
|
|
481
241
|
}
|
|
482
|
-
if (
|
|
483
|
-
d().sfDebug && console.log(`🔄 Merging from matched index ${
|
|
484
|
-
for (let b = 0; b <
|
|
485
|
-
const y =
|
|
486
|
-
|
|
242
|
+
if (h === -1) return w === 10 ? (w = 0, C) : (++w, d().sfDebug && console.log(`"❌ No matching frame found. Checking once again, Attempt N ${w}"`), []);
|
|
243
|
+
d().sfDebug && console.log(`🔄 Merging from matched index ${h} onward...`);
|
|
244
|
+
for (let b = 0; b < u.length; b++) {
|
|
245
|
+
const y = C[Z + b], f = u[h + b];
|
|
246
|
+
m.push(new V({ function: f?.function || y?.function || "<anonymous>", locals: f?.locals || y?.locals || {}, file: y?.file || f?.file || "<unknown>", line: f?.line || y?.line || 0, code: f?.code || y?.code || "<not captured>" }));
|
|
487
247
|
}
|
|
488
|
-
return
|
|
489
|
-
})(
|
|
490
|
-
if (
|
|
248
|
+
return m;
|
|
249
|
+
})(I, c || []);
|
|
250
|
+
if (p.length !== 0) {
|
|
491
251
|
t = null;
|
|
492
|
-
const
|
|
493
|
-
for (let y = 0; y <
|
|
494
|
-
const
|
|
495
|
-
|
|
252
|
+
const C = d().stackDepthCodeTraceDepth, u = C === -1 ? p : p.slice(0, C + 1), m = Math.min(u.length, I.length);
|
|
253
|
+
for (let y = 0; y < m; y++) (async () => {
|
|
254
|
+
const f = Xe(u[y].file, I[y].line, I[y].column);
|
|
255
|
+
f && (f.content != null && (u[y].code = f.content), f.file != null && (u[y].file = f.file));
|
|
496
256
|
})();
|
|
497
|
-
|
|
498
|
-
const
|
|
499
|
-
d().sfDebug && console.log("error message is : ",
|
|
500
|
-
const
|
|
501
|
-
b ? (
|
|
502
|
-
|
|
503
|
-
})) :
|
|
504
|
-
|
|
505
|
-
}) :
|
|
257
|
+
o.setOperationName("CollectExceptions");
|
|
258
|
+
const h = a.message ? `${a.name}: ${a.message}` : a.name;
|
|
259
|
+
d().sfDebug && console.log("error message is : ", h);
|
|
260
|
+
const Z = N.getInstance(), b = s.get(a);
|
|
261
|
+
b ? (Z.setTraceIdFor(b, b), Z.runWithSession(b, () => {
|
|
262
|
+
Z.setTraceId(b), o.doSend(h, u);
|
|
263
|
+
})) : o.doSend(h, u), l ? N.getInstance().runWithSession(l, () => {
|
|
264
|
+
o.doSend(h, u);
|
|
265
|
+
}) : o.doSend(h, u);
|
|
506
266
|
}
|
|
507
267
|
}
|
|
508
|
-
}), e.on("error", (
|
|
509
|
-
console.error("[Worker Error]",
|
|
510
|
-
}), e.on("exit", (
|
|
511
|
-
console.error(`[Worker] Exited with code ${
|
|
268
|
+
}), e.on("error", (r) => {
|
|
269
|
+
console.error("[Worker Error]", r);
|
|
270
|
+
}), e.on("exit", (r) => {
|
|
271
|
+
console.error(`[Worker] Exited with code ${r}`);
|
|
512
272
|
}), e.unref();
|
|
513
|
-
const
|
|
514
|
-
function
|
|
515
|
-
const c = Reflect.construct(
|
|
516
|
-
Reflect.setPrototypeOf(c,
|
|
273
|
+
const n = Error, i = /* @__PURE__ */ new Set();
|
|
274
|
+
function g(...r) {
|
|
275
|
+
const c = Reflect.construct(n, r);
|
|
276
|
+
Reflect.setPrototypeOf(c, g.prototype);
|
|
517
277
|
try {
|
|
518
|
-
const
|
|
519
|
-
s.set(c,
|
|
278
|
+
const l = N.getInstance().getTraceId();
|
|
279
|
+
s.set(c, l);
|
|
520
280
|
} catch {
|
|
521
281
|
}
|
|
522
|
-
|
|
523
|
-
const
|
|
282
|
+
n.captureStackTrace && n.captureStackTrace(c, g);
|
|
283
|
+
const a = `${c.message}:${c.stack?.split(`
|
|
524
284
|
`)[1]?.trim()}`;
|
|
525
|
-
if (!
|
|
526
|
-
|
|
527
|
-
const
|
|
528
|
-
s.set(c,
|
|
285
|
+
if (!i.has(a)) {
|
|
286
|
+
i.add(a), t = c;
|
|
287
|
+
const l = N.getInstance().getTraceId();
|
|
288
|
+
s.set(c, l), e.postMessage({ type: "processException", error: c.message });
|
|
529
289
|
}
|
|
530
290
|
return c;
|
|
531
291
|
}
|
|
532
|
-
|
|
292
|
+
g.prototype = Object.create(n.prototype, { constructor: { value: g, enumerable: !1, writable: !0, configurable: !0 } }), Object.setPrototypeOf(g, n), globalThis.Error = g;
|
|
533
293
|
}
|
|
534
|
-
function
|
|
535
|
-
return
|
|
294
|
+
function ee(o) {
|
|
295
|
+
return o = (o = (o = o.replace(/^webpack:\/\/[^\/]+\/\.?\//, "")).replace(/^.*\/pages\//, "pages/")).replace(/\.(js|ts)$/, "");
|
|
536
296
|
}
|
|
537
|
-
function
|
|
538
|
-
const s = (function(
|
|
539
|
-
|
|
540
|
-
const
|
|
541
|
-
return
|
|
542
|
-
})(
|
|
297
|
+
function Xe(o, e, t) {
|
|
298
|
+
const s = (function(i) {
|
|
299
|
+
i.startsWith("at ") && (i = i.slice(3).trim());
|
|
300
|
+
const g = i.match(/^(.*?)(:\d+)+(\.map)?$/);
|
|
301
|
+
return g ? g[1] : i;
|
|
302
|
+
})(o);
|
|
543
303
|
if (!s || s === "<unknown>") return null;
|
|
544
|
-
const
|
|
304
|
+
const n = s + ".map";
|
|
545
305
|
try {
|
|
546
|
-
const
|
|
547
|
-
if (
|
|
548
|
-
const
|
|
549
|
-
let
|
|
550
|
-
if (s &&
|
|
551
|
-
const c =
|
|
552
|
-
if (
|
|
306
|
+
const i = pe(n, "utf-8");
|
|
307
|
+
if (i) {
|
|
308
|
+
const g = JSON.parse(i);
|
|
309
|
+
let r = new me.SourceMapConsumer(g).originalPositionFor({ line: e, column: t });
|
|
310
|
+
if (s && r.source) {
|
|
311
|
+
const c = ee(s), a = g.sources.findIndex((l) => ee(l) === c);
|
|
312
|
+
if (a === -1) d().sfDebug && console.log(`Source file "${s}" not found in the source map.`);
|
|
553
313
|
else {
|
|
554
|
-
const
|
|
555
|
-
if (
|
|
556
|
-
return { content:
|
|
557
|
-
`).slice(
|
|
558
|
-
`), name:
|
|
314
|
+
const l = g.sourcesContent[a], I = g.names.join(",");
|
|
315
|
+
if (l)
|
|
316
|
+
return { content: l.split(`
|
|
317
|
+
`).slice(r.line - 1, r.line + 20).join(`
|
|
318
|
+
`), name: I, file: r.source };
|
|
559
319
|
d().sfDebug && console.log(`No source content available for file "${s}".`);
|
|
560
320
|
}
|
|
561
321
|
}
|
|
562
|
-
return { content:
|
|
322
|
+
return { content: g.sourcesContent[0], name: g.names[0], file: g.file };
|
|
563
323
|
}
|
|
564
|
-
} catch (
|
|
565
|
-
d().sfDebug && console.log(`Cant read/parse "${
|
|
324
|
+
} catch (i) {
|
|
325
|
+
d().sfDebug && console.log(`Cant read/parse "${n}: Error - ".`, i);
|
|
566
326
|
}
|
|
567
327
|
return null;
|
|
568
328
|
}
|
|
569
|
-
function
|
|
570
|
-
return
|
|
329
|
+
function Je(o) {
|
|
330
|
+
return o?.split("/").pop() || "<unknown>";
|
|
571
331
|
}
|
|
572
|
-
function
|
|
573
|
-
if (!
|
|
574
|
-
for (const t of Object.values(
|
|
575
|
-
if (typeof t == "string" && t.includes(e) || typeof t == "object" &&
|
|
332
|
+
function be(o, e) {
|
|
333
|
+
if (!o || typeof o != "object") return !1;
|
|
334
|
+
for (const t of Object.values(o))
|
|
335
|
+
if (typeof t == "string" && t.includes(e) || typeof t == "object" && be(t, e)) return !0;
|
|
576
336
|
return !1;
|
|
577
337
|
}
|
|
578
|
-
let
|
|
579
|
-
function
|
|
580
|
-
if (!
|
|
581
|
-
const e =
|
|
338
|
+
let te = !1;
|
|
339
|
+
function ne(o) {
|
|
340
|
+
if (!o) return;
|
|
341
|
+
const e = o.toLowerCase().trim();
|
|
582
342
|
return !!["1", "true", "yes", "on"].includes(e) || !["0", "false", "no", "off"].includes(e) && void 0;
|
|
583
343
|
}
|
|
584
|
-
function
|
|
344
|
+
function D(o, e, t) {
|
|
585
345
|
return new Promise((s) => {
|
|
586
346
|
try {
|
|
587
|
-
const
|
|
588
|
-
|
|
347
|
+
const n = new URL(o), i = (n.protocol, S).request({ method: "GET", hostname: n.hostname, port: n.port || (n.protocol === "https:" ? 443 : 80), path: n.pathname + (n.search || ""), headers: e }, (g) => {
|
|
348
|
+
g.resume(), g.statusCode && g.statusCode >= 200 && g.statusCode < 400 ? s("ok") : s("http_error");
|
|
589
349
|
});
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
}),
|
|
350
|
+
i.on("error", () => s("error")), i.setTimeout(t, () => {
|
|
351
|
+
i.destroy(), s("timeout");
|
|
352
|
+
}), i.end();
|
|
593
353
|
} catch {
|
|
594
354
|
s("error");
|
|
595
355
|
}
|
|
596
356
|
});
|
|
597
357
|
}
|
|
598
|
-
class
|
|
358
|
+
class Ke extends F {
|
|
599
359
|
constructor() {
|
|
600
360
|
super();
|
|
601
|
-
|
|
602
|
-
|
|
361
|
+
A(this, "serviceIdentifier", new Y());
|
|
362
|
+
A(this, "supplementalFields", {});
|
|
603
363
|
this.setOperationName("CollectExceptions");
|
|
604
364
|
}
|
|
605
365
|
setSupplementalFields(t) {
|
|
@@ -617,8 +377,8 @@ class at extends $ {
|
|
|
617
377
|
}
|
|
618
378
|
async send(t, s) {
|
|
619
379
|
d().sfDebug && console.log(" SENDING EXCEPTION...");
|
|
620
|
-
const
|
|
621
|
-
W(this.endpoint, this.operationName, this.getQuery(),
|
|
380
|
+
const n = JSON.stringify(k.encode(s)), i = this.normalizedSupplementalForGraphQL(), g = this.getVariables({ exceptionMessage: t, traceJson: n, reentrancyGuardPreactive: !1, library: d().packageLibraryType, version: d().version, ...i });
|
|
381
|
+
W(this.endpoint, this.operationName, this.getQuery(), g);
|
|
622
382
|
}
|
|
623
383
|
getQuery() {
|
|
624
384
|
return `
|
|
@@ -652,87 +412,44 @@ class at extends $ {
|
|
|
652
412
|
`;
|
|
653
413
|
}
|
|
654
414
|
}
|
|
655
|
-
const
|
|
656
|
-
var
|
|
657
|
-
const
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
return { capture_arguments: !1, capture_return_value: !1, arg_limit_mb: 1, return_limit_mb: 1, autocapture_all_child_functions: !1, sample_rate: 0, enable_sampling: !1, capture_sf_veritas: !1, parse_json_strings: !1 };
|
|
663
|
-
}
|
|
664
|
-
function Ye(n) {
|
|
665
|
-
try {
|
|
666
|
-
const e = n.split("-");
|
|
667
|
-
return e.length !== 9 ? (console.error(`[FuncSpan] Invalid header format: expected 9 parts, got ${e.length}`), null) : { capture_arguments: e[0] === "1", capture_return_value: e[1] === "1", arg_limit_mb: parseInt(e[2], 10), return_limit_mb: parseInt(e[3], 10), autocapture_all_child_functions: e[4] === "1", sample_rate: parseFloat(e[5]), enable_sampling: e[6] === "1", capture_sf_veritas: e[7] === "1", parse_json_strings: e[8] === "1" };
|
|
668
|
-
} catch (e) {
|
|
669
|
-
return console.error(`[FuncSpan] Failed to parse header override "${n}":`, e), null;
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
function U(n, e) {
|
|
673
|
-
if (!n) return e;
|
|
674
|
-
const t = n.toLowerCase();
|
|
675
|
-
return t === "true" || t === "1" || t === "yes";
|
|
676
|
-
}
|
|
677
|
-
const Ce = new pe();
|
|
678
|
-
function ct(n) {
|
|
679
|
-
Ce.enterWith(n);
|
|
680
|
-
}
|
|
681
|
-
function Je() {
|
|
682
|
-
return Ce.getStore();
|
|
683
|
-
}
|
|
684
|
-
function lt() {
|
|
685
|
-
Ce.enterWith(void 0);
|
|
686
|
-
}
|
|
687
|
-
function z(...n) {
|
|
688
|
-
const e = {};
|
|
689
|
-
for (const t of n) for (const s in t) t[s] !== void 0 && (e[s] = t[s]);
|
|
690
|
-
return e;
|
|
691
|
-
}
|
|
692
|
-
function J(n, e) {
|
|
693
|
-
try {
|
|
694
|
-
const t = JSON.stringify(n).length / 1048576;
|
|
695
|
-
return t <= e ? n : { _truncated: !0, _originalSizeMB: t.toFixed(2), _limitMB: e, _preview: JSON.stringify(n).substring(0, 500) + "..." };
|
|
696
|
-
} catch {
|
|
697
|
-
return { _error: "Failed to serialize data", _type: typeof n };
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
const gt = Me(import.meta.url);
|
|
701
|
-
let Ze = !1;
|
|
702
|
-
function dt() {
|
|
703
|
-
const n = d().sfDebug;
|
|
704
|
-
if (Ze) return void (n && console.log("[patchNodeHttpInbound] Already installed, skipping."));
|
|
415
|
+
const oe = "getting request source code";
|
|
416
|
+
var z = ((o) => (o.UNKNOWN = "unknown", o.ANONYMOUS = "anonymous", o.NOT_CAPTURED = "not captured", o))(z || {});
|
|
417
|
+
const x = "http:", P = "https:", _e = we(import.meta.url);
|
|
418
|
+
let se = !1;
|
|
419
|
+
function ze() {
|
|
420
|
+
const o = d().sfDebug;
|
|
421
|
+
if (se) return void (o && console.log("[patchNodeHttpInbound] Already installed, skipping."));
|
|
705
422
|
let e;
|
|
706
|
-
|
|
423
|
+
se = !0;
|
|
707
424
|
try {
|
|
708
|
-
e =
|
|
709
|
-
} catch (
|
|
710
|
-
return void console.error("Failed to require node:http:",
|
|
425
|
+
e = _e("node:http"), o && console.log("[patchNodeHttpInbound] node:http required successfully.");
|
|
426
|
+
} catch (n) {
|
|
427
|
+
return void console.error("Failed to require node:http:", n);
|
|
711
428
|
}
|
|
712
|
-
if (!e?.Server?.prototype) return void (
|
|
429
|
+
if (!e?.Server?.prototype) return void (o && console.log("[patchNodeHttpInbound] http.Server.prototype not found."));
|
|
713
430
|
const t = e.Server.prototype, s = t.emit;
|
|
714
|
-
s && !t.__sf_inbound_patched__ ? (Object.defineProperty(t, "__sf_inbound_patched__", { value: !0, enumerable: !1, configurable: !1, writable: !1 }),
|
|
715
|
-
if (
|
|
716
|
-
const
|
|
717
|
-
const
|
|
718
|
-
if (!
|
|
719
|
-
for (const [
|
|
720
|
-
return
|
|
721
|
-
})(
|
|
722
|
-
|
|
723
|
-
const
|
|
724
|
-
|
|
725
|
-
const
|
|
726
|
-
return
|
|
727
|
-
|
|
728
|
-
const
|
|
729
|
-
|
|
431
|
+
s && !t.__sf_inbound_patched__ ? (Object.defineProperty(t, "__sf_inbound_patched__", { value: !0, enumerable: !1, configurable: !1, writable: !1 }), o && console.log("[patchNodeHttpInbound] Patching http.Server.prototype.emit."), t.emit = function(n, ...i) {
|
|
432
|
+
if (n !== "request") return o && console.log(`[patchNodeHttpInbound] Passing through event: ${n}`), s.call(this, n, ...i);
|
|
433
|
+
const g = i[0], r = i[1], c = (function(C) {
|
|
434
|
+
const u = {};
|
|
435
|
+
if (!C) return u;
|
|
436
|
+
for (const [m, h] of Object.entries(C)) h != null && (Array.isArray(h) ? u[m.toLowerCase()] = h.join(", ") : u[m.toLowerCase()] = String(h));
|
|
437
|
+
return u;
|
|
438
|
+
})(g?.headers), a = c["x-sf3-rid"], l = c["x-sf3-functionspancaptureoverride"];
|
|
439
|
+
o && (console.log("[patchNodeHttpInbound] Intercepted request event."), console.log("[patchNodeHttpInbound] Inbound headers:", c), console.log("[patchNodeHttpInbound] Trace header:", a), console.log("[patchNodeHttpInbound] FuncSpan override header:", l));
|
|
440
|
+
const I = N.getInstance();
|
|
441
|
+
I.setTraceId(a);
|
|
442
|
+
const p = I.getTraceId();
|
|
443
|
+
return o && console.log("[patchNodeHttpInbound] Context traceId set:", p), I.runWith({ inboundHeaders: c, ...a ? { traceId: a } : {} }, () => {
|
|
444
|
+
a && I.setTraceId(a), l && (ye(l), o && console.log("[patchNodeHttpInbound] FuncSpan override set:", l)), o && console.log("[patchNodeHttpInbound] Running request handler in context.");
|
|
445
|
+
const C = () => {
|
|
446
|
+
o && console.log("[patchNodeHttpInbound] Response finished/closed for traceId:", I.getTraceId()), l && (Ze(), o && console.log("[patchNodeHttpInbound] FuncSpan override cleared"));
|
|
730
447
|
};
|
|
731
|
-
return
|
|
448
|
+
return r.on("finish", C), r.on("close", C), s.call(this, n, g, r);
|
|
732
449
|
});
|
|
733
|
-
}) :
|
|
450
|
+
}) : o && console.log("[patchNodeHttpInbound] Already patched, skipping.");
|
|
734
451
|
}
|
|
735
|
-
class
|
|
452
|
+
class ke extends Q {
|
|
736
453
|
constructor() {
|
|
737
454
|
super(), this.setOperationName("DomainsToNotPassHeaderTo");
|
|
738
455
|
}
|
|
@@ -756,10 +473,10 @@ class ut extends Ie {
|
|
|
756
473
|
W(this.endpoint, this.operationName, t, s);
|
|
757
474
|
}
|
|
758
475
|
}
|
|
759
|
-
class
|
|
476
|
+
class Ue extends F {
|
|
760
477
|
constructor() {
|
|
761
478
|
super();
|
|
762
|
-
|
|
479
|
+
A(this, "serviceIdentifier", new Y());
|
|
763
480
|
this.setOperationName("CollectNetworkHops");
|
|
764
481
|
}
|
|
765
482
|
async sendAppIdentifier() {
|
|
@@ -769,7 +486,7 @@ class pt extends $ {
|
|
|
769
486
|
this.sendAppIdentifier(), this.send(t);
|
|
770
487
|
}
|
|
771
488
|
async send(t) {
|
|
772
|
-
const { name: s, column:
|
|
489
|
+
const { name: s, column: n, line: i, entrypoint: g, retryWithoutTraceId: r } = t, c = this.getVariables({ name: s, column: n, line: i, entrypoint: g, retryWithoutTraceId: r });
|
|
773
490
|
W(this.endpoint, this.operationName, this.getQuery(), c);
|
|
774
491
|
}
|
|
775
492
|
getQuery() {
|
|
@@ -800,10 +517,10 @@ class pt extends $ {
|
|
|
800
517
|
`;
|
|
801
518
|
}
|
|
802
519
|
}
|
|
803
|
-
class
|
|
520
|
+
class Te extends F {
|
|
804
521
|
constructor() {
|
|
805
522
|
super();
|
|
806
|
-
|
|
523
|
+
A(this, "serviceIdentifier", new Y());
|
|
807
524
|
this.setOperationName("CollectNetworkRequest");
|
|
808
525
|
}
|
|
809
526
|
async sendAppIdentifier() {
|
|
@@ -827,15 +544,15 @@ class It extends $ {
|
|
|
827
544
|
await W(this.endpoint, this.operationName, this.getQuery(), s);
|
|
828
545
|
}
|
|
829
546
|
}
|
|
830
|
-
const
|
|
831
|
-
class
|
|
547
|
+
const O = [400, 403];
|
|
548
|
+
class $e {
|
|
832
549
|
constructor(e = []) {
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
this.contextManager =
|
|
550
|
+
A(this, "HEADER_TRACING", "X-Sf3-Rid");
|
|
551
|
+
A(this, "HEADER_LOG_GUARD", "reentrancy_guard_logging_preactive");
|
|
552
|
+
A(this, "HEADER_PRINT_GUARD", "reentrancy_guard_print_preactive");
|
|
553
|
+
A(this, "HEADER_EXCEPTION_GUARD", "reentrancy_guard_exception_preactive");
|
|
554
|
+
A(this, "contextManager");
|
|
555
|
+
this.contextManager = N.getInstance(), e?.forEach((t) => {
|
|
839
556
|
typeof t == "string" && t.trim() && this.contextManager.getExcludedDomains().add(t);
|
|
840
557
|
}), d().sfDebug && console.log("[RequestInterceptor] Initialized with static excluded domains.");
|
|
841
558
|
}
|
|
@@ -843,153 +560,153 @@ class Ct {
|
|
|
843
560
|
let s;
|
|
844
561
|
if (e instanceof Headers) s = e.get(t) ?? void 0;
|
|
845
562
|
else {
|
|
846
|
-
const
|
|
847
|
-
for (const [
|
|
848
|
-
s =
|
|
563
|
+
const i = t.toLowerCase();
|
|
564
|
+
for (const [g, r] of Object.entries(e)) if (g.toLowerCase() === i) {
|
|
565
|
+
s = r;
|
|
849
566
|
break;
|
|
850
567
|
}
|
|
851
568
|
}
|
|
852
569
|
if (!s) return {};
|
|
853
|
-
const
|
|
854
|
-
return
|
|
570
|
+
const n = s.split("/").filter(Boolean);
|
|
571
|
+
return n.length < 3 ? {} : { sessionId: n[0], pageVisitId: n[1], requestId: n[n.length - 1] };
|
|
855
572
|
}
|
|
856
573
|
parseStackFrame(e) {
|
|
857
574
|
const t = /\((.*):(\d+):(\d+)\)$/.exec(e.trim());
|
|
858
575
|
if (!t) return null;
|
|
859
|
-
const [, s,
|
|
860
|
-
return { filePath: s, line: parseInt(
|
|
576
|
+
const [, s, n, i] = t;
|
|
577
|
+
return { filePath: s, line: parseInt(n, 10), column: parseInt(i, 10) };
|
|
861
578
|
}
|
|
862
579
|
async getOriginalPosition(e, t, s) {
|
|
863
|
-
let
|
|
864
|
-
const
|
|
580
|
+
let n = { source: e, line: t, column: s, name: null };
|
|
581
|
+
const i = e + ".map";
|
|
865
582
|
try {
|
|
866
|
-
const
|
|
867
|
-
let
|
|
868
|
-
|
|
869
|
-
} catch (
|
|
870
|
-
d().sfDebug && console.error(`Could not read/parse map file at ${
|
|
583
|
+
const g = JSON.parse(pe(i, "utf-8"));
|
|
584
|
+
let r = (await new me.SourceMapConsumer(g)).originalPositionFor({ line: t, column: s });
|
|
585
|
+
r.source && (n = r);
|
|
586
|
+
} catch (g) {
|
|
587
|
+
d().sfDebug && console.error(`Could not read/parse map file at ${i}:`, g);
|
|
871
588
|
}
|
|
872
|
-
return { originalPos:
|
|
589
|
+
return { originalPos: n };
|
|
873
590
|
}
|
|
874
591
|
captureFirstUserLines(e, t = 10, s = !1) {
|
|
875
|
-
const
|
|
876
|
-
Error.stackTraceLimit = Math.max(
|
|
877
|
-
const
|
|
878
|
-
|
|
879
|
-
const
|
|
880
|
-
Error.stackTraceLimit =
|
|
881
|
-
const c =
|
|
882
|
-
`).slice(1),
|
|
883
|
-
for (const
|
|
884
|
-
if (!(
|
|
885
|
-
for (const
|
|
886
|
-
const
|
|
887
|
-
|
|
888
|
-
const { originalPos:
|
|
889
|
-
if (
|
|
890
|
-
d().sfDebug && console.log("[RequestInterceptor] First user code line:",
|
|
891
|
-
const
|
|
892
|
-
e.doSend(
|
|
592
|
+
const n = d().sfDebug ? 10 : t, i = Error.stackTraceLimit;
|
|
593
|
+
Error.stackTraceLimit = Math.max(i, n);
|
|
594
|
+
const g = new Error(oe);
|
|
595
|
+
oe in Error && Error.captureStackTrace(g, this.captureFirstUserLines);
|
|
596
|
+
const r = g.stack || "";
|
|
597
|
+
Error.stackTraceLimit = i;
|
|
598
|
+
const c = r.split(`
|
|
599
|
+
`).slice(1), a = [];
|
|
600
|
+
for (const l of c)
|
|
601
|
+
if (!(l.includes("node:internal") || l.includes("internal/modules") || l.includes("internal/process") || l.includes("node_modules") || l.includes(".next/server/chunks") || l.includes("RequestInterceptor") || l.includes("contextManager") || l.includes("setupConfig")) && (a.push(l.trim()), a.length >= t)) break;
|
|
602
|
+
for (const l of a) {
|
|
603
|
+
const I = this.parseStackFrame(l);
|
|
604
|
+
I ? (async () => {
|
|
605
|
+
const { originalPos: p } = await this.getOriginalPosition(I.filePath, I.line, I.column);
|
|
606
|
+
if (p) {
|
|
607
|
+
d().sfDebug && console.log("[RequestInterceptor] First user code line:", p);
|
|
608
|
+
const C = { line: p.line?.toString() || z.UNKNOWN, column: p.column?.toString() || z.NOT_CAPTURED, name: p.name || z.NOT_CAPTURED, entrypoint: p.source, retryWithoutTraceId: s };
|
|
609
|
+
e.doSend(C);
|
|
893
610
|
}
|
|
894
|
-
})() : d().sfDebug && console.error("Could not parse stack line:",
|
|
611
|
+
})() : d().sfDebug && console.error("Could not parse stack line:", l);
|
|
895
612
|
}
|
|
896
613
|
}
|
|
897
614
|
addReentrancyGuardHeaders(e) {
|
|
898
615
|
e.set(this.HEADER_LOG_GUARD, "true"), e.set(this.HEADER_PRINT_GUARD, "true"), e.set(this.HEADER_EXCEPTION_GUARD, "true");
|
|
899
616
|
}
|
|
900
617
|
shouldPropagateHeaders(e) {
|
|
901
|
-
return !
|
|
618
|
+
return !Ge.some((t) => new RegExp(`^${t.replace(/\*/g, ".*")}$`).test(e));
|
|
902
619
|
}
|
|
903
620
|
addTracingHeaders(e, t) {
|
|
904
|
-
const s = new URL(t).hostname,
|
|
905
|
-
return
|
|
621
|
+
const s = new URL(t).hostname, n = this.shouldPropagateHeaders(s);
|
|
622
|
+
return n ? this.addTracingHeader(e, t) : d().sfDebug && console.error(`[RequestInterceptor] Excluded domain: ${s}`), n;
|
|
906
623
|
}
|
|
907
624
|
addTracingHeader(e, t) {
|
|
908
|
-
const s =
|
|
625
|
+
const s = le();
|
|
909
626
|
if (s) {
|
|
910
|
-
const
|
|
911
|
-
if (
|
|
627
|
+
const r = de(s);
|
|
628
|
+
if (r && r.sample_rate === 0) return void (d().sfDebug && console.log(`[RequestInterceptor] Function span tracking disabled (sample_rate=0), skipping tracing header for ${t}`));
|
|
912
629
|
}
|
|
913
|
-
const
|
|
914
|
-
e.set(this.HEADER_TRACING, `${
|
|
630
|
+
const n = this.contextManager.getOrSetSfTraceId(), i = this.contextManager.getOrSetPageVisitUUID(), g = Ie();
|
|
631
|
+
e.set(this.HEADER_TRACING, `${n}/${i}/${g}`), d().sfDebug && console.log(`[RequestInterceptor] Added tracing header for ${t}`);
|
|
915
632
|
}
|
|
916
633
|
patchFetch(e, t) {
|
|
917
634
|
const s = globalThis.fetch;
|
|
918
|
-
typeof s == "function" ? globalThis.fetch = async (
|
|
919
|
-
const
|
|
920
|
-
if (
|
|
635
|
+
typeof s == "function" ? globalThis.fetch = async (n, i) => {
|
|
636
|
+
const g = new Headers(i?.headers);
|
|
637
|
+
if (g.get(this.HEADER_LOG_GUARD) === "true" || g.get(this.HEADER_PRINT_GUARD) === "true" || g.get(this.HEADER_EXCEPTION_GUARD) === "true") return s(n, i);
|
|
921
638
|
this.captureFirstUserLines(e);
|
|
922
|
-
const
|
|
639
|
+
const r = Date.now();
|
|
923
640
|
let c;
|
|
924
|
-
typeof
|
|
925
|
-
|
|
641
|
+
typeof n == "string" || n instanceof URL ? c = n.toString() : n instanceof Request ? (c = n.url, n.headers.forEach((u, m) => {
|
|
642
|
+
g.set(m, u);
|
|
926
643
|
})) : d().sfDebug && console.error("[Sailfish RequestInterceptor] Invalid fetch input."), d().sfDebug && console.log("[RequestInterceptor] Fetching request to:", c);
|
|
927
|
-
const
|
|
928
|
-
let
|
|
644
|
+
const a = new URL(c).hostname, l = new Headers(g), I = this.addTracingHeaders(g, c), p = { ...i, headers: g };
|
|
645
|
+
let C;
|
|
929
646
|
try {
|
|
930
|
-
let
|
|
931
|
-
this.addTracingHeaders(
|
|
932
|
-
const
|
|
933
|
-
d().sfDebug && console.log(`[RequestInterceptor] Fetch completed: ${c}, Status: ${
|
|
934
|
-
const { sessionId:
|
|
935
|
-
return t.doSend({ apiKey: d().apiKey, requestId: b, pageVisitId:
|
|
936
|
-
} catch (
|
|
937
|
-
const
|
|
938
|
-
d().sfDebug && console.error(`[RequestInterceptor] Fetch failed: ${c}, Error: ${
|
|
647
|
+
let u = !1;
|
|
648
|
+
this.addTracingHeaders(l, c), C = await s(c, p), I && O.includes(C.status) ? (C = await s(c, { ...i, headers: l }), u = !0, this.captureFirstUserLines(e, 10, u)) : this.contextManager.addSupportedDomains(a);
|
|
649
|
+
const m = Date.now();
|
|
650
|
+
d().sfDebug && console.log(`[RequestInterceptor] Fetch completed: ${c}, Status: ${C.status}, Duration: ${m - r}ms`);
|
|
651
|
+
const { sessionId: h, pageVisitId: Z, requestId: b } = this.extractIdsFromTraceHeader(g);
|
|
652
|
+
return t.doSend({ apiKey: d().apiKey, requestId: b, pageVisitId: Z, recordingSessionId: h, serviceUuid: d().serviceUUID, timestampStart: r.toString(), timestampEnd: m.toString(), responseCode: C.status, success: !0, error: null, url: c, method: p.method || "GET", retryWithoutTraceId: u, parentSpanId: $() }), C;
|
|
653
|
+
} catch (u) {
|
|
654
|
+
const m = Date.now();
|
|
655
|
+
d().sfDebug && console.error(`[RequestInterceptor] Fetch failed: ${c}, Error: ${u}, Duration: ${m - r}ms`);
|
|
939
656
|
}
|
|
940
657
|
} : d().sfDebug && console.error("[RequestInterceptor] Fetch not available.");
|
|
941
658
|
}
|
|
942
659
|
patchHttp(e, t) {
|
|
943
|
-
if (d().sfDebug && console.log("[RequestInterceptor] Initializing HTTP/HTTPS request patch..."), !
|
|
944
|
-
const s =
|
|
945
|
-
|
|
946
|
-
let
|
|
660
|
+
if (d().sfDebug && console.log("[RequestInterceptor] Initializing HTTP/HTTPS request patch..."), !S || typeof S.request != "function") return void (d().sfDebug && console.log("[RequestInterceptor] HTTP/HTTPS not available."));
|
|
661
|
+
const s = S.request.bind(S), n = S.request.bind(S);
|
|
662
|
+
S.request = function(i, g) {
|
|
663
|
+
let r;
|
|
947
664
|
try {
|
|
948
|
-
if (typeof
|
|
949
|
-
const
|
|
950
|
-
|
|
951
|
-
} else
|
|
952
|
-
if (
|
|
953
|
-
const
|
|
954
|
-
this.addTracingHeaders(
|
|
665
|
+
if (typeof i == "string") {
|
|
666
|
+
const a = new URL(i);
|
|
667
|
+
r = { protocol: a.protocol || x, hostname: a.hostname, path: a.pathname + a.search, headers: {} };
|
|
668
|
+
} else i instanceof URL ? r = { protocol: i.protocol || x, hostname: i.hostname, path: i.pathname + i.search, headers: {} } : (r = { ...i }, r.protocol || (r.protocol = x));
|
|
669
|
+
if (r.headers) {
|
|
670
|
+
const a = `${r.protocol}//${r.hostname}`;
|
|
671
|
+
this.addTracingHeaders(r.headers, a), this.captureFirstUserLines(e);
|
|
955
672
|
} else d().sfDebug && console.warn("[RequestInterceptor] No headers found in HTTP request options. Skipping header addition.");
|
|
956
|
-
} catch (
|
|
957
|
-
throw d().sfDebug && console.error("[RequestInterceptor] Error while processing HTTP request options:",
|
|
673
|
+
} catch (a) {
|
|
674
|
+
throw d().sfDebug && console.error("[RequestInterceptor] Error while processing HTTP request options:", a), a;
|
|
958
675
|
}
|
|
959
676
|
let c = !1;
|
|
960
|
-
return s(
|
|
961
|
-
const
|
|
962
|
-
if (
|
|
963
|
-
|
|
964
|
-
const
|
|
965
|
-
delete
|
|
677
|
+
return s(r, (a) => {
|
|
678
|
+
const l = `${r.protocol}//${r.hostname}`;
|
|
679
|
+
if (r.headers && this.shouldPropagateHeaders(new URL(l).hostname) && O.includes(a.statusCode || 0)) {
|
|
680
|
+
r.hostname;
|
|
681
|
+
const u = { ...r, headers: { ...r.headers } };
|
|
682
|
+
delete u.headers[this.HEADER_TRACING], s(u, g), c = !0, this.captureFirstUserLines(e, 10, c);
|
|
966
683
|
}
|
|
967
|
-
const { sessionId:
|
|
968
|
-
t.doSend({ apiKey: d().apiKey, requestId:
|
|
684
|
+
const { sessionId: I, pageVisitId: p, requestId: C } = this.extractIdsFromTraceHeader(r.headers);
|
|
685
|
+
t.doSend({ apiKey: d().apiKey, requestId: C, pageVisitId: p, recordingSessionId: I, serviceUuid: d().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: a.statusCode || 0, success: !!a.statusCode && a.statusCode < 400, error: null, url: l, method: r.method || "GET", retryWithoutTraceId: c, parentSpanId: $() }), g?.(a);
|
|
969
686
|
});
|
|
970
|
-
},
|
|
971
|
-
let
|
|
687
|
+
}, S.request = function(i, g) {
|
|
688
|
+
let r;
|
|
972
689
|
try {
|
|
973
|
-
if (typeof
|
|
974
|
-
const
|
|
975
|
-
|
|
976
|
-
} else
|
|
977
|
-
if (
|
|
978
|
-
const
|
|
979
|
-
this.addTracingHeaders(
|
|
690
|
+
if (typeof i == "string") {
|
|
691
|
+
const a = new URL(i);
|
|
692
|
+
r = { protocol: a.protocol || P, hostname: a.hostname, path: a.pathname + a.search, headers: {} };
|
|
693
|
+
} else i instanceof URL ? r = { protocol: i.protocol || P, hostname: i.hostname, path: i.pathname + i.search, headers: {} } : (r = { ...i }, r.protocol || (r.protocol = P));
|
|
694
|
+
if (r.headers) {
|
|
695
|
+
const a = `${r.protocol}//${r.hostname}`;
|
|
696
|
+
this.addTracingHeaders(r.headers, a);
|
|
980
697
|
} else d().sfDebug && console.warn("[RequestInterceptor] No headers found in HTTPS request options. Skipping header addition.");
|
|
981
|
-
} catch (
|
|
982
|
-
throw d().sfDebug && console.error("[RequestInterceptor] Error while processing HTTPS request options:",
|
|
698
|
+
} catch (a) {
|
|
699
|
+
throw d().sfDebug && console.error("[RequestInterceptor] Error while processing HTTPS request options:", a), a;
|
|
983
700
|
}
|
|
984
701
|
let c = !1;
|
|
985
|
-
return r
|
|
986
|
-
const
|
|
987
|
-
if (
|
|
988
|
-
const
|
|
989
|
-
delete
|
|
702
|
+
return n(r, (a) => {
|
|
703
|
+
const l = `${r.protocol}//${r.hostname}`;
|
|
704
|
+
if (r.headers && this.shouldPropagateHeaders(new URL(l).hostname) && O.includes(a.statusCode || 0)) {
|
|
705
|
+
const u = { ...r, headers: { ...r.headers } };
|
|
706
|
+
delete u.headers[this.HEADER_TRACING], n(u, g), c = !0, this.captureFirstUserLines(e, 10, c);
|
|
990
707
|
}
|
|
991
|
-
const { sessionId:
|
|
992
|
-
t.doSend({ apiKey: d().apiKey, requestId:
|
|
708
|
+
const { sessionId: I, pageVisitId: p, requestId: C } = this.extractIdsFromTraceHeader(r.headers);
|
|
709
|
+
t.doSend({ apiKey: d().apiKey, requestId: C, pageVisitId: p, recordingSessionId: I, serviceUuid: d().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: a.statusCode || 0, success: !!a.statusCode && a.statusCode < 400, error: null, url: l, method: r.method || "GET", retryWithoutTraceId: c, parentSpanId: $() }), g?.(a);
|
|
993
710
|
});
|
|
994
711
|
}, d().sfDebug && console.log("✅ HTTP and HTTPS request methods patched globally.");
|
|
995
712
|
}
|
|
@@ -1004,7 +721,7 @@ class Ct {
|
|
|
1004
721
|
return [...this.contextManager.getExcludedDomains()];
|
|
1005
722
|
}
|
|
1006
723
|
}
|
|
1007
|
-
class
|
|
724
|
+
class Ee extends Q {
|
|
1008
725
|
constructor() {
|
|
1009
726
|
super(), this.setOperationName("UpdateServiceDetails");
|
|
1010
727
|
}
|
|
@@ -1036,39 +753,39 @@ class mt extends Ie {
|
|
|
1036
753
|
W(this.endpoint, this.operationName, e, t);
|
|
1037
754
|
}
|
|
1038
755
|
}
|
|
1039
|
-
class
|
|
756
|
+
class Le {
|
|
1040
757
|
constructor(e = [process.cwd()], t = !1) {
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
758
|
+
A(this, "rootPaths");
|
|
759
|
+
A(this, "fileConfigs", /* @__PURE__ */ new Map());
|
|
760
|
+
A(this, "functionConfigs", /* @__PURE__ */ new Map());
|
|
761
|
+
A(this, "directoryConfigs", /* @__PURE__ */ new Map());
|
|
762
|
+
A(this, "hasSailfishFiles", !1);
|
|
763
|
+
A(this, "debug");
|
|
1047
764
|
this.rootPaths = e, this.debug = t || process.env.SF_DEBUG === "true";
|
|
1048
765
|
}
|
|
1049
766
|
async loadAllConfigs() {
|
|
1050
767
|
this.debug && console.log("[FuncSpan ConfigLoader] Scanning for .sailfish files in:", this.rootPaths);
|
|
1051
768
|
const e = [];
|
|
1052
|
-
for (const t of this.rootPaths)
|
|
769
|
+
for (const t of this.rootPaths) L.existsSync(t) ? await this._walkDirectory(t, e) : this.debug && console.log(`[FuncSpan ConfigLoader] Root path does not exist: ${t}`);
|
|
1053
770
|
e.length > 0 ? (this.hasSailfishFiles = !0, this.debug && (console.log(`[FuncSpan ConfigLoader] Found ${e.length} .sailfish files:`), e.forEach((t) => console.log(`[FuncSpan ConfigLoader] - ${t}`)))) : this.debug && console.log("[FuncSpan ConfigLoader] No .sailfish files found - function spans disabled by default");
|
|
1054
771
|
for (const t of e) await this._loadConfigFile(t);
|
|
1055
772
|
await this._resolveInheritance(), this.debug && console.log(`[FuncSpan ConfigLoader] Loaded ${this.fileConfigs.size} file configs, ${this.functionConfigs.size} function configs`);
|
|
1056
773
|
}
|
|
1057
774
|
getConfig(e, t) {
|
|
1058
|
-
const s = this.hasSailfishFiles ?
|
|
1059
|
-
let
|
|
775
|
+
const s = this.hasSailfishFiles ? ue() : Se(), n = this._getDirectoryConfig(e), i = G.normalize(e), g = this.fileConfigs.get(i) || {};
|
|
776
|
+
let r = {};
|
|
1060
777
|
if (t) {
|
|
1061
|
-
const c = this.functionConfigs.get(
|
|
1062
|
-
c && (
|
|
778
|
+
const c = this.functionConfigs.get(i);
|
|
779
|
+
c && (r = c.get(t) || {});
|
|
1063
780
|
}
|
|
1064
|
-
return
|
|
781
|
+
return R(s, n, g, r);
|
|
1065
782
|
}
|
|
1066
783
|
async _walkDirectory(e, t) {
|
|
1067
784
|
try {
|
|
1068
|
-
const s =
|
|
1069
|
-
for (const
|
|
1070
|
-
const
|
|
1071
|
-
|
|
785
|
+
const s = L.readdirSync(e, { withFileTypes: !0 });
|
|
786
|
+
for (const n of s) {
|
|
787
|
+
const i = G.join(e, n.name);
|
|
788
|
+
n.isFile() && n.name === ".sailfish" ? t.push(i) : n.name === "node_modules" || n.isDirectory() && n.name.startsWith(".") && n.name !== ".sailfish" || n.isDirectory() && await this._walkDirectory(i, t);
|
|
1072
789
|
}
|
|
1073
790
|
} catch (s) {
|
|
1074
791
|
this.debug && console.error(`[FuncSpan ConfigLoader] Error walking directory ${e}:`, s);
|
|
@@ -1076,46 +793,46 @@ class ht {
|
|
|
1076
793
|
}
|
|
1077
794
|
async _loadConfigFile(e) {
|
|
1078
795
|
try {
|
|
1079
|
-
const t =
|
|
1080
|
-
let
|
|
796
|
+
const t = L.readFileSync(e, "utf-8"), s = G.dirname(e);
|
|
797
|
+
let n = null;
|
|
1081
798
|
try {
|
|
1082
|
-
|
|
799
|
+
n = JSON.parse(t);
|
|
1083
800
|
} catch {
|
|
1084
801
|
try {
|
|
1085
|
-
|
|
1086
|
-
} catch (
|
|
1087
|
-
return void (this.debug && console.error(`[FuncSpan ConfigLoader] Failed to parse ${e} as JSON or YAML:`,
|
|
802
|
+
n = require("js-yaml").load(t);
|
|
803
|
+
} catch (i) {
|
|
804
|
+
return void (this.debug && console.error(`[FuncSpan ConfigLoader] Failed to parse ${e} as JSON or YAML:`, i));
|
|
1088
805
|
}
|
|
1089
806
|
}
|
|
1090
|
-
if (!
|
|
1091
|
-
|
|
807
|
+
if (!n) return;
|
|
808
|
+
n.default && this.directoryConfigs.set(s, n.default), n.files && await this._expandFileGlobs(s, n.files, n.default || {}), n.functions && this._storeFunctionConfigs(s, n.functions, n.default || {}), this.debug && (console.log(`[FuncSpan ConfigLoader] Loaded config from ${e}`), console.log(`[FuncSpan ConfigLoader] Directory: ${s}`), console.log(`[FuncSpan ConfigLoader] Has default: ${!!n.default}`), console.log(`[FuncSpan ConfigLoader] File patterns: ${Object.keys(n.files || {}).length}`), console.log(`[FuncSpan ConfigLoader] Functions: ${Object.keys(n.functions || {}).length}`));
|
|
1092
809
|
} catch (t) {
|
|
1093
810
|
this.debug && console.error(`[FuncSpan ConfigLoader] Error loading ${e}:`, t);
|
|
1094
811
|
}
|
|
1095
812
|
}
|
|
1096
813
|
async _expandFileGlobs(e, t, s) {
|
|
1097
|
-
for (const [
|
|
1098
|
-
const
|
|
1099
|
-
this.debug && console.log(`[FuncSpan ConfigLoader] Pattern '${
|
|
1100
|
-
for (const c of
|
|
1101
|
-
const
|
|
1102
|
-
this.fileConfigs.set(
|
|
814
|
+
for (const [n, i] of Object.entries(t)) try {
|
|
815
|
+
const g = G.join(e, n), r = await Ve(g, { absolute: !0, nodir: !0, ignore: ["**/node_modules/**", "**/.git/**"] });
|
|
816
|
+
this.debug && console.log(`[FuncSpan ConfigLoader] Pattern '${n}' matched ${r.length} files`);
|
|
817
|
+
for (const c of r) {
|
|
818
|
+
const a = G.normalize(c), l = R(s, i);
|
|
819
|
+
this.fileConfigs.set(a, l), this.debug && r.length <= 5 && console.log(`[FuncSpan ConfigLoader] - ${c}`);
|
|
1103
820
|
}
|
|
1104
|
-
} catch (
|
|
1105
|
-
this.debug && console.error(`[FuncSpan ConfigLoader] Error expanding glob '${
|
|
821
|
+
} catch (g) {
|
|
822
|
+
this.debug && console.error(`[FuncSpan ConfigLoader] Error expanding glob '${n}':`, g);
|
|
1106
823
|
}
|
|
1107
824
|
}
|
|
1108
825
|
_storeFunctionConfigs(e, t, s) {
|
|
1109
|
-
for (const [
|
|
1110
|
-
const
|
|
1111
|
-
if (
|
|
1112
|
-
this.debug && console.warn(`[FuncSpan ConfigLoader] Invalid function pattern '${
|
|
826
|
+
for (const [n, i] of Object.entries(t)) {
|
|
827
|
+
const g = n.split("::");
|
|
828
|
+
if (g.length !== 2) {
|
|
829
|
+
this.debug && console.warn(`[FuncSpan ConfigLoader] Invalid function pattern '${n}' (expected format: 'file.ts::functionName')`);
|
|
1113
830
|
continue;
|
|
1114
831
|
}
|
|
1115
|
-
const [
|
|
1116
|
-
this.functionConfigs.has(
|
|
1117
|
-
const
|
|
1118
|
-
|
|
832
|
+
const [r, c] = g, a = G.normalize(G.join(e, r));
|
|
833
|
+
this.functionConfigs.has(a) || this.functionConfigs.set(a, /* @__PURE__ */ new Map());
|
|
834
|
+
const l = this.functionConfigs.get(a), I = R(s, i);
|
|
835
|
+
l.set(c, I), this.debug && console.log(`[FuncSpan ConfigLoader] Function config: ${a}::${c}`);
|
|
1119
836
|
}
|
|
1120
837
|
}
|
|
1121
838
|
async _resolveInheritance() {
|
|
@@ -1124,634 +841,242 @@ class ht {
|
|
|
1124
841
|
let t = G.dirname(G.normalize(e));
|
|
1125
842
|
const s = [];
|
|
1126
843
|
for (; t && t !== G.dirname(t); ) {
|
|
1127
|
-
const
|
|
1128
|
-
|
|
1129
|
-
}
|
|
1130
|
-
return s.reduce((r, a) => z(r, a), {});
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
let D = null;
|
|
1134
|
-
async function ft(n, e) {
|
|
1135
|
-
D = new ht(n, e), await D.loadAllConfigs();
|
|
1136
|
-
}
|
|
1137
|
-
function bt(n, e) {
|
|
1138
|
-
return D ? D.getConfig(n, e) : (process.env.SF_DEBUG === "true" && console.log("[FuncSpan ConfigLoader] Config loader not initialized, using env config for worker process"), ke());
|
|
1139
|
-
}
|
|
1140
|
-
function At() {
|
|
1141
|
-
return D !== null;
|
|
1142
|
-
}
|
|
1143
|
-
function V(n, e) {
|
|
1144
|
-
const t = process.env[n];
|
|
1145
|
-
return t === void 0 ? e : t === "true" || t === "1";
|
|
1146
|
-
}
|
|
1147
|
-
function Be(n, e) {
|
|
1148
|
-
const t = process.env[n];
|
|
1149
|
-
if (t === void 0) return e;
|
|
1150
|
-
const s = parseFloat(t);
|
|
1151
|
-
return isNaN(s) ? e : s;
|
|
1152
|
-
}
|
|
1153
|
-
function me() {
|
|
1154
|
-
return { enabled: V("SF_WORKER_POOL_ENABLED", !0), trackFs: V("SF_WORKER_POOL_TRACK_FS", !1), trackDns: V("SF_WORKER_POOL_TRACK_DNS", !0), trackCrypto: V("SF_WORKER_POOL_TRACK_CRYPTO", !1), trackZlib: V("SF_WORKER_POOL_TRACK_ZLIB", !1), captureArguments: V("SF_WORKER_POOL_CAPTURE_ARGUMENTS", !0), captureReturnValue: V("SF_WORKER_POOL_CAPTURE_RETURN_VALUE", !0), argLimitMb: Be("SF_WORKER_POOL_ARG_LIMIT_MB", 1), returnLimitMb: Be("SF_WORKER_POOL_RETURN_LIMIT_MB", 1) };
|
|
1155
|
-
}
|
|
1156
|
-
function O(n) {
|
|
1157
|
-
const e = me();
|
|
1158
|
-
if (!e.enabled) return !1;
|
|
1159
|
-
switch (n) {
|
|
1160
|
-
case "fs":
|
|
1161
|
-
return e.trackFs;
|
|
1162
|
-
case "dns":
|
|
1163
|
-
return e.trackDns;
|
|
1164
|
-
case "crypto":
|
|
1165
|
-
return e.trackCrypto;
|
|
1166
|
-
case "zlib":
|
|
1167
|
-
return e.trackZlib;
|
|
1168
|
-
default:
|
|
1169
|
-
return !1;
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
function De(n, e, t, s) {
|
|
1173
|
-
let r;
|
|
1174
|
-
try {
|
|
1175
|
-
switch (n) {
|
|
1176
|
-
case "fs":
|
|
1177
|
-
r = (function(a, o) {
|
|
1178
|
-
const i = {};
|
|
1179
|
-
switch (a) {
|
|
1180
|
-
case "readFile":
|
|
1181
|
-
case "writeFile":
|
|
1182
|
-
case "appendFile":
|
|
1183
|
-
i.path = String(o[0] || ""), o[1] && typeof o[1] == "object" ? (i.encoding = o[1].encoding || null, i.flag = o[1].flag || null) : typeof o[1] == "string" && (i.encoding = o[1]), a !== "writeFile" && a !== "appendFile" || (Buffer.isBuffer(o[1]) ? (i.dataType = "Buffer", i.dataSize = o[1].length) : typeof o[1] == "string" && (i.dataType = "string", i.dataSize = o[1].length));
|
|
1184
|
-
break;
|
|
1185
|
-
case "readdir":
|
|
1186
|
-
case "stat":
|
|
1187
|
-
case "lstat":
|
|
1188
|
-
case "access":
|
|
1189
|
-
case "chmod":
|
|
1190
|
-
case "mkdir":
|
|
1191
|
-
case "rmdir":
|
|
1192
|
-
case "unlink":
|
|
1193
|
-
i.path = String(o[0] || ""), o[1] && typeof o[1] == "object" && (i.options = { ...o[1] }, delete i.options.callback);
|
|
1194
|
-
break;
|
|
1195
|
-
case "rename":
|
|
1196
|
-
i.oldPath = String(o[0] || ""), i.newPath = String(o[1] || "");
|
|
1197
|
-
break;
|
|
1198
|
-
case "open":
|
|
1199
|
-
i.path = String(o[0] || ""), i.flags = o[1], i.mode = o[2];
|
|
1200
|
-
break;
|
|
1201
|
-
case "close":
|
|
1202
|
-
case "fstat":
|
|
1203
|
-
i.fd = o[0];
|
|
1204
|
-
break;
|
|
1205
|
-
case "read":
|
|
1206
|
-
case "write":
|
|
1207
|
-
i.fd = o[0], Buffer.isBuffer(o[1]) && (i.bufferSize = o[1].length), i.offset = o[2], i.length = o[3], i.position = o[4];
|
|
1208
|
-
break;
|
|
1209
|
-
default:
|
|
1210
|
-
i.argsCount = o.length - 1;
|
|
1211
|
-
}
|
|
1212
|
-
return i;
|
|
1213
|
-
})(e, t);
|
|
1214
|
-
break;
|
|
1215
|
-
case "dns":
|
|
1216
|
-
r = (function(a, o) {
|
|
1217
|
-
const i = {};
|
|
1218
|
-
switch (a) {
|
|
1219
|
-
case "lookup":
|
|
1220
|
-
i.hostname = String(o[0] || ""), typeof o[1] == "object" ? (i.family = o[1].family, i.all = o[1].all) : typeof o[1] == "number" && (i.family = o[1]);
|
|
1221
|
-
break;
|
|
1222
|
-
case "resolve":
|
|
1223
|
-
case "resolve4":
|
|
1224
|
-
case "resolve6":
|
|
1225
|
-
case "resolveAny":
|
|
1226
|
-
case "resolveMx":
|
|
1227
|
-
case "resolveNs":
|
|
1228
|
-
case "resolveTxt":
|
|
1229
|
-
i.hostname = String(o[0] || "");
|
|
1230
|
-
break;
|
|
1231
|
-
case "reverse":
|
|
1232
|
-
i.ip = String(o[0] || "");
|
|
1233
|
-
break;
|
|
1234
|
-
default:
|
|
1235
|
-
i.argsCount = o.length - 1;
|
|
1236
|
-
}
|
|
1237
|
-
return i;
|
|
1238
|
-
})(e, t);
|
|
1239
|
-
break;
|
|
1240
|
-
case "crypto":
|
|
1241
|
-
r = (function(a, o) {
|
|
1242
|
-
const i = {};
|
|
1243
|
-
switch (a) {
|
|
1244
|
-
case "pbkdf2":
|
|
1245
|
-
i.passwordType = typeof o[0], i.saltType = typeof o[1], i.iterations = o[2], i.keylen = o[3], i.digest = o[4];
|
|
1246
|
-
break;
|
|
1247
|
-
case "scrypt":
|
|
1248
|
-
i.passwordType = typeof o[0], i.saltType = typeof o[1], i.keylen = o[2], typeof o[3] == "object" && (i.N = o[3].N, i.r = o[3].r, i.p = o[3].p);
|
|
1249
|
-
break;
|
|
1250
|
-
case "randomBytes":
|
|
1251
|
-
i.size = o[0];
|
|
1252
|
-
break;
|
|
1253
|
-
case "generateKeyPair":
|
|
1254
|
-
i.type = o[0], typeof o[1] == "object" && (i.modulusLength = o[1].modulusLength, i.namedCurve = o[1].namedCurve);
|
|
1255
|
-
break;
|
|
1256
|
-
default:
|
|
1257
|
-
i.argsCount = o.length - 1;
|
|
1258
|
-
}
|
|
1259
|
-
return i;
|
|
1260
|
-
})(e, t);
|
|
1261
|
-
break;
|
|
1262
|
-
case "zlib":
|
|
1263
|
-
r = (function(a, o) {
|
|
1264
|
-
const i = {};
|
|
1265
|
-
return Buffer.isBuffer(o[0]) ? (i.inputType = "Buffer", i.inputSize = o[0].length) : typeof o[0] == "string" ? (i.inputType = "string", i.inputSize = o[0].length) : i.inputType = typeof o[0], o[1] && typeof o[1] == "object" && typeof o[1] != "function" && (i.options = { ...o[1] }), i;
|
|
1266
|
-
})(0, t);
|
|
1267
|
-
break;
|
|
1268
|
-
default:
|
|
1269
|
-
return null;
|
|
844
|
+
const n = this.directoryConfigs.get(t);
|
|
845
|
+
n && s.unshift(n), t = G.dirname(t);
|
|
1270
846
|
}
|
|
1271
|
-
return s
|
|
1272
|
-
} catch {
|
|
1273
|
-
return { error: "Failed to capture arguments", argsCount: t.length - 1 };
|
|
1274
|
-
}
|
|
1275
|
-
}
|
|
1276
|
-
function Xe(n, e, t, s) {
|
|
1277
|
-
let r;
|
|
1278
|
-
try {
|
|
1279
|
-
switch (n) {
|
|
1280
|
-
case "fs":
|
|
1281
|
-
r = (function(a, o) {
|
|
1282
|
-
if (!o) return null;
|
|
1283
|
-
switch (a) {
|
|
1284
|
-
case "readFile":
|
|
1285
|
-
return Buffer.isBuffer(o) ? { type: "Buffer", size: o.length } : typeof o == "string" ? { type: "string", size: o.length } : { type: typeof o };
|
|
1286
|
-
case "readdir":
|
|
1287
|
-
return { count: Array.isArray(o) ? o.length : 0, items: o };
|
|
1288
|
-
case "stat":
|
|
1289
|
-
case "lstat":
|
|
1290
|
-
case "fstat":
|
|
1291
|
-
return { size: o.size, mode: o.mode, isFile: o.isFile(), isDirectory: o.isDirectory() };
|
|
1292
|
-
case "open":
|
|
1293
|
-
return { fd: o };
|
|
1294
|
-
case "read":
|
|
1295
|
-
return { bytesRead: o };
|
|
1296
|
-
case "write":
|
|
1297
|
-
return { bytesWritten: o };
|
|
1298
|
-
default:
|
|
1299
|
-
return o;
|
|
1300
|
-
}
|
|
1301
|
-
})(e, t);
|
|
1302
|
-
break;
|
|
1303
|
-
case "dns":
|
|
1304
|
-
r = (function(a, o) {
|
|
1305
|
-
if (!o) return null;
|
|
1306
|
-
switch (a) {
|
|
1307
|
-
case "lookup":
|
|
1308
|
-
return Array.isArray(o) ? { count: o.length, addresses: o } : o;
|
|
1309
|
-
case "resolve":
|
|
1310
|
-
case "resolve4":
|
|
1311
|
-
case "resolve6":
|
|
1312
|
-
case "resolveAny":
|
|
1313
|
-
case "resolveMx":
|
|
1314
|
-
case "resolveNs":
|
|
1315
|
-
case "resolveTxt":
|
|
1316
|
-
return { count: Array.isArray(o) ? o.length : 0, records: o };
|
|
1317
|
-
case "reverse":
|
|
1318
|
-
return { hostnames: o };
|
|
1319
|
-
default:
|
|
1320
|
-
return o;
|
|
1321
|
-
}
|
|
1322
|
-
})(e, t);
|
|
1323
|
-
break;
|
|
1324
|
-
case "crypto":
|
|
1325
|
-
r = (function(a, o) {
|
|
1326
|
-
if (!o) return null;
|
|
1327
|
-
switch (a) {
|
|
1328
|
-
case "pbkdf2":
|
|
1329
|
-
case "scrypt":
|
|
1330
|
-
case "randomBytes":
|
|
1331
|
-
return Buffer.isBuffer(o) ? { type: "Buffer", size: o.length } : { type: typeof o };
|
|
1332
|
-
case "generateKeyPair":
|
|
1333
|
-
return { hasPublicKey: !!o?.publicKey, hasPrivateKey: !!o?.privateKey };
|
|
1334
|
-
default:
|
|
1335
|
-
return o;
|
|
1336
|
-
}
|
|
1337
|
-
})(e, t);
|
|
1338
|
-
break;
|
|
1339
|
-
case "zlib":
|
|
1340
|
-
r = (function(a, o) {
|
|
1341
|
-
return o ? Buffer.isBuffer(o) ? { type: "Buffer", size: o.length } : typeof o == "string" ? { type: "string", size: o.length } : { type: typeof o } : null;
|
|
1342
|
-
})(0, t);
|
|
1343
|
-
break;
|
|
1344
|
-
default:
|
|
1345
|
-
return null;
|
|
1346
|
-
}
|
|
1347
|
-
return s > 0 ? J(r, s) : r;
|
|
1348
|
-
} catch {
|
|
1349
|
-
return { error: "Failed to capture result", type: typeof t };
|
|
1350
|
-
}
|
|
1351
|
-
}
|
|
1352
|
-
function yt(n) {
|
|
1353
|
-
return n.operationType === "worker_pool";
|
|
1354
|
-
}
|
|
1355
|
-
class Le extends $ {
|
|
1356
|
-
constructor() {
|
|
1357
|
-
super(), this.operationName = "CollectFunctionSpans";
|
|
1358
|
-
}
|
|
1359
|
-
send(e) {
|
|
1360
|
-
const t = d().sfDebug;
|
|
1361
|
-
t && console.log(`[FunctionSpanTransmitter] Preparing to send ${e.length} function span(s)`);
|
|
1362
|
-
for (const s of e) try {
|
|
1363
|
-
if (yt(s)) {
|
|
1364
|
-
this.sendWorkerPoolSpan(s, t);
|
|
1365
|
-
continue;
|
|
1366
|
-
}
|
|
1367
|
-
const r = s;
|
|
1368
|
-
let a;
|
|
1369
|
-
if (r.result !== void 0 && r.result !== null) {
|
|
1370
|
-
const i = typeof r.result;
|
|
1371
|
-
a = JSON.stringify({ type: i, has_value: !0, value: r.result });
|
|
1372
|
-
} else a = r.result === null ? JSON.stringify({ type: "null", has_value: !0, value: null }) : JSON.stringify({ type: "undefined", has_value: !1, value: null });
|
|
1373
|
-
const o = this.getVariables({ library: "JS/TS BACKEND", version: d().version, spanId: r.spanId, parentSpanId: r.parentSpanId, filePath: r.filePath, lineNumber: r.metadata.line, columnNumber: r.metadata.column, functionName: r.functionName, arguments: JSON.stringify(r.args || {}), returnValue: a, startTimeNs: (1e6 * Date.now() - 1e6 * r.duration).toString(), durationNs: (1e6 * r.duration).toString() });
|
|
1374
|
-
t && (console.log(`[FunctionSpanTransmitter] Sending GraphQL mutation to ${this.endpoint}`), console.log("[FunctionSpanTransmitter] Variables:", JSON.stringify(o, null, 2))), W(this.endpoint, this.operationName, this.getQuery(), o), t && console.log(`[FunctionSpanTransmitter] Queued function span for ${r.functionName}`);
|
|
1375
|
-
} catch (r) {
|
|
1376
|
-
console.error(`[FunctionSpanTransmitter] Error preparing function span for ${s.functionName}:`, r);
|
|
1377
|
-
}
|
|
1378
|
-
}
|
|
1379
|
-
sendWorkerPoolSpan(e, t) {
|
|
1380
|
-
try {
|
|
1381
|
-
let s;
|
|
1382
|
-
if (e.result !== void 0 && e.result !== null) {
|
|
1383
|
-
const a = typeof e.result;
|
|
1384
|
-
s = JSON.stringify({ type: a, has_value: !0, value: e.result });
|
|
1385
|
-
} else s = e.result === null ? JSON.stringify({ type: "null", has_value: !0, value: null }) : JSON.stringify({ type: "undefined", has_value: !1, value: null });
|
|
1386
|
-
const r = this.getVariables({ library: "JS/TS BACKEND", version: d().version, spanId: e.spanId, operationName: e.operationName, moduleName: e.moduleName, methodName: e.methodName, startTimeNs: e.startTimeNs, durationNs: e.durationNs, arguments: JSON.stringify(e.args || {}), returnValue: s, error: e.error, pid: e.pid, threadId: e.threadId });
|
|
1387
|
-
t && (console.log(`[FunctionSpanTransmitter] Sending worker pool span: ${e.operationName}`), console.log("[FunctionSpanTransmitter] Variables:", JSON.stringify(r, null, 2))), W(this.endpoint, "CollectWorkerPoolSpans", this.getWorkerPoolQuery(), r), t && console.log(`[FunctionSpanTransmitter] Queued worker pool span for ${e.operationName}`);
|
|
1388
|
-
} catch (s) {
|
|
1389
|
-
console.error(`[FunctionSpanTransmitter] Error preparing worker pool span for ${e.operationName}:`, s);
|
|
1390
|
-
}
|
|
1391
|
-
}
|
|
1392
|
-
getWorkerPoolQuery() {
|
|
1393
|
-
return `
|
|
1394
|
-
mutation CollectWorkerPoolSpans(
|
|
1395
|
-
$apiKey: String!,
|
|
1396
|
-
$serviceUuid: String!,
|
|
1397
|
-
$sessionId: String!,
|
|
1398
|
-
$timestampMs: String!,
|
|
1399
|
-
$library: String!,
|
|
1400
|
-
$version: String!,
|
|
1401
|
-
$spanId: String!,
|
|
1402
|
-
$operationName: String!,
|
|
1403
|
-
$moduleName: String!,
|
|
1404
|
-
$methodName: String!,
|
|
1405
|
-
$startTimeNs: String!,
|
|
1406
|
-
$durationNs: String!,
|
|
1407
|
-
$parentSpanId: String,
|
|
1408
|
-
$arguments: String,
|
|
1409
|
-
$returnValue: String,
|
|
1410
|
-
$error: String,
|
|
1411
|
-
$pid: Int,
|
|
1412
|
-
$threadId: Int
|
|
1413
|
-
) {
|
|
1414
|
-
collectWorkerPoolSpans(
|
|
1415
|
-
apiKey: $apiKey,
|
|
1416
|
-
serviceUuid: $serviceUuid,
|
|
1417
|
-
sessionId: $sessionId,
|
|
1418
|
-
timestampMs: $timestampMs,
|
|
1419
|
-
library: $library,
|
|
1420
|
-
version: $version,
|
|
1421
|
-
spanId: $spanId,
|
|
1422
|
-
operationName: $operationName,
|
|
1423
|
-
moduleName: $moduleName,
|
|
1424
|
-
methodName: $methodName,
|
|
1425
|
-
startTimeNs: $startTimeNs,
|
|
1426
|
-
durationNs: $durationNs,
|
|
1427
|
-
parentSpanId: $parentSpanId,
|
|
1428
|
-
arguments: $arguments,
|
|
1429
|
-
returnValue: $returnValue,
|
|
1430
|
-
error: $error,
|
|
1431
|
-
pid: $pid,
|
|
1432
|
-
threadId: $threadId
|
|
1433
|
-
)
|
|
1434
|
-
}
|
|
1435
|
-
`;
|
|
1436
|
-
}
|
|
1437
|
-
getQuery() {
|
|
1438
|
-
return `
|
|
1439
|
-
${this.queryType} ${this.operationName}(
|
|
1440
|
-
$apiKey: String!,
|
|
1441
|
-
$serviceUuid: String!,
|
|
1442
|
-
$sessionId: String!,
|
|
1443
|
-
$timestampMs: String!,
|
|
1444
|
-
$parentSpanId: String,
|
|
1445
|
-
$library: String!,
|
|
1446
|
-
$version: String!,
|
|
1447
|
-
$spanId: String!,
|
|
1448
|
-
$filePath: String!,
|
|
1449
|
-
$lineNumber: Int!,
|
|
1450
|
-
$columnNumber: Int!,
|
|
1451
|
-
$functionName: String!,
|
|
1452
|
-
$arguments: String!,
|
|
1453
|
-
$returnValue: String,
|
|
1454
|
-
$startTimeNs: String!,
|
|
1455
|
-
$durationNs: String!
|
|
1456
|
-
) {
|
|
1457
|
-
${this.queryName}(
|
|
1458
|
-
apiKey: $apiKey,
|
|
1459
|
-
serviceUuid: $serviceUuid,
|
|
1460
|
-
sessionId: $sessionId,
|
|
1461
|
-
timestampMs: $timestampMs,
|
|
1462
|
-
parentSpanId: $parentSpanId,
|
|
1463
|
-
library: $library,
|
|
1464
|
-
version: $version,
|
|
1465
|
-
spanId: $spanId,
|
|
1466
|
-
filePath: $filePath,
|
|
1467
|
-
lineNumber: $lineNumber,
|
|
1468
|
-
columnNumber: $columnNumber,
|
|
1469
|
-
functionName: $functionName,
|
|
1470
|
-
arguments: $arguments,
|
|
1471
|
-
returnValue: $returnValue,
|
|
1472
|
-
startTimeNs: $startTimeNs,
|
|
1473
|
-
durationNs: $durationNs
|
|
1474
|
-
)
|
|
1475
|
-
}
|
|
1476
|
-
`;
|
|
847
|
+
return s.reduce((n, i) => R(n, i), {});
|
|
1477
848
|
}
|
|
1478
849
|
}
|
|
1479
|
-
let
|
|
1480
|
-
function
|
|
1481
|
-
|
|
1482
|
-
o && console.log(`[WorkerPool] Capturing ${n}.${e}`);
|
|
1483
|
-
const i = me(), c = v.getInstance().getCurrentFunctionSpanId(), l = w();
|
|
1484
|
-
o && console.log(`[WorkerPool] Span ID: ${l}, Parent: ${c || "none"}`);
|
|
1485
|
-
const g = new Oe("WorkerPoolOperation"), u = process.hrtime.bigint();
|
|
1486
|
-
let I = null;
|
|
1487
|
-
i.captureArguments && (I = De(n, e, s, i.argLimitMb));
|
|
1488
|
-
const m = s.findIndex((f) => typeof f == "function");
|
|
1489
|
-
if (m === -1) return o && console.log(`[WorkerPool] No callback found for ${n}.${e}`), t.apply(r, s);
|
|
1490
|
-
const p = s[m], h = [...s];
|
|
1491
|
-
return h[m] = function(f, ...S) {
|
|
1492
|
-
const b = process.hrtime.bigint() - u, y = Number(b) / 1e6;
|
|
1493
|
-
p(f, ...S), g.runInAsyncScope(() => {
|
|
1494
|
-
o && console.log(`[WorkerPool] ${n}.${e} completed in ${y.toFixed(3)}ms (${b}ns)`);
|
|
1495
|
-
let A = null, Z = null;
|
|
1496
|
-
f ? Z = f?.message || String(f) : i.captureReturnValue && S.length > 0 && (A = Xe(n, e, S[0], i.returnLimitMb)), de({ operationType: "worker_pool", operationName: `${n}.${e}`, moduleName: n, methodName: e, duration: y, durationNs: b.toString(), startTimeNs: u.toString(), args: I, result: A, error: Z, spanId: l, parentSpanId: c, pid: process.pid, threadId: T });
|
|
1497
|
-
}), g.emitDestroy();
|
|
1498
|
-
}, t.apply(r, h);
|
|
850
|
+
let H = null;
|
|
851
|
+
async function De(o, e) {
|
|
852
|
+
H = new Le(o, e), await H.loadAllConfigs();
|
|
1499
853
|
}
|
|
1500
|
-
function
|
|
1501
|
-
|
|
1502
|
-
o && console.log(`[WorkerPool] Capturing ${n}.${e} (Promise)`);
|
|
1503
|
-
const i = me(), c = v.getInstance().getCurrentFunctionSpanId(), l = w();
|
|
1504
|
-
o && console.log(`[WorkerPool] Span ID: ${l}, Parent: ${c || "none"}`);
|
|
1505
|
-
const g = process.hrtime.bigint();
|
|
1506
|
-
let u = null;
|
|
1507
|
-
return i.captureArguments && (u = De(n, e, s, i.argLimitMb)), t.apply(r, s).then((I) => {
|
|
1508
|
-
const m = process.hrtime.bigint() - g, p = Number(m) / 1e6;
|
|
1509
|
-
o && console.log(`[WorkerPool] ${n}.${e} completed in ${p.toFixed(3)}ms (${m}ns)`);
|
|
1510
|
-
let h = null;
|
|
1511
|
-
return i.captureReturnValue && (h = Xe(n, e, I, i.returnLimitMb)), de({ operationType: "worker_pool", operationName: `${n}.${e}`, moduleName: n, methodName: e, duration: p, durationNs: m.toString(), startTimeNs: g.toString(), args: u, result: h, error: null, spanId: l, parentSpanId: c, pid: process.pid, threadId: T }), I;
|
|
1512
|
-
}, (I) => {
|
|
1513
|
-
const m = process.hrtime.bigint() - g, p = Number(m) / 1e6;
|
|
1514
|
-
throw o && console.log(`[WorkerPool] ${n}.${e} failed in ${p.toFixed(3)}ms: ${I?.message || I}`), de({ operationType: "worker_pool", operationName: `${n}.${e}`, moduleName: n, methodName: e, duration: p, durationNs: m.toString(), startTimeNs: g.toString(), args: u, result: null, error: I?.message || String(I), spanId: l, parentSpanId: c, pid: process.pid, threadId: T }), I;
|
|
1515
|
-
});
|
|
854
|
+
function xe(o, e) {
|
|
855
|
+
return H ? H.getConfig(o, e) : (process.env.SF_DEBUG === "true" && console.log("[FuncSpan ConfigLoader] Config loader not initialized, using env config for worker process"), ue());
|
|
1516
856
|
}
|
|
1517
|
-
function
|
|
1518
|
-
|
|
1519
|
-
t && console.log("[WorkerPool] Capturing span:", { operation: n.operationName, duration: `${n.duration}ms`, error: n.error, spanId: n.spanId, parentSpanId: n.parentSpanId }), process.env.SF_FUNCSPAN_CONSOLE_OUTPUT === "true" && console.log(`
|
|
1520
|
-
⚙️ Worker Pool Operation:`, { operation: n.operationName, duration: `${n.duration.toFixed(2)}ms`, arguments: n.args, result: n.error ? `Error: ${n.error}` : n.result, spanId: n.spanId, parentSpanId: n.parentSpanId || "none" });
|
|
1521
|
-
const s = process.env.SF_FUNCSPAN_JSONL_FILE;
|
|
1522
|
-
if (s) try {
|
|
1523
|
-
const r = s === "true" || s === "1" ? "funcspans.jsonl" : s, a = Date.now(), o = process.hrtime.bigint(), i = BigInt(n.startTimeNs), c = Number(o - i) / 1e6, l = new Date(a - c).toISOString(), g = JSON.stringify({ timestamp: l, operationType: n.operationType, operationName: n.operationName, moduleName: n.moduleName, methodName: n.methodName, duration: n.duration, durationNs: n.durationNs, startTimeNs: n.startTimeNs, arguments: n.args, returnValue: n.error ? { error: String(n.error) } : n.result, spanId: n.spanId, parentSpanId: n.parentSpanId, pid: n.pid, threadId: n.threadId }) + `
|
|
1524
|
-
`;
|
|
1525
|
-
Te(r, g, "utf-8");
|
|
1526
|
-
} catch (r) {
|
|
1527
|
-
console.error("[WorkerPool] Error writing to JSONL file:", r);
|
|
1528
|
-
}
|
|
1529
|
-
if (t && console.log("[WorkerPool] Sending span to transmitter"), process.env.SF_FUNCSPAN_SKIP_BACKEND !== "true") try {
|
|
1530
|
-
(le || (le = new Le()), le).send([n]), t && console.log("[WorkerPool] Span sent successfully");
|
|
1531
|
-
} catch (r) {
|
|
1532
|
-
t && console.error("[WorkerPool] Error sending span:", r);
|
|
1533
|
-
}
|
|
857
|
+
function Pe() {
|
|
858
|
+
return H !== null;
|
|
1534
859
|
}
|
|
1535
|
-
const
|
|
1536
|
-
let
|
|
1537
|
-
function
|
|
1538
|
-
if (!
|
|
1539
|
-
const
|
|
1540
|
-
if (
|
|
1541
|
-
Object.defineProperty(
|
|
1542
|
-
for (const e of
|
|
1543
|
-
const t =
|
|
1544
|
-
|
|
1545
|
-
const
|
|
1546
|
-
return typeof
|
|
1547
|
-
}, Object.defineProperty(
|
|
860
|
+
const Oe = ["readFile", "writeFile", "appendFile", "readdir", "stat", "lstat", "fstat", "access", "open", "close", "read", "write", "chmod", "mkdir", "rmdir", "unlink", "rename"], ie = ["lookup", "resolve", "resolve4", "resolve6", "resolveAny", "resolveMx", "resolveNs", "resolveTxt", "reverse"], je = ["pbkdf2", "randomBytes", "scrypt", "generateKeyPair"], Me = ["gzip", "gunzip", "deflate", "inflate", "deflateRaw", "inflateRaw", "brotliCompress", "brotliDecompress"];
|
|
861
|
+
let re = !1, ae = !1;
|
|
862
|
+
function Qe() {
|
|
863
|
+
if (!ae) try {
|
|
864
|
+
const o = require("node:dns");
|
|
865
|
+
if (o.__sf_worker_pool_patched__) return;
|
|
866
|
+
Object.defineProperty(o, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
|
|
867
|
+
for (const e of ie) if (typeof o[e] == "function") {
|
|
868
|
+
const t = o[e];
|
|
869
|
+
o[e] = function(...s) {
|
|
870
|
+
const n = s[0];
|
|
871
|
+
return typeof n == "string" && (n === "localhost" || n === "127.0.0.1") ? t.apply(this, s) : typeof s[s.length - 1] == "function" ? _("dns", e, t, s, this) : t.apply(this, s);
|
|
872
|
+
}, Object.defineProperty(o[e], "name", { value: e, writable: !1 });
|
|
1548
873
|
}
|
|
1549
874
|
(function(e) {
|
|
1550
875
|
if (!e.promises) return void (process.env.SF_DEBUG === "true" && console.log("[WorkerPool] dns.promises not available, skipping"));
|
|
1551
876
|
if (!e.promises.__sf_worker_pool_patched__) {
|
|
1552
877
|
Object.defineProperty(e.promises, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
|
|
1553
|
-
for (const t of
|
|
878
|
+
for (const t of ie) if (typeof e.promises[t] == "function") {
|
|
1554
879
|
const s = e.promises[t];
|
|
1555
|
-
e.promises[t] = function(...
|
|
1556
|
-
const
|
|
1557
|
-
return typeof
|
|
880
|
+
e.promises[t] = function(...n) {
|
|
881
|
+
const i = n[0];
|
|
882
|
+
return typeof i != "string" || i !== "localhost" && i !== "127.0.0.1" ? Be("dns", t, s, n, this) : s.apply(this, n);
|
|
1558
883
|
}, Object.defineProperty(e.promises[t], "name", { value: t, writable: !1 });
|
|
1559
884
|
}
|
|
1560
885
|
process.env.SF_DEBUG === "true" && console.log("[WorkerPool] dns.promises module patched successfully");
|
|
1561
886
|
}
|
|
1562
|
-
})(
|
|
1563
|
-
} catch (
|
|
1564
|
-
console.error("[WorkerPool] Error patching dns module:",
|
|
887
|
+
})(o), ae = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] dns module patched successfully");
|
|
888
|
+
} catch (o) {
|
|
889
|
+
console.error("[WorkerPool] Error patching dns module:", o);
|
|
1565
890
|
}
|
|
1566
891
|
}
|
|
1567
|
-
let
|
|
1568
|
-
function
|
|
1569
|
-
if (
|
|
1570
|
-
const
|
|
1571
|
-
|
|
1572
|
-
if (!
|
|
892
|
+
let ce = !1, ge = !1, M = !1;
|
|
893
|
+
function qe() {
|
|
894
|
+
if (M) return;
|
|
895
|
+
const o = process.env.SF_DEBUG === "true";
|
|
896
|
+
o && console.log("[WorkerPool] Initializing worker pool patching..."), X("fs") && (o && console.log("[WorkerPool] Patching fs module..."), (function() {
|
|
897
|
+
if (!re) try {
|
|
1573
898
|
const e = require("node:fs");
|
|
1574
899
|
if (e.__sf_worker_pool_patched__) return;
|
|
1575
900
|
Object.defineProperty(e, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
|
|
1576
|
-
for (const t of
|
|
901
|
+
for (const t of Oe) if (typeof e[t] == "function") {
|
|
1577
902
|
const s = e[t];
|
|
1578
|
-
e[t] = function(...
|
|
1579
|
-
return typeof
|
|
903
|
+
e[t] = function(...n) {
|
|
904
|
+
return typeof n[n.length - 1] == "function" ? _("fs", t, s, n, this) : s.apply(this, n);
|
|
1580
905
|
}, Object.defineProperty(e[t], "name", { value: t, writable: !1 });
|
|
1581
906
|
}
|
|
1582
|
-
|
|
907
|
+
re = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] fs module patched successfully");
|
|
1583
908
|
} catch (e) {
|
|
1584
909
|
console.error("[WorkerPool] Error patching fs module:", e);
|
|
1585
910
|
}
|
|
1586
|
-
})()),
|
|
1587
|
-
if (!
|
|
911
|
+
})()), X("dns") && (o && console.log("[WorkerPool] Patching dns module..."), Qe()), X("crypto") && (o && console.log("[WorkerPool] Patching crypto module..."), (function() {
|
|
912
|
+
if (!ce) try {
|
|
1588
913
|
const e = require("node:crypto");
|
|
1589
914
|
if (e.__sf_worker_pool_patched__) return;
|
|
1590
915
|
Object.defineProperty(e, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
|
|
1591
|
-
for (const t of
|
|
916
|
+
for (const t of je) if (typeof e[t] == "function") {
|
|
1592
917
|
const s = e[t];
|
|
1593
|
-
e[t] = function(...
|
|
1594
|
-
return typeof
|
|
918
|
+
e[t] = function(...n) {
|
|
919
|
+
return typeof n[n.length - 1] == "function" ? _("crypto", t, s, n, this) : s.apply(this, n);
|
|
1595
920
|
}, Object.defineProperty(e[t], "name", { value: t, writable: !1 });
|
|
1596
921
|
}
|
|
1597
|
-
|
|
922
|
+
ce = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] crypto module patched successfully");
|
|
1598
923
|
} catch (e) {
|
|
1599
924
|
console.error("[WorkerPool] Error patching crypto module:", e);
|
|
1600
925
|
}
|
|
1601
|
-
})()),
|
|
1602
|
-
if (!
|
|
926
|
+
})()), X("zlib") && (o && console.log("[WorkerPool] Patching zlib module..."), (function() {
|
|
927
|
+
if (!ge) try {
|
|
1603
928
|
const e = require("node:zlib");
|
|
1604
929
|
if (e.__sf_worker_pool_patched__) return;
|
|
1605
930
|
Object.defineProperty(e, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
|
|
1606
|
-
for (const t of
|
|
931
|
+
for (const t of Me) if (typeof e[t] == "function") {
|
|
1607
932
|
const s = e[t];
|
|
1608
|
-
e[t] = function(...
|
|
1609
|
-
return typeof
|
|
933
|
+
e[t] = function(...n) {
|
|
934
|
+
return typeof n[n.length - 1] == "function" ? _("zlib", t, s, n, this) : s.apply(this, n);
|
|
1610
935
|
}, Object.defineProperty(e[t], "name", { value: t, writable: !1 });
|
|
1611
936
|
}
|
|
1612
|
-
|
|
937
|
+
ge = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] zlib module patched successfully");
|
|
1613
938
|
} catch (e) {
|
|
1614
939
|
console.error("[WorkerPool] Error patching zlib module:", e);
|
|
1615
940
|
}
|
|
1616
|
-
})()),
|
|
941
|
+
})()), M = !0, o && console.log("[WorkerPool] Worker pool patching initialized");
|
|
1617
942
|
}
|
|
1618
|
-
function
|
|
1619
|
-
return
|
|
943
|
+
function et() {
|
|
944
|
+
return M;
|
|
1620
945
|
}
|
|
1621
|
-
function
|
|
1622
|
-
if (!
|
|
1623
|
-
const
|
|
1624
|
-
console.error(
|
|
946
|
+
function ct(o) {
|
|
947
|
+
if (!o || !o.apiKey) {
|
|
948
|
+
const n = `The required API Key is not provided: ${JSON.stringify(o)}`;
|
|
949
|
+
console.error(n);
|
|
1625
950
|
}
|
|
1626
|
-
const { config: e } =
|
|
951
|
+
const { config: e } = We(o);
|
|
1627
952
|
if (e.sfDebug && console.log("Updated configuration after applying options:", e), !e.apiKey || !e.apiGraphqlEndpoint) {
|
|
1628
|
-
const
|
|
1629
|
-
throw console.error(
|
|
1630
|
-
}
|
|
1631
|
-
|
|
1632
|
-
e.sfDebug && console.error("[FuncSpan] Failed to initialize config loader:",
|
|
1633
|
-
}),
|
|
1634
|
-
const t = new
|
|
1635
|
-
t.setServiceUUID(e.serviceUUID), (function(
|
|
1636
|
-
function
|
|
1637
|
-
|
|
953
|
+
const n = `The required config is not provided: ${JSON.stringify(e)}`;
|
|
954
|
+
throw console.error(n), new Error(n);
|
|
955
|
+
}
|
|
956
|
+
Pe() || De(void 0, e.sfDebug).catch((n) => {
|
|
957
|
+
e.sfDebug && console.error("[FuncSpan] Failed to initialize config loader:", n);
|
|
958
|
+
}), et() || (qe(), e.sfDebug && console.log("[setupInterceptors] Worker pool patching initialized (DNS tracking enabled)"));
|
|
959
|
+
const t = new Q();
|
|
960
|
+
t.setServiceUUID(e.serviceUUID), (function(n) {
|
|
961
|
+
function i(I, p) {
|
|
962
|
+
n.setOperationName("CollectLogs"), n.doSend([p, I]);
|
|
1638
963
|
}
|
|
1639
|
-
const
|
|
1640
|
-
console.log = (...
|
|
1641
|
-
|
|
1642
|
-
}, console.error = (...
|
|
1643
|
-
|
|
1644
|
-
}, console.warn = (...
|
|
1645
|
-
|
|
1646
|
-
}, console.info = (...
|
|
1647
|
-
|
|
1648
|
-
}, d().logLevel === "DEBUG" && (console.debug = (...
|
|
1649
|
-
|
|
964
|
+
const g = console.log.bind(console), r = console.error.bind(console), c = console.warn.bind(console), a = console.info.bind(console), l = console.debug.bind(console);
|
|
965
|
+
console.log = (...I) => {
|
|
966
|
+
i("INFO", I.join(" ")), g(...I);
|
|
967
|
+
}, console.error = (...I) => {
|
|
968
|
+
i("ERROR", I.join(" ")), r(...I);
|
|
969
|
+
}, console.warn = (...I) => {
|
|
970
|
+
i("WARN", I.join(" ")), c(...I);
|
|
971
|
+
}, console.info = (...I) => {
|
|
972
|
+
i("INFO", I.join(" ")), a(...I);
|
|
973
|
+
}, d().logLevel === "DEBUG" && (console.debug = (...I) => {
|
|
974
|
+
i("DEBUG", I.join(" ")), l(...I);
|
|
1650
975
|
});
|
|
1651
|
-
})(t), (function(
|
|
1652
|
-
const
|
|
1653
|
-
new
|
|
1654
|
-
const
|
|
1655
|
-
|
|
976
|
+
})(t), (function(n = []) {
|
|
977
|
+
const i = new $e(n);
|
|
978
|
+
new ke().doSend(i.getExcludedDomains());
|
|
979
|
+
const g = new Ue(), r = new Te();
|
|
980
|
+
i.patchFetch(g, r), i.patchHttp(g, r);
|
|
1656
981
|
})(e.domainsToNotPropagateHeadersTo);
|
|
1657
|
-
const s = new
|
|
1658
|
-
s.setServiceUUID(e.serviceUUID),
|
|
982
|
+
const s = new Ke();
|
|
983
|
+
s.setServiceUUID(e.serviceUUID), Re(s), ze(), new Ee().send();
|
|
1659
984
|
}
|
|
1660
|
-
function
|
|
1661
|
-
const
|
|
1662
|
-
new
|
|
985
|
+
function gt(o, e, t, s = !1) {
|
|
986
|
+
const n = d();
|
|
987
|
+
new he(n.apiKey).identify(o, e, t, s);
|
|
1663
988
|
}
|
|
1664
|
-
function
|
|
1665
|
-
const
|
|
1666
|
-
new
|
|
989
|
+
function lt(o, e = {}, t, s = !1) {
|
|
990
|
+
const n = d();
|
|
991
|
+
new he(n.apiKey).addOrUpdateMetadata(o, e, t, s);
|
|
1667
992
|
}
|
|
1668
|
-
let
|
|
1669
|
-
function
|
|
1670
|
-
const
|
|
1671
|
-
const
|
|
1672
|
-
|
|
1673
|
-
const c = (function(
|
|
1674
|
-
const
|
|
1675
|
-
if (
|
|
1676
|
-
const b =
|
|
1677
|
-
if (b) return process.env.SF_DEBUG === "true" && console.log(`[FuncSpan] Using HTTP header override for ${
|
|
993
|
+
let j = null;
|
|
994
|
+
function dt(o, e, t, s) {
|
|
995
|
+
const n = function(...i) {
|
|
996
|
+
const g = Ce(), r = g?.sfDebug || !1;
|
|
997
|
+
r && console.log(`[FuncSpan] captureFunctionSpan wrapper called for ${t}::${e}`);
|
|
998
|
+
const c = (function(m, h) {
|
|
999
|
+
const Z = le();
|
|
1000
|
+
if (Z) {
|
|
1001
|
+
const b = de(Z);
|
|
1002
|
+
if (b) return process.env.SF_DEBUG === "true" && console.log(`[FuncSpan] Using HTTP header override for ${m}::${h}`), b;
|
|
1678
1003
|
}
|
|
1679
1004
|
try {
|
|
1680
|
-
return
|
|
1005
|
+
return xe(m, h);
|
|
1681
1006
|
} catch {
|
|
1682
1007
|
return { sample_rate: process.env.SF_FUNCSPAN_SAMPLE_RATE ? parseFloat(process.env.SF_FUNCSPAN_SAMPLE_RATE) : 1, capture_arguments: !0, capture_return_value: !0, arg_limit_mb: 1, return_limit_mb: 1, enable_sampling: !1, autocapture_all_child_functions: !1, capture_sf_veritas: !1, parse_json_strings: !1 };
|
|
1683
1008
|
}
|
|
1684
1009
|
})(t, e);
|
|
1685
|
-
if (
|
|
1686
|
-
if (c.sample_rate === 0) return
|
|
1687
|
-
|
|
1688
|
-
const
|
|
1689
|
-
|
|
1690
|
-
const
|
|
1691
|
-
let
|
|
1692
|
-
c.capture_arguments && (
|
|
1693
|
-
|
|
1694
|
-
}),
|
|
1010
|
+
if (r && console.log(`[FuncSpan] Config for ${t}::${e}:`, c), c.enable_sampling && c.sample_rate < 1 && Math.random() > c.sample_rate) return r && console.log(`[FuncSpan] Skipping ${e} due to sampling`), o.apply(this, i);
|
|
1011
|
+
if (c.sample_rate === 0) return r && console.log(`[FuncSpan] Skipping ${e} - sample_rate is 0.0`), o.apply(this, i);
|
|
1012
|
+
r && console.log(`[FuncSpan] Capturing function span for ${e}`);
|
|
1013
|
+
const a = N.getInstance(), l = a.getCurrentFunctionSpanId(), I = Ie();
|
|
1014
|
+
a.setCurrentFunctionSpanId(I);
|
|
1015
|
+
const p = process.hrtime.bigint(), C = Date.now();
|
|
1016
|
+
let u = null;
|
|
1017
|
+
c.capture_arguments && (u = {}, s.paramNames.forEach((m, h) => {
|
|
1018
|
+
h < i.length && (u[m] = i[h]);
|
|
1019
|
+
}), u && c.arg_limit_mb > 0 && (u = E(u, c.arg_limit_mb)));
|
|
1695
1020
|
try {
|
|
1696
|
-
const
|
|
1697
|
-
if (
|
|
1698
|
-
const
|
|
1699
|
-
let
|
|
1700
|
-
return c.capture_return_value && c.return_limit_mb > 0 && (
|
|
1701
|
-
}, (
|
|
1702
|
-
const
|
|
1703
|
-
throw
|
|
1021
|
+
const m = o.apply(this, i);
|
|
1022
|
+
if (m && typeof m.then == "function") return l ? a.setCurrentFunctionSpanId(l) : a.clearCurrentFunctionSpanId(), m.then((f) => {
|
|
1023
|
+
const v = process.hrtime.bigint(), U = Date.now(), T = Number(v - p);
|
|
1024
|
+
let q = null;
|
|
1025
|
+
return c.capture_return_value && c.return_limit_mb > 0 && (q = E(f, c.return_limit_mb)), K({ functionName: e, filePath: t, metadata: s, args: u, result: q, error: null, duration: U - C, durationNs: T, startTimeNs: p.toString(), async: !0, spanId: I, parentSpanId: l, pid: process.pid, threadId: J }), f;
|
|
1026
|
+
}, (f) => {
|
|
1027
|
+
const v = process.hrtime.bigint(), U = Date.now(), T = Number(v - p);
|
|
1028
|
+
throw K({ functionName: e, filePath: t, metadata: s, args: u, result: null, error: f?.message || String(f), duration: U - C, durationNs: T, startTimeNs: p.toString(), async: !0, spanId: I, parentSpanId: l, pid: process.pid, threadId: J }), f;
|
|
1704
1029
|
});
|
|
1705
|
-
const
|
|
1030
|
+
const h = process.hrtime.bigint(), Z = Date.now(), b = Number(h - p);
|
|
1706
1031
|
let y = null;
|
|
1707
|
-
return c.capture_return_value && c.return_limit_mb > 0 && (y =
|
|
1708
|
-
} catch (
|
|
1709
|
-
const
|
|
1710
|
-
throw
|
|
1032
|
+
return c.capture_return_value && c.return_limit_mb > 0 && (y = E(m, c.return_limit_mb)), K({ functionName: e, filePath: t, metadata: s, args: u, result: y, error: null, duration: Z - C, durationNs: b, startTimeNs: p.toString(), async: !1, spanId: I, parentSpanId: l, pid: process.pid, threadId: J }), l ? a.setCurrentFunctionSpanId(l) : a.clearCurrentFunctionSpanId(), m;
|
|
1033
|
+
} catch (m) {
|
|
1034
|
+
const h = process.hrtime.bigint(), Z = Date.now(), b = Number(h - p);
|
|
1035
|
+
throw K({ functionName: e, filePath: t, metadata: s, args: u, result: null, error: m?.message || String(m), duration: Z - C, durationNs: b, startTimeNs: p.toString(), async: !1, spanId: I, parentSpanId: l, pid: process.pid, threadId: J }), l ? a.setCurrentFunctionSpanId(l) : a.clearCurrentFunctionSpanId(), m;
|
|
1711
1036
|
}
|
|
1712
1037
|
};
|
|
1713
|
-
Object.defineProperty(
|
|
1714
|
-
for (const
|
|
1715
|
-
return
|
|
1038
|
+
Object.defineProperty(n, "name", { value: e, writable: !1 });
|
|
1039
|
+
for (const i in o) o.hasOwnProperty(i) && (n[i] = o[i]);
|
|
1040
|
+
return n;
|
|
1716
1041
|
}
|
|
1717
|
-
function
|
|
1718
|
-
const e =
|
|
1719
|
-
t && console.log("[FuncSpan] captureSpanData called for:", { function:
|
|
1720
|
-
const s = { functionName:
|
|
1042
|
+
function K(o) {
|
|
1043
|
+
const e = Ce(), t = e?.sfDebug || !1;
|
|
1044
|
+
t && console.log("[FuncSpan] captureSpanData called for:", { function: o.functionName, file: o.filePath, duration: `${o.duration}ms`, async: o.async, error: o.error, spanId: o.spanId });
|
|
1045
|
+
const s = { functionName: o.functionName, filePath: o.filePath, metadata: o.metadata, args: o.args, result: o.result, error: o.error, duration: o.duration, durationNs: o.durationNs, async: o.async, spanId: o.spanId, parentSpanId: o.parentSpanId };
|
|
1721
1046
|
process.env.SF_FUNCSPAN_CONSOLE_OUTPUT === "true" && console.log(`
|
|
1722
|
-
📊 Function Span:`, { function: `${
|
|
1723
|
-
const
|
|
1724
|
-
if (
|
|
1725
|
-
const
|
|
1047
|
+
📊 Function Span:`, { function: `${o.functionName} (${o.filePath}:${o.metadata.line}:${o.metadata.column})`, duration: `${o.duration.toFixed(2)}ms`, arguments: o.args, result: o.error ? `Error: ${o.error}` : o.result, spanId: o.spanId, parentSpanId: o.parentSpanId || "none" });
|
|
1048
|
+
const n = process.env.SF_FUNCSPAN_JSONL_FILE;
|
|
1049
|
+
if (n) try {
|
|
1050
|
+
const i = n === "true" || n === "1" ? "funcspans.jsonl" : n, g = Date.now(), r = process.hrtime.bigint(), c = BigInt(o.startTimeNs), a = Number(r - c) / 1e6, l = new Date(g - a).toISOString(), I = JSON.stringify({ timestamp: l, functionName: o.functionName, filePath: o.filePath, line: o.metadata.line, column: o.metadata.column, duration: o.duration, durationNs: o.durationNs, startTimeNs: o.startTimeNs, arguments: o.args, returnValue: o.error ? { error: String(o.error) } : o.result, spanId: o.spanId, parentSpanId: o.parentSpanId, async: o.async, pid: o.pid, threadId: o.threadId }) + `
|
|
1726
1051
|
`;
|
|
1727
|
-
|
|
1728
|
-
} catch (
|
|
1729
|
-
console.error("[FuncSpan] Error writing to JSONL file:",
|
|
1052
|
+
Ne(i, I, "utf-8");
|
|
1053
|
+
} catch (i) {
|
|
1054
|
+
console.error("[FuncSpan] Error writing to JSONL file:", i);
|
|
1730
1055
|
}
|
|
1731
1056
|
if (t && console.log("[FuncSpan] Sending function span to transmitter:", s), process.env.SF_FUNCSPAN_SKIP_BACKEND !== "true") try {
|
|
1732
|
-
(
|
|
1733
|
-
} catch (
|
|
1734
|
-
t && console.error("[FuncSpan] Error sending function span:",
|
|
1057
|
+
(j || (j = new ve()), j).send([s]), t && console.log("[FuncSpan] Function span sent successfully");
|
|
1058
|
+
} catch (i) {
|
|
1059
|
+
t && console.error("[FuncSpan] Error sending function span:", i);
|
|
1735
1060
|
}
|
|
1736
1061
|
}
|
|
1737
1062
|
export {
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1063
|
+
N as ContextManager,
|
|
1064
|
+
lt as addOrUpdateMetadata,
|
|
1065
|
+
dt as captureFunctionSpan,
|
|
1066
|
+
Ze as clearFuncspanOverride,
|
|
1067
|
+
$ as getCurrentFunctionSpanId,
|
|
1068
|
+
Se as getDefaultConfig,
|
|
1069
|
+
ue as getEnvConfig,
|
|
1070
|
+
le as getFuncspanOverride,
|
|
1071
|
+
xe as getGlobalConfig,
|
|
1072
|
+
gt as identify,
|
|
1073
|
+
De as initializeConfigLoader,
|
|
1074
|
+
qe as initializeWorkerPoolPatching,
|
|
1075
|
+
Pe as isConfigLoaderInitialized,
|
|
1076
|
+
et as isWorkerPoolInitialized,
|
|
1077
|
+
de as parseHeaderOverride,
|
|
1078
|
+
Ct as runWithContext,
|
|
1079
|
+
ye as setFuncspanOverride,
|
|
1080
|
+
ct as setupInterceptors,
|
|
1081
|
+
mt as transformFunctionSpans
|
|
1757
1082
|
};
|