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