@sentry/replay 7.92.0 → 7.94.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
@@ -1,3 +1,8 @@
1
+ var {
2
+ _nullishCoalesce,
3
+ _optionalChain
4
+ } = require('@sentry/utils');
5
+
1
6
  Object.defineProperty(exports, '__esModule', { value: true });
2
7
 
3
8
  const core = require('@sentry/core');
@@ -54,37 +59,7 @@ const MIN_REPLAY_DURATION_LIMIT = 15000;
54
59
  /** The max. length of a replay. */
55
60
  const MAX_REPLAY_DURATION = 3600000; // 60 minutes in ms;
56
61
 
57
- const CANVAS_QUALITY = {
58
- low: {
59
- sampling: {
60
- canvas: 1,
61
- },
62
- dataURLOptions: {
63
- type: 'image/webp',
64
- quality: 0.25,
65
- },
66
- },
67
- medium: {
68
- sampling: {
69
- canvas: 2,
70
- },
71
- dataURLOptions: {
72
- type: 'image/webp',
73
- quality: 0.4,
74
- },
75
- },
76
- high: {
77
- sampling: {
78
- canvas: 4,
79
- },
80
- dataURLOptions: {
81
- type: 'image/webp',
82
- quality: 0.5,
83
- },
84
- },
85
- };
86
-
87
- var NodeType$1;
62
+ function _nullishCoalesce$1(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }function _optionalChain$5(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var NodeType$1;
88
63
  (function (NodeType) {
89
64
  NodeType[NodeType["Document"] = 0] = "Document";
90
65
  NodeType[NodeType["DocumentType"] = 1] = "DocumentType";
@@ -98,8 +73,8 @@ function isElement$1(n) {
98
73
  return n.nodeType === n.ELEMENT_NODE;
99
74
  }
100
75
  function isShadowRoot(n) {
101
- const host = n === null || n === void 0 ? void 0 : n.host;
102
- return Boolean((host === null || host === void 0 ? void 0 : host.shadowRoot) === n);
76
+ const host = _optionalChain$5([n, 'optionalAccess', _ => _.host]);
77
+ return Boolean(_optionalChain$5([host, 'optionalAccess', _2 => _2.shadowRoot]) === n);
103
78
  }
104
79
  function isNativeShadowDom(shadowRoot) {
105
80
  return Object.prototype.toString.call(shadowRoot) === '[object ShadowRoot]';
@@ -173,11 +148,10 @@ class Mirror {
173
148
  this.nodeMetaMap = new WeakMap();
174
149
  }
175
150
  getId(n) {
176
- var _a;
177
151
  if (!n)
178
152
  return -1;
179
- const id = (_a = this.getMeta(n)) === null || _a === void 0 ? void 0 : _a.id;
180
- return id !== null && id !== void 0 ? id : -1;
153
+ const id = _optionalChain$5([this, 'access', _3 => _3.getMeta, 'call', _4 => _4(n), 'optionalAccess', _5 => _5.id]);
154
+ return _nullishCoalesce$1(id, () => ( -1));
181
155
  }
182
156
  getNode(id) {
183
157
  return this.idNodeMap.get(id) || null;
@@ -508,18 +482,23 @@ function createMatchPredicate(className, selector) {
508
482
  const el = node;
509
483
  if (el === null)
510
484
  return false;
511
- if (className) {
512
- if (typeof className === 'string') {
513
- if (el.matches(`.${className}`))
485
+ try {
486
+ if (className) {
487
+ if (typeof className === 'string') {
488
+ if (el.matches(`.${className}`))
489
+ return true;
490
+ }
491
+ else if (elementClassMatchesRegex(el, className)) {
514
492
  return true;
493
+ }
515
494
  }
516
- else if (elementClassMatchesRegex(el, className)) {
495
+ if (selector && el.matches(selector))
517
496
  return true;
518
- }
497
+ return false;
498
+ }
499
+ catch (e2) {
500
+ return false;
519
501
  }
520
- if (selector && el.matches(selector))
521
- return true;
522
- return false;
523
502
  };
524
503
  }
525
504
  function needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextClass, unmaskTextSelector, maskAllText) {
@@ -699,7 +678,6 @@ function getRootId(doc, mirror) {
699
678
  return docId === 1 ? undefined : docId;
700
679
  }
701
680
  function serializeTextNode(n, options) {
702
- var _a;
703
681
  const { maskAllText, maskTextClass, unmaskTextClass, maskTextSelector, unmaskTextSelector, maskTextFn, maskInputOptions, maskInputFn, rootId, } = options;
704
682
  const parentTagName = n.parentNode && n.parentNode.tagName;
705
683
  let textContent = n.textContent;
@@ -710,7 +688,7 @@ function serializeTextNode(n, options) {
710
688
  try {
711
689
  if (n.nextSibling || n.previousSibling) {
712
690
  }
713
- else if ((_a = n.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {
691
+ else if (_optionalChain$5([n, 'access', _6 => _6.parentNode, 'access', _7 => _7.sheet, 'optionalAccess', _8 => _8.cssRules])) {
714
692
  textContent = stringifyStylesheet(n.parentNode.sheet);
715
693
  }
716
694
  }
@@ -1263,6 +1241,7 @@ function snapshot(n, options) {
1263
1241
  });
1264
1242
  }
1265
1243
 
1244
+ function _optionalChain$4(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
1266
1245
  function on(type, fn, target = document) {
1267
1246
  const options = { capture: true, passive: true };
1268
1247
  target.addEventListener(type, fn, options);
@@ -1369,7 +1348,7 @@ function patch(source, name, replacement) {
1369
1348
  source[name] = original;
1370
1349
  };
1371
1350
  }
1372
- catch (_a) {
1351
+ catch (e2) {
1373
1352
  return () => {
1374
1353
  };
1375
1354
  }
@@ -1379,24 +1358,23 @@ if (!(/[1-9][0-9]{12}/.test(Date.now().toString()))) {
1379
1358
  nowTimestamp = () => new Date().getTime();
1380
1359
  }
1381
1360
  function getWindowScroll(win) {
1382
- var _a, _b, _c, _d, _e, _f;
1383
1361
  const doc = win.document;
1384
1362
  return {
1385
1363
  left: doc.scrollingElement
1386
1364
  ? doc.scrollingElement.scrollLeft
1387
1365
  : win.pageXOffset !== undefined
1388
1366
  ? win.pageXOffset
1389
- : (doc === null || doc === void 0 ? void 0 : doc.documentElement.scrollLeft) ||
1390
- ((_b = (_a = doc === null || doc === void 0 ? void 0 : doc.body) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.scrollLeft) ||
1391
- ((_c = doc === null || doc === void 0 ? void 0 : doc.body) === null || _c === void 0 ? void 0 : _c.scrollLeft) ||
1367
+ : _optionalChain$4([doc, 'optionalAccess', _ => _.documentElement, 'access', _2 => _2.scrollLeft]) ||
1368
+ _optionalChain$4([doc, 'optionalAccess', _3 => _3.body, 'optionalAccess', _4 => _4.parentElement, 'optionalAccess', _5 => _5.scrollLeft]) ||
1369
+ _optionalChain$4([doc, 'optionalAccess', _6 => _6.body, 'optionalAccess', _7 => _7.scrollLeft]) ||
1392
1370
  0,
1393
1371
  top: doc.scrollingElement
1394
1372
  ? doc.scrollingElement.scrollTop
1395
1373
  : win.pageYOffset !== undefined
1396
1374
  ? win.pageYOffset
1397
- : (doc === null || doc === void 0 ? void 0 : doc.documentElement.scrollTop) ||
1398
- ((_e = (_d = doc === null || doc === void 0 ? void 0 : doc.body) === null || _d === void 0 ? void 0 : _d.parentElement) === null || _e === void 0 ? void 0 : _e.scrollTop) ||
1399
- ((_f = doc === null || doc === void 0 ? void 0 : doc.body) === null || _f === void 0 ? void 0 : _f.scrollTop) ||
1375
+ : _optionalChain$4([doc, 'optionalAccess', _8 => _8.documentElement, 'access', _9 => _9.scrollTop]) ||
1376
+ _optionalChain$4([doc, 'optionalAccess', _10 => _10.body, 'optionalAccess', _11 => _11.parentElement, 'optionalAccess', _12 => _12.scrollTop]) ||
1377
+ _optionalChain$4([doc, 'optionalAccess', _13 => _13.body, 'optionalAccess', _14 => _14.scrollTop]) ||
1400
1378
  0,
1401
1379
  };
1402
1380
  }
@@ -1498,7 +1476,7 @@ function isSerializedStylesheet(n, mirror) {
1498
1476
  mirror.getMeta(n));
1499
1477
  }
1500
1478
  function hasShadowRoot(n) {
1501
- return Boolean(n === null || n === void 0 ? void 0 : n.shadowRoot);
1479
+ return Boolean(_optionalChain$4([n, 'optionalAccess', _18 => _18.shadowRoot]));
1502
1480
  }
1503
1481
  class StyleSheetMirror {
1504
1482
  constructor() {
@@ -1507,8 +1485,7 @@ class StyleSheetMirror {
1507
1485
  this.idStyleMap = new Map();
1508
1486
  }
1509
1487
  getId(stylesheet) {
1510
- var _a;
1511
- return (_a = this.styleIDMap.get(stylesheet)) !== null && _a !== void 0 ? _a : -1;
1488
+ return _nullishCoalesce(this.styleIDMap.get(stylesheet), () => ( -1));
1512
1489
  }
1513
1490
  has(stylesheet) {
1514
1491
  return this.styleIDMap.has(stylesheet);
@@ -1539,9 +1516,8 @@ class StyleSheetMirror {
1539
1516
  }
1540
1517
  }
1541
1518
  function getShadowHost(n) {
1542
- var _a, _b;
1543
1519
  let shadowHost = null;
1544
- if (((_b = (_a = n.getRootNode) === null || _a === void 0 ? void 0 : _a.call(n)) === null || _b === void 0 ? void 0 : _b.nodeType) === Node.DOCUMENT_FRAGMENT_NODE &&
1520
+ if (_optionalChain$4([n, 'access', _19 => _19.getRootNode, 'optionalCall', _20 => _20(), 'optionalAccess', _21 => _21.nodeType]) === Node.DOCUMENT_FRAGMENT_NODE &&
1545
1521
  n.getRootNode().host)
1546
1522
  shadowHost = n.getRootNode().host;
1547
1523
  return shadowHost;
@@ -1566,6 +1542,34 @@ function inDom(n) {
1566
1542
  return false;
1567
1543
  return doc.contains(n) || shadowHostInDom(n);
1568
1544
  }
1545
+ let cachedRequestAnimationFrameImplementation;
1546
+ function getRequestAnimationFrameImplementation() {
1547
+ if (cachedRequestAnimationFrameImplementation) {
1548
+ return cachedRequestAnimationFrameImplementation;
1549
+ }
1550
+ const document = window.document;
1551
+ let requestAnimationFrameImplementation = window.requestAnimationFrame;
1552
+ if (document && typeof document.createElement === 'function') {
1553
+ try {
1554
+ const sandbox = document.createElement('iframe');
1555
+ sandbox.hidden = true;
1556
+ document.head.appendChild(sandbox);
1557
+ const contentWindow = sandbox.contentWindow;
1558
+ if (contentWindow && contentWindow.requestAnimationFrame) {
1559
+ requestAnimationFrameImplementation =
1560
+ contentWindow.requestAnimationFrame;
1561
+ }
1562
+ document.head.removeChild(sandbox);
1563
+ }
1564
+ catch (e) {
1565
+ }
1566
+ }
1567
+ return (cachedRequestAnimationFrameImplementation =
1568
+ requestAnimationFrameImplementation.bind(window));
1569
+ }
1570
+ function onRequestAnimationFrame(...rest) {
1571
+ return getRequestAnimationFrameImplementation()(...rest);
1572
+ }
1569
1573
 
1570
1574
  var EventType = /* @__PURE__ */ ((EventType2) => {
1571
1575
  EventType2[EventType2["DomContentLoaded"] = 0] = "DomContentLoaded";
@@ -1618,6 +1622,7 @@ var PointerTypes = /* @__PURE__ */ ((PointerTypes2) => {
1618
1622
  return PointerTypes2;
1619
1623
  })(PointerTypes || {});
1620
1624
 
1625
+ function _optionalChain$3(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
1621
1626
  function isNodeInLinkedList(n) {
1622
1627
  return '__ln' in n;
1623
1628
  }
@@ -1633,7 +1638,7 @@ class DoubleLinkedList {
1633
1638
  }
1634
1639
  let current = this.head;
1635
1640
  for (let index = 0; index < position; index++) {
1636
- current = (current === null || current === void 0 ? void 0 : current.next) || null;
1641
+ current = _optionalChain$3([current, 'optionalAccess', _ => _.next]) || null;
1637
1642
  }
1638
1643
  return current;
1639
1644
  }
@@ -2220,6 +2225,7 @@ const callbackWrapper = (cb) => {
2220
2225
  return rrwebWrapped;
2221
2226
  };
2222
2227
 
2228
+ function _optionalChain$2(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2223
2229
  const mutationBuffers = [];
2224
2230
  function getEventTarget(event) {
2225
2231
  try {
@@ -2233,18 +2239,17 @@ function getEventTarget(event) {
2233
2239
  return event.path[0];
2234
2240
  }
2235
2241
  }
2236
- catch (_a) {
2242
+ catch (e2) {
2237
2243
  }
2238
2244
  return event && event.target;
2239
2245
  }
2240
2246
  function initMutationObserver(options, rootEl) {
2241
- var _a, _b;
2242
2247
  const mutationBuffer = new MutationBuffer();
2243
2248
  mutationBuffers.push(mutationBuffer);
2244
2249
  mutationBuffer.init(options);
2245
2250
  let mutationObserverCtor = window.MutationObserver ||
2246
2251
  window.__rrMutationObserver;
2247
- const angularZoneSymbol = (_b = (_a = window === null || window === void 0 ? void 0 : window.Zone) === null || _a === void 0 ? void 0 : _a.__symbol__) === null || _b === void 0 ? void 0 : _b.call(_a, 'MutationObserver');
2252
+ const angularZoneSymbol = _optionalChain$2([window, 'optionalAccess', _ => _.Zone, 'optionalAccess', _2 => _2.__symbol__, 'optionalCall', _3 => _3('MutationObserver')]);
2248
2253
  if (angularZoneSymbol &&
2249
2254
  window[angularZoneSymbol]) {
2250
2255
  mutationObserverCtor = window[angularZoneSymbol];
@@ -2379,7 +2384,13 @@ function initMouseInteractionObserver({ mouseInteractionCb, doc, mirror, blockCl
2379
2384
  }
2380
2385
  const id = mirror.getId(target);
2381
2386
  const { clientX, clientY } = e;
2382
- callbackWrapper(mouseInteractionCb)(Object.assign({ type: MouseInteractions[thisEventKey], id, x: clientX, y: clientY }, (pointerType !== null && { pointerType })));
2387
+ callbackWrapper(mouseInteractionCb)({
2388
+ type: MouseInteractions[thisEventKey],
2389
+ id,
2390
+ x: clientX,
2391
+ y: clientY,
2392
+ ...(pointerType !== null && { pointerType }),
2393
+ });
2383
2394
  };
2384
2395
  };
2385
2396
  Object.keys(MouseInteractions)
@@ -2516,7 +2527,10 @@ function initInputObserver({ inputCb, doc, mirror, blockClass, blockSelector, un
2516
2527
  lastInputValue.isChecked !== v.isChecked) {
2517
2528
  lastInputValueMap.set(target, v);
2518
2529
  const id = mirror.getId(target);
2519
- callbackWrapper(inputCb)(Object.assign(Object.assign({}, v), { id }));
2530
+ callbackWrapper(inputCb)({
2531
+ ...v,
2532
+ id,
2533
+ });
2520
2534
  }
2521
2535
  }
2522
2536
  const events = sampling.input === 'last' ? ['change'] : ['input', 'change'];
@@ -2730,17 +2744,16 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror, stylesheetManager },
2730
2744
  });
2731
2745
  }
2732
2746
  function initAdoptedStyleSheetObserver({ mirror, stylesheetManager, }, host) {
2733
- var _a, _b, _c;
2734
2747
  let hostId = null;
2735
2748
  if (host.nodeName === '#document')
2736
2749
  hostId = mirror.getId(host);
2737
2750
  else
2738
2751
  hostId = mirror.getId(host.host);
2739
2752
  const patchTarget = host.nodeName === '#document'
2740
- ? (_a = host.defaultView) === null || _a === void 0 ? void 0 : _a.Document
2741
- : (_c = (_b = host.ownerDocument) === null || _b === void 0 ? void 0 : _b.defaultView) === null || _c === void 0 ? void 0 : _c.ShadowRoot;
2742
- const originalPropertyDescriptor = (patchTarget === null || patchTarget === void 0 ? void 0 : patchTarget.prototype)
2743
- ? Object.getOwnPropertyDescriptor(patchTarget === null || patchTarget === void 0 ? void 0 : patchTarget.prototype, 'adoptedStyleSheets')
2753
+ ? _optionalChain$2([host, 'access', _4 => _4.defaultView, 'optionalAccess', _5 => _5.Document])
2754
+ : _optionalChain$2([host, 'access', _6 => _6.ownerDocument, 'optionalAccess', _7 => _7.defaultView, 'optionalAccess', _8 => _8.ShadowRoot]);
2755
+ const originalPropertyDescriptor = _optionalChain$2([patchTarget, 'optionalAccess', _9 => _9.prototype])
2756
+ ? Object.getOwnPropertyDescriptor(_optionalChain$2([patchTarget, 'optionalAccess', _10 => _10.prototype]), 'adoptedStyleSheets')
2744
2757
  : undefined;
2745
2758
  if (hostId === null ||
2746
2759
  hostId === -1 ||
@@ -2752,12 +2765,10 @@ function initAdoptedStyleSheetObserver({ mirror, stylesheetManager, }, host) {
2752
2765
  configurable: originalPropertyDescriptor.configurable,
2753
2766
  enumerable: originalPropertyDescriptor.enumerable,
2754
2767
  get() {
2755
- var _a;
2756
- return (_a = originalPropertyDescriptor.get) === null || _a === void 0 ? void 0 : _a.call(this);
2768
+ return _optionalChain$2([originalPropertyDescriptor, 'access', _11 => _11.get, 'optionalAccess', _12 => _12.call, 'call', _13 => _13(this)]);
2757
2769
  },
2758
2770
  set(sheets) {
2759
- var _a;
2760
- const result = (_a = originalPropertyDescriptor.set) === null || _a === void 0 ? void 0 : _a.call(this, sheets);
2771
+ const result = _optionalChain$2([originalPropertyDescriptor, 'access', _14 => _14.set, 'optionalAccess', _15 => _15.call, 'call', _16 => _16(this, sheets)]);
2761
2772
  if (hostId !== null && hostId !== -1) {
2762
2773
  try {
2763
2774
  stylesheetManager.adoptStyleSheets(sheets, hostId);
@@ -2781,12 +2792,11 @@ function initStyleDeclarationObserver({ styleDeclarationCb, mirror, ignoreCSSAtt
2781
2792
  const setProperty = win.CSSStyleDeclaration.prototype.setProperty;
2782
2793
  win.CSSStyleDeclaration.prototype.setProperty = new Proxy(setProperty, {
2783
2794
  apply: callbackWrapper((target, thisArg, argumentsList) => {
2784
- var _a;
2785
2795
  const [property, value, priority] = argumentsList;
2786
2796
  if (ignoreCSSAttributes.has(property)) {
2787
2797
  return setProperty.apply(thisArg, [property, value, priority]);
2788
2798
  }
2789
- const { id, styleId } = getIdAndStyleId((_a = thisArg.parentRule) === null || _a === void 0 ? void 0 : _a.parentStyleSheet, mirror, stylesheetManager.styleMirror);
2799
+ const { id, styleId } = getIdAndStyleId(_optionalChain$2([thisArg, 'access', _17 => _17.parentRule, 'optionalAccess', _18 => _18.parentStyleSheet]), mirror, stylesheetManager.styleMirror);
2790
2800
  if ((id && id !== -1) || (styleId && styleId !== -1)) {
2791
2801
  styleDeclarationCb({
2792
2802
  id,
@@ -2805,12 +2815,11 @@ function initStyleDeclarationObserver({ styleDeclarationCb, mirror, ignoreCSSAtt
2805
2815
  const removeProperty = win.CSSStyleDeclaration.prototype.removeProperty;
2806
2816
  win.CSSStyleDeclaration.prototype.removeProperty = new Proxy(removeProperty, {
2807
2817
  apply: callbackWrapper((target, thisArg, argumentsList) => {
2808
- var _a;
2809
2818
  const [property] = argumentsList;
2810
2819
  if (ignoreCSSAttributes.has(property)) {
2811
2820
  return removeProperty.apply(thisArg, [property]);
2812
2821
  }
2813
- const { id, styleId } = getIdAndStyleId((_a = thisArg.parentRule) === null || _a === void 0 ? void 0 : _a.parentStyleSheet, mirror, stylesheetManager.styleMirror);
2822
+ const { id, styleId } = getIdAndStyleId(_optionalChain$2([thisArg, 'access', _19 => _19.parentRule, 'optionalAccess', _20 => _20.parentStyleSheet]), mirror, stylesheetManager.styleMirror);
2814
2823
  if ((id && id !== -1) || (styleId && styleId !== -1)) {
2815
2824
  styleDeclarationCb({
2816
2825
  id,
@@ -2903,7 +2912,7 @@ function initSelectionObserver(param) {
2903
2912
  let collapsed = true;
2904
2913
  const updateSelection = callbackWrapper(() => {
2905
2914
  const selection = doc.getSelection();
2906
- if (!selection || (collapsed && (selection === null || selection === void 0 ? void 0 : selection.isCollapsed)))
2915
+ if (!selection || (collapsed && _optionalChain$2([selection, 'optionalAccess', _21 => _21.isCollapsed])))
2907
2916
  return;
2908
2917
  collapsed = selection.isCollapsed || false;
2909
2918
  const ranges = [];
@@ -3069,6 +3078,7 @@ class CrossOriginIframeMirror {
3069
3078
  }
3070
3079
  }
3071
3080
 
3081
+ function _optionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
3072
3082
  class IframeManagerNoop {
3073
3083
  constructor() {
3074
3084
  this.crossOriginIframeMirror = new CrossOriginIframeMirror(genId);
@@ -3106,7 +3116,6 @@ class IframeManager {
3106
3116
  this.loadListener = cb;
3107
3117
  }
3108
3118
  attachIframe(iframeEl, childSn) {
3109
- var _a;
3110
3119
  this.mutationCb({
3111
3120
  adds: [
3112
3121
  {
@@ -3120,7 +3129,7 @@ class IframeManager {
3120
3129
  attributes: [],
3121
3130
  isAttachIframe: true,
3122
3131
  });
3123
- (_a = this.loadListener) === null || _a === void 0 ? void 0 : _a.call(this, iframeEl);
3132
+ _optionalChain$1([this, 'access', _ => _.loadListener, 'optionalCall', _2 => _2(iframeEl)]);
3124
3133
  if (iframeEl.contentDocument &&
3125
3134
  iframeEl.contentDocument.adoptedStyleSheets &&
3126
3135
  iframeEl.contentDocument.adoptedStyleSheets.length > 0)
@@ -3142,7 +3151,6 @@ class IframeManager {
3142
3151
  this.wrappedEmit(transformedEvent, crossOriginMessageEvent.data.isCheckout);
3143
3152
  }
3144
3153
  transformCrossOriginEvent(iframeEl, e) {
3145
- var _a;
3146
3154
  switch (e.type) {
3147
3155
  case EventType.FullSnapshot: {
3148
3156
  this.crossOriginIframeMirror.reset(iframeEl);
@@ -3243,9 +3251,9 @@ class IframeManager {
3243
3251
  case IncrementalSource.AdoptedStyleSheet: {
3244
3252
  this.replaceIds(e.data, iframeEl, ['id']);
3245
3253
  this.replaceStyleIds(e.data, iframeEl, ['styleIds']);
3246
- (_a = e.data.styles) === null || _a === void 0 ? void 0 : _a.forEach((style) => {
3254
+ _optionalChain$1([e, 'access', _3 => _3.data, 'access', _4 => _4.styles, 'optionalAccess', _5 => _5.forEach, 'call', _6 => _6((style) => {
3247
3255
  this.replaceStyleIds(style, iframeEl, ['styleId']);
3248
- });
3256
+ })]);
3249
3257
  return e;
3250
3258
  }
3251
3259
  }
@@ -3321,9 +3329,20 @@ class ShadowDomManager {
3321
3329
  if (this.shadowDoms.has(shadowRoot))
3322
3330
  return;
3323
3331
  this.shadowDoms.add(shadowRoot);
3324
- const observer = initMutationObserver(Object.assign(Object.assign({}, this.bypassOptions), { doc, mutationCb: this.mutationCb, mirror: this.mirror, shadowDomManager: this }), shadowRoot);
3332
+ const observer = initMutationObserver({
3333
+ ...this.bypassOptions,
3334
+ doc,
3335
+ mutationCb: this.mutationCb,
3336
+ mirror: this.mirror,
3337
+ shadowDomManager: this,
3338
+ }, shadowRoot);
3325
3339
  this.restoreHandlers.push(() => observer.disconnect());
3326
- this.restoreHandlers.push(initScrollObserver(Object.assign(Object.assign({}, this.bypassOptions), { scrollCb: this.scrollCb, doc: shadowRoot, mirror: this.mirror })));
3340
+ this.restoreHandlers.push(initScrollObserver({
3341
+ ...this.bypassOptions,
3342
+ scrollCb: this.scrollCb,
3343
+ doc: shadowRoot,
3344
+ mirror: this.mirror,
3345
+ }));
3327
3346
  setTimeout(() => {
3328
3347
  if (shadowRoot.adoptedStyleSheets &&
3329
3348
  shadowRoot.adoptedStyleSheets.length > 0)
@@ -3374,6 +3393,8 @@ class CanvasManagerNoop {
3374
3393
  }
3375
3394
  unlock() {
3376
3395
  }
3396
+ snapshot() {
3397
+ }
3377
3398
  }
3378
3399
 
3379
3400
  class StylesheetManager {
@@ -3448,7 +3469,7 @@ class ProcessedNodeManager {
3448
3469
  this.periodicallyClear();
3449
3470
  }
3450
3471
  periodicallyClear() {
3451
- requestAnimationFrame(() => {
3472
+ onRequestAnimationFrame(() => {
3452
3473
  this.clear();
3453
3474
  if (this.loop)
3454
3475
  this.periodicallyClear();
@@ -3474,7 +3495,6 @@ function wrapEvent(e) {
3474
3495
  eWithTime.timestamp = nowTimestamp();
3475
3496
  return eWithTime;
3476
3497
  }
3477
- let _wrappedEmit;
3478
3498
  let _takeFullSnapshot;
3479
3499
  const mirror = createMirror();
3480
3500
  function record(options = {}) {
@@ -3558,15 +3578,14 @@ function record(options = {}) {
3558
3578
  return e;
3559
3579
  };
3560
3580
  const wrappedEmit = (e, isCheckout) => {
3561
- var _a;
3562
- if (((_a = mutationBuffers[0]) === null || _a === void 0 ? void 0 : _a.isFrozen()) &&
3581
+ if (_optionalChain([mutationBuffers, 'access', _ => _[0], 'optionalAccess', _2 => _2.isFrozen, 'call', _3 => _3()]) &&
3563
3582
  e.type !== EventType.FullSnapshot &&
3564
3583
  !(e.type === EventType.IncrementalSnapshot &&
3565
3584
  e.data.source === IncrementalSource.Mutation)) {
3566
3585
  mutationBuffers.forEach((buf) => buf.unfreeze());
3567
3586
  }
3568
3587
  if (inEmittingFrame) {
3569
- emit === null || emit === void 0 ? void 0 : emit(eventProcessor(e), isCheckout);
3588
+ _optionalChain([emit, 'optionalCall', _4 => _4(eventProcessor(e), isCheckout)]);
3570
3589
  }
3571
3590
  else if (passEmitsToParent) {
3572
3591
  const message = {
@@ -3595,24 +3614,35 @@ function record(options = {}) {
3595
3614
  }
3596
3615
  }
3597
3616
  };
3598
- _wrappedEmit = wrappedEmit;
3599
3617
  const wrappedMutationEmit = (m) => {
3600
3618
  wrappedEmit(wrapEvent({
3601
3619
  type: EventType.IncrementalSnapshot,
3602
- data: Object.assign({ source: IncrementalSource.Mutation }, m),
3620
+ data: {
3621
+ source: IncrementalSource.Mutation,
3622
+ ...m,
3623
+ },
3603
3624
  }));
3604
3625
  };
3605
3626
  const wrappedScrollEmit = (p) => wrappedEmit(wrapEvent({
3606
3627
  type: EventType.IncrementalSnapshot,
3607
- data: Object.assign({ source: IncrementalSource.Scroll }, p),
3628
+ data: {
3629
+ source: IncrementalSource.Scroll,
3630
+ ...p,
3631
+ },
3608
3632
  }));
3609
3633
  const wrappedCanvasMutationEmit = (p) => wrappedEmit(wrapEvent({
3610
3634
  type: EventType.IncrementalSnapshot,
3611
- data: Object.assign({ source: IncrementalSource.CanvasMutation }, p),
3635
+ data: {
3636
+ source: IncrementalSource.CanvasMutation,
3637
+ ...p,
3638
+ },
3612
3639
  }));
3613
3640
  const wrappedAdoptedStyleSheetEmit = (a) => wrappedEmit(wrapEvent({
3614
3641
  type: EventType.IncrementalSnapshot,
3615
- data: Object.assign({ source: IncrementalSource.AdoptedStyleSheet }, a),
3642
+ data: {
3643
+ source: IncrementalSource.AdoptedStyleSheet,
3644
+ ...a,
3645
+ },
3616
3646
  }));
3617
3647
  const stylesheetManager = new StylesheetManager({
3618
3648
  mutationCb: wrappedMutationEmit,
@@ -3637,6 +3667,15 @@ function record(options = {}) {
3637
3667
  }
3638
3668
  const processedNodeManager = new ProcessedNodeManager();
3639
3669
  const canvasManager = _getCanvasManager(getCanvasManager, {
3670
+ mirror,
3671
+ win: window,
3672
+ mutationCb: (p) => wrappedEmit(wrapEvent({
3673
+ type: EventType.IncrementalSnapshot,
3674
+ data: {
3675
+ source: IncrementalSource.CanvasMutation,
3676
+ ...p,
3677
+ },
3678
+ })),
3640
3679
  recordCanvas,
3641
3680
  blockClass,
3642
3681
  blockSelector,
@@ -3747,7 +3786,6 @@ function record(options = {}) {
3747
3786
  try {
3748
3787
  const handlers = [];
3749
3788
  const observe = (doc) => {
3750
- var _a;
3751
3789
  return callbackWrapper(initObservers)({
3752
3790
  onMutation,
3753
3791
  mutationCb: wrappedMutationEmit,
@@ -3760,44 +3798,71 @@ function record(options = {}) {
3760
3798
  })),
3761
3799
  mouseInteractionCb: (d) => wrappedEmit(wrapEvent({
3762
3800
  type: EventType.IncrementalSnapshot,
3763
- data: Object.assign({ source: IncrementalSource.MouseInteraction }, d),
3801
+ data: {
3802
+ source: IncrementalSource.MouseInteraction,
3803
+ ...d,
3804
+ },
3764
3805
  })),
3765
3806
  scrollCb: wrappedScrollEmit,
3766
3807
  viewportResizeCb: (d) => wrappedEmit(wrapEvent({
3767
3808
  type: EventType.IncrementalSnapshot,
3768
- data: Object.assign({ source: IncrementalSource.ViewportResize }, d),
3809
+ data: {
3810
+ source: IncrementalSource.ViewportResize,
3811
+ ...d,
3812
+ },
3769
3813
  })),
3770
3814
  inputCb: (v) => wrappedEmit(wrapEvent({
3771
3815
  type: EventType.IncrementalSnapshot,
3772
- data: Object.assign({ source: IncrementalSource.Input }, v),
3816
+ data: {
3817
+ source: IncrementalSource.Input,
3818
+ ...v,
3819
+ },
3773
3820
  })),
3774
3821
  mediaInteractionCb: (p) => wrappedEmit(wrapEvent({
3775
3822
  type: EventType.IncrementalSnapshot,
3776
- data: Object.assign({ source: IncrementalSource.MediaInteraction }, p),
3823
+ data: {
3824
+ source: IncrementalSource.MediaInteraction,
3825
+ ...p,
3826
+ },
3777
3827
  })),
3778
3828
  styleSheetRuleCb: (r) => wrappedEmit(wrapEvent({
3779
3829
  type: EventType.IncrementalSnapshot,
3780
- data: Object.assign({ source: IncrementalSource.StyleSheetRule }, r),
3830
+ data: {
3831
+ source: IncrementalSource.StyleSheetRule,
3832
+ ...r,
3833
+ },
3781
3834
  })),
3782
3835
  styleDeclarationCb: (r) => wrappedEmit(wrapEvent({
3783
3836
  type: EventType.IncrementalSnapshot,
3784
- data: Object.assign({ source: IncrementalSource.StyleDeclaration }, r),
3837
+ data: {
3838
+ source: IncrementalSource.StyleDeclaration,
3839
+ ...r,
3840
+ },
3785
3841
  })),
3786
3842
  canvasMutationCb: wrappedCanvasMutationEmit,
3787
3843
  fontCb: (p) => wrappedEmit(wrapEvent({
3788
3844
  type: EventType.IncrementalSnapshot,
3789
- data: Object.assign({ source: IncrementalSource.Font }, p),
3845
+ data: {
3846
+ source: IncrementalSource.Font,
3847
+ ...p,
3848
+ },
3790
3849
  })),
3791
3850
  selectionCb: (p) => {
3792
3851
  wrappedEmit(wrapEvent({
3793
3852
  type: EventType.IncrementalSnapshot,
3794
- data: Object.assign({ source: IncrementalSource.Selection }, p),
3853
+ data: {
3854
+ source: IncrementalSource.Selection,
3855
+ ...p,
3856
+ },
3795
3857
  }));
3796
3858
  },
3797
3859
  customElementCb: (c) => {
3798
3860
  wrappedEmit(wrapEvent({
3799
3861
  type: EventType.IncrementalSnapshot,
3800
- data: Object.assign({ source: IncrementalSource.CustomElement }, c),
3862
+ data: {
3863
+ source: IncrementalSource.CustomElement,
3864
+ ...c,
3865
+ },
3801
3866
  }));
3802
3867
  },
3803
3868
  blockClass,
@@ -3831,7 +3896,9 @@ function record(options = {}) {
3831
3896
  processedNodeManager,
3832
3897
  canvasManager,
3833
3898
  ignoreCSSAttributes,
3834
- plugins: ((_a = plugins === null || plugins === void 0 ? void 0 : plugins.filter((p) => p.observer)) === null || _a === void 0 ? void 0 : _a.map((p) => ({
3899
+ plugins: _optionalChain([plugins
3900
+ , 'optionalAccess', _5 => _5.filter, 'call', _6 => _6((p) => p.observer)
3901
+ , 'optionalAccess', _7 => _7.map, 'call', _8 => _8((p) => ({
3835
3902
  observer: p.observer,
3836
3903
  options: p.options,
3837
3904
  callback: (payload) => wrappedEmit(wrapEvent({
@@ -3841,7 +3908,7 @@ function record(options = {}) {
3841
3908
  payload,
3842
3909
  },
3843
3910
  })),
3844
- }))) || [],
3911
+ }))]) || [],
3845
3912
  }, {});
3846
3913
  };
3847
3914
  iframeManager.addLoadListener((iframeEl) => {
@@ -3895,21 +3962,18 @@ function takeFullSnapshot(isCheckout) {
3895
3962
  }
3896
3963
  _takeFullSnapshot(isCheckout);
3897
3964
  }
3898
- function wrappedEmit(e) {
3899
- if (!_wrappedEmit) {
3900
- return;
3901
- }
3902
- _wrappedEmit(e);
3903
- }
3904
3965
  record.mirror = mirror;
3905
3966
  record.takeFullSnapshot = takeFullSnapshot;
3906
3967
  function _getCanvasManager(getCanvasManagerFn, options) {
3907
- return getCanvasManagerFn
3908
- ? getCanvasManagerFn(Object.assign(Object.assign({}, options), { mirror, win: window, mutationCb: (p) => wrappedEmit(wrapEvent({
3909
- type: EventType.IncrementalSnapshot,
3910
- data: Object.assign({ source: IncrementalSource.CanvasMutation }, p),
3911
- })) }))
3912
- : new CanvasManagerNoop();
3968
+ try {
3969
+ return getCanvasManagerFn
3970
+ ? getCanvasManagerFn(options)
3971
+ : new CanvasManagerNoop();
3972
+ }
3973
+ catch (e2) {
3974
+ console.warn('Unable to initialize CanvasManager');
3975
+ return new CanvasManagerNoop();
3976
+ }
3913
3977
  }
3914
3978
 
3915
3979
  const ReplayEventTypeIncrementalSnapshot = 3;
@@ -7347,6 +7411,7 @@ function createOptionsEvent(replay) {
7347
7411
  data: {
7348
7412
  tag: 'options',
7349
7413
  payload: {
7414
+ shouldRecordCanvas: replay.isRecordingCanvas(),
7350
7415
  sessionSampleRate: options.sessionSampleRate,
7351
7416
  errorSampleRate: options.errorSampleRate,
7352
7417
  useCompressionOption: options.useCompression,
@@ -7810,6 +7875,10 @@ class ReplayContainer {
7810
7875
  * Function to stop recording
7811
7876
  */
7812
7877
 
7878
+ /**
7879
+ * Internal use for canvas recording options
7880
+ */
7881
+
7813
7882
  constructor({
7814
7883
  options,
7815
7884
  recordingOptions,
@@ -7882,6 +7951,13 @@ class ReplayContainer {
7882
7951
  return this._isPaused;
7883
7952
  }
7884
7953
 
7954
+ /**
7955
+ * Determine if canvas recording is enabled
7956
+ */
7957
+ isRecordingCanvas() {
7958
+ return Boolean(this._canvas);
7959
+ }
7960
+
7885
7961
  /** Get the replay integration options. */
7886
7962
  getOptions() {
7887
7963
  return this._options;
@@ -8002,7 +8078,8 @@ class ReplayContainer {
8002
8078
  */
8003
8079
  startRecording() {
8004
8080
  try {
8005
- const canvas = this._options._experiments.canvas;
8081
+ const canvasOptions = this._canvas;
8082
+
8006
8083
  this._stopRecording = record({
8007
8084
  ...this._recordingOptions,
8008
8085
  // When running in error sampling mode, we need to overwrite `checkoutEveryNms`
@@ -8011,12 +8088,14 @@ class ReplayContainer {
8011
8088
  ...(this.recordingMode === 'buffer' && { checkoutEveryNms: BUFFER_CHECKOUT_TIME }),
8012
8089
  emit: getHandleRecordingEmit(this),
8013
8090
  onMutation: this._onMutationHandler,
8014
- ...(canvas &&
8015
- canvas.manager && {
8016
- recordCanvas: true,
8017
- getCanvasManager: canvas.manager,
8018
- ...(CANVAS_QUALITY[canvas.quality || 'medium'] || CANVAS_QUALITY.medium),
8019
- }),
8091
+ ...(canvasOptions
8092
+ ? {
8093
+ recordCanvas: canvasOptions.recordCanvas,
8094
+ getCanvasManager: canvasOptions.getCanvasManager,
8095
+ sampling: canvasOptions.sampling,
8096
+ dataURLOptions: canvasOptions.dataURLOptions,
8097
+ }
8098
+ : {}),
8020
8099
  });
8021
8100
  } catch (err) {
8022
8101
  this._handleException(err);
@@ -8369,12 +8448,16 @@ class ReplayContainer {
8369
8448
  * This is only available if performance is enabled, and if an instrumented router is used.
8370
8449
  */
8371
8450
  getCurrentRoute() {
8451
+ // eslint-disable-next-line deprecation/deprecation
8372
8452
  const lastTransaction = this.lastTransaction || core.getCurrentScope().getTransaction();
8373
- if (!lastTransaction || !['route', 'custom'].includes(lastTransaction.metadata.source)) {
8453
+
8454
+ const attributes = (lastTransaction && core.spanToJSON(lastTransaction).data) || {};
8455
+ const source = attributes[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
8456
+ if (!lastTransaction || !source || !['route', 'custom'].includes(source)) {
8374
8457
  return undefined;
8375
8458
  }
8376
8459
 
8377
- return lastTransaction.name;
8460
+ return core.spanToJSON(lastTransaction).description;
8378
8461
  }
8379
8462
 
8380
8463
  /**
@@ -9338,6 +9421,7 @@ Sentry.init({ replaysOnErrorSampleRate: ${errorSampleRate} })`,
9338
9421
 
9339
9422
  return this._replay.getSessionId();
9340
9423
  }
9424
+
9341
9425
  /**
9342
9426
  * Initializes replay.
9343
9427
  */
@@ -9346,6 +9430,12 @@ Sentry.init({ replaysOnErrorSampleRate: ${errorSampleRate} })`,
9346
9430
  return;
9347
9431
  }
9348
9432
 
9433
+ // We have to run this in _initialize, because this runs in setTimeout
9434
+ // So when this runs all integrations have been added
9435
+ // Before this, we cannot access integrations on the client,
9436
+ // so we need to mutate the options here
9437
+ this._maybeLoadFromReplayCanvasIntegration();
9438
+
9349
9439
  this._replay.initializeSampling();
9350
9440
  }
9351
9441
 
@@ -9359,7 +9449,28 @@ Sentry.init({ replaysOnErrorSampleRate: ${errorSampleRate} })`,
9359
9449
  recordingOptions: this._recordingOptions,
9360
9450
  });
9361
9451
  }
9362
- } Replay.__initStatic();
9452
+
9453
+ /** Get canvas options from ReplayCanvas integration, if it is also added. */
9454
+ _maybeLoadFromReplayCanvasIntegration() {
9455
+ // To save bundle size, we skip checking for stuff here
9456
+ // and instead just try-catch everything - as generally this should all be defined
9457
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */
9458
+ try {
9459
+ const client = core.getClient();
9460
+ const canvasIntegration = client.getIntegrationByName('ReplayCanvas')
9461
+
9462
+ ;
9463
+ if (!canvasIntegration) {
9464
+ return;
9465
+ }
9466
+
9467
+ this._replay['_canvas'] = canvasIntegration.getOptions();
9468
+ } catch (e) {
9469
+ // ignore errors here
9470
+ }
9471
+ /* eslint-enable @typescript-eslint/no-non-null-assertion */
9472
+ }
9473
+ }Replay.__initStatic();
9363
9474
 
9364
9475
  /** Parse Replay-related options from SDK options */
9365
9476
  function loadReplayOptionsFromClient(initialOptions) {