bitfab 0.54.7 → 0.54.8

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.
@@ -6,7 +6,7 @@ import {
6
6
  replayContextReady,
7
7
  runWithReplayContext,
8
8
  warnOnce
9
- } from "./chunk-GGMFD2ZE.js";
9
+ } from "./chunk-5H3D7J4K.js";
10
10
  import {
11
11
  runWithCaptureSuppressed
12
12
  } from "./chunk-VCRFFCLY.js";
@@ -1212,4 +1212,4 @@ export {
1212
1212
  sleepForReplayPersistence,
1213
1213
  replay
1214
1214
  };
1215
- //# sourceMappingURL=chunk-ONMN7WXS.js.map
1215
+ //# sourceMappingURL=chunk-RUCVJQBI.js.map
@@ -18,7 +18,7 @@ import {
18
18
  serializeValue,
19
19
  toJsonSafe,
20
20
  toJsonSafeReport
21
- } from "./chunk-ONMN7WXS.js";
21
+ } from "./chunk-RUCVJQBI.js";
22
22
  import {
23
23
  BitfabError,
24
24
  DEFAULT_SERVICE_URL,
@@ -35,7 +35,7 @@ import {
35
35
  recordCallerTraceMetadata,
36
36
  retireTraceMetadata,
37
37
  warnOnce
38
- } from "./chunk-GGMFD2ZE.js";
38
+ } from "./chunk-5H3D7J4K.js";
39
39
  import {
40
40
  __privateAdd,
41
41
  __privateGet,
@@ -3395,6 +3395,30 @@ function readEnv2(name) {
3395
3395
  }
3396
3396
  return void 0;
3397
3397
  }
3398
+ var CAPTURE_ENABLED_ENV = "BITFAB_CAPTURE_ENABLED";
3399
+ var TRUE_ENV_VALUES = /* @__PURE__ */ new Set(["1", "true", "yes"]);
3400
+ var FALSE_ENV_VALUES = /* @__PURE__ */ new Set(["0", "false", "no"]);
3401
+ function readBooleanEnv(name) {
3402
+ const raw = readEnv2(name);
3403
+ if (raw === void 0) {
3404
+ return void 0;
3405
+ }
3406
+ const value = raw.trim().toLowerCase();
3407
+ if (value === "") {
3408
+ return void 0;
3409
+ }
3410
+ if (TRUE_ENV_VALUES.has(value)) {
3411
+ return true;
3412
+ }
3413
+ if (FALSE_ENV_VALUES.has(value)) {
3414
+ return false;
3415
+ }
3416
+ warnOnce(
3417
+ `unrecognized-boolean-env:${name}`,
3418
+ `${name}="${raw}" is not 0 or 1; ignoring it.`
3419
+ );
3420
+ return void 0;
3421
+ }
3398
3422
  var DEFAULT_AUTO_TRACE_MAX_DEPTH = 30;
3399
3423
  var DEFAULT_AUTO_TRACE_MAX_SPANS = 500;
3400
3424
  var AUTO_TRACE_PROTOCOL = "ts-auto-v1";
@@ -3449,7 +3473,7 @@ var Bitfab = class {
3449
3473
  "Bitfab({ enabled }) is deprecated; pass captureEnabled instead."
3450
3474
  );
3451
3475
  }
3452
- this.captureConfigured = (config.captureEnabled ?? true) && (config.enabled ?? true);
3476
+ this.captureConfiguredInCode = config.captureEnabled === void 0 && config.enabled === void 0 ? void 0 : (config.captureEnabled ?? true) && (config.enabled ?? true);
3453
3477
  this.strict = config.strict ?? false;
3454
3478
  this.bamlClient = config.bamlClient ?? null;
3455
3479
  if (config.dbSnapshot) {
@@ -3903,7 +3927,7 @@ var Bitfab = class {
3903
3927
  "Bitfab: no API key resolved. Set BITFAB_API_KEY or pass apiKey to new Bitfab(). If a script loads env with dotenv, load it before the module that constructs the client is imported (e.g. `node --env-file=.env script.ts`), or pass `apiKey: () => process.env.BITFAB_API_KEY`."
3904
3928
  );
3905
3929
  }
3906
- if (this.captureConfigured && !this.apiKeyWarned) {
3930
+ if (this.isCaptureConfigured() && !this.apiKeyWarned) {
3907
3931
  this.apiKeyWarned = true;
3908
3932
  console.warn(
3909
3933
  "Bitfab: apiKey is empty - tracing is disabled. Provide a valid API key to enable tracing."
@@ -3911,20 +3935,29 @@ var Bitfab = class {
3911
3935
  }
3912
3936
  return void 0;
3913
3937
  }
3938
+ isCaptureConfigured() {
3939
+ if (this.captureConfiguredInCode !== void 0) {
3940
+ return this.captureConfiguredInCode;
3941
+ }
3942
+ if (this.captureConfiguredFromEnv === void 0) {
3943
+ this.captureConfiguredFromEnv = readBooleanEnv(CAPTURE_ENABLED_ENV) ?? true;
3944
+ }
3945
+ return this.captureConfiguredFromEnv;
3946
+ }
3914
3947
  isCaptureEnabled() {
3915
- if (!this.captureConfigured) {
3948
+ if (!this.isCaptureConfigured()) {
3916
3949
  return false;
3917
3950
  }
3918
3951
  return this.resolveApiKey() !== void 0;
3919
3952
  }
3920
3953
  shouldRecord() {
3921
- if (!this.captureConfigured && !getReplayContext() && !inSeedScope()) {
3954
+ if (!this.isCaptureConfigured() && !getReplayContext() && !inSeedScope()) {
3922
3955
  return false;
3923
3956
  }
3924
3957
  return this.resolveApiKey() !== void 0;
3925
3958
  }
3926
3959
  prepareFrameworkIntegration() {
3927
- if (this.captureConfigured && this.strict) {
3960
+ if (this.isCaptureConfigured() && this.strict) {
3928
3961
  this.resolveApiKey();
3929
3962
  }
3930
3963
  }
@@ -5204,7 +5237,7 @@ var Bitfab = class {
5204
5237
  await runWithSeedContext({ traceId }, async () => target(...args));
5205
5238
  } finally {
5206
5239
  try {
5207
- const { flushTraces: flushTraces2 } = await import("./http-DYGY3K7H.js");
5240
+ const { flushTraces: flushTraces2 } = await import("./http-7PL32JLX.js");
5208
5241
  await flushTraces2(3e4);
5209
5242
  } finally {
5210
5243
  unrecorded = activeTraceStates.delete(traceId);
@@ -5263,7 +5296,7 @@ var Bitfab = class {
5263
5296
  `Function is wrapped with trace function key '${wrappedKey}' but replay was called with '${traceFunctionKey}'. Pass matching keys, or pass the unwrapped function to replay it under the explicit key.`
5264
5297
  );
5265
5298
  }
5266
- const { replay: doReplay } = await import("./replay-22RLT3Z4.js");
5299
+ const { replay: doReplay } = await import("./replay-KWBZ2JQV.js");
5267
5300
  return doReplay(
5268
5301
  this.httpClient,
5269
5302
  this.serviceUrl,
@@ -5547,7 +5580,7 @@ async function seedFromRegistry(registry, pipeline, cases, options = {}) {
5547
5580
  sessionId: seedCase.sessionId
5548
5581
  })
5549
5582
  );
5550
- const { flushTraces: flushTraces2 } = await import("./http-DYGY3K7H.js");
5583
+ const { flushTraces: flushTraces2 } = await import("./http-7PL32JLX.js");
5551
5584
  await flushTraces2(3e4);
5552
5585
  return { pipeline, traceFunctionKey, traceIds };
5553
5586
  }
@@ -5585,4 +5618,4 @@ export {
5585
5618
  reseedFromRegistry,
5586
5619
  seedFromRegistry
5587
5620
  };
5588
- //# sourceMappingURL=chunk-MFMTLYDW.js.map
5621
+ //# sourceMappingURL=chunk-XPCVDQDS.js.map