@sailfish-ai/sf-veritas 0.2.1 → 0.2.3

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,54 +1,54 @@
1
- var fe = Object.defineProperty;
2
- var ye = (s, e, t) => e in s ? fe(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var u = (s, e, t) => ye(s, typeof e != "symbol" ? e + "" : e, t);
4
- import { AsyncLocalStorage as te } from "async_hooks";
5
- import * as $ from "fs";
6
- import { readFileSync as ue } from "fs";
7
- import { s as Ce } from "./source-map-Cr6YkjTd.js";
8
- import { Worker as Se } from "worker_threads";
1
+ var Se = Object.defineProperty;
2
+ var Ze = (o, e, t) => e in o ? Se(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
+ var C = (o, e, t) => Ze(o, typeof e != "symbol" ? e + "" : e, t);
4
+ import { AsyncLocalStorage as ie } from "async_hooks";
5
+ import * as k from "fs";
6
+ import { readFileSync as pe } from "fs";
7
+ import { s as he } from "./source-map-Cr6YkjTd.js";
8
+ import { Worker as Ge } from "worker_threads";
9
9
  import * as v from "path";
10
- import { glob as Ze } from "glob";
11
- const S = [];
12
- for (let s = 0; s < 256; ++s) S.push((s + 256).toString(16).slice(1));
13
- let k;
14
- const Ge = new Uint8Array(16), oe = { randomUUID: typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto) };
15
- function H(s, e, t) {
16
- if (oe.randomUUID && !s) return oe.randomUUID();
17
- const i = (s = s || {}).random ?? s.rng?.() ?? (function() {
18
- if (!k) {
10
+ import { glob as ve } from "glob";
11
+ const Z = [];
12
+ for (let o = 0; o < 256; ++o) Z.push((o + 256).toString(16).slice(1));
13
+ let O;
14
+ const Ne = new Uint8Array(16), re = { randomUUID: typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto) };
15
+ function R(o, e, t) {
16
+ if (re.randomUUID && !o) return re.randomUUID();
17
+ const n = (o = o || {}).random ?? o.rng?.() ?? (function() {
18
+ if (!O) {
19
19
  if (typeof crypto > "u" || !crypto.getRandomValues) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
20
- k = crypto.getRandomValues.bind(crypto);
20
+ O = crypto.getRandomValues.bind(crypto);
21
21
  }
22
- return k(Ge);
22
+ return O(Ne);
23
23
  })();
24
- if (i.length < 16) throw new Error("Random bytes length must be >= 16");
25
- return i[6] = 15 & i[6] | 64, i[8] = 63 & i[8] | 128, (function(n, o = 0) {
26
- return (S[n[o + 0]] + S[n[o + 1]] + S[n[o + 2]] + S[n[o + 3]] + "-" + S[n[o + 4]] + S[n[o + 5]] + "-" + S[n[o + 6]] + S[n[o + 7]] + "-" + S[n[o + 8]] + S[n[o + 9]] + "-" + S[n[o + 10]] + S[n[o + 11]] + S[n[o + 12]] + S[n[o + 13]] + S[n[o + 14]] + S[n[o + 15]]).toLowerCase();
27
- })(i);
24
+ if (n.length < 16) throw new Error("Random bytes length must be >= 16");
25
+ return n[6] = 15 & n[6] | 64, n[8] = 63 & n[8] | 128, (function(i, s = 0) {
26
+ return (Z[i[s + 0]] + Z[i[s + 1]] + Z[i[s + 2]] + Z[i[s + 3]] + "-" + Z[i[s + 4]] + Z[i[s + 5]] + "-" + Z[i[s + 6]] + Z[i[s + 7]] + "-" + Z[i[s + 8]] + Z[i[s + 9]] + "-" + Z[i[s + 10]] + Z[i[s + 11]] + Z[i[s + 12]] + Z[i[s + 13]] + Z[i[s + 14]] + Z[i[s + 15]]).toLowerCase();
27
+ })(n);
28
28
  }
29
- class ve {
29
+ class Be {
30
30
  constructor(e) {
31
- u(this, "apiKey");
32
- u(this, "apiGraphqlEndpoint");
33
- u(this, "sfDebug");
34
- u(this, "serviceIdentifier");
35
- u(this, "serviceVersion");
36
- u(this, "serviceUUID");
37
- u(this, "serviceAdditionalMetadata");
38
- u(this, "profilingModeEnabled");
39
- u(this, "profilingMaxDepth");
40
- u(this, "profilingMaxVariableSizeKb");
41
- u(this, "domainsToNotPropagateHeadersTo");
42
- u(this, "nodeModulesToCollectLocalVariablesOn");
43
- u(this, "printConfigurationStatuses");
44
- u(this, "logLevel");
45
- u(this, "stackDepthLocals");
46
- u(this, "stackDepthCodeTraceDepth");
47
- u(this, "packageLibraryType");
48
- u(this, "version");
49
- u(this, "gitSha");
50
- u(this, "_serviceIdentificationReceived", !1);
51
- this.apiKey = e.apiKey, this.apiGraphqlEndpoint = e?.apiGraphqlEndpoint || process.env.SAILFISH_GRAPHQL_ENDPOINT || "https://api-service.sailfishqa.com/graphql/", this.sfDebug = e?.debug === !0 || process.env.SF_DEBUG === "true", this.serviceIdentifier = e?.serviceIdentifier || process.env.SERVICE_IDENTIFIER, this.serviceUUID = H(), this.serviceVersion = e?.serviceVersion || process.env.SERVICE_VERSION, this.gitSha = e?.gitSha || process.env.GIT_SHA || process.env.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();
31
+ C(this, "apiKey");
32
+ C(this, "apiGraphqlEndpoint");
33
+ C(this, "sfDebug");
34
+ C(this, "serviceIdentifier");
35
+ C(this, "serviceVersion");
36
+ C(this, "serviceUUID");
37
+ C(this, "serviceAdditionalMetadata");
38
+ C(this, "profilingModeEnabled");
39
+ C(this, "profilingMaxDepth");
40
+ C(this, "profilingMaxVariableSizeKb");
41
+ C(this, "domainsToNotPropagateHeadersTo");
42
+ C(this, "nodeModulesToCollectLocalVariablesOn");
43
+ C(this, "printConfigurationStatuses");
44
+ C(this, "logLevel");
45
+ C(this, "stackDepthLocals");
46
+ C(this, "stackDepthCodeTraceDepth");
47
+ C(this, "packageLibraryType");
48
+ C(this, "version");
49
+ C(this, "gitSha");
50
+ C(this, "_serviceIdentificationReceived", !1);
51
+ 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 = R(), 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();
52
52
  }
53
53
  getPackageVersion() {
54
54
  return "0.1.15";
@@ -60,64 +60,64 @@ class ve {
60
60
  this._serviceIdentificationReceived = e;
61
61
  }
62
62
  }
63
- const pe = Symbol.for("sailfish.sf_config");
64
- function he() {
65
- return globalThis[pe];
63
+ const me = Symbol.for("sailfish.sf_config");
64
+ function z() {
65
+ return globalThis[me];
66
66
  }
67
- function Be(s) {
68
- const e = he();
67
+ function We(o) {
68
+ const e = z();
69
69
  if (e) return { config: e };
70
- const t = new ve(s);
71
- return (function(i) {
72
- globalThis[pe] = i;
70
+ const t = new Be(o);
71
+ return (function(n) {
72
+ globalThis[me] = n;
73
73
  })(t), t.sfDebug && console.log("[[getOrCreateConfig]] Created global config:", t), { config: t };
74
74
  }
75
75
  function l() {
76
- const s = he();
77
- if (!s) throw new Error("Configuration has not been initialized. Call getOrCreateConfig(options) first.");
78
- return s;
76
+ const o = z();
77
+ if (!o) throw new Error("Configuration has not been initialized. Call getOrCreateConfig(options) first.");
78
+ return o;
79
79
  }
80
- const se = Symbol.for("sf.ctx.storeAls"), W = globalThis, O = W[se] ?? (W[se] = new te()), Ae = ["identitytoolkit.googleapis.com", "t.co", "*.twitter.com", "*.gravatar.com", "*.googleapis.com", "*.amazonaws.com", "*.smooch.io", "*.zendesk.com"], re = Symbol.for("sf.ctx.als"), U = W[re] ?? (W[re] = new te()), ae = Symbol.for("sf.ctx.sessionRegistry"), Y = W[ae] ?? (W[ae] = /* @__PURE__ */ new Map()), _ = { handledExceptions: /* @__PURE__ */ new Set(), reentrancyGuardLoggingActive: !1, reentrancyGuardLoggingPreActive: !1, reentrancyGuardPrintActive: !1, reentrancyGuardPrintPreActive: !1, reentrancyGuardExceptionActive: !1, reentrancyGuardExceptionPreActive: !1, excludedDomains: new Set(Ae), supportedDomains: /* @__PURE__ */ new Set() }, V = class V {
80
+ const ae = Symbol.for("sf.ctx.storeAls"), W = globalThis, P = W[ae] ?? (W[ae] = new ie()), Ae = ["identitytoolkit.googleapis.com", "t.co", "*.twitter.com", "*.gravatar.com", "*.googleapis.com", "*.amazonaws.com", "*.smooch.io", "*.zendesk.com"], ce = Symbol.for("sf.ctx.als"), K = W[ce] ?? (W[ce] = new ie()), ge = Symbol.for("sf.ctx.sessionRegistry"), Y = W[ge] ?? (W[ge] = /* @__PURE__ */ new Map()), E = { handledExceptions: /* @__PURE__ */ new Set(), reentrancyGuardLoggingActive: !1, reentrancyGuardLoggingPreActive: !1, reentrancyGuardPrintActive: !1, reentrancyGuardPrintPreActive: !1, reentrancyGuardExceptionActive: !1, reentrancyGuardExceptionPreActive: !1, excludedDomains: new Set(Ae), supportedDomains: /* @__PURE__ */ new Set() }, V = class V {
81
81
  constructor() {
82
82
  }
83
83
  current() {
84
- return O.getStore();
84
+ return P.getStore();
85
85
  }
86
86
  ensureStore() {
87
87
  const e = this.current();
88
88
  if (e) return e;
89
89
  const t = /* @__PURE__ */ new Map();
90
- return O.enterWith(t), t;
90
+ return P.enterWith(t), t;
91
91
  }
92
92
  runWith(e, t) {
93
- const i = this.current() ?? /* @__PURE__ */ new Map(), n = new Map(i);
94
- for (const [o, a] of Object.entries(e)) n.set(o, a);
95
- return O.run(n, t);
93
+ const n = this.current() ?? /* @__PURE__ */ new Map(), i = new Map(n);
94
+ for (const [s, g] of Object.entries(e)) i.set(s, g);
95
+ return P.run(i, t);
96
96
  }
97
97
  static getInstance() {
98
98
  return W[V.GLOBAL_MANAGER_SYMBOL] || (W[V.GLOBAL_MANAGER_SYMBOL] = new V()), W[V.GLOBAL_MANAGER_SYMBOL];
99
99
  }
100
100
  getCurrentContext() {
101
- return U.getStore() || _;
101
+ return K.getStore() || E;
102
102
  }
103
103
  setCurrentContext(e) {
104
- const t = U.getStore() || _;
105
- U.enterWith({ ...t, ...e });
104
+ const t = K.getStore() || E;
105
+ K.enterWith({ ...t, ...e });
106
106
  }
107
107
  ensureSession(e) {
108
108
  let t = Y.get(e);
109
- return t || (t = { ..._ }, Y.set(e, t)), t;
109
+ return t || (t = { ...E }, Y.set(e, t)), t;
110
110
  }
111
111
  getContextFor(e) {
112
- return Y.get(e) ?? _;
112
+ return Y.get(e) ?? E;
113
113
  }
114
114
  updateContextFor(e, t) {
115
- const i = this.ensureSession(e);
116
- Y.set(e, { ...i, ...t });
115
+ const n = this.ensureSession(e);
116
+ Y.set(e, { ...n, ...t });
117
117
  }
118
118
  runWithSession(e, t) {
119
- const i = { ...this.ensureSession(e) };
120
- return U.run(i, t);
119
+ const n = { ...this.ensureSession(e) };
120
+ return K.run(n, t);
121
121
  }
122
122
  deleteSession(e) {
123
123
  Y.delete(e);
@@ -144,12 +144,12 @@ const se = Symbol.for("sf.ctx.storeAls"), W = globalThis, O = W[se] ?? (W[se] =
144
144
  this.setCurrentContext({ currentFunctionSpanId: void 0 });
145
145
  }
146
146
  getOrSetSfTraceId(e, t = !1) {
147
- let i = this.getTraceId();
148
- return i || (i = e || (t ? H() : `nonsession-applogs-v3/${l().apiKey}/${H()}`), this.setTraceId(i), l().sfDebug && console.log(" Created new trace ID:", i), i);
147
+ let n = this.getTraceId();
148
+ return n || (n = e || (t ? R() : `nonsession-applogs-v3/${l().apiKey}/${R()}`), this.setTraceId(n), l().sfDebug && console.log(" Created new trace ID:", n), n);
149
149
  }
150
150
  getOrSetPageVisitUUID() {
151
151
  let e = this.getPageVisitUUID();
152
- return e || (e = H(), this.setPageVisitUUID(e), l().sfDebug && console.log(" Created new page visit UUID:", e), e);
152
+ return e || (e = R(), this.setPageVisitUUID(e), l().sfDebug && console.log(" Created new page visit UUID:", e), e);
153
153
  }
154
154
  getHandledExceptions() {
155
155
  return this.getCurrentContext().handledExceptions;
@@ -180,33 +180,33 @@ const se = Symbol.for("sf.ctx.storeAls"), W = globalThis, O = W[se] ?? (W[se] =
180
180
  this.updateContextFor(e, { pageVisitUUID: t });
181
181
  }
182
182
  };
183
- u(V, "GLOBAL_MANAGER_SYMBOL", Symbol.for("sf.ctx.manager"));
183
+ C(V, "GLOBAL_MANAGER_SYMBOL", Symbol.for("sf.ctx.manager"));
184
184
  let G = V;
185
- function Ne(s) {
185
+ function it(o) {
186
186
  const e = { ...G.getInstance().getCurrentContext() };
187
- U.run(e, () => {
188
- s();
187
+ K.run(e, () => {
188
+ o();
189
189
  });
190
190
  }
191
- function P() {
191
+ function M() {
192
192
  return G.getInstance().getCurrentFunctionSpanId();
193
193
  }
194
- class R {
194
+ class w {
195
195
  constructor() {
196
- u(this, "apiKey");
197
- u(this, "endpoint");
198
- u(this, "queryType", "mutation");
199
- u(this, "operationName", "");
200
- u(this, "serviceUUID", l().serviceUUID);
201
- u(this, "contextManager");
196
+ C(this, "apiKey");
197
+ C(this, "endpoint");
198
+ C(this, "queryType", "mutation");
199
+ C(this, "operationName", "");
200
+ C(this, "serviceUUID", l().serviceUUID);
201
+ C(this, "contextManager");
202
202
  this.apiKey = l().apiKey, this.endpoint = l().apiGraphqlEndpoint, this.contextManager = G.getInstance();
203
203
  }
204
204
  get queryName() {
205
205
  return this.operationName ? this.operationName.charAt(0).toLowerCase() + this.operationName.slice(1) : "";
206
206
  }
207
207
  getDefaultVariables() {
208
- const e = Date.now().toString(), t = this.contextManager.getOrSetSfTraceId(), i = this.contextManager.getCurrentFunctionSpanId();
209
- return { apiKey: this.apiKey, serviceUuid: this.serviceUUID, sessionId: t, timestampMs: e, parentSpanId: i };
208
+ const e = Date.now().toString(), t = this.contextManager.getOrSetSfTraceId(), n = this.contextManager.getCurrentFunctionSpanId();
209
+ return { apiKey: this.apiKey, serviceUuid: this.serviceUUID, sessionId: t, timestampMs: e, parentSpanId: n };
210
210
  }
211
211
  getVariables(e = {}) {
212
212
  return { ...this.getDefaultVariables(), ...e };
@@ -221,34 +221,34 @@ class R {
221
221
  this.serviceUUID = e;
222
222
  }
223
223
  }
224
- const We = fetch;
225
- async function F(s, e, t, i) {
224
+ const Fe = fetch;
225
+ async function F(o, e, t, n) {
226
226
  try {
227
- const n = l();
228
- let o;
227
+ const i = l();
228
+ let s;
229
229
  try {
230
- o = JSON.stringify({ query: t, variables: i, operationName: e });
230
+ s = JSON.stringify({ query: t, variables: n, operationName: e });
231
231
  } catch {
232
- o = JSON.stringify({ query: t, operationName: e });
232
+ s = JSON.stringify({ query: t, operationName: e });
233
233
  }
234
- We(s, { method: "POST", headers: { "Content-Type": "application/json" }, body: o }).then(async (a) => {
235
- if (!a.ok) return void (n.sfDebug && console.error(`GraphQL request failed with status ${a.status} for ${e}`));
236
- const r = await a.json();
237
- r.errors?.length ? (function(g, c, I) {
238
- const d = g && typeof g == "object" && !Array.isArray(g) ? Object.keys(g)[0] : void 0;
239
- console.error(d === "identifyServiceDetails" ? `IdentifyServiceDetails NOT sent successfully for service: UUID=${I.serviceUUID}` : `GraphQL request failed with errors: ${JSON.stringify(c)} for operation key ${d}`);
240
- })(r.data, r.errors, n) : n.sfDebug && (function(g, c, I) {
241
- const d = g && typeof g == "object" && !Array.isArray(g) ? Object.keys(g)[0] : void 0, C = g[d] || !1;
242
- d === "identifyServiceDetails" && (I.setServiceIdentificationReceived(C), l().sfDebug && console.log(`IdentifyServiceDetails sent successfully for service: UUID=${I.serviceUUID}; serviceIdentificationReceived=${d === "identifyServiceDetails" ? C : "N/A"}`));
243
- })(r.data, 0, n);
244
- }).catch((a) => {
245
- n.sfDebug && console.error("Fetch error:", a);
234
+ Fe(o, { method: "POST", headers: { "Content-Type": "application/json" }, body: s }).then(async (g) => {
235
+ if (!g.ok) return void (i.sfDebug && console.error(`GraphQL request failed with status ${g.status} for ${e}`));
236
+ const r = await g.json();
237
+ r.errors?.length ? (function(a, c, d) {
238
+ const I = a && typeof a == "object" && !Array.isArray(a) ? Object.keys(a)[0] : void 0;
239
+ console.error(I === "identifyServiceDetails" ? `IdentifyServiceDetails NOT sent successfully for service: UUID=${d.serviceUUID}` : `GraphQL request failed with errors: ${JSON.stringify(c)} for operation key ${I}`);
240
+ })(r.data, r.errors, i) : i.sfDebug && (function(a, c, d) {
241
+ const I = a && typeof a == "object" && !Array.isArray(a) ? Object.keys(a)[0] : void 0, h = a[I] || !1;
242
+ I === "identifyServiceDetails" && (d.setServiceIdentificationReceived(h), l().sfDebug && console.log(`IdentifyServiceDetails sent successfully for service: UUID=${d.serviceUUID}; serviceIdentificationReceived=${I === "identifyServiceDetails" ? h : "N/A"}`));
243
+ })(r.data, 0, i);
244
+ }).catch((g) => {
245
+ i.sfDebug && (console.error(`[RequestUtils] Fetch error for ${e} to ${o}:`, g), g.cause && console.error("[RequestUtils] Error cause:", g.cause));
246
246
  });
247
- } catch (n) {
248
- l().sfDebug && console.error("Error sending data to GraphQL server:", n);
247
+ } catch (i) {
248
+ l().sfDebug && console.error("Error sending data to GraphQL server:", i);
249
249
  }
250
250
  }
251
- class T extends R {
251
+ class X extends w {
252
252
  constructor() {
253
253
  super(), this.setOperationName("IdentifyServiceDetails");
254
254
  }
@@ -288,37 +288,37 @@ class T extends R {
288
288
  F(this.endpoint, this.operationName, e, t);
289
289
  }
290
290
  }
291
- function Fe(s) {
291
+ function Ve(o) {
292
292
  try {
293
- return JSON.stringify(s), !0;
293
+ return JSON.stringify(o), !0;
294
294
  } catch {
295
295
  return !1;
296
296
  }
297
297
  }
298
- class Ve extends R {
298
+ class we extends w {
299
299
  constructor() {
300
300
  super();
301
- u(this, "serviceIdentifier", new T());
301
+ C(this, "serviceIdentifier", new X());
302
302
  this.setOperationName("CollectMetadata");
303
303
  }
304
304
  async sendAppIdentifier() {
305
305
  this.serviceIdentifier.doSend({});
306
306
  }
307
- async doSend(t, i, n, o) {
308
- this.sendAppIdentifier(), this.send(t, i, n, o);
309
- }
310
- async send(t, i, n, o) {
311
- if (!i && !o) throw new Error('Must pass in either traits or traits_json to "add_or_update_traits"');
312
- let a = [];
313
- if (!o) {
314
- const g = (function(c) {
315
- const I = {}, d = [];
316
- if (c) for (const [C, p] of Object.entries(c)) Fe(p) ? I[C] = p : d.push(C);
317
- return { traitsJson: JSON.stringify(I), excludedFields: d };
318
- })(i);
319
- o = g.traitsJson, a = g.excludedFields;
307
+ async doSend(t, n, i, s) {
308
+ this.sendAppIdentifier(), this.send(t, n, i, s);
309
+ }
310
+ async send(t, n, i, s) {
311
+ if (!n && !s) throw new Error('Must pass in either traits or traits_json to "add_or_update_traits"');
312
+ let g = [];
313
+ if (!s) {
314
+ const a = (function(c) {
315
+ const d = {}, I = [];
316
+ if (c) for (const [h, p] of Object.entries(c)) Ve(p) ? d[h] = p : I.push(h);
317
+ return { traitsJson: JSON.stringify(d), excludedFields: I };
318
+ })(n);
319
+ s = a.traitsJson, g = a.excludedFields;
320
320
  }
321
- const r = this.getVariables({ userId: t, traitsJson: o, excludedFields: a, override: n, library: l().packageLibraryType, version: l().version });
321
+ const r = this.getVariables({ userId: t, traitsJson: s, excludedFields: g, override: i, library: l().packageLibraryType, version: l().version });
322
322
  F(this.endpoint, this.operationName, this.getQuery(), r);
323
323
  }
324
324
  getQuery() {
@@ -329,23 +329,23 @@ class Ve extends R {
329
329
  `;
330
330
  }
331
331
  }
332
- class me {
332
+ class be {
333
333
  constructor(e) {
334
- u(this, "metadataTransmitter");
335
- this.apiKey = e, this.metadataTransmitter = new Ve();
334
+ C(this, "metadataTransmitter");
335
+ this.apiKey = e, this.metadataTransmitter = new we();
336
336
  }
337
- identify(e, t, i, n = !1) {
338
- t || i ? this.addOrUpdateMetadata(e, t, i, n) : this.addOrUpdateMetadata(e, {}, void 0, n);
337
+ identify(e, t, n, i = !1) {
338
+ t || n ? this.addOrUpdateMetadata(e, t, n, i) : this.addOrUpdateMetadata(e, {}, void 0, i);
339
339
  }
340
- addOrUpdateMetadata(e, t = {}, i, n = !1) {
341
- if (!t && !i) throw new Error('Must pass in either traits or traitsJson to "addOrUpdateMetadata"');
342
- l().sfDebug && console.log(" [[DEBUG - addOrUpdateMetadata]] Starting operation"), l().sfDebug && console.log(" addOrUpdateMetadata...SENDING DATA...", e, t, i), this.metadataTransmitter.doSend(e, t, n, i);
340
+ addOrUpdateMetadata(e, t = {}, n, i = !1) {
341
+ if (!t && !n) throw new Error('Must pass in either traits or traitsJson to "addOrUpdateMetadata"');
342
+ l().sfDebug && console.log(" [[DEBUG - addOrUpdateMetadata]] Starting operation"), l().sfDebug && console.log(" addOrUpdateMetadata...SENDING DATA...", e, t, n), this.metadataTransmitter.doSend(e, t, i, n);
343
343
  }
344
344
  }
345
- class ne extends R {
345
+ class oe extends w {
346
346
  constructor() {
347
347
  super();
348
- u(this, "serviceIdentifier", new T());
348
+ C(this, "serviceIdentifier", new X());
349
349
  }
350
350
  async sendAppIdentifier() {
351
351
  this.serviceIdentifier.doSend({});
@@ -355,10 +355,10 @@ class ne extends R {
355
355
  }
356
356
  async send(t) {
357
357
  try {
358
- const i = Array.isArray(t) ? t : [t, "default"], n = this.getVariables({ contents: i[0], level: i[1] });
359
- F(this.endpoint, this.operationName, this.getQuery(), n);
360
- } catch (i) {
361
- l().sfDebug && console.error("🚨 Error in send():", i);
358
+ const n = Array.isArray(t) ? t : [t, "default"], i = this.getVariables({ contents: n[0], level: n[1] });
359
+ F(this.endpoint, this.operationName, this.getQuery(), i);
360
+ } catch (n) {
361
+ l().sfDebug && console.error("🚨 Error in send():", n);
362
362
  }
363
363
  }
364
364
  getQuery() {
@@ -385,121 +385,121 @@ class ne extends R {
385
385
  `;
386
386
  }
387
387
  }
388
- const B = {};
389
- class X {
390
- constructor({ file: e, line: t, function: i, code: n, locals: o = {}, offender: a = !1, column: r }) {
391
- u(this, "file");
392
- u(this, "line");
393
- u(this, "function");
394
- u(this, "code");
395
- u(this, "locals");
396
- u(this, "offender");
397
- u(this, "column");
398
- this.file = e, this.line = t, this.function = i, this.code = n, this.locals = o, this.offender = a, this.column = r;
388
+ const N = {};
389
+ class T {
390
+ constructor({ file: e, line: t, function: n, code: i, locals: s = {}, offender: g = !1, column: r }) {
391
+ C(this, "file");
392
+ C(this, "line");
393
+ C(this, "function");
394
+ C(this, "code");
395
+ C(this, "locals");
396
+ C(this, "offender");
397
+ C(this, "column");
398
+ this.file = e, this.line = t, this.function = n, this.code = i, this.locals = s, this.offender = g, this.column = r;
399
399
  }
400
400
  toDict() {
401
- const e = { file: this.file, line: this.line, function: this.function, code: this.code, locals: Object.fromEntries(Object.entries(this.locals).map(([t, i]) => [t, String(i)])) };
401
+ const e = { file: this.file, line: this.line, function: this.function, code: this.code, locals: Object.fromEntries(Object.entries(this.locals).map(([t, n]) => [t, String(n)])) };
402
402
  return this.offender && (e.offender = this.offender), this.column !== void 0 && (e.column = this.column), e;
403
403
  }
404
404
  toJson() {
405
405
  return JSON.stringify(this.toDict());
406
406
  }
407
407
  }
408
- class z {
408
+ class L {
409
409
  static encode(e) {
410
- return e instanceof X ? e.toDict() : Array.isArray(e) ? e.map((t) => z.encode(t)) : typeof e == "object" && e !== null ? JSON.stringify(e) : e;
410
+ return e instanceof T ? e.toDict() : Array.isArray(e) ? e.map((t) => L.encode(t)) : typeof e == "object" && e !== null ? JSON.stringify(e) : e;
411
411
  }
412
412
  static stringify(e) {
413
- return JSON.stringify(z.encode(e), (t, i) => i instanceof X ? i.toDict() : i);
413
+ return JSON.stringify(L.encode(e), (t, n) => n instanceof T ? n.toDict() : n);
414
414
  }
415
415
  }
416
- let N, K = 0;
417
- function we(s) {
416
+ let B, U = 0;
417
+ function He(o) {
418
418
  l().sfDebug && console.log("Initializing Exception Interceptor...");
419
419
  try {
420
420
  const r = (function() {
421
- if (N !== void 0) return N;
422
- const g = process.env || {}, c = le(g.SF_IS_LOCAL);
423
- if (c !== void 0) return N = c;
424
- const I = (g.SF_ENV || g.NODE_ENV || "").toLowerCase();
425
- if (["local", "dev", "development"].includes(I)) return N = !0;
426
- 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((C) => !!g[C])) return N = !1;
427
- const d = (B.hostname?.() || g.HOSTNAME || "").toLowerCase();
428
- return d === "localhost" || d.endsWith(".local") || d.includes("local") ? N = !0 : N = !1;
421
+ if (B !== void 0) return B;
422
+ const a = process.env || {}, c = Ie(a.SF_IS_LOCAL);
423
+ if (c !== void 0) return B = c;
424
+ const d = (a.SF_ENV || a.NODE_ENV || "").toLowerCase();
425
+ if (["local", "dev", "development"].includes(d)) return B = !0;
426
+ 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((h) => !!a[h])) return B = !1;
427
+ const I = (N.hostname?.() || a.HOSTNAME || "").toLowerCase();
428
+ return I === "localhost" || I.endsWith(".local") || I.includes("local") ? B = !0 : B = !1;
429
429
  })();
430
- s?.setSupplementalFields?.({ isFromLocalService: r }), (async function(g) {
431
- if (ge) return;
432
- ge = !0;
430
+ o?.setSupplementalFields?.({ isFromLocalService: r }), (async function(a) {
431
+ if (de) return;
432
+ de = !0;
433
433
  const c = process.env || {};
434
- if (le(c.SF_IS_LOCAL) === void 0)
434
+ if (Ie(c.SF_IS_LOCAL) === void 0)
435
435
  try {
436
- await (async function(I) {
437
- const d = M("http://169.254.169.254/latest/meta-data/", {}, I), C = M("http://metadata.google.internal/computeMetadata/v1/instance/", { "Metadata-Flavor": "Google" }, I), p = M("http://169.254.169.254/metadata/instance?api-version=2021-02-01", { Metadata: "true" }, I);
438
- return (await Promise.allSettled([d, C, p])).some((h) => h.status === "fulfilled" && (h.value === "ok" || h.value === "http_error"));
439
- })(150) && N && (N = !1, g?.setSupplementalFields?.({ isFromLocalService: !1 }));
436
+ await (async function(d) {
437
+ const I = j("http://169.254.169.254/latest/meta-data/", {}, d), h = j("http://metadata.google.internal/computeMetadata/v1/instance/", { "Metadata-Flavor": "Google" }, d), p = j("http://169.254.169.254/metadata/instance?api-version=2021-02-01", { Metadata: "true" }, d);
438
+ return (await Promise.allSettled([I, h, p])).some((u) => u.status === "fulfilled" && (u.value === "ok" || u.value === "http_error"));
439
+ })(150) && B && (B = !1, a?.setSupplementalFields?.({ isFromLocalService: !1 }));
440
440
  } catch {
441
441
  }
442
- })(s).catch(() => {
442
+ })(o).catch(() => {
443
443
  });
444
444
  } catch {
445
445
  }
446
- const e = new Se(new URL("data:application/javascript;base64,aW1wb3J0IHsgU2Vzc2lvbiB9IGZyb20gImluc3BlY3Rvci9wcm9taXNlcyI7CmltcG9ydCB7IHBhcmVudFBvcnQsIHdvcmtlckRhdGEgfSBmcm9tICJ3b3JrZXJfdGhyZWFkcyI7CgpnbG9iYWwuc2ZEZWJ1ZyA9IHVuZGVmaW5lZDsKZ2xvYmFsLnN0YWNrRGVwdGhMb2NhbHMgPSB1bmRlZmluZWQ7Cmdsb2JhbC5ub2RlTW9kdWxlc1RvQ29sbGVjdExvY2FsVmFyaWFibGVzT24gPSB1bmRlZmluZWQ7CgovKioKICogUHJvY2Vzc2VzIGNhbGwgZnJhbWVzIGZyb20gYW4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WQsCiAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgKTsKICAgICAgICAgICAgY29uc3Qgc291cmNlTGluZXMgPSBzY3JpcHRTb3VyY2Uuc3BsaXQoIlxuIik7CiAgICAgICAgICAgIGNvZGUgPSBzb3VyY2VMaW5lc1tsb2NhdGlvbi5saW5lTnVtYmVyXSB8fCAiPG5vdCBjYXB0dXJlZD4iOwogICAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBmZXRjaCBzY3JpcHQgc291cmNlOiIsIGVycik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIC8vIEZldGNoIGxvY2FsIHZhcmlhYmxlcyBpZiB0aGVyZSdzIGFuIG9iamVjdElkCiAgICAgICAgY29uc3QgbG9jYWxzID0gbG9jYWxTY29wZT8ub2JqZWN0Py5vYmplY3RJZAogICAgICAgICAgPyBhd2FpdCBmZXRjaExvY2FsVmFyaWFibGVzKHNlc3Npb24sIGxvY2FsU2NvcGUub2JqZWN0Lm9iamVjdElkKQogICAgICAgICAgOiB7fTsKCiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGZ1bmN0aW9uOiBmdW5jdGlvbk5hbWUgfHwgIjxhbm9ueW1vdXM+IiwKICAgICAgICAgIGxvY2FscywKICAgICAgICAgIGZpbGUsCiAgICAgICAgICBsaW5lOiBsb2NhdGlvbj8ubGluZU51bWJlciB8fCAwLAogICAgICAgICAgY29kZSwKICAgICAgICB9OwogICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgY29uc29sZS5lcnJvcigiW1dvcmtlcl0gRXJyb3IgcHJvY2Vzc2luZyBjYWxsIGZyYW1lOiIsIGVycm9yKTsKICAgICAgICB9CiAgICAgICAg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jbHVkZXMoYCR7bW9kdWxlTmFtZX1gKSwKICAgICAgICApOwoKICAgICAgICBpZiAoIWlzRnJvbUFsbG93ZWROb2RlTW9kdWxlKSB7CiAgICAgICAgICAvLyBOb3QgZnJvbSBhbiBhbGxvd2VkIG5vZGUgbW9kdWxlID0+IHJldHVybiBlYXJseQogICAgICAgICAgaWYgKGdsb2JhbC5zZkRlYnVnKSB7CiAgICAgICAgICAgIGNvbnNvbGUubG9nKAogICAgICAgICAgICAgICJbV29ya2VyXSBFcnJvciBhcHBlYXJzIHRvIGJlIHRyaWdnZXJlZCBmcm9tIG5vbi1hcHBsaWNhdGlvbiBzb3VyY2VzOyBpZ25vcmluZy4iLAogICAgICAgICAgICApOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICAvLyBPdGhlcndpc2UsIGl0J3MgZnJvbSBhbiBhbGxvd2VkIG5vZGUgbW9kdWxlLCBzbyBjb250aW51ZQogICAgICB9IGVsc2UgewogICAgICAgIC8vIElmIHRoZSBsaXN0IGlzIGVtcHR5LCBwcmVzZXJ2ZSBleGlzdGluZyBiZWhhdmlvciBhbmQgaWdub3JlIG5vbi1hcHBsaWNhdGlvbiBlcnJvcnMKICAgICAgICBpZiAoZ2xvYmFsLnNmRGVidWcpIHsKICAgICAgICAgIGNvbnNvbGUubG9nKAogICAgICAgICAgICAiW1dvcmtlcl0gRXJyb3IgYXBwZWFycyB0byBiZSB0cmlnZ2VyZWQgZnJvbSBub24tYXBwbGljYXRpb24gc291cmNlczsgaWdub3JpbmcuIiwKICAgICAgICAgICk7CiAgICAgICAgfQogICAgICAgIHJldHVybjsKICAgICAgfQogICAgfQoKICAgIC8vIElmIHdlIHJlYWNoIHRoaXMgcG9pbnQsIHRoZSBlcnJvciBpcyBlaXRoZXIgZnJvbSBhcHAgY29kZSwgb3IgZnJvbSBhIG5vZGUgbW9kdWxlIGFsbG93ZWQgYnkgdGhlIGxpc3QKICAgIC8vID0+IFByb2NlZWQ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wdGlvbkxpbmVzW2luZGV4XSkgewogICAgICAgICAgZmlsZSA9IGRlc2NyaXB0aW9uTGluZXNbaW5kZXhdLnRyaW0oKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZmlsZSA9ICI8dW5rbm93bj4iOwogICAgICAgIH0KCiAgICAgICAgLy8gSWYgd2UgaGF2ZSBhIHZhbGlkIGxvY2F0aW9uIGFuZCBzY3JpcHRJZCwgZmV0Y2ggdGhlIGNvZGUgbGluZQogICAgICAgIGlmIChsb2NhdGlvbiAmJiBsb2NhdGlvbi5zY3JpcHRJZCkgewogICAgICAgICAgY29uc3Qgc2NyaXB0SWQgPSBsb2NhdGlvbi5zY3JpcHRJZDsKICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgIGNvbnN0IHsgc2NyaXB0U291cmNlIH0gPSBhd2FpdCBzZXNzaW9uLnBvc3QoCiAgICAgICAgICAgICAgIkRlYnVnZ2VyLmdldFNjcmlwdFNvdXJjZSIsCiAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgc2NyaXB0SWQsCiAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgKTsKICAgICAgICAgICAgY29uc3Qgc291cmNlTGluZXMgPSBzY3JpcHRTb3VyY2Uuc3BsaXQoIlxuIik7CiAgICAgICAgICAgIGNvZGUgPSBzb3VyY2VMaW5lc1tsb2NhdGlvbi5saW5lTnVtYmVyXSB8fCAiPG5vdCBjYXB0dXJlZD4iOwogICAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBmZXRjaCBzY3JpcHQgc291cmNlOiIsIGVycik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIC8vIEZldGNoIGxvY2FsIHZhcmlhYmxlcyBpZiB0aGVyZSdzIGFuIG9iamVjdElkCiAgICAgICAgY29uc3QgbG9jYWxzID0gbG9jYWxTY29wZT8ub2JqZWN0Py5vYmplY3RJZAogICAgICAgICAgPyBhd2FpdCBmZXRjaExvY2FsVmFyaWFibGVzKHNlc3Npb24sIGxvY2FsU2NvcGUub2JqZWN0Lm9iamVjdElkKQogICAgICAgICAgOiB7fTsKCiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGZ1bmN0aW9uOiBmdW5jdGlvbk5hbWUgfHwgIjxhbm9ueW1vdXM+IiwKICAgICAgICAgIGxvY2FscywKICAgICAgICAgIGZpbGUsCiAgICAgICAgICBsaW5lOiBsb2NhdGlvbj8ubGluZU51bWJlciB8fCAwLAogICAgICAgICAgY29kZSwKICAgICAgICB9OwogICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgY29uc29sZS5lcnJvcigiW1dvcmtlcl0gRXJyb3IgcHJvY2Vzc2luZyBjYWxsIGZyYW1lOiIsIGVycm9yKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGZ1bmN0aW9uOiAiPGVycm9yPiIsCiAgICAgICAgICBsb2NhbHM6IHt9LAogICAgICAgICAgZmlsZTogIjx1bmtub3duPiIsCiAgICAgICAgICBsaW5lOiAwLAogICAgICAgICAgY29kZTogIjxub3QgY2FwdHVyZWQ+IiwKICAgICAgICB9OwogICAgICB9CiAgICB9KSwKICApOwogIC8vIFBvc3QgZXhjZXB0aW9uIGRhdGEKICBwYXJlbnRQb3J0Py5wb3N0TWVzc2FnZSh7IHR5cGU6ICJleGNlcHRpb24iLCBmcmFtZXMgfSk7Cn0KCi8qKgogKiBIYW5kbGVzIHRoZSAicGF1c2VkIiBzdGF0ZSBvZiB0aGUgZGVidWdnZXIgYW5kIHByb2Nlc3NlcyBleGNlcHRpb25zIG9yIHByb21pc2UgcmVqZWN0aW9ucy4KICogQHBhcmFtIHtTZXNzaW9ufSBzZXNzaW9uIC0gVGhl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ICAgICBjb25zdCBpZCA9IHByb3AudmFsdWUub2JqZWN0SWQ7CiAgICAgICAgICBhd2FpdCB1bnJvbGxPYmplY3Qoc2Vzc2lvbiwgaWQsIHByb3AubmFtZSwgdmFyaWFibGVzKTsKICAgICAgICB9IGVsc2UgaWYgKHByb3A/LnZhbHVlKSB7CiAgICAgICAgICB1bnJvbGxPdGhlcihwcm9wLCB2YXJpYWJsZXMpOwogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4gdmFyaWFibGVzOwogICAgfQogIH0gY2F0Y2ggKGVycikgewogICAgaWYgKGdsb2JhbC5zZkRlYnVnKSB7CiAgICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBmZXRjaCBsb2NhbCB2YXJpYWJsZXM6IiwgZXJyKTsKICAgIH0KICAgIHJldHVybiB7fTsKICB9Cn0KCnN0YXJ0RGVidWdnZXIoKS5jYXRjaCgoZXJyb3IpID0+IHsKICBpZiAoZ2xvYmFsLnNmRGVidWcpIHsKICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBzdGFydCBkZWJ1Z2dlcjoiLCBlcnJvcik7CiAgfQp9KTsKCi8vIEtlZXAgdGhlIHdvcmtlciBhbGl2ZQpzZXRJbnRlcnZhbCgoKSA9PiB7fSwgMTAwMDApOwo="), { workerData: { captureAllExceptions: !0 } });
447
447
  let t = null;
448
- const i = /* @__PURE__ */ new WeakMap();
448
+ const n = /* @__PURE__ */ new WeakMap();
449
449
  e.on("message", (r) => {
450
450
  if (typeof r == "string" && l().sfDebug && console.log(`[Worker] ${r}`), r.readyToGetParameters && e.postMessage({ sfDebug: l().sfDebug, stackDepthLocals: l().stackDepthLocals, nodeModulesToCollectLocalVariablesOn: l().nodeModulesToCollectLocalVariablesOn }), r.type === "exception") {
451
- const { frames: g } = r, c = t;
451
+ const { frames: a } = r, c = t;
452
452
  if (!c) return;
453
- const I = i.get(c), d = (function(p) {
453
+ const d = n.get(c), I = (function(p) {
454
454
  return p ? p.split(`
455
- `).slice(1).map((h) => {
456
- const A = /at (.+?) \((.+):(\d+):(\d+)\)/.exec(h) || /at (.+):(\d+):(\d+)/.exec(h);
457
- if (A) {
458
- const [, b, Z, f, m] = A;
459
- return new X({ function: b || "<anonymous>", locals: {}, file: Z || "<unknown>", line: parseInt(f, 10) || 0, code: "<not captured>", column: parseInt(m) || 0 });
455
+ `).slice(1).map((u) => {
456
+ const m = /at (.+?) \((.+):(\d+):(\d+)\)/.exec(u) || /at (.+):(\d+):(\d+)/.exec(u);
457
+ if (m) {
458
+ const [, A, y, b, f] = m;
459
+ return new T({ function: A || "<anonymous>", locals: {}, file: y || "<unknown>", line: parseInt(b, 10) || 0, code: "<not captured>", column: parseInt(f) || 0 });
460
460
  }
461
- return new X({ function: "<unknown>", locals: {}, file: "<unknown>", line: 0, code: "<not captured>", column: 0 });
461
+ return new T({ function: "<unknown>", locals: {}, file: "<unknown>", line: 0, code: "<not captured>", column: 0 });
462
462
  }) : [];
463
- })(c.stack), C = (function(p, h) {
464
- const A = [];
465
- let b = -1, Z = -1;
466
- for (let f = 0; f < p.length; f++) {
467
- const m = Re(p[f].file);
468
- if (Z = f, m !== "<unknown>") {
469
- for (let y = 0; y < h.length; y++) {
470
- const x = h[y];
471
- if (be(x, m) || typeof x.file == "string" && x.file.includes(m)) {
472
- b = y, K = 0, l().sfDebug && console.log(`✅ Matched Frame Found: ${m} @ Debugger Frame ${y}`);
463
+ })(c.stack), h = (function(p, u) {
464
+ const m = [];
465
+ let A = -1, y = -1;
466
+ for (let b = 0; b < p.length; b++) {
467
+ const f = Ye(p[b].file);
468
+ if (y = b, f !== "<unknown>") {
469
+ for (let S = 0; S < u.length; S++) {
470
+ const x = u[S];
471
+ if (fe(x, f) || typeof x.file == "string" && x.file.includes(f)) {
472
+ A = S, U = 0, l().sfDebug && console.log(`✅ Matched Frame Found: ${f} @ Debugger Frame ${S}`);
473
473
  break;
474
474
  }
475
475
  }
476
- if (b !== -1) break;
476
+ if (A !== -1) break;
477
477
  }
478
478
  }
479
- if (b === -1) return K === 10 ? (K = 0, p) : (++K, l().sfDebug && console.log(`"❌ No matching frame found. Checking once again, Attempt N ${K}"`), []);
480
- l().sfDebug && console.log(`🔄 Merging from matched index ${b} onward...`);
481
- for (let f = 0; f < h.length; f++) {
482
- const m = p[Z + f], y = h[b + f];
483
- A.push(new X({ function: y?.function || m?.function || "<anonymous>", locals: y?.locals || m?.locals || {}, file: m?.file || y?.file || "<unknown>", line: y?.line || m?.line || 0, code: y?.code || m?.code || "<not captured>" }));
479
+ if (A === -1) return U === 10 ? (U = 0, p) : (++U, l().sfDebug && console.log(`"❌ No matching frame found. Checking once again, Attempt N ${U}"`), []);
480
+ l().sfDebug && console.log(`🔄 Merging from matched index ${A} onward...`);
481
+ for (let b = 0; b < u.length; b++) {
482
+ const f = p[y + b], S = u[A + b];
483
+ m.push(new T({ function: S?.function || f?.function || "<anonymous>", locals: S?.locals || f?.locals || {}, file: f?.file || S?.file || "<unknown>", line: S?.line || f?.line || 0, code: S?.code || f?.code || "<not captured>" }));
484
484
  }
485
- return A;
486
- })(d, g || []);
487
- if (C.length !== 0) {
485
+ return m;
486
+ })(I, a || []);
487
+ if (h.length !== 0) {
488
488
  t = null;
489
- const p = l().stackDepthCodeTraceDepth, h = p === -1 ? C : C.slice(0, p + 1), A = Math.min(h.length, d.length);
490
- for (let m = 0; m < A; m++) (async () => {
491
- const y = He(h[m].file, d[m].line, d[m].column);
492
- y && (y.content != null && (h[m].code = y.content), y.file != null && (h[m].file = y.file));
489
+ const p = l().stackDepthCodeTraceDepth, u = p === -1 ? h : h.slice(0, p + 1), m = Math.min(u.length, I.length);
490
+ for (let f = 0; f < m; f++) (async () => {
491
+ const S = Re(u[f].file, I[f].line, I[f].column);
492
+ S && (S.content != null && (u[f].code = S.content), S.file != null && (u[f].file = S.file));
493
493
  })();
494
- s.setOperationName("CollectExceptions");
495
- const b = c.message ? `${c.name}: ${c.message}` : c.name;
496
- l().sfDebug && console.log("error message is : ", b);
497
- const Z = G.getInstance(), f = i.get(c);
498
- f ? (Z.setTraceIdFor(f, f), Z.runWithSession(f, () => {
499
- Z.setTraceId(f), s.doSend(b, h);
500
- })) : s.doSend(b, h), I ? G.getInstance().runWithSession(I, () => {
501
- s.doSend(b, h);
502
- }) : s.doSend(b, h);
494
+ o.setOperationName("CollectExceptions");
495
+ const A = c.message ? `${c.name}: ${c.message}` : c.name;
496
+ l().sfDebug && console.log("error message is : ", A);
497
+ const y = G.getInstance(), b = n.get(c);
498
+ b ? (y.setTraceIdFor(b, b), y.runWithSession(b, () => {
499
+ y.setTraceId(b), o.doSend(A, u);
500
+ })) : o.doSend(A, u), d ? G.getInstance().runWithSession(d, () => {
501
+ o.doSend(A, u);
502
+ }) : o.doSend(A, u);
503
503
  }
504
504
  }
505
505
  }), e.on("error", (r) => {
@@ -507,115 +507,115 @@ function we(s) {
507
507
  }), e.on("exit", (r) => {
508
508
  console.error(`[Worker] Exited with code ${r}`);
509
509
  }), e.unref();
510
- const n = Error, o = /* @__PURE__ */ new Set();
511
- function a(...r) {
512
- const g = Reflect.construct(n, r);
513
- Reflect.setPrototypeOf(g, a.prototype);
510
+ const i = Error, s = /* @__PURE__ */ new Set();
511
+ function g(...r) {
512
+ const a = Reflect.construct(i, r);
513
+ Reflect.setPrototypeOf(a, g.prototype);
514
514
  try {
515
- const I = G.getInstance().getTraceId();
516
- i.set(g, I);
515
+ const d = G.getInstance().getTraceId();
516
+ n.set(a, d);
517
517
  } catch {
518
518
  }
519
- n.captureStackTrace && n.captureStackTrace(g, a);
520
- const c = `${g.message}:${g.stack?.split(`
519
+ i.captureStackTrace && i.captureStackTrace(a, g);
520
+ const c = `${a.message}:${a.stack?.split(`
521
521
  `)[1]?.trim()}`;
522
- if (!o.has(c)) {
523
- o.add(c), t = g;
524
- const I = G.getInstance().getTraceId();
525
- i.set(g, I), e.postMessage({ type: "processException", error: g.message });
522
+ if (!s.has(c)) {
523
+ s.add(c), t = a;
524
+ const d = G.getInstance().getTraceId();
525
+ n.set(a, d), e.postMessage({ type: "processException", error: a.message });
526
526
  }
527
- return g;
527
+ return a;
528
528
  }
529
- a.prototype = Object.create(n.prototype, { constructor: { value: a, enumerable: !1, writable: !0, configurable: !0 } }), Object.setPrototypeOf(a, n), globalThis.Error = a;
529
+ g.prototype = Object.create(i.prototype, { constructor: { value: g, enumerable: !1, writable: !0, configurable: !0 } }), Object.setPrototypeOf(g, i), globalThis.Error = g;
530
530
  }
531
- function ce(s) {
532
- return s = (s = (s = s.replace(/^webpack:\/\/[^\/]+\/\.?\//, "")).replace(/^.*\/pages\//, "pages/")).replace(/\.(js|ts)$/, "");
531
+ function le(o) {
532
+ return o = (o = (o = o.replace(/^webpack:\/\/[^\/]+\/\.?\//, "")).replace(/^.*\/pages\//, "pages/")).replace(/\.(js|ts)$/, "");
533
533
  }
534
- function He(s, e, t) {
535
- const i = (function(o) {
536
- o.startsWith("at ") && (o = o.slice(3).trim());
537
- const a = o.match(/^(.*?)(:\d+)+(\.map)?$/);
538
- return a ? a[1] : o;
539
- })(s);
540
- if (!i || i === "<unknown>") return null;
541
- const n = i + ".map";
534
+ function Re(o, e, t) {
535
+ const n = (function(s) {
536
+ s.startsWith("at ") && (s = s.slice(3).trim());
537
+ const g = s.match(/^(.*?)(:\d+)+(\.map)?$/);
538
+ return g ? g[1] : s;
539
+ })(o);
540
+ if (!n || n === "<unknown>") return null;
541
+ const i = n + ".map";
542
542
  try {
543
- const o = ue(n, "utf-8");
544
- if (o) {
545
- const a = JSON.parse(o);
546
- let r = new Ce.SourceMapConsumer(a).originalPositionFor({ line: e, column: t });
547
- if (i && r.source) {
548
- const g = ce(i), c = a.sources.findIndex((I) => ce(I) === g);
549
- if (c === -1) l().sfDebug && console.log(`Source file "${i}" not found in the source map.`);
543
+ const s = pe(i, "utf-8");
544
+ if (s) {
545
+ const g = JSON.parse(s);
546
+ let r = new he.SourceMapConsumer(g).originalPositionFor({ line: e, column: t });
547
+ if (n && r.source) {
548
+ const a = le(n), c = g.sources.findIndex((d) => le(d) === a);
549
+ if (c === -1) l().sfDebug && console.log(`Source file "${n}" not found in the source map.`);
550
550
  else {
551
- const I = a.sourcesContent[c], d = a.names.join(",");
552
- if (I)
553
- return { content: I.split(`
551
+ const d = g.sourcesContent[c], I = g.names.join(",");
552
+ if (d)
553
+ return { content: d.split(`
554
554
  `).slice(r.line - 1, r.line + 20).join(`
555
- `), name: d, file: r.source };
556
- l().sfDebug && console.log(`No source content available for file "${i}".`);
555
+ `), name: I, file: r.source };
556
+ l().sfDebug && console.log(`No source content available for file "${n}".`);
557
557
  }
558
558
  }
559
- return { content: a.sourcesContent[0], name: a.names[0], file: a.file };
559
+ return { content: g.sourcesContent[0], name: g.names[0], file: g.file };
560
560
  }
561
- } catch (o) {
562
- l().sfDebug && console.log(`Cant read/parse "${n}: Error - ".`, o);
561
+ } catch (s) {
562
+ l().sfDebug && console.log(`Cant read/parse "${i}: Error - ".`, s);
563
563
  }
564
564
  return null;
565
565
  }
566
- function Re(s) {
567
- return s?.split("/").pop() || "<unknown>";
566
+ function Ye(o) {
567
+ return o?.split("/").pop() || "<unknown>";
568
568
  }
569
- function be(s, e) {
570
- if (!s || typeof s != "object") return !1;
571
- for (const t of Object.values(s))
572
- if (typeof t == "string" && t.includes(e) || typeof t == "object" && be(t, e)) return !0;
569
+ function fe(o, e) {
570
+ if (!o || typeof o != "object") return !1;
571
+ for (const t of Object.values(o))
572
+ if (typeof t == "string" && t.includes(e) || typeof t == "object" && fe(t, e)) return !0;
573
573
  return !1;
574
574
  }
575
- let ge = !1;
576
- function le(s) {
577
- if (!s) return;
578
- const e = s.toLowerCase().trim();
575
+ let de = !1;
576
+ function Ie(o) {
577
+ if (!o) return;
578
+ const e = o.toLowerCase().trim();
579
579
  return !!["1", "true", "yes", "on"].includes(e) || !["0", "false", "no", "off"].includes(e) && void 0;
580
580
  }
581
- function M(s, e, t) {
582
- return new Promise((i) => {
581
+ function j(o, e, t) {
582
+ return new Promise((n) => {
583
583
  try {
584
- const n = new URL(s), o = (n.protocol, B).request({ method: "GET", hostname: n.hostname, port: n.port || (n.protocol === "https:" ? 443 : 80), path: n.pathname + (n.search || ""), headers: e }, (a) => {
585
- a.resume(), a.statusCode && a.statusCode >= 200 && a.statusCode < 400 ? i("ok") : i("http_error");
584
+ const i = new URL(o), s = (i.protocol, N).request({ method: "GET", hostname: i.hostname, port: i.port || (i.protocol === "https:" ? 443 : 80), path: i.pathname + (i.search || ""), headers: e }, (g) => {
585
+ g.resume(), g.statusCode && g.statusCode >= 200 && g.statusCode < 400 ? n("ok") : n("http_error");
586
586
  });
587
- o.on("error", () => i("error")), o.setTimeout(t, () => {
588
- o.destroy(), i("timeout");
589
- }), o.end();
587
+ s.on("error", () => n("error")), s.setTimeout(t, () => {
588
+ s.destroy(), n("timeout");
589
+ }), s.end();
590
590
  } catch {
591
- i("error");
591
+ n("error");
592
592
  }
593
593
  });
594
594
  }
595
- class Ye extends R {
595
+ class Ue extends w {
596
596
  constructor() {
597
597
  super();
598
- u(this, "serviceIdentifier", new T());
599
- u(this, "supplementalFields", {});
598
+ C(this, "serviceIdentifier", new X());
599
+ C(this, "supplementalFields", {});
600
600
  this.setOperationName("CollectExceptions");
601
601
  }
602
602
  setSupplementalFields(t) {
603
603
  this.supplementalFields = { ...this.supplementalFields, ...t };
604
604
  }
605
605
  normalizedSupplementalForGraphQL() {
606
- const { isFromLocalService: t } = this.supplementalFields, i = {};
607
- return t !== void 0 && (i.isFromLocalService = t), i;
606
+ const { isFromLocalService: t } = this.supplementalFields, n = {};
607
+ return t !== void 0 && (n.isFromLocalService = t), n;
608
608
  }
609
609
  async sendAppIdentifier() {
610
610
  this.serviceIdentifier.doSend({});
611
611
  }
612
- async doSend(t, i) {
613
- this.sendAppIdentifier(), this.send(t, i);
612
+ async doSend(t, n) {
613
+ this.sendAppIdentifier(), this.send(t, n);
614
614
  }
615
- async send(t, i) {
615
+ async send(t, n) {
616
616
  l().sfDebug && console.log(" SENDING EXCEPTION...");
617
- const n = JSON.stringify(z.encode(i)), o = this.normalizedSupplementalForGraphQL(), a = this.getVariables({ exceptionMessage: t, traceJson: n, reentrancyGuardPreactive: !1, library: l().packageLibraryType, version: l().version, ...o });
618
- F(this.endpoint, this.operationName, this.getQuery(), a);
617
+ const i = JSON.stringify(L.encode(n)), s = this.normalizedSupplementalForGraphQL(), g = this.getVariables({ exceptionMessage: t, traceJson: i, reentrancyGuardPreactive: !1, library: l().packageLibraryType, version: l().version, ...s });
618
+ F(this.endpoint, this.operationName, this.getQuery(), g);
619
619
  }
620
620
  getQuery() {
621
621
  return `
@@ -649,44 +649,86 @@ class Ye extends R {
649
649
  `;
650
650
  }
651
651
  }
652
- const Ie = "getting request source code";
653
- var L = ((s) => (s.UNKNOWN = "unknown", s.ANONYMOUS = "anonymous", s.NOT_CAPTURED = "not captured", s))(L || {});
654
- const j = "http:", Q = "https:";
655
- let de = !1;
656
- function Ke() {
657
- const s = l().sfDebug;
658
- if (de) return void (s && console.log("[patchNodeHttpInbound] Already installed, skipping."));
652
+ const ue = "getting request source code";
653
+ var $ = ((o) => (o.UNKNOWN = "unknown", o.ANONYMOUS = "anonymous", o.NOT_CAPTURED = "not captured", o))($ || {});
654
+ const Q = "http:", q = "https:";
655
+ function ye() {
656
+ return { capture_arguments: H(process.env.SF_FUNCSPAN_CAPTURE_ARGUMENTS, !0), capture_return_value: H(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: H(process.env.SF_FUNCSPAN_AUTOCAPTURE_ALL_CHILD_FUNCTIONS, !1), sample_rate: parseFloat(process.env.SF_FUNCSPAN_SAMPLE_RATE || "1.0"), enable_sampling: H(process.env.SF_FUNCSPAN_ENABLE_SAMPLING, !1), capture_sf_veritas: H(process.env.SF_FUNCSPAN_CAPTURE_SF_VERITAS, !1), parse_json_strings: H(process.env.SF_FUNCSPAN_PARSE_JSON_STRINGS, !1) };
657
+ }
658
+ function ot() {
659
+ 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 };
660
+ }
661
+ function Ke(o) {
662
+ try {
663
+ const e = o.split("-");
664
+ 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" };
665
+ } catch (e) {
666
+ return console.error(`[FuncSpan] Failed to parse header override "${o}":`, e), null;
667
+ }
668
+ }
669
+ function H(o, e) {
670
+ if (!o) return e;
671
+ const t = o.toLowerCase();
672
+ return t === "true" || t === "1" || t === "yes";
673
+ }
674
+ const se = new ie();
675
+ function Te(o) {
676
+ se.enterWith(o);
677
+ }
678
+ function Je() {
679
+ return se.getStore();
680
+ }
681
+ function Xe() {
682
+ se.enterWith(void 0);
683
+ }
684
+ function _(...o) {
685
+ const e = {};
686
+ for (const t of o) for (const n in t) t[n] !== void 0 && (e[n] = t[n]);
687
+ return e;
688
+ }
689
+ function ee(o, e) {
690
+ try {
691
+ const t = JSON.stringify(o).length / 1048576;
692
+ return t <= e ? o : { _truncated: !0, _originalSizeMB: t.toFixed(2), _limitMB: e, _preview: JSON.stringify(o).substring(0, 500) + "..." };
693
+ } catch {
694
+ return { _error: "Failed to serialize data", _type: typeof o };
695
+ }
696
+ }
697
+ let Ce = !1;
698
+ function Ee() {
699
+ const o = l().sfDebug;
700
+ if (Ce) return void (o && console.log("[patchNodeHttpInbound] Already installed, skipping."));
659
701
  let e;
660
- de = !0;
702
+ Ce = !0;
661
703
  try {
662
- e = require("node:http"), s && console.log("[patchNodeHttpInbound] node:http required successfully.");
663
- } catch (n) {
664
- return void console.error("Failed to require node:http:", n);
665
- }
666
- if (!e?.Server?.prototype) return void (s && console.log("[patchNodeHttpInbound] http.Server.prototype not found."));
667
- const t = e.Server.prototype, i = t.emit;
668
- i && !t.__sf_inbound_patched__ ? (Object.defineProperty(t, "__sf_inbound_patched__", { value: !0, enumerable: !1, configurable: !1, writable: !1 }), s && console.log("[patchNodeHttpInbound] Patching http.Server.prototype.emit."), t.emit = function(n, ...o) {
669
- if (n !== "request") return s && console.log(`[patchNodeHttpInbound] Passing through event: ${n}`), i.call(this, n, ...o);
670
- const a = o[0], r = o[1], g = (function(C) {
671
- const p = {};
672
- if (!C) return p;
673
- for (const [h, A] of Object.entries(C)) A != null && (Array.isArray(A) ? p[h.toLowerCase()] = A.join(", ") : p[h.toLowerCase()] = String(A));
674
- return p;
675
- })(a?.headers), c = g["x-sf3-rid"];
676
- s && (console.log("[patchNodeHttpInbound] Intercepted request event."), console.log("[patchNodeHttpInbound] Inbound headers:", g), console.log("[patchNodeHttpInbound] Trace header:", c));
704
+ e = require("node:http"), o && console.log("[patchNodeHttpInbound] node:http required successfully.");
705
+ } catch (i) {
706
+ return void console.error("Failed to require node:http:", i);
707
+ }
708
+ if (!e?.Server?.prototype) return void (o && console.log("[patchNodeHttpInbound] http.Server.prototype not found."));
709
+ const t = e.Server.prototype, n = t.emit;
710
+ n && !t.__sf_inbound_patched__ ? (Object.defineProperty(t, "__sf_inbound_patched__", { value: !0, enumerable: !1, configurable: !1, writable: !1 }), o && console.log("[patchNodeHttpInbound] Patching http.Server.prototype.emit."), t.emit = function(i, ...s) {
711
+ if (i !== "request") return o && console.log(`[patchNodeHttpInbound] Passing through event: ${i}`), n.call(this, i, ...s);
712
+ const g = s[0], r = s[1], a = (function(p) {
713
+ const u = {};
714
+ if (!p) return u;
715
+ for (const [m, A] of Object.entries(p)) A != null && (Array.isArray(A) ? u[m.toLowerCase()] = A.join(", ") : u[m.toLowerCase()] = String(A));
716
+ return u;
717
+ })(g?.headers), c = a["x-sf3-rid"], d = a["x-sf3-functionspancaptureoverride"];
718
+ o && (console.log("[patchNodeHttpInbound] Intercepted request event."), console.log("[patchNodeHttpInbound] Inbound headers:", a), console.log("[patchNodeHttpInbound] Trace header:", c), console.log("[patchNodeHttpInbound] FuncSpan override header:", d));
677
719
  const I = G.getInstance();
678
720
  I.setTraceId(c);
679
- const d = I.getTraceId();
680
- return s && console.log("[patchNodeHttpInbound] Context traceId set:", d), I.runWith({ inboundHeaders: g, ...c ? { traceId: c } : {} }, () => {
681
- c && I.setTraceId(c), s && console.log("[patchNodeHttpInbound] Running request handler in context.");
682
- const C = () => {
683
- s && console.log("[patchNodeHttpInbound] Response finished/closed for traceId:", I.getTraceId());
721
+ const h = I.getTraceId();
722
+ return o && console.log("[patchNodeHttpInbound] Context traceId set:", h), I.runWith({ inboundHeaders: a, ...c ? { traceId: c } : {} }, () => {
723
+ c && I.setTraceId(c), d && (Te(d), o && console.log("[patchNodeHttpInbound] FuncSpan override set:", d)), o && console.log("[patchNodeHttpInbound] Running request handler in context.");
724
+ const p = () => {
725
+ o && console.log("[patchNodeHttpInbound] Response finished/closed for traceId:", I.getTraceId()), d && (Xe(), o && console.log("[patchNodeHttpInbound] FuncSpan override cleared"));
684
726
  };
685
- return r.on("finish", C), r.on("close", C), i.call(this, n, a, r);
727
+ return r.on("finish", p), r.on("close", p), n.call(this, i, g, r);
686
728
  });
687
- }) : s && console.log("[patchNodeHttpInbound] Already patched, skipping.");
729
+ }) : o && console.log("[patchNodeHttpInbound] Already patched, skipping.");
688
730
  }
689
- class Ue extends ne {
731
+ class _e extends oe {
690
732
  constructor() {
691
733
  super(), this.setOperationName("DomainsToNotPassHeaderTo");
692
734
  }
@@ -706,14 +748,14 @@ class Ue extends ne {
706
748
  domains: $domains
707
749
  )
708
750
  }
709
- `, i = { apiKey: this.apiKey, serviceUuid: this.serviceUUID, domains: e };
710
- F(this.endpoint, this.operationName, t, i);
751
+ `, n = { apiKey: this.apiKey, serviceUuid: this.serviceUUID, domains: e };
752
+ F(this.endpoint, this.operationName, t, n);
711
753
  }
712
754
  }
713
- class Xe extends R {
755
+ class De extends w {
714
756
  constructor() {
715
757
  super();
716
- u(this, "serviceIdentifier", new T());
758
+ C(this, "serviceIdentifier", new X());
717
759
  this.setOperationName("CollectNetworkHops");
718
760
  }
719
761
  async sendAppIdentifier() {
@@ -723,8 +765,8 @@ class Xe extends R {
723
765
  this.sendAppIdentifier(), this.send(t);
724
766
  }
725
767
  async send(t) {
726
- const { name: i, column: n, line: o, entrypoint: a, retryWithoutTraceId: r } = t, g = this.getVariables({ name: i, column: n, line: o, entrypoint: a, retryWithoutTraceId: r });
727
- F(this.endpoint, this.operationName, this.getQuery(), g);
768
+ const { name: n, column: i, line: s, entrypoint: g, retryWithoutTraceId: r } = t, a = this.getVariables({ name: n, column: i, line: s, entrypoint: g, retryWithoutTraceId: r });
769
+ F(this.endpoint, this.operationName, this.getQuery(), a);
728
770
  }
729
771
  getQuery() {
730
772
  return `
@@ -754,10 +796,10 @@ class Xe extends R {
754
796
  `;
755
797
  }
756
798
  }
757
- class Je extends R {
799
+ class $e extends w {
758
800
  constructor() {
759
801
  super();
760
- u(this, "serviceIdentifier", new T());
802
+ C(this, "serviceIdentifier", new X());
761
803
  this.setOperationName("CollectNetworkRequest");
762
804
  }
763
805
  async sendAppIdentifier() {
@@ -777,75 +819,75 @@ class Je extends R {
777
819
  `;
778
820
  }
779
821
  async send(t) {
780
- const i = { data: { ...t } };
781
- await F(this.endpoint, this.operationName, this.getQuery(), i);
822
+ const n = { data: { ...t } };
823
+ await F(this.endpoint, this.operationName, this.getQuery(), n);
782
824
  }
783
825
  }
784
- const q = [400, 403];
785
- class Te {
826
+ const te = [400, 403];
827
+ class Le {
786
828
  constructor(e = []) {
787
- u(this, "HEADER_TRACING", "X-Sf3-Rid");
788
- u(this, "HEADER_LOG_GUARD", "reentrancy_guard_logging_preactive");
789
- u(this, "HEADER_PRINT_GUARD", "reentrancy_guard_print_preactive");
790
- u(this, "HEADER_EXCEPTION_GUARD", "reentrancy_guard_exception_preactive");
791
- u(this, "contextManager");
829
+ C(this, "HEADER_TRACING", "X-Sf3-Rid");
830
+ C(this, "HEADER_LOG_GUARD", "reentrancy_guard_logging_preactive");
831
+ C(this, "HEADER_PRINT_GUARD", "reentrancy_guard_print_preactive");
832
+ C(this, "HEADER_EXCEPTION_GUARD", "reentrancy_guard_exception_preactive");
833
+ C(this, "contextManager");
792
834
  this.contextManager = G.getInstance(), e?.forEach((t) => {
793
835
  typeof t == "string" && t.trim() && this.contextManager.getExcludedDomains().add(t);
794
836
  }), l().sfDebug && console.log("[RequestInterceptor] Initialized with static excluded domains.");
795
837
  }
796
838
  extractIdsFromTraceHeader(e, t = this.HEADER_TRACING) {
797
- let i;
798
- if (e instanceof Headers) i = e.get(t) ?? void 0;
839
+ let n;
840
+ if (e instanceof Headers) n = e.get(t) ?? void 0;
799
841
  else {
800
- const o = t.toLowerCase();
801
- for (const [a, r] of Object.entries(e)) if (a.toLowerCase() === o) {
802
- i = r;
842
+ const s = t.toLowerCase();
843
+ for (const [g, r] of Object.entries(e)) if (g.toLowerCase() === s) {
844
+ n = r;
803
845
  break;
804
846
  }
805
847
  }
806
- if (!i) return {};
807
- const n = i.split("/").filter(Boolean);
808
- return n.length < 3 ? {} : { sessionId: n[0], pageVisitId: n[1], requestId: n[n.length - 1] };
848
+ if (!n) return {};
849
+ const i = n.split("/").filter(Boolean);
850
+ return i.length < 3 ? {} : { sessionId: i[0], pageVisitId: i[1], requestId: i[i.length - 1] };
809
851
  }
810
852
  parseStackFrame(e) {
811
853
  const t = /\((.*):(\d+):(\d+)\)$/.exec(e.trim());
812
854
  if (!t) return null;
813
- const [, i, n, o] = t;
814
- return { filePath: i, line: parseInt(n, 10), column: parseInt(o, 10) };
855
+ const [, n, i, s] = t;
856
+ return { filePath: n, line: parseInt(i, 10), column: parseInt(s, 10) };
815
857
  }
816
- async getOriginalPosition(e, t, i) {
817
- let n = { source: e, line: t, column: i, name: null };
818
- const o = e + ".map";
858
+ async getOriginalPosition(e, t, n) {
859
+ let i = { source: e, line: t, column: n, name: null };
860
+ const s = e + ".map";
819
861
  try {
820
- const a = JSON.parse(ue(o, "utf-8"));
821
- let r = (await new Ce.SourceMapConsumer(a)).originalPositionFor({ line: t, column: i });
822
- r.source && (n = r);
823
- } catch (a) {
824
- l().sfDebug && console.error(`Could not read/parse map file at ${o}:`, a);
862
+ const g = JSON.parse(pe(s, "utf-8"));
863
+ let r = (await new he.SourceMapConsumer(g)).originalPositionFor({ line: t, column: n });
864
+ r.source && (i = r);
865
+ } catch (g) {
866
+ l().sfDebug && console.error(`Could not read/parse map file at ${s}:`, g);
825
867
  }
826
- return { originalPos: n };
827
- }
828
- captureFirstUserLines(e, t = 10, i = !1) {
829
- const n = l().sfDebug ? 10 : t, o = Error.stackTraceLimit;
830
- Error.stackTraceLimit = Math.max(o, n);
831
- const a = new Error(Ie);
832
- Ie in Error && Error.captureStackTrace(a, this.captureFirstUserLines);
833
- const r = a.stack || "";
834
- Error.stackTraceLimit = o;
835
- const g = r.split(`
868
+ return { originalPos: i };
869
+ }
870
+ captureFirstUserLines(e, t = 10, n = !1) {
871
+ const i = l().sfDebug ? 10 : t, s = Error.stackTraceLimit;
872
+ Error.stackTraceLimit = Math.max(s, i);
873
+ const g = new Error(ue);
874
+ ue in Error && Error.captureStackTrace(g, this.captureFirstUserLines);
875
+ const r = g.stack || "";
876
+ Error.stackTraceLimit = s;
877
+ const a = r.split(`
836
878
  `).slice(1), c = [];
837
- for (const I of g)
838
- if (!(I.includes("node:internal") || I.includes("internal/modules") || I.includes("internal/process") || I.includes("node_modules") || I.includes(".next/server/chunks") || I.includes("RequestInterceptor") || I.includes("contextManager") || I.includes("setupConfig")) && (c.push(I.trim()), c.length >= t)) break;
839
- for (const I of c) {
840
- const d = this.parseStackFrame(I);
841
- d ? (async () => {
842
- const { originalPos: C } = await this.getOriginalPosition(d.filePath, d.line, d.column);
843
- if (C) {
844
- l().sfDebug && console.log("[RequestInterceptor] First user code line:", C);
845
- const p = { line: C.line?.toString() || L.UNKNOWN, column: C.column?.toString() || L.NOT_CAPTURED, name: C.name || L.NOT_CAPTURED, entrypoint: C.source, retryWithoutTraceId: i };
879
+ for (const d of a)
880
+ if (!(d.includes("node:internal") || d.includes("internal/modules") || d.includes("internal/process") || d.includes("node_modules") || d.includes(".next/server/chunks") || d.includes("RequestInterceptor") || d.includes("contextManager") || d.includes("setupConfig")) && (c.push(d.trim()), c.length >= t)) break;
881
+ for (const d of c) {
882
+ const I = this.parseStackFrame(d);
883
+ I ? (async () => {
884
+ const { originalPos: h } = await this.getOriginalPosition(I.filePath, I.line, I.column);
885
+ if (h) {
886
+ l().sfDebug && console.log("[RequestInterceptor] First user code line:", h);
887
+ const p = { line: h.line?.toString() || $.UNKNOWN, column: h.column?.toString() || $.NOT_CAPTURED, name: h.name || $.NOT_CAPTURED, entrypoint: h.source, retryWithoutTraceId: n };
846
888
  e.doSend(p);
847
889
  }
848
- })() : l().sfDebug && console.error("Could not parse stack line:", I);
890
+ })() : l().sfDebug && console.error("Could not parse stack line:", d);
849
891
  }
850
892
  }
851
893
  addReentrancyGuardHeaders(e) {
@@ -855,47 +897,49 @@ class Te {
855
897
  return !Ae.some((t) => new RegExp(`^${t.replace(/\*/g, ".*")}$`).test(e));
856
898
  }
857
899
  addTracingHeaders(e, t) {
858
- const i = new URL(t).hostname, n = this.shouldPropagateHeaders(i);
859
- return n ? this.addTracingHeader(e, t) : l().sfDebug && console.error(`[RequestInterceptor] Excluded domain: ${i}`), n;
900
+ const n = new URL(t).hostname, i = this.shouldPropagateHeaders(n);
901
+ return i ? this.addTracingHeader(e, t) : l().sfDebug && console.error(`[RequestInterceptor] Excluded domain: ${n}`), i;
860
902
  }
861
903
  addTracingHeader(e, t) {
862
- const i = this.contextManager.getOrSetSfTraceId(), n = this.contextManager.getOrSetPageVisitUUID(), o = H();
863
- e.set(this.HEADER_TRACING, `${i}/${n}/${o}`), l().sfDebug && console.log(`[RequestInterceptor] Added tracing header for ${t}`);
904
+ const n = this.contextManager.getOrSetSfTraceId(), i = this.contextManager.getOrSetPageVisitUUID(), s = R();
905
+ e.set(this.HEADER_TRACING, `${n}/${i}/${s}`), l().sfDebug && console.log(`[RequestInterceptor] Added tracing header for ${t}`);
864
906
  }
865
907
  patchFetch(e, t) {
866
- const i = globalThis.fetch;
867
- typeof i == "function" ? globalThis.fetch = async (n, o) => {
908
+ const n = globalThis.fetch;
909
+ typeof n == "function" ? globalThis.fetch = async (i, s) => {
910
+ const g = new Headers(s?.headers);
911
+ if (g.get(this.HEADER_LOG_GUARD) === "true" || g.get(this.HEADER_PRINT_GUARD) === "true" || g.get(this.HEADER_EXCEPTION_GUARD) === "true") return n(i, s);
868
912
  this.captureFirstUserLines(e);
869
- const a = Date.now(), r = new Headers(o?.headers);
870
- let g;
871
- typeof n == "string" || n instanceof URL ? g = n.toString() : n instanceof Request ? (g = n.url, n.headers.forEach((h, A) => {
872
- r.set(A, h);
873
- })) : l().sfDebug && console.error("[Sailfish RequestInterceptor] Invalid fetch input."), l().sfDebug && console.log("[RequestInterceptor] Fetching request to:", g);
874
- const c = new URL(g).hostname, I = new Headers(r), d = this.addTracingHeaders(r, g), C = { ...o, headers: r };
913
+ const r = Date.now();
914
+ let a;
915
+ typeof i == "string" || i instanceof URL ? a = i.toString() : i instanceof Request ? (a = i.url, i.headers.forEach((u, m) => {
916
+ g.set(m, u);
917
+ })) : l().sfDebug && console.error("[Sailfish RequestInterceptor] Invalid fetch input."), l().sfDebug && console.log("[RequestInterceptor] Fetching request to:", a);
918
+ const c = new URL(a).hostname, d = new Headers(g), I = this.addTracingHeaders(g, a), h = { ...s, headers: g };
875
919
  let p;
876
920
  try {
877
- let h = !1;
878
- this.addTracingHeaders(I, g), p = await i(g, C), d && q.includes(p.status) ? (p = await i(g, { ...o, headers: I }), h = !0, this.captureFirstUserLines(e, 10, h)) : this.contextManager.addSupportedDomains(c);
879
- const A = Date.now();
880
- l().sfDebug && console.log(`[RequestInterceptor] Fetch completed: ${g}, Status: ${p.status}, Duration: ${A - a}ms`);
881
- const { sessionId: b, pageVisitId: Z, requestId: f } = this.extractIdsFromTraceHeader(r);
882
- return t.doSend({ apiKey: l().apiKey, requestId: f, pageVisitId: Z, recordingSessionId: b, serviceUuid: l().serviceUUID, timestampStart: a.toString(), timestampEnd: A.toString(), responseCode: p.status, success: !0, error: null, url: g, method: C.method || "GET", retryWithoutTraceId: h, parentSpanId: P() }), p;
883
- } catch (h) {
884
- const A = Date.now();
885
- l().sfDebug && console.error(`[RequestInterceptor] Fetch failed: ${g}, Error: ${h}, Duration: ${A - a}ms`);
921
+ let u = !1;
922
+ this.addTracingHeaders(d, a), p = await n(a, h), I && te.includes(p.status) ? (p = await n(a, { ...s, headers: d }), u = !0, this.captureFirstUserLines(e, 10, u)) : this.contextManager.addSupportedDomains(c);
923
+ const m = Date.now();
924
+ l().sfDebug && console.log(`[RequestInterceptor] Fetch completed: ${a}, Status: ${p.status}, Duration: ${m - r}ms`);
925
+ const { sessionId: A, pageVisitId: y, requestId: b } = this.extractIdsFromTraceHeader(g);
926
+ return t.doSend({ apiKey: l().apiKey, requestId: b, pageVisitId: y, recordingSessionId: A, serviceUuid: l().serviceUUID, timestampStart: r.toString(), timestampEnd: m.toString(), responseCode: p.status, success: !0, error: null, url: a, method: h.method || "GET", retryWithoutTraceId: u, parentSpanId: M() }), p;
927
+ } catch (u) {
928
+ const m = Date.now();
929
+ l().sfDebug && console.error(`[RequestInterceptor] Fetch failed: ${a}, Error: ${u}, Duration: ${m - r}ms`);
886
930
  }
887
931
  } : l().sfDebug && console.error("[RequestInterceptor] Fetch not available.");
888
932
  }
889
933
  patchHttp(e, t) {
890
- if (l().sfDebug && console.log("[RequestInterceptor] Initializing HTTP/HTTPS request patch..."), !B || typeof B.request != "function") return void (l().sfDebug && console.log("[RequestInterceptor] HTTP/HTTPS not available."));
891
- const i = B.request.bind(B), n = B.request.bind(B);
892
- B.request = function(o, a) {
934
+ if (l().sfDebug && console.log("[RequestInterceptor] Initializing HTTP/HTTPS request patch..."), !N || typeof N.request != "function") return void (l().sfDebug && console.log("[RequestInterceptor] HTTP/HTTPS not available."));
935
+ const n = N.request.bind(N), i = N.request.bind(N);
936
+ N.request = function(s, g) {
893
937
  let r;
894
938
  try {
895
- if (typeof o == "string") {
896
- const c = new URL(o);
897
- r = { protocol: c.protocol || j, hostname: c.hostname, path: c.pathname + c.search, headers: {} };
898
- } else o instanceof URL ? r = { protocol: o.protocol || j, hostname: o.hostname, path: o.pathname + o.search, headers: {} } : (r = { ...o }, r.protocol || (r.protocol = j));
939
+ if (typeof s == "string") {
940
+ const c = new URL(s);
941
+ r = { protocol: c.protocol || Q, hostname: c.hostname, path: c.pathname + c.search, headers: {} };
942
+ } else s instanceof URL ? r = { protocol: s.protocol || Q, hostname: s.hostname, path: s.pathname + s.search, headers: {} } : (r = { ...s }, r.protocol || (r.protocol = Q));
899
943
  if (r.headers) {
900
944
  const c = `${r.protocol}//${r.hostname}`;
901
945
  this.addTracingHeaders(r.headers, c), this.captureFirstUserLines(e);
@@ -903,24 +947,24 @@ class Te {
903
947
  } catch (c) {
904
948
  throw l().sfDebug && console.error("[RequestInterceptor] Error while processing HTTP request options:", c), c;
905
949
  }
906
- let g = !1;
907
- return i(r, (c) => {
908
- const I = `${r.protocol}//${r.hostname}`;
909
- if (r.headers && this.shouldPropagateHeaders(new URL(I).hostname) && q.includes(c.statusCode || 0)) {
950
+ let a = !1;
951
+ return n(r, (c) => {
952
+ const d = `${r.protocol}//${r.hostname}`;
953
+ if (r.headers && this.shouldPropagateHeaders(new URL(d).hostname) && te.includes(c.statusCode || 0)) {
910
954
  r.hostname;
911
- const h = { ...r, headers: { ...r.headers } };
912
- delete h.headers[this.HEADER_TRACING], i(h, a), g = !0, this.captureFirstUserLines(e, 10, g);
955
+ const u = { ...r, headers: { ...r.headers } };
956
+ delete u.headers[this.HEADER_TRACING], n(u, g), a = !0, this.captureFirstUserLines(e, 10, a);
913
957
  }
914
- const { sessionId: d, pageVisitId: C, requestId: p } = this.extractIdsFromTraceHeader(r.headers);
915
- t.doSend({ apiKey: l().apiKey, requestId: p, pageVisitId: C, recordingSessionId: d, serviceUuid: l().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: c.statusCode || 0, success: !!c.statusCode && c.statusCode < 400, error: null, url: I, method: r.method || "GET", retryWithoutTraceId: g, parentSpanId: P() }), a?.(c);
958
+ const { sessionId: I, pageVisitId: h, requestId: p } = this.extractIdsFromTraceHeader(r.headers);
959
+ t.doSend({ apiKey: l().apiKey, requestId: p, pageVisitId: h, recordingSessionId: I, serviceUuid: l().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: c.statusCode || 0, success: !!c.statusCode && c.statusCode < 400, error: null, url: d, method: r.method || "GET", retryWithoutTraceId: a, parentSpanId: M() }), g?.(c);
916
960
  });
917
- }, B.request = function(o, a) {
961
+ }, N.request = function(s, g) {
918
962
  let r;
919
963
  try {
920
- if (typeof o == "string") {
921
- const c = new URL(o);
922
- r = { protocol: c.protocol || Q, hostname: c.hostname, path: c.pathname + c.search, headers: {} };
923
- } else o instanceof URL ? r = { protocol: o.protocol || Q, hostname: o.hostname, path: o.pathname + o.search, headers: {} } : (r = { ...o }, r.protocol || (r.protocol = Q));
964
+ if (typeof s == "string") {
965
+ const c = new URL(s);
966
+ r = { protocol: c.protocol || q, hostname: c.hostname, path: c.pathname + c.search, headers: {} };
967
+ } else s instanceof URL ? r = { protocol: s.protocol || q, hostname: s.hostname, path: s.pathname + s.search, headers: {} } : (r = { ...s }, r.protocol || (r.protocol = q));
924
968
  if (r.headers) {
925
969
  const c = `${r.protocol}//${r.hostname}`;
926
970
  this.addTracingHeaders(r.headers, c);
@@ -928,30 +972,30 @@ class Te {
928
972
  } catch (c) {
929
973
  throw l().sfDebug && console.error("[RequestInterceptor] Error while processing HTTPS request options:", c), c;
930
974
  }
931
- let g = !1;
932
- return n(r, (c) => {
933
- const I = `${r.protocol}//${r.hostname}`;
934
- if (r.headers && this.shouldPropagateHeaders(new URL(I).hostname) && q.includes(c.statusCode || 0)) {
935
- const h = { ...r, headers: { ...r.headers } };
936
- delete h.headers[this.HEADER_TRACING], n(h, a), g = !0, this.captureFirstUserLines(e, 10, g);
975
+ let a = !1;
976
+ return i(r, (c) => {
977
+ const d = `${r.protocol}//${r.hostname}`;
978
+ if (r.headers && this.shouldPropagateHeaders(new URL(d).hostname) && te.includes(c.statusCode || 0)) {
979
+ const u = { ...r, headers: { ...r.headers } };
980
+ delete u.headers[this.HEADER_TRACING], i(u, g), a = !0, this.captureFirstUserLines(e, 10, a);
937
981
  }
938
- const { sessionId: d, pageVisitId: C, requestId: p } = this.extractIdsFromTraceHeader(r.headers);
939
- t.doSend({ apiKey: l().apiKey, requestId: p, pageVisitId: C, recordingSessionId: d, serviceUuid: l().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: c.statusCode || 0, success: !!c.statusCode && c.statusCode < 400, error: null, url: I, method: r.method || "GET", retryWithoutTraceId: g, parentSpanId: P() }), a?.(c);
982
+ const { sessionId: I, pageVisitId: h, requestId: p } = this.extractIdsFromTraceHeader(r.headers);
983
+ t.doSend({ apiKey: l().apiKey, requestId: p, pageVisitId: h, recordingSessionId: I, serviceUuid: l().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: c.statusCode || 0, success: !!c.statusCode && c.statusCode < 400, error: null, url: d, method: r.method || "GET", retryWithoutTraceId: a, parentSpanId: M() }), g?.(c);
940
984
  });
941
985
  }, l().sfDebug && console.log("✅ HTTP and HTTPS request methods patched globally.");
942
986
  }
943
987
  tryPatch(e, t) {
944
988
  try {
945
989
  require.resolve(t), e(), console.log(`[RequestInterceptor] Patched ${t}`);
946
- } catch (i) {
947
- console.warn(`[RequestInterceptor] Could not patch ${t}: ${i.message}`);
990
+ } catch (n) {
991
+ console.warn(`[RequestInterceptor] Could not patch ${t}: ${n.message}`);
948
992
  }
949
993
  }
950
994
  getExcludedDomains() {
951
995
  return [...this.contextManager.getExcludedDomains()];
952
996
  }
953
997
  }
954
- class _e extends ne {
998
+ class ze extends oe {
955
999
  constructor() {
956
1000
  super(), this.setOperationName("UpdateServiceDetails");
957
1001
  }
@@ -983,259 +1027,289 @@ class _e extends ne {
983
1027
  F(this.endpoint, this.operationName, e, t);
984
1028
  }
985
1029
  }
986
- function Ee() {
987
- return { capture_arguments: w(process.env.SF_FUNCSPAN_CAPTURE_ARGUMENTS, !0), capture_return_value: w(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: w(process.env.SF_FUNCSPAN_AUTOCAPTURE_ALL_CHILD_FUNCTIONS, !1), sample_rate: parseFloat(process.env.SF_FUNCSPAN_SAMPLE_RATE || "1.0"), enable_sampling: w(process.env.SF_FUNCSPAN_ENABLE_SAMPLING, !1), capture_sf_veritas: w(process.env.SF_FUNCSPAN_CAPTURE_SF_VERITAS, !1), parse_json_strings: w(process.env.SF_FUNCSPAN_PARSE_JSON_STRINGS, !1) };
988
- }
989
- function et() {
990
- return { capture_arguments: !1, capture_return_value: !1, arg_limit_mb: 1, return_limit_mb: 1, autocapture_all_child_functions: !1, sample_rate: 1, enable_sampling: !1, capture_sf_veritas: !1, parse_json_strings: !1 };
991
- }
992
- function De(s) {
993
- try {
994
- const e = s.split("-");
995
- 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" };
996
- } catch (e) {
997
- return console.error(`[FuncSpan] Failed to parse header override "${s}":`, e), null;
998
- }
999
- }
1000
- function w(s, e) {
1001
- if (!s) return e;
1002
- const t = s.toLowerCase();
1003
- return t === "true" || t === "1" || t === "yes";
1004
- }
1005
- const ie = new te();
1006
- function tt(s) {
1007
- ie.enterWith(s);
1008
- }
1009
- function Le() {
1010
- return ie.getStore();
1011
- }
1012
- function nt() {
1013
- ie.enterWith(void 0);
1014
- }
1015
- function E(...s) {
1016
- const e = {};
1017
- for (const t of s) for (const i in t) t[i] !== void 0 && (e[i] = t[i]);
1018
- return e;
1019
- }
1020
- function ee(s, e) {
1021
- try {
1022
- const t = JSON.stringify(s).length / 1048576;
1023
- return t <= e ? s : { _truncated: !0, _originalSizeMB: t.toFixed(2), _limitMB: e, _preview: JSON.stringify(s).substring(0, 500) + "..." };
1024
- } catch {
1025
- return { _error: "Failed to serialize data", _type: typeof s };
1026
- }
1027
- }
1028
- class ze {
1030
+ class xe {
1029
1031
  constructor(e = [process.cwd()], t = !1) {
1030
- u(this, "rootPaths");
1031
- u(this, "fileConfigs", /* @__PURE__ */ new Map());
1032
- u(this, "functionConfigs", /* @__PURE__ */ new Map());
1033
- u(this, "directoryConfigs", /* @__PURE__ */ new Map());
1034
- u(this, "hasSailfishFiles", !1);
1035
- u(this, "debug");
1032
+ C(this, "rootPaths");
1033
+ C(this, "fileConfigs", /* @__PURE__ */ new Map());
1034
+ C(this, "functionConfigs", /* @__PURE__ */ new Map());
1035
+ C(this, "directoryConfigs", /* @__PURE__ */ new Map());
1036
+ C(this, "hasSailfishFiles", !1);
1037
+ C(this, "debug");
1036
1038
  this.rootPaths = e, this.debug = t || process.env.SF_DEBUG === "true";
1037
1039
  }
1038
1040
  async loadAllConfigs() {
1039
1041
  this.debug && console.log("[FuncSpan ConfigLoader] Scanning for .sailfish files in:", this.rootPaths);
1040
1042
  const e = [];
1041
- for (const t of this.rootPaths) $.existsSync(t) ? await this._walkDirectory(t, e) : this.debug && console.log(`[FuncSpan ConfigLoader] Root path does not exist: ${t}`);
1043
+ for (const t of this.rootPaths) k.existsSync(t) ? await this._walkDirectory(t, e) : this.debug && console.log(`[FuncSpan ConfigLoader] Root path does not exist: ${t}`);
1042
1044
  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");
1043
1045
  for (const t of e) await this._loadConfigFile(t);
1044
1046
  await this._resolveInheritance(), this.debug && console.log(`[FuncSpan ConfigLoader] Loaded ${this.fileConfigs.size} file configs, ${this.functionConfigs.size} function configs`);
1045
1047
  }
1046
1048
  getConfig(e, t) {
1047
- const i = this.hasSailfishFiles ? Ee() : { capture_arguments: !1, capture_return_value: !1, arg_limit_mb: 1, return_limit_mb: 1, autocapture_all_child_functions: !1, sample_rate: 1, enable_sampling: !1, capture_sf_veritas: !1, parse_json_strings: !1 }, n = this._getDirectoryConfig(e), o = v.normalize(e), a = this.fileConfigs.get(o) || {};
1049
+ const n = this.hasSailfishFiles ? ye() : { 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 }, i = this._getDirectoryConfig(e), s = v.normalize(e), g = this.fileConfigs.get(s) || {};
1048
1050
  let r = {};
1049
1051
  if (t) {
1050
- const g = this.functionConfigs.get(o);
1051
- g && (r = g.get(t) || {});
1052
+ const a = this.functionConfigs.get(s);
1053
+ a && (r = a.get(t) || {});
1052
1054
  }
1053
- return E(i, n, a, r);
1055
+ return _(n, i, g, r);
1054
1056
  }
1055
1057
  async _walkDirectory(e, t) {
1056
1058
  try {
1057
- const i = $.readdirSync(e, { withFileTypes: !0 });
1058
- for (const n of i) {
1059
- const o = v.join(e, n.name);
1060
- n.name === "node_modules" || n.name === ".git" || n.name.startsWith(".") || (n.isDirectory() ? await this._walkDirectory(o, t) : n.name === ".sailfish" && t.push(o));
1059
+ const n = k.readdirSync(e, { withFileTypes: !0 });
1060
+ for (const i of n) {
1061
+ const s = v.join(e, i.name);
1062
+ i.isFile() && i.name === ".sailfish" ? t.push(s) : i.name === "node_modules" || i.isDirectory() && i.name.startsWith(".") && i.name !== ".sailfish" || i.isDirectory() && await this._walkDirectory(s, t);
1061
1063
  }
1062
- } catch (i) {
1063
- this.debug && console.error(`[FuncSpan ConfigLoader] Error walking directory ${e}:`, i);
1064
+ } catch (n) {
1065
+ this.debug && console.error(`[FuncSpan ConfigLoader] Error walking directory ${e}:`, n);
1064
1066
  }
1065
1067
  }
1066
1068
  async _loadConfigFile(e) {
1067
1069
  try {
1068
- const t = $.readFileSync(e, "utf-8"), i = v.dirname(e);
1069
- let n = null;
1070
+ const t = k.readFileSync(e, "utf-8"), n = v.dirname(e);
1071
+ let i = null;
1070
1072
  try {
1071
- n = JSON.parse(t);
1073
+ i = JSON.parse(t);
1072
1074
  } catch {
1073
1075
  try {
1074
- n = require("js-yaml").load(t);
1075
- } catch (o) {
1076
- return void (this.debug && console.error(`[FuncSpan ConfigLoader] Failed to parse ${e} as JSON or YAML:`, o));
1076
+ i = require("js-yaml").load(t);
1077
+ } catch (s) {
1078
+ return void (this.debug && console.error(`[FuncSpan ConfigLoader] Failed to parse ${e} as JSON or YAML:`, s));
1077
1079
  }
1078
1080
  }
1079
- if (!n) return;
1080
- n.default && this.directoryConfigs.set(i, n.default), n.files && await this._expandFileGlobs(i, n.files, n.default || {}), n.functions && this._storeFunctionConfigs(i, n.functions, n.default || {}), this.debug && (console.log(`[FuncSpan ConfigLoader] Loaded config from ${e}`), console.log(`[FuncSpan ConfigLoader] Directory: ${i}`), console.log(`[FuncSpan ConfigLoader] Has default: ${!!n.default}`), console.log(`[FuncSpan ConfigLoader] File patterns: ${Object.keys(n.files || {}).length}`), console.log(`[FuncSpan ConfigLoader] Functions: ${Object.keys(n.functions || {}).length}`));
1081
+ if (!i) return;
1082
+ i.default && this.directoryConfigs.set(n, i.default), i.files && await this._expandFileGlobs(n, i.files, i.default || {}), i.functions && this._storeFunctionConfigs(n, i.functions, i.default || {}), this.debug && (console.log(`[FuncSpan ConfigLoader] Loaded config from ${e}`), console.log(`[FuncSpan ConfigLoader] Directory: ${n}`), console.log(`[FuncSpan ConfigLoader] Has default: ${!!i.default}`), console.log(`[FuncSpan ConfigLoader] File patterns: ${Object.keys(i.files || {}).length}`), console.log(`[FuncSpan ConfigLoader] Functions: ${Object.keys(i.functions || {}).length}`));
1081
1083
  } catch (t) {
1082
1084
  this.debug && console.error(`[FuncSpan ConfigLoader] Error loading ${e}:`, t);
1083
1085
  }
1084
1086
  }
1085
- async _expandFileGlobs(e, t, i) {
1086
- for (const [n, o] of Object.entries(t)) try {
1087
- const a = v.join(e, n), r = await Ze(a, { absolute: !0, nodir: !0, ignore: ["**/node_modules/**", "**/.git/**"] });
1088
- this.debug && console.log(`[FuncSpan ConfigLoader] Pattern '${n}' matched ${r.length} files`);
1089
- for (const g of r) {
1090
- const c = v.normalize(g), I = E(i, o);
1091
- this.fileConfigs.set(c, I), this.debug && r.length <= 5 && console.log(`[FuncSpan ConfigLoader] - ${g}`);
1087
+ async _expandFileGlobs(e, t, n) {
1088
+ for (const [i, s] of Object.entries(t)) try {
1089
+ const g = v.join(e, i), r = await ve(g, { absolute: !0, nodir: !0, ignore: ["**/node_modules/**", "**/.git/**"] });
1090
+ this.debug && console.log(`[FuncSpan ConfigLoader] Pattern '${i}' matched ${r.length} files`);
1091
+ for (const a of r) {
1092
+ const c = v.normalize(a), d = _(n, s);
1093
+ this.fileConfigs.set(c, d), this.debug && r.length <= 5 && console.log(`[FuncSpan ConfigLoader] - ${a}`);
1092
1094
  }
1093
- } catch (a) {
1094
- this.debug && console.error(`[FuncSpan ConfigLoader] Error expanding glob '${n}':`, a);
1095
+ } catch (g) {
1096
+ this.debug && console.error(`[FuncSpan ConfigLoader] Error expanding glob '${i}':`, g);
1095
1097
  }
1096
1098
  }
1097
- _storeFunctionConfigs(e, t, i) {
1098
- for (const [n, o] of Object.entries(t)) {
1099
- const a = n.split("::");
1100
- if (a.length !== 2) {
1101
- this.debug && console.warn(`[FuncSpan ConfigLoader] Invalid function pattern '${n}' (expected format: 'file.ts::functionName')`);
1099
+ _storeFunctionConfigs(e, t, n) {
1100
+ for (const [i, s] of Object.entries(t)) {
1101
+ const g = i.split("::");
1102
+ if (g.length !== 2) {
1103
+ this.debug && console.warn(`[FuncSpan ConfigLoader] Invalid function pattern '${i}' (expected format: 'file.ts::functionName')`);
1102
1104
  continue;
1103
1105
  }
1104
- const [r, g] = a, c = v.normalize(v.join(e, r));
1106
+ const [r, a] = g, c = v.normalize(v.join(e, r));
1105
1107
  this.functionConfigs.has(c) || this.functionConfigs.set(c, /* @__PURE__ */ new Map());
1106
- const I = this.functionConfigs.get(c), d = E(i, o);
1107
- I.set(g, d), this.debug && console.log(`[FuncSpan ConfigLoader] Function config: ${c}::${g}`);
1108
+ const d = this.functionConfigs.get(c), I = _(n, s);
1109
+ d.set(a, I), this.debug && console.log(`[FuncSpan ConfigLoader] Function config: ${c}::${a}`);
1108
1110
  }
1109
1111
  }
1110
1112
  async _resolveInheritance() {
1111
1113
  }
1112
1114
  _getDirectoryConfig(e) {
1113
1115
  let t = v.dirname(v.normalize(e));
1114
- const i = [];
1116
+ const n = [];
1115
1117
  for (; t && t !== v.dirname(t); ) {
1116
- const n = this.directoryConfigs.get(t);
1117
- n && i.unshift(n), t = v.dirname(t);
1118
+ const i = this.directoryConfigs.get(t);
1119
+ i && n.unshift(i), t = v.dirname(t);
1118
1120
  }
1119
- return i.reduce((n, o) => E(n, o), {});
1121
+ return n.reduce((i, s) => _(i, s), {});
1120
1122
  }
1121
1123
  }
1122
1124
  let J = null;
1123
- async function xe(s, e) {
1124
- J = new ze(s, e), await J.loadAllConfigs();
1125
+ async function ke(o, e) {
1126
+ J = new xe(o, e), await J.loadAllConfigs();
1125
1127
  }
1126
- function $e(s, e) {
1127
- return J ? J.getConfig(s, e) : { capture_arguments: !1, capture_return_value: !1, arg_limit_mb: 1, return_limit_mb: 1, autocapture_all_child_functions: !1, sample_rate: 1, enable_sampling: !1, capture_sf_veritas: !1, parse_json_strings: !1 };
1128
+ function Oe(o, e) {
1129
+ return J ? J.getConfig(o, e) : (process.env.SF_DEBUG === "true" && console.log("[FuncSpan ConfigLoader] Config loader not initialized, using env config for worker process"), ye());
1128
1130
  }
1129
- function ke() {
1131
+ function Pe() {
1130
1132
  return J !== null;
1131
1133
  }
1132
- function it(s) {
1133
- if (!s || !s.apiKey) {
1134
- const n = `The required API Key is not provided: ${JSON.stringify(s)}`;
1135
- console.error(n);
1134
+ function st(o) {
1135
+ if (!o || !o.apiKey) {
1136
+ const i = `The required API Key is not provided: ${JSON.stringify(o)}`;
1137
+ console.error(i);
1136
1138
  }
1137
- const { config: e } = Be(s);
1139
+ const { config: e } = We(o);
1138
1140
  if (e.sfDebug && console.log("Updated configuration after applying options:", e), !e.apiKey || !e.apiGraphqlEndpoint) {
1139
- const n = `The required config is not provided: ${JSON.stringify(e)}`;
1140
- throw console.error(n), new Error(n);
1141
+ const i = `The required config is not provided: ${JSON.stringify(e)}`;
1142
+ throw console.error(i), new Error(i);
1141
1143
  }
1142
- ke() || xe(void 0, e.sfDebug).catch((n) => {
1143
- e.sfDebug && console.error("[FuncSpan] Failed to initialize config loader:", n);
1144
+ Pe() || ke(void 0, e.sfDebug).catch((i) => {
1145
+ e.sfDebug && console.error("[FuncSpan] Failed to initialize config loader:", i);
1144
1146
  });
1145
- const t = new ne();
1146
- t.setServiceUUID(e.serviceUUID), (function(n) {
1147
- function o(d, C) {
1148
- n.setOperationName("CollectLogs"), n.doSend([C, d]);
1147
+ const t = new oe();
1148
+ t.setServiceUUID(e.serviceUUID), (function(i) {
1149
+ function s(I, h) {
1150
+ i.setOperationName("CollectLogs"), i.doSend([h, I]);
1149
1151
  }
1150
- const a = console.log.bind(console), r = console.error.bind(console), g = console.warn.bind(console), c = console.info.bind(console), I = console.debug.bind(console);
1151
- console.log = (...d) => {
1152
- o("INFO", d.join(" ")), a(...d);
1153
- }, console.error = (...d) => {
1154
- o("ERROR", d.join(" ")), r(...d);
1155
- }, console.warn = (...d) => {
1156
- o("WARN", d.join(" ")), g(...d);
1157
- }, console.info = (...d) => {
1158
- o("INFO", d.join(" ")), c(...d);
1159
- }, l().logLevel === "DEBUG" && (console.debug = (...d) => {
1160
- o("DEBUG", d.join(" ")), I(...d);
1152
+ const g = console.log.bind(console), r = console.error.bind(console), a = console.warn.bind(console), c = console.info.bind(console), d = console.debug.bind(console);
1153
+ console.log = (...I) => {
1154
+ s("INFO", I.join(" ")), g(...I);
1155
+ }, console.error = (...I) => {
1156
+ s("ERROR", I.join(" ")), r(...I);
1157
+ }, console.warn = (...I) => {
1158
+ s("WARN", I.join(" ")), a(...I);
1159
+ }, console.info = (...I) => {
1160
+ s("INFO", I.join(" ")), c(...I);
1161
+ }, l().logLevel === "DEBUG" && (console.debug = (...I) => {
1162
+ s("DEBUG", I.join(" ")), d(...I);
1161
1163
  });
1162
- })(t), (function(n = []) {
1163
- const o = new Te(n);
1164
- new Ue().doSend(o.getExcludedDomains());
1165
- const a = new Xe(), r = new Je();
1166
- o.patchFetch(a, r), o.patchHttp(a, r);
1164
+ })(t), (function(i = []) {
1165
+ const s = new Le(i);
1166
+ new _e().doSend(s.getExcludedDomains());
1167
+ const g = new De(), r = new $e();
1168
+ s.patchFetch(g, r), s.patchHttp(g, r);
1167
1169
  })(e.domainsToNotPropagateHeadersTo);
1168
- const i = new Ye();
1169
- i.setServiceUUID(e.serviceUUID), we(i), Ke(), new _e().send();
1170
+ const n = new Ue();
1171
+ n.setServiceUUID(e.serviceUUID), He(n), Ee(), new ze().send();
1172
+ }
1173
+ function rt(o, e, t, n = !1) {
1174
+ const i = l();
1175
+ new be(i.apiKey).identify(o, e, t, n);
1170
1176
  }
1171
- function ot(s, e, t, i = !1) {
1172
- const n = l();
1173
- new me(n.apiKey).identify(s, e, t, i);
1177
+ function at(o, e = {}, t, n = !1) {
1178
+ const i = l();
1179
+ new be(i.apiKey).addOrUpdateMetadata(o, e, t, n);
1174
1180
  }
1175
- function st(s, e = {}, t, i = !1) {
1176
- const n = l();
1177
- new me(n.apiKey).addOrUpdateMetadata(s, e, t, i);
1181
+ class Me extends w {
1182
+ constructor() {
1183
+ super(), this.operationName = "CollectFunctionSpans";
1184
+ }
1185
+ send(e) {
1186
+ const t = l().sfDebug;
1187
+ t && console.log(`[FunctionSpanTransmitter] Preparing to send ${e.length} function span(s)`);
1188
+ for (const n of e) try {
1189
+ let i;
1190
+ if (n.result !== void 0 && n.result !== null) {
1191
+ const g = typeof n.result;
1192
+ i = JSON.stringify({ type: g, has_value: !0, value: n.result });
1193
+ } else i = n.result === null ? JSON.stringify({ type: "null", has_value: !0, value: null }) : JSON.stringify({ type: "undefined", has_value: !1, value: null });
1194
+ const s = this.getVariables({ library: "JS/TS BACKEND", version: l().version, spanId: n.spanId, parentSpanId: n.parentSpanId, filePath: n.filePath, lineNumber: n.metadata.line, columnNumber: n.metadata.column, functionName: n.functionName, arguments: JSON.stringify(n.args || {}), returnValue: i, startTimeNs: (1e6 * Date.now() - 1e6 * n.duration).toString(), durationNs: (1e6 * n.duration).toString() });
1195
+ t && (console.log(`[FunctionSpanTransmitter] Sending GraphQL mutation to ${this.endpoint}`), console.log("[FunctionSpanTransmitter] Variables:", JSON.stringify(s, null, 2))), F(this.endpoint, this.operationName, this.getQuery(), s), t && console.log(`[FunctionSpanTransmitter] Queued function span for ${n.functionName}`);
1196
+ } catch (i) {
1197
+ console.error(`[FunctionSpanTransmitter] Error preparing function span for ${n.functionName}:`, i);
1198
+ }
1199
+ }
1200
+ getQuery() {
1201
+ return `
1202
+ ${this.queryType} ${this.operationName}(
1203
+ $apiKey: String!,
1204
+ $serviceUuid: String!,
1205
+ $sessionId: String!,
1206
+ $timestampMs: String!,
1207
+ $parentSpanId: String,
1208
+ $library: String!,
1209
+ $version: String!,
1210
+ $spanId: String!,
1211
+ $filePath: String!,
1212
+ $lineNumber: Int!,
1213
+ $columnNumber: Int!,
1214
+ $functionName: String!,
1215
+ $arguments: String!,
1216
+ $returnValue: String,
1217
+ $startTimeNs: String!,
1218
+ $durationNs: String!
1219
+ ) {
1220
+ ${this.queryName}(
1221
+ apiKey: $apiKey,
1222
+ serviceUuid: $serviceUuid,
1223
+ sessionId: $sessionId,
1224
+ timestampMs: $timestampMs,
1225
+ parentSpanId: $parentSpanId,
1226
+ library: $library,
1227
+ version: $version,
1228
+ spanId: $spanId,
1229
+ filePath: $filePath,
1230
+ lineNumber: $lineNumber,
1231
+ columnNumber: $columnNumber,
1232
+ functionName: $functionName,
1233
+ arguments: $arguments,
1234
+ returnValue: $returnValue,
1235
+ startTimeNs: $startTimeNs,
1236
+ durationNs: $durationNs
1237
+ )
1238
+ }
1239
+ `;
1240
+ }
1178
1241
  }
1179
- function rt(s, e, t, i) {
1180
- const n = function(...o) {
1181
- const a = (function(C, p) {
1182
- const h = Le();
1183
- if (h) {
1184
- const A = De(h);
1185
- if (A) return process.env.SF_DEBUG === "true" && console.log(`[FuncSpan] Using HTTP header override for ${C}::${p}`), A;
1242
+ let ne = null;
1243
+ function ct(o, e, t, n) {
1244
+ const i = function(...s) {
1245
+ const g = z(), r = g?.sfDebug || !1;
1246
+ r && console.log(`[FuncSpan] captureFunctionSpan wrapper called for ${t}::${e}`);
1247
+ const a = (function(u, m) {
1248
+ const A = Je();
1249
+ if (A) {
1250
+ const y = Ke(A);
1251
+ if (y) return process.env.SF_DEBUG === "true" && console.log(`[FuncSpan] Using HTTP header override for ${u}::${m}`), y;
1186
1252
  }
1187
- return $e(C, p);
1253
+ return Oe(u, m);
1188
1254
  })(t, e);
1189
- if (a.enable_sampling && a.sample_rate < 1 && Math.random() > a.sample_rate) return s.apply(this, o);
1190
- if (a.sample_rate === 0) return s.apply(this, o);
1191
- const r = G.getInstance(), g = r.getCurrentFunctionSpanId(), c = H();
1192
- r.setCurrentFunctionSpanId(c);
1193
- const I = Date.now();
1194
- let d = null;
1195
- a.capture_arguments && (d = {}, i.paramNames.forEach((C, p) => {
1196
- p < o.length && (d[C] = o[p]);
1197
- }), d && a.arg_limit_mb > 0 && (d = ee(d, a.arg_limit_mb)));
1255
+ if (r && console.log(`[FuncSpan] Config for ${t}::${e}:`, a), a.enable_sampling && a.sample_rate < 1 && Math.random() > a.sample_rate) return r && console.log(`[FuncSpan] Skipping ${e} due to sampling`), o.apply(this, s);
1256
+ if (a.sample_rate === 0) return r && console.log(`[FuncSpan] Skipping ${e} - sample_rate is 0.0`), o.apply(this, s);
1257
+ r && console.log(`[FuncSpan] Capturing function span for ${e}`);
1258
+ const c = G.getInstance(), d = c.getCurrentFunctionSpanId(), I = R();
1259
+ c.setCurrentFunctionSpanId(I);
1260
+ const h = Date.now();
1261
+ let p = null;
1262
+ a.capture_arguments && (p = {}, n.paramNames.forEach((u, m) => {
1263
+ m < s.length && (p[u] = s[m]);
1264
+ }), p && a.arg_limit_mb > 0 && (p = ee(p, a.arg_limit_mb)));
1198
1265
  try {
1199
- const C = s.apply(this, o);
1200
- if (C && typeof C.then == "function") return C.then((A) => {
1266
+ const u = o.apply(this, s);
1267
+ if (u && typeof u.then == "function") return u.then((y) => {
1201
1268
  const b = Date.now();
1202
- let Z = null;
1203
- return a.capture_return_value && a.return_limit_mb > 0 && (Z = ee(A, a.return_limit_mb)), D({ functionName: e, filePath: t, metadata: i, args: d, result: Z, error: null, duration: b - I, async: !0, spanId: c }), g ? r.setCurrentFunctionSpanId(g) : r.clearCurrentFunctionSpanId(), A;
1204
- }, (A) => {
1269
+ let f = null;
1270
+ return a.capture_return_value && a.return_limit_mb > 0 && (f = ee(y, a.return_limit_mb)), D({ functionName: e, filePath: t, metadata: n, args: p, result: f, error: null, duration: b - h, async: !0, spanId: I, parentSpanId: d }), d ? c.setCurrentFunctionSpanId(d) : c.clearCurrentFunctionSpanId(), y;
1271
+ }, (y) => {
1205
1272
  const b = Date.now();
1206
- throw D({ functionName: e, filePath: t, metadata: i, args: d, result: null, error: A?.message || String(A), duration: b - I, async: !0, spanId: c }), g ? r.setCurrentFunctionSpanId(g) : r.clearCurrentFunctionSpanId(), A;
1273
+ throw D({ functionName: e, filePath: t, metadata: n, args: p, result: null, error: y?.message || String(y), duration: b - h, async: !0, spanId: I, parentSpanId: d }), d ? c.setCurrentFunctionSpanId(d) : c.clearCurrentFunctionSpanId(), y;
1207
1274
  });
1208
- const p = Date.now();
1209
- let h = null;
1210
- return a.capture_return_value && a.return_limit_mb > 0 && (h = ee(C, a.return_limit_mb)), D({ functionName: e, filePath: t, metadata: i, args: d, result: h, error: null, duration: p - I, async: !1, spanId: c }), g ? r.setCurrentFunctionSpanId(g) : r.clearCurrentFunctionSpanId(), C;
1211
- } catch (C) {
1212
- const p = Date.now();
1213
- throw D({ functionName: e, filePath: t, error: C?.message || String(C), duration: p - I, async: !1 }), g ? r.setCurrentFunctionSpanId(g) : r.clearCurrentFunctionSpanId(), C;
1275
+ const m = Date.now();
1276
+ let A = null;
1277
+ return a.capture_return_value && a.return_limit_mb > 0 && (A = ee(u, a.return_limit_mb)), D({ functionName: e, filePath: t, metadata: n, args: p, result: A, error: null, duration: m - h, async: !1, spanId: I, parentSpanId: d }), d ? c.setCurrentFunctionSpanId(d) : c.clearCurrentFunctionSpanId(), u;
1278
+ } catch (u) {
1279
+ const m = Date.now();
1280
+ throw D({ functionName: e, filePath: t, metadata: n, args: p, result: null, error: u?.message || String(u), duration: m - h, async: !1, spanId: I, parentSpanId: d }), d ? c.setCurrentFunctionSpanId(d) : c.clearCurrentFunctionSpanId(), u;
1214
1281
  }
1215
1282
  };
1216
- Object.defineProperty(n, "name", { value: e, writable: !1 });
1217
- for (const o in s) s.hasOwnProperty(o) && (n[o] = s[o]);
1218
- return n;
1283
+ Object.defineProperty(i, "name", { value: e, writable: !1 });
1284
+ for (const s in o) o.hasOwnProperty(s) && (i[s] = o[s]);
1285
+ return i;
1219
1286
  }
1220
- function D(s) {
1221
- process.env.SF_VERITAS_DEBUG === "true" && console.log("[FuncSpan Capture]", { function: s.functionName, file: s.filePath, duration: `${s.duration}ms`, async: s.async, error: s.error }), Ne(() => {
1222
- });
1287
+ function D(o) {
1288
+ const e = z(), t = e?.sfDebug || !1;
1289
+ t && console.log("[FuncSpan] captureSpanData called for:", { function: o.functionName, file: o.filePath, duration: `${o.duration}ms`, async: o.async, error: o.error, spanId: o.spanId });
1290
+ const n = { functionName: o.functionName, filePath: o.filePath, metadata: o.metadata, args: o.args, result: o.result, error: o.error, duration: o.duration, async: o.async, spanId: o.spanId, parentSpanId: o.parentSpanId };
1291
+ t && console.log("[FuncSpan] Sending function span to transmitter:", n);
1292
+ try {
1293
+ (ne || (ne = new Me()), ne).send([n]), t && console.log("[FuncSpan] Function span sent successfully");
1294
+ } catch (i) {
1295
+ console.error("[FuncSpan] Error sending function span:", i);
1296
+ }
1223
1297
  }
1224
1298
  export {
1225
1299
  G as ContextManager,
1226
- st as addOrUpdateMetadata,
1227
- rt as captureFunctionSpan,
1228
- nt as clearFuncspanOverride,
1229
- P as getCurrentFunctionSpanId,
1230
- et as getDefaultConfig,
1231
- Ee as getEnvConfig,
1232
- Le as getFuncspanOverride,
1233
- $e as getGlobalConfig,
1234
- ot as identify,
1235
- xe as initializeConfigLoader,
1236
- ke as isConfigLoaderInitialized,
1237
- De as parseHeaderOverride,
1238
- Ne as runWithContext,
1239
- tt as setFuncspanOverride,
1240
- it as setupInterceptors
1300
+ at as addOrUpdateMetadata,
1301
+ ct as captureFunctionSpan,
1302
+ Xe as clearFuncspanOverride,
1303
+ M as getCurrentFunctionSpanId,
1304
+ ot as getDefaultConfig,
1305
+ ye as getEnvConfig,
1306
+ Je as getFuncspanOverride,
1307
+ Oe as getGlobalConfig,
1308
+ rt as identify,
1309
+ ke as initializeConfigLoader,
1310
+ Pe as isConfigLoaderInitialized,
1311
+ Ke as parseHeaderOverride,
1312
+ it as runWithContext,
1313
+ Te as setFuncspanOverride,
1314
+ st as setupInterceptors
1241
1315
  };