@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/cjs/index.js CHANGED
@@ -22,9 +22,6 @@ const VISIBILITY_CHANGE_TIMEOUT = SESSION_IDLE_DURATION;
22
22
  // The maximum length of a session
23
23
  const MAX_SESSION_LIFE = 3600000; // 60 minutes
24
24
 
25
- /** The select to use for the `maskAllText` option */
26
- const MASK_ALL_TEXT_SELECTOR = 'body *:not(style), body *:not(script)';
27
-
28
25
  /** Default flush delays */
29
26
  const DEFAULT_FLUSH_MIN_DELAY = 5000;
30
27
  const DEFAULT_FLUSH_MAX_DELAY = 5000;
@@ -92,6 +89,9 @@ function is2DCanvasBlank(canvas) {
92
89
  let _id = 1;
93
90
  const tagNameRegex = new RegExp('[^a-z0-9-_:]');
94
91
  const IGNORED_NODE = -2;
92
+ function defaultMaskFn(str) {
93
+ return str.replace(/[\S]/g, '*');
94
+ }
95
95
  function genId() {
96
96
  return _id++;
97
97
  }
@@ -260,7 +260,7 @@ function getHref() {
260
260
  a.href = '';
261
261
  return a.href;
262
262
  }
263
- function transformAttribute(doc, tagName, name, value) {
263
+ function transformAttribute(doc, tagName, name, value, maskAllText, maskTextFn) {
264
264
  if (name === 'src' || (name === 'href' && value)) {
265
265
  return absoluteToDoc(doc, value);
266
266
  }
@@ -281,6 +281,9 @@ function transformAttribute(doc, tagName, name, value) {
281
281
  else if (tagName === 'object' && name === 'data' && value) {
282
282
  return absoluteToDoc(doc, value);
283
283
  }
284
+ else if (maskAllText && ['placeholder', 'title', 'aria-label'].indexOf(name) > -1) {
285
+ return maskTextFn ? maskTextFn(value) : defaultMaskFn(value);
286
+ }
284
287
  else {
285
288
  return value;
286
289
  }
@@ -307,41 +310,41 @@ function _isBlockedElement(element, blockClass, blockSelector, unblockSelector)
307
310
  }
308
311
  return false;
309
312
  }
310
- function needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextSelector) {
313
+ function needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextSelector, maskAllText) {
311
314
  if (!node) {
312
315
  return false;
313
316
  }
314
- if (node.nodeType === node.ELEMENT_NODE) {
315
- if (unmaskTextSelector) {
316
- if (node.matches(unmaskTextSelector) ||
317
- node.closest(unmaskTextSelector)) {
318
- return false;
319
- }
320
- }
321
- if (typeof maskTextClass === 'string') {
322
- if (node.classList.contains(maskTextClass)) {
323
- return true;
324
- }
317
+ if (node.nodeType !== node.ELEMENT_NODE) {
318
+ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector, maskAllText);
319
+ }
320
+ if (unmaskTextSelector) {
321
+ if (node.matches(unmaskTextSelector) ||
322
+ node.closest(unmaskTextSelector)) {
323
+ return false;
325
324
  }
326
- else {
327
- for (let eIndex = 0; eIndex < node.classList.length; eIndex++) {
328
- const className = node.classList[eIndex];
329
- if (maskTextClass.test(className)) {
330
- return true;
331
- }
332
- }
325
+ }
326
+ if (maskAllText) {
327
+ return true;
328
+ }
329
+ if (typeof maskTextClass === 'string') {
330
+ if (node.classList.contains(maskTextClass)) {
331
+ return true;
333
332
  }
334
- if (maskTextSelector) {
335
- if (node.matches(maskTextSelector)) {
333
+ }
334
+ else {
335
+ for (let eIndex = 0; eIndex < node.classList.length; eIndex++) {
336
+ const className = node.classList[eIndex];
337
+ if (maskTextClass.test(className)) {
336
338
  return true;
337
339
  }
338
340
  }
339
- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);
340
341
  }
341
- if (node.nodeType === node.TEXT_NODE) {
342
- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);
342
+ if (maskTextSelector) {
343
+ if (node.matches(maskTextSelector)) {
344
+ return true;
345
+ }
343
346
  }
344
- return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector);
347
+ return needMaskingText(node.parentNode, maskTextClass, maskTextSelector, unmaskTextSelector, maskAllText);
345
348
  }
346
349
  function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
347
350
  const win = iframeEl.contentWindow;
@@ -381,7 +384,7 @@ function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
381
384
  }
382
385
  function serializeNode(n, options) {
383
386
  var _a;
384
- const { doc, blockClass, blockSelector, unblockSelector, maskTextClass, maskTextSelector, unmaskTextSelector, inlineStylesheet, maskInputSelector, unmaskInputSelector, maskInputOptions = {}, maskTextFn, maskInputFn, dataURLOptions = {}, inlineImages, recordCanvas, keepIframeSrcFn, } = options;
387
+ const { doc, blockClass, blockSelector, unblockSelector, maskTextClass, maskTextSelector, unmaskTextSelector, inlineStylesheet, maskInputSelector, unmaskInputSelector, maskAllText, maskInputOptions = {}, maskTextFn, maskInputFn, dataURLOptions = {}, inlineImages, recordCanvas, keepIframeSrcFn, } = options;
385
388
  let rootId;
386
389
  if (doc.__sn) {
387
390
  const docId = doc.__sn.id;
@@ -417,7 +420,7 @@ function serializeNode(n, options) {
417
420
  const tagName = getValidTagName(n);
418
421
  let attributes = {};
419
422
  for (const { name, value } of Array.from(n.attributes)) {
420
- attributes[name] = transformAttribute(doc, tagName, name, value);
423
+ attributes[name] = transformAttribute(doc, tagName, name, value, maskAllText, maskTextFn);
421
424
  }
422
425
  if (tagName === 'link' && inlineStylesheet) {
423
426
  const stylesheet = Array.from(doc.styleSheets).find((s) => {
@@ -575,13 +578,25 @@ function serializeNode(n, options) {
575
578
  if (isScript) {
576
579
  textContent = 'SCRIPT_PLACEHOLDER';
577
580
  }
578
- if (!isStyle &&
581
+ if (parentTagName === 'TEXTAREA' && textContent) {
582
+ textContent = maskInputValue({
583
+ input: n.parentNode,
584
+ maskInputSelector,
585
+ unmaskInputSelector,
586
+ maskInputOptions,
587
+ tagName: parentTagName,
588
+ type: null,
589
+ value: textContent,
590
+ maskInputFn,
591
+ });
592
+ }
593
+ else if (!isStyle &&
579
594
  !isScript &&
580
- needMaskingText(n, maskTextClass, maskTextSelector, unmaskTextSelector) &&
595
+ needMaskingText(n, maskTextClass, maskTextSelector, unmaskTextSelector, maskAllText) &&
581
596
  textContent) {
582
597
  textContent = maskTextFn
583
598
  ? maskTextFn(textContent)
584
- : textContent.replace(/[\S]/g, '*');
599
+ : defaultMaskFn(textContent);
585
600
  }
586
601
  return {
587
602
  type: NodeType.Text,
@@ -685,7 +700,7 @@ function slimDOMExcluded(sn, slimDOMOptions) {
685
700
  return false;
686
701
  }
687
702
  function serializeNodeWithId(n, options) {
688
- 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;
703
+ 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;
689
704
  let { preserveWhiteSpace = true } = options;
690
705
  const _serializedNode = serializeNode(n, {
691
706
  doc,
@@ -698,6 +713,7 @@ function serializeNodeWithId(n, options) {
698
713
  inlineStylesheet,
699
714
  maskInputSelector,
700
715
  unmaskInputSelector,
716
+ maskAllText,
701
717
  maskInputOptions,
702
718
  maskTextFn,
703
719
  maskInputFn,
@@ -761,6 +777,7 @@ function serializeNodeWithId(n, options) {
761
777
  inlineStylesheet,
762
778
  maskInputSelector,
763
779
  unmaskInputSelector,
780
+ maskAllText,
764
781
  maskInputOptions,
765
782
  maskTextFn,
766
783
  maskInputFn,
@@ -811,6 +828,7 @@ function serializeNodeWithId(n, options) {
811
828
  inlineStylesheet,
812
829
  maskInputSelector,
813
830
  unmaskInputSelector,
831
+ maskAllText,
814
832
  maskInputOptions,
815
833
  maskTextFn,
816
834
  maskInputFn,
@@ -833,7 +851,7 @@ function serializeNodeWithId(n, options) {
833
851
  return serializedNode;
834
852
  }
835
853
  function snapshot(n, options) {
836
- 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 || {};
854
+ 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 || {};
837
855
  const idNodeMap = {};
838
856
  const maskInputOptions = maskAllInputs === true
839
857
  ? {
@@ -890,6 +908,7 @@ function snapshot(n, options) {
890
908
  inlineStylesheet,
891
909
  maskInputSelector,
892
910
  unmaskInputSelector,
911
+ maskAllText,
893
912
  maskInputOptions,
894
913
  maskTextFn,
895
914
  maskInputFn,
@@ -1128,33 +1147,42 @@ function getWindowWidth() {
1128
1147
  (document.documentElement && document.documentElement.clientWidth) ||
1129
1148
  (document.body && document.body.clientWidth));
1130
1149
  }
1131
- function isBlocked(node, blockClass) {
1150
+ function isBlocked(node, blockClass, blockSelector, unblockSelector) {
1132
1151
  if (!node) {
1133
1152
  return false;
1134
1153
  }
1135
1154
  if (node.nodeType === node.ELEMENT_NODE) {
1136
1155
  let needBlock = false;
1156
+ const needUnblock = unblockSelector && node.matches(unblockSelector);
1137
1157
  if (typeof blockClass === 'string') {
1138
1158
  if (node.closest !== undefined) {
1139
- return node.closest('.' + blockClass) !== null;
1159
+ needBlock =
1160
+ !needUnblock &&
1161
+ node.closest('.' + blockClass) !== null;
1140
1162
  }
1141
1163
  else {
1142
- needBlock = node.classList.contains(blockClass);
1164
+ needBlock =
1165
+ !needUnblock && node.classList.contains(blockClass);
1143
1166
  }
1144
1167
  }
1145
1168
  else {
1146
- node.classList.forEach((className) => {
1147
- if (blockClass.test(className)) {
1148
- needBlock = true;
1149
- }
1150
- });
1169
+ !needUnblock &&
1170
+ node.classList.forEach((className) => {
1171
+ if (blockClass.test(className)) {
1172
+ needBlock = true;
1173
+ }
1174
+ });
1175
+ }
1176
+ if (!needBlock && blockSelector) {
1177
+ needBlock = node.matches(blockSelector);
1151
1178
  }
1152
- return needBlock || isBlocked(node.parentNode, blockClass);
1179
+ return ((!needUnblock && needBlock) ||
1180
+ isBlocked(node.parentNode, blockClass, blockSelector, unblockSelector));
1153
1181
  }
1154
1182
  if (node.nodeType === node.TEXT_NODE) {
1155
- return isBlocked(node.parentNode, blockClass);
1183
+ return isBlocked(node.parentNode, blockClass, blockSelector, unblockSelector);
1156
1184
  }
1157
- return isBlocked(node.parentNode, blockClass);
1185
+ return isBlocked(node.parentNode, blockClass, blockSelector, unblockSelector);
1158
1186
  }
1159
1187
  function isIgnored(n) {
1160
1188
  if ('__sn' in n) {
@@ -1362,6 +1390,7 @@ class MutationBuffer {
1362
1390
  unmaskInputSelector: this.unmaskInputSelector,
1363
1391
  skipChild: true,
1364
1392
  inlineStylesheet: this.inlineStylesheet,
1393
+ maskAllText: this.maskAllText,
1365
1394
  maskInputOptions: this.maskInputOptions,
1366
1395
  maskTextFn: this.maskTextFn,
1367
1396
  maskInputFn: this.maskInputFn,
@@ -1482,9 +1511,9 @@ class MutationBuffer {
1482
1511
  switch (m.type) {
1483
1512
  case 'characterData': {
1484
1513
  const value = m.target.textContent;
1485
- if (!isBlocked(m.target, this.blockClass) && value !== m.oldValue) {
1514
+ if (!isBlocked(m.target, this.blockClass, this.blockSelector, this.unblockSelector) && value !== m.oldValue) {
1486
1515
  this.texts.push({
1487
- value: needMaskingText(m.target, this.maskTextClass, this.maskTextSelector, this.unmaskTextSelector) && value
1516
+ value: needMaskingText(m.target, this.maskTextClass, this.maskTextSelector, this.unmaskTextSelector, this.maskAllText) && value
1488
1517
  ? this.maskTextFn
1489
1518
  ? this.maskTextFn(value)
1490
1519
  : value.replace(/[\S]/g, '*')
@@ -1509,7 +1538,7 @@ class MutationBuffer {
1509
1538
  maskInputFn: this.maskInputFn,
1510
1539
  });
1511
1540
  }
1512
- if (isBlocked(m.target, this.blockClass) || value === m.oldValue) {
1541
+ if (isBlocked(m.target, this.blockClass, this.blockSelector, this.unblockSelector) || value === m.oldValue) {
1513
1542
  return;
1514
1543
  }
1515
1544
  let item = this.attributes.find((a) => a.node === m.target);
@@ -1555,7 +1584,7 @@ class MutationBuffer {
1555
1584
  }
1556
1585
  }
1557
1586
  else {
1558
- item.attributes[m.attributeName] = transformAttribute(this.doc, m.target.tagName, m.attributeName, value);
1587
+ item.attributes[m.attributeName] = transformAttribute(this.doc, m.target.tagName, m.attributeName, value, this.maskAllText, this.maskTextFn);
1559
1588
  }
1560
1589
  break;
1561
1590
  }
@@ -1566,7 +1595,7 @@ class MutationBuffer {
1566
1595
  const parentId = isShadowRoot(m.target)
1567
1596
  ? this.mirror.getId(m.target.host)
1568
1597
  : this.mirror.getId(m.target);
1569
- if (isBlocked(m.target, this.blockClass) || isIgnored(n)) {
1598
+ if (isBlocked(m.target, this.blockClass, this.blockSelector, this.unblockSelector) || isIgnored(n)) {
1570
1599
  return;
1571
1600
  }
1572
1601
  if (this.addedSet.has(n)) {
@@ -1593,7 +1622,7 @@ class MutationBuffer {
1593
1622
  }
1594
1623
  };
1595
1624
  this.genAdds = (n, target) => {
1596
- if (target && isBlocked(target, this.blockClass)) {
1625
+ if (target && isBlocked(target, this.blockClass, this.blockSelector, this.unblockSelector)) {
1597
1626
  return;
1598
1627
  }
1599
1628
  if (isINode(n)) {
@@ -1613,7 +1642,7 @@ class MutationBuffer {
1613
1642
  this.addedSet.add(n);
1614
1643
  this.droppedSet.delete(n);
1615
1644
  }
1616
- if (!isBlocked(n, this.blockClass))
1645
+ if (!isBlocked(n, this.blockClass, this.blockSelector, this.unblockSelector))
1617
1646
  n.childNodes.forEach((childN) => this.genAdds(childN));
1618
1647
  };
1619
1648
  }
@@ -1629,6 +1658,7 @@ class MutationBuffer {
1629
1658
  'maskInputSelector',
1630
1659
  'unmaskInputSelector',
1631
1660
  'inlineStylesheet',
1661
+ 'maskAllText',
1632
1662
  'maskInputOptions',
1633
1663
  'maskTextFn',
1634
1664
  'maskInputFn',
@@ -1802,7 +1832,7 @@ function initMoveObserver({ mousemoveCb, sampling, doc, mirror, }) {
1802
1832
  handlers.forEach((h) => h());
1803
1833
  });
1804
1834
  }
1805
- function initMouseInteractionObserver({ mouseInteractionCb, doc, mirror, blockClass, sampling, }) {
1835
+ function initMouseInteractionObserver({ mouseInteractionCb, doc, mirror, blockClass, blockSelector, unblockSelector, sampling, }) {
1806
1836
  if (sampling.mouseInteraction === false) {
1807
1837
  return () => { };
1808
1838
  }
@@ -1814,7 +1844,7 @@ function initMouseInteractionObserver({ mouseInteractionCb, doc, mirror, blockCl
1814
1844
  const getHandler = (eventKey) => {
1815
1845
  return (event) => {
1816
1846
  const target = getEventTarget(event);
1817
- if (isBlocked(target, blockClass)) {
1847
+ if (isBlocked(target, blockClass, blockSelector, unblockSelector)) {
1818
1848
  return;
1819
1849
  }
1820
1850
  const e = isTouchEvent(event) ? event.changedTouches[0] : event;
@@ -1844,10 +1874,10 @@ function initMouseInteractionObserver({ mouseInteractionCb, doc, mirror, blockCl
1844
1874
  handlers.forEach((h) => h());
1845
1875
  });
1846
1876
  }
1847
- function initScrollObserver({ scrollCb, doc, mirror, blockClass, sampling, }) {
1877
+ function initScrollObserver({ scrollCb, doc, mirror, blockClass, blockSelector, unblockSelector, sampling, }) {
1848
1878
  const updatePosition = throttle((evt) => {
1849
1879
  const target = getEventTarget(evt);
1850
- if (!target || isBlocked(target, blockClass)) {
1880
+ if (!target || isBlocked(target, blockClass, blockSelector, unblockSelector)) {
1851
1881
  return;
1852
1882
  }
1853
1883
  const id = mirror.getId(target);
@@ -1894,7 +1924,7 @@ function wrapEventWithUserTriggeredFlag(v, enable) {
1894
1924
  }
1895
1925
  const INPUT_TAGS = ['INPUT', 'TEXTAREA', 'SELECT'];
1896
1926
  const lastInputValueMap = new WeakMap();
1897
- function initInputObserver({ inputCb, doc, mirror, blockClass, ignoreClass, ignoreSelector, maskInputSelector, unmaskInputSelector, maskInputOptions, maskInputFn, sampling, userTriggeredOnInput, }) {
1927
+ function initInputObserver({ inputCb, doc, mirror, blockClass, blockSelector, unblockSelector, ignoreClass, ignoreSelector, maskInputSelector, unmaskInputSelector, maskInputOptions, maskInputFn, sampling, userTriggeredOnInput, }) {
1898
1928
  function eventHandler(event) {
1899
1929
  let target = getEventTarget(event);
1900
1930
  const userTriggered = event.isTrusted;
@@ -1903,7 +1933,7 @@ function initInputObserver({ inputCb, doc, mirror, blockClass, ignoreClass, igno
1903
1933
  if (!target ||
1904
1934
  !target.tagName ||
1905
1935
  INPUT_TAGS.indexOf(target.tagName) < 0 ||
1906
- isBlocked(target, blockClass)) {
1936
+ isBlocked(target, blockClass, blockSelector, unblockSelector)) {
1907
1937
  return;
1908
1938
  }
1909
1939
  const type = target.type;
@@ -2144,10 +2174,10 @@ function initStyleDeclarationObserver({ styleDeclarationCb, mirror }, { win }) {
2144
2174
  win.CSSStyleDeclaration.prototype.removeProperty = removeProperty;
2145
2175
  });
2146
2176
  }
2147
- function initMediaInteractionObserver({ mediaInteractionCb, blockClass, mirror, sampling, }) {
2177
+ function initMediaInteractionObserver({ mediaInteractionCb, blockClass, blockSelector, unblockSelector, mirror, sampling, }) {
2148
2178
  const handler = (type) => throttle(callbackWrapper((event) => {
2149
2179
  const target = getEventTarget(event);
2150
- if (!target || isBlocked(target, blockClass)) {
2180
+ if (!target || isBlocked(target, blockClass, blockSelector, unblockSelector)) {
2151
2181
  return;
2152
2182
  }
2153
2183
  const { currentTime, volume, muted } = target;
@@ -2426,7 +2456,7 @@ function __rest(s, e) {
2426
2456
  return t;
2427
2457
  }
2428
2458
 
2429
- function initCanvas2DMutationObserver(cb, win, blockClass, mirror) {
2459
+ function initCanvas2DMutationObserver(cb, win, blockClass, unblockSelector, blockSelector, mirror) {
2430
2460
  const handlers = [];
2431
2461
  const props2D = Object.getOwnPropertyNames(win.CanvasRenderingContext2D.prototype);
2432
2462
  for (const prop of props2D) {
@@ -2436,7 +2466,7 @@ function initCanvas2DMutationObserver(cb, win, blockClass, mirror) {
2436
2466
  }
2437
2467
  const restoreHandler = patch(win.CanvasRenderingContext2D.prototype, prop, function (original) {
2438
2468
  return function (...args) {
2439
- if (!isBlocked(this.canvas, blockClass)) {
2469
+ if (!isBlocked(this.canvas, blockClass, blockSelector, unblockSelector)) {
2440
2470
  setTimeout(() => {
2441
2471
  const recordArgs = [...args];
2442
2472
  if (prop === 'drawImage') {
@@ -2480,12 +2510,12 @@ function initCanvas2DMutationObserver(cb, win, blockClass, mirror) {
2480
2510
  };
2481
2511
  }
2482
2512
 
2483
- function initCanvasContextObserver(win, blockClass) {
2513
+ function initCanvasContextObserver(win, blockClass, blockSelector, unblockSelector) {
2484
2514
  const handlers = [];
2485
2515
  try {
2486
2516
  const restoreHandler = patch(win.HTMLCanvasElement.prototype, 'getContext', function (original) {
2487
2517
  return function (contextType, ...args) {
2488
- if (!isBlocked(this, blockClass)) {
2518
+ if (!isBlocked(this, blockClass, blockSelector, unblockSelector)) {
2489
2519
  if (!('__context' in this))
2490
2520
  this.__context = contextType;
2491
2521
  }
@@ -2642,7 +2672,7 @@ const isInstanceOfWebGLObject = (value, win) => {
2642
2672
  return Boolean(supportedWebGLConstructorNames.find((name) => value instanceof win[name]));
2643
2673
  };
2644
2674
 
2645
- function patchGLPrototype(prototype, type, cb, blockClass, mirror, win) {
2675
+ function patchGLPrototype(prototype, type, cb, blockClass, unblockSelector, blockSelector, mirror, win) {
2646
2676
  const handlers = [];
2647
2677
  const props = Object.getOwnPropertyNames(prototype);
2648
2678
  for (const prop of props) {
@@ -2654,7 +2684,7 @@ function patchGLPrototype(prototype, type, cb, blockClass, mirror, win) {
2654
2684
  return function (...args) {
2655
2685
  const result = original.apply(this, args);
2656
2686
  saveWebGLVar(result, win, prototype);
2657
- if (!isBlocked(this.canvas, blockClass)) {
2687
+ if (!isBlocked(this.canvas, blockClass, blockSelector, unblockSelector)) {
2658
2688
  const id = mirror.getId(this.canvas);
2659
2689
  const recordArgs = serializeArgs([...args], win, prototype);
2660
2690
  const mutation = {
@@ -2685,11 +2715,11 @@ function patchGLPrototype(prototype, type, cb, blockClass, mirror, win) {
2685
2715
  }
2686
2716
  return handlers;
2687
2717
  }
2688
- function initCanvasWebGLMutationObserver(cb, win, blockClass, mirror) {
2718
+ function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector, unblockSelector, mirror) {
2689
2719
  const handlers = [];
2690
- handlers.push(...patchGLPrototype(win.WebGLRenderingContext.prototype, CanvasContext.WebGL, cb, blockClass, mirror, win));
2720
+ handlers.push(...patchGLPrototype(win.WebGLRenderingContext.prototype, CanvasContext.WebGL, cb, blockClass, blockSelector, unblockSelector, mirror, win));
2691
2721
  if (typeof win.WebGL2RenderingContext !== 'undefined') {
2692
- handlers.push(...patchGLPrototype(win.WebGL2RenderingContext.prototype, CanvasContext.WebGL2, cb, blockClass, mirror, win));
2722
+ handlers.push(...patchGLPrototype(win.WebGL2RenderingContext.prototype, CanvasContext.WebGL2, cb, blockClass, blockSelector, unblockSelector, mirror, win));
2693
2723
  }
2694
2724
  return () => {
2695
2725
  handlers.forEach((h) => h());
@@ -2731,14 +2761,14 @@ class CanvasManager {
2731
2761
  this.mutationCb = options.mutationCb;
2732
2762
  this.mirror = options.mirror;
2733
2763
  if (options.recordCanvas === true)
2734
- this.initCanvasMutationObserver(options.win, options.blockClass);
2764
+ this.initCanvasMutationObserver(options.win, options.blockClass, options.blockSelector, options.unblockSelector);
2735
2765
  }
2736
- initCanvasMutationObserver(win, blockClass) {
2766
+ initCanvasMutationObserver(win, blockClass, unblockSelector, blockSelector) {
2737
2767
  this.startRAFTimestamping();
2738
2768
  this.startPendingCanvasMutationFlusher();
2739
- const canvasContextReset = initCanvasContextObserver(win, blockClass);
2740
- const canvas2DReset = initCanvas2DMutationObserver(this.processMutation.bind(this), win, blockClass, this.mirror);
2741
- const canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(this.processMutation.bind(this), win, blockClass, this.mirror);
2769
+ const canvasContextReset = initCanvasContextObserver(win, blockClass, blockSelector, unblockSelector);
2770
+ const canvas2DReset = initCanvas2DMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector, unblockSelector, this.mirror);
2771
+ const canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(this.processMutation.bind(this), win, blockClass, blockSelector, unblockSelector, this.mirror);
2742
2772
  this.resetObservers = () => {
2743
2773
  canvasContextReset();
2744
2774
  canvas2DReset();
@@ -2786,7 +2816,7 @@ let wrappedEmit;
2786
2816
  let takeFullSnapshot;
2787
2817
  const mirror = createMirror();
2788
2818
  function record(options = {}) {
2789
- 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;
2819
+ 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;
2790
2820
  if (!emit) {
2791
2821
  throw new Error('emit function is required');
2792
2822
  }
@@ -2894,6 +2924,8 @@ function record(options = {}) {
2894
2924
  mutationCb: wrappedCanvasMutationEmit,
2895
2925
  win: window,
2896
2926
  blockClass,
2927
+ blockSelector,
2928
+ unblockSelector,
2897
2929
  mirror,
2898
2930
  });
2899
2931
  const shadowDomManager = new ShadowDomManager({
@@ -2909,6 +2941,7 @@ function record(options = {}) {
2909
2941
  maskInputSelector,
2910
2942
  unmaskInputSelector,
2911
2943
  inlineStylesheet,
2944
+ maskAllText,
2912
2945
  maskInputOptions,
2913
2946
  maskTextFn,
2914
2947
  maskInputFn,
@@ -2942,6 +2975,7 @@ function record(options = {}) {
2942
2975
  maskInputSelector,
2943
2976
  unmaskInputSelector,
2944
2977
  inlineStylesheet,
2978
+ maskAllText,
2945
2979
  maskAllInputs: maskInputOptions,
2946
2980
  maskTextFn,
2947
2981
  slimDOM: slimDOMOptions,
@@ -3052,6 +3086,7 @@ function record(options = {}) {
3052
3086
  userTriggeredOnInput,
3053
3087
  collectFonts,
3054
3088
  doc,
3089
+ maskAllText,
3055
3090
  maskInputFn,
3056
3091
  maskTextFn,
3057
3092
  blockSelector,
@@ -5792,7 +5827,7 @@ function isElectronNodeRenderer() {
5792
5827
  return typeof process !== 'undefined' && (process ).type === 'renderer';
5793
5828
  }
5794
5829
 
5795
- const MEDIA_SELECTORS = 'img,image,svg,path,rect,area,video,object,picture,embed,map,audio';
5830
+ const MEDIA_SELECTORS = 'img,image,svg,video,object,picture,embed,map,audio';
5796
5831
 
5797
5832
  let _initialized = false;
5798
5833
 
@@ -5830,7 +5865,7 @@ class Replay {
5830
5865
  _experiments = {},
5831
5866
  sessionSampleRate,
5832
5867
  errorSampleRate,
5833
- maskAllText,
5868
+ maskAllText = true,
5834
5869
  maskAllInputs = true,
5835
5870
  blockAllMedia = true,
5836
5871
 
@@ -5856,6 +5891,7 @@ class Replay {
5856
5891
  } = {}) {Replay.prototype.__init.call(this);
5857
5892
  this._recordingOptions = {
5858
5893
  maskAllInputs,
5894
+ maskAllText,
5859
5895
  maskInputOptions: { ...(maskInputOptions || {}), password: true },
5860
5896
  maskTextFn: maskFn,
5861
5897
  maskInputFn: maskFn,
@@ -5890,7 +5926,6 @@ class Replay {
5890
5926
  sessionSampleRate,
5891
5927
  errorSampleRate,
5892
5928
  useCompression,
5893
- maskAllText: typeof maskAllText === 'boolean' ? maskAllText : !maskTextSelector,
5894
5929
  blockAllMedia,
5895
5930
  _experiments,
5896
5931
  };
@@ -5919,13 +5954,6 @@ Sentry.init({ replaysOnErrorSampleRate: ${errorSampleRate} })`,
5919
5954
  this._initialOptions.errorSampleRate = errorSampleRate;
5920
5955
  }
5921
5956
 
5922
- if (this._initialOptions.maskAllText) {
5923
- // `maskAllText` is a more user friendly option to configure
5924
- // `maskTextSelector`. This means that all nodes will have their text
5925
- // content masked.
5926
- this._recordingOptions.maskTextSelector = MASK_ALL_TEXT_SELECTOR;
5927
- }
5928
-
5929
5957
  if (this._initialOptions.blockAllMedia) {
5930
5958
  // `blockAllMedia` is a more user friendly option to configure blocking
5931
5959
  // embedded media elements