bitfab 0.28.7 → 0.28.10

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/index.cjs CHANGED
@@ -692,7 +692,7 @@ __export(index_exports, {
692
692
  module.exports = __toCommonJS(index_exports);
693
693
 
694
694
  // src/version.generated.ts
695
- var __version__ = "0.28.7";
695
+ var __version__ = "0.28.10";
696
696
 
697
697
  // src/constants.ts
698
698
  var DEFAULT_SERVICE_URL = "https://bitfab.ai";
@@ -3138,8 +3138,11 @@ init_warnOnce();
3138
3138
  var activeTraceStates = /* @__PURE__ */ new Map();
3139
3139
  var pendingSpanPromises = /* @__PURE__ */ new Map();
3140
3140
  var asyncLocalStorage = null;
3141
+ var initializeAsyncContext = () => {
3142
+ asyncLocalStorage ?? (asyncLocalStorage = createAsyncLocalStorage());
3143
+ };
3141
3144
  var asyncLocalStorageReady = asyncStorageReady.then(() => {
3142
- asyncLocalStorage = createAsyncLocalStorage();
3145
+ initializeAsyncContext();
3143
3146
  });
3144
3147
  var browserSpanStack = [];
3145
3148
  function getSpanStack() {
@@ -3908,6 +3911,7 @@ var Bitfab = class {
3908
3911
  if (!self.isTracingEnabled()) {
3909
3912
  return fn.apply(this, args);
3910
3913
  }
3914
+ initializeAsyncContext();
3911
3915
  if (!asyncLocalStorage && !isAsyncStorageInitDone()) {
3912
3916
  return asyncLocalStorageReady.then(
3913
3917
  () => wrappedFn.apply(this, args)
@@ -3971,13 +3975,16 @@ var Bitfab = class {
3971
3975
  }
3972
3976
  try {
3973
3977
  const endedAt = (/* @__PURE__ */ new Date()).toISOString();
3974
- const spanPromise = self.sendWrapperSpan({
3978
+ const traceDropped = activeTraceStates.get(traceId)?.dropped === true;
3979
+ const spanPromise = traceDropped ? Promise.resolve() : self.sendWrapperSpan({
3975
3980
  ...baseSpanParams,
3976
3981
  ...params,
3977
3982
  contexts: newContext.contexts,
3978
3983
  prompt: newContext.prompt,
3979
3984
  endedAt,
3980
- ...replayCtx?.testRunId && { testRunId: replayCtx.testRunId },
3985
+ ...replayCtx?.testRunId && {
3986
+ testRunId: replayCtx.testRunId
3987
+ },
3981
3988
  ...replayCtx?.inputSourceSpanId && {
3982
3989
  inputSourceSpanId: replayCtx.inputSourceSpanId
3983
3990
  }
@@ -4065,7 +4072,7 @@ var Bitfab = class {
4065
4072
  meta: mockSpan.outputMeta
4066
4073
  });
4067
4074
  }
4068
- void sendSpan({ result: output });
4075
+ void sendSpan({ result: output, mocked: true });
4069
4076
  if (fnReturnsPromise) {
4070
4077
  return Promise.resolve(output);
4071
4078
  }
@@ -4317,7 +4324,8 @@ var Bitfab = class {
4317
4324
  sourceTraceId: params.traceId,
4318
4325
  traceFunctionKey: params.traceFunctionKey,
4319
4326
  rawSpan: externalSpan,
4320
- ...params.testRunId && { testRunId: params.testRunId }
4327
+ ...params.testRunId && { testRunId: params.testRunId },
4328
+ ...params.mocked && { mocked: true }
4321
4329
  });
4322
4330
  }
4323
4331
  /**