@sentry/replay 7.87.0 → 7.89.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
@@ -3444,6 +3444,7 @@ function wrapEvent(e) {
3444
3444
  eWithTime.timestamp = nowTimestamp();
3445
3445
  return eWithTime;
3446
3446
  }
3447
+ let _wrappedEmit;
3447
3448
  let _takeFullSnapshot;
3448
3449
  const mirror = createMirror();
3449
3450
  function record(options = {}) {
@@ -3564,6 +3565,7 @@ function record(options = {}) {
3564
3565
  }
3565
3566
  }
3566
3567
  };
3568
+ _wrappedEmit = wrappedEmit;
3567
3569
  const wrappedMutationEmit = (m) => {
3568
3570
  wrappedEmit(wrapEvent({
3569
3571
  type: EventType.IncrementalSnapshot,
@@ -3604,16 +3606,14 @@ function record(options = {}) {
3604
3606
  });
3605
3607
  }
3606
3608
  const processedNodeManager = new ProcessedNodeManager();
3607
- const canvasManager = getCanvasManager
3608
- ? getCanvasManager({
3609
- recordCanvas,
3610
- blockClass,
3611
- blockSelector,
3612
- unblockSelector,
3613
- sampling: sampling['canvas'],
3614
- dataURLOptions,
3615
- })
3616
- : new CanvasManagerNoop();
3609
+ const canvasManager = _getCanvasManager(getCanvasManager, {
3610
+ recordCanvas,
3611
+ blockClass,
3612
+ blockSelector,
3613
+ unblockSelector,
3614
+ sampling: sampling['canvas'],
3615
+ dataURLOptions,
3616
+ });
3617
3617
  const shadowDomManager = typeof __RRWEB_EXCLUDE_SHADOW_DOM__ === 'boolean' &&
3618
3618
  __RRWEB_EXCLUDE_SHADOW_DOM__
3619
3619
  ? new ShadowDomManagerNoop()
@@ -3865,8 +3865,22 @@ function takeFullSnapshot(isCheckout) {
3865
3865
  }
3866
3866
  _takeFullSnapshot(isCheckout);
3867
3867
  }
3868
+ function wrappedEmit(e) {
3869
+ if (!_wrappedEmit) {
3870
+ return;
3871
+ }
3872
+ _wrappedEmit(e);
3873
+ }
3868
3874
  record.mirror = mirror;
3869
3875
  record.takeFullSnapshot = takeFullSnapshot;
3876
+ function _getCanvasManager(getCanvasManagerFn, options) {
3877
+ return getCanvasManagerFn
3878
+ ? getCanvasManagerFn(Object.assign(Object.assign({}, options), { mirror, win: window, mutationCb: (p) => wrappedEmit(wrapEvent({
3879
+ type: EventType.IncrementalSnapshot,
3880
+ data: Object.assign({ source: IncrementalSource.CanvasMutation }, p),
3881
+ })) }))
3882
+ : new CanvasManagerNoop();
3883
+ }
3870
3884
 
3871
3885
  const ReplayEventTypeIncrementalSnapshot = 3;
3872
3886
  const ReplayEventTypeCustom = 5;
@@ -4725,7 +4739,7 @@ function logInfo(message, shouldAddBreadcrumb) {
4725
4739
  utils.logger.info(message);
4726
4740
 
4727
4741
  if (shouldAddBreadcrumb) {
4728
- addBreadcrumb(message);
4742
+ addLogBreadcrumb(message);
4729
4743
  }
4730
4744
  }
4731
4745
 
@@ -4744,14 +4758,13 @@ function logInfoNextTick(message, shouldAddBreadcrumb) {
4744
4758
  // Wait a tick here to avoid race conditions for some initial logs
4745
4759
  // which may be added before replay is initialized
4746
4760
  setTimeout(() => {
4747
- addBreadcrumb(message);
4761
+ addLogBreadcrumb(message);
4748
4762
  }, 0);
4749
4763
  }
4750
4764
  }
4751
4765
 
4752
- function addBreadcrumb(message) {
4753
- const hub = core.getCurrentHub();
4754
- hub.addBreadcrumb(
4766
+ function addLogBreadcrumb(message) {
4767
+ core.addBreadcrumb(
4755
4768
  {
4756
4769
  category: 'console',
4757
4770
  data: {
@@ -5931,7 +5944,7 @@ function shouldFilterRequest(replay, url) {
5931
5944
  return false;
5932
5945
  }
5933
5946
 
5934
- return core.isSentryRequestUrl(url, core.getCurrentHub());
5947
+ return core.isSentryRequestUrl(url, core.getClient());
5935
5948
  }
5936
5949
 
5937
5950
  /** Add a performance entry breadcrumb */
@@ -7009,7 +7022,7 @@ function normalizeConsoleBreadcrumb(
7009
7022
  */
7010
7023
  function addGlobalListeners(replay) {
7011
7024
  // Listeners from core SDK //
7012
- const scope = core.getCurrentHub().getScope();
7025
+ const scope = core.getCurrentScope();
7013
7026
  const client = core.getClient();
7014
7027
 
7015
7028
  scope.addScopeListener(handleScopeListener(replay));
@@ -7442,9 +7455,8 @@ async function sendReplayRequest({
7442
7455
 
7443
7456
  const { urls, errorIds, traceIds, initialTimestamp } = eventContext;
7444
7457
 
7445
- const hub = core.getCurrentHub();
7446
- const client = hub.getClient();
7447
- const scope = hub.getScope();
7458
+ const client = core.getClient();
7459
+ const scope = core.getCurrentScope();
7448
7460
  const transport = client && client.getTransport();
7449
7461
  const dsn = client && client.getDsn();
7450
7462
 
@@ -7948,7 +7960,10 @@ class ReplayContainer {
7948
7960
  ...(canvas && {
7949
7961
  recordCanvas: true,
7950
7962
  sampling: { canvas: canvas.fps || 4 },
7951
- dataURLOptions: { quality: canvas.quality || 0.6 },
7963
+ dataURLOptions: {
7964
+ type: canvas.type || 'image/webp',
7965
+ quality: canvas.quality || 0.6,
7966
+ },
7952
7967
  getCanvasManager: canvas.manager,
7953
7968
  }),
7954
7969
  });
@@ -8303,7 +8318,7 @@ class ReplayContainer {
8303
8318
  * This is only available if performance is enabled, and if an instrumented router is used.
8304
8319
  */
8305
8320
  getCurrentRoute() {
8306
- const lastTransaction = this.lastTransaction || core.getCurrentHub().getScope().getTransaction();
8321
+ const lastTransaction = this.lastTransaction || core.getCurrentScope().getTransaction();
8307
8322
  if (!lastTransaction || !['route', 'custom'].includes(lastTransaction.metadata.source)) {
8308
8323
  return undefined;
8309
8324
  }