@sailfish-ai/sf-veritas 0.2.5 → 0.2.7

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";
11
- 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 $ {
1
+ var Ze = Object.defineProperty;
2
+ var Se = (n, e, t) => e in n ? Ze(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var A = (n, e, t) => Se(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import { B as F, g as d, n as v, C as N, f as Ge, D as Be, a as ue, p as pe, v as Ce, b as T, d as me, e as ve, m as R, c as _, h as We, i as X, j as Ne, k as he, t as $, F as Fe } from "./workerPoolSpanCapture-D0-0Z0Jw.js";
5
+ import { l as bt, r as At, s as ft } from "./workerPoolSpanCapture-D0-0Z0Jw.js";
6
+ import * as L from "fs";
7
+ import { readFileSync as be, appendFileSync as we } from "fs";
8
+ import { s as Ae } from "./funcSpanTransformer-BLhIRZqX.js";
9
+ import { t as Zt } from "./funcSpanTransformer-BLhIRZqX.js";
10
+ import { Worker as Ve, threadId as J } from "worker_threads";
11
+ import { createRequire as He } from "node:module";
12
+ import * as S from "path";
13
+ import { glob as Ye } from "glob";
14
+ class Y extends F {
255
15
  constructor() {
256
16
  super(), this.setOperationName("IdentifyServiceDetails");
257
17
  }
@@ -288,41 +48,41 @@ class X extends $ {
288
48
  )
289
49
  }
290
50
  `, t = this.getVariables({ serviceIdentifier: d().serviceIdentifier, serviceVersion: d().serviceVersion, library: d().packageLibraryType, version: d().version, serviceAdditionalMetadata: d().serviceAdditionalMetadata, gitSha: d().gitSha || "" });
291
- W(this.endpoint, this.operationName, e, t);
51
+ v(this.endpoint, this.operationName, e, t);
292
52
  }
293
53
  }
294
- function nt(n) {
54
+ function Re(n) {
295
55
  try {
296
56
  return JSON.stringify(n), !0;
297
57
  } catch {
298
58
  return !1;
299
59
  }
300
60
  }
301
- class rt extends $ {
61
+ class Xe 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, o, i) {
71
+ this.sendAppIdentifier(), this.send(t, s, o, i);
72
+ }
73
+ async send(t, s, o, 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)) Re(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: o, library: d().packageLibraryType, version: d().version });
85
+ v(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 fe {
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 Xe();
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, o = !1) {
101
+ t || s ? this.addOrUpdateMetadata(e, t, s, o) : this.addOrUpdateMetadata(e, {}, void 0, o);
342
102
  }
343
- addOrUpdateMetadata(e, t = {}, s, r = !1) {
103
+ addOrUpdateMetadata(e, t = {}, s, o = !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, o, s);
346
106
  }
347
107
  }
348
- class Ie extends $ {
108
+ class ee 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"], o = this.getVariables({ contents: s[0], level: s[1] });
122
+ v(this.endpoint, this.operationName, this.getQuery(), o);
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 G = {};
152
+ class V {
153
+ constructor({ file: e, line: t, function: s, code: o, 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 = o, 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 z {
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) => z.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(z.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 Je(n) {
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 = se(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 = (G.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
+ n?.setSupplementalFields?.({ isFromLocalService: r }), (async function(c) {
194
+ if (oe) return;
195
+ oe = !0;
196
+ const a = process.env || {};
197
+ if (se(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
205
  })(n).catch(() => {
446
206
  });
447
207
  } catch {
448
208
  }
449
- const e = new xe(new URL("data:application/javascript;base64,aW1wb3J0IHsgU2Vzc2lvbiB9IGZyb20gImluc3BlY3Rvci9wcm9taXNlcyI7CmltcG9ydCB7IHBhcmVudFBvcnQsIHdvcmtlckRhdGEgfSBmcm9tICJ3b3JrZXJfdGhyZWFkcyI7CgpnbG9iYWwuc2ZEZWJ1ZyA9IHVuZGVmaW5lZDsKZ2xvYmFsLnN0YWNrRGVwdGhMb2NhbHMgPSB1bmRlZmluZWQ7Cmdsb2JhbC5ub2RlTW9kdWxlc1RvQ29sbGVjdExvY2FsVmFyaWFibGVzT24gPSB1bmRlZmluZWQ7CgovKioKICogUHJvY2Vzc2VzIGNhbGwgZnJhbWVzIGZyb20gYW4gZXhjZXB0aW9uIGFuZCBwb3N0cyB0aGVtIHZpYSB0aGUgV29ya2Vy4oCZ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qgc291cmNlTGluZXMgPSBzY3JpcHRTb3VyY2Uuc3BsaXQoIlxuIik7CiAgICAgICAgICAgIGNvZGUgPSBzb3VyY2VMaW5lc1tsb2NhdGlvbi5saW5lTnVtYmVyXSB8fCAiPG5vdCBjYXB0dXJlZD4iOwogICAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBmZXRjaCBzY3JpcHQgc291cmNlOiIsIGVycik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIC8vIEZldGNoIGxvY2FsIHZhcmlhYmxlcyBpZiB0aGVyZSdzIGFuIG9iamVjdElkCiAgICAgICAgY29uc3QgbG9jYWxzID0gbG9jYWxTY29wZT8ub2JqZWN0Py5vYmplY3RJZAogICAgICAgICAgPyBhd2FpdCBmZXRjaExvY2FsVmFyaWFibGVzKHNlc3Npb24sIGxvY2FsU2NvcGUub2JqZWN0Lm9iamVjdElkKQogICAgICAgICAgOiB7fTsKCiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGZ1bmN0aW9uOiBmdW5jdGlvbk5hbWUgfHwgIjxhbm9ueW1vdXM+IiwKICAgICAgICAgIGxvY2FscywKICAgICAgICAgIGZpbGUsCiAgICAgICAgICBsaW5lOiBsb2NhdGlvbj8ubGluZU51bWJlciB8fCAwLAogICAgICAgICAgY29kZSwKICAgICAgICB9OwogICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgY29uc29sZS5lcnJvcigiW1dvcmtlcl0gRXJyb3IgcHJvY2Vzc2luZyBjYWxsIGZyYW1lOiIsIGVycm9yKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGZ1bmN0aW9uOiAiPGVycm9yPiIsCiAgICAgIC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oIWlzRnJvbUFsbG93ZWROb2RlTW9kdWxlKSB7CiAgICAgICAgICAvLyBOb3QgZnJvbSBhbiBhbGxvd2VkIG5vZGUgbW9kdWxlID0+IHJldHVybiBlYXJseQogICAgICAgICAgaWYgKGdsb2JhbC5zZkRlYnVnKSB7CiAgICAgICAgICAgIGNvbnNvbGUubG9nKAogICAgICAgICAgICAgICJbV29ya2VyXSBFcnJvciBhcHBlYXJzIHRvIGJlIHRyaWdnZXJlZCBmcm9tIG5vbi1hcHBsaWNhdGlvbiBzb3VyY2VzOyBpZ25vcmluZy4iLAogICAgICAgICAgICApOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICAvLyBPdGhlcndpc2UsIGl0J3MgZnJvbSBhbiBhbGxvd2VkIG5vZGUgbW9kdWxlLCBzbyBjb250aW51ZQogICAgICB9IGVsc2UgewogICAgICAgIC8vIElmIHRoZSBsaXN0IGlzIGVtcHR5LCBwcmVzZXJ2ZSBleGlzdGluZyBiZWhhdmlvciBhbmQgaWdub3JlIG5vbi1hcHBsaWNhdGlvbiBlcnJvcnMKICAgICAgICBpZiAoZ2xvYmFsLnNmRGVidWcpIHsKICAgICAgICAgIGNvbnNvbGUubG9nKAogICAgICAgICAgICAiW1dvcmtlcl0gRXJyb3IgYXBwZWFycyB0byBiZSB0cmlnZ2VyZWQgZnJvbSBub24tYXBwbGljYXRpb24gc291cmNlczsgaWdub3JpbmcuIiwKICAgICAgICAgICk7CiAgICAgICAgfQogICAgICAgIHJldHVybjsKICAgICAgfQogICAgfQoKICAgIC8vIElmIHdlIHJlYWNoIHRoaXMgcG9pbnQsIHRoZSBlcnJvciBpcyBlaXRoZXIgZnJvbSBhcHAgY29kZSwgb3IgZnJvbSBhIG5vZGUgbW9kdWxlIGFsbG93ZWQgYnkgdGhlIGxpc3QKICAgIC8vID0+IFByb2NlZWQgd2l0aCBjYXB0dXJpbmcgbG9jYWwgdmFyaWFibGVzLCBldGMuCiAgICBhd2F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9uTGluZXNbaW5kZXhdLnRyaW0oKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZmlsZSA9ICI8dW5rbm93bj4iOwogICAgICAgIH0KCiAgICAgICAgLy8gSWYgd2UgaGF2ZSBhIHZhbGlkIGxvY2F0aW9uIGFuZCBzY3JpcHRJZCwgZmV0Y2ggdGhlIGNvZGUgbGluZQogICAgICAgIGlmIChsb2NhdGlvbiAmJiBsb2NhdGlvbi5zY3JpcHRJZCkgewogICAgICAgICAgY29uc3Qgc2NyaXB0SWQgPSBsb2NhdGlvbi5zY3JpcHRJZDsKICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgIGNvbnN0IHsgc2NyaXB0U291cmNlIH0gPSBhd2FpdCBzZXNzaW9uLnBvc3QoCiAgICAgICAgICAgICAgIkRlYnVnZ2VyLmdldFNjcmlwdFNvdXJjZSIsCiAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgc2NyaXB0SWQsCiAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgKTsKICAgICAgICAgICAgY29uc3Qgc291cmNlTGluZXMgPSBzY3JpcHRTb3VyY2Uuc3BsaXQoIlxuIik7CiAgICAgICAgICAgIGNvZGUgPSBzb3VyY2VMaW5lc1tsb2NhdGlvbi5saW5lTnVtYmVyXSB8fCAiPG5vdCBjYXB0dXJlZD4iOwogICAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBmZXRjaCBzY3JpcHQgc291cmNlOiIsIGVycik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIC8vIEZldGNoIGxvY2FsIHZhcmlhYmxlcyBpZiB0aGVyZSdzIGFuIG9iamVjdElkCiAgICAgICAgY29uc3QgbG9jYWxzID0gbG9jYWxTY29wZT8ub2JqZWN0Py5vYmplY3RJZAogICAgICAgICAgPyBhd2FpdCBmZXRjaExvY2FsVmFyaWFibGVzKHNlc3Npb24sIGxvY2FsU2NvcGUub2JqZWN0Lm9iamVjdElkKQogICAgICAgICAgOiB7fTsKCiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGZ1bmN0aW9uOiBmdW5jdGlvbk5hbWUgfHwgIjxhbm9ueW1vdXM+IiwKICAgICAgICAgIGxvY2FscywKICAgICAgICAgIGZpbGUsCiAgICAgICAgICBsaW5lOiBsb2NhdGlvbj8ubGluZU51bWJlciB8fCAwLAogICAgICAgICAgY29kZSwKICAgICAgICB9OwogICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgY29uc29sZS5lcnJvcigiW1dvcmtlcl0gRXJyb3IgcHJvY2Vzc2luZyBjYWxsIGZyYW1lOiIsIGVycm9yKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGZ1bmN0aW9uOiAiPGVycm9yPiIsCiAgICAgICAgICBsb2NhbHM6IHt9LAogICAgICAgICAgZmlsZTogIjx1bmtub3duPiIsCiAgICAgICAgICBsaW5lOiAwLAogICAgICAgICAgY29kZTogIjxub3QgY2FwdHVyZWQ+IiwKICAgICAgICB9OwogICAgICB9CiAgICB9KSwKICApOwogIC8vIFBvc3QgZXhjZXB0aW9uIGRhdGEKICBwYXJlbnRQb3J0Py5wb3N0TWVzc2FnZSh7IHR5cGU6ICJleGNlcHRpb24iLCBmcmFtZXMgfSk7Cn0KCi8qKgogKiBIYW5kbGVzIHRoZSAicGF1c2VkIiBzdGF0ZSBvZiB0aGUgZGVidWdnZXIgYW5kIHByb2Nlc3NlcyBleGNlcHRpb25zIG9yIHByb21pc2UgcmVqZWN0aW9ucy4KICogQHBhcmFtIHtTZXNzaW9ufSBzZXNzaW9uIC0gVGhlIGRlYnVnZ2luZyBzZXNzaW9uIGluc3RhbmNlLgogKiBAcGFyYW0ge29iamVjd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2FpdCB1bnJvbGxPYmplY3Qoc2Vzc2lvbiwgaWQsIHByb3AubmFtZSwgdmFyaWFibGVzKTsKICAgICAgICB9IGVsc2UgaWYgKHByb3A/LnZhbHVlKSB7CiAgICAgICAgICB1bnJvbGxPdGhlcihwcm9wLCB2YXJpYWJsZXMpOwogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4gdmFyaWFibGVzOwogICAgfQogIH0gY2F0Y2ggKGVycikgewogICAgaWYgKGdsb2JhbC5zZkRlYnVnKSB7CiAgICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBmZXRjaCBsb2NhbCB2YXJpYWJsZXM6IiwgZXJyKTsKICAgIH0KICAgIHJldHVybiB7fTsKICB9Cn0KCnN0YXJ0RGVidWdnZXIoKS5jYXRjaCgoZXJyb3IpID0+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 = _e(C[b].file);
231
+ if (Z = b, y !== "<unknown>") {
232
+ for (let f = 0; f < u.length; f++) {
233
+ const W = u[f];
234
+ if (ye(W, y) || typeof W.file == "string" && W.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 = Ke(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
257
  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);
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), n.doSend(h, u);
263
+ })) : n.doSend(h, u), l ? N.getInstance().runWithSession(l, () => {
264
+ n.doSend(h, u);
265
+ }) : n.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 o = Error, i = /* @__PURE__ */ new Set();
274
+ function g(...r) {
275
+ const c = Reflect.construct(o, 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
+ o.captureStackTrace && o.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(o.prototype, { constructor: { value: g, enumerable: !1, writable: !0, configurable: !0 } }), Object.setPrototypeOf(g, o), globalThis.Error = g;
533
293
  }
534
- function Se(n) {
294
+ function ne(n) {
535
295
  return n = (n = (n = n.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;
297
+ function Ke(n, 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;
542
302
  })(n);
543
303
  if (!s || s === "<unknown>") return null;
544
- const r = s + ".map";
304
+ const o = 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 = be(o, "utf-8");
307
+ if (i) {
308
+ const g = JSON.parse(i);
309
+ let r = new Ae.SourceMapConsumer(g).originalPositionFor({ line: e, column: t });
310
+ if (s && r.source) {
311
+ const c = ne(s), a = g.sources.findIndex((l) => ne(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 "${o}: Error - ".`, i);
566
326
  }
567
327
  return null;
568
328
  }
569
- function it(n) {
329
+ function _e(n) {
570
330
  return n?.split("/").pop() || "<unknown>";
571
331
  }
572
- function Ee(n, e) {
332
+ function ye(n, e) {
573
333
  if (!n || typeof n != "object") return !1;
574
334
  for (const t of Object.values(n))
575
- if (typeof t == "string" && t.includes(e) || typeof t == "object" && Ee(t, e)) return !0;
335
+ if (typeof t == "string" && t.includes(e) || typeof t == "object" && ye(t, e)) return !0;
576
336
  return !1;
577
337
  }
578
- let Ne = !1;
579
- function ve(n) {
338
+ let oe = !1;
339
+ function se(n) {
580
340
  if (!n) return;
581
341
  const e = n.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(n, 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 o = new URL(n), i = (o.protocol, G).request({ method: "GET", hostname: o.hostname, port: o.port || (o.protocol === "https:" ? 443 : 80), path: o.pathname + (o.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 o = JSON.stringify(z.encode(s)), i = this.normalizedSupplementalForGraphQL(), g = this.getVariables({ exceptionMessage: t, traceJson: o, reentrancyGuardPreactive: !1, library: d().packageLibraryType, version: d().version, ...i });
381
+ v(this.endpoint, this.operationName, this.getQuery(), g);
622
382
  }
623
383
  getQuery() {
624
384
  return `
@@ -652,87 +412,51 @@ 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() {
415
+ const ie = "getting request source code";
416
+ var k = ((n) => (n.UNKNOWN = "unknown", n.ANONYMOUS = "anonymous", n.NOT_CAPTURED = "not captured", n))(k || {});
417
+ const P = "http:", x = "https:", ze = He(import.meta.url);
418
+ let re = !1;
419
+ function Ue() {
703
420
  const n = d().sfDebug;
704
- if (Ze) return void (n && console.log("[patchNodeHttpInbound] Already installed, skipping."));
421
+ if (re) return void (n && console.log("[patchNodeHttpInbound] Already installed, skipping."));
705
422
  let e;
706
- Ze = !0;
423
+ re = !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 = ze("node:http"), n && console.log("[patchNodeHttpInbound] node:http required successfully.");
426
+ } catch (o) {
427
+ return void console.error("Failed to require node:http:", o);
711
428
  }
712
429
  if (!e?.Server?.prototype) return void (n && 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 }), n && console.log("[patchNodeHttpInbound] Patching http.Server.prototype.emit."), t.emit = function(o, ...i) {
432
+ if (o !== "request") return n && console.log(`[patchNodeHttpInbound] Passing through event: ${o}`), s.call(this, o, ...i);
433
+ const g = i[0], r = i[1], c = (function(u) {
434
+ const m = {};
435
+ if (!u) return m;
436
+ for (const [h, Z] of Object.entries(u)) Z != null && (Array.isArray(Z) ? m[h.toLowerCase()] = Z.join(", ") : m[h.toLowerCase()] = String(Z));
437
+ return m;
438
+ })(g?.headers), a = c["x-sf3-rid"], l = c["x-sf3-functionspancaptureoverride"];
439
+ n && (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
+ n && console.log("[patchNodeHttpInbound] Context traceId set:", p);
444
+ const C = () => I.runWith({ inboundHeaders: c, ...a ? { traceId: a } : {} }, () => {
445
+ a && I.setTraceId(a), n && console.log("[patchNodeHttpInbound] Running request handler in context.");
446
+ const u = () => {
447
+ n && console.log("[patchNodeHttpInbound] Response finished/closed for traceId:", I.getTraceId());
730
448
  };
731
- return i.on("finish", m), i.on("close", m), s.call(this, r, o, i);
449
+ return r.on("finish", u), r.on("close", u), s.call(this, o, g, r);
732
450
  });
451
+ if (!l) return C();
452
+ try {
453
+ return Ge.run(l, () => C());
454
+ } catch {
455
+ return C();
456
+ }
733
457
  }) : n && console.log("[patchNodeHttpInbound] Already patched, skipping.");
734
458
  }
735
- class ut extends Ie {
459
+ class Ee extends ee {
736
460
  constructor() {
737
461
  super(), this.setOperationName("DomainsToNotPassHeaderTo");
738
462
  }
@@ -753,13 +477,13 @@ class ut extends Ie {
753
477
  )
754
478
  }
755
479
  `, s = { apiKey: this.apiKey, serviceUuid: this.serviceUUID, domains: e };
756
- W(this.endpoint, this.operationName, t, s);
480
+ v(this.endpoint, this.operationName, t, s);
757
481
  }
758
482
  }
759
- class pt extends $ {
483
+ class Te extends F {
760
484
  constructor() {
761
485
  super();
762
- C(this, "serviceIdentifier", new X());
486
+ A(this, "serviceIdentifier", new Y());
763
487
  this.setOperationName("CollectNetworkHops");
764
488
  }
765
489
  async sendAppIdentifier() {
@@ -769,8 +493,8 @@ class pt extends $ {
769
493
  this.sendAppIdentifier(), this.send(t);
770
494
  }
771
495
  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 });
773
- W(this.endpoint, this.operationName, this.getQuery(), c);
496
+ const { name: s, column: o, line: i, entrypoint: g, retryWithoutTraceId: r } = t, c = this.getVariables({ name: s, column: o, line: i, entrypoint: g, retryWithoutTraceId: r });
497
+ v(this.endpoint, this.operationName, this.getQuery(), c);
774
498
  }
775
499
  getQuery() {
776
500
  return `
@@ -800,10 +524,10 @@ class pt extends $ {
800
524
  `;
801
525
  }
802
526
  }
803
- class It extends $ {
527
+ class $e extends F {
804
528
  constructor() {
805
529
  super();
806
- C(this, "serviceIdentifier", new X());
530
+ A(this, "serviceIdentifier", new Y());
807
531
  this.setOperationName("CollectNetworkRequest");
808
532
  }
809
533
  async sendAppIdentifier() {
@@ -824,18 +548,18 @@ class It extends $ {
824
548
  }
825
549
  async send(t) {
826
550
  const s = { data: { ...t } };
827
- await W(this.endpoint, this.operationName, this.getQuery(), s);
551
+ await v(this.endpoint, this.operationName, this.getQuery(), s);
828
552
  }
829
553
  }
830
- const ce = [400, 403];
831
- class Ct {
554
+ const O = [400, 403];
555
+ class Le {
832
556
  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) => {
557
+ A(this, "HEADER_TRACING", "X-Sf3-Rid");
558
+ A(this, "HEADER_LOG_GUARD", "reentrancy_guard_logging_preactive");
559
+ A(this, "HEADER_PRINT_GUARD", "reentrancy_guard_print_preactive");
560
+ A(this, "HEADER_EXCEPTION_GUARD", "reentrancy_guard_exception_preactive");
561
+ A(this, "contextManager");
562
+ this.contextManager = N.getInstance(), e?.forEach((t) => {
839
563
  typeof t == "string" && t.trim() && this.contextManager.getExcludedDomains().add(t);
840
564
  }), d().sfDebug && console.log("[RequestInterceptor] Initialized with static excluded domains.");
841
565
  }
@@ -843,153 +567,153 @@ class Ct {
843
567
  let s;
844
568
  if (e instanceof Headers) s = e.get(t) ?? void 0;
845
569
  else {
846
- const a = t.toLowerCase();
847
- for (const [o, i] of Object.entries(e)) if (o.toLowerCase() === a) {
848
- s = i;
570
+ const i = t.toLowerCase();
571
+ for (const [g, r] of Object.entries(e)) if (g.toLowerCase() === i) {
572
+ s = r;
849
573
  break;
850
574
  }
851
575
  }
852
576
  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] };
577
+ const o = s.split("/").filter(Boolean);
578
+ return o.length < 3 ? {} : { sessionId: o[0], pageVisitId: o[1], requestId: o[o.length - 1] };
855
579
  }
856
580
  parseStackFrame(e) {
857
581
  const t = /\((.*):(\d+):(\d+)\)$/.exec(e.trim());
858
582
  if (!t) return null;
859
- const [, s, r, a] = t;
860
- return { filePath: s, line: parseInt(r, 10), column: parseInt(a, 10) };
583
+ const [, s, o, i] = t;
584
+ return { filePath: s, line: parseInt(o, 10), column: parseInt(i, 10) };
861
585
  }
862
586
  async getOriginalPosition(e, t, s) {
863
- let r = { source: e, line: t, column: s, name: null };
864
- const a = e + ".map";
587
+ let o = { source: e, line: t, column: s, name: null };
588
+ const i = e + ".map";
865
589
  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);
590
+ const g = JSON.parse(be(i, "utf-8"));
591
+ let r = (await new Ae.SourceMapConsumer(g)).originalPositionFor({ line: t, column: s });
592
+ r.source && (o = r);
593
+ } catch (g) {
594
+ d().sfDebug && console.error(`Could not read/parse map file at ${i}:`, g);
871
595
  }
872
- return { originalPos: r };
596
+ return { originalPos: o };
873
597
  }
874
598
  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);
599
+ const o = d().sfDebug ? 10 : t, i = Error.stackTraceLimit;
600
+ Error.stackTraceLimit = Math.max(i, o);
601
+ const g = new Error(ie);
602
+ ie in Error && Error.captureStackTrace(g, this.captureFirstUserLines);
603
+ const r = g.stack || "";
604
+ Error.stackTraceLimit = i;
605
+ const c = r.split(`
606
+ `).slice(1), a = [];
607
+ for (const l of c)
608
+ 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;
609
+ for (const l of a) {
610
+ const I = this.parseStackFrame(l);
611
+ I ? (async () => {
612
+ const { originalPos: p } = await this.getOriginalPosition(I.filePath, I.line, I.column);
613
+ if (p) {
614
+ d().sfDebug && console.log("[RequestInterceptor] First user code line:", p);
615
+ const C = { line: p.line?.toString() || k.UNKNOWN, column: p.column?.toString() || k.NOT_CAPTURED, name: p.name || k.NOT_CAPTURED, entrypoint: p.source, retryWithoutTraceId: s };
616
+ e.doSend(C);
893
617
  }
894
- })() : d().sfDebug && console.error("Could not parse stack line:", g);
618
+ })() : d().sfDebug && console.error("Could not parse stack line:", l);
895
619
  }
896
620
  }
897
621
  addReentrancyGuardHeaders(e) {
898
622
  e.set(this.HEADER_LOG_GUARD, "true"), e.set(this.HEADER_PRINT_GUARD, "true"), e.set(this.HEADER_EXCEPTION_GUARD, "true");
899
623
  }
900
624
  shouldPropagateHeaders(e) {
901
- return !Ue.some((t) => new RegExp(`^${t.replace(/\*/g, ".*")}$`).test(e));
625
+ return !Be.some((t) => new RegExp(`^${t.replace(/\*/g, ".*")}$`).test(e));
902
626
  }
903
627
  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;
628
+ const s = new URL(t).hostname, o = this.shouldPropagateHeaders(s);
629
+ return o ? this.addTracingHeader(e, t) : d().sfDebug && console.error(`[RequestInterceptor] Excluded domain: ${s}`), o;
906
630
  }
907
631
  addTracingHeader(e, t) {
908
- const s = Je();
632
+ const s = ue();
909
633
  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}`));
634
+ const r = pe(s);
635
+ 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
636
  }
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}`);
637
+ const o = this.contextManager.getOrSetSfTraceId(), i = this.contextManager.getOrSetPageVisitUUID(), g = Ce();
638
+ e.set(this.HEADER_TRACING, `${o}/${i}/${g}`), d().sfDebug && console.log(`[RequestInterceptor] Added tracing header for ${t}`);
915
639
  }
916
640
  patchFetch(e, t) {
917
641
  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);
642
+ typeof s == "function" ? globalThis.fetch = async (o, i) => {
643
+ const g = new Headers(i?.headers);
644
+ if (g.get(this.HEADER_LOG_GUARD) === "true" || g.get(this.HEADER_PRINT_GUARD) === "true" || g.get(this.HEADER_EXCEPTION_GUARD) === "true") return s(o, i);
921
645
  this.captureFirstUserLines(e);
922
- const i = Date.now();
646
+ const r = Date.now();
923
647
  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);
648
+ typeof o == "string" || o instanceof URL ? c = o.toString() : o instanceof Request ? (c = o.url, o.headers.forEach((u, m) => {
649
+ g.set(m, u);
926
650
  })) : 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;
651
+ const a = new URL(c).hostname, l = new Headers(g), I = this.addTracingHeaders(g, c), p = { ...i, headers: g };
652
+ let C;
929
653
  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`);
654
+ let u = !1;
655
+ 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);
656
+ const m = Date.now();
657
+ d().sfDebug && console.log(`[RequestInterceptor] Fetch completed: ${c}, Status: ${C.status}, Duration: ${m - r}ms`);
658
+ const { sessionId: h, pageVisitId: Z, requestId: b } = this.extractIdsFromTraceHeader(g);
659
+ 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: T() }), C;
660
+ } catch (u) {
661
+ const m = Date.now();
662
+ d().sfDebug && console.error(`[RequestInterceptor] Fetch failed: ${c}, Error: ${u}, Duration: ${m - r}ms`);
939
663
  }
940
664
  } : d().sfDebug && console.error("[RequestInterceptor] Fetch not available.");
941
665
  }
942
666
  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;
667
+ if (d().sfDebug && console.log("[RequestInterceptor] Initializing HTTP/HTTPS request patch..."), !G || typeof G.request != "function") return void (d().sfDebug && console.log("[RequestInterceptor] HTTP/HTTPS not available."));
668
+ const s = G.request.bind(G), o = G.request.bind(G);
669
+ G.request = function(i, g) {
670
+ let r;
947
671
  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);
672
+ if (typeof i == "string") {
673
+ const a = new URL(i);
674
+ r = { protocol: a.protocol || P, hostname: a.hostname, path: a.pathname + a.search, headers: {} };
675
+ } 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));
676
+ if (r.headers) {
677
+ const a = `${r.protocol}//${r.hostname}`;
678
+ this.addTracingHeaders(r.headers, a), this.captureFirstUserLines(e);
955
679
  } 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;
680
+ } catch (a) {
681
+ throw d().sfDebug && console.error("[RequestInterceptor] Error while processing HTTP request options:", a), a;
958
682
  }
959
683
  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);
684
+ return s(r, (a) => {
685
+ const l = `${r.protocol}//${r.hostname}`;
686
+ if (r.headers && this.shouldPropagateHeaders(new URL(l).hostname) && O.includes(a.statusCode || 0)) {
687
+ r.hostname;
688
+ const u = { ...r, headers: { ...r.headers } };
689
+ delete u.headers[this.HEADER_TRACING], s(u, g), c = !0, this.captureFirstUserLines(e, 10, c);
966
690
  }
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);
691
+ const { sessionId: I, pageVisitId: p, requestId: C } = this.extractIdsFromTraceHeader(r.headers);
692
+ 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: T() }), g?.(a);
969
693
  });
970
- }, B.request = function(a, o) {
971
- let i;
694
+ }, G.request = function(i, g) {
695
+ let r;
972
696
  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);
697
+ if (typeof i == "string") {
698
+ const a = new URL(i);
699
+ r = { protocol: a.protocol || x, hostname: a.hostname, path: a.pathname + a.search, headers: {} };
700
+ } 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));
701
+ if (r.headers) {
702
+ const a = `${r.protocol}//${r.hostname}`;
703
+ this.addTracingHeaders(r.headers, a);
980
704
  } 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;
705
+ } catch (a) {
706
+ throw d().sfDebug && console.error("[RequestInterceptor] Error while processing HTTPS request options:", a), a;
983
707
  }
984
708
  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);
709
+ return o(r, (a) => {
710
+ const l = `${r.protocol}//${r.hostname}`;
711
+ if (r.headers && this.shouldPropagateHeaders(new URL(l).hostname) && O.includes(a.statusCode || 0)) {
712
+ const u = { ...r, headers: { ...r.headers } };
713
+ delete u.headers[this.HEADER_TRACING], o(u, g), c = !0, this.captureFirstUserLines(e, 10, c);
990
714
  }
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);
715
+ const { sessionId: I, pageVisitId: p, requestId: C } = this.extractIdsFromTraceHeader(r.headers);
716
+ 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: T() }), g?.(a);
993
717
  });
994
718
  }, d().sfDebug && console.log("✅ HTTP and HTTPS request methods patched globally.");
995
719
  }
@@ -1004,7 +728,7 @@ class Ct {
1004
728
  return [...this.contextManager.getExcludedDomains()];
1005
729
  }
1006
730
  }
1007
- class mt extends Ie {
731
+ class De extends ee {
1008
732
  constructor() {
1009
733
  super(), this.setOperationName("UpdateServiceDetails");
1010
734
  }
@@ -1033,42 +757,42 @@ class mt extends Ie {
1033
757
  )
1034
758
  }
1035
759
  `, t = this.getVariables({ serviceIdentifier: d().serviceIdentifier, serviceVersion: d().serviceVersion, serviceAdditionalMetadata: d().serviceAdditionalMetadata, gitSha: d().gitSha || "" });
1036
- W(this.endpoint, this.operationName, e, t);
760
+ v(this.endpoint, this.operationName, e, t);
1037
761
  }
1038
762
  }
1039
- class ht {
763
+ class Pe {
1040
764
  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");
765
+ A(this, "rootPaths");
766
+ A(this, "fileConfigs", /* @__PURE__ */ new Map());
767
+ A(this, "functionConfigs", /* @__PURE__ */ new Map());
768
+ A(this, "directoryConfigs", /* @__PURE__ */ new Map());
769
+ A(this, "hasSailfishFiles", !1);
770
+ A(this, "debug");
1047
771
  this.rootPaths = e, this.debug = t || process.env.SF_DEBUG === "true";
1048
772
  }
1049
773
  async loadAllConfigs() {
1050
774
  this.debug && console.log("[FuncSpan ConfigLoader] Scanning for .sailfish files in:", this.rootPaths);
1051
775
  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}`);
776
+ 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
777
  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
778
  for (const t of e) await this._loadConfigFile(t);
1055
779
  await this._resolveInheritance(), this.debug && console.log(`[FuncSpan ConfigLoader] Loaded ${this.fileConfigs.size} file configs, ${this.functionConfigs.size} function configs`);
1056
780
  }
1057
781
  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 = {};
782
+ const s = this.hasSailfishFiles ? me() : ve(), o = this._getDirectoryConfig(e), i = S.normalize(e), g = this.fileConfigs.get(i) || {};
783
+ let r = {};
1060
784
  if (t) {
1061
- const c = this.functionConfigs.get(a);
1062
- c && (i = c.get(t) || {});
785
+ const c = this.functionConfigs.get(i);
786
+ c && (r = c.get(t) || {});
1063
787
  }
1064
- return z(s, r, o, i);
788
+ return R(s, o, g, r);
1065
789
  }
1066
790
  async _walkDirectory(e, t) {
1067
791
  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);
792
+ const s = L.readdirSync(e, { withFileTypes: !0 });
793
+ for (const o of s) {
794
+ const i = S.join(e, o.name);
795
+ o.isFile() && o.name === ".sailfish" ? t.push(i) : o.name === "node_modules" || o.isDirectory() && o.name.startsWith(".") && o.name !== ".sailfish" || o.isDirectory() && await this._walkDirectory(i, t);
1072
796
  }
1073
797
  } catch (s) {
1074
798
  this.debug && console.error(`[FuncSpan ConfigLoader] Error walking directory ${e}:`, s);
@@ -1076,682 +800,326 @@ class ht {
1076
800
  }
1077
801
  async _loadConfigFile(e) {
1078
802
  try {
1079
- const t = te.readFileSync(e, "utf-8"), s = G.dirname(e);
1080
- let r = null;
803
+ const t = L.readFileSync(e, "utf-8"), s = S.dirname(e);
804
+ let o = null;
1081
805
  try {
1082
- r = JSON.parse(t);
806
+ o = JSON.parse(t);
1083
807
  } catch {
1084
808
  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));
809
+ o = require("js-yaml").load(t);
810
+ } catch (i) {
811
+ return void (this.debug && console.error(`[FuncSpan ConfigLoader] Failed to parse ${e} as JSON or YAML:`, i));
1088
812
  }
1089
813
  }
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}`));
814
+ if (!o) return;
815
+ o.default && this.directoryConfigs.set(s, o.default), o.files && await this._expandFileGlobs(s, o.files, o.default || {}), o.functions && this._storeFunctionConfigs(s, o.functions, o.default || {}), this.debug && (console.log(`[FuncSpan ConfigLoader] Loaded config from ${e}`), console.log(`[FuncSpan ConfigLoader] Directory: ${s}`), console.log(`[FuncSpan ConfigLoader] Has default: ${!!o.default}`), console.log(`[FuncSpan ConfigLoader] File patterns: ${Object.keys(o.files || {}).length}`), console.log(`[FuncSpan ConfigLoader] Functions: ${Object.keys(o.functions || {}).length}`));
1092
816
  } catch (t) {
1093
817
  this.debug && console.error(`[FuncSpan ConfigLoader] Error loading ${e}:`, t);
1094
818
  }
1095
819
  }
1096
820
  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}`);
821
+ for (const [o, i] of Object.entries(t)) try {
822
+ const g = S.join(e, o), r = await Ye(g, { absolute: !0, nodir: !0, ignore: ["**/node_modules/**", "**/.git/**"] });
823
+ this.debug && console.log(`[FuncSpan ConfigLoader] Pattern '${o}' matched ${r.length} files`);
824
+ for (const c of r) {
825
+ const a = S.normalize(c), l = R(s, i);
826
+ this.fileConfigs.set(a, l), this.debug && r.length <= 5 && console.log(`[FuncSpan ConfigLoader] - ${c}`);
1103
827
  }
1104
- } catch (o) {
1105
- this.debug && console.error(`[FuncSpan ConfigLoader] Error expanding glob '${r}':`, o);
828
+ } catch (g) {
829
+ this.debug && console.error(`[FuncSpan ConfigLoader] Error expanding glob '${o}':`, g);
1106
830
  }
1107
831
  }
1108
832
  _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')`);
833
+ for (const [o, i] of Object.entries(t)) {
834
+ const g = o.split("::");
835
+ if (g.length !== 2) {
836
+ this.debug && console.warn(`[FuncSpan ConfigLoader] Invalid function pattern '${o}' (expected format: 'file.ts::functionName')`);
1113
837
  continue;
1114
838
  }
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}`);
839
+ const [r, c] = g, a = S.normalize(S.join(e, r));
840
+ this.functionConfigs.has(a) || this.functionConfigs.set(a, /* @__PURE__ */ new Map());
841
+ const l = this.functionConfigs.get(a), I = R(s, i);
842
+ l.set(c, I), this.debug && console.log(`[FuncSpan ConfigLoader] Function config: ${a}::${c}`);
1119
843
  }
1120
844
  }
1121
845
  async _resolveInheritance() {
1122
846
  }
1123
847
  _getDirectoryConfig(e) {
1124
- let t = G.dirname(G.normalize(e));
848
+ let t = S.dirname(S.normalize(e));
1125
849
  const s = [];
1126
- for (; t && t !== G.dirname(t); ) {
1127
- const r = this.directoryConfigs.get(t);
1128
- r && s.unshift(r), t = G.dirname(t);
850
+ for (; t && t !== S.dirname(t); ) {
851
+ const o = this.directoryConfigs.get(t);
852
+ o && s.unshift(o), t = S.dirname(t);
1129
853
  }
1130
- return s.reduce((r, a) => z(r, a), {});
854
+ return s.reduce((o, i) => R(o, i), {});
1131
855
  }
1132
856
  }
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());
857
+ let H = null;
858
+ async function xe(n, e) {
859
+ H = new Pe(n, e), await H.loadAllConfigs();
1139
860
  }
1140
- function At() {
1141
- return D !== null;
861
+ function Oe(n, e) {
862
+ return H ? H.getConfig(n, e) : (process.env.SF_DEBUG === "true" && console.log("[FuncSpan ConfigLoader] Config loader not initialized, using env config for worker process"), me());
1142
863
  }
1143
- function V(n, e) {
1144
- const t = process.env[n];
1145
- return t === void 0 ? e : t === "true" || t === "1";
864
+ function je() {
865
+ return H !== null;
1146
866
  }
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;
1270
- }
1271
- return s > 0 ? J(r, s) : r;
1272
- } catch {
1273
- return { error: "Failed to capture arguments", argsCount: t.length - 1 };
1274
- }
867
+ const Me = ["readFile", "writeFile", "appendFile", "readdir", "stat", "lstat", "fstat", "access", "open", "close", "read", "write", "chmod", "mkdir", "rmdir", "unlink", "rename"], ae = ["lookup", "resolve", "resolve4", "resolve6", "resolveAny", "resolveMx", "resolveNs", "resolveTxt", "reverse"], Qe = ["pbkdf2", "randomBytes", "scrypt", "generateKeyPair"], qe = ["gzip", "gunzip", "deflate", "inflate", "deflateRaw", "inflateRaw", "brotliCompress", "brotliDecompress"];
868
+ let ce = !1;
869
+ function et(n) {
870
+ if (typeof n != "string") return !1;
871
+ const e = process.env.SF_FUNCSPAN_JSONL_FILE;
872
+ if (e && n.includes(e)) return !0;
873
+ const t = process.env.SF_WORKER_POOL_JSONL_FILE;
874
+ return !(!t || !n.includes(t));
1275
875
  }
1276
- function Xe(n, e, t, s) {
1277
- let r;
876
+ let ge = !1;
877
+ function le(n) {
878
+ if (typeof n != "string") return !1;
879
+ if (n === "localhost" || n === "127.0.0.1" || n === "::1") return !0;
1278
880
  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;
881
+ const e = process.env.API_GRAPHQL_ENDPOINT;
882
+ if (e && n === new URL(e).hostname)
883
+ return !0;
1348
884
  } catch {
1349
- return { error: "Failed to capture result", type: typeof t };
1350
885
  }
886
+ return !1;
1351
887
  }
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) {
888
+ function tt() {
889
+ if (!ge) try {
890
+ let n;
891
+ if (typeof require > "u") return void (process.env.SF_DEBUG === "true" && console.log("[WorkerPool] Skipping dns patching in pure ESM environment (require unavailable)"));
1380
892
  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);
893
+ n = require("node:dns");
894
+ } catch (e) {
895
+ return void (process.env.SF_DEBUG === "true" && console.log("[WorkerPool] Failed to require dns module:", e));
1390
896
  }
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
- `;
1477
- }
1478
- }
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);
1499
- }
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
- });
1516
- }
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
- }
1534
- }
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
897
  if (n.__sf_worker_pool_patched__) return;
1541
898
  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") {
899
+ for (const e of ae) if (typeof n[e] == "function") {
1543
900
  const t = n[e];
1544
901
  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);
902
+ return le(s[0]) ? t.apply(this, s) : typeof s[s.length - 1] == "function" ? _("dns", e, t, s, this) : t.apply(this, s);
1547
903
  }, Object.defineProperty(n[e], "name", { value: e, writable: !1 });
1548
904
  }
1549
905
  (function(e) {
1550
906
  if (!e.promises) return void (process.env.SF_DEBUG === "true" && console.log("[WorkerPool] dns.promises not available, skipping"));
1551
907
  if (!e.promises.__sf_worker_pool_patched__) {
1552
908
  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") {
909
+ for (const t of ae) if (typeof e.promises[t] == "function") {
1554
910
  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);
911
+ e.promises[t] = function(...o) {
912
+ return le(o[0]) ? s.apply(this, o) : We("dns", t, s, o, this);
1558
913
  }, Object.defineProperty(e.promises[t], "name", { value: t, writable: !1 });
1559
914
  }
1560
915
  process.env.SF_DEBUG === "true" && console.log("[WorkerPool] dns.promises module patched successfully");
1561
916
  }
1562
- })(n), _e = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] dns module patched successfully");
917
+ })(n), ge = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] dns module patched successfully");
1563
918
  } catch (n) {
1564
919
  console.error("[WorkerPool] Error patching dns module:", n);
1565
920
  }
1566
921
  }
1567
- let we = !1, Ve = !1, ue = !1;
1568
- function Bt() {
1569
- if (ue) return;
922
+ let de = !1, Ie = !1, Q = !1;
923
+ function nt() {
924
+ if (Q) return;
1570
925
  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 {
926
+ n && console.log("[WorkerPool] Initializing worker pool patching..."), X("fs") && (n && console.log("[WorkerPool] Patching fs module..."), (function() {
927
+ if (!ce) try {
1573
928
  const e = require("node:fs");
1574
929
  if (e.__sf_worker_pool_patched__) return;
1575
930
  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") {
931
+ for (const t of Me) if (typeof e[t] == "function") {
1577
932
  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);
933
+ e[t] = function(...o) {
934
+ return et(o[0]) ? s.apply(this, o) : typeof o[o.length - 1] == "function" ? _("fs", t, s, o, this) : s.apply(this, o);
1580
935
  }, Object.defineProperty(e[t], "name", { value: t, writable: !1 });
1581
936
  }
1582
- Fe = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] fs module patched successfully");
937
+ ce = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] fs module patched successfully");
1583
938
  } catch (e) {
1584
939
  console.error("[WorkerPool] Error patching fs module:", e);
1585
940
  }
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 {
941
+ })()), X("dns") && (n && console.log("[WorkerPool] Patching dns module..."), tt()), X("crypto") && (n && console.log("[WorkerPool] Patching crypto module..."), (function() {
942
+ if (!de) try {
1588
943
  const e = require("node:crypto");
1589
944
  if (e.__sf_worker_pool_patched__) return;
1590
945
  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") {
946
+ for (const t of Qe) if (typeof e[t] == "function") {
1592
947
  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);
948
+ e[t] = function(...o) {
949
+ return typeof o[o.length - 1] == "function" ? _("crypto", t, s, o, this) : s.apply(this, o);
1595
950
  }, Object.defineProperty(e[t], "name", { value: t, writable: !1 });
1596
951
  }
1597
- we = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] crypto module patched successfully");
952
+ de = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] crypto module patched successfully");
1598
953
  } catch (e) {
1599
954
  console.error("[WorkerPool] Error patching crypto module:", e);
1600
955
  }
1601
- })()), O("zlib") && (n && console.log("[WorkerPool] Patching zlib module..."), (function() {
1602
- if (!Ve) try {
956
+ })()), X("zlib") && (n && console.log("[WorkerPool] Patching zlib module..."), (function() {
957
+ if (!Ie) try {
1603
958
  const e = require("node:zlib");
1604
959
  if (e.__sf_worker_pool_patched__) return;
1605
960
  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") {
961
+ for (const t of qe) if (typeof e[t] == "function") {
1607
962
  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);
963
+ e[t] = function(...o) {
964
+ return typeof o[o.length - 1] == "function" ? _("zlib", t, s, o, this) : s.apply(this, o);
1610
965
  }, Object.defineProperty(e[t], "name", { value: t, writable: !1 });
1611
966
  }
1612
- Ve = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] zlib module patched successfully");
967
+ Ie = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] zlib module patched successfully");
1613
968
  } catch (e) {
1614
969
  console.error("[WorkerPool] Error patching zlib module:", e);
1615
970
  }
1616
- })()), ue = !0, n && console.log("[WorkerPool] Worker pool patching initialized");
971
+ })()), Q = !0, n && console.log("[WorkerPool] Worker pool patching initialized");
1617
972
  }
1618
- function Wt() {
1619
- return ue;
973
+ function ot() {
974
+ return Q;
1620
975
  }
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);
1625
- }
1626
- const { config: e } = et(n);
1627
- 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]);
976
+ let q = !1, j = !1;
977
+ function dt(n) {
978
+ if (j) console.warn("[setupInterceptors] ⚠️ Recursive call detected and blocked!");
979
+ else if (!q) {
980
+ j = !0;
981
+ try {
982
+ if (!n || !n.apiKey) {
983
+ const o = `The required API Key is not provided: ${JSON.stringify(n)}`;
984
+ console.error(o);
985
+ }
986
+ const { config: e } = Ne(n);
987
+ if (e.sfDebug && console.log("Updated configuration after applying options:", e), !e.apiKey || !e.apiGraphqlEndpoint) {
988
+ const o = `The required config is not provided: ${JSON.stringify(e)}`;
989
+ throw console.error(o), new Error(o);
990
+ }
991
+ je() || xe(void 0, e.sfDebug).catch((o) => {
992
+ e.sfDebug && console.error("[FuncSpan] Failed to initialize config loader:", o);
993
+ }), process.env.SF_WORKER_POOL_DISABLED === "true" ? e.sfDebug && console.log("[setupInterceptors] Worker pool patching DISABLED (SF_WORKER_POOL_DISABLED=true)") : ot() || (nt(), e.sfDebug && console.log("[setupInterceptors] Worker pool patching initialized (DNS tracking enabled)"));
994
+ const t = new ee();
995
+ t.setServiceUUID(e.serviceUUID), (function(o) {
996
+ function i(I, p) {
997
+ o.setOperationName("CollectLogs"), o.doSend([p, I]);
998
+ }
999
+ 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);
1000
+ console.log = (...I) => {
1001
+ i("INFO", I.join(" ")), g(...I);
1002
+ }, console.error = (...I) => {
1003
+ i("ERROR", I.join(" ")), r(...I);
1004
+ }, console.warn = (...I) => {
1005
+ i("WARN", I.join(" ")), c(...I);
1006
+ }, console.info = (...I) => {
1007
+ i("INFO", I.join(" ")), a(...I);
1008
+ }, d().logLevel === "DEBUG" && (console.debug = (...I) => {
1009
+ i("DEBUG", I.join(" ")), l(...I);
1010
+ });
1011
+ })(t), (function(o = []) {
1012
+ const i = new Le(o);
1013
+ new Ee().doSend(i.getExcludedDomains());
1014
+ const g = new Te(), r = new $e();
1015
+ i.patchFetch(g, r), i.patchHttp(g, r);
1016
+ })(e.domainsToNotPropagateHeadersTo);
1017
+ const s = new ke();
1018
+ s.setServiceUUID(e.serviceUUID), Je(s), Ue(), new De().send(), q = !0, e.sfDebug && console.log("[setupInterceptors] ✅ Initialization complete");
1019
+ } finally {
1020
+ j = !1;
1638
1021
  }
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);
1650
- });
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);
1656
- })(e.domainsToNotPropagateHeadersTo);
1657
- const s = new at();
1658
- s.setServiceUUID(e.serviceUUID), ot(s), dt(), new mt().send();
1022
+ }
1023
+ }
1024
+ function It() {
1025
+ return q;
1659
1026
  }
1660
- function Et(n, e, t, s = !1) {
1661
- const r = d();
1662
- new Ke(r.apiKey).identify(n, e, t, s);
1027
+ function ut(n, e, t, s = !1) {
1028
+ const o = d();
1029
+ new fe(o.apiKey).identify(n, e, t, s);
1663
1030
  }
1664
- function kt(n, e = {}, t, s = !1) {
1665
- const r = d();
1666
- new Ke(r.apiKey).addOrUpdateMetadata(n, e, t, s);
1031
+ function pt(n, e = {}, t, s = !1) {
1032
+ const o = d();
1033
+ new fe(o.apiKey).addOrUpdateMetadata(n, e, t, s);
1667
1034
  }
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;
1035
+ let M = null;
1036
+ function Ct(n, e, t, s) {
1037
+ const o = function(...i) {
1038
+ const g = he(), r = g?.sfDebug || !1;
1039
+ r && console.log(`[FuncSpan] captureFunctionSpan wrapper called for ${t}::${e}`);
1040
+ const c = (function(m, h) {
1041
+ const Z = ue();
1042
+ if (Z) {
1043
+ const b = pe(Z);
1044
+ if (b) return process.env.SF_DEBUG === "true" && console.log(`[FuncSpan] Using HTTP header override for ${m}::${h}`), b;
1678
1045
  }
1679
1046
  try {
1680
- return bt(h, f);
1047
+ return Oe(m, h);
1681
1048
  } catch {
1682
1049
  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
1050
  }
1684
1051
  })(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)));
1052
+ 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`), n.apply(this, i);
1053
+ if (c.sample_rate === 0) return r && console.log(`[FuncSpan] Skipping ${e} - sample_rate is 0.0`), n.apply(this, i);
1054
+ r && console.log(`[FuncSpan] Capturing function span for ${e}`);
1055
+ const a = N.getInstance(), l = a.getCurrentFunctionSpanId(), I = Ce();
1056
+ a.setCurrentFunctionSpanId(I);
1057
+ const p = process.hrtime.bigint(), C = Date.now();
1058
+ let u = null;
1059
+ c.capture_arguments && (u = {}, s.paramNames.forEach((m, h) => {
1060
+ h < i.length && (u[m] = i[h]);
1061
+ }), u && c.arg_limit_mb > 0 && (u = $(u, c.arg_limit_mb)));
1695
1062
  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;
1063
+ const m = n.apply(this, i);
1064
+ if (m && typeof m.then == "function") return l ? a.setCurrentFunctionSpanId(l) : a.clearCurrentFunctionSpanId(), m.then((f) => {
1065
+ const W = process.hrtime.bigint(), U = Date.now(), E = Number(W - p);
1066
+ let te = null;
1067
+ return c.capture_return_value && c.return_limit_mb > 0 && (te = $(f, c.return_limit_mb)), K({ functionName: e, filePath: t, metadata: s, args: u, result: te, error: null, duration: U - C, durationNs: E, startTimeNs: p.toString(), async: !0, spanId: I, parentSpanId: l, pid: process.pid, threadId: J }), f;
1068
+ }, (f) => {
1069
+ const W = process.hrtime.bigint(), U = Date.now(), E = Number(W - p);
1070
+ throw K({ functionName: e, filePath: t, metadata: s, args: u, result: null, error: f?.message || String(f), duration: U - C, durationNs: E, startTimeNs: p.toString(), async: !0, spanId: I, parentSpanId: l, pid: process.pid, threadId: J }), f;
1704
1071
  });
1705
- const f = process.hrtime.bigint(), S = Date.now(), b = Number(f - I);
1072
+ const h = process.hrtime.bigint(), Z = Date.now(), b = Number(h - p);
1706
1073
  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;
1074
+ return c.capture_return_value && c.return_limit_mb > 0 && (y = $(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;
1075
+ } catch (m) {
1076
+ const h = process.hrtime.bigint(), Z = Date.now(), b = Number(h - p);
1077
+ 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
1078
  }
1712
1079
  };
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;
1080
+ Object.defineProperty(o, "name", { value: e, writable: !1 });
1081
+ for (const i in n) n.hasOwnProperty(i) && (o[i] = n[i]);
1082
+ return o;
1716
1083
  }
1717
- function x(n) {
1718
- const e = H(), t = e?.sfDebug || !1;
1084
+ function K(n) {
1085
+ const e = he(), t = e?.sfDebug || !1;
1719
1086
  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
1087
  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 };
1721
1088
  process.env.SF_FUNCSPAN_CONSOLE_OUTPUT === "true" && console.log(`
1722
1089
  📊 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 }) + `
1090
+ const o = process.env.SF_FUNCSPAN_JSONL_FILE;
1091
+ if (o) try {
1092
+ const i = o === "true" || o === "1" ? "funcspans.jsonl" : o, g = Date.now(), r = process.hrtime.bigint(), c = BigInt(n.startTimeNs), a = Number(r - c) / 1e6, l = new Date(g - a).toISOString(), I = JSON.stringify({ timestamp: l, 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 }) + `
1726
1093
  `;
1727
- Te(a, u, "utf-8");
1728
- } catch (a) {
1729
- console.error("[FuncSpan] Error writing to JSONL file:", a);
1094
+ we(i, I, "utf-8");
1095
+ } catch (i) {
1096
+ console.error("[FuncSpan] Error writing to JSONL file:", i);
1730
1097
  }
1731
1098
  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);
1099
+ (M || (M = new Fe()), M).send([s]), t && console.log("[FuncSpan] Function span sent successfully");
1100
+ } catch (i) {
1101
+ t && console.error("[FuncSpan] Error sending function span:", i);
1735
1102
  }
1736
1103
  }
1737
1104
  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
1105
+ N as ContextManager,
1106
+ pt as addOrUpdateMetadata,
1107
+ Ct as captureFunctionSpan,
1108
+ bt as clearFuncspanOverride,
1109
+ T as getCurrentFunctionSpanId,
1110
+ ve as getDefaultConfig,
1111
+ me as getEnvConfig,
1112
+ ue as getFuncspanOverride,
1113
+ Oe as getGlobalConfig,
1114
+ ut as identify,
1115
+ xe as initializeConfigLoader,
1116
+ nt as initializeWorkerPoolPatching,
1117
+ je as isConfigLoaderInitialized,
1118
+ It as isSetupInterceptorsInitialized,
1119
+ ot as isWorkerPoolInitialized,
1120
+ pe as parseHeaderOverride,
1121
+ At as runWithContext,
1122
+ ft as setFuncspanOverride,
1123
+ dt as setupInterceptors,
1124
+ Zt as transformFunctionSpans
1757
1125
  };