bitfab 0.53.3 → 0.53.5
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/autoTrace.cjs +10 -2
- package/dist/autoTrace.cjs.map +1 -1
- package/dist/autoTrace.js +2 -2
- package/dist/{chunk-KUWCXZVT.js → chunk-7UOWGJFK.js} +3 -3
- package/dist/chunk-7UOWGJFK.js.map +1 -0
- package/dist/{chunk-I3W46Y7U.js → chunk-A67P4IPJ.js} +20 -2
- package/dist/chunk-A67P4IPJ.js.map +1 -0
- package/dist/{chunk-E5BLYL5X.js → chunk-EGWJYCNT.js} +6 -5
- package/dist/chunk-EGWJYCNT.js.map +1 -0
- package/dist/{chunk-QVRPMSFH.js → chunk-HIWCN36R.js} +11 -2
- package/dist/chunk-HIWCN36R.js.map +1 -0
- package/dist/{chunk-LOQOG2MW.js → chunk-I6HABUAU.js} +10 -4
- package/dist/chunk-I6HABUAU.js.map +1 -0
- package/dist/{chunk-JFDOUOBS.js → chunk-JMZSZD22.js} +39 -21
- package/dist/chunk-JMZSZD22.js.map +1 -0
- package/dist/{chunk-H6LZRFMN.js → chunk-VCRFFCLY.js} +20 -2
- package/dist/chunk-VCRFFCLY.js.map +1 -0
- package/dist/{http-DPLYIYPM.js → http-7G364U2F.js} +2 -2
- package/dist/{http-UBKEZ5VN.js → http-VZG3GUGE.js} +3 -3
- package/dist/index.cjs +70 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -5
- package/dist/node.cjs +70 -14
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +5 -5
- package/dist/{replay-RPZ5RUPM.js → replay-2PZ7OOTJ.js} +4 -4
- package/dist/replayCli.js +2 -2
- package/dist/seedCli.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-E5BLYL5X.js.map +0 -1
- package/dist/chunk-H6LZRFMN.js.map +0 -1
- package/dist/chunk-I3W46Y7U.js.map +0 -1
- package/dist/chunk-JFDOUOBS.js.map +0 -1
- package/dist/chunk-KUWCXZVT.js.map +0 -1
- package/dist/chunk-LOQOG2MW.js.map +0 -1
- package/dist/chunk-QVRPMSFH.js.map +0 -1
- /package/dist/{http-DPLYIYPM.js.map → http-7G364U2F.js.map} +0 -0
- /package/dist/{http-UBKEZ5VN.js.map → http-VZG3GUGE.js.map} +0 -0
- /package/dist/{replay-RPZ5RUPM.js.map → replay-2PZ7OOTJ.js.map} +0 -0
|
@@ -46,6 +46,22 @@ function createAsyncLocalStorage() {
|
|
|
46
46
|
return AsyncLocalStorageClass ? new AsyncLocalStorageClass() : null;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
// src/captureSuppression.ts
|
|
50
|
+
var suppressionGlobal = globalThis;
|
|
51
|
+
var suppressionState = suppressionGlobal.__bitfabCaptureSuppressionV1 ?? { depth: 0 };
|
|
52
|
+
suppressionGlobal.__bitfabCaptureSuppressionV1 = suppressionState;
|
|
53
|
+
function isCaptureSuppressed() {
|
|
54
|
+
return suppressionState.depth > 0;
|
|
55
|
+
}
|
|
56
|
+
function runWithCaptureSuppressed(fn) {
|
|
57
|
+
suppressionState.depth += 1;
|
|
58
|
+
try {
|
|
59
|
+
return fn();
|
|
60
|
+
} finally {
|
|
61
|
+
suppressionState.depth -= 1;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
49
65
|
export {
|
|
50
66
|
__privateGet,
|
|
51
67
|
__privateAdd,
|
|
@@ -54,6 +70,8 @@ export {
|
|
|
54
70
|
assertAsyncStorageRegistered,
|
|
55
71
|
asyncStorageReady,
|
|
56
72
|
isAsyncStorageInitDone,
|
|
57
|
-
createAsyncLocalStorage
|
|
73
|
+
createAsyncLocalStorage,
|
|
74
|
+
isCaptureSuppressed,
|
|
75
|
+
runWithCaptureSuppressed
|
|
58
76
|
};
|
|
59
|
-
//# sourceMappingURL=chunk-
|
|
77
|
+
//# sourceMappingURL=chunk-VCRFFCLY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/asyncStorage.ts","../src/captureSuppression.ts"],"sourcesContent":["/**\n * Shared AsyncLocalStorage loader.\n *\n * Provides two ways to initialize AsyncLocalStorage:\n *\n * 1. **Synchronous registration** (preferred for Node.js):\n * `asyncStorageNode.ts` calls `registerAsyncLocalStorageClass()` at module\n * evaluation time, so the class is available immediately - no async gap.\n * The `node.ts` entry point imports it before anything else.\n *\n * 2. **Async dynamic import** (fallback for the default entry point):\n * Loads `node:async_hooks` via a bundler-safe dynamic import. This is used\n * by the default `index.ts` entry point so the SDK works in browsers\n * (where the import silently fails) and in Node.js when imported via the\n * default entry point.\n *\n * ## Why the dynamic import looks like this\n *\n * We need to handle three environments:\n *\n * 1. **Pure Node.js** - `import(\"node:async_hooks\")` works natively.\n * 2. **Webpack/Turbopack (Next.js server)** - The bundler processes\n * `import()` calls at build time. The `webpackIgnore` magic comment tells\n * webpack (and turbopack) to emit a native `import()` call instead of\n * trying to resolve it, so Node.js handles it at runtime.\n * 3. **Browsers / Edge** - The `process.versions?.node` guard prevents\n * execution entirely. If it somehow runs, `.catch(() => {})` swallows\n * the failure.\n */\n\nexport interface AsyncLocalStorageLike<T> {\n getStore(): T | undefined\n run<R>(store: T, fn: () => R): R\n}\n\nlet AsyncLocalStorageClass: (new () => AsyncLocalStorageLike<unknown>) | null =\n null\nlet initDone = false\n\n/**\n * Register the AsyncLocalStorage class synchronously.\n *\n * Called by `asyncStorageNode.ts` at module evaluation time so the class\n * is available before any span is created - no async gap, no race condition.\n *\n * Safe to call multiple times; subsequent calls are no-ops.\n */\nexport function registerAsyncLocalStorageClass(\n cls: new () => AsyncLocalStorageLike<unknown>,\n): void {\n if (!AsyncLocalStorageClass) {\n AsyncLocalStorageClass = cls\n }\n initDone = true\n}\n\n/**\n * Assert that AsyncLocalStorage was registered successfully.\n *\n * Called by `node.ts` after importing `asyncStorageNode.ts` to catch\n * import-order bugs at startup rather than silently degrading to the\n * browser fallback (flat spans with no nesting).\n *\n * This should ONLY be called from the Node.js entry point where we\n * know `node:async_hooks` must be available.\n */\nexport function assertAsyncStorageRegistered(): void {\n if (!AsyncLocalStorageClass) {\n console.warn(\n \"Bitfab: AsyncLocalStorage not available - nested span context will not propagate.\",\n )\n }\n}\n\nexport const asyncStorageReady: Promise<void> = (\n typeof process !== \"undefined\" && process.versions?.node\n ? // The join trick hides \"node:async_hooks\" from static analysis so\n // bundlers that ban Node.js built-ins don't fail at build time.\n // webpackIgnore tells webpack/turbopack to emit a native import()\n // so Node.js can resolve the module at runtime.\n import(\n /* webpackIgnore: true */\n [\"node\", \"async_hooks\"].join(\":\")\n )\n .then(\n (mod: {\n AsyncLocalStorage: new () => AsyncLocalStorageLike<unknown>\n }) => {\n registerAsyncLocalStorageClass(mod.AsyncLocalStorage)\n },\n )\n .catch(() => {})\n : Promise.resolve()\n).then(() => {\n initDone = true\n})\n\nexport function isAsyncStorageInitDone(): boolean {\n return initDone\n}\n\nexport function createAsyncLocalStorage<T>(): AsyncLocalStorageLike<T> | null {\n return AsyncLocalStorageClass\n ? (new AsyncLocalStorageClass() as AsyncLocalStorageLike<T>)\n : null\n}\n","interface CaptureSuppressionState {\n depth: number\n}\n\ninterface CaptureSuppressionGlobal {\n __bitfabCaptureSuppressionV1?: CaptureSuppressionState\n}\n\nconst suppressionGlobal = globalThis as unknown as CaptureSuppressionGlobal\nconst suppressionState: CaptureSuppressionState =\n suppressionGlobal.__bitfabCaptureSuppressionV1 ?? { depth: 0 }\nsuppressionGlobal.__bitfabCaptureSuppressionV1 = suppressionState\n\nexport function isCaptureSuppressed(): boolean {\n return suppressionState.depth > 0\n}\n\nexport function runWithCaptureSuppressed<T>(fn: () => T): T {\n suppressionState.depth += 1\n try {\n return fn()\n } finally {\n suppressionState.depth -= 1\n }\n}\n"],"mappings":";;;;;;;;;AAmCA,IAAI,yBACF;AACF,IAAI,WAAW;AAUR,SAAS,+BACd,KACM;AACN,MAAI,CAAC,wBAAwB;AAC3B,6BAAyB;AAAA,EAC3B;AACA,aAAW;AACb;AAYO,SAAS,+BAAqC;AACnD,MAAI,CAAC,wBAAwB;AAC3B,YAAQ;AAAA,MACN;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,qBACX,OAAO,YAAY,eAAe,QAAQ,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAKhD;AAAA;AAAA,IAEE,CAAC,QAAQ,aAAa,EAAE,KAAK,GAAG;AAAA,IAE/B;AAAA,IACC,CAAC,QAEK;AACJ,qCAA+B,IAAI,iBAAiB;AAAA,IACtD;AAAA,EACF,EACC,MAAM,MAAM;AAAA,EAAC,CAAC;AAAA,IACjB,QAAQ,QAAQ,GACpB,KAAK,MAAM;AACX,aAAW;AACb,CAAC;AAEM,SAAS,yBAAkC;AAChD,SAAO;AACT;AAEO,SAAS,0BAA8D;AAC5E,SAAO,yBACF,IAAI,uBAAuB,IAC5B;AACN;;;ACjGA,IAAM,oBAAoB;AAC1B,IAAM,mBACJ,kBAAkB,gCAAgC,EAAE,OAAO,EAAE;AAC/D,kBAAkB,+BAA+B;AAE1C,SAAS,sBAA+B;AAC7C,SAAO,iBAAiB,QAAQ;AAClC;AAEO,SAAS,yBAA4B,IAAgB;AAC1D,mBAAiB,SAAS;AAC1B,MAAI;AACF,WAAO,GAAG;AAAA,EACZ,UAAE;AACA,qBAAiB,SAAS;AAAA,EAC5B;AACF;","names":[]}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
flushTraces,
|
|
7
7
|
parseRetryAfterMs,
|
|
8
8
|
serializePayloadBody
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-A67P4IPJ.js";
|
|
10
10
|
export {
|
|
11
11
|
BitfabError,
|
|
12
12
|
HttpClient,
|
|
@@ -16,4 +16,4 @@ export {
|
|
|
16
16
|
parseRetryAfterMs,
|
|
17
17
|
serializePayloadBody
|
|
18
18
|
};
|
|
19
|
-
//# sourceMappingURL=http-
|
|
19
|
+
//# sourceMappingURL=http-7G364U2F.js.map
|
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
flushTraces,
|
|
7
7
|
parseRetryAfterMs,
|
|
8
8
|
serializePayloadBody
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-I6HABUAU.js";
|
|
10
|
+
import "./chunk-VCRFFCLY.js";
|
|
11
11
|
export {
|
|
12
12
|
BitfabError,
|
|
13
13
|
HttpClient,
|
|
@@ -17,4 +17,4 @@ export {
|
|
|
17
17
|
parseRetryAfterMs,
|
|
18
18
|
serializePayloadBody
|
|
19
19
|
};
|
|
20
|
-
//# sourceMappingURL=http-
|
|
20
|
+
//# sourceMappingURL=http-VZG3GUGE.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -51,7 +51,7 @@ var __version__, __packageName__;
|
|
|
51
51
|
var init_version_generated = __esm({
|
|
52
52
|
"src/version.generated.ts"() {
|
|
53
53
|
"use strict";
|
|
54
|
-
__version__ = "0.53.
|
|
54
|
+
__version__ = "0.53.5";
|
|
55
55
|
__packageName__ = "bitfab";
|
|
56
56
|
}
|
|
57
57
|
});
|
|
@@ -267,6 +267,28 @@ var init_replayContext = __esm({
|
|
|
267
267
|
}
|
|
268
268
|
});
|
|
269
269
|
|
|
270
|
+
// src/captureSuppression.ts
|
|
271
|
+
function isCaptureSuppressed() {
|
|
272
|
+
return suppressionState.depth > 0;
|
|
273
|
+
}
|
|
274
|
+
function runWithCaptureSuppressed(fn) {
|
|
275
|
+
suppressionState.depth += 1;
|
|
276
|
+
try {
|
|
277
|
+
return fn();
|
|
278
|
+
} finally {
|
|
279
|
+
suppressionState.depth -= 1;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
var suppressionGlobal, suppressionState;
|
|
283
|
+
var init_captureSuppression = __esm({
|
|
284
|
+
"src/captureSuppression.ts"() {
|
|
285
|
+
"use strict";
|
|
286
|
+
suppressionGlobal = globalThis;
|
|
287
|
+
suppressionState = suppressionGlobal.__bitfabCaptureSuppressionV1 ?? { depth: 0 };
|
|
288
|
+
suppressionGlobal.__bitfabCaptureSuppressionV1 = suppressionState;
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
|
|
270
292
|
// src/payloadBudget.ts
|
|
271
293
|
function byteLength(value) {
|
|
272
294
|
return textEncoder ? textEncoder.encode(value).length : value.length;
|
|
@@ -417,6 +439,11 @@ var init_warnOnce = __esm({
|
|
|
417
439
|
|
|
418
440
|
// src/serializePayload.ts
|
|
419
441
|
function serializePayloadBody(payload, maxCarrierBytes = MAX_SPAN_CARRIER_BYTES) {
|
|
442
|
+
return runWithCaptureSuppressed(
|
|
443
|
+
() => encodeWithinBudget(payload, maxCarrierBytes)
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
function encodeWithinBudget(payload, maxCarrierBytes) {
|
|
420
447
|
const encoded = encodePayloadBody(payload);
|
|
421
448
|
if (fitsCarrierBudget(encoded.body, maxCarrierBytes)) {
|
|
422
449
|
return { body: encoded.body, dropped: encoded.dropped };
|
|
@@ -541,6 +568,7 @@ function encodePayloadBody(payload) {
|
|
|
541
568
|
var init_serializePayload = __esm({
|
|
542
569
|
"src/serializePayload.ts"() {
|
|
543
570
|
"use strict";
|
|
571
|
+
init_captureSuppression();
|
|
544
572
|
init_payloadBudget();
|
|
545
573
|
init_warnOnce();
|
|
546
574
|
}
|
|
@@ -2723,6 +2751,9 @@ function unserializableStub(value, reason) {
|
|
|
2723
2751
|
return { json: summary };
|
|
2724
2752
|
}
|
|
2725
2753
|
function serializeValue(value) {
|
|
2754
|
+
return runWithCaptureSuppressed(() => serializeWithSuperjson(value));
|
|
2755
|
+
}
|
|
2756
|
+
function serializeWithSuperjson(value) {
|
|
2726
2757
|
try {
|
|
2727
2758
|
const { json, meta } = import_superjson.default.serialize(value);
|
|
2728
2759
|
let size;
|
|
@@ -2756,6 +2787,9 @@ function toJsonSafe(value) {
|
|
|
2756
2787
|
return toJsonSafeReport(value).safe;
|
|
2757
2788
|
}
|
|
2758
2789
|
function toJsonSafeReport(value) {
|
|
2790
|
+
return runWithCaptureSuppressed(() => jsonSafeReport(value));
|
|
2791
|
+
}
|
|
2792
|
+
function jsonSafeReport(value) {
|
|
2759
2793
|
const dropped = [];
|
|
2760
2794
|
const safe = toJsonSafeInner(value, 0, /* @__PURE__ */ new WeakSet(), dropped);
|
|
2761
2795
|
try {
|
|
@@ -2841,6 +2875,7 @@ var init_serialize = __esm({
|
|
|
2841
2875
|
"src/serialize.ts"() {
|
|
2842
2876
|
"use strict";
|
|
2843
2877
|
import_superjson = __toESM(require("superjson"), 1);
|
|
2878
|
+
init_captureSuppression();
|
|
2844
2879
|
init_payloadBudget();
|
|
2845
2880
|
init_warnOnce();
|
|
2846
2881
|
MAX_SERIALIZED_BYTES = MAX_COMPRESSIBLE_SPAN_CARRIER_BYTES;
|
|
@@ -4740,6 +4775,7 @@ init_asyncStorage();
|
|
|
4740
4775
|
|
|
4741
4776
|
// src/autoTrace.ts
|
|
4742
4777
|
init_asyncStorage();
|
|
4778
|
+
init_captureSuppression();
|
|
4743
4779
|
var autoTraceGlobal = globalThis;
|
|
4744
4780
|
var autoTraceState = autoTraceGlobal.__bitfabAutoTraceStateV4 ?? {
|
|
4745
4781
|
storage: null,
|
|
@@ -4872,7 +4908,7 @@ function wrapAutoTraceNodeAsyncGenerator(nodeConfiguration, source) {
|
|
|
4872
4908
|
return wrapped;
|
|
4873
4909
|
}
|
|
4874
4910
|
function __bitfabAutoTraceActive() {
|
|
4875
|
-
if (autoTraceState.activeRoots === 0) {
|
|
4911
|
+
if (autoTraceState.activeRoots === 0 || isCaptureSuppressed()) {
|
|
4876
4912
|
return false;
|
|
4877
4913
|
}
|
|
4878
4914
|
return currentAutoTraceEntries().length > 0;
|
|
@@ -5202,6 +5238,9 @@ async function runFunctionWithBaml(bamlSource, inputs, providers, envVars) {
|
|
|
5202
5238
|
};
|
|
5203
5239
|
}
|
|
5204
5240
|
|
|
5241
|
+
// src/client.ts
|
|
5242
|
+
init_captureSuppression();
|
|
5243
|
+
|
|
5205
5244
|
// src/captureSurface.ts
|
|
5206
5245
|
init_errors();
|
|
5207
5246
|
var DEFAULT_SURFACE = "opt-in";
|
|
@@ -5495,14 +5534,24 @@ var DatasetsClient = class {
|
|
|
5495
5534
|
}
|
|
5496
5535
|
/**
|
|
5497
5536
|
* List datasets, scoped to one trace function when `traceFunctionKey` is
|
|
5498
|
-
* given and organization-wide otherwise.
|
|
5537
|
+
* given and organization-wide otherwise. Fetches all pages automatically.
|
|
5499
5538
|
*/
|
|
5500
5539
|
async list(params = {}) {
|
|
5501
|
-
const
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
|
|
5540
|
+
const datasets = [];
|
|
5541
|
+
let cursor;
|
|
5542
|
+
do {
|
|
5543
|
+
const query = new URLSearchParams({ limit: "100" });
|
|
5544
|
+
if (params.traceFunctionKey !== void 0) {
|
|
5545
|
+
query.set("traceFunctionKey", params.traceFunctionKey);
|
|
5546
|
+
}
|
|
5547
|
+
if (cursor !== void 0) {
|
|
5548
|
+
query.set("cursor", cursor);
|
|
5549
|
+
}
|
|
5550
|
+
const response = await this.httpClient.get(`/api/sdk/datasets?${query}`);
|
|
5551
|
+
datasets.push(...response.datasets);
|
|
5552
|
+
cursor = response.nextCursor ?? void 0;
|
|
5553
|
+
} while (cursor !== void 0);
|
|
5554
|
+
return datasets;
|
|
5506
5555
|
}
|
|
5507
5556
|
/** Fetch one dataset by id. Rejects with a 404 `BitfabError` when it is not in this organization. */
|
|
5508
5557
|
async get(datasetId) {
|
|
@@ -5511,11 +5560,18 @@ var DatasetsClient = class {
|
|
|
5511
5560
|
);
|
|
5512
5561
|
return response.dataset;
|
|
5513
5562
|
}
|
|
5514
|
-
/**
|
|
5563
|
+
/** Fetches all trace-ID pages, the same membership a replay with `datasetId` selects. */
|
|
5515
5564
|
async listTraces(datasetId) {
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
)
|
|
5565
|
+
const traceIds = [];
|
|
5566
|
+
const query = new URLSearchParams({ limit: "100" });
|
|
5567
|
+
for (; ; ) {
|
|
5568
|
+
const page = await this.httpClient.get(`${datasetPath(datasetId, "/traces")}?${query}`);
|
|
5569
|
+
traceIds.push(...page.traceIds);
|
|
5570
|
+
if (page.nextCursor === void 0 || page.nextCursor === null) {
|
|
5571
|
+
return { datasetId: page.datasetId, traceIds };
|
|
5572
|
+
}
|
|
5573
|
+
query.set("cursor", page.nextCursor);
|
|
5574
|
+
}
|
|
5519
5575
|
}
|
|
5520
5576
|
/**
|
|
5521
5577
|
* Add traces to the dataset (1 to 100 ids per call). Traces outside the
|
|
@@ -7904,7 +7960,7 @@ var Bitfab = class {
|
|
|
7904
7960
|
);
|
|
7905
7961
|
const tracedRoot = buildTracedRoot(rootOptions);
|
|
7906
7962
|
const autoTraceRoot = function(...args) {
|
|
7907
|
-
if (!self.shouldRecord()) {
|
|
7963
|
+
if (!self.shouldRecord() || isCaptureSuppressed()) {
|
|
7908
7964
|
return fn.apply(this, args);
|
|
7909
7965
|
}
|
|
7910
7966
|
const enclosing = currentAutoTraceEntries();
|
|
@@ -8481,7 +8537,7 @@ var Bitfab = class {
|
|
|
8481
8537
|
}
|
|
8482
8538
|
})();
|
|
8483
8539
|
const wrappedFn = function(...args) {
|
|
8484
|
-
if (!self.shouldRecord()) {
|
|
8540
|
+
if (!self.shouldRecord() || isCaptureSuppressed()) {
|
|
8485
8541
|
return fn.apply(this, args);
|
|
8486
8542
|
}
|
|
8487
8543
|
initializeAsyncContext();
|