@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/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { getCurrentHub, getClient, isSentryRequestUrl, addEventProcessor, prepareEvent, setContext, captureException } from '@sentry/core';
1
+ import { addBreadcrumb, getClient, isSentryRequestUrl, getCurrentScope, addEventProcessor, prepareEvent, setContext, captureException } from '@sentry/core';
2
2
  import { GLOBAL_OBJ, normalize, fill, htmlTreeAsString, browserPerformanceTimeOrigin, logger, uuid4, SENTRY_XHR_DATA_KEY, dropUndefinedKeys, stringMatchesSomePattern, addFetchInstrumentationHandler, addXhrInstrumentationHandler, addClickKeypressInstrumentationHandler, addHistoryInstrumentationHandler, createEnvelope, createEventEnvelopeHeaders, getSdkMetadataForEnvelopeHeader, updateRateLimits, isRateLimited, consoleSandbox, isBrowser } from '@sentry/utils';
3
3
  import { addPerformanceInstrumentationHandler, addLcpInstrumentationHandler } from '@sentry-internal/tracing';
4
4
 
@@ -3442,6 +3442,7 @@ function wrapEvent(e) {
3442
3442
  eWithTime.timestamp = nowTimestamp();
3443
3443
  return eWithTime;
3444
3444
  }
3445
+ let _wrappedEmit;
3445
3446
  let _takeFullSnapshot;
3446
3447
  const mirror = createMirror();
3447
3448
  function record(options = {}) {
@@ -3562,6 +3563,7 @@ function record(options = {}) {
3562
3563
  }
3563
3564
  }
3564
3565
  };
3566
+ _wrappedEmit = wrappedEmit;
3565
3567
  const wrappedMutationEmit = (m) => {
3566
3568
  wrappedEmit(wrapEvent({
3567
3569
  type: EventType.IncrementalSnapshot,
@@ -3602,16 +3604,14 @@ function record(options = {}) {
3602
3604
  });
3603
3605
  }
3604
3606
  const processedNodeManager = new ProcessedNodeManager();
3605
- const canvasManager = getCanvasManager
3606
- ? getCanvasManager({
3607
- recordCanvas,
3608
- blockClass,
3609
- blockSelector,
3610
- unblockSelector,
3611
- sampling: sampling['canvas'],
3612
- dataURLOptions,
3613
- })
3614
- : new CanvasManagerNoop();
3607
+ const canvasManager = _getCanvasManager(getCanvasManager, {
3608
+ recordCanvas,
3609
+ blockClass,
3610
+ blockSelector,
3611
+ unblockSelector,
3612
+ sampling: sampling['canvas'],
3613
+ dataURLOptions,
3614
+ });
3615
3615
  const shadowDomManager = typeof __RRWEB_EXCLUDE_SHADOW_DOM__ === 'boolean' &&
3616
3616
  __RRWEB_EXCLUDE_SHADOW_DOM__
3617
3617
  ? new ShadowDomManagerNoop()
@@ -3863,8 +3863,22 @@ function takeFullSnapshot(isCheckout) {
3863
3863
  }
3864
3864
  _takeFullSnapshot(isCheckout);
3865
3865
  }
3866
+ function wrappedEmit(e) {
3867
+ if (!_wrappedEmit) {
3868
+ return;
3869
+ }
3870
+ _wrappedEmit(e);
3871
+ }
3866
3872
  record.mirror = mirror;
3867
3873
  record.takeFullSnapshot = takeFullSnapshot;
3874
+ function _getCanvasManager(getCanvasManagerFn, options) {
3875
+ return getCanvasManagerFn
3876
+ ? getCanvasManagerFn(Object.assign(Object.assign({}, options), { mirror, win: window, mutationCb: (p) => wrappedEmit(wrapEvent({
3877
+ type: EventType.IncrementalSnapshot,
3878
+ data: Object.assign({ source: IncrementalSource.CanvasMutation }, p),
3879
+ })) }))
3880
+ : new CanvasManagerNoop();
3881
+ }
3868
3882
 
3869
3883
  const ReplayEventTypeIncrementalSnapshot = 3;
3870
3884
  const ReplayEventTypeCustom = 5;
@@ -4723,7 +4737,7 @@ function logInfo(message, shouldAddBreadcrumb) {
4723
4737
  logger.info(message);
4724
4738
 
4725
4739
  if (shouldAddBreadcrumb) {
4726
- addBreadcrumb(message);
4740
+ addLogBreadcrumb(message);
4727
4741
  }
4728
4742
  }
4729
4743
 
@@ -4742,14 +4756,13 @@ function logInfoNextTick(message, shouldAddBreadcrumb) {
4742
4756
  // Wait a tick here to avoid race conditions for some initial logs
4743
4757
  // which may be added before replay is initialized
4744
4758
  setTimeout(() => {
4745
- addBreadcrumb(message);
4759
+ addLogBreadcrumb(message);
4746
4760
  }, 0);
4747
4761
  }
4748
4762
  }
4749
4763
 
4750
- function addBreadcrumb(message) {
4751
- const hub = getCurrentHub();
4752
- hub.addBreadcrumb(
4764
+ function addLogBreadcrumb(message) {
4765
+ addBreadcrumb(
4753
4766
  {
4754
4767
  category: 'console',
4755
4768
  data: {
@@ -5929,7 +5942,7 @@ function shouldFilterRequest(replay, url) {
5929
5942
  return false;
5930
5943
  }
5931
5944
 
5932
- return isSentryRequestUrl(url, getCurrentHub());
5945
+ return isSentryRequestUrl(url, getClient());
5933
5946
  }
5934
5947
 
5935
5948
  /** Add a performance entry breadcrumb */
@@ -7007,7 +7020,7 @@ function normalizeConsoleBreadcrumb(
7007
7020
  */
7008
7021
  function addGlobalListeners(replay) {
7009
7022
  // Listeners from core SDK //
7010
- const scope = getCurrentHub().getScope();
7023
+ const scope = getCurrentScope();
7011
7024
  const client = getClient();
7012
7025
 
7013
7026
  scope.addScopeListener(handleScopeListener(replay));
@@ -7440,9 +7453,8 @@ async function sendReplayRequest({
7440
7453
 
7441
7454
  const { urls, errorIds, traceIds, initialTimestamp } = eventContext;
7442
7455
 
7443
- const hub = getCurrentHub();
7444
- const client = hub.getClient();
7445
- const scope = hub.getScope();
7456
+ const client = getClient();
7457
+ const scope = getCurrentScope();
7446
7458
  const transport = client && client.getTransport();
7447
7459
  const dsn = client && client.getDsn();
7448
7460
 
@@ -7946,7 +7958,10 @@ class ReplayContainer {
7946
7958
  ...(canvas && {
7947
7959
  recordCanvas: true,
7948
7960
  sampling: { canvas: canvas.fps || 4 },
7949
- dataURLOptions: { quality: canvas.quality || 0.6 },
7961
+ dataURLOptions: {
7962
+ type: canvas.type || 'image/webp',
7963
+ quality: canvas.quality || 0.6,
7964
+ },
7950
7965
  getCanvasManager: canvas.manager,
7951
7966
  }),
7952
7967
  });
@@ -8301,7 +8316,7 @@ class ReplayContainer {
8301
8316
  * This is only available if performance is enabled, and if an instrumented router is used.
8302
8317
  */
8303
8318
  getCurrentRoute() {
8304
- const lastTransaction = this.lastTransaction || getCurrentHub().getScope().getTransaction();
8319
+ const lastTransaction = this.lastTransaction || getCurrentScope().getTransaction();
8305
8320
  if (!lastTransaction || !['route', 'custom'].includes(lastTransaction.metadata.source)) {
8306
8321
  return undefined;
8307
8322
  }