@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.
@@ -1,257 +1,17 @@
1
- var Pe = Object.defineProperty;
2
- var ze = (n, e, t) => e in n ? Pe(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var C = (n, e, t) => ze(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { AsyncLocalStorage as pe, AsyncResource as Oe } from "async_hooks";
5
- import * as te from "fs";
6
- import { readFileSync as Re, appendFileSync as Te } from "fs";
7
- import { s as He } from "./funcSpanTransformer-sqmZLAcs.js";
8
- import { t as Xt } from "./funcSpanTransformer-sqmZLAcs.js";
9
- import { Worker as xe, threadId as T } from "worker_threads";
10
- import { createRequire as Me } from "node:module";
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 je } from "glob";
13
- const N = [];
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 nt(n) {
54
+ function He(o) {
295
55
  try {
296
- return JSON.stringify(n), !0;
56
+ return JSON.stringify(o), !0;
297
57
  } catch {
298
58
  return !1;
299
59
  }
300
60
  }
301
- class rt extends $ {
61
+ class Ye extends F {
302
62
  constructor() {
303
63
  super();
304
- C(this, "serviceIdentifier", new X());
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, r, a) {
311
- this.sendAppIdentifier(), this.send(t, s, r, a);
312
- }
313
- async send(t, s, r, a) {
314
- if (!s && !a) throw new Error('Must pass in either traits or traits_json to "add_or_update_traits"');
315
- let o = [];
316
- if (!a) {
317
- const c = (function(l) {
318
- const g = {}, u = [];
319
- if (l) for (const [I, m] of Object.entries(l)) nt(m) ? g[I] = m : u.push(I);
320
- return { traitsJson: JSON.stringify(g), excludedFields: u };
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
- a = c.traitsJson, o = c.excludedFields;
82
+ i = c.traitsJson, g = c.excludedFields;
323
83
  }
324
- const i = this.getVariables({ userId: t, traitsJson: a, excludedFields: o, override: r, library: d().packageLibraryType, version: d().version });
325
- W(this.endpoint, this.operationName, this.getQuery(), i);
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 Ke {
95
+ class he {
336
96
  constructor(e) {
337
- C(this, "metadataTransmitter");
338
- this.apiKey = e, this.metadataTransmitter = new rt();
97
+ A(this, "metadataTransmitter");
98
+ this.apiKey = e, this.metadataTransmitter = new Ye();
339
99
  }
340
- identify(e, t, s, r = !1) {
341
- t || s ? this.addOrUpdateMetadata(e, t, s, r) : this.addOrUpdateMetadata(e, {}, void 0, r);
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, r = !1) {
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, r, s);
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 Ie extends $ {
108
+ class Q extends F {
349
109
  constructor() {
350
110
  super();
351
- C(this, "serviceIdentifier", new X());
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"], r = this.getVariables({ contents: s[0], level: s[1] });
362
- W(this.endpoint, this.operationName, this.getQuery(), r);
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 B = {};
392
- class Y {
393
- constructor({ file: e, line: t, function: s, code: r, locals: a = {}, offender: o = !1, column: i }) {
394
- C(this, "file");
395
- C(this, "line");
396
- C(this, "function");
397
- C(this, "code");
398
- C(this, "locals");
399
- C(this, "offender");
400
- C(this, "column");
401
- this.file = e, this.line = t, this.function = s, this.code = r, this.locals = a, this.offender = o, this.column = i;
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 Q {
171
+ class k {
412
172
  static encode(e) {
413
- return e instanceof Y ? e.toDict() : Array.isArray(e) ? e.map((t) => Q.encode(t)) : typeof e == "object" && e !== null ? JSON.stringify(e) : e;
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(Q.encode(e), (t, s) => s instanceof Y ? s.toDict() : s);
176
+ return JSON.stringify(k.encode(e), (t, s) => s instanceof V ? s.toDict() : s);
417
177
  }
418
178
  }
419
- let F, E = 0;
420
- function ot(n) {
179
+ let B, w = 0;
180
+ function Re(o) {
421
181
  d().sfDebug && console.log("Initializing Exception Interceptor...");
422
182
  try {
423
- const i = (function() {
424
- if (F !== void 0) return F;
425
- const c = process.env || {}, l = ve(c.SF_IS_LOCAL);
426
- if (l !== void 0) return F = l;
427
- const g = (c.SF_ENV || c.NODE_ENV || "").toLowerCase();
428
- if (["local", "dev", "development"].includes(g)) return F = !0;
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((I) => !!c[I])) return F = !1;
430
- const u = (B.hostname?.() || c.HOSTNAME || "").toLowerCase();
431
- return u === "localhost" || u.endsWith(".local") || u.includes("local") ? F = !0 : F = !1;
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
- n?.setSupplementalFields?.({ isFromLocalService: i }), (async function(c) {
434
- if (Ne) return;
435
- Ne = !0;
436
- const l = process.env || {};
437
- if (ve(l.SF_IS_LOCAL) === void 0)
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(g) {
440
- const u = se("http://169.254.169.254/latest/meta-data/", {}, g), I = se("http://metadata.google.internal/computeMetadata/v1/instance/", { "Metadata-Flavor": "Google" }, g), m = se("http://169.254.169.254/metadata/instance?api-version=2021-02-01", { Metadata: "true" }, g);
441
- return (await Promise.allSettled([u, I, m])).some((p) => p.status === "fulfilled" && (p.value === "ok" || p.value === "http_error"));
442
- })(150) && F && (F = !1, c?.setSupplementalFields?.({ isFromLocalService: !1 }));
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
- })(n).catch(() => {
205
+ })(o).catch(() => {
446
206
  });
447
207
  } catch {
448
208
  }
449
- const e = new xe(new URL("data:application/javascript;base64,aW1wb3J0IHsgU2Vzc2lvbiB9IGZyb20gImluc3BlY3Rvci9wcm9taXNlcyI7CmltcG9ydCB7IHBhcmVudFBvcnQsIHdvcmtlckRhdGEgfSBmcm9tICJ3b3JrZXJfdGhyZWFkcyI7CgpnbG9iYWwuc2ZEZWJ1ZyA9IHVuZGVmaW5lZDsKZ2xvYmFsLnN0YWNrRGVwdGhMb2NhbHMgPSB1bmRlZmluZWQ7Cmdsb2JhbC5ub2RlTW9kdWxlc1RvQ29sbGVjdExvY2FsVmFyaWFibGVzT24gPSB1bmRlZmluZWQ7CgovKioKICogUHJvY2Vzc2VzIGNhbGwgZnJhbWVzIGZyb20gYW4gZXhjZXB0aW9uIGFuZCBwb3N0cyB0aGVtIHZpYSB0aGUgV29ya2Vy4oCZcyBwYXJlbnRQb3J0LgogKgogKiBAcGFyYW0gc2Vzc2lvbiAtIFRoZSBEZXZUb29scyBzZXNzaW9uIG9yIHNpbWlsYXIgb2JqZWN0IHlvdSB1c2UgdG8gcXVlcnkgZm9yIHNjcmlwdCBzb3VyY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iOwogICAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBmZXRjaCBzY3JpcHQgc291cmNlOiIsIGVycik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIC8vIEZldGNoIGxvY2FsIHZhcmlhYmxlcyBpZiB0aGVyZSdzIGFuIG9iamVjdElkCiAgICAgICAgY29uc3QgbG9jYWxzID0gbG9jYWxTY29wZT8ub2JqZWN0Py5vYmplY3RJZAogICAgICAgICAgPyBhd2FpdCBmZXRjaExvY2FsVmFyaWFibGVzKHNlc3Npb24sIGxvY2FsU2NvcGUub2JqZWN0Lm9iamVjdElkKQogICAgICAgICAgOiB7fTsKCiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGZ1bmN0aW9uOiBmdW5jdGlvbk5hbWUgfHwgIjxhbm9ueW1vdXM+IiwKICAgICAgICAgIGxvY2FscywKICAgICAgICAgIGZpbGUsCiAgICAgICAgICBsaW5lOiBsb2NhdGlvbj8ubGluZU51bWJlciB8fCAwLAogICAgICAgICAgY29kZSwKICAgICAgICB9OwogICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgY29uc29sZS5lcnJvcigiW1dvcmtlcl0gRXJyb3IgcHJvY2Vzc2luZyBjYWxsIGZyYW1lOiIsIGVycm9yKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGZ1bmN0aW9uOiAiPGVycm9yPiIsCiAgICAgICAgICBsb2NhbHM6IHt9LAogICAgICAgICAgZmlsZTogIjx1bmtub3duPiIsCiAgICAgICAgICBsaW5lOiAwLAogICAgICAgICAgY29kZTogIjxub3QgY2FwdHVyZWQ+IiwKICAgICAgICB9OwogICAgICB9CiAgICB9KSwK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JyYXkiKSB7CiAgICAgICAgICBjb25zdCBpZCA9IHByb3AudmFsdWUub2JqZWN0SWQ7CiAgICAgICAgICBhd2FpdCB1bnJvbGxBcnJheShzZXNzaW9uLCBpZCwgcHJvcC5uYW1lLCB2YXJpYWJsZXMpOwogICAgICAgIH0gZWxzZSBpZiAoCiAgICAgICAgICBwcm9wPy52YWx1ZT8ub2JqZWN0SWQgJiYKICAgICAgICAgIHByb3A/LnZhbHVlPy5jbGFzc05hbWUgPT09ICJPYmplY3QiCiAgICAgICAgKSB7CiAgICAgICAgICBjb25zdCBpZCA9IHByb3AudmFsdWUub2JqZWN0SWQ7CiAgICAgICAgICBhd2FpdCB1bnJvbGxPYmplY3Qoc2Vzc2lvbiwgaWQsIHByb3AubmFtZSwgdmFyaWFibGVzKTsKICAgICAgICB9IGVsc2UgaWYgKHByb3A/LnZhbHVlKSB7CiAgICAgICAgICB1bnJvbGxPdGhlcihwcm9wLCB2YXJpYWJsZXMpOwogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4gdmFyaWFibGVzOwogICAgfQogIH0gY2F0Y2ggKGVycikgewogICAgaWYgKGdsb2JhbC5zZkRlYnVnKSB7CiAgICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBmZXRjaCBsb2NhbCB2YXJpYWJsZXM6IiwgZXJyKTsKICAgIH0KICAgIHJldHVybiB7fTsKICB9Cn0KCnN0YXJ0RGVidWdnZXIoKS5jYXRjaCgoZXJyb3IpID0+IHsKICBpZiAoZ2xvYmFsLnNmRGVidWcpIHsKICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBzdGFydCBkZWJ1Z2dlcjoiLCBlcnJvcik7CiAgfQp9KTsKCi8vIEtlZXAgdGhlIHdvcmtlciBhbGl2ZQpzZXRJbnRlcnZhbCgoKSA9PiB7fSwgMTAwMDApOwo="), { workerData: { captureAllExceptions: !0 } });
209
+ const e = new Fe(new URL("data:application/javascript;base64,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9uIGFuZCBzY3JpcHRJZCwgZmV0Y2ggdGhlIGNvZGUgbGluZQogICAgICAgIGlmIChsb2NhdGlvbiAmJiBsb2NhdGlvbi5zY3JpcHRJZCkgewogICAgICAgICAgY29uc3Qgc2NyaXB0SWQgPSBsb2NhdGlvbi5zY3JpcHRJZDsKICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgIGNvbnN0IHsgc2NyaXB0U291cmNlIH0gPSBhd2FpdCBzZXNzaW9uLnBvc3QoCiAgICAgICAgICAgICAgIkRlYnVnZ2VyLmdldFNjcmlwdFNvdXJjZSIsCiAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgc2NyaXB0SWQsCiAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgKTsKICAgICAgICAgICAgY29uc3Qgc291cmNlTGluZXMgPSBzY3JpcHRTb3VyY2Uuc3BsaXQoIlxuIik7CiAgICAgICAgICAgIGNvZGUgPSBzb3VyY2VMaW5lc1tsb2NhdGlvbi5saW5lTnVtYmVyXSB8fCAiPG5vdCBjYXB0dXJlZD4iOwogICAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBmZXRjaCBzY3JpcHQgc291cmNlOiIsIGVycik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIC8vIEZldGNoIGxvY2FsIHZhcmlhYmxlcyBpZiB0aGVyZSdzIGFuIG9iamVjdElkCiAgICAgICAgY29uc3QgbG9jYWxzID0gbG9jYWxTY29wZT8ub2JqZWN0Py5vYmplY3RJZAogICAgICAgICAgPyBhd2FpdCBmZXRjaExvY2FsVmFyaWFibGVzKHNlc3Npb24sIGxvY2FsU2NvcGUub2JqZWN0Lm9iamVjdElkKQogICAgICAgICAgOiB7fTsKCiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIG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CB2YXJpYWJsZXMpOwogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4gdmFyaWFibGVzOwogICAgfQogIH0gY2F0Y2ggKGVycikgewogICAgaWYgKGdsb2JhbC5zZkRlYnVnKSB7CiAgICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBmZXRjaCBsb2NhbCB2YXJpYWJsZXM6IiwgZXJyKTsKICAgIH0KICAgIHJldHVybiB7fTsKICB9Cn0KCnN0YXJ0RGVidWdnZXIoKS5jYXRjaCgoZXJyb3IpID0+IHsKICBpZiAoZ2xvYmFsLnNmRGVidWcpIHsKICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBzdGFydCBkZWJ1Z2dlcjoiLCBlcnJvcik7CiAgfQp9KTsKCi8vIEtlZXAgdGhlIHdvcmtlciBhbGl2ZQpzZXRJbnRlcnZhbCgoKSA9PiB7fSwgMTAwMDApOwo="), { workerData: { captureAllExceptions: !0 } });
450
210
  let t = null;
451
211
  const s = /* @__PURE__ */ new WeakMap();
452
- e.on("message", (i) => {
453
- if (typeof i == "string" && d().sfDebug && console.log(`[Worker] ${i}`), i.readyToGetParameters && e.postMessage({ sfDebug: d().sfDebug, stackDepthLocals: d().stackDepthLocals, nodeModulesToCollectLocalVariablesOn: d().nodeModulesToCollectLocalVariablesOn }), i.type === "exception") {
454
- const { frames: c } = i, l = t;
455
- if (!l) return;
456
- const g = s.get(l), u = (function(m) {
457
- return m ? m.split(`
458
- `).slice(1).map((p) => {
459
- const h = /at (.+?) \((.+):(\d+):(\d+)\)/.exec(p) || /at (.+):(\d+):(\d+)/.exec(p);
460
- if (h) {
461
- const [, f, S, b, y] = h;
462
- return new Y({ function: f || "<anonymous>", locals: {}, file: S || "<unknown>", line: parseInt(b, 10) || 0, code: "<not captured>", column: parseInt(y) || 0 });
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 Y({ function: "<unknown>", locals: {}, file: "<unknown>", line: 0, code: "<not captured>", column: 0 });
224
+ return new V({ function: "<unknown>", locals: {}, file: "<unknown>", line: 0, code: "<not captured>", column: 0 });
465
225
  }) : [];
466
- })(l.stack), I = (function(m, p) {
467
- const h = [];
468
- let f = -1, S = -1;
469
- for (let b = 0; b < m.length; b++) {
470
- const y = it(m[b].file);
471
- if (S = b, y !== "<unknown>") {
472
- for (let A = 0; A < p.length; A++) {
473
- const Z = p[A];
474
- if (Ee(Z, y) || typeof Z.file == "string" && Z.file.includes(y)) {
475
- f = A, E = 0, d().sfDebug && console.log(`✅ Matched Frame Found: ${y} @ Debugger Frame ${A}`);
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 (f !== -1) break;
239
+ if (h !== -1) break;
480
240
  }
481
241
  }
482
- if (f === -1) return E === 10 ? (E = 0, m) : (++E, d().sfDebug && console.log(`"❌ No matching frame found. Checking once again, Attempt N ${E}"`), []);
483
- d().sfDebug && console.log(`🔄 Merging from matched index ${f} onward...`);
484
- for (let b = 0; b < p.length; b++) {
485
- const y = m[S + b], A = p[f + b];
486
- h.push(new Y({ function: A?.function || y?.function || "<anonymous>", locals: A?.locals || y?.locals || {}, file: y?.file || A?.file || "<unknown>", line: A?.line || y?.line || 0, code: A?.code || y?.code || "<not captured>" }));
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 h;
489
- })(u, c || []);
490
- if (I.length !== 0) {
248
+ return m;
249
+ })(I, c || []);
250
+ if (p.length !== 0) {
491
251
  t = null;
492
- const m = d().stackDepthCodeTraceDepth, p = m === -1 ? I : I.slice(0, m + 1), h = Math.min(p.length, u.length);
493
- for (let y = 0; y < h; y++) (async () => {
494
- const A = st(p[y].file, u[y].line, u[y].column);
495
- A && (A.content != null && (p[y].code = A.content), A.file != null && (p[y].file = A.file));
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
- n.setOperationName("CollectExceptions");
498
- const f = l.message ? `${l.name}: ${l.message}` : l.name;
499
- d().sfDebug && console.log("error message is : ", f);
500
- const S = v.getInstance(), b = s.get(l);
501
- b ? (S.setTraceIdFor(b, b), S.runWithSession(b, () => {
502
- S.setTraceId(b), n.doSend(f, p);
503
- })) : n.doSend(f, p), g ? v.getInstance().runWithSession(g, () => {
504
- n.doSend(f, p);
505
- }) : n.doSend(f, p);
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", (i) => {
509
- console.error("[Worker Error]", i);
510
- }), e.on("exit", (i) => {
511
- console.error(`[Worker] Exited with code ${i}`);
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 r = Error, a = /* @__PURE__ */ new Set();
514
- function o(...i) {
515
- const c = Reflect.construct(r, i);
516
- Reflect.setPrototypeOf(c, o.prototype);
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 g = v.getInstance().getTraceId();
519
- s.set(c, g);
278
+ const l = N.getInstance().getTraceId();
279
+ s.set(c, l);
520
280
  } catch {
521
281
  }
522
- r.captureStackTrace && r.captureStackTrace(c, o);
523
- const l = `${c.message}:${c.stack?.split(`
282
+ n.captureStackTrace && n.captureStackTrace(c, g);
283
+ const a = `${c.message}:${c.stack?.split(`
524
284
  `)[1]?.trim()}`;
525
- if (!a.has(l)) {
526
- a.add(l), t = c;
527
- const g = v.getInstance().getTraceId();
528
- s.set(c, g), e.postMessage({ type: "processException", error: c.message });
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
- o.prototype = Object.create(r.prototype, { constructor: { value: o, enumerable: !1, writable: !0, configurable: !0 } }), Object.setPrototypeOf(o, r), globalThis.Error = o;
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 Se(n) {
535
- return n = (n = (n = n.replace(/^webpack:\/\/[^\/]+\/\.?\//, "")).replace(/^.*\/pages\//, "pages/")).replace(/\.(js|ts)$/, "");
294
+ function ee(o) {
295
+ return o = (o = (o = o.replace(/^webpack:\/\/[^\/]+\/\.?\//, "")).replace(/^.*\/pages\//, "pages/")).replace(/\.(js|ts)$/, "");
536
296
  }
537
- function st(n, e, t) {
538
- const s = (function(a) {
539
- a.startsWith("at ") && (a = a.slice(3).trim());
540
- const o = a.match(/^(.*?)(:\d+)+(\.map)?$/);
541
- return o ? o[1] : a;
542
- })(n);
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 r = s + ".map";
304
+ const n = s + ".map";
545
305
  try {
546
- const a = Re(r, "utf-8");
547
- if (a) {
548
- const o = JSON.parse(a);
549
- let i = new He.SourceMapConsumer(o).originalPositionFor({ line: e, column: t });
550
- if (s && i.source) {
551
- const c = Se(s), l = o.sources.findIndex((g) => Se(g) === c);
552
- if (l === -1) d().sfDebug && console.log(`Source file "${s}" not found in the source map.`);
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 g = o.sourcesContent[l], u = o.names.join(",");
555
- if (g)
556
- return { content: g.split(`
557
- `).slice(i.line - 1, i.line + 20).join(`
558
- `), name: u, file: i.source };
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: o.sourcesContent[0], name: o.names[0], file: o.file };
322
+ return { content: g.sourcesContent[0], name: g.names[0], file: g.file };
563
323
  }
564
- } catch (a) {
565
- d().sfDebug && console.log(`Cant read/parse "${r}: Error - ".`, a);
324
+ } catch (i) {
325
+ d().sfDebug && console.log(`Cant read/parse "${n}: Error - ".`, i);
566
326
  }
567
327
  return null;
568
328
  }
569
- function it(n) {
570
- return n?.split("/").pop() || "<unknown>";
329
+ function Je(o) {
330
+ return o?.split("/").pop() || "<unknown>";
571
331
  }
572
- function Ee(n, e) {
573
- if (!n || typeof n != "object") return !1;
574
- for (const t of Object.values(n))
575
- if (typeof t == "string" && t.includes(e) || typeof t == "object" && Ee(t, e)) return !0;
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 Ne = !1;
579
- function ve(n) {
580
- if (!n) return;
581
- const e = n.toLowerCase().trim();
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 se(n, e, t) {
344
+ function D(o, e, t) {
585
345
  return new Promise((s) => {
586
346
  try {
587
- const r = new URL(n), a = (r.protocol, B).request({ method: "GET", hostname: r.hostname, port: r.port || (r.protocol === "https:" ? 443 : 80), path: r.pathname + (r.search || ""), headers: e }, (o) => {
588
- o.resume(), o.statusCode && o.statusCode >= 200 && o.statusCode < 400 ? s("ok") : s("http_error");
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
- a.on("error", () => s("error")), a.setTimeout(t, () => {
591
- a.destroy(), s("timeout");
592
- }), a.end();
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 at extends $ {
358
+ class Ke extends F {
599
359
  constructor() {
600
360
  super();
601
- C(this, "serviceIdentifier", new X());
602
- C(this, "supplementalFields", {});
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 r = JSON.stringify(Q.encode(s)), a = this.normalizedSupplementalForGraphQL(), o = this.getVariables({ exceptionMessage: t, traceJson: r, reentrancyGuardPreactive: !1, library: d().packageLibraryType, version: d().version, ...a });
621
- W(this.endpoint, this.operationName, this.getQuery(), o);
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 Ge = "getting request source code";
656
- var M = ((n) => (n.UNKNOWN = "unknown", n.ANONYMOUS = "anonymous", n.NOT_CAPTURED = "not captured", n))(M || {});
657
- const ie = "http:", ae = "https:";
658
- function ke() {
659
- return { capture_arguments: U(process.env.SF_FUNCSPAN_CAPTURE_ARGUMENTS, !0), capture_return_value: U(process.env.SF_FUNCSPAN_CAPTURE_RETURN_VALUE, !0), arg_limit_mb: parseInt(process.env.SF_FUNCSPAN_ARG_LIMIT_MB || "1", 10), return_limit_mb: parseInt(process.env.SF_FUNCSPAN_RETURN_LIMIT_MB || "1", 10), autocapture_all_child_functions: U(process.env.SF_FUNCSPAN_AUTOCAPTURE_ALL_CHILD_FUNCTIONS, !1), sample_rate: parseFloat(process.env.SF_FUNCSPAN_SAMPLE_RATE || "1.0"), enable_sampling: U(process.env.SF_FUNCSPAN_ENABLE_SAMPLING, !1), capture_sf_veritas: U(process.env.SF_FUNCSPAN_CAPTURE_SF_VERITAS, !1), parse_json_strings: U(process.env.SF_FUNCSPAN_PARSE_JSON_STRINGS, !1) };
660
- }
661
- function Ut() {
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
- Ze = !0;
423
+ se = !0;
707
424
  try {
708
- e = gt("node:http"), n && console.log("[patchNodeHttpInbound] node:http required successfully.");
709
- } catch (r) {
710
- return void console.error("Failed to require node:http:", r);
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 (n && console.log("[patchNodeHttpInbound] http.Server.prototype not found."));
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 }), n && console.log("[patchNodeHttpInbound] Patching http.Server.prototype.emit."), t.emit = function(r, ...a) {
715
- if (r !== "request") return n && console.log(`[patchNodeHttpInbound] Passing through event: ${r}`), s.call(this, r, ...a);
716
- const o = a[0], i = a[1], c = (function(m) {
717
- const p = {};
718
- if (!m) return p;
719
- for (const [h, f] of Object.entries(m)) f != null && (Array.isArray(f) ? p[h.toLowerCase()] = f.join(", ") : p[h.toLowerCase()] = String(f));
720
- return p;
721
- })(o?.headers), l = c["x-sf3-rid"], g = c["x-sf3-functionspancaptureoverride"];
722
- n && (console.log("[patchNodeHttpInbound] Intercepted request event."), console.log("[patchNodeHttpInbound] Inbound headers:", c), console.log("[patchNodeHttpInbound] Trace header:", l), console.log("[patchNodeHttpInbound] FuncSpan override header:", g));
723
- const u = v.getInstance();
724
- u.setTraceId(l);
725
- const I = u.getTraceId();
726
- return n && console.log("[patchNodeHttpInbound] Context traceId set:", I), u.runWith({ inboundHeaders: c, ...l ? { traceId: l } : {} }, () => {
727
- l && u.setTraceId(l), g && (ct(g), n && console.log("[patchNodeHttpInbound] FuncSpan override set:", g)), n && console.log("[patchNodeHttpInbound] Running request handler in context.");
728
- const m = () => {
729
- n && console.log("[patchNodeHttpInbound] Response finished/closed for traceId:", u.getTraceId()), g && (lt(), n && console.log("[patchNodeHttpInbound] FuncSpan override cleared"));
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 i.on("finish", m), i.on("close", m), s.call(this, r, o, i);
448
+ return r.on("finish", C), r.on("close", C), s.call(this, n, g, r);
732
449
  });
733
- }) : n && console.log("[patchNodeHttpInbound] Already patched, skipping.");
450
+ }) : o && console.log("[patchNodeHttpInbound] Already patched, skipping.");
734
451
  }
735
- class ut extends Ie {
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 pt extends $ {
476
+ class Ue extends F {
760
477
  constructor() {
761
478
  super();
762
- C(this, "serviceIdentifier", new X());
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: r, line: a, entrypoint: o, retryWithoutTraceId: i } = t, c = this.getVariables({ name: s, column: r, line: a, entrypoint: o, retryWithoutTraceId: i });
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 It extends $ {
520
+ class Te extends F {
804
521
  constructor() {
805
522
  super();
806
- C(this, "serviceIdentifier", new X());
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 ce = [400, 403];
831
- class Ct {
547
+ const O = [400, 403];
548
+ class $e {
832
549
  constructor(e = []) {
833
- C(this, "HEADER_TRACING", "X-Sf3-Rid");
834
- C(this, "HEADER_LOG_GUARD", "reentrancy_guard_logging_preactive");
835
- C(this, "HEADER_PRINT_GUARD", "reentrancy_guard_print_preactive");
836
- C(this, "HEADER_EXCEPTION_GUARD", "reentrancy_guard_exception_preactive");
837
- C(this, "contextManager");
838
- this.contextManager = v.getInstance(), e?.forEach((t) => {
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 a = t.toLowerCase();
847
- for (const [o, i] of Object.entries(e)) if (o.toLowerCase() === a) {
848
- s = i;
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 r = s.split("/").filter(Boolean);
854
- return r.length < 3 ? {} : { sessionId: r[0], pageVisitId: r[1], requestId: r[r.length - 1] };
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, r, a] = t;
860
- return { filePath: s, line: parseInt(r, 10), column: parseInt(a, 10) };
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 r = { source: e, line: t, column: s, name: null };
864
- const a = e + ".map";
580
+ let n = { source: e, line: t, column: s, name: null };
581
+ const i = e + ".map";
865
582
  try {
866
- const o = JSON.parse(Re(a, "utf-8"));
867
- let i = (await new He.SourceMapConsumer(o)).originalPositionFor({ line: t, column: s });
868
- i.source && (r = i);
869
- } catch (o) {
870
- d().sfDebug && console.error(`Could not read/parse map file at ${a}:`, o);
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: r };
589
+ return { originalPos: n };
873
590
  }
874
591
  captureFirstUserLines(e, t = 10, s = !1) {
875
- const r = d().sfDebug ? 10 : t, a = Error.stackTraceLimit;
876
- Error.stackTraceLimit = Math.max(a, r);
877
- const o = new Error(Ge);
878
- Ge in Error && Error.captureStackTrace(o, this.captureFirstUserLines);
879
- const i = o.stack || "";
880
- Error.stackTraceLimit = a;
881
- const c = i.split(`
882
- `).slice(1), l = [];
883
- for (const g of c)
884
- if (!(g.includes("node:internal") || g.includes("internal/modules") || g.includes("internal/process") || g.includes("node_modules") || g.includes(".next/server/chunks") || g.includes("RequestInterceptor") || g.includes("contextManager") || g.includes("setupConfig")) && (l.push(g.trim()), l.length >= t)) break;
885
- for (const g of l) {
886
- const u = this.parseStackFrame(g);
887
- u ? (async () => {
888
- const { originalPos: I } = await this.getOriginalPosition(u.filePath, u.line, u.column);
889
- if (I) {
890
- d().sfDebug && console.log("[RequestInterceptor] First user code line:", I);
891
- const m = { line: I.line?.toString() || M.UNKNOWN, column: I.column?.toString() || M.NOT_CAPTURED, name: I.name || M.NOT_CAPTURED, entrypoint: I.source, retryWithoutTraceId: s };
892
- e.doSend(m);
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:", g);
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 !Ue.some((t) => new RegExp(`^${t.replace(/\*/g, ".*")}$`).test(e));
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, r = this.shouldPropagateHeaders(s);
905
- return r ? this.addTracingHeader(e, t) : d().sfDebug && console.error(`[RequestInterceptor] Excluded domain: ${s}`), r;
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 = Je();
625
+ const s = le();
909
626
  if (s) {
910
- const i = Ye(s);
911
- if (i && i.sample_rate === 0) return void (d().sfDebug && console.log(`[RequestInterceptor] Function span tracking disabled (sample_rate=0), skipping tracing header for ${t}`));
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 r = this.contextManager.getOrSetSfTraceId(), a = this.contextManager.getOrSetPageVisitUUID(), o = w();
914
- e.set(this.HEADER_TRACING, `${r}/${a}/${o}`), d().sfDebug && console.log(`[RequestInterceptor] Added tracing header for ${t}`);
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 (r, a) => {
919
- const o = new Headers(a?.headers);
920
- if (o.get(this.HEADER_LOG_GUARD) === "true" || o.get(this.HEADER_PRINT_GUARD) === "true" || o.get(this.HEADER_EXCEPTION_GUARD) === "true") return s(r, a);
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 i = Date.now();
639
+ const r = Date.now();
923
640
  let c;
924
- typeof r == "string" || r instanceof URL ? c = r.toString() : r instanceof Request ? (c = r.url, r.headers.forEach((p, h) => {
925
- o.set(h, p);
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 l = new URL(c).hostname, g = new Headers(o), u = this.addTracingHeaders(o, c), I = { ...a, headers: o };
928
- let m;
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 p = !1;
931
- this.addTracingHeaders(g, c), m = await s(c, I), u && ce.includes(m.status) ? (m = await s(c, { ...a, headers: g }), p = !0, this.captureFirstUserLines(e, 10, p)) : this.contextManager.addSupportedDomains(l);
932
- const h = Date.now();
933
- d().sfDebug && console.log(`[RequestInterceptor] Fetch completed: ${c}, Status: ${m.status}, Duration: ${h - i}ms`);
934
- const { sessionId: f, pageVisitId: S, requestId: b } = this.extractIdsFromTraceHeader(o);
935
- return t.doSend({ apiKey: d().apiKey, requestId: b, pageVisitId: S, recordingSessionId: f, serviceUuid: d().serviceUUID, timestampStart: i.toString(), timestampEnd: h.toString(), responseCode: m.status, success: !0, error: null, url: c, method: I.method || "GET", retryWithoutTraceId: p, parentSpanId: oe() }), m;
936
- } catch (p) {
937
- const h = Date.now();
938
- d().sfDebug && console.error(`[RequestInterceptor] Fetch failed: ${c}, Error: ${p}, Duration: ${h - i}ms`);
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..."), !B || typeof B.request != "function") return void (d().sfDebug && console.log("[RequestInterceptor] HTTP/HTTPS not available."));
944
- const s = B.request.bind(B), r = B.request.bind(B);
945
- B.request = function(a, o) {
946
- let i;
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 a == "string") {
949
- const l = new URL(a);
950
- i = { protocol: l.protocol || ie, hostname: l.hostname, path: l.pathname + l.search, headers: {} };
951
- } else a instanceof URL ? i = { protocol: a.protocol || ie, hostname: a.hostname, path: a.pathname + a.search, headers: {} } : (i = { ...a }, i.protocol || (i.protocol = ie));
952
- if (i.headers) {
953
- const l = `${i.protocol}//${i.hostname}`;
954
- this.addTracingHeaders(i.headers, l), this.captureFirstUserLines(e);
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 (l) {
957
- throw d().sfDebug && console.error("[RequestInterceptor] Error while processing HTTP request options:", l), l;
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(i, (l) => {
961
- const g = `${i.protocol}//${i.hostname}`;
962
- if (i.headers && this.shouldPropagateHeaders(new URL(g).hostname) && ce.includes(l.statusCode || 0)) {
963
- i.hostname;
964
- const p = { ...i, headers: { ...i.headers } };
965
- delete p.headers[this.HEADER_TRACING], s(p, o), c = !0, this.captureFirstUserLines(e, 10, c);
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: u, pageVisitId: I, requestId: m } = this.extractIdsFromTraceHeader(i.headers);
968
- t.doSend({ apiKey: d().apiKey, requestId: m, pageVisitId: I, recordingSessionId: u, serviceUuid: d().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: l.statusCode || 0, success: !!l.statusCode && l.statusCode < 400, error: null, url: g, method: i.method || "GET", retryWithoutTraceId: c, parentSpanId: oe() }), o?.(l);
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
- }, B.request = function(a, o) {
971
- let i;
687
+ }, S.request = function(i, g) {
688
+ let r;
972
689
  try {
973
- if (typeof a == "string") {
974
- const l = new URL(a);
975
- i = { protocol: l.protocol || ae, hostname: l.hostname, path: l.pathname + l.search, headers: {} };
976
- } else a instanceof URL ? i = { protocol: a.protocol || ae, hostname: a.hostname, path: a.pathname + a.search, headers: {} } : (i = { ...a }, i.protocol || (i.protocol = ae));
977
- if (i.headers) {
978
- const l = `${i.protocol}//${i.hostname}`;
979
- this.addTracingHeaders(i.headers, l);
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 (l) {
982
- throw d().sfDebug && console.error("[RequestInterceptor] Error while processing HTTPS request options:", l), l;
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(i, (l) => {
986
- const g = `${i.protocol}//${i.hostname}`;
987
- if (i.headers && this.shouldPropagateHeaders(new URL(g).hostname) && ce.includes(l.statusCode || 0)) {
988
- const p = { ...i, headers: { ...i.headers } };
989
- delete p.headers[this.HEADER_TRACING], r(p, o), c = !0, this.captureFirstUserLines(e, 10, c);
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: u, pageVisitId: I, requestId: m } = this.extractIdsFromTraceHeader(i.headers);
992
- t.doSend({ apiKey: d().apiKey, requestId: m, pageVisitId: I, recordingSessionId: u, serviceUuid: d().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: l.statusCode || 0, success: !!l.statusCode && l.statusCode < 400, error: null, url: g, method: i.method || "GET", retryWithoutTraceId: c, parentSpanId: oe() }), o?.(l);
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 mt extends Ie {
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 ht {
756
+ class Le {
1040
757
  constructor(e = [process.cwd()], t = !1) {
1041
- C(this, "rootPaths");
1042
- C(this, "fileConfigs", /* @__PURE__ */ new Map());
1043
- C(this, "functionConfigs", /* @__PURE__ */ new Map());
1044
- C(this, "directoryConfigs", /* @__PURE__ */ new Map());
1045
- C(this, "hasSailfishFiles", !1);
1046
- C(this, "debug");
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) te.existsSync(t) ? await this._walkDirectory(t, e) : this.debug && console.log(`[FuncSpan ConfigLoader] Root path does not exist: ${t}`);
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 ? ke() : { 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 }, r = this._getDirectoryConfig(e), a = G.normalize(e), o = this.fileConfigs.get(a) || {};
1059
- let i = {};
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(a);
1062
- c && (i = c.get(t) || {});
778
+ const c = this.functionConfigs.get(i);
779
+ c && (r = c.get(t) || {});
1063
780
  }
1064
- return z(s, r, o, i);
781
+ return R(s, n, g, r);
1065
782
  }
1066
783
  async _walkDirectory(e, t) {
1067
784
  try {
1068
- const s = te.readdirSync(e, { withFileTypes: !0 });
1069
- for (const r of s) {
1070
- const a = G.join(e, r.name);
1071
- r.isFile() && r.name === ".sailfish" ? t.push(a) : r.name === "node_modules" || r.isDirectory() && r.name.startsWith(".") && r.name !== ".sailfish" || r.isDirectory() && await this._walkDirectory(a, t);
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 = te.readFileSync(e, "utf-8"), s = G.dirname(e);
1080
- let r = null;
796
+ const t = L.readFileSync(e, "utf-8"), s = G.dirname(e);
797
+ let n = null;
1081
798
  try {
1082
- r = JSON.parse(t);
799
+ n = JSON.parse(t);
1083
800
  } catch {
1084
801
  try {
1085
- r = require("js-yaml").load(t);
1086
- } catch (a) {
1087
- return void (this.debug && console.error(`[FuncSpan ConfigLoader] Failed to parse ${e} as JSON or YAML:`, a));
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 (!r) return;
1091
- r.default && this.directoryConfigs.set(s, r.default), r.files && await this._expandFileGlobs(s, r.files, r.default || {}), r.functions && this._storeFunctionConfigs(s, r.functions, r.default || {}), this.debug && (console.log(`[FuncSpan ConfigLoader] Loaded config from ${e}`), console.log(`[FuncSpan ConfigLoader] Directory: ${s}`), console.log(`[FuncSpan ConfigLoader] Has default: ${!!r.default}`), console.log(`[FuncSpan ConfigLoader] File patterns: ${Object.keys(r.files || {}).length}`), console.log(`[FuncSpan ConfigLoader] Functions: ${Object.keys(r.functions || {}).length}`));
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 [r, a] of Object.entries(t)) try {
1098
- const o = G.join(e, r), i = await je(o, { absolute: !0, nodir: !0, ignore: ["**/node_modules/**", "**/.git/**"] });
1099
- this.debug && console.log(`[FuncSpan ConfigLoader] Pattern '${r}' matched ${i.length} files`);
1100
- for (const c of i) {
1101
- const l = G.normalize(c), g = z(s, a);
1102
- this.fileConfigs.set(l, g), this.debug && i.length <= 5 && console.log(`[FuncSpan ConfigLoader] - ${c}`);
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 (o) {
1105
- this.debug && console.error(`[FuncSpan ConfigLoader] Error expanding glob '${r}':`, o);
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 [r, a] of Object.entries(t)) {
1110
- const o = r.split("::");
1111
- if (o.length !== 2) {
1112
- this.debug && console.warn(`[FuncSpan ConfigLoader] Invalid function pattern '${r}' (expected format: 'file.ts::functionName')`);
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 [i, c] = o, l = G.normalize(G.join(e, i));
1116
- this.functionConfigs.has(l) || this.functionConfigs.set(l, /* @__PURE__ */ new Map());
1117
- const g = this.functionConfigs.get(l), u = z(s, a);
1118
- g.set(c, u), this.debug && console.log(`[FuncSpan ConfigLoader] Function config: ${l}::${c}`);
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 r = this.directoryConfigs.get(t);
1128
- r && s.unshift(r), t = G.dirname(t);
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 > 0 ? J(r, s) : r;
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 le = null;
1480
- function j(n, e, t, s, r) {
1481
- const a = H(), o = a?.sfDebug || !1;
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 St(n, e, t, s, r) {
1501
- const a = H(), o = a?.sfDebug || !1;
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 de(n) {
1518
- const e = H(), t = e?.sfDebug || !1;
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 Nt = ["readFile", "writeFile", "appendFile", "readdir", "stat", "lstat", "fstat", "access", "open", "close", "read", "write", "chmod", "mkdir", "rmdir", "unlink", "rename"], We = ["lookup", "resolve", "resolve4", "resolve6", "resolveAny", "resolveMx", "resolveNs", "resolveTxt", "reverse"], vt = ["pbkdf2", "randomBytes", "scrypt", "generateKeyPair"], Gt = ["gzip", "gunzip", "deflate", "inflate", "deflateRaw", "inflateRaw", "brotliCompress", "brotliDecompress"];
1536
- let Fe = !1, _e = !1;
1537
- function Zt() {
1538
- if (!_e) try {
1539
- const n = require("node:dns");
1540
- if (n.__sf_worker_pool_patched__) return;
1541
- Object.defineProperty(n, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
1542
- for (const e of We) if (typeof n[e] == "function") {
1543
- const t = n[e];
1544
- n[e] = function(...s) {
1545
- const r = s[0];
1546
- return typeof r == "string" && (r === "localhost" || r === "127.0.0.1") ? t.apply(this, s) : typeof s[s.length - 1] == "function" ? j("dns", e, t, s, this) : t.apply(this, s);
1547
- }, Object.defineProperty(n[e], "name", { value: e, writable: !1 });
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 We) if (typeof e.promises[t] == "function") {
878
+ for (const t of ie) if (typeof e.promises[t] == "function") {
1554
879
  const s = e.promises[t];
1555
- e.promises[t] = function(...r) {
1556
- const a = r[0];
1557
- return typeof a != "string" || a !== "localhost" && a !== "127.0.0.1" ? St("dns", t, s, r, this) : s.apply(this, r);
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
- })(n), _e = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] dns module patched successfully");
1563
- } catch (n) {
1564
- console.error("[WorkerPool] Error patching dns module:", n);
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 we = !1, Ve = !1, ue = !1;
1568
- function Bt() {
1569
- if (ue) return;
1570
- const n = process.env.SF_DEBUG === "true";
1571
- n && console.log("[WorkerPool] Initializing worker pool patching..."), O("fs") && (n && console.log("[WorkerPool] Patching fs module..."), (function() {
1572
- if (!Fe) try {
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 Nt) if (typeof e[t] == "function") {
901
+ for (const t of Oe) if (typeof e[t] == "function") {
1577
902
  const s = e[t];
1578
- e[t] = function(...r) {
1579
- return typeof r[r.length - 1] == "function" ? j("fs", t, s, r, this) : s.apply(this, r);
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
- Fe = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] fs module patched successfully");
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
- })()), O("dns") && (n && console.log("[WorkerPool] Patching dns module..."), Zt()), O("crypto") && (n && console.log("[WorkerPool] Patching crypto module..."), (function() {
1587
- if (!we) try {
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 vt) if (typeof e[t] == "function") {
916
+ for (const t of je) if (typeof e[t] == "function") {
1592
917
  const s = e[t];
1593
- e[t] = function(...r) {
1594
- return typeof r[r.length - 1] == "function" ? j("crypto", t, s, r, this) : s.apply(this, r);
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
- we = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] crypto module patched successfully");
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
- })()), O("zlib") && (n && console.log("[WorkerPool] Patching zlib module..."), (function() {
1602
- if (!Ve) try {
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 Gt) if (typeof e[t] == "function") {
931
+ for (const t of Me) if (typeof e[t] == "function") {
1607
932
  const s = e[t];
1608
- e[t] = function(...r) {
1609
- return typeof r[r.length - 1] == "function" ? j("zlib", t, s, r, this) : s.apply(this, r);
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
- Ve = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] zlib module patched successfully");
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
- })()), ue = !0, n && console.log("[WorkerPool] Worker pool patching initialized");
941
+ })()), M = !0, o && console.log("[WorkerPool] Worker pool patching initialized");
1617
942
  }
1618
- function Wt() {
1619
- return ue;
943
+ function et() {
944
+ return M;
1620
945
  }
1621
- function Kt(n) {
1622
- if (!n || !n.apiKey) {
1623
- const r = `The required API Key is not provided: ${JSON.stringify(n)}`;
1624
- console.error(r);
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 } = et(n);
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 r = `The required config is not provided: ${JSON.stringify(e)}`;
1629
- throw console.error(r), new Error(r);
1630
- }
1631
- At() || ft(void 0, e.sfDebug).catch((r) => {
1632
- e.sfDebug && console.error("[FuncSpan] Failed to initialize config loader:", r);
1633
- }), Wt() || (Bt(), e.sfDebug && console.log("[setupInterceptors] Worker pool patching initialized (DNS tracking enabled)"));
1634
- const t = new Ie();
1635
- t.setServiceUUID(e.serviceUUID), (function(r) {
1636
- function a(u, I) {
1637
- r.setOperationName("CollectLogs"), r.doSend([I, u]);
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 o = console.log.bind(console), i = console.error.bind(console), c = console.warn.bind(console), l = console.info.bind(console), g = console.debug.bind(console);
1640
- console.log = (...u) => {
1641
- a("INFO", u.join(" ")), o(...u);
1642
- }, console.error = (...u) => {
1643
- a("ERROR", u.join(" ")), i(...u);
1644
- }, console.warn = (...u) => {
1645
- a("WARN", u.join(" ")), c(...u);
1646
- }, console.info = (...u) => {
1647
- a("INFO", u.join(" ")), l(...u);
1648
- }, d().logLevel === "DEBUG" && (console.debug = (...u) => {
1649
- a("DEBUG", u.join(" ")), g(...u);
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(r = []) {
1652
- const a = new Ct(r);
1653
- new ut().doSend(a.getExcludedDomains());
1654
- const o = new pt(), i = new It();
1655
- a.patchFetch(o, i), a.patchHttp(o, i);
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 at();
1658
- s.setServiceUUID(e.serviceUUID), ot(s), dt(), new mt().send();
982
+ const s = new Ke();
983
+ s.setServiceUUID(e.serviceUUID), Re(s), ze(), new Ee().send();
1659
984
  }
1660
- function Et(n, e, t, s = !1) {
1661
- const r = d();
1662
- new Ke(r.apiKey).identify(n, e, t, s);
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 kt(n, e = {}, t, s = !1) {
1665
- const r = d();
1666
- new Ke(r.apiKey).addOrUpdateMetadata(n, e, t, s);
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 ge = null;
1669
- function Yt(n, e, t, s) {
1670
- const r = function(...a) {
1671
- const o = H(), i = o?.sfDebug || !1;
1672
- i && console.log(`[FuncSpan] captureFunctionSpan wrapper called for ${t}::${e}`);
1673
- const c = (function(h, f) {
1674
- const S = Je();
1675
- if (S) {
1676
- const b = Ye(S);
1677
- if (b) return process.env.SF_DEBUG === "true" && console.log(`[FuncSpan] Using HTTP header override for ${h}::${f}`), b;
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 bt(h, f);
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 (i && console.log(`[FuncSpan] Config for ${t}::${e}:`, c), c.enable_sampling && c.sample_rate < 1 && Math.random() > c.sample_rate) return i && console.log(`[FuncSpan] Skipping ${e} due to sampling`), n.apply(this, a);
1686
- if (c.sample_rate === 0) return i && console.log(`[FuncSpan] Skipping ${e} - sample_rate is 0.0`), n.apply(this, a);
1687
- i && console.log(`[FuncSpan] Capturing function span for ${e}`);
1688
- const l = v.getInstance(), g = l.getCurrentFunctionSpanId(), u = w();
1689
- l.setCurrentFunctionSpanId(u);
1690
- const I = process.hrtime.bigint(), m = Date.now();
1691
- let p = null;
1692
- c.capture_arguments && (p = {}, s.paramNames.forEach((h, f) => {
1693
- f < a.length && (p[h] = a[f]);
1694
- }), p && c.arg_limit_mb > 0 && (p = J(p, c.arg_limit_mb)));
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 h = n.apply(this, a);
1697
- if (h && typeof h.then == "function") return g ? l.setCurrentFunctionSpanId(g) : l.clearCurrentFunctionSpanId(), h.then((A) => {
1698
- const Z = process.hrtime.bigint(), q = Date.now(), ee = Number(Z - I);
1699
- let he = null;
1700
- return c.capture_return_value && c.return_limit_mb > 0 && (he = J(A, c.return_limit_mb)), x({ functionName: e, filePath: t, metadata: s, args: p, result: he, error: null, duration: q - m, durationNs: ee, startTimeNs: I.toString(), async: !0, spanId: u, parentSpanId: g, pid: process.pid, threadId: T }), A;
1701
- }, (A) => {
1702
- const Z = process.hrtime.bigint(), q = Date.now(), ee = Number(Z - I);
1703
- throw x({ functionName: e, filePath: t, metadata: s, args: p, result: null, error: A?.message || String(A), duration: q - m, durationNs: ee, startTimeNs: I.toString(), async: !0, spanId: u, parentSpanId: g, pid: process.pid, threadId: T }), A;
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 f = process.hrtime.bigint(), S = Date.now(), b = Number(f - I);
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 = J(h, c.return_limit_mb)), x({ functionName: e, filePath: t, metadata: s, args: p, result: y, error: null, duration: S - m, durationNs: b, startTimeNs: I.toString(), async: !1, spanId: u, parentSpanId: g, pid: process.pid, threadId: T }), g ? l.setCurrentFunctionSpanId(g) : l.clearCurrentFunctionSpanId(), h;
1708
- } catch (h) {
1709
- const f = process.hrtime.bigint(), S = Date.now(), b = Number(f - I);
1710
- throw x({ functionName: e, filePath: t, metadata: s, args: p, result: null, error: h?.message || String(h), duration: S - m, durationNs: b, startTimeNs: I.toString(), async: !1, spanId: u, parentSpanId: g, pid: process.pid, threadId: T }), g ? l.setCurrentFunctionSpanId(g) : l.clearCurrentFunctionSpanId(), h;
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(r, "name", { value: e, writable: !1 });
1714
- for (const a in n) n.hasOwnProperty(a) && (r[a] = n[a]);
1715
- return r;
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 x(n) {
1718
- const e = H(), t = e?.sfDebug || !1;
1719
- t && console.log("[FuncSpan] captureSpanData called for:", { function: n.functionName, file: n.filePath, duration: `${n.duration}ms`, async: n.async, error: n.error, spanId: n.spanId });
1720
- const s = { functionName: n.functionName, filePath: n.filePath, metadata: n.metadata, args: n.args, result: n.result, error: n.error, duration: n.duration, durationNs: n.durationNs, async: n.async, spanId: n.spanId, parentSpanId: n.parentSpanId };
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: `${n.functionName} (${n.filePath}:${n.metadata.line}:${n.metadata.column})`, duration: `${n.duration.toFixed(2)}ms`, arguments: n.args, result: n.error ? `Error: ${n.error}` : n.result, spanId: n.spanId, parentSpanId: n.parentSpanId || "none" });
1723
- const r = process.env.SF_FUNCSPAN_JSONL_FILE;
1724
- if (r) try {
1725
- const a = r === "true" || r === "1" ? "funcspans.jsonl" : r, o = Date.now(), i = process.hrtime.bigint(), c = BigInt(n.startTimeNs), l = Number(i - c) / 1e6, g = new Date(o - l).toISOString(), u = JSON.stringify({ timestamp: g, functionName: n.functionName, filePath: n.filePath, line: n.metadata.line, column: n.metadata.column, 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, async: n.async, pid: n.pid, threadId: n.threadId }) + `
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
- Te(a, u, "utf-8");
1728
- } catch (a) {
1729
- console.error("[FuncSpan] Error writing to JSONL file:", a);
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
- (ge || (ge = new Le()), ge).send([s]), t && console.log("[FuncSpan] Function span sent successfully");
1733
- } catch (a) {
1734
- t && console.error("[FuncSpan] Error sending function span:", a);
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
- v as ContextManager,
1739
- kt as addOrUpdateMetadata,
1740
- Yt as captureFunctionSpan,
1741
- lt as clearFuncspanOverride,
1742
- oe as getCurrentFunctionSpanId,
1743
- Ut as getDefaultConfig,
1744
- ke as getEnvConfig,
1745
- Je as getFuncspanOverride,
1746
- bt as getGlobalConfig,
1747
- Et as identify,
1748
- ft as initializeConfigLoader,
1749
- Bt as initializeWorkerPoolPatching,
1750
- At as isConfigLoaderInitialized,
1751
- Wt as isWorkerPoolInitialized,
1752
- Ye as parseHeaderOverride,
1753
- $t as runWithContext,
1754
- ct as setFuncspanOverride,
1755
- Kt as setupInterceptors,
1756
- Xt as transformFunctionSpans
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
  };