@sentry/replay 7.37.1 → 7.37.2

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
@@ -20,9 +20,6 @@ const VISIBILITY_CHANGE_TIMEOUT = SESSION_IDLE_DURATION;
20
20
  // The maximum length of a session
21
21
  const MAX_SESSION_LIFE = 3600000; // 60 minutes
22
22
 
23
- /** The select to use for the `maskAllText` option */
24
- const MASK_ALL_TEXT_SELECTOR = 'body *:not(style), body *:not(script)';
25
-
26
23
  /** Default flush delays */
27
24
  const DEFAULT_FLUSH_MIN_DELAY = 5000;
28
25
  const DEFAULT_FLUSH_MAX_DELAY = 5000;
@@ -90,6 +87,9 @@ function is2DCanvasBlank(canvas) {
90
87
  let _id = 1;
91
88
  const tagNameRegex = new RegExp('[^a-z0-9-_:]');
92
89
  const IGNORED_NODE = -2;
90
+ function defaultMaskFn(str) {
91
+ return str.replace(/[\S]/g, '*');
92
+ }
93
93
  function genId() {
94
94
  return _id++;
95
95
  }
@@ -258,7 +258,7 @@ function getHref() {
258
258
  a.href = '';
259
259
  return a.href;
260
260
  }
261
- function transformAttribute(doc, tagName, name, value) {
261
+ function transformAttribute(doc, tagName, name, value, maskAllText, maskTextFn) {
262
262
  if (name === 'src' || (name === 'href' && value)) {
263
263
  return absoluteToDoc(doc, value);
264
264
  }
@@ -279,6 +279,9 @@ function transformAttribute(doc, tagName, name, value) {
279
279
  else if (tagName === 'object' && name === 'data' && value) {
280
280
  return absoluteToDoc(doc, value);
281
281
  }
282
+ else if (maskAllText && ['placeholder', 'title', 'aria-label'].indexOf(name) > -1) {
283
+ return maskTextFn ? maskTextFn(value) : defaultMaskFn(value);
284
+ }
282
285
  else {
283
286
  return value;
284
287
  }
@@ -305,41 +308,41 @@ function _isBlockedElement(element, blockClass, blockSelector, unblockSelector)
305
308
  }
306
309
  return false;
307
310
  }
308
- function needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextSelector) {
311
+ function needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextSelector, maskAllText) {
309
312
  if (!node) {
310
313
  return false;
311
314
  }
312
- if (node.nodeType === node.ELEMENT_NODE) {
313
- if (unmaskTextSelector) {
314
- if (node.matches(unmaskTextSelector) ||
315
- node.closest(unmaskTextSelector)) {
316
- return false;
317
- }
318
- }
319
- if (typeof maskTextClass === 'string') {
320
- if (node.classList.contains(maskTextClass)) {
321
- return true;
322
- }
315
+ if (node.nodeType !== node.ELEMENT_NODE) {
316
+ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector, maskAllText);
317
+ }
318
+ if (unmaskTextSelector) {
319
+ if (node.matches(unmaskTextSelector) ||
320
+ node.closest(unmaskTextSelector)) {
321
+ return false;
323
322
  }
324
- else {
325
- for (let eIndex = 0; eIndex < node.classList.length; eIndex++) {
326
- const className = node.classList[eIndex];
327
- if (maskTextClass.test(className)) {
328
- return true;
329
- }
330
- }
323
+ }
324
+ if (maskAllText) {
325
+ return true;
326
+ }
327
+ if (typeof maskTextClass === 'string') {
328
+ if (node.classList.contains(maskTextClass)) {
329
+ return true;
331
330
  }
332
- if (maskTextSelector) {
333
- if (node.matches(maskTextSelector)) {
331
+ }
332
+ else {
333
+ for (let eIndex = 0; eIndex < node.classList.length; eIndex++) {
334
+ const className = node.classList[eIndex];
335
+ if (maskTextClass.test(className)) {
334
336
  return true;
335
337
  }
336
338
  }
337
- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);
338
339
  }
339
- if (node.nodeType === node.TEXT_NODE) {
340
- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);
340
+ if (maskTextSelector) {
341
+ if (node.matches(maskTextSelector)) {
342
+ return true;
343
+ }
341
344
  }
342
- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);
345
+ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector, maskAllText);
343
346
  }
344
347
  function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
345
348
  const win = iframeEl.contentWindow;
@@ -379,7 +382,7 @@ function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
379
382
  }
380
383
  function serializeNode(n, options) {
381
384
  var _a;
382
- const { doc, blockClass, blockSelector, unblockSelector, maskTextClass, maskTextSelector, unmaskTextSelector, inlineStylesheet, maskInputSelector, unmaskInputSelector, maskInputOptions = {}, maskTextFn, maskInputFn, dataURLOptions = {}, inlineImages, recordCanvas, keepIframeSrcFn, } = options;
385
+ const { doc, blockClass, blockSelector, unblockSelector, maskTextClass, maskTextSelector, unmaskTextSelector, inlineStylesheet, maskInputSelector, unmaskInputSelector, maskAllText, maskInputOptions = {}, maskTextFn, maskInputFn, dataURLOptions = {}, inlineImages, recordCanvas, keepIframeSrcFn, } = options;
383
386
  let rootId;
384
387
  if (doc.__sn) {
385
388
  const docId = doc.__sn.id;
@@ -415,7 +418,7 @@ function serializeNode(n, options) {
415
418
  const tagName = getValidTagName(n);
416
419
  let attributes = {};
417
420
  for (const { name, value } of Array.from(n.attributes)) {
418
- attributes[name] = transformAttribute(doc, tagName, name, value);
421
+ attributes[name] = transformAttribute(doc, tagName, name, value, maskAllText, maskTextFn);
419
422
  }
420
423
  if (tagName === 'link' && inlineStylesheet) {
421
424
  const stylesheet = Array.from(doc.styleSheets).find((s) => {
@@ -573,13 +576,25 @@ function serializeNode(n, options) {
573
576
  if (isScript) {
574
577
  textContent = 'SCRIPT_PLACEHOLDER';
575
578
  }
576
- if (!isStyle &&
579
+ if (parentTagName === 'TEXTAREA' && textContent) {
580
+ textContent = maskInputValue({
581
+ input: n.parentNode,
582
+ maskInputSelector,
583
+ unmaskInputSelector,
584
+ maskInputOptions,
585
+ tagName: parentTagName,
586
+ type: null,
587
+ value: textContent,
588
+ maskInputFn,
589
+ });
590
+ }
591
+ else if (!isStyle &&
577
592
  !isScript &&
578
- needMaskingText(n, maskTextClass, maskTextSelector, unmaskTextSelector) &&
593
+ needMaskingText(n, maskTextClass, maskTextSelector, unmaskTextSelector, maskAllText) &&
579
594
  textContent) {
580
595
  textContent = maskTextFn
581
596
  ? maskTextFn(textContent)
582
- : textContent.replace(/[\S]/g, '*');
597
+ : defaultMaskFn(textContent);
583
598
  }
584
599
  return {
585
600
  type: NodeType.Text,
@@ -683,7 +698,7 @@ function slimDOMExcluded(sn, slimDOMOptions) {
683
698
  return false;
684
699
  }
685
700
  function serializeNodeWithId(n, options) {
686
- const { doc, map, blockClass, blockSelector, unblockSelector, maskTextClass, maskTextSelector, unmaskTextSelector, skipChild = false, inlineStylesheet = true, maskInputSelector, unmaskInputSelector, maskInputOptions = {}, maskTextFn, maskInputFn, slimDOMOptions, dataURLOptions = {}, inlineImages = false, recordCanvas = false, onSerialize, onIframeLoad, iframeLoadTimeout = 5000, keepIframeSrcFn = () => false, } = options;
701
+ const { doc, map, blockClass, blockSelector, unblockSelector, maskTextClass, maskTextSelector, unmaskTextSelector, skipChild = false, inlineStylesheet = true, maskInputSelector, unmaskInputSelector, maskAllText, maskInputOptions = {}, maskTextFn, maskInputFn, slimDOMOptions, dataURLOptions = {}, inlineImages = false, recordCanvas = false, onSerialize, onIframeLoad, iframeLoadTimeout = 5000, keepIframeSrcFn = () => false, } = options;
687
702
  let { preserveWhiteSpace = true } = options;
688
703
  const _serializedNode = serializeNode(n, {
689
704
  doc,
@@ -696,6 +711,7 @@ function serializeNodeWithId(n, options) {
696
711
  inlineStylesheet,
697
712
  maskInputSelector,
698
713
  unmaskInputSelector,
714
+ maskAllText,
699
715
  maskInputOptions,
700
716
  maskTextFn,
701
717
  maskInputFn,
@@ -759,6 +775,7 @@ function serializeNodeWithId(n, options) {
759
775
  inlineStylesheet,
760
776
  maskInputSelector,
761
777
  unmaskInputSelector,
778
+ maskAllText,
762
779
  maskInputOptions,
763
780
  maskTextFn,
764
781
  maskInputFn,
@@ -809,6 +826,7 @@ function serializeNodeWithId(n, options) {
809
826
  inlineStylesheet,
810
827
  maskInputSelector,
811
828
  unmaskInputSelector,
829
+ maskAllText,
812
830
  maskInputOptions,
813
831
  maskTextFn,
814
832
  maskInputFn,
@@ -831,7 +849,7 @@ function serializeNodeWithId(n, options) {
831
849
  return serializedNode;
832
850
  }
833
851
  function snapshot(n, options) {
834
- const { blockClass = 'rr-block', blockSelector = null, unblockSelector = null, maskTextClass = 'rr-mask', maskTextSelector = null, unmaskTextSelector = null, inlineStylesheet = true, inlineImages = false, recordCanvas = false, maskInputSelector = null, unmaskInputSelector = null, maskAllInputs = false, maskTextFn, maskInputFn, slimDOM = false, dataURLOptions, preserveWhiteSpace, onSerialize, onIframeLoad, iframeLoadTimeout, keepIframeSrcFn = () => false, } = options || {};
852
+ const { blockClass = 'rr-block', blockSelector = null, unblockSelector = null, maskTextClass = 'rr-mask', maskTextSelector = null, unmaskTextSelector = null, inlineStylesheet = true, inlineImages = false, recordCanvas = false, maskInputSelector = null, unmaskInputSelector = null, maskAllText = false, maskAllInputs = false, maskTextFn, maskInputFn, slimDOM = false, dataURLOptions, preserveWhiteSpace, onSerialize, onIframeLoad, iframeLoadTimeout, keepIframeSrcFn = () => false, } = options || {};
835
853
  const idNodeMap = {};
836
854
  const maskInputOptions = maskAllInputs === true
837
855
  ? {
@@ -888,6 +906,7 @@ function snapshot(n, options) {
888
906
  inlineStylesheet,
889
907
  maskInputSelector,
890
908
  unmaskInputSelector,
909
+ maskAllText,
891
910
  maskInputOptions,
892
911
  maskTextFn,
893
912
  maskInputFn,
@@ -1126,33 +1145,42 @@ function getWindowWidth() {
1126
1145
  (document.documentElement && document.documentElement.clientWidth) ||
1127
1146
  (document.body && document.body.clientWidth));
1128
1147
  }
1129
- function isBlocked(node, blockClass) {
1148
+ function isBlocked(node, blockClass, blockSelector, unblockSelector) {
1130
1149
  if (!node) {
1131
1150
  return false;
1132
1151
  }
1133
1152
  if (node.nodeType === node.ELEMENT_NODE) {
1134
1153
  let needBlock = false;
1154
+ const needUnblock = unblockSelector && node.matches(unblockSelector);
1135
1155
  if (typeof blockClass === 'string') {
1136
1156
  if (node.closest !== undefined) {
1137
- return node.closest('.' + blockClass) !== null;
1157
+ needBlock =
1158
+ !needUnblock &&
1159
+ node.closest('.' + blockClass) !== null;
1138
1160
  }
1139
1161
  else {
1140
- needBlock = node.classList.contains(blockClass);
1162
+ needBlock =
1163
+ !needUnblock && node.classList.contains(blockClass);
1141
1164
  }
1142
1165
  }
1143
1166
  else {
1144
- node.classList.forEach((className) => {
1145
- if (blockClass.test(className)) {
1146
- needBlock = true;
1147
- }
1148
- });
1167
+ !needUnblock &&
1168
+ node.classList.forEach((className) => {
1169
+ if (blockClass.test(className)) {
1170
+ needBlock = true;
1171
+ }
1172
+ });
1173
+ }
1174
+ if (!needBlock && blockSelector) {
1175
+ needBlock = node.matches(blockSelector);
1149
1176
  }
1150
- return needBlock || isBlocked(node.parentNode, blockClass);
1177
+ return ((!needUnblock && needBlock) ||
1178
+ isBlocked(node.parentNode, blockClass, blockSelector, unblockSelector));
1151
1179
  }
1152
1180
  if (node.nodeType === node.TEXT_NODE) {
1153
- return isBlocked(node.parentNode, blockClass);
1181
+ return isBlocked(node.parentNode, blockClass, blockSelector, unblockSelector);
1154
1182
  }
1155
- return isBlocked(node.parentNode, blockClass);
1183
+ return isBlocked(node.parentNode, blockClass, blockSelector, unblockSelector);
1156
1184
  }
1157
1185
  function isIgnored(n) {
1158
1186
  if ('__sn' in n) {
@@ -1360,6 +1388,7 @@ class MutationBuffer {
1360
1388
  unmaskInputSelector: this.unmaskInputSelector,
1361
1389
  skipChild: true,
1362
1390
  inlineStylesheet: this.inlineStylesheet,
1391
+ maskAllText: this.maskAllText,
1363
1392
  maskInputOptions: this.maskInputOptions,
1364
1393
  maskTextFn: this.maskTextFn,
1365
1394
  maskInputFn: this.maskInputFn,
@@ -1480,9 +1509,9 @@ class MutationBuffer {
1480
1509
  switch (m.type) {
1481
1510
  case 'characterData': {
1482
1511
  const value = m.target.textContent;
1483
- if (!isBlocked(m.target, this.blockClass) && value !== m.oldValue) {
1512
+ if (!isBlocked(m.target, this.blockClass, this.blockSelector, this.unblockSelector) && value !== m.oldValue) {
1484
1513
  this.texts.push({
1485
- value: needMaskingText(m.target, this.maskTextClass, this.maskTextSelector, this.unmaskTextSelector) && value
1514
+ value: needMaskingText(m.target, this.maskTextClass, this.maskTextSelector, this.unmaskTextSelector, this.maskAllText) && value
1486
1515
  ? this.maskTextFn
1487
1516
  ? this.maskTextFn(value)
1488
1517
  : value.replace(/[\S]/g, '*')
@@ -1507,7 +1536,7 @@ class MutationBuffer {
1507
1536
  maskInputFn: this.maskInputFn,
1508
1537
  });
1509
1538
  }
1510
- if (isBlocked(m.target, this.blockClass) || value === m.oldValue) {
1539
+ if (isBlocked(m.target, this.blockClass, this.blockSelector, this.unblockSelector) || value === m.oldValue) {
1511
1540
  return;
1512
1541
  }
1513
1542
  let item = this.attributes.find((a) => a.node === m.target);
@@ -1553,7 +1582,7 @@ class MutationBuffer {
1553
1582
  }
1554
1583
  }
1555
1584
  else {
1556
- item.attributes[m.attributeName] = transformAttribute(this.doc, m.target.tagName, m.attributeName, value);
1585
+ item.attributes[m.attributeName] = transformAttribute(this.doc, m.target.tagName, m.attributeName, value, this.maskAllText, this.maskTextFn);
1557
1586
  }
1558
1587
  break;
1559
1588
  }
@@ -1564,7 +1593,7 @@ class MutationBuffer {
1564
1593
  const parentId = isShadowRoot(m.target)
1565
1594
  ? this.mirror.getId(m.target.host)
1566
1595
  : this.mirror.getId(m.target);
1567
- if (isBlocked(m.target, this.blockClass) || isIgnored(n)) {
1596
+ if (isBlocked(m.target, this.blockClass, this.blockSelector, this.unblockSelector) || isIgnored(n)) {
1568
1597
  return;
1569
1598
  }
1570
1599
  if (this.addedSet.has(n)) {
@@ -1591,7 +1620,7 @@ class MutationBuffer {
1591
1620
  }
1592
1621
  };
1593
1622
  this.genAdds = (n, target) => {
1594
- if (target && isBlocked(target, this.blockClass)) {
1623
+ if (target && isBlocked(target, this.blockClass, this.blockSelector, this.unblockSelector)) {
1595
1624
  return;
1596
1625
  }
1597
1626
  if (isINode(n)) {
@@ -1611,7 +1640,7 @@ class MutationBuffer {
1611
1640
  this.addedSet.add(n);
1612
1641
  this.droppedSet.delete(n);
1613
1642
  }
1614
- if (!isBlocked(n, this.blockClass))
1643
+ if (!isBlocked(n, this.blockClass, this.blockSelector, this.unblockSelector))
1615
1644
  n.childNodes.forEach((childN) => this.genAdds(childN));
1616
1645
  };
1617
1646
  }
@@ -1627,6 +1656,7 @@ class MutationBuffer {
1627
1656
  'maskInputSelector',
1628
1657
  'unmaskInputSelector',
1629
1658
  'inlineStylesheet',
1659
+ 'maskAllText',
1630
1660
  'maskInputOptions',
1631
1661
  'maskTextFn',
1632
1662
  'maskInputFn',
@@ -1800,7 +1830,7 @@ function initMoveObserver({ mousemoveCb, sampling, doc, mirror, }) {
1800
1830
  handlers.forEach((h) => h());
1801
1831
  });
1802
1832
  }
1803
- function initMouseInteractionObserver({ mouseInteractionCb, doc, mirror, blockClass, sampling, }) {
1833
+ function initMouseInteractionObserver({ mouseInteractionCb, doc, mirror, blockClass, blockSelector, unblockSelector, sampling, }) {
1804
1834
  if (sampling.mouseInteraction === false) {
1805
1835
  return () => { };
1806
1836
  }
@@ -1812,7 +1842,7 @@ function initMouseInteractionObserver({ mouseInteractionCb, doc, mirror, blockCl
1812
1842
  const getHandler = (eventKey) => {
1813
1843
  return (event) => {
1814
1844
  const target = getEventTarget(event);
1815
- if (isBlocked(target, blockClass)) {
1845
+ if (isBlocked(target, blockClass, blockSelector, unblockSelector)) {
1816
1846
  return;
1817
1847
  }
1818
1848
  const e = isTouchEvent(event) ? event.changedTouches[0] : event;
@@ -1842,10 +1872,10 @@ function initMouseInteractionObserver({ mouseInteractionCb, doc, mirror, blockCl
1842
1872
  handlers.forEach((h) => h());
1843
1873
  });
1844
1874
  }
1845
- function initScrollObserver({ scrollCb, doc, mirror, blockClass, sampling, }) {
1875
+ function initScrollObserver({ scrollCb, doc, mirror, blockClass, blockSelector, unblockSelector, sampling, }) {
1846
1876
  const updatePosition = throttle((evt) => {
1847
1877
  const target = getEventTarget(evt);
1848
- if (!target || isBlocked(target, blockClass)) {
1878
+ if (!target || isBlocked(target, blockClass, blockSelector, unblockSelector)) {
1849
1879
  return;
1850
1880
  }
1851
1881
  const id = mirror.getId(target);
@@ -1892,7 +1922,7 @@ function wrapEventWithUserTriggeredFlag(v, enable) {
1892
1922
  }
1893
1923
  const INPUT_TAGS = ['INPUT', 'TEXTAREA', 'SELECT'];
1894
1924
  const lastInputValueMap = new WeakMap();
1895
- function initInputObserver({ inputCb, doc, mirror, blockClass, ignoreClass, ignoreSelector, maskInputSelector, unmaskInputSelector, maskInputOptions, maskInputFn, sampling, userTriggeredOnInput, }) {
1925
+ function initInputObserver({ inputCb, doc, mirror, blockClass, blockSelector, unblockSelector, ignoreClass, ignoreSelector, maskInputSelector, unmaskInputSelector, maskInputOptions, maskInputFn, sampling, userTriggeredOnInput, }) {
1896
1926
  function eventHandler(event) {
1897
1927
  let target = getEventTarget(event);
1898
1928
  const userTriggered = event.isTrusted;
@@ -1901,7 +1931,7 @@ function initInputObserver({ inputCb, doc, mirror, blockClass, ignoreClass, igno
1901
1931
  if (!target ||
1902
1932
  !target.tagName ||
1903
1933
  INPUT_TAGS.indexOf(target.tagName) < 0 ||
1904
- isBlocked(target, blockClass)) {
1934
+ isBlocked(target, blockClass, blockSelector, unblockSelector)) {
1905
1935
  return;
1906
1936
  }
1907
1937
  const type = target.type;
@@ -2142,10 +2172,10 @@ function initStyleDeclarationObserver({ styleDeclarationCb, mirror }, { win }) {
2142
2172
  win.CSSStyleDeclaration.prototype.removeProperty = removeProperty;
2143
2173
  });
2144
2174
  }
2145
- function initMediaInteractionObserver({ mediaInteractionCb, blockClass, mirror, sampling, }) {
2175
+ function initMediaInteractionObserver({ mediaInteractionCb, blockClass, blockSelector, unblockSelector, mirror, sampling, }) {
2146
2176
  const handler = (type) => throttle(callbackWrapper((event) => {
2147
2177
  const target = getEventTarget(event);
2148
- if (!target || isBlocked(target, blockClass)) {
2178
+ if (!target || isBlocked(target, blockClass, blockSelector, unblockSelector)) {
2149
2179
  return;
2150
2180
  }
2151
2181
  const { currentTime, volume, muted } = target;
@@ -2424,7 +2454,7 @@ function __rest(s, e) {
2424
2454
  return t;
2425
2455
  }
2426
2456
 
2427
- function initCanvas2DMutationObserver(cb, win, blockClass, mirror) {
2457
+ function initCanvas2DMutationObserver(cb, win, blockClass, unblockSelector, blockSelector, mirror) {
2428
2458
  const handlers = [];
2429
2459
  const props2D = Object.getOwnPropertyNames(win.CanvasRenderingContext2D.prototype);
2430
2460
  for (const prop of props2D) {
@@ -2434,7 +2464,7 @@ function initCanvas2DMutationObserver(cb, win, blockClass, mirror) {
2434
2464
  }
2435
2465
  const restoreHandler = patch(win.CanvasRenderingContext2D.prototype, prop, function (original) {
2436
2466
  return function (...args) {
2437
- if (!isBlocked(this.canvas, blockClass)) {
2467
+ if (!isBlocked(this.canvas, blockClass, blockSelector, unblockSelector)) {
2438
2468
  setTimeout(() => {
2439
2469
  const recordArgs = [...args];
2440
2470
  if (prop === 'drawImage') {
@@ -2478,12 +2508,12 @@ function initCanvas2DMutationObserver(cb, win, blockClass, mirror) {
2478
2508
  };
2479
2509
  }
2480
2510
 
2481
- function initCanvasContextObserver(win, blockClass) {
2511
+ function initCanvasContextObserver(win, blockClass, blockSelector, unblockSelector) {
2482
2512
  const handlers = [];
2483
2513
  try {
2484
2514
  const restoreHandler = patch(win.HTMLCanvasElement.prototype, 'getContext', function (original) {
2485
2515
  return function (contextType, ...args) {
2486
- if (!isBlocked(this, blockClass)) {
2516
+ if (!isBlocked(this, blockClass, blockSelector, unblockSelector)) {
2487
2517
  if (!('__context' in this))
2488
2518
  this.__context = contextType;
2489
2519
  }
@@ -2640,7 +2670,7 @@ const isInstanceOfWebGLObject = (value, win) => {
2640
2670
  return Boolean(supportedWebGLConstructorNames.find((name) => value instanceof win[name]));
2641
2671
  };
2642
2672
 
2643
- function patchGLPrototype(prototype, type, cb, blockClass, mirror, win) {
2673
+ function patchGLPrototype(prototype, type, cb, blockClass, unblockSelector, blockSelector, mirror, win) {
2644
2674
  const handlers = [];
2645
2675
  const props = Object.getOwnPropertyNames(prototype);
2646
2676
  for (const prop of props) {
@@ -2652,7 +2682,7 @@ function patchGLPrototype(prototype, type, cb, blockClass, mirror, win) {
2652
2682
  return function (...args) {
2653
2683
  const result = original.apply(this, args);
2654
2684
  saveWebGLVar(result, win, prototype);
2655
- if (!isBlocked(this.canvas, blockClass)) {
2685
+ if (!isBlocked(this.canvas, blockClass, blockSelector, unblockSelector)) {
2656
2686
  const id = mirror.getId(this.canvas);
2657
2687
  const recordArgs = serializeArgs([...args], win, prototype);
2658
2688
  const mutation = {
@@ -2683,11 +2713,11 @@ function patchGLPrototype(prototype, type, cb, blockClass, mirror, win) {
2683
2713
  }
2684
2714
  return handlers;
2685
2715
  }
2686
- function initCanvasWebGLMutationObserver(cb, win, blockClass, mirror) {
2716
+ function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector, unblockSelector, mirror) {
2687
2717
  const handlers = [];
2688
- handlers.push(...patchGLPrototype(win.WebGLRenderingContext.prototype, CanvasContext.WebGL, cb, blockClass, mirror, win));
2718
+ handlers.push(...patchGLPrototype(win.WebGLRenderingContext.prototype, CanvasContext.WebGL, cb, blockClass, blockSelector, unblockSelector, mirror, win));
2689
2719
  if (typeof win.WebGL2RenderingContext !== 'undefined') {
2690
- handlers.push(...patchGLPrototype(win.WebGL2RenderingContext.prototype, CanvasContext.WebGL2, cb, blockClass, mirror, win));
2720
+ handlers.push(...patchGLPrototype(win.WebGL2RenderingContext.prototype, CanvasContext.WebGL2, cb, blockClass, blockSelector, unblockSelector, mirror, win));
2691
2721
  }
2692
2722
  return () => {
2693
2723
  handlers.forEach((h) => h());
@@ -2729,14 +2759,14 @@ class CanvasManager {
2729
2759
  this.mutationCb = options.mutationCb;
2730
2760
  this.mirror = options.mirror;
2731
2761
  if (options.recordCanvas === true)
2732
- this.initCanvasMutationObserver(options.win, options.blockClass);
2762
+ this.initCanvasMutationObserver(options.win, options.blockClass, options.blockSelector, options.unblockSelector);
2733
2763
  }
2734
- initCanvasMutationObserver(win, blockClass) {
2764
+ initCanvasMutationObserver(win, blockClass, unblockSelector, blockSelector) {
2735
2765
  this.startRAFTimestamping();
2736
2766
  this.startPendingCanvasMutationFlusher();
2737
- const canvasContextReset = initCanvasContextObserver(win, blockClass);
2738
- const canvas2DReset = initCanvas2DMutationObserver(this.processMutation.bind(this), win, blockClass, this.mirror);
2739
- const canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(this.processMutation.bind(this), win, blockClass, this.mirror);
2767
+ const canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, unblockSelector);
2768
+ const canvas2DReset = initCanvas2DMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector, unblockSelector, this.mirror);
2769
+ const canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector, unblockSelector, this.mirror);
2740
2770
  this.resetObservers = () => {
2741
2771
  canvasContextReset();
2742
2772
  canvas2DReset();
@@ -2784,7 +2814,7 @@ let wrappedEmit;
2784
2814
  let takeFullSnapshot;
2785
2815
  const mirror = createMirror();
2786
2816
  function record(options = {}) {
2787
- const { emit, checkoutEveryNms, checkoutEveryNth, blockClass = 'rr-block', blockSelector = null, unblockSelector = null, ignoreClass = 'rr-ignore', ignoreSelector = null, maskTextClass = 'rr-mask', maskTextSelector = null, maskInputSelector = null, unmaskTextSelector = null, unmaskInputSelector = null, inlineStylesheet = true, maskAllInputs, maskInputOptions: _maskInputOptions, slimDOMOptions: _slimDOMOptions, maskInputFn, maskTextFn, hooks, packFn, sampling = {}, mousemoveWait, recordCanvas = false, userTriggeredOnInput = false, collectFonts = false, inlineImages = false, plugins, keepIframeSrcFn = () => false, } = options;
2817
+ const { emit, checkoutEveryNms, checkoutEveryNth, blockClass = 'rr-block', blockSelector = null, unblockSelector = null, ignoreClass = 'rr-ignore', ignoreSelector = null, maskTextClass = 'rr-mask', maskTextSelector = null, maskInputSelector = null, unmaskTextSelector = null, unmaskInputSelector = null, inlineStylesheet = true, maskAllText = false, maskAllInputs, maskInputOptions: _maskInputOptions, slimDOMOptions: _slimDOMOptions, maskInputFn, maskTextFn, hooks, packFn, sampling = {}, mousemoveWait, recordCanvas = false, userTriggeredOnInput = false, collectFonts = false, inlineImages = false, plugins, keepIframeSrcFn = () => false, } = options;
2788
2818
  if (!emit) {
2789
2819
  throw new Error('emit function is required');
2790
2820
  }
@@ -2892,6 +2922,8 @@ function record(options = {}) {
2892
2922
  mutationCb: wrappedCanvasMutationEmit,
2893
2923
  win: window,
2894
2924
  blockClass,
2925
+ blockSelector,
2926
+ unblockSelector,
2895
2927
  mirror,
2896
2928
  });
2897
2929
  const shadowDomManager = new ShadowDomManager({
@@ -2907,6 +2939,7 @@ function record(options = {}) {
2907
2939
  maskInputSelector,
2908
2940
  unmaskInputSelector,
2909
2941
  inlineStylesheet,
2942
+ maskAllText,
2910
2943
  maskInputOptions,
2911
2944
  maskTextFn,
2912
2945
  maskInputFn,
@@ -2940,6 +2973,7 @@ function record(options = {}) {
2940
2973
  maskInputSelector,
2941
2974
  unmaskInputSelector,
2942
2975
  inlineStylesheet,
2976
+ maskAllText,
2943
2977
  maskAllInputs: maskInputOptions,
2944
2978
  maskTextFn,
2945
2979
  slimDOM: slimDOMOptions,
@@ -3050,6 +3084,7 @@ function record(options = {}) {
3050
3084
  userTriggeredOnInput,
3051
3085
  collectFonts,
3052
3086
  doc,
3087
+ maskAllText,
3053
3088
  maskInputFn,
3054
3089
  maskTextFn,
3055
3090
  blockSelector,
@@ -5790,7 +5825,7 @@ function isElectronNodeRenderer() {
5790
5825
  return typeof process !== 'undefined' && (process ).type === 'renderer';
5791
5826
  }
5792
5827
 
5793
- const MEDIA_SELECTORS = 'img,image,svg,path,rect,area,video,object,picture,embed,map,audio';
5828
+ const MEDIA_SELECTORS = 'img,image,svg,video,object,picture,embed,map,audio';
5794
5829
 
5795
5830
  let _initialized = false;
5796
5831
 
@@ -5828,7 +5863,7 @@ class Replay {
5828
5863
  _experiments = {},
5829
5864
  sessionSampleRate,
5830
5865
  errorSampleRate,
5831
- maskAllText,
5866
+ maskAllText = true,
5832
5867
  maskAllInputs = true,
5833
5868
  blockAllMedia = true,
5834
5869
 
@@ -5854,6 +5889,7 @@ class Replay {
5854
5889
  } = {}) {Replay.prototype.__init.call(this);
5855
5890
  this._recordingOptions = {
5856
5891
  maskAllInputs,
5892
+ maskAllText,
5857
5893
  maskInputOptions: { ...(maskInputOptions || {}), password: true },
5858
5894
  maskTextFn: maskFn,
5859
5895
  maskInputFn: maskFn,
@@ -5888,7 +5924,6 @@ class Replay {
5888
5924
  sessionSampleRate,
5889
5925
  errorSampleRate,
5890
5926
  useCompression,
5891
- maskAllText: typeof maskAllText === 'boolean' ? maskAllText : !maskTextSelector,
5892
5927
  blockAllMedia,
5893
5928
  _experiments,
5894
5929
  };
@@ -5917,13 +5952,6 @@ Sentry.init({ replaysOnErrorSampleRate: ${errorSampleRate} })`,
5917
5952
  this._initialOptions.errorSampleRate = errorSampleRate;
5918
5953
  }
5919
5954
 
5920
- if (this._initialOptions.maskAllText) {
5921
- // `maskAllText` is a more user friendly option to configure
5922
- // `maskTextSelector`. This means that all nodes will have their text
5923
- // content masked.
5924
- this._recordingOptions.maskTextSelector = MASK_ALL_TEXT_SELECTOR;
5925
- }
5926
-
5927
5955
  if (this._initialOptions.blockAllMedia) {
5928
5956
  // `blockAllMedia` is a more user friendly option to configure blocking
5929
5957
  // embedded media elements