@sailfish-ai/sf-veritas 0.2.7 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/contextManager-CEPhVu9T.js +197 -0
- package/dist/contextManager-CGINtRN5.cjs +1 -0
- package/dist/funcSpanTransformer-B9WWl-g1.cjs +1 -0
- package/dist/funcSpanTransformer-CWNEWRxq.js +225 -0
- package/dist/plugins/funcspanEsbuildPlugin.cjs +1 -1
- package/dist/plugins/funcspanEsbuildPlugin.mjs +17 -11
- package/dist/plugins/funcspanRollupPlugin.cjs +1 -1
- package/dist/plugins/funcspanRollupPlugin.mjs +13 -8
- package/dist/plugins/funcspanTscPlugin.cjs +1 -1
- package/dist/plugins/funcspanTscPlugin.mjs +19 -14
- package/dist/plugins/funcspanVitePlugin.cjs +1 -1
- package/dist/plugins/funcspanVitePlugin.mjs +15 -10
- package/dist/plugins/funcspanWebpackLoader.cjs +1 -1
- package/dist/plugins/funcspanWebpackLoader.mjs +1 -1
- package/dist/plugins/funcspanWebpackPlugin.cjs +1 -1
- package/dist/plugins/funcspanWebpackPlugin.mjs +22 -17
- package/dist/runtime/funcspanRegister.cjs +276 -0
- package/dist/runtimeConfig-CpQ27dZD.cjs +8 -0
- package/dist/runtimeConfig-emBNO3lJ.js +350 -0
- package/dist/sf-veritas.cjs +18 -18
- package/dist/sf-veritas.mjs +417 -619
- package/dist/source-map-Cr6YkjTd.js +631 -0
- package/dist/source-map-rHHEdpre.cjs +1 -0
- package/dist/types/dataTransmitter.d.ts +1 -0
- package/dist/types/funcSpanConfigLoader.d.ts +10 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/logHandler.d.ts +5 -0
- package/dist/types/plugins/funcSpanTransformer.d.ts +13 -0
- package/dist/types/runtime/instrumentationDetector.d.ts +33 -0
- package/dist/types/runtime/runtimeConfig.d.ts +48 -0
- package/dist/types/sourceLocation.d.ts +30 -0
- package/dist/worker-pool-capture.cjs +1 -1
- package/dist/worker-pool-capture.mjs +1 -1
- package/dist/workerPoolSpanCapture-B5KN-q4b.js +528 -0
- package/dist/workerPoolSpanCapture-Dg_WGjmO.cjs +86 -0
- package/package.json +5 -2
- package/dist/funcSpanTransformer-BLhIRZqX.js +0 -765
- package/dist/funcSpanTransformer-BpWuHXKT.cjs +0 -1
- package/dist/workerPoolSpanCapture-D0-0Z0Jw.js +0 -718
- package/dist/workerPoolSpanCapture-DEwlTq0a.cjs +0 -86
package/dist/sf-veritas.mjs
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
|
|
1
|
+
var pe = Object.defineProperty;
|
|
2
|
+
var fe = (n, e, t) => e in n ? pe(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var S = (n, e, t) => fe(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { g as l, C as J, D as he, v as ie, b as q, c as ge, a as ae } from "./contextManager-CEPhVu9T.js";
|
|
5
|
+
import { r as ft } from "./contextManager-CEPhVu9T.js";
|
|
6
|
+
import { B as D, n as F, f as me, g as ce, p as de, a as le, b as Se, m as P, c as R, d as ye, i as C, t as M, F as Ie } from "./workerPoolSpanCapture-B5KN-q4b.js";
|
|
7
|
+
import { e as gt, s as mt } from "./workerPoolSpanCapture-B5KN-q4b.js";
|
|
8
|
+
import { C as _e, i as _, a as $e, h as b, b as ve, c as be } from "./runtimeConfig-emBNO3lJ.js";
|
|
9
|
+
import { e as yt, d as It, s as _t } from "./runtimeConfig-emBNO3lJ.js";
|
|
10
|
+
import { createRequire as Fe } from "node:module";
|
|
11
|
+
import * as H from "fs";
|
|
12
|
+
import { readFileSync as Ne, appendFileSync as De } from "fs";
|
|
13
|
+
import { s as we } from "./source-map-Cr6YkjTd.js";
|
|
14
|
+
import * as $ from "path";
|
|
15
|
+
import { glob as Ee } from "glob";
|
|
16
|
+
import { threadId as T } from "worker_threads";
|
|
17
|
+
import { s as vt, t as bt, a as Ft } from "./funcSpanTransformer-CWNEWRxq.js";
|
|
18
|
+
class E extends D {
|
|
15
19
|
constructor() {
|
|
16
20
|
super(), this.setOperationName("IdentifyServiceDetails");
|
|
17
21
|
}
|
|
18
22
|
async doSend(e) {
|
|
19
|
-
if (!
|
|
23
|
+
if (!l().serviceIdentificationReceived) try {
|
|
20
24
|
this.send();
|
|
21
25
|
} catch (t) {
|
|
22
|
-
|
|
26
|
+
l().sfDebug && console.error(" Error during service identification:", t);
|
|
23
27
|
}
|
|
24
28
|
}
|
|
25
29
|
async send() {
|
|
@@ -47,42 +51,42 @@ class Y extends F {
|
|
|
47
51
|
gitSha: $gitSha,
|
|
48
52
|
)
|
|
49
53
|
}
|
|
50
|
-
`, t = this.getVariables({ serviceIdentifier:
|
|
51
|
-
|
|
54
|
+
`, t = this.getVariables({ serviceIdentifier: l().serviceIdentifier, serviceVersion: l().serviceVersion, library: l().packageLibraryType, version: l().version, serviceAdditionalMetadata: l().serviceAdditionalMetadata, gitSha: l().gitSha || "" });
|
|
55
|
+
F(this.endpoint, this.operationName, e, t);
|
|
52
56
|
}
|
|
53
57
|
}
|
|
54
|
-
function
|
|
58
|
+
function Pe(n) {
|
|
55
59
|
try {
|
|
56
60
|
return JSON.stringify(n), !0;
|
|
57
61
|
} catch {
|
|
58
62
|
return !1;
|
|
59
63
|
}
|
|
60
64
|
}
|
|
61
|
-
class
|
|
65
|
+
class Ce extends D {
|
|
62
66
|
constructor() {
|
|
63
67
|
super();
|
|
64
|
-
|
|
68
|
+
S(this, "serviceIdentifier", new E());
|
|
65
69
|
this.setOperationName("CollectMetadata");
|
|
66
70
|
}
|
|
67
71
|
async sendAppIdentifier() {
|
|
68
72
|
this.serviceIdentifier.doSend({});
|
|
69
73
|
}
|
|
70
|
-
async doSend(t, s,
|
|
71
|
-
this.sendAppIdentifier(), this.send(t, s,
|
|
74
|
+
async doSend(t, s, r, o) {
|
|
75
|
+
this.sendAppIdentifier(), this.send(t, s, r, o);
|
|
72
76
|
}
|
|
73
|
-
async send(t, s,
|
|
74
|
-
if (!s && !
|
|
75
|
-
let
|
|
76
|
-
if (!
|
|
77
|
+
async send(t, s, r, o) {
|
|
78
|
+
if (!s && !o) throw new Error('Must pass in either traits or traits_json to "add_or_update_traits"');
|
|
79
|
+
let d = [];
|
|
80
|
+
if (!o) {
|
|
77
81
|
const c = (function(a) {
|
|
78
|
-
const
|
|
79
|
-
if (a) for (const [
|
|
80
|
-
return { traitsJson: JSON.stringify(
|
|
82
|
+
const u = {}, f = [];
|
|
83
|
+
if (a) for (const [h, m] of Object.entries(a)) Pe(m) ? u[h] = m : f.push(h);
|
|
84
|
+
return { traitsJson: JSON.stringify(u), excludedFields: f };
|
|
81
85
|
})(s);
|
|
82
|
-
|
|
86
|
+
o = c.traitsJson, d = c.excludedFields;
|
|
83
87
|
}
|
|
84
|
-
const
|
|
85
|
-
|
|
88
|
+
const i = this.getVariables({ userId: t, traitsJson: o, excludedFields: d, override: r, library: l().packageLibraryType, version: l().version });
|
|
89
|
+
F(this.endpoint, this.operationName, this.getQuery(), i);
|
|
86
90
|
}
|
|
87
91
|
getQuery() {
|
|
88
92
|
return `
|
|
@@ -92,23 +96,23 @@ class Xe extends F {
|
|
|
92
96
|
`;
|
|
93
97
|
}
|
|
94
98
|
}
|
|
95
|
-
class
|
|
99
|
+
class ue {
|
|
96
100
|
constructor(e) {
|
|
97
|
-
|
|
98
|
-
this.apiKey = e, this.metadataTransmitter = new
|
|
101
|
+
S(this, "metadataTransmitter");
|
|
102
|
+
this.apiKey = e, this.metadataTransmitter = new Ce();
|
|
99
103
|
}
|
|
100
|
-
identify(e, t, s,
|
|
101
|
-
t || s ? this.addOrUpdateMetadata(e, t, s,
|
|
104
|
+
identify(e, t, s, r = !1) {
|
|
105
|
+
t || s ? this.addOrUpdateMetadata(e, t, s, r) : this.addOrUpdateMetadata(e, {}, void 0, r);
|
|
102
106
|
}
|
|
103
|
-
addOrUpdateMetadata(e, t = {}, s,
|
|
107
|
+
addOrUpdateMetadata(e, t = {}, s, r = !1) {
|
|
104
108
|
if (!t && !s) throw new Error('Must pass in either traits or traitsJson to "addOrUpdateMetadata"');
|
|
105
|
-
|
|
109
|
+
l().sfDebug && console.log(" [[DEBUG - addOrUpdateMetadata]] Starting operation"), l().sfDebug && console.log(" addOrUpdateMetadata...SENDING DATA...", e, t, s), this.metadataTransmitter.doSend(e, t, r, s);
|
|
106
110
|
}
|
|
107
111
|
}
|
|
108
|
-
class
|
|
112
|
+
class V extends D {
|
|
109
113
|
constructor() {
|
|
110
114
|
super();
|
|
111
|
-
|
|
115
|
+
S(this, "serviceIdentifier", new E());
|
|
112
116
|
}
|
|
113
117
|
async sendAppIdentifier() {
|
|
114
118
|
this.serviceIdentifier.doSend({});
|
|
@@ -118,10 +122,10 @@ class ee extends F {
|
|
|
118
122
|
}
|
|
119
123
|
async send(t) {
|
|
120
124
|
try {
|
|
121
|
-
const s = Array.isArray(t) ? t : [t, "default"],
|
|
122
|
-
|
|
125
|
+
const s = Array.isArray(t) ? t : [t, "default", null, null], r = this.getVariables({ contents: s[0], level: s[1], sourceFile: s[2] || void 0, sourceLine: s[3] || void 0 });
|
|
126
|
+
F(this.endpoint, this.operationName, this.getQuery(), r);
|
|
123
127
|
} catch (s) {
|
|
124
|
-
|
|
128
|
+
l().sfDebug && console.error("🚨 Error in send():", s);
|
|
125
129
|
}
|
|
126
130
|
}
|
|
127
131
|
getQuery() {
|
|
@@ -133,7 +137,9 @@ class ee extends F {
|
|
|
133
137
|
$timestampMs: String!,
|
|
134
138
|
$level: String!,
|
|
135
139
|
$contents: String!,
|
|
136
|
-
$parentSpanId: String
|
|
140
|
+
$parentSpanId: String,
|
|
141
|
+
$sourceFile: String,
|
|
142
|
+
$sourceLine: Int
|
|
137
143
|
) {
|
|
138
144
|
${this.queryName}(
|
|
139
145
|
apiKey: $apiKey,
|
|
@@ -142,224 +148,19 @@ class ee extends F {
|
|
|
142
148
|
timestampMs: $timestampMs,
|
|
143
149
|
level: $level,
|
|
144
150
|
contents: $contents,
|
|
145
|
-
parentSpanId: $parentSpanId
|
|
151
|
+
parentSpanId: $parentSpanId,
|
|
152
|
+
sourceFile: $sourceFile,
|
|
153
|
+
sourceLine: $sourceLine
|
|
146
154
|
)
|
|
147
155
|
}
|
|
148
156
|
`;
|
|
149
157
|
}
|
|
150
158
|
}
|
|
151
|
-
|
|
152
|
-
class V {
|
|
153
|
-
constructor({ file: e, line: t, function: s, code: o, locals: i = {}, offender: g = !1, column: r }) {
|
|
154
|
-
A(this, "file");
|
|
155
|
-
A(this, "line");
|
|
156
|
-
A(this, "function");
|
|
157
|
-
A(this, "code");
|
|
158
|
-
A(this, "locals");
|
|
159
|
-
A(this, "offender");
|
|
160
|
-
A(this, "column");
|
|
161
|
-
this.file = e, this.line = t, this.function = s, this.code = o, this.locals = i, this.offender = g, this.column = r;
|
|
162
|
-
}
|
|
163
|
-
toDict() {
|
|
164
|
-
const e = { file: this.file, line: this.line, function: this.function, code: this.code, locals: Object.fromEntries(Object.entries(this.locals).map(([t, s]) => [t, String(s)])) };
|
|
165
|
-
return this.offender && (e.offender = this.offender), this.column !== void 0 && (e.column = this.column), e;
|
|
166
|
-
}
|
|
167
|
-
toJson() {
|
|
168
|
-
return JSON.stringify(this.toDict());
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
class z {
|
|
172
|
-
static encode(e) {
|
|
173
|
-
return e instanceof V ? e.toDict() : Array.isArray(e) ? e.map((t) => z.encode(t)) : typeof e == "object" && e !== null ? JSON.stringify(e) : e;
|
|
174
|
-
}
|
|
175
|
-
static stringify(e) {
|
|
176
|
-
return JSON.stringify(z.encode(e), (t, s) => s instanceof V ? s.toDict() : s);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
let B, w = 0;
|
|
180
|
-
function Je(n) {
|
|
181
|
-
d().sfDebug && console.log("Initializing Exception Interceptor...");
|
|
182
|
-
try {
|
|
183
|
-
const r = (function() {
|
|
184
|
-
if (B !== void 0) return B;
|
|
185
|
-
const c = process.env || {}, a = se(c.SF_IS_LOCAL);
|
|
186
|
-
if (a !== void 0) return B = a;
|
|
187
|
-
const l = (c.SF_ENV || c.NODE_ENV || "").toLowerCase();
|
|
188
|
-
if (["local", "dev", "development"].includes(l)) return B = !0;
|
|
189
|
-
if (["KUBERNETES_SERVICE_HOST", "AWS_EXECUTION_ENV", "ECS_CONTAINER_METADATA_URI", "ECS_CONTAINER_METADATA_URI_V4", "GAE_ENV", "K_SERVICE", "GOOGLE_CLOUD_PROJECT", "WEBSITE_INSTANCE_ID", "VERCEL", "NETLIFY", "DYNO", "RENDER", "FLY_APP_NAME", "RAILWAY_STATIC_URL", "CF_PAGES", "CLOUDFLARE"].some((p) => !!c[p])) return B = !1;
|
|
190
|
-
const I = (G.hostname?.() || c.HOSTNAME || "").toLowerCase();
|
|
191
|
-
return I === "localhost" || I.endsWith(".local") || I.includes("local") ? B = !0 : B = !1;
|
|
192
|
-
})();
|
|
193
|
-
n?.setSupplementalFields?.({ isFromLocalService: r }), (async function(c) {
|
|
194
|
-
if (oe) return;
|
|
195
|
-
oe = !0;
|
|
196
|
-
const a = process.env || {};
|
|
197
|
-
if (se(a.SF_IS_LOCAL) === void 0)
|
|
198
|
-
try {
|
|
199
|
-
await (async function(l) {
|
|
200
|
-
const I = D("http://169.254.169.254/latest/meta-data/", {}, l), p = D("http://metadata.google.internal/computeMetadata/v1/instance/", { "Metadata-Flavor": "Google" }, l), C = D("http://169.254.169.254/metadata/instance?api-version=2021-02-01", { Metadata: "true" }, l);
|
|
201
|
-
return (await Promise.allSettled([I, p, C])).some((u) => u.status === "fulfilled" && (u.value === "ok" || u.value === "http_error"));
|
|
202
|
-
})(150) && B && (B = !1, c?.setSupplementalFields?.({ isFromLocalService: !1 }));
|
|
203
|
-
} catch {
|
|
204
|
-
}
|
|
205
|
-
})(n).catch(() => {
|
|
206
|
-
});
|
|
207
|
-
} catch {
|
|
208
|
-
}
|
|
209
|
-
const e = new Ve(new URL("data:application/javascript;base64,aW1wb3J0IHsgU2Vzc2lvbiB9IGZyb20gImluc3BlY3Rvci9wcm9taXNlcyI7CmltcG9ydCB7IHBhcmVudFBvcnQsIHdvcmtlckRhdGEgfSBmcm9tICJ3b3JrZXJfdGhyZWFkcyI7CgpnbG9iYWwuc2ZEZWJ1ZyA9IHVuZGVmaW5lZDsKZ2xvYmFsLnN0YWNrRGVwdGhMb2NhbHMgPSB1bmRlZmluZWQ7Cmdsb2JhbC5ub2RlTW9kdWxlc1RvQ29sbGVjdExvY2FsVmFyaWFibGVzT24gPSB1bmRlZmluZWQ7CgovKioKICogUHJvY2Vzc2VzIGNhbGwgZnJhbWVzIGZyb20gYW4gZXhjZXB0aW9uIGFuZCBwb3N0cyB0aGVtIHZpYSB0aGUgV29ya2Vy4oCZcyBwYXJlbnRQb3J0LgogKgogKiBAcGFyYW0gc2Vzc2lvbiAtIFRoZSBEZXZUb29scyBzZXNzaW9uIG9yIHNpbWlsYXIgb2JqZWN0IHlvdSB1c2UgdG8gcXVlcnkgZm9yIHNjcmlwdCBzb3VyY2VzLgogKiBAcGFyYW0gY2FsbEZyYW1lcyAtIEFuIGFycmF5IG9mIGNhbGwgZnJhbWUgb2JqZWN0cy4KICogQHBhcmFtIGRlc2NyaXB0aW9uTGluZXMgLSBBbiBhcnJheSBvZiBsaW5lcyBmcm9tIHRoZSBlcnJvcuKAmXMgZGVzY3JpcHRpb24sIGVhY2ggdHlwaWNhbGx5IGJlZ2lubmluZyB3aXRoICJhdCAiLgogKiBAcmV0dXJucyB7UHJvbWlzZTx2b2lkPn0KICovCmV4cG9ydCBhc3luYyBmdW5jdGlvbiBwcm9jZXNzQ2FsbEZyYW1lcyhzZXNzaW9uLCBjYW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NyaXB0aW9uTGluZXNbaW5kZXhdLnRyaW0oKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgZmlsZSA9ICI8dW5rbm93bj4iOwogICAgICAgIH0KCiAgICAgICAgLy8gSWYgd2UgaGF2ZSBhIHZhbGlkIGxvY2F0aW9uIGFuZCBzY3JpcHRJZCwgZmV0Y2ggdGhlIGNvZGUgbGluZQogICAgICAgIGlmIChsb2NhdGlvbiAmJiBsb2NhdGlvbi5zY3JpcHRJZCkgewogICAgICAgICAgY29uc3Qgc2NyaXB0SWQgPSBsb2NhdGlvbi5zY3JpcHRJZDsKICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgIGNvbnN0IHsgc2NyaXB0U291cmNlIH0gPSBhd2FpdCBzZXNzaW9uLnBvc3QoCiAgICAgICAgICAgICAgIkRlYnVnZ2VyLmdldFNjcmlwdFNvdXJjZSIsCiAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgc2NyaXB0SWQsCiAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgKTsKICAgICAgICAgICAgY29uc3Qgc291cmNlTGluZXMgPSBzY3JpcHRTb3VyY2Uuc3BsaXQoIlxuIik7CiAgICAgICAgICAgIGNvZGUgPSBzb3VyY2VMaW5lc1tsb2NhdGlvbi5saW5lTnVtYmVyXSB8fCAiPG5vdCBjYXB0dXJlZD4iOwogICAgICAgICAgfSBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBmZXRjaCBzY3JpcHQgc291cmNlOiIsIGVycik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIC8vIEZldGNoIGxvY2FsIHZhcmlhYmxlcyBpZiB0aGVyZSdzIGFuIG9iamVjdElkCiAgICAgICAgY29uc3QgbG9jYWxzID0gbG9jYWxTY29wZT8ub2JqZWN0Py5vYmplY3RJZAogICAgICAgICAgPyBhd2FpdCBmZXRjaExvY2FsVmFyaWFibGVzKHNlc3Npb24sIGxvY2FsU2NvcGUub2JqZWN0Lm9iamVjdElkKQogICAgICAgICAgOiB7fTsKCiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGZ1bmN0aW9uOiBmdW5jdGlvbk5hbWUgfHwgIjxhbm9ueW1vdXM+IiwKICAgICAgICAgIGxvY2FscywKICAgICAgICAgIGZpbGUsCiAgICAgICAgICBsaW5lOiBsb2NhdGlvbj8ubGluZU51bWJlciB8fCAwLAogICAgICAgICAgY29kZSwKICAgICAgICB9OwogICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgIGlmIChnbG9iYWwuc2ZEZWJ1ZykgewogICAgICAgICAgY29uc29sZS5lcnJvcigiW1dvcmtlcl0gRXJyb3IgcHJvY2Vzc2luZyBjYWxsIGZyYW1lOiIsIGVycm9yKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGZ1bmN0aW9uOiAiPGVycm9yPiIsCiAgICAgICAgICBsb2NhbHM6IHt9LAogICAgICAgICAgZmlsZTogIjx1bmtub3duPiIsCiAgICAgICAgICBsaW5lOiAwLAogICAgICAgICAgY29kZTogIjxub3QgY2FwdHVyZWQ+IiwKICAgICAgICB9OwogICAgICB9CiAgICB9KSwKICApOwogIC8vIFBvc3QgZXhjZXB0aW9uIGRhdGEKICBwYXJlbnRQb3J0Py5wb3N0TWVzc2FnZSh7IHR5cGU6ICJleGNlcHRpb24iLCBmcmFtZXMgfSk7Cn0KCi8qKgogKiBIYW5kbGVzIHRoZSAicGF1c2VkIiBzdGF0ZSBvZiB0aGUgZGVidWdnZXIgYW5kIHByb2Nlc3NlcyBleGNlcHRpb25zIG9yIHByb21pc2UgcmVqZWN0aW9ucy4KICogQHBhcmFtIHtTZXNzaW9ufSBzZXNzaW9uIC0gVGhlIGRlYnVnZ2luZyBzZXNzaW9uIGluc3RhbmNlLgogKiBAcGFyYW0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gICAgICBhd2FpdCB1bnJvbGxPYmplY3Qoc2Vzc2lvbiwgaWQsIHByb3AubmFtZSwgdmFyaWFibGVzKTsKICAgICAgICB9IGVsc2UgaWYgKHByb3A/LnZhbHVlKSB7CiAgICAgICAgICB1bnJvbGxPdGhlcihwcm9wLCB2YXJpYWJsZXMpOwogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4gdmFyaWFibGVzOwogICAgfQogIH0gY2F0Y2ggKGVycikgewogICAgaWYgKGdsb2JhbC5zZkRlYnVnKSB7CiAgICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBmZXRjaCBsb2NhbCB2YXJpYWJsZXM6IiwgZXJyKTsKICAgIH0KICAgIHJldHVybiB7fTsKICB9Cn0KCnN0YXJ0RGVidWdnZXIoKS5jYXRjaCgoZXJyb3IpID0+IHsKICBpZiAoZ2xvYmFsLnNmRGVidWcpIHsKICAgIGNvbnNvbGUuZXJyb3IoIltXb3JrZXJdIEZhaWxlZCB0byBzdGFydCBkZWJ1Z2dlcjoiLCBlcnJvcik7CiAgfQp9KTsKCi8vIEtlZXAgdGhlIHdvcmtlciBhbGl2ZQpzZXRJbnRlcnZhbCgoKSA9PiB7fSwgMTAwMDApOwo="), { workerData: { captureAllExceptions: !0 } });
|
|
210
|
-
let t = null;
|
|
211
|
-
const s = /* @__PURE__ */ new WeakMap();
|
|
212
|
-
e.on("message", (r) => {
|
|
213
|
-
if (typeof r == "string" && d().sfDebug && console.log(`[Worker] ${r}`), r.readyToGetParameters && e.postMessage({ sfDebug: d().sfDebug, stackDepthLocals: d().stackDepthLocals, nodeModulesToCollectLocalVariablesOn: d().nodeModulesToCollectLocalVariablesOn }), r.type === "exception") {
|
|
214
|
-
const { frames: c } = r, a = t;
|
|
215
|
-
if (!a) return;
|
|
216
|
-
const l = s.get(a), I = (function(C) {
|
|
217
|
-
return C ? C.split(`
|
|
218
|
-
`).slice(1).map((u) => {
|
|
219
|
-
const m = /at (.+?) \((.+):(\d+):(\d+)\)/.exec(u) || /at (.+):(\d+):(\d+)/.exec(u);
|
|
220
|
-
if (m) {
|
|
221
|
-
const [, h, Z, b, y] = m;
|
|
222
|
-
return new V({ function: h || "<anonymous>", locals: {}, file: Z || "<unknown>", line: parseInt(b, 10) || 0, code: "<not captured>", column: parseInt(y) || 0 });
|
|
223
|
-
}
|
|
224
|
-
return new V({ function: "<unknown>", locals: {}, file: "<unknown>", line: 0, code: "<not captured>", column: 0 });
|
|
225
|
-
}) : [];
|
|
226
|
-
})(a.stack), p = (function(C, u) {
|
|
227
|
-
const m = [];
|
|
228
|
-
let h = -1, Z = -1;
|
|
229
|
-
for (let b = 0; b < C.length; b++) {
|
|
230
|
-
const y = _e(C[b].file);
|
|
231
|
-
if (Z = b, y !== "<unknown>") {
|
|
232
|
-
for (let f = 0; f < u.length; f++) {
|
|
233
|
-
const W = u[f];
|
|
234
|
-
if (ye(W, y) || typeof W.file == "string" && W.file.includes(y)) {
|
|
235
|
-
h = f, w = 0, d().sfDebug && console.log(`✅ Matched Frame Found: ${y} @ Debugger Frame ${f}`);
|
|
236
|
-
break;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
if (h !== -1) break;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
if (h === -1) return w === 10 ? (w = 0, C) : (++w, d().sfDebug && console.log(`"❌ No matching frame found. Checking once again, Attempt N ${w}"`), []);
|
|
243
|
-
d().sfDebug && console.log(`🔄 Merging from matched index ${h} onward...`);
|
|
244
|
-
for (let b = 0; b < u.length; b++) {
|
|
245
|
-
const y = C[Z + b], f = u[h + b];
|
|
246
|
-
m.push(new V({ function: f?.function || y?.function || "<anonymous>", locals: f?.locals || y?.locals || {}, file: y?.file || f?.file || "<unknown>", line: f?.line || y?.line || 0, code: f?.code || y?.code || "<not captured>" }));
|
|
247
|
-
}
|
|
248
|
-
return m;
|
|
249
|
-
})(I, c || []);
|
|
250
|
-
if (p.length !== 0) {
|
|
251
|
-
t = null;
|
|
252
|
-
const C = d().stackDepthCodeTraceDepth, u = C === -1 ? p : p.slice(0, C + 1), m = Math.min(u.length, I.length);
|
|
253
|
-
for (let y = 0; y < m; y++) (async () => {
|
|
254
|
-
const f = Ke(u[y].file, I[y].line, I[y].column);
|
|
255
|
-
f && (f.content != null && (u[y].code = f.content), f.file != null && (u[y].file = f.file));
|
|
256
|
-
})();
|
|
257
|
-
n.setOperationName("CollectExceptions");
|
|
258
|
-
const h = a.message ? `${a.name}: ${a.message}` : a.name;
|
|
259
|
-
d().sfDebug && console.log("error message is : ", h);
|
|
260
|
-
const Z = N.getInstance(), b = s.get(a);
|
|
261
|
-
b ? (Z.setTraceIdFor(b, b), Z.runWithSession(b, () => {
|
|
262
|
-
Z.setTraceId(b), n.doSend(h, u);
|
|
263
|
-
})) : n.doSend(h, u), l ? N.getInstance().runWithSession(l, () => {
|
|
264
|
-
n.doSend(h, u);
|
|
265
|
-
}) : n.doSend(h, u);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}), e.on("error", (r) => {
|
|
269
|
-
console.error("[Worker Error]", r);
|
|
270
|
-
}), e.on("exit", (r) => {
|
|
271
|
-
console.error(`[Worker] Exited with code ${r}`);
|
|
272
|
-
}), e.unref();
|
|
273
|
-
const o = Error, i = /* @__PURE__ */ new Set();
|
|
274
|
-
function g(...r) {
|
|
275
|
-
const c = Reflect.construct(o, r);
|
|
276
|
-
Reflect.setPrototypeOf(c, g.prototype);
|
|
277
|
-
try {
|
|
278
|
-
const l = N.getInstance().getTraceId();
|
|
279
|
-
s.set(c, l);
|
|
280
|
-
} catch {
|
|
281
|
-
}
|
|
282
|
-
o.captureStackTrace && o.captureStackTrace(c, g);
|
|
283
|
-
const a = `${c.message}:${c.stack?.split(`
|
|
284
|
-
`)[1]?.trim()}`;
|
|
285
|
-
if (!i.has(a)) {
|
|
286
|
-
i.add(a), t = c;
|
|
287
|
-
const l = N.getInstance().getTraceId();
|
|
288
|
-
s.set(c, l), e.postMessage({ type: "processException", error: c.message });
|
|
289
|
-
}
|
|
290
|
-
return c;
|
|
291
|
-
}
|
|
292
|
-
g.prototype = Object.create(o.prototype, { constructor: { value: g, enumerable: !1, writable: !0, configurable: !0 } }), Object.setPrototypeOf(g, o), globalThis.Error = g;
|
|
293
|
-
}
|
|
294
|
-
function ne(n) {
|
|
295
|
-
return n = (n = (n = n.replace(/^webpack:\/\/[^\/]+\/\.?\//, "")).replace(/^.*\/pages\//, "pages/")).replace(/\.(js|ts)$/, "");
|
|
296
|
-
}
|
|
297
|
-
function Ke(n, e, t) {
|
|
298
|
-
const s = (function(i) {
|
|
299
|
-
i.startsWith("at ") && (i = i.slice(3).trim());
|
|
300
|
-
const g = i.match(/^(.*?)(:\d+)+(\.map)?$/);
|
|
301
|
-
return g ? g[1] : i;
|
|
302
|
-
})(n);
|
|
303
|
-
if (!s || s === "<unknown>") return null;
|
|
304
|
-
const o = s + ".map";
|
|
305
|
-
try {
|
|
306
|
-
const i = be(o, "utf-8");
|
|
307
|
-
if (i) {
|
|
308
|
-
const g = JSON.parse(i);
|
|
309
|
-
let r = new Ae.SourceMapConsumer(g).originalPositionFor({ line: e, column: t });
|
|
310
|
-
if (s && r.source) {
|
|
311
|
-
const c = ne(s), a = g.sources.findIndex((l) => ne(l) === c);
|
|
312
|
-
if (a === -1) d().sfDebug && console.log(`Source file "${s}" not found in the source map.`);
|
|
313
|
-
else {
|
|
314
|
-
const l = g.sourcesContent[a], I = g.names.join(",");
|
|
315
|
-
if (l)
|
|
316
|
-
return { content: l.split(`
|
|
317
|
-
`).slice(r.line - 1, r.line + 20).join(`
|
|
318
|
-
`), name: I, file: r.source };
|
|
319
|
-
d().sfDebug && console.log(`No source content available for file "${s}".`);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
return { content: g.sourcesContent[0], name: g.names[0], file: g.file };
|
|
323
|
-
}
|
|
324
|
-
} catch (i) {
|
|
325
|
-
d().sfDebug && console.log(`Cant read/parse "${o}: Error - ".`, i);
|
|
326
|
-
}
|
|
327
|
-
return null;
|
|
328
|
-
}
|
|
329
|
-
function _e(n) {
|
|
330
|
-
return n?.split("/").pop() || "<unknown>";
|
|
331
|
-
}
|
|
332
|
-
function ye(n, e) {
|
|
333
|
-
if (!n || typeof n != "object") return !1;
|
|
334
|
-
for (const t of Object.values(n))
|
|
335
|
-
if (typeof t == "string" && t.includes(e) || typeof t == "object" && ye(t, e)) return !0;
|
|
336
|
-
return !1;
|
|
337
|
-
}
|
|
338
|
-
let oe = !1;
|
|
339
|
-
function se(n) {
|
|
340
|
-
if (!n) return;
|
|
341
|
-
const e = n.toLowerCase().trim();
|
|
342
|
-
return !!["1", "true", "yes", "on"].includes(e) || !["0", "false", "no", "off"].includes(e) && void 0;
|
|
343
|
-
}
|
|
344
|
-
function D(n, e, t) {
|
|
345
|
-
return new Promise((s) => {
|
|
346
|
-
try {
|
|
347
|
-
const o = new URL(n), i = (o.protocol, G).request({ method: "GET", hostname: o.hostname, port: o.port || (o.protocol === "https:" ? 443 : 80), path: o.pathname + (o.search || ""), headers: e }, (g) => {
|
|
348
|
-
g.resume(), g.statusCode && g.statusCode >= 200 && g.statusCode < 400 ? s("ok") : s("http_error");
|
|
349
|
-
});
|
|
350
|
-
i.on("error", () => s("error")), i.setTimeout(t, () => {
|
|
351
|
-
i.destroy(), s("timeout");
|
|
352
|
-
}), i.end();
|
|
353
|
-
} catch {
|
|
354
|
-
s("error");
|
|
355
|
-
}
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
class ke extends F {
|
|
159
|
+
class Te extends D {
|
|
359
160
|
constructor() {
|
|
360
161
|
super();
|
|
361
|
-
|
|
362
|
-
|
|
162
|
+
S(this, "serviceIdentifier", new E());
|
|
163
|
+
S(this, "supplementalFields", {});
|
|
363
164
|
this.setOperationName("CollectExceptions");
|
|
364
165
|
}
|
|
365
166
|
setSupplementalFields(t) {
|
|
@@ -376,9 +177,9 @@ class ke extends F {
|
|
|
376
177
|
this.sendAppIdentifier(), this.send(t, s);
|
|
377
178
|
}
|
|
378
179
|
async send(t, s) {
|
|
379
|
-
|
|
380
|
-
const
|
|
381
|
-
|
|
180
|
+
l().sfDebug && console.log(" SENDING EXCEPTION...");
|
|
181
|
+
const r = JSON.stringify(_e.encode(s)), o = this.normalizedSupplementalForGraphQL(), d = this.getVariables({ exceptionMessage: t, traceJson: r, reentrancyGuardPreactive: !1, library: l().packageLibraryType, version: l().version, ...o });
|
|
182
|
+
F(this.endpoint, this.operationName, this.getQuery(), d);
|
|
382
183
|
}
|
|
383
184
|
getQuery() {
|
|
384
185
|
return `
|
|
@@ -412,51 +213,51 @@ class ke extends F {
|
|
|
412
213
|
`;
|
|
413
214
|
}
|
|
414
215
|
}
|
|
415
|
-
const
|
|
416
|
-
var
|
|
417
|
-
const
|
|
418
|
-
let
|
|
419
|
-
function
|
|
420
|
-
const n =
|
|
421
|
-
if (
|
|
216
|
+
const Y = "getting request source code";
|
|
217
|
+
var A = ((n) => (n.UNKNOWN = "unknown", n.ANONYMOUS = "anonymous", n.NOT_CAPTURED = "not captured", n))(A || {});
|
|
218
|
+
const x = "http:", G = "https:", Ue = Fe(import.meta.url);
|
|
219
|
+
let Z = !1;
|
|
220
|
+
function Re() {
|
|
221
|
+
const n = l().sfDebug;
|
|
222
|
+
if (Z) return void (n && _("[patchNodeHttpInbound] Already installed, skipping."));
|
|
422
223
|
let e;
|
|
423
|
-
|
|
224
|
+
Z = !0;
|
|
424
225
|
try {
|
|
425
|
-
e =
|
|
426
|
-
} catch (
|
|
427
|
-
return void
|
|
226
|
+
e = Ue("node:http"), n && _("[patchNodeHttpInbound] node:http required successfully.");
|
|
227
|
+
} catch (r) {
|
|
228
|
+
return void $e("Failed to require node:http:", r);
|
|
428
229
|
}
|
|
429
|
-
if (!e?.Server?.prototype) return void (n &&
|
|
230
|
+
if (!e?.Server?.prototype) return void (n && _("[patchNodeHttpInbound] http.Server.prototype not found."));
|
|
430
231
|
const t = e.Server.prototype, s = t.emit;
|
|
431
|
-
s && !t.__sf_inbound_patched__ ? (Object.defineProperty(t, "__sf_inbound_patched__", { value: !0, enumerable: !1, configurable: !1, writable: !1 }), n &&
|
|
432
|
-
if (
|
|
433
|
-
const
|
|
434
|
-
const
|
|
435
|
-
if (!
|
|
436
|
-
for (const [
|
|
437
|
-
return
|
|
438
|
-
})(
|
|
439
|
-
n && (
|
|
440
|
-
const
|
|
441
|
-
|
|
442
|
-
const
|
|
443
|
-
n &&
|
|
444
|
-
const
|
|
445
|
-
a &&
|
|
446
|
-
const
|
|
447
|
-
n &&
|
|
232
|
+
s && !t.__sf_inbound_patched__ ? (Object.defineProperty(t, "__sf_inbound_patched__", { value: !0, enumerable: !1, configurable: !1, writable: !1 }), n && _("[patchNodeHttpInbound] Patching http.Server.prototype.emit."), t.emit = function(r, ...o) {
|
|
233
|
+
if (r !== "request") return n && _(`[patchNodeHttpInbound] Passing through event: ${r}`), s.call(this, r, ...o);
|
|
234
|
+
const d = o[0], i = o[1], c = (function(p) {
|
|
235
|
+
const g = {};
|
|
236
|
+
if (!p) return g;
|
|
237
|
+
for (const [y, I] of Object.entries(p)) I != null && (Array.isArray(I) ? g[y.toLowerCase()] = I.join(", ") : g[y.toLowerCase()] = String(I));
|
|
238
|
+
return g;
|
|
239
|
+
})(d?.headers), a = c["x-sf3-rid"], u = c["x-sf3-functionspancaptureoverride"];
|
|
240
|
+
n && (_("[patchNodeHttpInbound] Intercepted request event."), _("[patchNodeHttpInbound] Inbound headers:", c), _("[patchNodeHttpInbound] Trace header:", a), _("[patchNodeHttpInbound] FuncSpan override header:", u));
|
|
241
|
+
const f = J.getInstance();
|
|
242
|
+
f.setTraceId(a);
|
|
243
|
+
const h = f.getTraceId();
|
|
244
|
+
n && _("[patchNodeHttpInbound] Context traceId set:", h);
|
|
245
|
+
const m = () => f.runWith({ inboundHeaders: c, ...a ? { traceId: a } : {} }, () => {
|
|
246
|
+
a && f.setTraceId(a), n && _("[patchNodeHttpInbound] Running request handler in context.");
|
|
247
|
+
const p = () => {
|
|
248
|
+
n && _("[patchNodeHttpInbound] Response finished/closed for traceId:", f.getTraceId());
|
|
448
249
|
};
|
|
449
|
-
return
|
|
250
|
+
return i.on("finish", p), i.on("close", p), s.call(this, r, d, i);
|
|
450
251
|
});
|
|
451
|
-
if (!
|
|
252
|
+
if (!u) return m();
|
|
452
253
|
try {
|
|
453
|
-
return
|
|
254
|
+
return me.run(u, () => m());
|
|
454
255
|
} catch {
|
|
455
|
-
return
|
|
256
|
+
return m();
|
|
456
257
|
}
|
|
457
|
-
}) : n &&
|
|
258
|
+
}) : n && _("[patchNodeHttpInbound] Already patched, skipping.");
|
|
458
259
|
}
|
|
459
|
-
class
|
|
260
|
+
class Ae extends V {
|
|
460
261
|
constructor() {
|
|
461
262
|
super(), this.setOperationName("DomainsToNotPassHeaderTo");
|
|
462
263
|
}
|
|
@@ -477,13 +278,13 @@ class Ee extends ee {
|
|
|
477
278
|
)
|
|
478
279
|
}
|
|
479
280
|
`, s = { apiKey: this.apiKey, serviceUuid: this.serviceUUID, domains: e };
|
|
480
|
-
|
|
281
|
+
F(this.endpoint, this.operationName, t, s);
|
|
481
282
|
}
|
|
482
283
|
}
|
|
483
|
-
class
|
|
284
|
+
class Oe extends D {
|
|
484
285
|
constructor() {
|
|
485
286
|
super();
|
|
486
|
-
|
|
287
|
+
S(this, "serviceIdentifier", new E());
|
|
487
288
|
this.setOperationName("CollectNetworkHops");
|
|
488
289
|
}
|
|
489
290
|
async sendAppIdentifier() {
|
|
@@ -493,8 +294,8 @@ class Te extends F {
|
|
|
493
294
|
this.sendAppIdentifier(), this.send(t);
|
|
494
295
|
}
|
|
495
296
|
async send(t) {
|
|
496
|
-
const { name: s, column:
|
|
497
|
-
|
|
297
|
+
const { name: s, column: r, line: o, entrypoint: d, retryWithoutTraceId: i } = t, c = this.getVariables({ name: s, column: r, line: o, entrypoint: d, retryWithoutTraceId: i });
|
|
298
|
+
F(this.endpoint, this.operationName, this.getQuery(), c);
|
|
498
299
|
}
|
|
499
300
|
getQuery() {
|
|
500
301
|
return `
|
|
@@ -524,10 +325,10 @@ class Te extends F {
|
|
|
524
325
|
`;
|
|
525
326
|
}
|
|
526
327
|
}
|
|
527
|
-
class
|
|
328
|
+
class Le extends D {
|
|
528
329
|
constructor() {
|
|
529
330
|
super();
|
|
530
|
-
|
|
331
|
+
S(this, "serviceIdentifier", new E());
|
|
531
332
|
this.setOperationName("CollectNetworkRequest");
|
|
532
333
|
}
|
|
533
334
|
async sendAppIdentifier() {
|
|
@@ -548,174 +349,174 @@ class $e extends F {
|
|
|
548
349
|
}
|
|
549
350
|
async send(t) {
|
|
550
351
|
const s = { data: { ...t } };
|
|
551
|
-
await
|
|
352
|
+
await F(this.endpoint, this.operationName, this.getQuery(), s);
|
|
552
353
|
}
|
|
553
354
|
}
|
|
554
|
-
const
|
|
555
|
-
class
|
|
355
|
+
const K = [400, 403];
|
|
356
|
+
class ke {
|
|
556
357
|
constructor(e = []) {
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
this.contextManager =
|
|
358
|
+
S(this, "HEADER_TRACING", "X-Sf3-Rid");
|
|
359
|
+
S(this, "HEADER_LOG_GUARD", "reentrancy_guard_logging_preactive");
|
|
360
|
+
S(this, "HEADER_PRINT_GUARD", "reentrancy_guard_print_preactive");
|
|
361
|
+
S(this, "HEADER_EXCEPTION_GUARD", "reentrancy_guard_exception_preactive");
|
|
362
|
+
S(this, "contextManager");
|
|
363
|
+
this.contextManager = J.getInstance(), e?.forEach((t) => {
|
|
563
364
|
typeof t == "string" && t.trim() && this.contextManager.getExcludedDomains().add(t);
|
|
564
|
-
}),
|
|
365
|
+
}), l().sfDebug && console.log("[RequestInterceptor] Initialized with static excluded domains.");
|
|
565
366
|
}
|
|
566
367
|
extractIdsFromTraceHeader(e, t = this.HEADER_TRACING) {
|
|
567
368
|
let s;
|
|
568
369
|
if (e instanceof Headers) s = e.get(t) ?? void 0;
|
|
569
370
|
else {
|
|
570
|
-
const
|
|
571
|
-
for (const [
|
|
572
|
-
s =
|
|
371
|
+
const o = t.toLowerCase();
|
|
372
|
+
for (const [d, i] of Object.entries(e)) if (d.toLowerCase() === o) {
|
|
373
|
+
s = i;
|
|
573
374
|
break;
|
|
574
375
|
}
|
|
575
376
|
}
|
|
576
377
|
if (!s) return {};
|
|
577
|
-
const
|
|
578
|
-
return
|
|
378
|
+
const r = s.split("/").filter(Boolean);
|
|
379
|
+
return r.length < 3 ? {} : { sessionId: r[0], pageVisitId: r[1], requestId: r[r.length - 1] };
|
|
579
380
|
}
|
|
580
381
|
parseStackFrame(e) {
|
|
581
382
|
const t = /\((.*):(\d+):(\d+)\)$/.exec(e.trim());
|
|
582
383
|
if (!t) return null;
|
|
583
|
-
const [, s,
|
|
584
|
-
return { filePath: s, line: parseInt(
|
|
384
|
+
const [, s, r, o] = t;
|
|
385
|
+
return { filePath: s, line: parseInt(r, 10), column: parseInt(o, 10) };
|
|
585
386
|
}
|
|
586
387
|
async getOriginalPosition(e, t, s) {
|
|
587
|
-
let
|
|
588
|
-
const
|
|
388
|
+
let r = { source: e, line: t, column: s, name: null };
|
|
389
|
+
const o = e + ".map";
|
|
589
390
|
try {
|
|
590
|
-
const
|
|
591
|
-
let
|
|
592
|
-
|
|
593
|
-
} catch (
|
|
594
|
-
|
|
391
|
+
const d = JSON.parse(Ne(o, "utf-8"));
|
|
392
|
+
let i = (await new we.SourceMapConsumer(d)).originalPositionFor({ line: t, column: s });
|
|
393
|
+
i.source && (r = i);
|
|
394
|
+
} catch (d) {
|
|
395
|
+
l().sfDebug && console.error(`Could not read/parse map file at ${o}:`, d);
|
|
595
396
|
}
|
|
596
|
-
return { originalPos:
|
|
397
|
+
return { originalPos: r };
|
|
597
398
|
}
|
|
598
399
|
captureFirstUserLines(e, t = 10, s = !1) {
|
|
599
|
-
const
|
|
600
|
-
Error.stackTraceLimit = Math.max(
|
|
601
|
-
const
|
|
602
|
-
|
|
603
|
-
const
|
|
604
|
-
Error.stackTraceLimit =
|
|
605
|
-
const c =
|
|
400
|
+
const r = l().sfDebug ? 10 : t, o = Error.stackTraceLimit;
|
|
401
|
+
Error.stackTraceLimit = Math.max(o, r);
|
|
402
|
+
const d = new Error(Y);
|
|
403
|
+
Y in Error && Error.captureStackTrace(d, this.captureFirstUserLines);
|
|
404
|
+
const i = d.stack || "";
|
|
405
|
+
Error.stackTraceLimit = o;
|
|
406
|
+
const c = i.split(`
|
|
606
407
|
`).slice(1), a = [];
|
|
607
|
-
for (const
|
|
608
|
-
if (!(
|
|
609
|
-
for (const
|
|
610
|
-
const
|
|
611
|
-
|
|
612
|
-
const { originalPos:
|
|
613
|
-
if (
|
|
614
|
-
|
|
615
|
-
const
|
|
616
|
-
e.doSend(
|
|
408
|
+
for (const u of c)
|
|
409
|
+
if (!(u.includes("node:internal") || u.includes("internal/modules") || u.includes("internal/process") || u.includes("node_modules") || u.includes(".next/server/chunks") || u.includes("RequestInterceptor") || u.includes("contextManager") || u.includes("setupConfig")) && (a.push(u.trim()), a.length >= t)) break;
|
|
410
|
+
for (const u of a) {
|
|
411
|
+
const f = this.parseStackFrame(u);
|
|
412
|
+
f ? (async () => {
|
|
413
|
+
const { originalPos: h } = await this.getOriginalPosition(f.filePath, f.line, f.column);
|
|
414
|
+
if (h) {
|
|
415
|
+
l().sfDebug && console.log("[RequestInterceptor] First user code line:", h);
|
|
416
|
+
const m = { line: h.line?.toString() || A.UNKNOWN, column: h.column?.toString() || A.NOT_CAPTURED, name: h.name || A.NOT_CAPTURED, entrypoint: h.source, retryWithoutTraceId: s };
|
|
417
|
+
e.doSend(m);
|
|
617
418
|
}
|
|
618
|
-
})() :
|
|
419
|
+
})() : l().sfDebug && console.error("Could not parse stack line:", u);
|
|
619
420
|
}
|
|
620
421
|
}
|
|
621
422
|
addReentrancyGuardHeaders(e) {
|
|
622
423
|
e.set(this.HEADER_LOG_GUARD, "true"), e.set(this.HEADER_PRINT_GUARD, "true"), e.set(this.HEADER_EXCEPTION_GUARD, "true");
|
|
623
424
|
}
|
|
624
425
|
shouldPropagateHeaders(e) {
|
|
625
|
-
return !
|
|
426
|
+
return !he.some((t) => new RegExp(`^${t.replace(/\*/g, ".*")}$`).test(e));
|
|
626
427
|
}
|
|
627
428
|
addTracingHeaders(e, t) {
|
|
628
|
-
const s = new URL(t).hostname,
|
|
629
|
-
return
|
|
429
|
+
const s = new URL(t).hostname, r = this.shouldPropagateHeaders(s);
|
|
430
|
+
return r ? this.addTracingHeader(e, t) : l().sfDebug && console.error(`[RequestInterceptor] Excluded domain: ${s}`), r;
|
|
630
431
|
}
|
|
631
432
|
addTracingHeader(e, t) {
|
|
632
|
-
const s =
|
|
433
|
+
const s = ce();
|
|
633
434
|
if (s) {
|
|
634
|
-
const
|
|
635
|
-
if (
|
|
435
|
+
const i = de(s);
|
|
436
|
+
if (i && i.sample_rate === 0) return void (l().sfDebug && console.log(`[RequestInterceptor] Function span tracking disabled (sample_rate=0), skipping tracing header for ${t}`));
|
|
636
437
|
}
|
|
637
|
-
const
|
|
638
|
-
e.set(this.HEADER_TRACING, `${
|
|
438
|
+
const r = this.contextManager.getOrSetSfTraceId(), o = this.contextManager.getOrSetPageVisitUUID(), d = ie();
|
|
439
|
+
e.set(this.HEADER_TRACING, `${r}/${o}/${d}`), l().sfDebug && console.log(`[RequestInterceptor] Added tracing header for ${t}`);
|
|
639
440
|
}
|
|
640
441
|
patchFetch(e, t) {
|
|
641
442
|
const s = globalThis.fetch;
|
|
642
|
-
typeof s == "function" ? globalThis.fetch = async (
|
|
643
|
-
const
|
|
644
|
-
if (
|
|
443
|
+
typeof s == "function" ? globalThis.fetch = async (r, o) => {
|
|
444
|
+
const d = new Headers(o?.headers);
|
|
445
|
+
if (d.get(this.HEADER_LOG_GUARD) === "true" || d.get(this.HEADER_PRINT_GUARD) === "true" || d.get(this.HEADER_EXCEPTION_GUARD) === "true") return s(r, o);
|
|
645
446
|
this.captureFirstUserLines(e);
|
|
646
|
-
const
|
|
447
|
+
const i = Date.now();
|
|
647
448
|
let c;
|
|
648
|
-
typeof
|
|
649
|
-
|
|
650
|
-
})) :
|
|
651
|
-
const a = new URL(c).hostname,
|
|
652
|
-
let
|
|
449
|
+
typeof r == "string" || r instanceof URL ? c = r.toString() : r instanceof Request ? (c = r.url, r.headers.forEach((p, g) => {
|
|
450
|
+
d.set(g, p);
|
|
451
|
+
})) : l().sfDebug && console.error("[Sailfish RequestInterceptor] Invalid fetch input."), l().sfDebug && console.log("[RequestInterceptor] Fetching request to:", c);
|
|
452
|
+
const a = new URL(c).hostname, u = new Headers(d), f = this.addTracingHeaders(d, c), h = { ...o, headers: d };
|
|
453
|
+
let m;
|
|
653
454
|
try {
|
|
654
|
-
let
|
|
655
|
-
this.addTracingHeaders(
|
|
656
|
-
const
|
|
657
|
-
|
|
658
|
-
const { sessionId:
|
|
659
|
-
return t.doSend({ apiKey:
|
|
660
|
-
} catch (
|
|
661
|
-
const
|
|
662
|
-
|
|
455
|
+
let p = !1;
|
|
456
|
+
this.addTracingHeaders(u, c), m = await s(c, h), f && K.includes(m.status) ? (m = await s(c, { ...o, headers: u }), p = !0, this.captureFirstUserLines(e, 10, p)) : this.contextManager.addSupportedDomains(a);
|
|
457
|
+
const g = Date.now();
|
|
458
|
+
l().sfDebug && console.log(`[RequestInterceptor] Fetch completed: ${c}, Status: ${m.status}, Duration: ${g - i}ms`);
|
|
459
|
+
const { sessionId: y, pageVisitId: I, requestId: v } = this.extractIdsFromTraceHeader(d);
|
|
460
|
+
return t.doSend({ apiKey: l().apiKey, requestId: v, pageVisitId: I, recordingSessionId: y, serviceUuid: l().serviceUUID, timestampStart: i.toString(), timestampEnd: g.toString(), responseCode: m.status, success: !0, error: null, url: c, method: h.method || "GET", retryWithoutTraceId: p, parentSpanId: q() }), m;
|
|
461
|
+
} catch (p) {
|
|
462
|
+
const g = Date.now();
|
|
463
|
+
l().sfDebug && console.error(`[RequestInterceptor] Fetch failed: ${c}, Error: ${p}, Duration: ${g - i}ms`);
|
|
663
464
|
}
|
|
664
|
-
} :
|
|
465
|
+
} : l().sfDebug && console.error("[RequestInterceptor] Fetch not available.");
|
|
665
466
|
}
|
|
666
467
|
patchHttp(e, t) {
|
|
667
|
-
if (
|
|
668
|
-
const s =
|
|
669
|
-
|
|
670
|
-
let
|
|
468
|
+
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."));
|
|
469
|
+
const s = b.request.bind(b), r = b.request.bind(b);
|
|
470
|
+
b.request = function(o, d) {
|
|
471
|
+
let i;
|
|
671
472
|
try {
|
|
672
|
-
if (typeof
|
|
673
|
-
const a = new URL(
|
|
674
|
-
|
|
675
|
-
} else
|
|
676
|
-
if (
|
|
677
|
-
const a = `${
|
|
678
|
-
this.addTracingHeaders(
|
|
679
|
-
} else
|
|
473
|
+
if (typeof o == "string") {
|
|
474
|
+
const a = new URL(o);
|
|
475
|
+
i = { protocol: a.protocol || x, hostname: a.hostname, path: a.pathname + a.search, headers: {} };
|
|
476
|
+
} else o instanceof URL ? i = { protocol: o.protocol || x, hostname: o.hostname, path: o.pathname + o.search, headers: {} } : (i = { ...o }, i.protocol || (i.protocol = x));
|
|
477
|
+
if (i.headers) {
|
|
478
|
+
const a = `${i.protocol}//${i.hostname}`;
|
|
479
|
+
this.addTracingHeaders(i.headers, a), this.captureFirstUserLines(e);
|
|
480
|
+
} else l().sfDebug && console.warn("[RequestInterceptor] No headers found in HTTP request options. Skipping header addition.");
|
|
680
481
|
} catch (a) {
|
|
681
|
-
throw
|
|
482
|
+
throw l().sfDebug && console.error("[RequestInterceptor] Error while processing HTTP request options:", a), a;
|
|
682
483
|
}
|
|
683
484
|
let c = !1;
|
|
684
|
-
return s(
|
|
685
|
-
const
|
|
686
|
-
if (
|
|
687
|
-
|
|
688
|
-
const
|
|
689
|
-
delete
|
|
485
|
+
return s(i, (a) => {
|
|
486
|
+
const u = `${i.protocol}//${i.hostname}`;
|
|
487
|
+
if (i.headers && this.shouldPropagateHeaders(new URL(u).hostname) && K.includes(a.statusCode || 0)) {
|
|
488
|
+
i.hostname;
|
|
489
|
+
const p = { ...i, headers: { ...i.headers } };
|
|
490
|
+
delete p.headers[this.HEADER_TRACING], s(p, d), c = !0, this.captureFirstUserLines(e, 10, c);
|
|
690
491
|
}
|
|
691
|
-
const { sessionId:
|
|
692
|
-
t.doSend({ apiKey:
|
|
492
|
+
const { sessionId: f, pageVisitId: h, requestId: m } = this.extractIdsFromTraceHeader(i.headers);
|
|
493
|
+
t.doSend({ apiKey: l().apiKey, requestId: m, pageVisitId: h, recordingSessionId: f, serviceUuid: l().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: a.statusCode || 0, success: !!a.statusCode && a.statusCode < 400, error: null, url: u, method: i.method || "GET", retryWithoutTraceId: c, parentSpanId: q() }), d?.(a);
|
|
693
494
|
});
|
|
694
|
-
},
|
|
695
|
-
let
|
|
495
|
+
}, b.request = function(o, d) {
|
|
496
|
+
let i;
|
|
696
497
|
try {
|
|
697
|
-
if (typeof
|
|
698
|
-
const a = new URL(
|
|
699
|
-
|
|
700
|
-
} else
|
|
701
|
-
if (
|
|
702
|
-
const a = `${
|
|
703
|
-
this.addTracingHeaders(
|
|
704
|
-
} else
|
|
498
|
+
if (typeof o == "string") {
|
|
499
|
+
const a = new URL(o);
|
|
500
|
+
i = { protocol: a.protocol || G, hostname: a.hostname, path: a.pathname + a.search, headers: {} };
|
|
501
|
+
} else o instanceof URL ? i = { protocol: o.protocol || G, hostname: o.hostname, path: o.pathname + o.search, headers: {} } : (i = { ...o }, i.protocol || (i.protocol = G));
|
|
502
|
+
if (i.headers) {
|
|
503
|
+
const a = `${i.protocol}//${i.hostname}`;
|
|
504
|
+
this.addTracingHeaders(i.headers, a);
|
|
505
|
+
} else l().sfDebug && console.warn("[RequestInterceptor] No headers found in HTTPS request options. Skipping header addition.");
|
|
705
506
|
} catch (a) {
|
|
706
|
-
throw
|
|
507
|
+
throw l().sfDebug && console.error("[RequestInterceptor] Error while processing HTTPS request options:", a), a;
|
|
707
508
|
}
|
|
708
509
|
let c = !1;
|
|
709
|
-
return
|
|
710
|
-
const
|
|
711
|
-
if (
|
|
712
|
-
const
|
|
713
|
-
delete
|
|
510
|
+
return r(i, (a) => {
|
|
511
|
+
const u = `${i.protocol}//${i.hostname}`;
|
|
512
|
+
if (i.headers && this.shouldPropagateHeaders(new URL(u).hostname) && K.includes(a.statusCode || 0)) {
|
|
513
|
+
const p = { ...i, headers: { ...i.headers } };
|
|
514
|
+
delete p.headers[this.HEADER_TRACING], r(p, d), c = !0, this.captureFirstUserLines(e, 10, c);
|
|
714
515
|
}
|
|
715
|
-
const { sessionId:
|
|
716
|
-
t.doSend({ apiKey:
|
|
516
|
+
const { sessionId: f, pageVisitId: h, requestId: m } = this.extractIdsFromTraceHeader(i.headers);
|
|
517
|
+
t.doSend({ apiKey: l().apiKey, requestId: m, pageVisitId: h, recordingSessionId: f, serviceUuid: l().serviceUUID, timestampStart: Date.now().toString(), timestampEnd: Date.now().toString(), responseCode: a.statusCode || 0, success: !!a.statusCode && a.statusCode < 400, error: null, url: u, method: i.method || "GET", retryWithoutTraceId: c, parentSpanId: q() }), d?.(a);
|
|
717
518
|
});
|
|
718
|
-
},
|
|
519
|
+
}, l().sfDebug && console.log("✅ HTTP and HTTPS request methods patched globally.");
|
|
719
520
|
}
|
|
720
521
|
tryPatch(e, t) {
|
|
721
522
|
try {
|
|
@@ -728,7 +529,7 @@ class Le {
|
|
|
728
529
|
return [...this.contextManager.getExcludedDomains()];
|
|
729
530
|
}
|
|
730
531
|
}
|
|
731
|
-
class
|
|
532
|
+
class qe extends V {
|
|
732
533
|
constructor() {
|
|
733
534
|
super(), this.setOperationName("UpdateServiceDetails");
|
|
734
535
|
}
|
|
@@ -756,43 +557,47 @@ class De extends ee {
|
|
|
756
557
|
gitSha: $gitSha,
|
|
757
558
|
)
|
|
758
559
|
}
|
|
759
|
-
`, t = this.getVariables({ serviceIdentifier:
|
|
760
|
-
|
|
560
|
+
`, t = this.getVariables({ serviceIdentifier: l().serviceIdentifier, serviceVersion: l().serviceVersion, serviceAdditionalMetadata: l().serviceAdditionalMetadata, gitSha: l().gitSha || "" });
|
|
561
|
+
F(this.endpoint, this.operationName, e, t);
|
|
761
562
|
}
|
|
762
563
|
}
|
|
763
|
-
class
|
|
564
|
+
class Me {
|
|
764
565
|
constructor(e = [process.cwd()], t = !1) {
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
566
|
+
S(this, "rootPaths");
|
|
567
|
+
S(this, "fileConfigs", /* @__PURE__ */ new Map());
|
|
568
|
+
S(this, "functionConfigs", /* @__PURE__ */ new Map());
|
|
569
|
+
S(this, "directoryConfigs", /* @__PURE__ */ new Map());
|
|
570
|
+
S(this, "hasSailfishFiles", !1);
|
|
571
|
+
S(this, "runtimeModeEnabled", !1);
|
|
572
|
+
S(this, "debug");
|
|
771
573
|
this.rootPaths = e, this.debug = t || process.env.SF_DEBUG === "true";
|
|
772
574
|
}
|
|
773
575
|
async loadAllConfigs() {
|
|
774
576
|
this.debug && console.log("[FuncSpan ConfigLoader] Scanning for .sailfish files in:", this.rootPaths);
|
|
775
577
|
const e = [];
|
|
776
|
-
for (const t of this.rootPaths)
|
|
578
|
+
for (const t of this.rootPaths) H.existsSync(t) ? await this._walkDirectory(t, e) : this.debug && console.log(`[FuncSpan ConfigLoader] Root path does not exist: ${t}`);
|
|
777
579
|
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");
|
|
778
580
|
for (const t of e) await this._loadConfigFile(t);
|
|
779
581
|
await this._resolveInheritance(), this.debug && console.log(`[FuncSpan ConfigLoader] Loaded ${this.fileConfigs.size} file configs, ${this.functionConfigs.size} function configs`);
|
|
780
582
|
}
|
|
781
583
|
getConfig(e, t) {
|
|
782
|
-
const s = this.hasSailfishFiles ?
|
|
783
|
-
let
|
|
584
|
+
const s = this.hasSailfishFiles ? le() : Se(), r = this._getDirectoryConfig(e), o = $.normalize(e), d = this.fileConfigs.get(o) || {};
|
|
585
|
+
let i = {};
|
|
784
586
|
if (t) {
|
|
785
|
-
const c = this.functionConfigs.get(
|
|
786
|
-
c && (
|
|
587
|
+
const c = this.functionConfigs.get(o);
|
|
588
|
+
c && (i = c.get(t) || {});
|
|
787
589
|
}
|
|
788
|
-
return
|
|
590
|
+
return P(s, r, d, i);
|
|
591
|
+
}
|
|
592
|
+
hasRuntimeMode() {
|
|
593
|
+
return this.runtimeModeEnabled;
|
|
789
594
|
}
|
|
790
595
|
async _walkDirectory(e, t) {
|
|
791
596
|
try {
|
|
792
|
-
const s =
|
|
793
|
-
for (const
|
|
794
|
-
const
|
|
795
|
-
|
|
597
|
+
const s = H.readdirSync(e, { withFileTypes: !0 });
|
|
598
|
+
for (const r of s) {
|
|
599
|
+
const o = $.join(e, r.name);
|
|
600
|
+
r.isFile() && r.name === ".sailfish" ? t.push(o) : r.name === "node_modules" || r.isDirectory() && r.name.startsWith(".") && r.name !== ".sailfish" || r.isDirectory() && await this._walkDirectory(o, t);
|
|
796
601
|
}
|
|
797
602
|
} catch (s) {
|
|
798
603
|
this.debug && console.error(`[FuncSpan ConfigLoader] Error walking directory ${e}:`, s);
|
|
@@ -800,81 +605,81 @@ class Pe {
|
|
|
800
605
|
}
|
|
801
606
|
async _loadConfigFile(e) {
|
|
802
607
|
try {
|
|
803
|
-
const t =
|
|
804
|
-
let
|
|
608
|
+
const t = H.readFileSync(e, "utf-8"), s = $.dirname(e);
|
|
609
|
+
let r = null;
|
|
805
610
|
try {
|
|
806
|
-
|
|
611
|
+
r = JSON.parse(t);
|
|
807
612
|
} catch {
|
|
808
613
|
try {
|
|
809
|
-
|
|
810
|
-
} catch (
|
|
811
|
-
return void (this.debug && console.error(`[FuncSpan ConfigLoader] Failed to parse ${e} as JSON or YAML:`,
|
|
614
|
+
r = require("js-yaml").load(t);
|
|
615
|
+
} catch (o) {
|
|
616
|
+
return void (this.debug && console.error(`[FuncSpan ConfigLoader] Failed to parse ${e} as JSON or YAML:`, o));
|
|
812
617
|
}
|
|
813
618
|
}
|
|
814
|
-
if (!
|
|
815
|
-
|
|
619
|
+
if (!r) return;
|
|
620
|
+
r.runtime_mode === !0 && (this.runtimeModeEnabled = !0, this.debug && console.log(`[FuncSpan ConfigLoader] Runtime mode ENABLED in ${e}`)), r.default && this.directoryConfigs.set(s, r.default), r.files && await this._expandFileGlobs(s, r.files, r.default || {}), r.functions && this._storeFunctionConfigs(s, r.functions, r.default || {}), this.debug && (console.log(`[FuncSpan ConfigLoader] Loaded config from ${e}`), console.log(`[FuncSpan ConfigLoader] Directory: ${s}`), console.log(`[FuncSpan ConfigLoader] Has default: ${!!r.default}`), console.log(`[FuncSpan ConfigLoader] File patterns: ${Object.keys(r.files || {}).length}`), console.log(`[FuncSpan ConfigLoader] Functions: ${Object.keys(r.functions || {}).length}`));
|
|
816
621
|
} catch (t) {
|
|
817
622
|
this.debug && console.error(`[FuncSpan ConfigLoader] Error loading ${e}:`, t);
|
|
818
623
|
}
|
|
819
624
|
}
|
|
820
625
|
async _expandFileGlobs(e, t, s) {
|
|
821
|
-
for (const [
|
|
822
|
-
const
|
|
823
|
-
this.debug && console.log(`[FuncSpan ConfigLoader] Pattern '${
|
|
824
|
-
for (const c of
|
|
825
|
-
const a =
|
|
826
|
-
this.fileConfigs.set(a,
|
|
626
|
+
for (const [r, o] of Object.entries(t)) try {
|
|
627
|
+
const d = $.join(e, r), i = await Ee(d, { absolute: !0, nodir: !0, ignore: ["**/node_modules/**", "**/.git/**"] });
|
|
628
|
+
this.debug && console.log(`[FuncSpan ConfigLoader] Pattern '${r}' matched ${i.length} files`);
|
|
629
|
+
for (const c of i) {
|
|
630
|
+
const a = $.normalize(c), u = P(s, o);
|
|
631
|
+
this.fileConfigs.set(a, u), this.debug && i.length <= 5 && console.log(`[FuncSpan ConfigLoader] - ${c}`);
|
|
827
632
|
}
|
|
828
|
-
} catch (
|
|
829
|
-
this.debug && console.error(`[FuncSpan ConfigLoader] Error expanding glob '${
|
|
633
|
+
} catch (d) {
|
|
634
|
+
this.debug && console.error(`[FuncSpan ConfigLoader] Error expanding glob '${r}':`, d);
|
|
830
635
|
}
|
|
831
636
|
}
|
|
832
637
|
_storeFunctionConfigs(e, t, s) {
|
|
833
|
-
for (const [
|
|
834
|
-
const
|
|
835
|
-
if (
|
|
836
|
-
this.debug && console.warn(`[FuncSpan ConfigLoader] Invalid function pattern '${
|
|
638
|
+
for (const [r, o] of Object.entries(t)) {
|
|
639
|
+
const d = r.split("::");
|
|
640
|
+
if (d.length !== 2) {
|
|
641
|
+
this.debug && console.warn(`[FuncSpan ConfigLoader] Invalid function pattern '${r}' (expected format: 'file.ts::functionName')`);
|
|
837
642
|
continue;
|
|
838
643
|
}
|
|
839
|
-
const [
|
|
644
|
+
const [i, c] = d, a = $.normalize($.join(e, i));
|
|
840
645
|
this.functionConfigs.has(a) || this.functionConfigs.set(a, /* @__PURE__ */ new Map());
|
|
841
|
-
const
|
|
842
|
-
|
|
646
|
+
const u = this.functionConfigs.get(a), f = P(s, o);
|
|
647
|
+
u.set(c, f), this.debug && console.log(`[FuncSpan ConfigLoader] Function config: ${a}::${c}`);
|
|
843
648
|
}
|
|
844
649
|
}
|
|
845
650
|
async _resolveInheritance() {
|
|
846
651
|
}
|
|
847
652
|
_getDirectoryConfig(e) {
|
|
848
|
-
let t =
|
|
653
|
+
let t = $.dirname($.normalize(e));
|
|
849
654
|
const s = [];
|
|
850
|
-
for (; t && t !==
|
|
851
|
-
const
|
|
852
|
-
|
|
655
|
+
for (; t && t !== $.dirname(t); ) {
|
|
656
|
+
const r = this.directoryConfigs.get(t);
|
|
657
|
+
r && s.unshift(r), t = $.dirname(t);
|
|
853
658
|
}
|
|
854
|
-
return s.reduce((
|
|
659
|
+
return s.reduce((r, o) => P(r, o), {});
|
|
855
660
|
}
|
|
856
661
|
}
|
|
857
|
-
let
|
|
858
|
-
async function
|
|
859
|
-
|
|
662
|
+
let w = null;
|
|
663
|
+
async function He(n, e) {
|
|
664
|
+
w = new Me(n, e), await w.loadAllConfigs();
|
|
860
665
|
}
|
|
861
|
-
function
|
|
862
|
-
return
|
|
666
|
+
function xe(n, e) {
|
|
667
|
+
return w ? w.getConfig(n, e) : (process.env.SF_DEBUG === "true" && console.log("[FuncSpan ConfigLoader] Config loader not initialized, using env config for worker process"), le());
|
|
863
668
|
}
|
|
864
|
-
function
|
|
865
|
-
return
|
|
669
|
+
function Ge() {
|
|
670
|
+
return w !== null;
|
|
866
671
|
}
|
|
867
|
-
const
|
|
868
|
-
let
|
|
869
|
-
function
|
|
672
|
+
const Ke = ["readFile", "writeFile", "appendFile", "readdir", "stat", "lstat", "fstat", "access", "open", "close", "read", "write", "chmod", "mkdir", "rmdir", "unlink", "rename"], ee = ["lookup", "resolve", "resolve4", "resolve6", "resolveAny", "resolveMx", "resolveNs", "resolveTxt", "reverse"], We = ["pbkdf2", "randomBytes", "scrypt", "generateKeyPair"], ze = ["gzip", "gunzip", "deflate", "inflate", "deflateRaw", "inflateRaw", "brotliCompress", "brotliDecompress"];
|
|
673
|
+
let te = !1;
|
|
674
|
+
function je(n) {
|
|
870
675
|
if (typeof n != "string") return !1;
|
|
871
676
|
const e = process.env.SF_FUNCSPAN_JSONL_FILE;
|
|
872
677
|
if (e && n.includes(e)) return !0;
|
|
873
678
|
const t = process.env.SF_WORKER_POOL_JSONL_FILE;
|
|
874
679
|
return !(!t || !n.includes(t));
|
|
875
680
|
}
|
|
876
|
-
let
|
|
877
|
-
function
|
|
681
|
+
let ne = !1;
|
|
682
|
+
function re(n) {
|
|
878
683
|
if (typeof n != "string") return !1;
|
|
879
684
|
if (n === "localhost" || n === "127.0.0.1" || n === "::1") return !0;
|
|
880
685
|
try {
|
|
@@ -885,8 +690,8 @@ function le(n) {
|
|
|
885
690
|
}
|
|
886
691
|
return !1;
|
|
887
692
|
}
|
|
888
|
-
function
|
|
889
|
-
if (!
|
|
693
|
+
function Be() {
|
|
694
|
+
if (!ne) try {
|
|
890
695
|
let n;
|
|
891
696
|
if (typeof require > "u") return void (process.env.SF_DEBUG === "true" && console.log("[WorkerPool] Skipping dns patching in pure ESM environment (require unavailable)"));
|
|
892
697
|
try {
|
|
@@ -896,230 +701,223 @@ function tt() {
|
|
|
896
701
|
}
|
|
897
702
|
if (n.__sf_worker_pool_patched__) return;
|
|
898
703
|
Object.defineProperty(n, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
|
|
899
|
-
for (const e of
|
|
704
|
+
for (const e of ee) if (typeof n[e] == "function") {
|
|
900
705
|
const t = n[e];
|
|
901
706
|
n[e] = function(...s) {
|
|
902
|
-
return
|
|
707
|
+
return re(s[0]) ? t.apply(this, s) : typeof s[s.length - 1] == "function" ? R("dns", e, t, s, this) : t.apply(this, s);
|
|
903
708
|
}, Object.defineProperty(n[e], "name", { value: e, writable: !1 });
|
|
904
709
|
}
|
|
905
710
|
(function(e) {
|
|
906
711
|
if (!e.promises) return void (process.env.SF_DEBUG === "true" && console.log("[WorkerPool] dns.promises not available, skipping"));
|
|
907
712
|
if (!e.promises.__sf_worker_pool_patched__) {
|
|
908
713
|
Object.defineProperty(e.promises, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
|
|
909
|
-
for (const t of
|
|
714
|
+
for (const t of ee) if (typeof e.promises[t] == "function") {
|
|
910
715
|
const s = e.promises[t];
|
|
911
|
-
e.promises[t] = function(...
|
|
912
|
-
return
|
|
716
|
+
e.promises[t] = function(...r) {
|
|
717
|
+
return re(r[0]) ? s.apply(this, r) : ye("dns", t, s, r, this);
|
|
913
718
|
}, Object.defineProperty(e.promises[t], "name", { value: t, writable: !1 });
|
|
914
719
|
}
|
|
915
720
|
process.env.SF_DEBUG === "true" && console.log("[WorkerPool] dns.promises module patched successfully");
|
|
916
721
|
}
|
|
917
|
-
})(n),
|
|
722
|
+
})(n), ne = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] dns module patched successfully");
|
|
918
723
|
} catch (n) {
|
|
919
724
|
console.error("[WorkerPool] Error patching dns module:", n);
|
|
920
725
|
}
|
|
921
726
|
}
|
|
922
|
-
let
|
|
923
|
-
function
|
|
924
|
-
if (
|
|
727
|
+
let se = !1, oe = !1, j = !1;
|
|
728
|
+
function Je() {
|
|
729
|
+
if (j) return;
|
|
925
730
|
const n = process.env.SF_DEBUG === "true";
|
|
926
|
-
n && console.log("[WorkerPool] Initializing worker pool patching..."),
|
|
927
|
-
if (!
|
|
731
|
+
n && console.log("[WorkerPool] Initializing worker pool patching..."), C("fs") && (n && console.log("[WorkerPool] Patching fs module..."), (function() {
|
|
732
|
+
if (!te) try {
|
|
928
733
|
const e = require("node:fs");
|
|
929
734
|
if (e.__sf_worker_pool_patched__) return;
|
|
930
735
|
Object.defineProperty(e, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
|
|
931
|
-
for (const t of
|
|
736
|
+
for (const t of Ke) if (typeof e[t] == "function") {
|
|
932
737
|
const s = e[t];
|
|
933
|
-
e[t] = function(...
|
|
934
|
-
return
|
|
738
|
+
e[t] = function(...r) {
|
|
739
|
+
return je(r[0]) ? s.apply(this, r) : typeof r[r.length - 1] == "function" ? R("fs", t, s, r, this) : s.apply(this, r);
|
|
935
740
|
}, Object.defineProperty(e[t], "name", { value: t, writable: !1 });
|
|
936
741
|
}
|
|
937
|
-
|
|
742
|
+
te = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] fs module patched successfully");
|
|
938
743
|
} catch (e) {
|
|
939
744
|
console.error("[WorkerPool] Error patching fs module:", e);
|
|
940
745
|
}
|
|
941
|
-
})()),
|
|
942
|
-
if (!
|
|
746
|
+
})()), C("dns") && (n && console.log("[WorkerPool] Patching dns module..."), Be()), C("crypto") && (n && console.log("[WorkerPool] Patching crypto module..."), (function() {
|
|
747
|
+
if (!se) try {
|
|
943
748
|
const e = require("node:crypto");
|
|
944
749
|
if (e.__sf_worker_pool_patched__) return;
|
|
945
750
|
Object.defineProperty(e, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
|
|
946
|
-
for (const t of
|
|
751
|
+
for (const t of We) if (typeof e[t] == "function") {
|
|
947
752
|
const s = e[t];
|
|
948
|
-
e[t] = function(...
|
|
949
|
-
return typeof
|
|
753
|
+
e[t] = function(...r) {
|
|
754
|
+
return typeof r[r.length - 1] == "function" ? R("crypto", t, s, r, this) : s.apply(this, r);
|
|
950
755
|
}, Object.defineProperty(e[t], "name", { value: t, writable: !1 });
|
|
951
756
|
}
|
|
952
|
-
|
|
757
|
+
se = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] crypto module patched successfully");
|
|
953
758
|
} catch (e) {
|
|
954
759
|
console.error("[WorkerPool] Error patching crypto module:", e);
|
|
955
760
|
}
|
|
956
|
-
})()),
|
|
957
|
-
if (!
|
|
761
|
+
})()), C("zlib") && (n && console.log("[WorkerPool] Patching zlib module..."), (function() {
|
|
762
|
+
if (!oe) try {
|
|
958
763
|
const e = require("node:zlib");
|
|
959
764
|
if (e.__sf_worker_pool_patched__) return;
|
|
960
765
|
Object.defineProperty(e, "__sf_worker_pool_patched__", { value: !0, enumerable: !1, writable: !1, configurable: !1 });
|
|
961
|
-
for (const t of
|
|
766
|
+
for (const t of ze) if (typeof e[t] == "function") {
|
|
962
767
|
const s = e[t];
|
|
963
|
-
e[t] = function(...
|
|
964
|
-
return typeof
|
|
768
|
+
e[t] = function(...r) {
|
|
769
|
+
return typeof r[r.length - 1] == "function" ? R("zlib", t, s, r, this) : s.apply(this, r);
|
|
965
770
|
}, Object.defineProperty(e[t], "name", { value: t, writable: !1 });
|
|
966
771
|
}
|
|
967
|
-
|
|
772
|
+
oe = !0, process.env.SF_DEBUG === "true" && console.log("[WorkerPool] zlib module patched successfully");
|
|
968
773
|
} catch (e) {
|
|
969
774
|
console.error("[WorkerPool] Error patching zlib module:", e);
|
|
970
775
|
}
|
|
971
|
-
})()),
|
|
776
|
+
})()), j = !0, n && console.log("[WorkerPool] Worker pool patching initialized");
|
|
972
777
|
}
|
|
973
|
-
function
|
|
974
|
-
return
|
|
778
|
+
function Ve() {
|
|
779
|
+
return j;
|
|
975
780
|
}
|
|
976
|
-
let
|
|
977
|
-
function
|
|
978
|
-
if (
|
|
979
|
-
else if (!
|
|
980
|
-
|
|
781
|
+
let B = !1, W = !1;
|
|
782
|
+
function ot(n) {
|
|
783
|
+
if (W) console.warn("[setupInterceptors] ⚠️ Recursive call detected and blocked!");
|
|
784
|
+
else if (!B) {
|
|
785
|
+
W = !0;
|
|
981
786
|
try {
|
|
982
787
|
if (!n || !n.apiKey) {
|
|
983
|
-
const
|
|
984
|
-
console.error(
|
|
788
|
+
const r = `The required API Key is not provided: ${JSON.stringify(n)}`;
|
|
789
|
+
console.error(r);
|
|
985
790
|
}
|
|
986
|
-
const { config: e } =
|
|
791
|
+
const { config: e } = ge(n);
|
|
987
792
|
if (e.sfDebug && console.log("Updated configuration after applying options:", e), !e.apiKey || !e.apiGraphqlEndpoint) {
|
|
988
|
-
const
|
|
989
|
-
throw console.error(
|
|
793
|
+
const r = `The required config is not provided: ${JSON.stringify(e)}`;
|
|
794
|
+
throw console.error(r), new Error(r);
|
|
990
795
|
}
|
|
991
|
-
|
|
992
|
-
e.sfDebug && console.error("[FuncSpan] Failed to initialize config loader:",
|
|
993
|
-
}), process.env.SF_WORKER_POOL_DISABLED === "true" ? e.sfDebug && console.log("[setupInterceptors] Worker pool patching DISABLED (SF_WORKER_POOL_DISABLED=true)") :
|
|
994
|
-
const t = new
|
|
995
|
-
t.setServiceUUID(e.serviceUUID), (function(
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
console.log = (...I) => {
|
|
1001
|
-
i("INFO", I.join(" ")), g(...I);
|
|
1002
|
-
}, console.error = (...I) => {
|
|
1003
|
-
i("ERROR", I.join(" ")), r(...I);
|
|
1004
|
-
}, console.warn = (...I) => {
|
|
1005
|
-
i("WARN", I.join(" ")), c(...I);
|
|
1006
|
-
}, console.info = (...I) => {
|
|
1007
|
-
i("INFO", I.join(" ")), a(...I);
|
|
1008
|
-
}, d().logLevel === "DEBUG" && (console.debug = (...I) => {
|
|
1009
|
-
i("DEBUG", I.join(" ")), l(...I);
|
|
1010
|
-
});
|
|
1011
|
-
})(t), (function(o = []) {
|
|
1012
|
-
const i = new Le(o);
|
|
1013
|
-
new Ee().doSend(i.getExcludedDomains());
|
|
1014
|
-
const g = new Te(), r = new $e();
|
|
1015
|
-
i.patchFetch(g, r), i.patchHttp(g, r);
|
|
796
|
+
Ge() || He(void 0, e.sfDebug).catch((r) => {
|
|
797
|
+
e.sfDebug && console.error("[FuncSpan] Failed to initialize config loader:", r);
|
|
798
|
+
}), process.env.SF_WORKER_POOL_DISABLED === "true" ? e.sfDebug && console.log("[setupInterceptors] Worker pool patching DISABLED (SF_WORKER_POOL_DISABLED=true)") : Ve() || (Je(), e.sfDebug && console.log("[setupInterceptors] Worker pool patching initialized (DNS tracking enabled)"));
|
|
799
|
+
const t = new V();
|
|
800
|
+
t.setServiceUUID(e.serviceUUID), ve(t), (function(r = []) {
|
|
801
|
+
const o = new ke(r);
|
|
802
|
+
new Ae().doSend(o.getExcludedDomains());
|
|
803
|
+
const d = new Oe(), i = new Le();
|
|
804
|
+
o.patchFetch(d, i), o.patchHttp(d, i);
|
|
1016
805
|
})(e.domainsToNotPropagateHeadersTo);
|
|
1017
|
-
const s = new
|
|
1018
|
-
s.setServiceUUID(e.serviceUUID),
|
|
806
|
+
const s = new Te();
|
|
807
|
+
s.setServiceUUID(e.serviceUUID), be(s), Re(), new qe().send(), B = !0, e.sfDebug && console.log("[setupInterceptors] ✅ Initialization complete");
|
|
1019
808
|
} finally {
|
|
1020
|
-
|
|
809
|
+
W = !1;
|
|
1021
810
|
}
|
|
1022
811
|
}
|
|
1023
812
|
}
|
|
1024
|
-
function
|
|
1025
|
-
return
|
|
813
|
+
function it() {
|
|
814
|
+
return B;
|
|
1026
815
|
}
|
|
1027
|
-
function
|
|
1028
|
-
const
|
|
1029
|
-
new
|
|
816
|
+
function at(n, e, t, s = !1) {
|
|
817
|
+
const r = l();
|
|
818
|
+
new ue(r.apiKey).identify(n, e, t, s);
|
|
1030
819
|
}
|
|
1031
|
-
function
|
|
1032
|
-
const
|
|
1033
|
-
new
|
|
820
|
+
function ct(n, e = {}, t, s = !1) {
|
|
821
|
+
const r = l();
|
|
822
|
+
new ue(r.apiKey).addOrUpdateMetadata(n, e, t, s);
|
|
1034
823
|
}
|
|
1035
|
-
let
|
|
1036
|
-
function
|
|
1037
|
-
const
|
|
1038
|
-
const
|
|
1039
|
-
|
|
1040
|
-
const c = (function(
|
|
1041
|
-
const
|
|
1042
|
-
if (
|
|
1043
|
-
const
|
|
1044
|
-
if (
|
|
824
|
+
let z = null;
|
|
825
|
+
function dt(n, e, t, s) {
|
|
826
|
+
const r = function(...o) {
|
|
827
|
+
const d = ae(), i = d?.sfDebug || !1;
|
|
828
|
+
i && console.log(`[FuncSpan] captureFunctionSpan wrapper called for ${t}::${e}`);
|
|
829
|
+
const c = (function(g, y) {
|
|
830
|
+
const I = ce();
|
|
831
|
+
if (I) {
|
|
832
|
+
const v = de(I);
|
|
833
|
+
if (v) return process.env.SF_DEBUG === "true" && console.log(`[FuncSpan] Using HTTP header override for ${g}::${y}`), v;
|
|
1045
834
|
}
|
|
1046
835
|
try {
|
|
1047
|
-
return
|
|
836
|
+
return xe(g, y);
|
|
1048
837
|
} catch {
|
|
1049
838
|
return { sample_rate: process.env.SF_FUNCSPAN_SAMPLE_RATE ? parseFloat(process.env.SF_FUNCSPAN_SAMPLE_RATE) : 1, capture_arguments: !0, capture_return_value: !0, arg_limit_mb: 1, return_limit_mb: 1, enable_sampling: !1, autocapture_all_child_functions: !1, capture_sf_veritas: !1, parse_json_strings: !1 };
|
|
1050
839
|
}
|
|
1051
840
|
})(t, e);
|
|
1052
|
-
if (
|
|
1053
|
-
if (c.sample_rate === 0) return
|
|
1054
|
-
|
|
1055
|
-
const a =
|
|
1056
|
-
a.setCurrentFunctionSpanId(
|
|
1057
|
-
const
|
|
1058
|
-
let
|
|
1059
|
-
c.capture_arguments && (
|
|
1060
|
-
|
|
1061
|
-
}),
|
|
841
|
+
if (i && console.log(`[FuncSpan] Config for ${t}::${e}:`, c), c.enable_sampling && c.sample_rate < 1 && Math.random() > c.sample_rate) return i && console.log(`[FuncSpan] Skipping ${e} due to sampling`), n.apply(this, o);
|
|
842
|
+
if (c.sample_rate === 0) return i && console.log(`[FuncSpan] Skipping ${e} - sample_rate is 0.0`), n.apply(this, o);
|
|
843
|
+
i && console.log(`[FuncSpan] Capturing function span for ${e}`);
|
|
844
|
+
const a = J.getInstance(), u = a.getCurrentFunctionSpanId(), f = ie();
|
|
845
|
+
a.setCurrentFunctionSpanId(f);
|
|
846
|
+
const h = process.hrtime.bigint(), m = Date.now();
|
|
847
|
+
let p = null;
|
|
848
|
+
c.capture_arguments && (p = {}, s.paramNames.forEach((g, y) => {
|
|
849
|
+
y < o.length && (p[g] = o[y]);
|
|
850
|
+
}), p && c.arg_limit_mb > 0 && (p = M(p, c.arg_limit_mb)));
|
|
1062
851
|
try {
|
|
1063
|
-
const
|
|
1064
|
-
if (
|
|
1065
|
-
const
|
|
1066
|
-
let
|
|
1067
|
-
return c.capture_return_value && c.return_limit_mb > 0 && (
|
|
1068
|
-
}, (
|
|
1069
|
-
const
|
|
1070
|
-
throw
|
|
852
|
+
const g = n.apply(this, o);
|
|
853
|
+
if (g && typeof g.then == "function") return u ? a.setCurrentFunctionSpanId(u) : a.clearCurrentFunctionSpanId(), g.then((N) => {
|
|
854
|
+
const O = process.hrtime.bigint(), L = Date.now(), k = Number(O - h);
|
|
855
|
+
let X = null;
|
|
856
|
+
return c.capture_return_value && c.return_limit_mb > 0 && (X = M(N, c.return_limit_mb)), U({ functionName: e, filePath: t, metadata: s, args: p, result: X, error: null, duration: L - m, durationNs: k, startTimeNs: h.toString(), async: !0, spanId: f, parentSpanId: u, pid: process.pid, threadId: T }), N;
|
|
857
|
+
}, (N) => {
|
|
858
|
+
const O = process.hrtime.bigint(), L = Date.now(), k = Number(O - h);
|
|
859
|
+
throw U({ functionName: e, filePath: t, metadata: s, args: p, result: null, error: N?.message || String(N), duration: L - m, durationNs: k, startTimeNs: h.toString(), async: !0, spanId: f, parentSpanId: u, pid: process.pid, threadId: T }), N;
|
|
1071
860
|
});
|
|
1072
|
-
const
|
|
1073
|
-
let
|
|
1074
|
-
return c.capture_return_value && c.return_limit_mb > 0 && (
|
|
1075
|
-
} catch (
|
|
1076
|
-
const
|
|
1077
|
-
throw
|
|
861
|
+
const y = process.hrtime.bigint(), I = Date.now(), v = Number(y - h);
|
|
862
|
+
let Q = null;
|
|
863
|
+
return c.capture_return_value && c.return_limit_mb > 0 && (Q = M(g, c.return_limit_mb)), U({ functionName: e, filePath: t, metadata: s, args: p, result: Q, error: null, duration: I - m, durationNs: v, startTimeNs: h.toString(), async: !1, spanId: f, parentSpanId: u, pid: process.pid, threadId: T }), u ? a.setCurrentFunctionSpanId(u) : a.clearCurrentFunctionSpanId(), g;
|
|
864
|
+
} catch (g) {
|
|
865
|
+
const y = process.hrtime.bigint(), I = Date.now(), v = Number(y - h);
|
|
866
|
+
throw U({ functionName: e, filePath: t, metadata: s, args: p, result: null, error: g?.message || String(g), duration: I - m, durationNs: v, startTimeNs: h.toString(), async: !1, spanId: f, parentSpanId: u, pid: process.pid, threadId: T }), u ? a.setCurrentFunctionSpanId(u) : a.clearCurrentFunctionSpanId(), g;
|
|
1078
867
|
}
|
|
1079
868
|
};
|
|
1080
|
-
Object.defineProperty(
|
|
1081
|
-
for (const
|
|
1082
|
-
return
|
|
869
|
+
Object.defineProperty(r, "name", { value: e, writable: !1 });
|
|
870
|
+
for (const o in n) n.hasOwnProperty(o) && (r[o] = n[o]);
|
|
871
|
+
return r;
|
|
1083
872
|
}
|
|
1084
|
-
function
|
|
1085
|
-
const e =
|
|
873
|
+
function U(n) {
|
|
874
|
+
const e = ae(), t = e?.sfDebug || !1;
|
|
1086
875
|
t && console.log("[FuncSpan] captureSpanData called for:", { function: n.functionName, file: n.filePath, duration: `${n.duration}ms`, async: n.async, error: n.error, spanId: n.spanId });
|
|
1087
876
|
const s = { functionName: n.functionName, filePath: n.filePath, metadata: n.metadata, args: n.args, result: n.result, error: n.error, duration: n.duration, durationNs: n.durationNs, async: n.async, spanId: n.spanId, parentSpanId: n.parentSpanId };
|
|
1088
877
|
process.env.SF_FUNCSPAN_CONSOLE_OUTPUT === "true" && console.log(`
|
|
1089
878
|
📊 Function Span:`, { function: `${n.functionName} (${n.filePath}:${n.metadata.line}:${n.metadata.column})`, duration: `${n.duration.toFixed(2)}ms`, arguments: n.args, result: n.error ? `Error: ${n.error}` : n.result, spanId: n.spanId, parentSpanId: n.parentSpanId || "none" });
|
|
1090
|
-
const
|
|
1091
|
-
if (
|
|
1092
|
-
const
|
|
879
|
+
const r = process.env.SF_FUNCSPAN_JSONL_FILE;
|
|
880
|
+
if (r) try {
|
|
881
|
+
const o = r === "true" || r === "1" ? "funcspans.jsonl" : r, d = Date.now(), i = process.hrtime.bigint(), c = BigInt(n.startTimeNs), a = Number(i - c) / 1e6, u = new Date(d - a).toISOString(), f = JSON.stringify({ timestamp: u, functionName: n.functionName, filePath: n.filePath, line: n.metadata.line, column: n.metadata.column, duration: n.duration, durationNs: n.durationNs, startTimeNs: n.startTimeNs, arguments: n.args, returnValue: n.error ? { error: String(n.error) } : n.result, spanId: n.spanId, parentSpanId: n.parentSpanId, async: n.async, pid: n.pid, threadId: n.threadId }) + `
|
|
1093
882
|
`;
|
|
1094
|
-
|
|
1095
|
-
} catch (
|
|
1096
|
-
console.error("[FuncSpan] Error writing to JSONL file:",
|
|
883
|
+
De(o, f, "utf-8");
|
|
884
|
+
} catch (o) {
|
|
885
|
+
console.error("[FuncSpan] Error writing to JSONL file:", o);
|
|
1097
886
|
}
|
|
1098
887
|
if (t && console.log("[FuncSpan] Sending function span to transmitter:", s), process.env.SF_FUNCSPAN_SKIP_BACKEND !== "true") try {
|
|
1099
|
-
(
|
|
1100
|
-
} catch (
|
|
1101
|
-
t && console.error("[FuncSpan] Error sending function span:",
|
|
888
|
+
(z || (z = new Ie()), z).send([s]), t && console.log("[FuncSpan] Function span sent successfully");
|
|
889
|
+
} catch (o) {
|
|
890
|
+
t && console.error("[FuncSpan] Error sending function span:", o);
|
|
1102
891
|
}
|
|
1103
892
|
}
|
|
893
|
+
function lt(n) {
|
|
894
|
+
return !!n.includes("captureFunctionSpan(") || !!n.includes("@sailfish-ai/sf-veritas") || !(!n.includes("/* @sailfish-instrumented */") && !n.includes("// @sailfish-instrumented"));
|
|
895
|
+
}
|
|
1104
896
|
export {
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
897
|
+
J as ContextManager,
|
|
898
|
+
ct as addOrUpdateMetadata,
|
|
899
|
+
dt as captureFunctionSpan,
|
|
900
|
+
gt as clearFuncspanOverride,
|
|
901
|
+
q as getCurrentFunctionSpanId,
|
|
902
|
+
Se as getDefaultConfig,
|
|
903
|
+
le as getEnvConfig,
|
|
904
|
+
ce as getFuncspanOverride,
|
|
905
|
+
xe as getGlobalConfig,
|
|
906
|
+
at as identify,
|
|
907
|
+
He as initializeConfigLoader,
|
|
908
|
+
Je as initializeWorkerPoolPatching,
|
|
909
|
+
lt as isAlreadyInstrumented,
|
|
910
|
+
Ge as isConfigLoaderInitialized,
|
|
911
|
+
yt as isProductionEnvironment,
|
|
912
|
+
It as isRuntimeModeEnabled,
|
|
913
|
+
it as isSetupInterceptorsInitialized,
|
|
914
|
+
Ve as isWorkerPoolInitialized,
|
|
915
|
+
de as parseHeaderOverride,
|
|
916
|
+
ft as runWithContext,
|
|
917
|
+
mt as setFuncspanOverride,
|
|
918
|
+
vt as setSkipTypeScriptPlugin,
|
|
919
|
+
ot as setupInterceptors,
|
|
920
|
+
_t as shouldEnableRuntimeHooks,
|
|
921
|
+
bt as transformFunctionSpans,
|
|
922
|
+
Ft as transformFunctionSpansSync
|
|
1125
923
|
};
|