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