@sentry/replay 7.76.0 → 7.77.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
@@ -5764,18 +5764,19 @@ class EventBufferProxy {
5764
5764
  /**
5765
5765
  * Create an event buffer for replays.
5766
5766
  */
5767
- function createEventBuffer({ useCompression }) {
5768
- // eslint-disable-next-line no-restricted-globals
5769
- if (useCompression && window.Worker) {
5770
- try {
5771
- const workerUrl = e();
5767
+ function createEventBuffer({
5768
+ useCompression,
5769
+ workerUrl: customWorkerUrl,
5770
+ }) {
5771
+ if (
5772
+ useCompression &&
5773
+ // eslint-disable-next-line no-restricted-globals
5774
+ window.Worker
5775
+ ) {
5776
+ const worker = _loadWorker(customWorkerUrl);
5772
5777
 
5773
- logInfo('[Replay] Using compression worker');
5774
- const worker = new Worker(workerUrl);
5775
- return new EventBufferProxy(worker);
5776
- } catch (error) {
5777
- logInfo('[Replay] Failed to create compression worker');
5778
- // Fall back to use simple event buffer array
5778
+ if (worker) {
5779
+ return worker;
5779
5780
  }
5780
5781
  }
5781
5782
 
@@ -5783,6 +5784,31 @@ function createEventBuffer({ useCompression }) {
5783
5784
  return new EventBufferArray();
5784
5785
  }
5785
5786
 
5787
+ function _loadWorker(customWorkerUrl) {
5788
+ try {
5789
+ const workerUrl = customWorkerUrl || _getWorkerUrl();
5790
+
5791
+ if (!workerUrl) {
5792
+ return;
5793
+ }
5794
+
5795
+ logInfo(`[Replay] Using compression worker${customWorkerUrl ? ` from ${customWorkerUrl}` : ''}`);
5796
+ const worker = new Worker(workerUrl);
5797
+ return new EventBufferProxy(worker);
5798
+ } catch (error) {
5799
+ logInfo('[Replay] Failed to create compression worker');
5800
+ // Fall back to use simple event buffer array
5801
+ }
5802
+ }
5803
+
5804
+ function _getWorkerUrl() {
5805
+ if (typeof __SENTRY_EXCLUDE_REPLAY_WORKER__ === 'undefined' || !__SENTRY_EXCLUDE_REPLAY_WORKER__) {
5806
+ return e();
5807
+ }
5808
+
5809
+ return '';
5810
+ }
5811
+
5786
5812
  /** If sessionStorage is available. */
5787
5813
  function hasSessionStorage() {
5788
5814
  try {
@@ -6252,14 +6278,7 @@ function isRrwebError(event, hint) {
6252
6278
  return true;
6253
6279
  }
6254
6280
 
6255
- // Check if any exception originates from rrweb
6256
- return event.exception.values.some(exception => {
6257
- if (!exception.stacktrace || !exception.stacktrace.frames || !exception.stacktrace.frames.length) {
6258
- return false;
6259
- }
6260
-
6261
- return exception.stacktrace.frames.some(frame => frame.filename && frame.filename.includes('/rrweb/src/'));
6262
- });
6281
+ return false;
6263
6282
  }
6264
6283
 
6265
6284
  /**
@@ -7397,7 +7416,7 @@ async function captureXhrBreadcrumbToReplay(
7397
7416
  const result = makeNetworkReplayBreadcrumb('resource.xhr', data);
7398
7417
  addNetworkBreadcrumb(options.replay, result);
7399
7418
  } catch (error) {
7400
- (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.error('[Replay] Failed to capture fetch breadcrumb', error);
7419
+ (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.error('[Replay] Failed to capture xhr breadcrumb', error);
7401
7420
  }
7402
7421
  }
7403
7422
 
@@ -8983,6 +9002,7 @@ class ReplayContainer {
8983
9002
 
8984
9003
  this.eventBuffer = createEventBuffer({
8985
9004
  useCompression: this._options.useCompression,
9005
+ workerUrl: this._options.workerUrl,
8986
9006
  });
8987
9007
 
8988
9008
  this._removeListeners();
@@ -9213,19 +9233,6 @@ class ReplayContainer {
9213
9233
  }
9214
9234
  }
9215
9235
 
9216
- /**
9217
- * Trigger rrweb to take a full snapshot which will cause this plugin to
9218
- * create a new Replay event.
9219
- */
9220
- _triggerFullSnapshot(checkout = true) {
9221
- try {
9222
- logInfo('[Replay] Taking full rrweb snapshot');
9223
- record.takeFullSnapshot(checkout);
9224
- } catch (err) {
9225
- this._handleException(err);
9226
- }
9227
- }
9228
-
9229
9236
  /**
9230
9237
  * Update user activity (across session lifespans)
9231
9238
  */
@@ -9419,7 +9426,7 @@ class ReplayContainer {
9419
9426
  }
9420
9427
 
9421
9428
  if (!this.session) {
9422
- (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.error('[Replay] No session found to flush.');
9429
+ // should never happen, as we would have bailed out before
9423
9430
  return;
9424
9431
  }
9425
9432
 
@@ -9674,6 +9681,7 @@ class Replay {
9674
9681
  maxReplayDuration = MAX_REPLAY_DURATION,
9675
9682
  stickySession = true,
9676
9683
  useCompression = true,
9684
+ workerUrl,
9677
9685
  _experiments = {},
9678
9686
  sessionSampleRate,
9679
9687
  errorSampleRate,
@@ -9776,6 +9784,7 @@ class Replay {
9776
9784
  sessionSampleRate,
9777
9785
  errorSampleRate,
9778
9786
  useCompression,
9787
+ workerUrl,
9779
9788
  blockAllMedia,
9780
9789
  maskAllInputs,
9781
9790
  maskAllText,