@sentry/replay 7.57.0 → 7.58.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/cjs/index.js CHANGED
@@ -44,8 +44,6 @@ const CONSOLE_ARG_MAX_SIZE = 5000;
44
44
  const SLOW_CLICK_THRESHOLD = 3000;
45
45
  /* For scroll actions after a click, we only look for a very short time period to detect programmatic scrolling. */
46
46
  const SLOW_CLICK_SCROLL_TIMEOUT = 300;
47
- /* Clicks in this time period are considered e.g. double/triple clicks. */
48
- const MULTI_CLICK_TIMEOUT = 1000;
49
47
 
50
48
  /** When encountering a total segment size exceeding this size, stop the replay (as we cannot properly ingest it). */
51
49
  const REPLAY_MAX_EVENT_BUFFER_SIZE = 20000000; // ~20MB
@@ -3398,7 +3396,6 @@ class ClickDetector {
3398
3396
  ) {ClickDetector.prototype.__init.call(this);ClickDetector.prototype.__init2.call(this);ClickDetector.prototype.__init3.call(this);
3399
3397
  // We want everything in s, but options are in ms
3400
3398
  this._timeout = slowClickConfig.timeout / 1000;
3401
- this._multiClickTimeout = slowClickConfig.multiClickTimeout / 1000;
3402
3399
  this._threshold = slowClickConfig.threshold / 1000;
3403
3400
  this._scollTimeout = slowClickConfig.scrollTimeout / 1000;
3404
3401
  this._replay = replay;
@@ -3473,13 +3470,6 @@ class ClickDetector {
3473
3470
  return;
3474
3471
  }
3475
3472
 
3476
- const click = this._getClick(node);
3477
-
3478
- if (click) {
3479
- // this means a click on the same element was captured in the last 1s, so we consider this a multi click
3480
- return;
3481
- }
3482
-
3483
3473
  const newClick = {
3484
3474
  timestamp: breadcrumb.timestamp,
3485
3475
  clickBreadcrumb: breadcrumb,
@@ -3497,22 +3487,14 @@ class ClickDetector {
3497
3487
 
3498
3488
  /** Count multiple clicks on elements. */
3499
3489
  _handleMultiClick(node) {
3500
- const click = this._getClick(node);
3501
-
3502
- if (!click) {
3503
- return;
3504
- }
3505
-
3506
- click.clickCount++;
3490
+ this._getClicks(node).forEach(click => {
3491
+ click.clickCount++;
3492
+ });
3507
3493
  }
3508
3494
 
3509
- /** Try to get an existing click on the given element. */
3510
- _getClick(node) {
3511
- const now = nowInSeconds();
3512
-
3513
- // Find any click on the same element in the last second
3514
- // If one exists, we consider this click as a double/triple/etc click
3515
- return this._clicks.find(click => click.node === node && now - click.timestamp < this._multiClickTimeout);
3495
+ /** Get all pending clicks for a given node. */
3496
+ _getClicks(node) {
3497
+ return this._clicks.filter(click => click.node === node);
3516
3498
  }
3517
3499
 
3518
3500
  /** Check the clicks that happened. */
@@ -3529,13 +3511,6 @@ class ClickDetector {
3529
3511
  click.scrollAfter = click.timestamp <= this._lastScroll ? this._lastScroll - click.timestamp : undefined;
3530
3512
  }
3531
3513
 
3532
- // If an action happens after the multi click threshold, we can skip waiting and handle the click right away
3533
- const actionTime = click.scrollAfter || click.mutationAfter || 0;
3534
- if (actionTime && actionTime >= this._multiClickTimeout) {
3535
- timedOutClicks.push(click);
3536
- return;
3537
- }
3538
-
3539
3514
  if (click.timestamp + this._timeout <= now) {
3540
3515
  timedOutClicks.push(click);
3541
3516
  }
@@ -3616,6 +3591,10 @@ class ClickDetector {
3616
3591
 
3617
3592
  /** Schedule to check current clicks. */
3618
3593
  _scheduleCheckClicks() {
3594
+ if (this._checkClickTimeout) {
3595
+ clearTimeout(this._checkClickTimeout);
3596
+ }
3597
+
3619
3598
  this._checkClickTimeout = setTimeout(() => this._checkClicks(), 1000);
3620
3599
  }
3621
3600
  }
@@ -5756,7 +5735,8 @@ async function _prepareFetchData(
5756
5735
  response_body_size: responseBodySize,
5757
5736
  } = breadcrumb.data;
5758
5737
 
5759
- const captureDetails = urlMatches(url, options.networkDetailAllowUrls);
5738
+ const captureDetails =
5739
+ urlMatches(url, options.networkDetailAllowUrls) && !urlMatches(url, options.networkDetailDenyUrls);
5760
5740
 
5761
5741
  const request = captureDetails
5762
5742
  ? _getRequestInfo(options, hint.input, requestBodySize)
@@ -5970,7 +5950,7 @@ function _prepareXhrData(
5970
5950
  return null;
5971
5951
  }
5972
5952
 
5973
- if (!urlMatches(url, options.networkDetailAllowUrls)) {
5953
+ if (!urlMatches(url, options.networkDetailAllowUrls) || urlMatches(url, options.networkDetailDenyUrls)) {
5974
5954
  const request = buildSkippedNetworkRequestOrResponse(requestBodySize);
5975
5955
  const response = buildSkippedNetworkRequestOrResponse(responseBodySize);
5976
5956
  return {
@@ -6038,13 +6018,19 @@ function handleNetworkBreadcrumbs(replay) {
6038
6018
  try {
6039
6019
  const textEncoder = new TextEncoder();
6040
6020
 
6041
- const { networkDetailAllowUrls, networkCaptureBodies, networkRequestHeaders, networkResponseHeaders } =
6042
- replay.getOptions();
6021
+ const {
6022
+ networkDetailAllowUrls,
6023
+ networkDetailDenyUrls,
6024
+ networkCaptureBodies,
6025
+ networkRequestHeaders,
6026
+ networkResponseHeaders,
6027
+ } = replay.getOptions();
6043
6028
 
6044
6029
  const options = {
6045
6030
  replay,
6046
6031
  textEncoder,
6047
6032
  networkDetailAllowUrls,
6033
+ networkDetailDenyUrls,
6048
6034
  networkCaptureBodies,
6049
6035
  networkRequestHeaders,
6050
6036
  networkResponseHeaders,
@@ -6851,6 +6837,12 @@ async function sendReplayRequest({
6851
6837
  }
6852
6838
  */
6853
6839
 
6840
+ // Prevent this data (which, if it exists, was used in earlier steps in the processing pipeline) from being sent to
6841
+ // sentry. (Note: Our use of this property comes and goes with whatever we might be debugging, whatever hacks we may
6842
+ // have temporarily added, etc. Even if we don't happen to be using it at some point in the future, let's not get rid
6843
+ // of this `delete`, lest we miss putting it back in the next time the property is in use.)
6844
+ delete replayEvent.sdkProcessingMetadata;
6845
+
6854
6846
  const envelope = createReplayEnvelope(replayEvent, preparedRecordingData, dsn, client.getOptions().tunnel);
6855
6847
 
6856
6848
  let response;
@@ -7124,7 +7116,6 @@ class ReplayContainer {
7124
7116
  timeout: slowClickTimeout,
7125
7117
  scrollTimeout: SLOW_CLICK_SCROLL_TIMEOUT,
7126
7118
  ignoreSelector: slowClickIgnoreSelectors ? slowClickIgnoreSelectors.join(',') : '',
7127
- multiClickTimeout: MULTI_CLICK_TIMEOUT,
7128
7119
  }
7129
7120
  : undefined;
7130
7121
 
@@ -8264,6 +8255,7 @@ class Replay {
8264
8255
  slowClickIgnoreSelectors = [],
8265
8256
 
8266
8257
  networkDetailAllowUrls = [],
8258
+ networkDetailDenyUrls = [],
8267
8259
  networkCaptureBodies = true,
8268
8260
  networkRequestHeaders = [],
8269
8261
  networkResponseHeaders = [],
@@ -8335,6 +8327,7 @@ class Replay {
8335
8327
  slowClickTimeout,
8336
8328
  slowClickIgnoreSelectors,
8337
8329
  networkDetailAllowUrls,
8330
+ networkDetailDenyUrls,
8338
8331
  networkCaptureBodies,
8339
8332
  networkRequestHeaders: _getMergedNetworkHeaders(networkRequestHeaders),
8340
8333
  networkResponseHeaders: _getMergedNetworkHeaders(networkResponseHeaders),