@sentry/replay 10.64.0 → 10.66.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, 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, isObjectLike, 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;
@@ -4633,7 +4633,7 @@ function getTargetNode(event) {
4633
4633
  return event;
4634
4634
  }
4635
4635
  function isEventWithTarget(event) {
4636
- return typeof event === "object" && !!event && "target" in event;
4636
+ return isObjectLike(event) && "target" in event;
4637
4637
  }
4638
4638
 
4639
4639
  let handlers;
@@ -5825,6 +5825,10 @@ async function _addEvent(replay, event, isCheckout) {
5825
5825
  }
5826
5826
  return await eventBuffer.addEvent(eventAfterPossibleCallback);
5827
5827
  } catch (error) {
5828
+ if (!replay.isEnabled()) {
5829
+ replay.handleException(error);
5830
+ return null;
5831
+ }
5828
5832
  const isExceeded = error && error instanceof EventBufferSizeExceededError;
5829
5833
  const reason = isExceeded ? "eventBufferOverflow" : "eventBufferError";
5830
5834
  const client = getClient();
@@ -6680,7 +6684,7 @@ function _parseXhrResponse(body, responseType) {
6680
6684
  if (body instanceof Document) {
6681
6685
  return [body.body.outerHTML];
6682
6686
  }
6683
- if (responseType === "json" && body && typeof body === "object") {
6687
+ if (responseType === "json" && isObjectLike(body)) {
6684
6688
  return [JSON.stringify(body)];
6685
6689
  }
6686
6690
  if (!body) {
@@ -6695,7 +6699,7 @@ function _parseXhrResponse(body, responseType) {
6695
6699
  }
6696
6700
  function _getBodySize(body, responseType) {
6697
6701
  try {
6698
- const bodyStr = responseType === "json" && body && typeof body === "object" ? JSON.stringify(body) : body;
6702
+ const bodyStr = responseType === "json" && isObjectLike(body) ? JSON.stringify(body) : body;
6699
6703
  return getBodySize(bodyStr);
6700
6704
  } catch {
6701
6705
  return void 0;
@@ -6851,46 +6855,50 @@ function getRecordingSamplingOptions() {
6851
6855
  function getHandleRecordingEmit(replay) {
6852
6856
  let hadFirstEvent = false;
6853
6857
  return (event, _isCheckout) => {
6854
- if (!replay.checkAndHandleExpiredSession()) {
6855
- DEBUG_BUILD && debug.warn("Received replay event after session expired.");
6856
- return;
6857
- }
6858
- const isCheckout = _isCheckout || !hadFirstEvent;
6859
- hadFirstEvent = true;
6860
- syncMirrorAttributesFromMutationEvent(event);
6861
- if (replay.clickDetector) {
6862
- updateClickDetectorForRecordingEvent(replay.clickDetector, event);
6863
- }
6864
- replay.addUpdate(() => {
6865
- if (replay.recordingMode === "buffer" && isCheckout) {
6866
- replay.setInitialState();
6867
- }
6868
- if (!addEventSync(replay, event, isCheckout)) {
6869
- return true;
6858
+ try {
6859
+ if (!replay.checkAndHandleExpiredSession()) {
6860
+ DEBUG_BUILD && debug.warn("Received replay event after session expired.");
6861
+ return;
6870
6862
  }
6871
- if (!isCheckout) {
6872
- return false;
6863
+ const isCheckout = _isCheckout || !hadFirstEvent;
6864
+ hadFirstEvent = true;
6865
+ syncMirrorAttributesFromMutationEvent(event);
6866
+ if (replay.clickDetector) {
6867
+ updateClickDetectorForRecordingEvent(replay.clickDetector, event);
6873
6868
  }
6874
- const session = replay.session;
6875
- addSettingsEvent(replay, isCheckout);
6876
- if (replay.recordingMode === "buffer" && session && replay.eventBuffer && !session.dirty) {
6877
- const earliestEvent = replay.eventBuffer.getEarliestTimestamp();
6878
- if (earliestEvent) {
6879
- DEBUG_BUILD && debug.log(`Updating session start time to earliest event in buffer to ${new Date(earliestEvent)}`);
6880
- session.started = earliestEvent;
6881
- if (replay.getOptions().stickySession) {
6882
- saveSession(session);
6869
+ replay.addUpdate(() => {
6870
+ if (replay.recordingMode === "buffer" && isCheckout) {
6871
+ replay.setInitialState();
6872
+ }
6873
+ if (!addEventSync(replay, event, isCheckout)) {
6874
+ return true;
6875
+ }
6876
+ if (!isCheckout) {
6877
+ return false;
6878
+ }
6879
+ const session = replay.session;
6880
+ addSettingsEvent(replay, isCheckout);
6881
+ if (replay.recordingMode === "buffer" && session && replay.eventBuffer && !session.dirty) {
6882
+ const earliestEvent = replay.eventBuffer.getEarliestTimestamp();
6883
+ if (earliestEvent) {
6884
+ DEBUG_BUILD && debug.log(`Updating session start time to earliest event in buffer to ${new Date(earliestEvent)}`);
6885
+ session.started = earliestEvent;
6886
+ if (replay.getOptions().stickySession) {
6887
+ saveSession(session);
6888
+ }
6883
6889
  }
6884
6890
  }
6885
- }
6886
- if (session?.previousSessionId) {
6891
+ if (session?.previousSessionId) {
6892
+ return true;
6893
+ }
6894
+ if (replay.recordingMode === "session") {
6895
+ void replay.flush();
6896
+ }
6887
6897
  return true;
6888
- }
6889
- if (replay.recordingMode === "session") {
6890
- void replay.flush();
6891
- }
6892
- return true;
6893
- });
6898
+ });
6899
+ } catch (error) {
6900
+ replay.handleException(error);
6901
+ }
6894
6902
  };
6895
6903
  }
6896
6904
  function syncMirrorAttributesFromMutationEvent(event) {