@posthog/rrweb-record 0.0.40 → 0.0.42

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/dist/index.d.cts CHANGED
@@ -1,5 +1,11 @@
1
1
  import { record } from '@posthog/rrweb';
2
+ import { resetMaxDepthState } from '@posthog/rrweb';
3
+ import { wasMaxDepthReached } from '@posthog/rrweb';
2
4
 
3
5
  export { record }
4
6
 
7
+ export { resetMaxDepthState }
8
+
9
+ export { wasMaxDepthReached }
10
+
5
11
  export { }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,11 @@
1
1
  import { record } from '@posthog/rrweb';
2
+ import { resetMaxDepthState } from '@posthog/rrweb';
3
+ import { wasMaxDepthReached } from '@posthog/rrweb';
2
4
 
3
5
  export { record }
4
6
 
7
+ export { resetMaxDepthState }
8
+
9
+ export { wasMaxDepthReached }
10
+
5
11
  export { }
@@ -1136,6 +1136,16 @@ function slimDOMExcluded(sn, slimDOMOptions) {
1136
1136
  }
1137
1137
  return false;
1138
1138
  }
1139
+ const DEFAULT_MAX_DEPTH = 50;
1140
+ let _maxDepthWarned = false;
1141
+ let _maxDepthReached = false;
1142
+ function wasMaxDepthReached() {
1143
+ return _maxDepthReached;
1144
+ }
1145
+ function resetMaxDepthState() {
1146
+ _maxDepthReached = false;
1147
+ _maxDepthWarned = false;
1148
+ }
1139
1149
  function serializeNodeWithId(n2, options) {
1140
1150
  const {
1141
1151
  doc,
@@ -1159,10 +1169,22 @@ function serializeNodeWithId(n2, options) {
1159
1169
  onStylesheetLoad,
1160
1170
  stylesheetLoadTimeout = 5e3,
1161
1171
  keepIframeSrcFn = () => false,
1162
- newlyAddedElement = false
1172
+ newlyAddedElement = false,
1173
+ depth = 0,
1174
+ maxDepth = DEFAULT_MAX_DEPTH
1163
1175
  } = options;
1164
1176
  let { needsMask } = options;
1165
1177
  let { preserveWhiteSpace = true } = options;
1178
+ if (depth >= maxDepth) {
1179
+ _maxDepthReached = true;
1180
+ if (!_maxDepthWarned) {
1181
+ _maxDepthWarned = true;
1182
+ console.warn(
1183
+ `[rrweb-snapshot] DOM tree depth exceeded max depth of ${maxDepth}. Children beyond this depth will not be recorded. This may indicate deeply nested DOM structures.`
1184
+ );
1185
+ }
1186
+ return null;
1187
+ }
1166
1188
  if (!needsMask) {
1167
1189
  const checkAncestors = needsMask === void 0;
1168
1190
  needsMask = needMaskingText(
@@ -1243,7 +1265,9 @@ function serializeNodeWithId(n2, options) {
1243
1265
  iframeLoadTimeout,
1244
1266
  onStylesheetLoad,
1245
1267
  stylesheetLoadTimeout,
1246
- keepIframeSrcFn
1268
+ keepIframeSrcFn,
1269
+ depth: depth + 1,
1270
+ maxDepth
1247
1271
  };
1248
1272
  if (serializedNode.type === NodeType$1$1.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
1249
1273
  else {
@@ -1298,7 +1322,9 @@ function serializeNodeWithId(n2, options) {
1298
1322
  iframeLoadTimeout,
1299
1323
  onStylesheetLoad,
1300
1324
  stylesheetLoadTimeout,
1301
- keepIframeSrcFn
1325
+ keepIframeSrcFn,
1326
+ depth: depth + 1,
1327
+ maxDepth
1302
1328
  });
1303
1329
  if (serializedIframeNode) {
1304
1330
  onIframeLoad(
@@ -1339,7 +1365,9 @@ function serializeNodeWithId(n2, options) {
1339
1365
  iframeLoadTimeout,
1340
1366
  onStylesheetLoad,
1341
1367
  stylesheetLoadTimeout,
1342
- keepIframeSrcFn
1368
+ keepIframeSrcFn,
1369
+ depth,
1370
+ maxDepth
1343
1371
  });
1344
1372
  if (serializedLinkNode) {
1345
1373
  onStylesheetLoad(
@@ -1375,7 +1403,8 @@ function snapshot(n2, options) {
1375
1403
  iframeLoadTimeout,
1376
1404
  onStylesheetLoad,
1377
1405
  stylesheetLoadTimeout,
1378
- keepIframeSrcFn = () => false
1406
+ keepIframeSrcFn = () => false,
1407
+ maxDepth
1379
1408
  } = options || {};
1380
1409
  const maskInputOptions = maskAllInputs === true ? {
1381
1410
  color: true,
@@ -1436,7 +1465,8 @@ function snapshot(n2, options) {
1436
1465
  onStylesheetLoad,
1437
1466
  stylesheetLoadTimeout,
1438
1467
  keepIframeSrcFn,
1439
- newlyAddedElement: false
1468
+ newlyAddedElement: false,
1469
+ maxDepth
1440
1470
  });
1441
1471
  }
1442
1472
  function getDefaultExportFromCjs$1(x) {
@@ -13174,4 +13204,6 @@ const { addCustomEvent } = record;
13174
13204
  const { freezePage } = record;
13175
13205
  const { takeFullSnapshot } = record;
13176
13206
  exports.record = record;
13207
+ exports.resetMaxDepthState = resetMaxDepthState;
13208
+ exports.wasMaxDepthReached = wasMaxDepthReached;
13177
13209
  //# sourceMappingURL=rrweb-record.cjs.map