@bitfab/sdk 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
@@ -8,13 +8,13 @@ import {
8
8
  SUPPORTED_PROVIDERS,
9
9
  getCurrentSpan,
10
10
  getCurrentTrace
11
- } from "./chunk-XUW46356.js";
11
+ } from "./chunk-4IHJJRMU.js";
12
12
  import {
13
13
  BitfabError,
14
14
  DEFAULT_SERVICE_URL,
15
15
  __version__,
16
16
  flushTraces
17
- } from "./chunk-SKJWF5VX.js";
17
+ } from "./chunk-BVFST7Q3.js";
18
18
  export {
19
19
  Bitfab,
20
20
  BitfabClaudeAgentHandler,
package/dist/node.cjs CHANGED
@@ -81,7 +81,7 @@ var __version__;
81
81
  var init_version_generated = __esm({
82
82
  "src/version.generated.ts"() {
83
83
  "use strict";
84
- __version__ = "0.13.4";
84
+ __version__ = "0.13.5";
85
85
  }
86
86
  });
87
87
 
@@ -579,6 +579,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
579
579
  let originalOutput;
580
580
  let result;
581
581
  let error = null;
582
+ const replayedTraceId = crypto.randomUUID();
582
583
  try {
583
584
  const span = await httpClient.getExternalSpan(serverItem.externalSpanId);
584
585
  const spanData = span.rawData?.span_data ?? {};
@@ -594,6 +595,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
594
595
  const maybePromise = runWithReplayContext(
595
596
  {
596
597
  testRunId,
598
+ traceId: replayedTraceId,
597
599
  inputSourceSpanId: span.id,
598
600
  inputSourceTraceId: span.externalTraceId,
599
601
  sourceBitfabTraceId: serverItem.traceId,
@@ -622,6 +624,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
622
624
  }
623
625
  }
624
626
  return {
627
+ traceId: replayedTraceId,
625
628
  input: inputs,
626
629
  result,
627
630
  originalOutput,
@@ -677,14 +680,21 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options) {
677
680
  );
678
681
  const resultItems = await mapWithConcurrency(tasks, maxConcurrency);
679
682
  await flushTraces();
683
+ let serverTraceIds = {};
680
684
  try {
681
- await httpClient.completeReplay(testRunId);
685
+ const completeResult = await httpClient.completeReplay(testRunId);
686
+ serverTraceIds = completeResult.traceIds ?? {};
682
687
  } catch (e) {
683
688
  try {
684
689
  console.error("Bitfab: Failed to complete replay:", e);
685
690
  } catch {
686
691
  }
687
692
  }
693
+ for (const item of resultItems) {
694
+ if (item.traceId) {
695
+ item.traceId = serverTraceIds[item.traceId] ?? null;
696
+ }
697
+ }
688
698
  return {
689
699
  items: resultItems,
690
700
  testRunId,
@@ -2876,7 +2886,8 @@ var Bitfab = class {
2876
2886
  }
2877
2887
  const currentStack = getSpanStack();
2878
2888
  const parentContext = currentStack[currentStack.length - 1];
2879
- const traceId = parentContext?.traceId ?? crypto.randomUUID();
2889
+ const replayCtxForTraceId = parentContext ? null : getReplayContext();
2890
+ const traceId = parentContext?.traceId ?? replayCtxForTraceId?.traceId ?? crypto.randomUUID();
2880
2891
  const spanId = crypto.randomUUID();
2881
2892
  const parentSpanId = parentContext?.spanId ?? null;
2882
2893
  const isRootSpan = parentSpanId === null;