@sentry/replay 7.89.0 → 7.91.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/cjs/index.js CHANGED
@@ -54,6 +54,36 @@ const MIN_REPLAY_DURATION_LIMIT = 15000;
54
54
  /** The max. length of a replay. */
55
55
  const MAX_REPLAY_DURATION = 3600000; // 60 minutes in ms;
56
56
 
57
+ const CANVAS_QUALITY = {
58
+ low: {
59
+ sampling: {
60
+ canvas: 1,
61
+ },
62
+ dataURLOptions: {
63
+ type: 'image/webp',
64
+ quality: 0.25,
65
+ },
66
+ },
67
+ medium: {
68
+ sampling: {
69
+ canvas: 2,
70
+ },
71
+ dataURLOptions: {
72
+ type: 'image/webp',
73
+ quality: 0.4,
74
+ },
75
+ },
76
+ high: {
77
+ sampling: {
78
+ canvas: 4,
79
+ },
80
+ dataURLOptions: {
81
+ type: 'image/webp',
82
+ quality: 0.5,
83
+ },
84
+ },
85
+ };
86
+
57
87
  var NodeType$1;
58
88
  (function (NodeType) {
59
89
  NodeType[NodeType["Document"] = 0] = "Document";
@@ -3916,7 +3946,9 @@ function addBreadcrumbEvent(replay, breadcrumb) {
3916
3946
  }
3917
3947
 
3918
3948
  replay.addUpdate(() => {
3919
- void replay.throttledAddEvent({
3949
+ // This should never reject
3950
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
3951
+ replay.throttledAddEvent({
3920
3952
  type: EventType.Custom,
3921
3953
  // TODO: We were converting from ms to seconds for breadcrumbs, spans,
3922
3954
  // but maybe we should just keep them as milliseconds
@@ -4347,6 +4379,7 @@ const ATTRIBUTES_TO_RECORD = new Set([
4347
4379
  'data-testid',
4348
4380
  'disabled',
4349
4381
  'aria-disabled',
4382
+ 'data-sentry-component',
4350
4383
  ]);
4351
4384
 
4352
4385
  /**
@@ -5030,7 +5063,9 @@ class EventBufferCompressionWorker {
5030
5063
  this.hasCheckout = false;
5031
5064
 
5032
5065
  // We do not wait on this, as we assume the order of messages is consistent for the worker
5033
- void this._worker.postMessage('clear');
5066
+ this._worker.postMessage('clear').then(null, e => {
5067
+ DEBUG_BUILD && utils.logger.warn('[Replay] Sending "clear" message to worker failed', e);
5068
+ });
5034
5069
  }
5035
5070
 
5036
5071
  /** @inheritdoc */
@@ -5466,7 +5501,9 @@ function addEventSync(replay, event, isCheckout) {
5466
5501
  return false;
5467
5502
  }
5468
5503
 
5469
- void _addEvent(replay, event, isCheckout);
5504
+ // This should never reject
5505
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
5506
+ _addEvent(replay, event, isCheckout);
5470
5507
 
5471
5508
  return true;
5472
5509
  }
@@ -5663,7 +5700,9 @@ function handleErrorEvent(replay, event) {
5663
5700
 
5664
5701
  setTimeout(() => {
5665
5702
  // Capture current event buffer as new replay
5666
- void replay.sendBufferedReplayOrFlush();
5703
+ // This should never reject
5704
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
5705
+ replay.sendBufferedReplayOrFlush();
5667
5706
  });
5668
5707
  }
5669
5708
 
@@ -5707,8 +5746,9 @@ function handleHydrationError(replay, event) {
5707
5746
  // Example https://reactjs.org/docs/error-decoder.html?invariant=423
5708
5747
  exceptionValue.match(/reactjs\.org\/docs\/error-decoder\.html\?invariant=(418|419|422|423|425)/) ||
5709
5748
  // Development builds of react-dom
5710
- // Example Text: content did not match. Server: "A" Client: "B"
5711
- exceptionValue.match(/(hydration|content does not match|did not match)/i)
5749
+ // Error 1: Hydration failed because the initial UI does not match what was rendered on the server.
5750
+ // Error 2: Text content does not match server-rendered HTML. Warning: Text content did not match.
5751
+ exceptionValue.match(/(does not match server-rendered HTML|Hydration failed because)/i)
5712
5752
  ) {
5713
5753
  const breadcrumb = createBreadcrumb({
5714
5754
  category: 'replay.hydrate-error',
@@ -5745,7 +5785,9 @@ function addFeedbackBreadcrumb(replay, event) {
5745
5785
  return true;
5746
5786
  }
5747
5787
 
5748
- void replay.throttledAddEvent({
5788
+ // This should never reject
5789
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
5790
+ replay.throttledAddEvent({
5749
5791
  type: EventType.Custom,
5750
5792
  timestamp: event.timestamp * 1000,
5751
5793
  data: {
@@ -5823,7 +5865,9 @@ function handleGlobalEventListener(
5823
5865
  }
5824
5866
 
5825
5867
  if (isFeedbackEvent(event)) {
5826
- void replay.flush();
5868
+ // This should never reject
5869
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
5870
+ replay.flush();
5827
5871
  event.contexts.feedback.replay_id = replay.getSessionId();
5828
5872
  // Add a replay breadcrumb for this piece of feedback
5829
5873
  addFeedbackBreadcrumb(replay, event);
@@ -6877,7 +6921,9 @@ function beforeAddNetworkBreadcrumb(
6877
6921
  // So any async mutations to it will not be reflected in the final breadcrumb
6878
6922
  enrichXhrBreadcrumb(breadcrumb, hint, options);
6879
6923
 
6880
- void captureXhrBreadcrumbToReplay(breadcrumb, hint, options);
6924
+ // This call should not reject
6925
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
6926
+ captureXhrBreadcrumbToReplay(breadcrumb, hint, options);
6881
6927
  }
6882
6928
 
6883
6929
  if (_isFetchBreadcrumb(breadcrumb) && _isFetchHint(hint)) {
@@ -6886,7 +6932,9 @@ function beforeAddNetworkBreadcrumb(
6886
6932
  // So any async mutations to it will not be reflected in the final breadcrumb
6887
6933
  enrichFetchBreadcrumb(breadcrumb, hint, options);
6888
6934
 
6889
- void captureFetchBreadcrumbToReplay(breadcrumb, hint, options);
6935
+ // This call should not reject
6936
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
6937
+ captureFetchBreadcrumbToReplay(breadcrumb, hint, options);
6890
6938
  }
6891
6939
  } catch (e) {
6892
6940
  DEBUG_BUILD && utils.logger.warn('Error when enriching network breadcrumb');
@@ -7069,7 +7117,9 @@ function addGlobalListeners(replay) {
7069
7117
  client.on('beforeSendFeedback', (feedbackEvent, options) => {
7070
7118
  const replayId = replay.getSessionId();
7071
7119
  if (options && options.includeReplay && replay.isEnabled() && replayId) {
7072
- void replay.flush();
7120
+ // This should never reject
7121
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
7122
+ replay.flush();
7073
7123
  if (feedbackEvent.contexts && feedbackEvent.contexts.feedback) {
7074
7124
  feedbackEvent.contexts.feedback.replay_id = replayId;
7075
7125
  }
@@ -7275,6 +7325,9 @@ function getHandleRecordingEmit(replay) {
7275
7325
  // a previous session ID. In this case, we want to buffer events
7276
7326
  // for a set amount of time before flushing. This can help avoid
7277
7327
  // capturing replays of users that immediately close the window.
7328
+
7329
+ // This should never reject
7330
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
7278
7331
  void replay.flush();
7279
7332
  }
7280
7333
 
@@ -7410,6 +7463,7 @@ async function prepareReplayEvent({
7410
7463
  eventHint,
7411
7464
  scope,
7412
7465
  client,
7466
+ core.getIsolationScope(),
7413
7467
  )) ;
7414
7468
 
7415
7469
  // If e.g. a global event processor returned null
@@ -7957,15 +8011,12 @@ class ReplayContainer {
7957
8011
  ...(this.recordingMode === 'buffer' && { checkoutEveryNms: BUFFER_CHECKOUT_TIME }),
7958
8012
  emit: getHandleRecordingEmit(this),
7959
8013
  onMutation: this._onMutationHandler,
7960
- ...(canvas && {
7961
- recordCanvas: true,
7962
- sampling: { canvas: canvas.fps || 4 },
7963
- dataURLOptions: {
7964
- type: canvas.type || 'image/webp',
7965
- quality: canvas.quality || 0.6,
7966
- },
7967
- getCanvasManager: canvas.manager,
7968
- }),
8014
+ ...(canvas &&
8015
+ canvas.manager && {
8016
+ recordCanvas: true,
8017
+ getCanvasManager: canvas.manager,
8018
+ ...(CANVAS_QUALITY[canvas.quality || 'medium'] || CANVAS_QUALITY.medium),
8019
+ }),
7969
8020
  });
7970
8021
  } catch (err) {
7971
8022
  this._handleException(err);
@@ -8405,7 +8456,9 @@ class ReplayContainer {
8405
8456
  maxReplayDuration: this._options.maxReplayDuration,
8406
8457
  })
8407
8458
  ) {
8408
- void this._refreshSession(currentSession);
8459
+ // This should never reject
8460
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
8461
+ this._refreshSession(currentSession);
8409
8462
  return false;
8410
8463
  }
8411
8464
 
@@ -8544,6 +8597,8 @@ class ReplayContainer {
8544
8597
  // Send replay when the page/tab becomes hidden. There is no reason to send
8545
8598
  // replay if it becomes visible, since no actions we care about were done
8546
8599
  // while it was hidden
8600
+ // This should never reject
8601
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
8547
8602
  void this.conditionalFlush();
8548
8603
  }
8549
8604
 
@@ -8592,7 +8647,9 @@ class ReplayContainer {
8592
8647
  */
8593
8648
  _createCustomBreadcrumb(breadcrumb) {
8594
8649
  this.addUpdate(() => {
8595
- void this.throttledAddEvent({
8650
+ // This should never reject
8651
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
8652
+ this.throttledAddEvent({
8596
8653
  type: EventType.Custom,
8597
8654
  timestamp: breadcrumb.timestamp || 0,
8598
8655
  data: {
@@ -8733,7 +8790,9 @@ class ReplayContainer {
8733
8790
  // This means we retried 3 times and all of them failed,
8734
8791
  // or we ran into a problem we don't want to retry, like rate limiting.
8735
8792
  // In this case, we want to completely stop the replay - otherwise, we may get inconsistent segments
8736
- void this.stop({ reason: 'sendReplay' });
8793
+ // This should never reject
8794
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
8795
+ this.stop({ reason: 'sendReplay' });
8737
8796
 
8738
8797
  const client = core.getClient();
8739
8798
 
@@ -8852,7 +8911,9 @@ class ReplayContainer {
8852
8911
 
8853
8912
  // Stop replay if over the mutation limit
8854
8913
  if (overMutationLimit) {
8855
- void this.stop({ reason: 'mutationLimit', forceFlush: this.recordingMode === 'session' });
8914
+ // This should never reject
8915
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
8916
+ this.stop({ reason: 'mutationLimit', forceFlush: this.recordingMode === 'session' });
8856
8917
  return false;
8857
8918
  }
8858
8919