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