mixpanel-browser 2.71.0 → 2.72.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.
Files changed (39) hide show
  1. package/.claude/settings.local.json +9 -0
  2. package/.github/workflows/tests.yml +1 -0
  3. package/CHANGELOG.md +10 -0
  4. package/dist/mixpanel-core.cjs.d.ts +47 -10
  5. package/dist/mixpanel-core.cjs.js +57 -21
  6. package/dist/mixpanel-recorder.js +681 -113
  7. package/dist/mixpanel-recorder.min.js +1 -1
  8. package/dist/mixpanel-recorder.min.js.map +1 -1
  9. package/dist/mixpanel-with-async-recorder.cjs.d.ts +47 -10
  10. package/dist/mixpanel-with-async-recorder.cjs.js +57 -21
  11. package/dist/mixpanel-with-recorder.d.ts +47 -10
  12. package/dist/mixpanel-with-recorder.js +737 -133
  13. package/dist/mixpanel-with-recorder.min.d.ts +47 -10
  14. package/dist/mixpanel-with-recorder.min.js +1 -1
  15. package/dist/mixpanel.amd.d.ts +47 -10
  16. package/dist/mixpanel.amd.js +737 -133
  17. package/dist/mixpanel.cjs.d.ts +47 -10
  18. package/dist/mixpanel.cjs.js +737 -133
  19. package/dist/mixpanel.globals.js +57 -21
  20. package/dist/mixpanel.min.js +149 -149
  21. package/dist/mixpanel.module.d.ts +47 -10
  22. package/dist/mixpanel.module.js +737 -133
  23. package/dist/mixpanel.umd.d.ts +47 -10
  24. package/dist/mixpanel.umd.js +737 -133
  25. package/dist/rrweb-bundled.js +12760 -0
  26. package/dist/rrweb-compiled.js +2496 -7176
  27. package/package.json +3 -2
  28. package/rollup.config.mjs +15 -4
  29. package/src/autocapture/index.js +7 -5
  30. package/src/autocapture/rageclick.js +20 -1
  31. package/src/autocapture/shadow-dom-observer.js +3 -15
  32. package/src/autocapture/utils.js +30 -0
  33. package/src/config.js +1 -1
  34. package/src/index.d.ts +47 -10
  35. package/src/mixpanel-core.js +1 -0
  36. package/src/recorder/recorder.js +1 -1
  37. package/src/recorder/rrweb-entrypoint.js +6 -0
  38. package/src/recorder/session-recording.js +69 -12
  39. package/src/utils.js +24 -0
@@ -328,30 +328,30 @@
328
328
  };
329
329
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
330
330
  }
331
- var __defProp = Object.defineProperty;
332
- var __defNormalProp = function(obj, key, value) {
333
- return key in obj ? __defProp(obj, key, {
331
+ var __defProp$1 = Object.defineProperty;
332
+ var __defNormalProp$1 = function(obj, key, value) {
333
+ return key in obj ? __defProp$1(obj, key, {
334
334
  enumerable: true,
335
335
  configurable: true,
336
336
  writable: true,
337
337
  value: value
338
338
  }) : obj[key] = value;
339
339
  };
340
- var __publicField = function(obj, key, value) {
341
- return __defNormalProp(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
340
+ var __publicField$1 = function(obj, key, value) {
341
+ return __defNormalProp$1(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
342
342
  };
343
343
  var _a;
344
- var __defProp$1 = Object.defineProperty;
345
- var __defNormalProp$1 = function(obj, key, value) {
346
- return key in obj ? __defProp$1(obj, key, {
344
+ var __defProp$1$1 = Object.defineProperty;
345
+ var __defNormalProp$1$1 = function(obj, key, value) {
346
+ return key in obj ? __defProp$1$1(obj, key, {
347
347
  enumerable: true,
348
348
  configurable: true,
349
349
  writable: true,
350
350
  value: value
351
351
  }) : obj[key] = value;
352
352
  };
353
- var __publicField$1 = function(obj, key, value) {
354
- return __defNormalProp$1(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
353
+ var __publicField$1$1 = function(obj, key, value) {
354
+ return __defNormalProp$1$1(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
355
355
  };
356
356
  var NodeType$3 = /* @__PURE__ */ function(NodeType2) {
357
357
  NodeType2[NodeType2["Document"] = 0] = "Document";
@@ -621,8 +621,8 @@
621
621
  }
622
622
  var Mirror = /*#__PURE__*/ function() {
623
623
  function Mirror() {
624
- __publicField$1(this, "idNodeMap", /* @__PURE__ */ new Map());
625
- __publicField$1(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap());
624
+ __publicField$1$1(this, "idNodeMap", /* @__PURE__ */ new Map());
625
+ __publicField$1$1(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap());
626
626
  }
627
627
  var _proto = Mirror.prototype;
628
628
  _proto.getId = function getId(n2) {
@@ -2506,7 +2506,8 @@
2506
2506
  return id;
2507
2507
  };
2508
2508
  var nonSecure$1 = {
2509
- nanoid: nanoid$1$1};
2509
+ nanoid: nanoid$1$1
2510
+ };
2510
2511
  var SourceMapConsumer$2$1 = require$$2$1.SourceMapConsumer, SourceMapGenerator$2$1 = require$$2$1.SourceMapGenerator;
2511
2512
  var existsSync$1 = require$$2$1.existsSync, readFileSync$1 = require$$2$1.readFileSync;
2512
2513
  var dirname$1$1 = require$$2$1.dirname, join$1 = require$$2$1.join;
@@ -6657,7 +6658,8 @@
6657
6658
  return id;
6658
6659
  };
6659
6660
  var nonSecure = {
6660
- nanoid: nanoid$1};
6661
+ nanoid: nanoid$1
6662
+ };
6661
6663
  var SourceMapConsumer$2 = require$$2.SourceMapConsumer, SourceMapGenerator$2 = require$$2.SourceMapGenerator;
6662
6664
  var existsSync = require$$2.existsSync, readFileSync = require$$2.readFileSync;
6663
6665
  var dirname$1 = require$$2.dirname, join = require$$2.join;
@@ -9817,7 +9819,7 @@
9817
9819
  var LazyResult22 = lazyResult;
9818
9820
  var Container22 = container;
9819
9821
  var Processor22 = processor;
9820
- var stringify = stringify_1;
9822
+ var stringify$6 = stringify_1;
9821
9823
  var fromJSON = fromJSON_1;
9822
9824
  var Document222 = document$1$2;
9823
9825
  var Warning22 = warning;
@@ -9871,7 +9873,7 @@
9871
9873
  };
9872
9874
  return creator;
9873
9875
  };
9874
- postcss.stringify = stringify;
9876
+ postcss.stringify = stringify$6;
9875
9877
  postcss.parse = parse;
9876
9878
  postcss.fromJSON = fromJSON;
9877
9879
  postcss.list = list;
@@ -10121,7 +10123,7 @@
10121
10123
  function mutationObserverCtor() {
10122
10124
  return getUntaintedPrototype("MutationObserver").constructor;
10123
10125
  }
10124
- function patch(source, name, replacement) {
10126
+ function patch$2(source, name, replacement) {
10125
10127
  try {
10126
10128
  if (!(name in source)) {
10127
10129
  return function() {};
@@ -10158,7 +10160,7 @@
10158
10160
  querySelector: querySelector,
10159
10161
  querySelectorAll: querySelectorAll,
10160
10162
  mutationObserver: mutationObserverCtor,
10161
- patch: patch
10163
+ patch: patch$2
10162
10164
  };
10163
10165
  function on(type, fn, target) {
10164
10166
  if (target === void 0) target = document;
@@ -10353,9 +10355,9 @@
10353
10355
  }
10354
10356
  var StyleSheetMirror = /*#__PURE__*/ function() {
10355
10357
  function StyleSheetMirror() {
10356
- __publicField(this, "id", 1);
10357
- __publicField(this, "styleIDMap", /* @__PURE__ */ new WeakMap());
10358
- __publicField(this, "idStyleMap", /* @__PURE__ */ new Map());
10358
+ __publicField$1(this, "id", 1);
10359
+ __publicField$1(this, "styleIDMap", /* @__PURE__ */ new WeakMap());
10360
+ __publicField$1(this, "idStyleMap", /* @__PURE__ */ new Map());
10359
10361
  }
10360
10362
  var _proto = StyleSheetMirror.prototype;
10361
10363
  _proto.getId = function getId(stylesheet) {
@@ -10491,9 +10493,9 @@
10491
10493
  }
10492
10494
  var DoubleLinkedList = /*#__PURE__*/ function() {
10493
10495
  function DoubleLinkedList() {
10494
- __publicField(this, "length", 0);
10495
- __publicField(this, "head", null);
10496
- __publicField(this, "tail", null);
10496
+ __publicField$1(this, "length", 0);
10497
+ __publicField$1(this, "head", null);
10498
+ __publicField$1(this, "tail", null);
10497
10499
  }
10498
10500
  var _proto = DoubleLinkedList.prototype;
10499
10501
  _proto.get = function get(position) {
@@ -10574,14 +10576,14 @@
10574
10576
  var MutationBuffer = /*#__PURE__*/ function() {
10575
10577
  function MutationBuffer() {
10576
10578
  var _this = this;
10577
- __publicField(this, "frozen", false);
10578
- __publicField(this, "locked", false);
10579
- __publicField(this, "texts", []);
10580
- __publicField(this, "attributes", []);
10581
- __publicField(this, "attributeMap", /* @__PURE__ */ new WeakMap());
10582
- __publicField(this, "removes", []);
10583
- __publicField(this, "mapRemoves", []);
10584
- __publicField(this, "movedMap", {});
10579
+ __publicField$1(this, "frozen", false);
10580
+ __publicField$1(this, "locked", false);
10581
+ __publicField$1(this, "texts", []);
10582
+ __publicField$1(this, "attributes", []);
10583
+ __publicField$1(this, "attributeMap", /* @__PURE__ */ new WeakMap());
10584
+ __publicField$1(this, "removes", []);
10585
+ __publicField$1(this, "mapRemoves", []);
10586
+ __publicField$1(this, "movedMap", {});
10585
10587
  /**
10586
10588
  * the browser MutationObserver emits multiple mutations after
10587
10589
  * a delay for performance reasons, making tracing added nodes hard
@@ -10598,37 +10600,37 @@
10598
10600
  * collect added nodes from the Set which have no duplicate copy. But
10599
10601
  * this also causes newly added nodes will not be serialized with id ASAP,
10600
10602
  * which means all the id related calculation should be lazy too.
10601
- */ __publicField(this, "addedSet", /* @__PURE__ */ new Set());
10602
- __publicField(this, "movedSet", /* @__PURE__ */ new Set());
10603
- __publicField(this, "droppedSet", /* @__PURE__ */ new Set());
10604
- __publicField(this, "removesSubTreeCache", /* @__PURE__ */ new Set());
10605
- __publicField(this, "mutationCb");
10606
- __publicField(this, "blockClass");
10607
- __publicField(this, "blockSelector");
10608
- __publicField(this, "maskTextClass");
10609
- __publicField(this, "maskTextSelector");
10610
- __publicField(this, "inlineStylesheet");
10611
- __publicField(this, "maskInputOptions");
10612
- __publicField(this, "maskTextFn");
10613
- __publicField(this, "maskInputFn");
10614
- __publicField(this, "keepIframeSrcFn");
10615
- __publicField(this, "recordCanvas");
10616
- __publicField(this, "inlineImages");
10617
- __publicField(this, "slimDOMOptions");
10618
- __publicField(this, "dataURLOptions");
10619
- __publicField(this, "doc");
10620
- __publicField(this, "mirror");
10621
- __publicField(this, "iframeManager");
10622
- __publicField(this, "stylesheetManager");
10623
- __publicField(this, "shadowDomManager");
10624
- __publicField(this, "canvasManager");
10625
- __publicField(this, "processedNodeManager");
10626
- __publicField(this, "unattachedDoc");
10627
- __publicField(this, "processMutations", function(mutations) {
10603
+ */ __publicField$1(this, "addedSet", /* @__PURE__ */ new Set());
10604
+ __publicField$1(this, "movedSet", /* @__PURE__ */ new Set());
10605
+ __publicField$1(this, "droppedSet", /* @__PURE__ */ new Set());
10606
+ __publicField$1(this, "removesSubTreeCache", /* @__PURE__ */ new Set());
10607
+ __publicField$1(this, "mutationCb");
10608
+ __publicField$1(this, "blockClass");
10609
+ __publicField$1(this, "blockSelector");
10610
+ __publicField$1(this, "maskTextClass");
10611
+ __publicField$1(this, "maskTextSelector");
10612
+ __publicField$1(this, "inlineStylesheet");
10613
+ __publicField$1(this, "maskInputOptions");
10614
+ __publicField$1(this, "maskTextFn");
10615
+ __publicField$1(this, "maskInputFn");
10616
+ __publicField$1(this, "keepIframeSrcFn");
10617
+ __publicField$1(this, "recordCanvas");
10618
+ __publicField$1(this, "inlineImages");
10619
+ __publicField$1(this, "slimDOMOptions");
10620
+ __publicField$1(this, "dataURLOptions");
10621
+ __publicField$1(this, "doc");
10622
+ __publicField$1(this, "mirror");
10623
+ __publicField$1(this, "iframeManager");
10624
+ __publicField$1(this, "stylesheetManager");
10625
+ __publicField$1(this, "shadowDomManager");
10626
+ __publicField$1(this, "canvasManager");
10627
+ __publicField$1(this, "processedNodeManager");
10628
+ __publicField$1(this, "unattachedDoc");
10629
+ __publicField$1(this, "processMutations", function(mutations) {
10628
10630
  mutations.forEach(_this.processMutation);
10629
10631
  _this.emit();
10630
10632
  });
10631
- __publicField(this, "emit", function() {
10633
+ __publicField$1(this, "emit", function() {
10632
10634
  if (_this.frozen || _this.locked) {
10633
10635
  return;
10634
10636
  }
@@ -10829,7 +10831,7 @@
10829
10831
  _this.movedMap = {};
10830
10832
  _this.mutationCb(payload);
10831
10833
  });
10832
- __publicField(this, "genTextAreaValueMutation", function(textarea) {
10834
+ __publicField$1(this, "genTextAreaValueMutation", function(textarea) {
10833
10835
  var item = _this.attributeMap.get(textarea);
10834
10836
  if (!item) {
10835
10837
  item = {
@@ -10853,7 +10855,7 @@
10853
10855
  maskInputFn: _this.maskInputFn
10854
10856
  });
10855
10857
  });
10856
- __publicField(this, "processMutation", function(m) {
10858
+ __publicField$1(this, "processMutation", function(m) {
10857
10859
  if (isIgnored(m.target, _this.mirror, _this.slimDOMOptions)) {
10858
10860
  return;
10859
10861
  }
@@ -10998,7 +11000,7 @@
10998
11000
  });
10999
11001
  /**
11000
11002
  * Make sure you check if `n`'s parent is blocked before calling this function
11001
- * */ __publicField(this, "genAdds", function(n2, target) {
11003
+ * */ __publicField$1(this, "genAdds", function(n2, target) {
11002
11004
  if (_this.processedNodeManager.inOtherBuffer(n2, _this)) return;
11003
11005
  if (_this.addedSet.has(n2) || _this.movedSet.has(n2)) return;
11004
11006
  if (_this.mirror.hasNode(n2)) {
@@ -11844,7 +11846,7 @@
11844
11846
  });
11845
11847
  return fontFace;
11846
11848
  };
11847
- var restoreHandler = patch(doc.fonts, "add", function(original) {
11849
+ var restoreHandler = patch$2(doc.fonts, "add", function(original) {
11848
11850
  return function(fontFace) {
11849
11851
  setTimeout(callbackWrapper(function() {
11850
11852
  var p = fontMap.get(fontFace);
@@ -11900,7 +11902,7 @@
11900
11902
  var doc = param.doc, customElementCb = param.customElementCb;
11901
11903
  var win = doc.defaultView;
11902
11904
  if (!win || !win.customElements) return function() {};
11903
- var restoreHandler = patch(win.customElements, "define", function(original) {
11905
+ var restoreHandler = patch$2(win.customElements, "define", function(original) {
11904
11906
  return function(name, constructor, options) {
11905
11907
  try {
11906
11908
  customElementCb({
@@ -12127,8 +12129,8 @@
12127
12129
  }
12128
12130
  var CrossOriginIframeMirror = /*#__PURE__*/ function() {
12129
12131
  function CrossOriginIframeMirror(generateIdFn) {
12130
- __publicField(this, "iframeIdToRemoteIdMap", /* @__PURE__ */ new WeakMap());
12131
- __publicField(this, "iframeRemoteIdToIdMap", /* @__PURE__ */ new WeakMap());
12132
+ __publicField$1(this, "iframeIdToRemoteIdMap", /* @__PURE__ */ new WeakMap());
12133
+ __publicField$1(this, "iframeRemoteIdToIdMap", /* @__PURE__ */ new WeakMap());
12132
12134
  this.generateIdFn = generateIdFn;
12133
12135
  }
12134
12136
  var _proto = CrossOriginIframeMirror.prototype;
@@ -12194,17 +12196,17 @@
12194
12196
  }();
12195
12197
  var IframeManager = /*#__PURE__*/ function() {
12196
12198
  function IframeManager(options) {
12197
- __publicField(this, "iframes", /* @__PURE__ */ new WeakMap());
12198
- __publicField(this, "crossOriginIframeMap", /* @__PURE__ */ new WeakMap());
12199
- __publicField(this, "crossOriginIframeMirror", new CrossOriginIframeMirror(genId));
12200
- __publicField(this, "crossOriginIframeStyleMirror");
12201
- __publicField(this, "crossOriginIframeRootIdMap", /* @__PURE__ */ new WeakMap());
12202
- __publicField(this, "mirror");
12203
- __publicField(this, "mutationCb");
12204
- __publicField(this, "wrappedEmit");
12205
- __publicField(this, "loadListener");
12206
- __publicField(this, "stylesheetManager");
12207
- __publicField(this, "recordCrossOriginIframes");
12199
+ __publicField$1(this, "iframes", /* @__PURE__ */ new WeakMap());
12200
+ __publicField$1(this, "crossOriginIframeMap", /* @__PURE__ */ new WeakMap());
12201
+ __publicField$1(this, "crossOriginIframeMirror", new CrossOriginIframeMirror(genId));
12202
+ __publicField$1(this, "crossOriginIframeStyleMirror");
12203
+ __publicField$1(this, "crossOriginIframeRootIdMap", /* @__PURE__ */ new WeakMap());
12204
+ __publicField$1(this, "mirror");
12205
+ __publicField$1(this, "mutationCb");
12206
+ __publicField$1(this, "wrappedEmit");
12207
+ __publicField$1(this, "loadListener");
12208
+ __publicField$1(this, "stylesheetManager");
12209
+ __publicField$1(this, "recordCrossOriginIframes");
12208
12210
  this.mutationCb = options.mutationCb;
12209
12211
  this.wrappedEmit = options.wrappedEmit;
12210
12212
  this.stylesheetManager = options.stylesheetManager;
@@ -12451,12 +12453,12 @@
12451
12453
  }();
12452
12454
  var ShadowDomManager = /*#__PURE__*/ function() {
12453
12455
  function ShadowDomManager(options) {
12454
- __publicField(this, "shadowDoms", /* @__PURE__ */ new WeakSet());
12455
- __publicField(this, "mutationCb");
12456
- __publicField(this, "scrollCb");
12457
- __publicField(this, "bypassOptions");
12458
- __publicField(this, "mirror");
12459
- __publicField(this, "restoreHandlers", []);
12456
+ __publicField$1(this, "shadowDoms", /* @__PURE__ */ new WeakSet());
12457
+ __publicField$1(this, "mutationCb");
12458
+ __publicField$1(this, "scrollCb");
12459
+ __publicField$1(this, "bypassOptions");
12460
+ __publicField$1(this, "mirror");
12461
+ __publicField$1(this, "restoreHandlers", []);
12460
12462
  this.mutationCb = options.mutationCb;
12461
12463
  this.scrollCb = options.scrollCb;
12462
12464
  this.bypassOptions = options.bypassOptions;
@@ -12507,7 +12509,7 @@
12507
12509
  * Patch 'attachShadow' to observe newly added shadow doms.
12508
12510
  */ _proto.patchAttachShadow = function patchAttachShadow(element, doc) {
12509
12511
  var manager = this;
12510
- this.restoreHandlers.push(patch(element.prototype, "attachShadow", function(original) {
12512
+ this.restoreHandlers.push(patch$2(element.prototype, "attachShadow", function(original) {
12511
12513
  return function(option) {
12512
12514
  var sRoot = original.call(this, option);
12513
12515
  var shadowRootEl = index.shadowRoot(this);
@@ -12673,7 +12675,7 @@
12673
12675
  if (typeof win.CanvasRenderingContext2D.prototype[prop] !== "function") {
12674
12676
  return "continue";
12675
12677
  }
12676
- var restoreHandler = patch(win.CanvasRenderingContext2D.prototype, prop, function(original) {
12678
+ var restoreHandler = patch$2(win.CanvasRenderingContext2D.prototype, prop, function(original) {
12677
12679
  return function() {
12678
12680
  var _this = this;
12679
12681
  for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
@@ -12724,7 +12726,7 @@
12724
12726
  function initCanvasContextObserver(win, blockClass, blockSelector, setPreserveDrawingBufferToTrue) {
12725
12727
  var handlers = [];
12726
12728
  try {
12727
- var restoreHandler = patch(win.HTMLCanvasElement.prototype, "getContext", function(original) {
12729
+ var restoreHandler = patch$2(win.HTMLCanvasElement.prototype, "getContext", function(original) {
12728
12730
  return function(contextType) {
12729
12731
  for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
12730
12732
  args[_key - 1] = arguments[_key];
@@ -12779,7 +12781,7 @@
12779
12781
  if (typeof prototype[prop] !== "function") {
12780
12782
  return "continue";
12781
12783
  }
12782
- var restoreHandler = patch(prototype, prop, function(original) {
12784
+ var restoreHandler = patch$2(prototype, prop, function(original) {
12783
12785
  return function() {
12784
12786
  for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
12785
12787
  args[_key] = arguments[_key];
@@ -12868,17 +12870,17 @@
12868
12870
  var CanvasManager = /*#__PURE__*/ function() {
12869
12871
  function CanvasManager(options) {
12870
12872
  var _this = this;
12871
- __publicField(this, "pendingCanvasMutations", /* @__PURE__ */ new Map());
12872
- __publicField(this, "rafStamps", {
12873
+ __publicField$1(this, "pendingCanvasMutations", /* @__PURE__ */ new Map());
12874
+ __publicField$1(this, "rafStamps", {
12873
12875
  latestId: 0,
12874
12876
  invokeId: null
12875
12877
  });
12876
- __publicField(this, "mirror");
12877
- __publicField(this, "mutationCb");
12878
- __publicField(this, "resetObservers");
12879
- __publicField(this, "frozen", false);
12880
- __publicField(this, "locked", false);
12881
- __publicField(this, "processMutation", function(target, mutation) {
12878
+ __publicField$1(this, "mirror");
12879
+ __publicField$1(this, "mutationCb");
12880
+ __publicField$1(this, "resetObservers");
12881
+ __publicField$1(this, "frozen", false);
12882
+ __publicField$1(this, "locked", false);
12883
+ __publicField$1(this, "processMutation", function(target, mutation) {
12882
12884
  var newFrame = _this.rafStamps.invokeId && _this.rafStamps.latestId !== _this.rafStamps.invokeId;
12883
12885
  if (newFrame || !_this.rafStamps.invokeId) _this.rafStamps.invokeId = _this.rafStamps.latestId;
12884
12886
  if (!_this.pendingCanvasMutations.has(target)) {
@@ -13091,10 +13093,10 @@
13091
13093
  }();
13092
13094
  var StylesheetManager = /*#__PURE__*/ function() {
13093
13095
  function StylesheetManager(options) {
13094
- __publicField(this, "trackedLinkElements", /* @__PURE__ */ new WeakSet());
13095
- __publicField(this, "mutationCb");
13096
- __publicField(this, "adoptedStyleSheetCb");
13097
- __publicField(this, "styleMirror", new StyleSheetMirror());
13096
+ __publicField$1(this, "trackedLinkElements", /* @__PURE__ */ new WeakSet());
13097
+ __publicField$1(this, "mutationCb");
13098
+ __publicField$1(this, "adoptedStyleSheetCb");
13099
+ __publicField$1(this, "styleMirror", new StyleSheetMirror());
13098
13100
  this.mutationCb = options.mutationCb;
13099
13101
  this.adoptedStyleSheetCb = options.adoptedStyleSheetCb;
13100
13102
  }
@@ -13156,8 +13158,8 @@
13156
13158
  }();
13157
13159
  var ProcessedNodeManager = /*#__PURE__*/ function() {
13158
13160
  function ProcessedNodeManager() {
13159
- __publicField(this, "nodeMap", /* @__PURE__ */ new WeakMap());
13160
- __publicField(this, "active", false);
13161
+ __publicField$1(this, "nodeMap", /* @__PURE__ */ new WeakMap());
13162
+ __publicField$1(this, "active", false);
13161
13163
  }
13162
13164
  var _proto = ProcessedNodeManager.prototype;
13163
13165
  _proto.inOtherBuffer = function inOtherBuffer(node2, thisBuffer) {
@@ -13682,6 +13684,493 @@
13682
13684
  record.addCustomEvent;
13683
13685
  record.freezePage;
13684
13686
  record.takeFullSnapshot;
13687
+ var __defProp = Object.defineProperty;
13688
+ var __defNormalProp = function(obj, key, value) {
13689
+ return key in obj ? __defProp(obj, key, {
13690
+ enumerable: true,
13691
+ configurable: true,
13692
+ writable: true,
13693
+ value: value
13694
+ }) : obj[key] = value;
13695
+ };
13696
+ var __publicField = function(obj, key, value) {
13697
+ return __defNormalProp(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
13698
+ };
13699
+ function patch(source, name, replacement) {
13700
+ try {
13701
+ if (!(name in source)) {
13702
+ return function() {};
13703
+ }
13704
+ var original = source[name];
13705
+ var wrapped = replacement(original);
13706
+ if (typeof wrapped === "function") {
13707
+ wrapped.prototype = wrapped.prototype || {};
13708
+ Object.defineProperties(wrapped, {
13709
+ __rrweb_original__: {
13710
+ enumerable: false,
13711
+ value: original
13712
+ }
13713
+ });
13714
+ }
13715
+ source[name] = wrapped;
13716
+ return function() {
13717
+ source[name] = original;
13718
+ };
13719
+ } catch (e) {
13720
+ return function() {};
13721
+ }
13722
+ }
13723
+ var StackFrame = /*#__PURE__*/ function() {
13724
+ function StackFrame(obj) {
13725
+ __publicField(this, "fileName");
13726
+ __publicField(this, "functionName");
13727
+ __publicField(this, "lineNumber");
13728
+ __publicField(this, "columnNumber");
13729
+ this.fileName = obj.fileName || "";
13730
+ this.functionName = obj.functionName || "";
13731
+ this.lineNumber = obj.lineNumber;
13732
+ this.columnNumber = obj.columnNumber;
13733
+ }
13734
+ var _proto = StackFrame.prototype;
13735
+ _proto.toString = function toString() {
13736
+ var lineNumber = this.lineNumber || "";
13737
+ var columnNumber = this.columnNumber || "";
13738
+ if (this.functionName) return this.functionName + " (" + this.fileName + ":" + lineNumber + ":" + columnNumber + ")";
13739
+ return this.fileName + ":" + lineNumber + ":" + columnNumber;
13740
+ };
13741
+ return StackFrame;
13742
+ }();
13743
+ var FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\S+:\d+/;
13744
+ var CHROME_IE_STACK_REGEXP = /^\s*at .*(\S+:\d+|\(native\))/m;
13745
+ var SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\[native code])?$/;
13746
+ var ErrorStackParser = {
13747
+ /**
13748
+ * Given an Error object, extract the most information from it.
13749
+ */ parse: function parse(error) {
13750
+ if (!error) {
13751
+ return [];
13752
+ }
13753
+ if (// eslint-disable-next-line @typescript-eslint/ban-ts-comment
13754
+ // @ts-ignore
13755
+ typeof error.stacktrace !== "undefined" || // eslint-disable-next-line @typescript-eslint/ban-ts-comment
13756
+ // @ts-ignore
13757
+ typeof error["opera#sourceloc"] !== "undefined") {
13758
+ return this.parseOpera(error);
13759
+ } else if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP)) {
13760
+ return this.parseV8OrIE(error);
13761
+ } else if (error.stack) {
13762
+ return this.parseFFOrSafari(error);
13763
+ } else {
13764
+ console.warn("[console-record-plugin]: Failed to parse error object:", error);
13765
+ return [];
13766
+ }
13767
+ },
13768
+ // Separate line and column numbers from a string of the form: (URI:Line:Column)
13769
+ extractLocation: function extractLocation(urlLike) {
13770
+ if (urlLike.indexOf(":") === -1) {
13771
+ return [
13772
+ urlLike
13773
+ ];
13774
+ }
13775
+ var regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
13776
+ var parts = regExp.exec(urlLike.replace(/[()]/g, ""));
13777
+ if (!parts) throw new Error("Cannot parse given url: " + urlLike);
13778
+ return [
13779
+ parts[1],
13780
+ parts[2] || void 0,
13781
+ parts[3] || void 0
13782
+ ];
13783
+ },
13784
+ parseV8OrIE: function parseV8OrIE(error) {
13785
+ var filtered = error.stack.split("\n").filter(function(line) {
13786
+ return !!line.match(CHROME_IE_STACK_REGEXP);
13787
+ }, this);
13788
+ return filtered.map(function(line) {
13789
+ if (line.indexOf("(eval ") > -1) {
13790
+ line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(\),.*$)/g, "");
13791
+ }
13792
+ var sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(");
13793
+ var location = sanitizedLine.match(/ (\((.+):(\d+):(\d+)\)$)/);
13794
+ sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine;
13795
+ var tokens = sanitizedLine.split(/\s+/).slice(1);
13796
+ var locationParts = this.extractLocation(location ? location[1] : tokens.pop());
13797
+ var functionName = tokens.join(" ") || void 0;
13798
+ var fileName = [
13799
+ "eval",
13800
+ "<anonymous>"
13801
+ ].indexOf(locationParts[0]) > -1 ? void 0 : locationParts[0];
13802
+ return new StackFrame({
13803
+ functionName: functionName,
13804
+ fileName: fileName,
13805
+ lineNumber: locationParts[1],
13806
+ columnNumber: locationParts[2]
13807
+ });
13808
+ }, this);
13809
+ },
13810
+ parseFFOrSafari: function parseFFOrSafari(error) {
13811
+ var filtered = error.stack.split("\n").filter(function(line) {
13812
+ return !line.match(SAFARI_NATIVE_CODE_REGEXP);
13813
+ }, this);
13814
+ return filtered.map(function(line) {
13815
+ if (line.indexOf(" > eval") > -1) {
13816
+ line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1");
13817
+ }
13818
+ if (line.indexOf("@") === -1 && line.indexOf(":") === -1) {
13819
+ return new StackFrame({
13820
+ functionName: line
13821
+ });
13822
+ } else {
13823
+ var functionNameRegex = /((.*".+"[^@]*)?[^@]*)(?:@)/;
13824
+ var matches = line.match(functionNameRegex);
13825
+ var functionName = matches && matches[1] ? matches[1] : void 0;
13826
+ var locationParts = this.extractLocation(line.replace(functionNameRegex, ""));
13827
+ return new StackFrame({
13828
+ functionName: functionName,
13829
+ fileName: locationParts[0],
13830
+ lineNumber: locationParts[1],
13831
+ columnNumber: locationParts[2]
13832
+ });
13833
+ }
13834
+ }, this);
13835
+ },
13836
+ parseOpera: function parseOpera(e) {
13837
+ if (!e.stacktrace || e.message.indexOf("\n") > -1 && e.message.split("\n").length > e.stacktrace.split("\n").length) {
13838
+ return this.parseOpera9(e);
13839
+ } else if (!e.stack) {
13840
+ return this.parseOpera10(e);
13841
+ } else {
13842
+ return this.parseOpera11(e);
13843
+ }
13844
+ },
13845
+ parseOpera9: function parseOpera9(e) {
13846
+ var lineRE = /Line (\d+).*script (?:in )?(\S+)/i;
13847
+ var lines = e.message.split("\n");
13848
+ var result = [];
13849
+ for(var i = 2, len = lines.length; i < len; i += 2){
13850
+ var match = lineRE.exec(lines[i]);
13851
+ if (match) {
13852
+ result.push(new StackFrame({
13853
+ fileName: match[2],
13854
+ lineNumber: parseFloat(match[1])
13855
+ }));
13856
+ }
13857
+ }
13858
+ return result;
13859
+ },
13860
+ parseOpera10: function parseOpera10(e) {
13861
+ var lineRE = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i;
13862
+ var lines = e.stacktrace.split("\n");
13863
+ var result = [];
13864
+ for(var i = 0, len = lines.length; i < len; i += 2){
13865
+ var match = lineRE.exec(lines[i]);
13866
+ if (match) {
13867
+ result.push(new StackFrame({
13868
+ functionName: match[3] || void 0,
13869
+ fileName: match[2],
13870
+ lineNumber: parseFloat(match[1])
13871
+ }));
13872
+ }
13873
+ }
13874
+ return result;
13875
+ },
13876
+ // Opera 10.65+ Error.stack very similar to FF/Safari
13877
+ parseOpera11: function parseOpera11(error) {
13878
+ var filtered = error.stack.split("\n").filter(function(line) {
13879
+ return !!line.match(FIREFOX_SAFARI_STACK_REGEXP) && !line.match(/^Error created at/);
13880
+ }, this);
13881
+ return filtered.map(function(line) {
13882
+ var tokens = line.split("@");
13883
+ var locationParts = this.extractLocation(tokens.pop());
13884
+ var functionCall = tokens.shift() || "";
13885
+ var functionName = functionCall.replace(/<anonymous function(: (\w+))?>/, "$2").replace(/\([^)]*\)/g, "") || void 0;
13886
+ return new StackFrame({
13887
+ functionName: functionName,
13888
+ fileName: locationParts[0],
13889
+ lineNumber: locationParts[1],
13890
+ columnNumber: locationParts[2]
13891
+ });
13892
+ }, this);
13893
+ }
13894
+ };
13895
+ function pathToSelector(node) {
13896
+ if (!node || !node.outerHTML) {
13897
+ return "";
13898
+ }
13899
+ var path = "";
13900
+ while(node.parentElement){
13901
+ var name = node.localName;
13902
+ if (!name) {
13903
+ break;
13904
+ }
13905
+ name = name.toLowerCase();
13906
+ var parent = node.parentElement;
13907
+ var domSiblings = [];
13908
+ if (parent.children && parent.children.length > 0) {
13909
+ for(var i = 0; i < parent.children.length; i++){
13910
+ var sibling = parent.children[i];
13911
+ if (sibling.localName && sibling.localName.toLowerCase) {
13912
+ if (sibling.localName.toLowerCase() === name) {
13913
+ domSiblings.push(sibling);
13914
+ }
13915
+ }
13916
+ }
13917
+ }
13918
+ if (domSiblings.length > 1) {
13919
+ name += ":eq(" + domSiblings.indexOf(node) + ")";
13920
+ }
13921
+ path = name + (path ? ">" + path : "");
13922
+ node = parent;
13923
+ }
13924
+ return path;
13925
+ }
13926
+ function isObject(obj) {
13927
+ return Object.prototype.toString.call(obj) === "[object Object]";
13928
+ }
13929
+ function isObjTooDeep(obj, limit) {
13930
+ if (limit === 0) {
13931
+ return true;
13932
+ }
13933
+ var keys = Object.keys(obj);
13934
+ for(var _iterator = _create_for_of_iterator_helper_loose(keys), _step; !(_step = _iterator()).done;){
13935
+ var key = _step.value;
13936
+ if (isObject(obj[key]) && isObjTooDeep(obj[key], limit - 1)) {
13937
+ return true;
13938
+ }
13939
+ }
13940
+ return false;
13941
+ }
13942
+ function stringify(obj, stringifyOptions) {
13943
+ var options = {
13944
+ numOfKeysLimit: 50,
13945
+ depthOfLimit: 4
13946
+ };
13947
+ Object.assign(options, stringifyOptions);
13948
+ var stack = [];
13949
+ var keys = [];
13950
+ return JSON.stringify(obj, function(key, value) {
13951
+ if (stack.length > 0) {
13952
+ var thisPos = stack.indexOf(this);
13953
+ ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
13954
+ ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
13955
+ if (~stack.indexOf(value)) {
13956
+ if (stack[0] === value) {
13957
+ value = "[Circular ~]";
13958
+ } else {
13959
+ value = "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
13960
+ }
13961
+ }
13962
+ } else {
13963
+ stack.push(value);
13964
+ }
13965
+ if (value === null) return value;
13966
+ if (value === void 0) return "undefined";
13967
+ if (shouldIgnore(value)) {
13968
+ return toString(value);
13969
+ }
13970
+ if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "bigint") {
13971
+ return value.toString() + "n";
13972
+ }
13973
+ if (_instanceof(value, Event)) {
13974
+ var eventResult = {};
13975
+ for(var eventKey in value){
13976
+ var eventValue = value[eventKey];
13977
+ if (Array.isArray(eventValue)) {
13978
+ eventResult[eventKey] = pathToSelector(eventValue.length ? eventValue[0] : null);
13979
+ } else {
13980
+ eventResult[eventKey] = eventValue;
13981
+ }
13982
+ }
13983
+ return eventResult;
13984
+ } else if (_instanceof(value, Node)) {
13985
+ if (_instanceof(value, HTMLElement)) {
13986
+ return value ? value.outerHTML : "";
13987
+ }
13988
+ return value.nodeName;
13989
+ } else if (_instanceof(value, Error)) {
13990
+ return value.stack ? value.stack + "\nEnd of stack for Error object" : value.name + ": " + value.message;
13991
+ }
13992
+ return value;
13993
+ });
13994
+ function shouldIgnore(_obj) {
13995
+ if (isObject(_obj) && Object.keys(_obj).length > options.numOfKeysLimit) {
13996
+ return true;
13997
+ }
13998
+ if (typeof _obj === "function") {
13999
+ return true;
14000
+ }
14001
+ if (isObject(_obj) && isObjTooDeep(_obj, options.depthOfLimit)) {
14002
+ return true;
14003
+ }
14004
+ return false;
14005
+ }
14006
+ function toString(_obj) {
14007
+ var str = _obj.toString();
14008
+ if (options.stringLengthLimit && str.length > options.stringLengthLimit) {
14009
+ str = "" + str.slice(0, options.stringLengthLimit) + "...";
14010
+ }
14011
+ return str;
14012
+ }
14013
+ }
14014
+ var defaultLogOptions = {
14015
+ level: [
14016
+ "assert",
14017
+ "clear",
14018
+ "count",
14019
+ "countReset",
14020
+ "debug",
14021
+ "dir",
14022
+ "dirxml",
14023
+ "error",
14024
+ "group",
14025
+ "groupCollapsed",
14026
+ "groupEnd",
14027
+ "info",
14028
+ "log",
14029
+ "table",
14030
+ "time",
14031
+ "timeEnd",
14032
+ "timeLog",
14033
+ "trace",
14034
+ "warn"
14035
+ ],
14036
+ lengthThreshold: 1e3,
14037
+ logger: "console"
14038
+ };
14039
+ function initLogObserver(cb, win, options) {
14040
+ var logOptions = options ? Object.assign({}, defaultLogOptions, options) : defaultLogOptions;
14041
+ var loggerType = logOptions.logger;
14042
+ if (!loggerType) {
14043
+ return function() {};
14044
+ }
14045
+ var logger;
14046
+ if (typeof loggerType === "string") {
14047
+ logger = win[loggerType];
14048
+ } else {
14049
+ logger = loggerType;
14050
+ }
14051
+ var logCount = 0;
14052
+ var inStack = false;
14053
+ var cancelHandlers = [];
14054
+ if (logOptions.level.includes("error")) {
14055
+ var errorHandler = function(event) {
14056
+ var message = event.message, error = event.error;
14057
+ var trace = ErrorStackParser.parse(error).map(function(stackFrame) {
14058
+ return stackFrame.toString();
14059
+ });
14060
+ var payload = [
14061
+ stringify(message, logOptions.stringifyOptions)
14062
+ ];
14063
+ cb({
14064
+ level: "error",
14065
+ trace: trace,
14066
+ payload: payload
14067
+ });
14068
+ };
14069
+ win.addEventListener("error", errorHandler);
14070
+ cancelHandlers.push(function() {
14071
+ win.removeEventListener("error", errorHandler);
14072
+ });
14073
+ var unhandledrejectionHandler = function(event) {
14074
+ var error;
14075
+ var payload;
14076
+ if (_instanceof(event.reason, Error)) {
14077
+ error = event.reason;
14078
+ payload = [
14079
+ stringify("Uncaught (in promise) " + error.name + ": " + error.message, logOptions.stringifyOptions)
14080
+ ];
14081
+ } else {
14082
+ error = new Error();
14083
+ payload = [
14084
+ stringify("Uncaught (in promise)", logOptions.stringifyOptions),
14085
+ stringify(event.reason, logOptions.stringifyOptions)
14086
+ ];
14087
+ }
14088
+ var trace = ErrorStackParser.parse(error).map(function(stackFrame) {
14089
+ return stackFrame.toString();
14090
+ });
14091
+ cb({
14092
+ level: "error",
14093
+ trace: trace,
14094
+ payload: payload
14095
+ });
14096
+ };
14097
+ win.addEventListener("unhandledrejection", unhandledrejectionHandler);
14098
+ cancelHandlers.push(function() {
14099
+ win.removeEventListener("unhandledrejection", unhandledrejectionHandler);
14100
+ });
14101
+ }
14102
+ for(var _iterator = _create_for_of_iterator_helper_loose(logOptions.level), _step; !(_step = _iterator()).done;){
14103
+ var levelType = _step.value;
14104
+ cancelHandlers.push(replace(logger, levelType));
14105
+ }
14106
+ return function() {
14107
+ cancelHandlers.forEach(function(h) {
14108
+ return h();
14109
+ });
14110
+ };
14111
+ function replace(_logger, level) {
14112
+ var _this = this;
14113
+ if (!_logger[level]) {
14114
+ return function() {};
14115
+ }
14116
+ return patch(_logger, level, function(original) {
14117
+ var _this1 = _this;
14118
+ return function() {
14119
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
14120
+ args[_key] = arguments[_key];
14121
+ }
14122
+ original.apply(_this1, args);
14123
+ if (level === "assert" && !!args[0]) {
14124
+ return;
14125
+ }
14126
+ if (inStack) {
14127
+ return;
14128
+ }
14129
+ inStack = true;
14130
+ try {
14131
+ var trace = ErrorStackParser.parse(new Error()).map(function(stackFrame) {
14132
+ return stackFrame.toString();
14133
+ }).splice(1);
14134
+ var argsForPayload = level === "assert" ? args.slice(1) : args;
14135
+ var payload = argsForPayload.map(function(s) {
14136
+ return stringify(s, logOptions.stringifyOptions);
14137
+ });
14138
+ logCount++;
14139
+ if (logCount < logOptions.lengthThreshold) {
14140
+ cb({
14141
+ level: level,
14142
+ trace: trace,
14143
+ payload: payload
14144
+ });
14145
+ } else if (logCount === logOptions.lengthThreshold) {
14146
+ cb({
14147
+ level: "warn",
14148
+ trace: [],
14149
+ payload: [
14150
+ stringify("The number of log records reached the threshold.")
14151
+ ]
14152
+ });
14153
+ }
14154
+ } catch (error) {
14155
+ original.apply(void 0, [].concat([
14156
+ "rrweb logger error:",
14157
+ error
14158
+ ], args));
14159
+ } finally{
14160
+ inStack = false;
14161
+ }
14162
+ };
14163
+ });
14164
+ }
14165
+ }
14166
+ var PLUGIN_NAME = "rrweb/console@1";
14167
+ var getRecordConsolePlugin = function(options) {
14168
+ return {
14169
+ name: PLUGIN_NAME,
14170
+ observer: initLogObserver,
14171
+ options: options
14172
+ };
14173
+ };
13685
14174
 
13686
14175
  var setImmediate = win['setImmediate'];
13687
14176
  var builtInProp, cycle, schedulingQueue,
@@ -14047,7 +14536,7 @@
14047
14536
 
14048
14537
  var Config = {
14049
14538
  DEBUG: false,
14050
- LIB_VERSION: '2.71.0'
14539
+ LIB_VERSION: '2.72.0'
14051
14540
  };
14052
14541
 
14053
14542
  /* eslint camelcase: "off", eqeqeq: "off" */
@@ -15787,6 +16276,28 @@
15787
16276
  JSONStringify = JSONStringify || _.JSONEncode;
15788
16277
  JSONParse = JSONParse || _.JSONDecode;
15789
16278
 
16279
+ /**
16280
+ * Determines if CompressionStream API should be used.
16281
+ * Returns false for Safari 16.4 and 16.5 which have breaking CompressionStream bugs.
16282
+ * https://bugs.webkit.org/show_bug.cgi?id=254021
16283
+ * fixed in 16.6 https://developer.apple.com/documentation/safari-release-notes/safari-16_6-release-notes
16284
+ */
16285
+ var canUseCompressionStream = function(userAgent, vendor, opera) {
16286
+ if (!win.CompressionStream) {
16287
+ return false;
16288
+ }
16289
+
16290
+ var browser = _.info.browser(userAgent, vendor, opera);
16291
+ var version = _.info.browserVersion(userAgent, vendor, opera);
16292
+ if (browser === 'Safari' || browser === 'Mobile Safari') {
16293
+ if (version >= 16.4 && version < 16.6) {
16294
+ return false;
16295
+ }
16296
+ }
16297
+
16298
+ return true;
16299
+ };
16300
+
15790
16301
  // UNMINIFIED EXPORTS (for closure compiler)
15791
16302
  _['info'] = _.info;
15792
16303
  _['info']['browser'] = _.info.browser;
@@ -17162,6 +17673,7 @@
17162
17673
  * @property {number} idleExpires
17163
17674
  * @property {number} maxExpires
17164
17675
  * @property {number} replayStartTime
17676
+ * @property {number} lastEventTimestamp
17165
17677
  * @property {number} seqNo
17166
17678
  * @property {string} batchStartUrl
17167
17679
  * @property {string} replayId
@@ -17182,6 +17694,7 @@
17182
17694
  * @property {number} idleExpires
17183
17695
  * @property {number} maxExpires
17184
17696
  * @property {number} replayStartTime
17697
+ * @property {number} lastEventTimestamp - the unix timestamp of the last recorded event from rrweb
17185
17698
  * @property {number} seqNo
17186
17699
  * @property {string} batchStartUrl
17187
17700
  * @property {string} replayStartUrl
@@ -17215,6 +17728,7 @@
17215
17728
  this.idleExpires = options.idleExpires || null;
17216
17729
  this.maxExpires = options.maxExpires || null;
17217
17730
  this.replayStartTime = options.replayStartTime || null;
17731
+ this.lastEventTimestamp = options.lastEventTimestamp || null;
17218
17732
  this.seqNo = options.seqNo || 0;
17219
17733
 
17220
17734
  this.idleTimeoutId = null;
@@ -17274,10 +17788,20 @@
17274
17788
 
17275
17789
  SessionRecording.prototype.unloadPersistedData = function () {
17276
17790
  this.batcher.stop();
17277
- return this.batcher.flush()
17278
- .then(function () {
17791
+
17792
+ return this.queueStorage.init().catch(function () {
17793
+ this.reportError('Error initializing IndexedDB storage for unloading persisted data.');
17794
+ }.bind(this)).then(function () {
17795
+ // if the recording is too short, just delete any stored events without flushing
17796
+ if (this.getDurationMs() < this._getRecordMinMs()) {
17279
17797
  return this.queueStorage.removeItem(this.batcherKey);
17280
- }.bind(this));
17798
+ }
17799
+
17800
+ return this.batcher.flush()
17801
+ .then(function () {
17802
+ return this.queueStorage.removeItem(this.batcherKey);
17803
+ }.bind(this));
17804
+ }.bind(this));
17281
17805
  };
17282
17806
 
17283
17807
  SessionRecording.prototype.getConfig = function(configVar) {
@@ -17312,11 +17836,7 @@
17312
17836
  this.maxExpires = new Date().getTime() + this.recordMaxMs;
17313
17837
  }
17314
17838
 
17315
- this.recordMinMs = this.getConfig('record_min_ms');
17316
- if (this.recordMinMs > MAX_VALUE_FOR_MIN_RECORDING_MS) {
17317
- this.recordMinMs = MAX_VALUE_FOR_MIN_RECORDING_MS;
17318
- logger$3.critical('record_min_ms cannot be greater than ' + MAX_VALUE_FOR_MIN_RECORDING_MS + 'ms. Capping value.');
17319
- }
17839
+ this.recordMinMs = this._getRecordMinMs();
17320
17840
 
17321
17841
  if (!this.replayStartTime) {
17322
17842
  this.replayStartTime = new Date().getTime();
@@ -17364,6 +17884,11 @@
17364
17884
  }
17365
17885
  // promise only used to await during tests
17366
17886
  this.__enqueuePromise = this.batcher.enqueue(ev);
17887
+
17888
+ // Capture the timestamp of the last event for duration calculation.
17889
+ if (this.lastEventTimestamp === null || ev.timestamp > this.lastEventTimestamp) {
17890
+ this.lastEventTimestamp = ev.timestamp;
17891
+ }
17367
17892
  }.bind(this),
17368
17893
  'blockClass': this.getConfig('record_block_class'),
17369
17894
  'blockSelector': blockSelector,
@@ -17378,7 +17903,16 @@
17378
17903
  'recordCanvas': this.getConfig('record_canvas'),
17379
17904
  'sampling': {
17380
17905
  'canvas': 15
17381
- }
17906
+ },
17907
+ 'plugins': this.getConfig('record_console') ? [
17908
+ getRecordConsolePlugin({
17909
+ stringifyOptions: {
17910
+ stringLengthLimit: 1000,
17911
+ numOfKeysLimit: 50,
17912
+ depthOfLimit: 2
17913
+ }
17914
+ })
17915
+ ] : []
17382
17916
  });
17383
17917
  } catch (err) {
17384
17918
  this.reportError('Unexpected error when starting rrweb recording.', err);
@@ -17463,6 +17997,7 @@
17463
17997
  'replayStartTime': this.replayStartTime,
17464
17998
  'batchStartUrl': this.batchStartUrl,
17465
17999
  'replayStartUrl': this.replayStartUrl,
18000
+ 'lastEventTimestamp': this.lastEventTimestamp,
17466
18001
  'idleExpires': this.idleExpires,
17467
18002
  'maxExpires': this.maxExpires,
17468
18003
  'tabId': tabId,
@@ -17484,6 +18019,7 @@
17484
18019
  idleExpires: serializedRecording['idleExpires'],
17485
18020
  maxExpires: serializedRecording['maxExpires'],
17486
18021
  replayStartTime: serializedRecording['replayStartTime'],
18022
+ lastEventTimestamp: serializedRecording['lastEventTimestamp'],
17487
18023
  seqNo: serializedRecording['seqNo'],
17488
18024
  sharedLockStorage: options.sharedLockStorage,
17489
18025
  }));
@@ -17574,7 +18110,7 @@
17574
18110
  var eventsJson = JSON.stringify(data);
17575
18111
  Object.assign(reqParams, this.getUserIdInfo());
17576
18112
 
17577
- if (CompressionStream) {
18113
+ if (canUseCompressionStream(userAgent, navigator.vendor, windowOpera)) {
17578
18114
  var jsonStream = new Blob([eventsJson], {type: 'application/json'}).stream();
17579
18115
  var gzipStream = jsonStream.pipeThrough(new CompressionStream('gzip'));
17580
18116
  new Response(gzipStream)
@@ -17603,6 +18139,38 @@
17603
18139
  }
17604
18140
  };
17605
18141
 
18142
+ /**
18143
+ * Calculates the duration of the recording in milliseconds, based on the start time and time of last recorded event.
18144
+ * @returns {number} The duration of the recording in milliseconds. Returns 0 if recording hasn't started.
18145
+ */
18146
+ SessionRecording.prototype.getDurationMs = function() {
18147
+ if (this.replayStartTime === null) {
18148
+ return 0;
18149
+ }
18150
+
18151
+ // If the recording has no events, assume it is in progress and use the current time as the end time.
18152
+ if (this.lastEventTimestamp === null) {
18153
+ return new Date().getTime() - this.replayStartTime;
18154
+ }
18155
+
18156
+ return this.lastEventTimestamp - this.replayStartTime;
18157
+ };
18158
+
18159
+ /**
18160
+ * Lazily loads the minimum recording length config in milliseconds, respecting the maximum limit.
18161
+ * @returns {number} The minimum recording length in milliseconds.
18162
+ */
18163
+ SessionRecording.prototype._getRecordMinMs = function() {
18164
+ var configValue = this.getConfig('record_min_ms');
18165
+
18166
+ if (configValue > MAX_VALUE_FOR_MIN_RECORDING_MS) {
18167
+ logger$3.critical('record_min_ms cannot be greater than ' + MAX_VALUE_FOR_MIN_RECORDING_MS + 'ms. Capping value.');
18168
+ return MAX_VALUE_FOR_MIN_RECORDING_MS;
18169
+ }
18170
+
18171
+ return configValue;
18172
+ };
18173
+
17606
18174
  /**
17607
18175
  * Module for handling the storage and retrieval of recording metadata as well as any active recordings.
17608
18176
  * Makes sure that only one tab can be recording at a time.
@@ -18612,20 +19180,65 @@
18612
19180
  return false;
18613
19181
  }
18614
19182
 
19183
+ /**
19184
+ * Get the composed path of a click event for elements embedded in shadow DOM.
19185
+ * @param {Event} event - event to get the composed path from
19186
+ * @returns {Array} the composed path of the click event
19187
+ */
19188
+ function getClickEventComposedPath(event) {
19189
+ if ('composedPath' in event) {
19190
+ return event['composedPath']();
19191
+ }
19192
+
19193
+ return [];
19194
+ }
19195
+
19196
+ /**
19197
+ * Get the element from a click event, accounting for elements embedded in shadow DOM.
19198
+ * @param {Event} event - event to get the target from
19199
+ * @returns {Element | null} the element that was the target of the click event
19200
+ */
19201
+ function getClickEventTargetElement(event) {
19202
+ var path = getClickEventComposedPath(event);
19203
+
19204
+ if (path && path.length > 0) {
19205
+ return path[0];
19206
+ }
19207
+
19208
+ return event['target'] || event['srcElement'];
19209
+ }
19210
+
18615
19211
  /** @const */ var DEFAULT_RAGE_CLICK_THRESHOLD_PX = 30;
18616
19212
  /** @const */ var DEFAULT_RAGE_CLICK_TIMEOUT_MS = 1000;
18617
19213
  /** @const */ var DEFAULT_RAGE_CLICK_CLICK_COUNT = 4;
19214
+ /** @const */ var DEFAULT_RAGE_CLICK_INTERACTIVE_ELEMENTS_ONLY = false;
18618
19215
 
18619
19216
  function RageClickTracker() {
18620
19217
  this.clicks = [];
18621
19218
  }
18622
19219
 
18623
- RageClickTracker.prototype.isRageClick = function(x, y, options) {
19220
+ /**
19221
+ * Determines if a click event is part of a rage click sequence.
19222
+ * @param {Event} event - the original click event.
19223
+ * @param {import('../index.d.ts').RageClickConfig} options - configuration options for rage click detection.
19224
+ * @returns {boolean} - true if the click is considered a rage click, false otherwise.
19225
+ */
19226
+ RageClickTracker.prototype.isRageClick = function(event, options) {
18624
19227
  options = options || {};
18625
19228
  var thresholdPx = options['threshold_px'] || DEFAULT_RAGE_CLICK_THRESHOLD_PX;
18626
19229
  var timeoutMs = options['timeout_ms'] || DEFAULT_RAGE_CLICK_TIMEOUT_MS;
18627
19230
  var clickCount = options['click_count'] || DEFAULT_RAGE_CLICK_CLICK_COUNT;
19231
+ var interactiveElementsOnly = options['interactive_elements_only'] || DEFAULT_RAGE_CLICK_INTERACTIVE_ELEMENTS_ONLY;
19232
+
19233
+ if (interactiveElementsOnly) {
19234
+ var target = getClickEventTargetElement(event);
19235
+ if (!target || isDefinitelyNonInteractive(target)) {
19236
+ return false;
19237
+ }
19238
+ }
19239
+
18628
19240
  var timestamp = Date.now();
19241
+ var x = event['pageX'], y = event['pageY'];
18629
19242
 
18630
19243
  var lastClick = this.clicks[this.clicks.length - 1];
18631
19244
  if (
@@ -18656,28 +19269,16 @@
18656
19269
  if (!this.observedShadowRoots) {
18657
19270
  return;
18658
19271
  }
18659
- var path = this.getComposedPath(event);
18660
- if (path && path.length) {
18661
- return path[0];
18662
- }
18663
19272
 
18664
- return event['target'] || event['srcElement'];
19273
+ return getClickEventTargetElement(event);
18665
19274
  };
18666
19275
 
18667
-
18668
- ShadowDOMObserver.prototype.getComposedPath = function(event) {
18669
- if ('composedPath' in event) {
18670
- return event['composedPath']();
18671
- }
18672
-
18673
- return [];
18674
- };
18675
19276
  ShadowDOMObserver.prototype.observeFromEvent = function(event) {
18676
19277
  if (!this.observedShadowRoots) {
18677
19278
  return;
18678
19279
  }
18679
19280
 
18680
- var path = this.getComposedPath(event);
19281
+ var path = getClickEventComposedPath(event);
18681
19282
 
18682
19283
  // Check each element in path for shadow roots
18683
19284
  for (var i = 0; i < path.length; i++) {
@@ -19229,6 +19830,11 @@
19229
19830
  // User has navigated away already ending their impression.
19230
19831
  return;
19231
19832
  }
19833
+
19834
+ if (!this.getConfig(CONFIG_TRACK_PAGE_LEAVE) && !this.mp.is_recording_heatmap_data()) {
19835
+ return;
19836
+ }
19837
+
19232
19838
  this.hasTrackedScrollSession = true;
19233
19839
  var viewportHeight = Math.max(document$1.documentElement.clientHeight, win.innerHeight || 0);
19234
19840
  var scrollPercentage = Math.round(Math.max(this.maxScrollViewDepth - viewportHeight, 0) / (currentScrollHeight - viewportHeight) * 100);
@@ -19248,12 +19854,9 @@
19248
19854
  '$current_url': currentUrl || _.info.currentUrl(),
19249
19855
  '$viewportHeight': viewportHeight, // This is the fold line
19250
19856
  '$viewportWidth': Math.max(document$1.documentElement.clientWidth, win.innerWidth || 0),
19857
+ '$captured_for_heatmap': this.mp.is_recording_heatmap_data()
19251
19858
  }, DEFAULT_PROPS);
19252
19859
 
19253
- if (this.mp.is_recording_heatmap_data() && !this.getConfig(CONFIG_TRACK_PAGE_LEAVE)) {
19254
- props['$captured_for_heatmap'] = true;
19255
- }
19256
-
19257
19860
  // Send with beacon transport to ensure event is sent before unload
19258
19861
  this.mp.track(MP_EV_PAGE_LEAVE, props, {transport: 'sendBeacon'});
19259
19862
  };
@@ -19427,7 +20030,7 @@
19427
20030
  return;
19428
20031
  }
19429
20032
 
19430
- if (this._rageClickTracker.isRageClick(ev['pageX'], ev['pageY'], currentRageClickConfig)) {
20033
+ if (this._rageClickTracker.isRageClick(ev, currentRageClickConfig)) {
19431
20034
  this.trackDomEvent(ev, MP_EV_RAGE_CLICK);
19432
20035
  }
19433
20036
  }.bind(this);
@@ -21296,6 +21899,7 @@
21296
21899
  'record_block_selector': 'img, video, audio',
21297
21900
  'record_canvas': false,
21298
21901
  'record_collect_fonts': false,
21902
+ 'record_console': true,
21299
21903
  'record_heatmap_data': false,
21300
21904
  'record_idle_timeout_ms': 30 * 60 * 1000, // 30 minutes
21301
21905
  'record_mask_text_class': new RegExp('^(mp-mask|fs-mask|amp-mask|rr-mask|ph-mask)$'),