bitfab 0.13.4 → 0.13.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/index.d.cts CHANGED
@@ -396,6 +396,8 @@ interface ReplayOptions {
396
396
  environment?: ReplayEnvironment;
397
397
  }
398
398
  interface ReplayItem<T> {
399
+ /** Trace ID of the new trace created during replay. */
400
+ traceId: string | null;
399
401
  /** Deserialized inputs from the original trace. */
400
402
  input: unknown[];
401
403
  /** The result returned by the function during replay, or undefined on error. */
@@ -1006,7 +1008,7 @@ declare class BitfabFunction {
1006
1008
  /**
1007
1009
  * SDK version from package.json (injected at build time)
1008
1010
  */
1009
- declare const __version__ = "0.13.4";
1011
+ declare const __version__ = "0.13.5";
1010
1012
 
1011
1013
  /**
1012
1014
  * Constants for the Bitfab SDK.
package/dist/index.d.ts CHANGED
@@ -396,6 +396,8 @@ interface ReplayOptions {
396
396
  environment?: ReplayEnvironment;
397
397
  }
398
398
  interface ReplayItem<T> {
399
+ /** Trace ID of the new trace created during replay. */
400
+ traceId: string | null;
399
401
  /** Deserialized inputs from the original trace. */
400
402
  input: unknown[];
401
403
  /** The result returned by the function during replay, or undefined on error. */
@@ -1006,7 +1008,7 @@ declare class BitfabFunction {
1006
1008
  /**
1007
1009
  * SDK version from package.json (injected at build time)
1008
1010
  */
1009
- declare const __version__ = "0.13.4";
1011
+ declare const __version__ = "0.13.5";
1010
1012
 
1011
1013
  /**
1012
1014
  * Constants for the Bitfab SDK.
package/dist/index.js CHANGED
@@ -17,13 +17,13 @@ import {
17
17
  SUPPORTED_PROVIDERS,
18
18
  getCurrentSpan,
19
19
  getCurrentTrace
20
- } from "./chunk-XUW46356.js";
20
+ } from "./chunk-4IHJJRMU.js";
21
21
  import {
22
22
  BitfabError,
23
23
  DEFAULT_SERVICE_URL,
24
24
  __version__,
25
25
  flushTraces
26
- } from "./chunk-SKJWF5VX.js";
26
+ } from "./chunk-BVFST7Q3.js";
27
27
  export {
28
28
  Bitfab,
29
29
  BitfabClaudeAgentHandler,
package/dist/node.cjs CHANGED
@@ -90,7 +90,7 @@ var __version__;
90
90
  var init_version_generated = __esm({
91
91
  "src/version.generated.ts"() {
92
92
  "use strict";
93
- __version__ = "0.13.4";
93
+ __version__ = "0.13.5";
94
94
  }
95
95
  });
96
96
 
@@ -588,6 +588,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
588
588
  let originalOutput;
589
589
  let result;
590
590
  let error = null;
591
+ const replayedTraceId = crypto.randomUUID();
591
592
  try {
592
593
  const span = await httpClient.getExternalSpan(serverItem.externalSpanId);
593
594
  const spanData = span.rawData?.span_data ?? {};
@@ -603,6 +604,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
603
604
  const maybePromise = runWithReplayContext(
604
605
  {
605
606
  testRunId,
607
+ traceId: replayedTraceId,
606
608
  inputSourceSpanId: span.id,
607
609
  inputSourceTraceId: span.externalTraceId,
608
610
  sourceBitfabTraceId: serverItem.traceId,
@@ -631,6 +633,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
631
633
  }
632
634
  }
633
635
  return {
636
+ traceId: replayedTraceId,
634
637
  input: inputs,
635
638
  result,
636
639
  originalOutput,
@@ -686,14 +689,21 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options) {
686
689
  );
687
690
  const resultItems = await mapWithConcurrency(tasks, maxConcurrency);
688
691
  await flushTraces();
692
+ let serverTraceIds = {};
689
693
  try {
690
- await httpClient.completeReplay(testRunId);
694
+ const completeResult = await httpClient.completeReplay(testRunId);
695
+ serverTraceIds = completeResult.traceIds ?? {};
691
696
  } catch (e) {
692
697
  try {
693
698
  console.error("Bitfab: Failed to complete replay:", e);
694
699
  } catch {
695
700
  }
696
701
  }
702
+ for (const item of resultItems) {
703
+ if (item.traceId) {
704
+ item.traceId = serverTraceIds[item.traceId] ?? null;
705
+ }
706
+ }
697
707
  return {
698
708
  items: resultItems,
699
709
  testRunId,
@@ -2885,7 +2895,8 @@ var Bitfab = class {
2885
2895
  }
2886
2896
  const currentStack = getSpanStack();
2887
2897
  const parentContext = currentStack[currentStack.length - 1];
2888
- const traceId = parentContext?.traceId ?? crypto.randomUUID();
2898
+ const replayCtxForTraceId = parentContext ? null : getReplayContext();
2899
+ const traceId = parentContext?.traceId ?? replayCtxForTraceId?.traceId ?? crypto.randomUUID();
2889
2900
  const spanId = crypto.randomUUID();
2890
2901
  const parentSpanId = parentContext?.spanId ?? null;
2891
2902
  const isRootSpan = parentSpanId === null;