@sentry/replay 10.60.0 → 10.62.0

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.
@@ -5869,6 +5869,26 @@ function maybeApplyCallback(event, callback) {
5869
5869
  return event;
5870
5870
  }
5871
5871
 
5872
+ const MAX_TRACE_IDS = 100;
5873
+ function addTraceIdToContext(replay, traceId) {
5874
+ const replayContext = replay.getContext();
5875
+ if (replayContext.traceIds.size < MAX_TRACE_IDS) {
5876
+ replayContext.traceIds.add(traceId);
5877
+ }
5878
+ }
5879
+
5880
+ function handleAfterSegmentSpanEnd(replay) {
5881
+ return (segmentSpan) => {
5882
+ if (!replay.isEnabled() || !core.spanIsSampled(segmentSpan)) {
5883
+ return;
5884
+ }
5885
+ const traceId = segmentSpan.spanContext().traceId;
5886
+ if (traceId) {
5887
+ addTraceIdToContext(replay, traceId);
5888
+ }
5889
+ };
5890
+ }
5891
+
5872
5892
  function isErrorEvent(event) {
5873
5893
  return !event.type;
5874
5894
  }
@@ -5899,9 +5919,9 @@ function handleAfterSendEvent(replay) {
5899
5919
  };
5900
5920
  }
5901
5921
  function handleTransactionEvent(replay, event) {
5902
- const replayContext = replay.getContext();
5903
- if (event.contexts?.trace?.trace_id && replayContext.traceIds.size < 100) {
5904
- replayContext.traceIds.add(event.contexts.trace.trace_id);
5922
+ const traceId = event.contexts?.trace?.trace_id;
5923
+ if (traceId) {
5924
+ addTraceIdToContext(replay, traceId);
5905
5925
  }
5906
5926
  }
5907
5927
  function handleErrorEvent(replay, event) {
@@ -6761,6 +6781,7 @@ function addGlobalListeners(replay) {
6761
6781
  }
6762
6782
  }
6763
6783
  });
6784
+ client.on("afterSegmentSpanEnd", handleAfterSegmentSpanEnd(replay));
6764
6785
  client.on("spanStart", (span) => {
6765
6786
  replay.lastActiveSpan = span;
6766
6787
  });