@sentry/replay 10.62.0 → 10.64.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.
@@ -1,4 +1,4 @@
1
- import { GLOBAL_OBJ, normalize, fill, browserPerformanceTimeOrigin, debug as debug$1, severityLevelFromString, captureException, addBreadcrumb, uuid4, getClient, spanIsSampled, getLocationHref, getCurrentScope, getActiveSpan, getDynamicSamplingContextFromSpan, isSentryRequestUrl, stringMatchesSomePattern, addEventProcessor, debounce as debounce$1, createEnvelope, createEventEnvelopeHeaders, getSdkMetadataForEnvelopeHeader, prepareEvent, getIsolationScope, updateRateLimits, isRateLimited, setContext, getRootSpan, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, isBrowser, safeSetSpanJSONAttributes, parseSampleRate, consoleSandbox } from '@sentry/core';
1
+ import { GLOBAL_OBJ, normalize, fill, browserPerformanceTimeOrigin, debug as debug$1, severityLevelFromString, captureException, addBreadcrumb, uuid4, getClient, getLocationHref, getCurrentScope, getActiveSpan, getDynamicSamplingContextFromSpan, isSentryRequestUrl, stringMatchesSomePattern, addEventProcessor, debounce as debounce$1, createEnvelope, createEventEnvelopeHeaders, getSdkMetadataForEnvelopeHeader, prepareEvent, getIsolationScope, updateRateLimits, isRateLimited, setContext, getRootSpan, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, isBrowser, safeSetSpanJSONAttributes, parseSampleRate, consoleSandbox } from '@sentry/core';
2
2
  import { setTimeout as setTimeout$3, htmlTreeAsString, addPerformanceInstrumentationHandler, addLcpInstrumentationHandler, addClsInstrumentationHandler, addInpInstrumentationHandler, serializeFormData, getFetchRequestArgBody, getBodyString, SENTRY_XHR_DATA_KEY, parseXhrResponseHeaders, addClickKeypressInstrumentationHandler, addHistoryInstrumentationHandler } from '@sentry/browser-utils';
3
3
 
4
4
  const WINDOW = GLOBAL_OBJ;
@@ -5867,23 +5867,23 @@ function maybeApplyCallback(event, callback) {
5867
5867
  return event;
5868
5868
  }
5869
5869
 
5870
- const MAX_TRACE_IDS = 100;
5871
- function addTraceIdToContext(replay, traceId) {
5870
+ const MAX_CONTEXT_VALUES = 100;
5871
+ function addSegmentDetailsToContext(replay, traceId, segmentName) {
5872
5872
  const replayContext = replay.getContext();
5873
- if (replayContext.traceIds.size < MAX_TRACE_IDS) {
5873
+ if (traceId && replayContext.traceIds.size < MAX_CONTEXT_VALUES) {
5874
5874
  replayContext.traceIds.add(traceId);
5875
5875
  }
5876
+ if (segmentName && replayContext.segmentNames.size < MAX_CONTEXT_VALUES) {
5877
+ replayContext.segmentNames.add(segmentName);
5878
+ }
5876
5879
  }
5877
5880
 
5878
- function handleAfterSegmentSpanEnd(replay) {
5879
- return (segmentSpan) => {
5880
- if (!replay.isEnabled() || !spanIsSampled(segmentSpan)) {
5881
+ function handleProcessSegmentSpan(replay) {
5882
+ return (spanJSON) => {
5883
+ if (!replay.isEnabled()) {
5881
5884
  return;
5882
5885
  }
5883
- const traceId = segmentSpan.spanContext().traceId;
5884
- if (traceId) {
5885
- addTraceIdToContext(replay, traceId);
5886
- }
5886
+ addSegmentDetailsToContext(replay, spanJSON.trace_id, spanJSON.name || void 0);
5887
5887
  };
5888
5888
  }
5889
5889
 
@@ -5917,10 +5917,7 @@ function handleAfterSendEvent(replay) {
5917
5917
  };
5918
5918
  }
5919
5919
  function handleTransactionEvent(replay, event) {
5920
- const traceId = event.contexts?.trace?.trace_id;
5921
- if (traceId) {
5922
- addTraceIdToContext(replay, traceId);
5923
- }
5920
+ addSegmentDetailsToContext(replay, event.contexts?.trace?.trace_id, event.transaction);
5924
5921
  }
5925
5922
  function handleErrorEvent(replay, event) {
5926
5923
  const replayContext = replay.getContext();
@@ -6779,7 +6776,7 @@ function addGlobalListeners(replay) {
6779
6776
  }
6780
6777
  }
6781
6778
  });
6782
- client.on("afterSegmentSpanEnd", handleAfterSegmentSpanEnd(replay));
6779
+ client.on("processSegmentSpan", handleProcessSegmentSpan(replay));
6783
6780
  client.on("spanStart", (span) => {
6784
6781
  replay.lastActiveSpan = span;
6785
6782
  });
@@ -7044,7 +7041,7 @@ async function sendReplayRequest({
7044
7041
  segment_id
7045
7042
  }
7046
7043
  });
7047
- const { urls, errorIds, traceIds, initialTimestamp } = eventContext;
7044
+ const { urls, errorIds, traceIds, segmentNames, initialTimestamp } = eventContext;
7048
7045
  const client = getClient();
7049
7046
  const scope = getCurrentScope();
7050
7047
  const transport = client?.getTransport();
@@ -7058,6 +7055,7 @@ async function sendReplayRequest({
7058
7055
  timestamp: timestamp / 1e3,
7059
7056
  error_ids: errorIds,
7060
7057
  trace_ids: traceIds,
7058
+ segment_names: segmentNames,
7061
7059
  urls,
7062
7060
  replay_id: replayId,
7063
7061
  segment_id,
@@ -7203,6 +7201,7 @@ class ReplayContainer {
7203
7201
  this._context = {
7204
7202
  errorIds: /* @__PURE__ */ new Set(),
7205
7203
  traceIds: /* @__PURE__ */ new Set(),
7204
+ segmentNames: /* @__PURE__ */ new Set(),
7206
7205
  urls: [],
7207
7206
  initialTimestamp: Date.now(),
7208
7207
  initialUrl: ""
@@ -7875,6 +7874,7 @@ class ReplayContainer {
7875
7874
  _clearContext() {
7876
7875
  this._context.errorIds.clear();
7877
7876
  this._context.traceIds.clear();
7877
+ this._context.segmentNames.clear();
7878
7878
  this._context.urls = [];
7879
7879
  }
7880
7880
  /** Update the initial timestamp based on the buffer content. */
@@ -7900,6 +7900,7 @@ class ReplayContainer {
7900
7900
  initialUrl: this._context.initialUrl,
7901
7901
  errorIds: Array.from(this._context.errorIds),
7902
7902
  traceIds: Array.from(this._context.traceIds),
7903
+ segmentNames: Array.from(this._context.segmentNames),
7903
7904
  urls: this._context.urls
7904
7905
  };
7905
7906
  this._clearContext();