@sentry/replay 7.80.2-alpha.1 → 7.81.1

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/esm/index.js CHANGED
@@ -5737,6 +5737,8 @@ function handleGlobalEventListener(
5737
5737
  }
5738
5738
 
5739
5739
  if (isFeedbackEvent(event)) {
5740
+ void replay.flush();
5741
+ event.contexts.feedback.replay_id = replay.getSessionId();
5740
5742
  // Add a replay breadcrumb for this piece of feedback
5741
5743
  addFeedbackBreadcrumb(replay, event);
5742
5744
  return event;
@@ -6034,6 +6036,8 @@ function getBodyString(body) {
6034
6036
  (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.warn('[Replay] Failed to serialize body', body);
6035
6037
  }
6036
6038
 
6039
+ (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.info('[Replay] Skipping network body because of body type', body);
6040
+
6037
6041
  return undefined;
6038
6042
  }
6039
6043
 
@@ -6553,15 +6557,24 @@ function getResponseHeaders(xhr) {
6553
6557
  }
6554
6558
 
6555
6559
  function _getXhrResponseBody(xhr) {
6560
+ // We collect errors that happen, but only log them if we can't get any response body
6561
+ const errors = [];
6562
+
6556
6563
  try {
6557
6564
  return xhr.responseText;
6558
- } catch (e) {} // eslint-disable-line no-empty
6565
+ } catch (e) {
6566
+ errors.push(e);
6567
+ }
6559
6568
 
6560
6569
  // Try to manually parse the response body, if responseText fails
6561
6570
  try {
6562
6571
  const response = xhr.response;
6563
6572
  return getBodyString(response);
6564
- } catch (e2) {} // eslint-disable-line no-empty
6573
+ } catch (e) {
6574
+ errors.push(e);
6575
+ }
6576
+
6577
+ (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.warn('[Replay] Failed to get xhr response body', ...errors);
6565
6578
 
6566
6579
  return undefined;
6567
6580
  }
@@ -6811,6 +6824,17 @@ function addGlobalListeners(replay) {
6811
6824
  client.on('finishTransaction', transaction => {
6812
6825
  replay.lastTransaction = transaction;
6813
6826
  });
6827
+
6828
+ // We want to flush replay
6829
+ client.on('beforeSendFeedback', (feedbackEvent, options) => {
6830
+ const replayId = replay.getSessionId();
6831
+ if (options && options.includeReplay && replay.isEnabled() && replayId) {
6832
+ void replay.flush();
6833
+ if (feedbackEvent.contexts && feedbackEvent.contexts.feedback) {
6834
+ feedbackEvent.contexts.feedback.replay_id = replayId;
6835
+ }
6836
+ }
6837
+ });
6814
6838
  }
6815
6839
  }
6816
6840