@sentry/replay 7.89.0 → 7.90.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
@@ -52,6 +52,36 @@ const MIN_REPLAY_DURATION_LIMIT = 15000;
52
52
  /** The max. length of a replay. */
53
53
  const MAX_REPLAY_DURATION = 3600000; // 60 minutes in ms;
54
54
 
55
+ const CANVAS_QUALITY = {
56
+ low: {
57
+ sampling: {
58
+ canvas: 1,
59
+ },
60
+ dataURLOptions: {
61
+ type: 'image/webp',
62
+ quality: 0.25,
63
+ },
64
+ },
65
+ medium: {
66
+ sampling: {
67
+ canvas: 2,
68
+ },
69
+ dataURLOptions: {
70
+ type: 'image/webp',
71
+ quality: 0.4,
72
+ },
73
+ },
74
+ high: {
75
+ sampling: {
76
+ canvas: 4,
77
+ },
78
+ dataURLOptions: {
79
+ type: 'image/webp',
80
+ quality: 0.5,
81
+ },
82
+ },
83
+ };
84
+
55
85
  var NodeType$1;
56
86
  (function (NodeType) {
57
87
  NodeType[NodeType["Document"] = 0] = "Document";
@@ -3914,7 +3944,9 @@ function addBreadcrumbEvent(replay, breadcrumb) {
3914
3944
  }
3915
3945
 
3916
3946
  replay.addUpdate(() => {
3917
- void replay.throttledAddEvent({
3947
+ // This should never reject
3948
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
3949
+ replay.throttledAddEvent({
3918
3950
  type: EventType.Custom,
3919
3951
  // TODO: We were converting from ms to seconds for breadcrumbs, spans,
3920
3952
  // but maybe we should just keep them as milliseconds
@@ -5028,7 +5060,9 @@ class EventBufferCompressionWorker {
5028
5060
  this.hasCheckout = false;
5029
5061
 
5030
5062
  // We do not wait on this, as we assume the order of messages is consistent for the worker
5031
- void this._worker.postMessage('clear');
5063
+ this._worker.postMessage('clear').then(null, e => {
5064
+ DEBUG_BUILD && logger.warn('[Replay] Sending "clear" message to worker failed', e);
5065
+ });
5032
5066
  }
5033
5067
 
5034
5068
  /** @inheritdoc */
@@ -5464,7 +5498,9 @@ function addEventSync(replay, event, isCheckout) {
5464
5498
  return false;
5465
5499
  }
5466
5500
 
5467
- void _addEvent(replay, event, isCheckout);
5501
+ // This should never reject
5502
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
5503
+ _addEvent(replay, event, isCheckout);
5468
5504
 
5469
5505
  return true;
5470
5506
  }
@@ -5661,7 +5697,9 @@ function handleErrorEvent(replay, event) {
5661
5697
 
5662
5698
  setTimeout(() => {
5663
5699
  // Capture current event buffer as new replay
5664
- void replay.sendBufferedReplayOrFlush();
5700
+ // This should never reject
5701
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
5702
+ replay.sendBufferedReplayOrFlush();
5665
5703
  });
5666
5704
  }
5667
5705
 
@@ -5705,8 +5743,9 @@ function handleHydrationError(replay, event) {
5705
5743
  // Example https://reactjs.org/docs/error-decoder.html?invariant=423
5706
5744
  exceptionValue.match(/reactjs\.org\/docs\/error-decoder\.html\?invariant=(418|419|422|423|425)/) ||
5707
5745
  // Development builds of react-dom
5708
- // Example Text: content did not match. Server: "A" Client: "B"
5709
- exceptionValue.match(/(hydration|content does not match|did not match)/i)
5746
+ // Error 1: Hydration failed because the initial UI does not match what was rendered on the server.
5747
+ // Error 2: Text content does not match server-rendered HTML. Warning: Text content did not match.
5748
+ exceptionValue.match(/(does not match server-rendered HTML|Hydration failed because)/i)
5710
5749
  ) {
5711
5750
  const breadcrumb = createBreadcrumb({
5712
5751
  category: 'replay.hydrate-error',
@@ -5743,7 +5782,9 @@ function addFeedbackBreadcrumb(replay, event) {
5743
5782
  return true;
5744
5783
  }
5745
5784
 
5746
- void replay.throttledAddEvent({
5785
+ // This should never reject
5786
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
5787
+ replay.throttledAddEvent({
5747
5788
  type: EventType.Custom,
5748
5789
  timestamp: event.timestamp * 1000,
5749
5790
  data: {
@@ -5821,7 +5862,9 @@ function handleGlobalEventListener(
5821
5862
  }
5822
5863
 
5823
5864
  if (isFeedbackEvent(event)) {
5824
- void replay.flush();
5865
+ // This should never reject
5866
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
5867
+ replay.flush();
5825
5868
  event.contexts.feedback.replay_id = replay.getSessionId();
5826
5869
  // Add a replay breadcrumb for this piece of feedback
5827
5870
  addFeedbackBreadcrumb(replay, event);
@@ -6875,7 +6918,9 @@ function beforeAddNetworkBreadcrumb(
6875
6918
  // So any async mutations to it will not be reflected in the final breadcrumb
6876
6919
  enrichXhrBreadcrumb(breadcrumb, hint, options);
6877
6920
 
6878
- void captureXhrBreadcrumbToReplay(breadcrumb, hint, options);
6921
+ // This call should not reject
6922
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
6923
+ captureXhrBreadcrumbToReplay(breadcrumb, hint, options);
6879
6924
  }
6880
6925
 
6881
6926
  if (_isFetchBreadcrumb(breadcrumb) && _isFetchHint(hint)) {
@@ -6884,7 +6929,9 @@ function beforeAddNetworkBreadcrumb(
6884
6929
  // So any async mutations to it will not be reflected in the final breadcrumb
6885
6930
  enrichFetchBreadcrumb(breadcrumb, hint, options);
6886
6931
 
6887
- void captureFetchBreadcrumbToReplay(breadcrumb, hint, options);
6932
+ // This call should not reject
6933
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
6934
+ captureFetchBreadcrumbToReplay(breadcrumb, hint, options);
6888
6935
  }
6889
6936
  } catch (e) {
6890
6937
  DEBUG_BUILD && logger.warn('Error when enriching network breadcrumb');
@@ -7067,7 +7114,9 @@ function addGlobalListeners(replay) {
7067
7114
  client.on('beforeSendFeedback', (feedbackEvent, options) => {
7068
7115
  const replayId = replay.getSessionId();
7069
7116
  if (options && options.includeReplay && replay.isEnabled() && replayId) {
7070
- void replay.flush();
7117
+ // This should never reject
7118
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
7119
+ replay.flush();
7071
7120
  if (feedbackEvent.contexts && feedbackEvent.contexts.feedback) {
7072
7121
  feedbackEvent.contexts.feedback.replay_id = replayId;
7073
7122
  }
@@ -7273,6 +7322,9 @@ function getHandleRecordingEmit(replay) {
7273
7322
  // a previous session ID. In this case, we want to buffer events
7274
7323
  // for a set amount of time before flushing. This can help avoid
7275
7324
  // capturing replays of users that immediately close the window.
7325
+
7326
+ // This should never reject
7327
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
7276
7328
  void replay.flush();
7277
7329
  }
7278
7330
 
@@ -7955,15 +8007,12 @@ class ReplayContainer {
7955
8007
  ...(this.recordingMode === 'buffer' && { checkoutEveryNms: BUFFER_CHECKOUT_TIME }),
7956
8008
  emit: getHandleRecordingEmit(this),
7957
8009
  onMutation: this._onMutationHandler,
7958
- ...(canvas && {
7959
- recordCanvas: true,
7960
- sampling: { canvas: canvas.fps || 4 },
7961
- dataURLOptions: {
7962
- type: canvas.type || 'image/webp',
7963
- quality: canvas.quality || 0.6,
7964
- },
7965
- getCanvasManager: canvas.manager,
7966
- }),
8010
+ ...(canvas &&
8011
+ canvas.manager && {
8012
+ recordCanvas: true,
8013
+ getCanvasManager: canvas.manager,
8014
+ ...(CANVAS_QUALITY[canvas.quality || 'medium'] || CANVAS_QUALITY.medium),
8015
+ }),
7967
8016
  });
7968
8017
  } catch (err) {
7969
8018
  this._handleException(err);
@@ -8403,7 +8452,9 @@ class ReplayContainer {
8403
8452
  maxReplayDuration: this._options.maxReplayDuration,
8404
8453
  })
8405
8454
  ) {
8406
- void this._refreshSession(currentSession);
8455
+ // This should never reject
8456
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
8457
+ this._refreshSession(currentSession);
8407
8458
  return false;
8408
8459
  }
8409
8460
 
@@ -8542,6 +8593,8 @@ class ReplayContainer {
8542
8593
  // Send replay when the page/tab becomes hidden. There is no reason to send
8543
8594
  // replay if it becomes visible, since no actions we care about were done
8544
8595
  // while it was hidden
8596
+ // This should never reject
8597
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
8545
8598
  void this.conditionalFlush();
8546
8599
  }
8547
8600
 
@@ -8590,7 +8643,9 @@ class ReplayContainer {
8590
8643
  */
8591
8644
  _createCustomBreadcrumb(breadcrumb) {
8592
8645
  this.addUpdate(() => {
8593
- void this.throttledAddEvent({
8646
+ // This should never reject
8647
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
8648
+ this.throttledAddEvent({
8594
8649
  type: EventType.Custom,
8595
8650
  timestamp: breadcrumb.timestamp || 0,
8596
8651
  data: {
@@ -8731,7 +8786,9 @@ class ReplayContainer {
8731
8786
  // This means we retried 3 times and all of them failed,
8732
8787
  // or we ran into a problem we don't want to retry, like rate limiting.
8733
8788
  // In this case, we want to completely stop the replay - otherwise, we may get inconsistent segments
8734
- void this.stop({ reason: 'sendReplay' });
8789
+ // This should never reject
8790
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
8791
+ this.stop({ reason: 'sendReplay' });
8735
8792
 
8736
8793
  const client = getClient();
8737
8794
 
@@ -8850,7 +8907,9 @@ class ReplayContainer {
8850
8907
 
8851
8908
  // Stop replay if over the mutation limit
8852
8909
  if (overMutationLimit) {
8853
- void this.stop({ reason: 'mutationLimit', forceFlush: this.recordingMode === 'session' });
8910
+ // This should never reject
8911
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
8912
+ this.stop({ reason: 'mutationLimit', forceFlush: this.recordingMode === 'session' });
8854
8913
  return false;
8855
8914
  }
8856
8915