@sentry/replay 7.80.2-alpha.0 → 7.81.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.
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { getCurrentHub, isSentryRequestUrl, addGlobalEventProcessor, prepareEvent, setContext, captureException } from '@sentry/core';
2
- import { GLOBAL_OBJ, normalize, fill, getElementIdentifier, browserPerformanceTimeOrigin, logger, uuid4, SENTRY_XHR_DATA_KEY, dropUndefinedKeys, stringMatchesSomePattern, addInstrumentationHandler, createEnvelope, createEventEnvelopeHeaders, getSdkMetadataForEnvelopeHeader, updateRateLimits, isRateLimited, isBrowser } from '@sentry/utils';
2
+ import { GLOBAL_OBJ, normalize, fill, htmlTreeAsString, browserPerformanceTimeOrigin, logger, uuid4, SENTRY_XHR_DATA_KEY, dropUndefinedKeys, stringMatchesSomePattern, addInstrumentationHandler, createEnvelope, createEventEnvelopeHeaders, getSdkMetadataForEnvelopeHeader, updateRateLimits, isRateLimited, isBrowser } from '@sentry/utils';
3
3
  import { addPerformanceInstrumentationHandler, addLcpInstrumentationHandler } from '@sentry-internal/tracing';
4
4
 
5
5
  // exporting a separate copy of `WINDOW` rather than exporting the one from `@sentry/browser`
@@ -4410,7 +4410,7 @@ function getDomTarget(handlerData) {
4410
4410
  // Accessing event.target can throw (see getsentry/raven-js#838, #768)
4411
4411
  try {
4412
4412
  target = isClick ? getClickTargetNode(handlerData.event) : getTargetNode(handlerData.event);
4413
- message = getElementIdentifier(target, { maxStringLength: 200 }) || '<unknown>';
4413
+ message = htmlTreeAsString(target, { maxStringLength: 200 }) || '<unknown>';
4414
4414
  } catch (e) {
4415
4415
  message = '<unknown>';
4416
4416
  }
@@ -4461,7 +4461,7 @@ function getKeyboardBreadcrumb(event) {
4461
4461
  return null;
4462
4462
  }
4463
4463
 
4464
- const message = getElementIdentifier(target, { maxStringLength: 200 }) || '<unknown>';
4464
+ const message = htmlTreeAsString(target, { maxStringLength: 200 }) || '<unknown>';
4465
4465
  const baseBreadcrumb = getBaseDomBreadcrumb(target , message);
4466
4466
 
4467
4467
  return createBreadcrumb({
@@ -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
  }