mixpanel-browser 2.71.1 → 2.73.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 (40) hide show
  1. package/.github/workflows/tests.yml +1 -0
  2. package/CHANGELOG.md +12 -0
  3. package/dist/mixpanel-core.cjs.d.ts +84 -13
  4. package/dist/mixpanel-core.cjs.js +180 -28
  5. package/dist/mixpanel-recorder.js +684 -114
  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 +84 -13
  9. package/dist/mixpanel-with-async-recorder.cjs.js +180 -28
  10. package/dist/mixpanel-with-recorder.d.ts +84 -13
  11. package/dist/mixpanel-with-recorder.js +860 -140
  12. package/dist/mixpanel-with-recorder.min.d.ts +84 -13
  13. package/dist/mixpanel-with-recorder.min.js +1 -1
  14. package/dist/mixpanel.amd.d.ts +84 -13
  15. package/dist/mixpanel.amd.js +860 -140
  16. package/dist/mixpanel.cjs.d.ts +84 -13
  17. package/dist/mixpanel.cjs.js +860 -140
  18. package/dist/mixpanel.globals.js +180 -28
  19. package/dist/mixpanel.min.js +172 -170
  20. package/dist/mixpanel.module.d.ts +84 -13
  21. package/dist/mixpanel.module.js +860 -140
  22. package/dist/mixpanel.umd.d.ts +84 -13
  23. package/dist/mixpanel.umd.js +860 -140
  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 +84 -13
  34. package/src/mixpanel-core.js +127 -10
  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
  39. package/src/window.js +3 -1
  40. package/.claude/settings.local.json +0 -9
@@ -15,7 +15,9 @@ if (typeof(window) === 'undefined') {
15
15
  screen: { width: 0, height: 0 },
16
16
  location: loc,
17
17
  addEventListener: function() {},
18
- removeEventListener: function() {}
18
+ removeEventListener: function() {},
19
+ dispatchEvent: function() {},
20
+ CustomEvent: function () {}
19
21
  };
20
22
  } else {
21
23
  win = window;
@@ -322,30 +324,30 @@ function _ts_values(o) {
322
324
  };
323
325
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
324
326
  }
325
- var __defProp = Object.defineProperty;
326
- var __defNormalProp = function(obj, key, value) {
327
- return key in obj ? __defProp(obj, key, {
327
+ var __defProp$1 = Object.defineProperty;
328
+ var __defNormalProp$1 = function(obj, key, value) {
329
+ return key in obj ? __defProp$1(obj, key, {
328
330
  enumerable: true,
329
331
  configurable: true,
330
332
  writable: true,
331
333
  value: value
332
334
  }) : obj[key] = value;
333
335
  };
334
- var __publicField = function(obj, key, value) {
335
- return __defNormalProp(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
336
+ var __publicField$1 = function(obj, key, value) {
337
+ return __defNormalProp$1(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
336
338
  };
337
339
  var _a;
338
- var __defProp$1 = Object.defineProperty;
339
- var __defNormalProp$1 = function(obj, key, value) {
340
- return key in obj ? __defProp$1(obj, key, {
340
+ var __defProp$1$1 = Object.defineProperty;
341
+ var __defNormalProp$1$1 = function(obj, key, value) {
342
+ return key in obj ? __defProp$1$1(obj, key, {
341
343
  enumerable: true,
342
344
  configurable: true,
343
345
  writable: true,
344
346
  value: value
345
347
  }) : obj[key] = value;
346
348
  };
347
- var __publicField$1 = function(obj, key, value) {
348
- return __defNormalProp$1(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
349
+ var __publicField$1$1 = function(obj, key, value) {
350
+ return __defNormalProp$1$1(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
349
351
  };
350
352
  var NodeType$3 = /* @__PURE__ */ function(NodeType2) {
351
353
  NodeType2[NodeType2["Document"] = 0] = "Document";
@@ -615,8 +617,8 @@ function isCSSStyleRule(rule2) {
615
617
  }
616
618
  var Mirror = /*#__PURE__*/ function() {
617
619
  function Mirror() {
618
- __publicField$1(this, "idNodeMap", /* @__PURE__ */ new Map());
619
- __publicField$1(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap());
620
+ __publicField$1$1(this, "idNodeMap", /* @__PURE__ */ new Map());
621
+ __publicField$1$1(this, "nodeMetaMap", /* @__PURE__ */ new WeakMap());
620
622
  }
621
623
  var _proto = Mirror.prototype;
622
624
  _proto.getId = function getId(n2) {
@@ -2500,7 +2502,8 @@ var nanoid$1$1 = function(size) {
2500
2502
  return id;
2501
2503
  };
2502
2504
  var nonSecure$1 = {
2503
- nanoid: nanoid$1$1};
2505
+ nanoid: nanoid$1$1
2506
+ };
2504
2507
  var SourceMapConsumer$2$1 = require$$2$1.SourceMapConsumer, SourceMapGenerator$2$1 = require$$2$1.SourceMapGenerator;
2505
2508
  var existsSync$1 = require$$2$1.existsSync, readFileSync$1 = require$$2$1.readFileSync;
2506
2509
  var dirname$1$1 = require$$2$1.dirname, join$1 = require$$2$1.join;
@@ -6651,7 +6654,8 @@ var nanoid$1 = function(size) {
6651
6654
  return id;
6652
6655
  };
6653
6656
  var nonSecure = {
6654
- nanoid: nanoid$1};
6657
+ nanoid: nanoid$1
6658
+ };
6655
6659
  var SourceMapConsumer$2 = require$$2.SourceMapConsumer, SourceMapGenerator$2 = require$$2.SourceMapGenerator;
6656
6660
  var existsSync = require$$2.existsSync, readFileSync = require$$2.readFileSync;
6657
6661
  var dirname$1 = require$$2.dirname, join = require$$2.join;
@@ -9811,7 +9815,7 @@ var Declaration22 = declaration;
9811
9815
  var LazyResult22 = lazyResult;
9812
9816
  var Container22 = container;
9813
9817
  var Processor22 = processor;
9814
- var stringify = stringify_1;
9818
+ var stringify$6 = stringify_1;
9815
9819
  var fromJSON = fromJSON_1;
9816
9820
  var Document222 = document$1$2;
9817
9821
  var Warning22 = warning;
@@ -9865,7 +9869,7 @@ postcss.plugin = function plugin2(name, initializer) {
9865
9869
  };
9866
9870
  return creator;
9867
9871
  };
9868
- postcss.stringify = stringify;
9872
+ postcss.stringify = stringify$6;
9869
9873
  postcss.parse = parse;
9870
9874
  postcss.fromJSON = fromJSON;
9871
9875
  postcss.list = list;
@@ -10115,7 +10119,7 @@ function querySelectorAll(n2, selectors) {
10115
10119
  function mutationObserverCtor() {
10116
10120
  return getUntaintedPrototype("MutationObserver").constructor;
10117
10121
  }
10118
- function patch(source, name, replacement) {
10122
+ function patch$2(source, name, replacement) {
10119
10123
  try {
10120
10124
  if (!(name in source)) {
10121
10125
  return function() {};
@@ -10152,7 +10156,7 @@ var index = {
10152
10156
  querySelector: querySelector,
10153
10157
  querySelectorAll: querySelectorAll,
10154
10158
  mutationObserver: mutationObserverCtor,
10155
- patch: patch
10159
+ patch: patch$2
10156
10160
  };
10157
10161
  function on(type, fn, target) {
10158
10162
  if (target === void 0) target = document;
@@ -10347,9 +10351,9 @@ function hasShadowRoot(n2) {
10347
10351
  }
10348
10352
  var StyleSheetMirror = /*#__PURE__*/ function() {
10349
10353
  function StyleSheetMirror() {
10350
- __publicField(this, "id", 1);
10351
- __publicField(this, "styleIDMap", /* @__PURE__ */ new WeakMap());
10352
- __publicField(this, "idStyleMap", /* @__PURE__ */ new Map());
10354
+ __publicField$1(this, "id", 1);
10355
+ __publicField$1(this, "styleIDMap", /* @__PURE__ */ new WeakMap());
10356
+ __publicField$1(this, "idStyleMap", /* @__PURE__ */ new Map());
10353
10357
  }
10354
10358
  var _proto = StyleSheetMirror.prototype;
10355
10359
  _proto.getId = function getId(stylesheet) {
@@ -10485,9 +10489,9 @@ function isNodeInLinkedList(n2) {
10485
10489
  }
10486
10490
  var DoubleLinkedList = /*#__PURE__*/ function() {
10487
10491
  function DoubleLinkedList() {
10488
- __publicField(this, "length", 0);
10489
- __publicField(this, "head", null);
10490
- __publicField(this, "tail", null);
10492
+ __publicField$1(this, "length", 0);
10493
+ __publicField$1(this, "head", null);
10494
+ __publicField$1(this, "tail", null);
10491
10495
  }
10492
10496
  var _proto = DoubleLinkedList.prototype;
10493
10497
  _proto.get = function get(position) {
@@ -10568,14 +10572,14 @@ var moveKey = function(id, parentId) {
10568
10572
  var MutationBuffer = /*#__PURE__*/ function() {
10569
10573
  function MutationBuffer() {
10570
10574
  var _this = this;
10571
- __publicField(this, "frozen", false);
10572
- __publicField(this, "locked", false);
10573
- __publicField(this, "texts", []);
10574
- __publicField(this, "attributes", []);
10575
- __publicField(this, "attributeMap", /* @__PURE__ */ new WeakMap());
10576
- __publicField(this, "removes", []);
10577
- __publicField(this, "mapRemoves", []);
10578
- __publicField(this, "movedMap", {});
10575
+ __publicField$1(this, "frozen", false);
10576
+ __publicField$1(this, "locked", false);
10577
+ __publicField$1(this, "texts", []);
10578
+ __publicField$1(this, "attributes", []);
10579
+ __publicField$1(this, "attributeMap", /* @__PURE__ */ new WeakMap());
10580
+ __publicField$1(this, "removes", []);
10581
+ __publicField$1(this, "mapRemoves", []);
10582
+ __publicField$1(this, "movedMap", {});
10579
10583
  /**
10580
10584
  * the browser MutationObserver emits multiple mutations after
10581
10585
  * a delay for performance reasons, making tracing added nodes hard
@@ -10592,37 +10596,37 @@ var MutationBuffer = /*#__PURE__*/ function() {
10592
10596
  * collect added nodes from the Set which have no duplicate copy. But
10593
10597
  * this also causes newly added nodes will not be serialized with id ASAP,
10594
10598
  * which means all the id related calculation should be lazy too.
10595
- */ __publicField(this, "addedSet", /* @__PURE__ */ new Set());
10596
- __publicField(this, "movedSet", /* @__PURE__ */ new Set());
10597
- __publicField(this, "droppedSet", /* @__PURE__ */ new Set());
10598
- __publicField(this, "removesSubTreeCache", /* @__PURE__ */ new Set());
10599
- __publicField(this, "mutationCb");
10600
- __publicField(this, "blockClass");
10601
- __publicField(this, "blockSelector");
10602
- __publicField(this, "maskTextClass");
10603
- __publicField(this, "maskTextSelector");
10604
- __publicField(this, "inlineStylesheet");
10605
- __publicField(this, "maskInputOptions");
10606
- __publicField(this, "maskTextFn");
10607
- __publicField(this, "maskInputFn");
10608
- __publicField(this, "keepIframeSrcFn");
10609
- __publicField(this, "recordCanvas");
10610
- __publicField(this, "inlineImages");
10611
- __publicField(this, "slimDOMOptions");
10612
- __publicField(this, "dataURLOptions");
10613
- __publicField(this, "doc");
10614
- __publicField(this, "mirror");
10615
- __publicField(this, "iframeManager");
10616
- __publicField(this, "stylesheetManager");
10617
- __publicField(this, "shadowDomManager");
10618
- __publicField(this, "canvasManager");
10619
- __publicField(this, "processedNodeManager");
10620
- __publicField(this, "unattachedDoc");
10621
- __publicField(this, "processMutations", function(mutations) {
10599
+ */ __publicField$1(this, "addedSet", /* @__PURE__ */ new Set());
10600
+ __publicField$1(this, "movedSet", /* @__PURE__ */ new Set());
10601
+ __publicField$1(this, "droppedSet", /* @__PURE__ */ new Set());
10602
+ __publicField$1(this, "removesSubTreeCache", /* @__PURE__ */ new Set());
10603
+ __publicField$1(this, "mutationCb");
10604
+ __publicField$1(this, "blockClass");
10605
+ __publicField$1(this, "blockSelector");
10606
+ __publicField$1(this, "maskTextClass");
10607
+ __publicField$1(this, "maskTextSelector");
10608
+ __publicField$1(this, "inlineStylesheet");
10609
+ __publicField$1(this, "maskInputOptions");
10610
+ __publicField$1(this, "maskTextFn");
10611
+ __publicField$1(this, "maskInputFn");
10612
+ __publicField$1(this, "keepIframeSrcFn");
10613
+ __publicField$1(this, "recordCanvas");
10614
+ __publicField$1(this, "inlineImages");
10615
+ __publicField$1(this, "slimDOMOptions");
10616
+ __publicField$1(this, "dataURLOptions");
10617
+ __publicField$1(this, "doc");
10618
+ __publicField$1(this, "mirror");
10619
+ __publicField$1(this, "iframeManager");
10620
+ __publicField$1(this, "stylesheetManager");
10621
+ __publicField$1(this, "shadowDomManager");
10622
+ __publicField$1(this, "canvasManager");
10623
+ __publicField$1(this, "processedNodeManager");
10624
+ __publicField$1(this, "unattachedDoc");
10625
+ __publicField$1(this, "processMutations", function(mutations) {
10622
10626
  mutations.forEach(_this.processMutation);
10623
10627
  _this.emit();
10624
10628
  });
10625
- __publicField(this, "emit", function() {
10629
+ __publicField$1(this, "emit", function() {
10626
10630
  if (_this.frozen || _this.locked) {
10627
10631
  return;
10628
10632
  }
@@ -10823,7 +10827,7 @@ var MutationBuffer = /*#__PURE__*/ function() {
10823
10827
  _this.movedMap = {};
10824
10828
  _this.mutationCb(payload);
10825
10829
  });
10826
- __publicField(this, "genTextAreaValueMutation", function(textarea) {
10830
+ __publicField$1(this, "genTextAreaValueMutation", function(textarea) {
10827
10831
  var item = _this.attributeMap.get(textarea);
10828
10832
  if (!item) {
10829
10833
  item = {
@@ -10847,7 +10851,7 @@ var MutationBuffer = /*#__PURE__*/ function() {
10847
10851
  maskInputFn: _this.maskInputFn
10848
10852
  });
10849
10853
  });
10850
- __publicField(this, "processMutation", function(m) {
10854
+ __publicField$1(this, "processMutation", function(m) {
10851
10855
  if (isIgnored(m.target, _this.mirror, _this.slimDOMOptions)) {
10852
10856
  return;
10853
10857
  }
@@ -10992,7 +10996,7 @@ var MutationBuffer = /*#__PURE__*/ function() {
10992
10996
  });
10993
10997
  /**
10994
10998
  * Make sure you check if `n`'s parent is blocked before calling this function
10995
- * */ __publicField(this, "genAdds", function(n2, target) {
10999
+ * */ __publicField$1(this, "genAdds", function(n2, target) {
10996
11000
  if (_this.processedNodeManager.inOtherBuffer(n2, _this)) return;
10997
11001
  if (_this.addedSet.has(n2) || _this.movedSet.has(n2)) return;
10998
11002
  if (_this.mirror.hasNode(n2)) {
@@ -11838,7 +11842,7 @@ function initFontObserver(param) {
11838
11842
  });
11839
11843
  return fontFace;
11840
11844
  };
11841
- var restoreHandler = patch(doc.fonts, "add", function(original) {
11845
+ var restoreHandler = patch$2(doc.fonts, "add", function(original) {
11842
11846
  return function(fontFace) {
11843
11847
  setTimeout(callbackWrapper(function() {
11844
11848
  var p = fontMap.get(fontFace);
@@ -11894,7 +11898,7 @@ function initCustomElementObserver(param) {
11894
11898
  var doc = param.doc, customElementCb = param.customElementCb;
11895
11899
  var win = doc.defaultView;
11896
11900
  if (!win || !win.customElements) return function() {};
11897
- var restoreHandler = patch(win.customElements, "define", function(original) {
11901
+ var restoreHandler = patch$2(win.customElements, "define", function(original) {
11898
11902
  return function(name, constructor, options) {
11899
11903
  try {
11900
11904
  customElementCb({
@@ -12121,8 +12125,8 @@ function canMonkeyPatchNestedCSSRule(prop) {
12121
12125
  }
12122
12126
  var CrossOriginIframeMirror = /*#__PURE__*/ function() {
12123
12127
  function CrossOriginIframeMirror(generateIdFn) {
12124
- __publicField(this, "iframeIdToRemoteIdMap", /* @__PURE__ */ new WeakMap());
12125
- __publicField(this, "iframeRemoteIdToIdMap", /* @__PURE__ */ new WeakMap());
12128
+ __publicField$1(this, "iframeIdToRemoteIdMap", /* @__PURE__ */ new WeakMap());
12129
+ __publicField$1(this, "iframeRemoteIdToIdMap", /* @__PURE__ */ new WeakMap());
12126
12130
  this.generateIdFn = generateIdFn;
12127
12131
  }
12128
12132
  var _proto = CrossOriginIframeMirror.prototype;
@@ -12188,17 +12192,17 @@ var CrossOriginIframeMirror = /*#__PURE__*/ function() {
12188
12192
  }();
12189
12193
  var IframeManager = /*#__PURE__*/ function() {
12190
12194
  function IframeManager(options) {
12191
- __publicField(this, "iframes", /* @__PURE__ */ new WeakMap());
12192
- __publicField(this, "crossOriginIframeMap", /* @__PURE__ */ new WeakMap());
12193
- __publicField(this, "crossOriginIframeMirror", new CrossOriginIframeMirror(genId));
12194
- __publicField(this, "crossOriginIframeStyleMirror");
12195
- __publicField(this, "crossOriginIframeRootIdMap", /* @__PURE__ */ new WeakMap());
12196
- __publicField(this, "mirror");
12197
- __publicField(this, "mutationCb");
12198
- __publicField(this, "wrappedEmit");
12199
- __publicField(this, "loadListener");
12200
- __publicField(this, "stylesheetManager");
12201
- __publicField(this, "recordCrossOriginIframes");
12195
+ __publicField$1(this, "iframes", /* @__PURE__ */ new WeakMap());
12196
+ __publicField$1(this, "crossOriginIframeMap", /* @__PURE__ */ new WeakMap());
12197
+ __publicField$1(this, "crossOriginIframeMirror", new CrossOriginIframeMirror(genId));
12198
+ __publicField$1(this, "crossOriginIframeStyleMirror");
12199
+ __publicField$1(this, "crossOriginIframeRootIdMap", /* @__PURE__ */ new WeakMap());
12200
+ __publicField$1(this, "mirror");
12201
+ __publicField$1(this, "mutationCb");
12202
+ __publicField$1(this, "wrappedEmit");
12203
+ __publicField$1(this, "loadListener");
12204
+ __publicField$1(this, "stylesheetManager");
12205
+ __publicField$1(this, "recordCrossOriginIframes");
12202
12206
  this.mutationCb = options.mutationCb;
12203
12207
  this.wrappedEmit = options.wrappedEmit;
12204
12208
  this.stylesheetManager = options.stylesheetManager;
@@ -12445,12 +12449,12 @@ var IframeManager = /*#__PURE__*/ function() {
12445
12449
  }();
12446
12450
  var ShadowDomManager = /*#__PURE__*/ function() {
12447
12451
  function ShadowDomManager(options) {
12448
- __publicField(this, "shadowDoms", /* @__PURE__ */ new WeakSet());
12449
- __publicField(this, "mutationCb");
12450
- __publicField(this, "scrollCb");
12451
- __publicField(this, "bypassOptions");
12452
- __publicField(this, "mirror");
12453
- __publicField(this, "restoreHandlers", []);
12452
+ __publicField$1(this, "shadowDoms", /* @__PURE__ */ new WeakSet());
12453
+ __publicField$1(this, "mutationCb");
12454
+ __publicField$1(this, "scrollCb");
12455
+ __publicField$1(this, "bypassOptions");
12456
+ __publicField$1(this, "mirror");
12457
+ __publicField$1(this, "restoreHandlers", []);
12454
12458
  this.mutationCb = options.mutationCb;
12455
12459
  this.scrollCb = options.scrollCb;
12456
12460
  this.bypassOptions = options.bypassOptions;
@@ -12501,7 +12505,7 @@ var ShadowDomManager = /*#__PURE__*/ function() {
12501
12505
  * Patch 'attachShadow' to observe newly added shadow doms.
12502
12506
  */ _proto.patchAttachShadow = function patchAttachShadow(element, doc) {
12503
12507
  var manager = this;
12504
- this.restoreHandlers.push(patch(element.prototype, "attachShadow", function(original) {
12508
+ this.restoreHandlers.push(patch$2(element.prototype, "attachShadow", function(original) {
12505
12509
  return function(option) {
12506
12510
  var sRoot = original.call(this, option);
12507
12511
  var shadowRootEl = index.shadowRoot(this);
@@ -12667,7 +12671,7 @@ function initCanvas2DMutationObserver(cb, win, blockClass, blockSelector) {
12667
12671
  if (typeof win.CanvasRenderingContext2D.prototype[prop] !== "function") {
12668
12672
  return "continue";
12669
12673
  }
12670
- var restoreHandler = patch(win.CanvasRenderingContext2D.prototype, prop, function(original) {
12674
+ var restoreHandler = patch$2(win.CanvasRenderingContext2D.prototype, prop, function(original) {
12671
12675
  return function() {
12672
12676
  var _this = this;
12673
12677
  for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
@@ -12718,7 +12722,7 @@ function getNormalizedContextName(contextType) {
12718
12722
  function initCanvasContextObserver(win, blockClass, blockSelector, setPreserveDrawingBufferToTrue) {
12719
12723
  var handlers = [];
12720
12724
  try {
12721
- var restoreHandler = patch(win.HTMLCanvasElement.prototype, "getContext", function(original) {
12725
+ var restoreHandler = patch$2(win.HTMLCanvasElement.prototype, "getContext", function(original) {
12722
12726
  return function(contextType) {
12723
12727
  for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
12724
12728
  args[_key - 1] = arguments[_key];
@@ -12773,7 +12777,7 @@ function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win) {
12773
12777
  if (typeof prototype[prop] !== "function") {
12774
12778
  return "continue";
12775
12779
  }
12776
- var restoreHandler = patch(prototype, prop, function(original) {
12780
+ var restoreHandler = patch$2(prototype, prop, function(original) {
12777
12781
  return function() {
12778
12782
  for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
12779
12783
  args[_key] = arguments[_key];
@@ -12862,17 +12866,17 @@ function WorkerWrapper(options) {
12862
12866
  var CanvasManager = /*#__PURE__*/ function() {
12863
12867
  function CanvasManager(options) {
12864
12868
  var _this = this;
12865
- __publicField(this, "pendingCanvasMutations", /* @__PURE__ */ new Map());
12866
- __publicField(this, "rafStamps", {
12869
+ __publicField$1(this, "pendingCanvasMutations", /* @__PURE__ */ new Map());
12870
+ __publicField$1(this, "rafStamps", {
12867
12871
  latestId: 0,
12868
12872
  invokeId: null
12869
12873
  });
12870
- __publicField(this, "mirror");
12871
- __publicField(this, "mutationCb");
12872
- __publicField(this, "resetObservers");
12873
- __publicField(this, "frozen", false);
12874
- __publicField(this, "locked", false);
12875
- __publicField(this, "processMutation", function(target, mutation) {
12874
+ __publicField$1(this, "mirror");
12875
+ __publicField$1(this, "mutationCb");
12876
+ __publicField$1(this, "resetObservers");
12877
+ __publicField$1(this, "frozen", false);
12878
+ __publicField$1(this, "locked", false);
12879
+ __publicField$1(this, "processMutation", function(target, mutation) {
12876
12880
  var newFrame = _this.rafStamps.invokeId && _this.rafStamps.latestId !== _this.rafStamps.invokeId;
12877
12881
  if (newFrame || !_this.rafStamps.invokeId) _this.rafStamps.invokeId = _this.rafStamps.latestId;
12878
12882
  if (!_this.pendingCanvasMutations.has(target)) {
@@ -13085,10 +13089,10 @@ var CanvasManager = /*#__PURE__*/ function() {
13085
13089
  }();
13086
13090
  var StylesheetManager = /*#__PURE__*/ function() {
13087
13091
  function StylesheetManager(options) {
13088
- __publicField(this, "trackedLinkElements", /* @__PURE__ */ new WeakSet());
13089
- __publicField(this, "mutationCb");
13090
- __publicField(this, "adoptedStyleSheetCb");
13091
- __publicField(this, "styleMirror", new StyleSheetMirror());
13092
+ __publicField$1(this, "trackedLinkElements", /* @__PURE__ */ new WeakSet());
13093
+ __publicField$1(this, "mutationCb");
13094
+ __publicField$1(this, "adoptedStyleSheetCb");
13095
+ __publicField$1(this, "styleMirror", new StyleSheetMirror());
13092
13096
  this.mutationCb = options.mutationCb;
13093
13097
  this.adoptedStyleSheetCb = options.adoptedStyleSheetCb;
13094
13098
  }
@@ -13150,8 +13154,8 @@ var StylesheetManager = /*#__PURE__*/ function() {
13150
13154
  }();
13151
13155
  var ProcessedNodeManager = /*#__PURE__*/ function() {
13152
13156
  function ProcessedNodeManager() {
13153
- __publicField(this, "nodeMap", /* @__PURE__ */ new WeakMap());
13154
- __publicField(this, "active", false);
13157
+ __publicField$1(this, "nodeMap", /* @__PURE__ */ new WeakMap());
13158
+ __publicField$1(this, "active", false);
13155
13159
  }
13156
13160
  var _proto = ProcessedNodeManager.prototype;
13157
13161
  _proto.inOtherBuffer = function inOtherBuffer(node2, thisBuffer) {
@@ -13676,6 +13680,493 @@ var n;
13676
13680
  record.addCustomEvent;
13677
13681
  record.freezePage;
13678
13682
  record.takeFullSnapshot;
13683
+ var __defProp = Object.defineProperty;
13684
+ var __defNormalProp = function(obj, key, value) {
13685
+ return key in obj ? __defProp(obj, key, {
13686
+ enumerable: true,
13687
+ configurable: true,
13688
+ writable: true,
13689
+ value: value
13690
+ }) : obj[key] = value;
13691
+ };
13692
+ var __publicField = function(obj, key, value) {
13693
+ return __defNormalProp(obj, (typeof key === "undefined" ? "undefined" : _type_of(key)) !== "symbol" ? key + "" : key, value);
13694
+ };
13695
+ function patch(source, name, replacement) {
13696
+ try {
13697
+ if (!(name in source)) {
13698
+ return function() {};
13699
+ }
13700
+ var original = source[name];
13701
+ var wrapped = replacement(original);
13702
+ if (typeof wrapped === "function") {
13703
+ wrapped.prototype = wrapped.prototype || {};
13704
+ Object.defineProperties(wrapped, {
13705
+ __rrweb_original__: {
13706
+ enumerable: false,
13707
+ value: original
13708
+ }
13709
+ });
13710
+ }
13711
+ source[name] = wrapped;
13712
+ return function() {
13713
+ source[name] = original;
13714
+ };
13715
+ } catch (e) {
13716
+ return function() {};
13717
+ }
13718
+ }
13719
+ var StackFrame = /*#__PURE__*/ function() {
13720
+ function StackFrame(obj) {
13721
+ __publicField(this, "fileName");
13722
+ __publicField(this, "functionName");
13723
+ __publicField(this, "lineNumber");
13724
+ __publicField(this, "columnNumber");
13725
+ this.fileName = obj.fileName || "";
13726
+ this.functionName = obj.functionName || "";
13727
+ this.lineNumber = obj.lineNumber;
13728
+ this.columnNumber = obj.columnNumber;
13729
+ }
13730
+ var _proto = StackFrame.prototype;
13731
+ _proto.toString = function toString() {
13732
+ var lineNumber = this.lineNumber || "";
13733
+ var columnNumber = this.columnNumber || "";
13734
+ if (this.functionName) return this.functionName + " (" + this.fileName + ":" + lineNumber + ":" + columnNumber + ")";
13735
+ return this.fileName + ":" + lineNumber + ":" + columnNumber;
13736
+ };
13737
+ return StackFrame;
13738
+ }();
13739
+ var FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\S+:\d+/;
13740
+ var CHROME_IE_STACK_REGEXP = /^\s*at .*(\S+:\d+|\(native\))/m;
13741
+ var SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\[native code])?$/;
13742
+ var ErrorStackParser = {
13743
+ /**
13744
+ * Given an Error object, extract the most information from it.
13745
+ */ parse: function parse(error) {
13746
+ if (!error) {
13747
+ return [];
13748
+ }
13749
+ if (// eslint-disable-next-line @typescript-eslint/ban-ts-comment
13750
+ // @ts-ignore
13751
+ typeof error.stacktrace !== "undefined" || // eslint-disable-next-line @typescript-eslint/ban-ts-comment
13752
+ // @ts-ignore
13753
+ typeof error["opera#sourceloc"] !== "undefined") {
13754
+ return this.parseOpera(error);
13755
+ } else if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP)) {
13756
+ return this.parseV8OrIE(error);
13757
+ } else if (error.stack) {
13758
+ return this.parseFFOrSafari(error);
13759
+ } else {
13760
+ console.warn("[console-record-plugin]: Failed to parse error object:", error);
13761
+ return [];
13762
+ }
13763
+ },
13764
+ // Separate line and column numbers from a string of the form: (URI:Line:Column)
13765
+ extractLocation: function extractLocation(urlLike) {
13766
+ if (urlLike.indexOf(":") === -1) {
13767
+ return [
13768
+ urlLike
13769
+ ];
13770
+ }
13771
+ var regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
13772
+ var parts = regExp.exec(urlLike.replace(/[()]/g, ""));
13773
+ if (!parts) throw new Error("Cannot parse given url: " + urlLike);
13774
+ return [
13775
+ parts[1],
13776
+ parts[2] || void 0,
13777
+ parts[3] || void 0
13778
+ ];
13779
+ },
13780
+ parseV8OrIE: function parseV8OrIE(error) {
13781
+ var filtered = error.stack.split("\n").filter(function(line) {
13782
+ return !!line.match(CHROME_IE_STACK_REGEXP);
13783
+ }, this);
13784
+ return filtered.map(function(line) {
13785
+ if (line.indexOf("(eval ") > -1) {
13786
+ line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(\),.*$)/g, "");
13787
+ }
13788
+ var sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(");
13789
+ var location = sanitizedLine.match(/ (\((.+):(\d+):(\d+)\)$)/);
13790
+ sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine;
13791
+ var tokens = sanitizedLine.split(/\s+/).slice(1);
13792
+ var locationParts = this.extractLocation(location ? location[1] : tokens.pop());
13793
+ var functionName = tokens.join(" ") || void 0;
13794
+ var fileName = [
13795
+ "eval",
13796
+ "<anonymous>"
13797
+ ].indexOf(locationParts[0]) > -1 ? void 0 : locationParts[0];
13798
+ return new StackFrame({
13799
+ functionName: functionName,
13800
+ fileName: fileName,
13801
+ lineNumber: locationParts[1],
13802
+ columnNumber: locationParts[2]
13803
+ });
13804
+ }, this);
13805
+ },
13806
+ parseFFOrSafari: function parseFFOrSafari(error) {
13807
+ var filtered = error.stack.split("\n").filter(function(line) {
13808
+ return !line.match(SAFARI_NATIVE_CODE_REGEXP);
13809
+ }, this);
13810
+ return filtered.map(function(line) {
13811
+ if (line.indexOf(" > eval") > -1) {
13812
+ line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1");
13813
+ }
13814
+ if (line.indexOf("@") === -1 && line.indexOf(":") === -1) {
13815
+ return new StackFrame({
13816
+ functionName: line
13817
+ });
13818
+ } else {
13819
+ var functionNameRegex = /((.*".+"[^@]*)?[^@]*)(?:@)/;
13820
+ var matches = line.match(functionNameRegex);
13821
+ var functionName = matches && matches[1] ? matches[1] : void 0;
13822
+ var locationParts = this.extractLocation(line.replace(functionNameRegex, ""));
13823
+ return new StackFrame({
13824
+ functionName: functionName,
13825
+ fileName: locationParts[0],
13826
+ lineNumber: locationParts[1],
13827
+ columnNumber: locationParts[2]
13828
+ });
13829
+ }
13830
+ }, this);
13831
+ },
13832
+ parseOpera: function parseOpera(e) {
13833
+ if (!e.stacktrace || e.message.indexOf("\n") > -1 && e.message.split("\n").length > e.stacktrace.split("\n").length) {
13834
+ return this.parseOpera9(e);
13835
+ } else if (!e.stack) {
13836
+ return this.parseOpera10(e);
13837
+ } else {
13838
+ return this.parseOpera11(e);
13839
+ }
13840
+ },
13841
+ parseOpera9: function parseOpera9(e) {
13842
+ var lineRE = /Line (\d+).*script (?:in )?(\S+)/i;
13843
+ var lines = e.message.split("\n");
13844
+ var result = [];
13845
+ for(var i = 2, len = lines.length; i < len; i += 2){
13846
+ var match = lineRE.exec(lines[i]);
13847
+ if (match) {
13848
+ result.push(new StackFrame({
13849
+ fileName: match[2],
13850
+ lineNumber: parseFloat(match[1])
13851
+ }));
13852
+ }
13853
+ }
13854
+ return result;
13855
+ },
13856
+ parseOpera10: function parseOpera10(e) {
13857
+ var lineRE = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i;
13858
+ var lines = e.stacktrace.split("\n");
13859
+ var result = [];
13860
+ for(var i = 0, len = lines.length; i < len; i += 2){
13861
+ var match = lineRE.exec(lines[i]);
13862
+ if (match) {
13863
+ result.push(new StackFrame({
13864
+ functionName: match[3] || void 0,
13865
+ fileName: match[2],
13866
+ lineNumber: parseFloat(match[1])
13867
+ }));
13868
+ }
13869
+ }
13870
+ return result;
13871
+ },
13872
+ // Opera 10.65+ Error.stack very similar to FF/Safari
13873
+ parseOpera11: function parseOpera11(error) {
13874
+ var filtered = error.stack.split("\n").filter(function(line) {
13875
+ return !!line.match(FIREFOX_SAFARI_STACK_REGEXP) && !line.match(/^Error created at/);
13876
+ }, this);
13877
+ return filtered.map(function(line) {
13878
+ var tokens = line.split("@");
13879
+ var locationParts = this.extractLocation(tokens.pop());
13880
+ var functionCall = tokens.shift() || "";
13881
+ var functionName = functionCall.replace(/<anonymous function(: (\w+))?>/, "$2").replace(/\([^)]*\)/g, "") || void 0;
13882
+ return new StackFrame({
13883
+ functionName: functionName,
13884
+ fileName: locationParts[0],
13885
+ lineNumber: locationParts[1],
13886
+ columnNumber: locationParts[2]
13887
+ });
13888
+ }, this);
13889
+ }
13890
+ };
13891
+ function pathToSelector(node) {
13892
+ if (!node || !node.outerHTML) {
13893
+ return "";
13894
+ }
13895
+ var path = "";
13896
+ while(node.parentElement){
13897
+ var name = node.localName;
13898
+ if (!name) {
13899
+ break;
13900
+ }
13901
+ name = name.toLowerCase();
13902
+ var parent = node.parentElement;
13903
+ var domSiblings = [];
13904
+ if (parent.children && parent.children.length > 0) {
13905
+ for(var i = 0; i < parent.children.length; i++){
13906
+ var sibling = parent.children[i];
13907
+ if (sibling.localName && sibling.localName.toLowerCase) {
13908
+ if (sibling.localName.toLowerCase() === name) {
13909
+ domSiblings.push(sibling);
13910
+ }
13911
+ }
13912
+ }
13913
+ }
13914
+ if (domSiblings.length > 1) {
13915
+ name += ":eq(" + domSiblings.indexOf(node) + ")";
13916
+ }
13917
+ path = name + (path ? ">" + path : "");
13918
+ node = parent;
13919
+ }
13920
+ return path;
13921
+ }
13922
+ function isObject(obj) {
13923
+ return Object.prototype.toString.call(obj) === "[object Object]";
13924
+ }
13925
+ function isObjTooDeep(obj, limit) {
13926
+ if (limit === 0) {
13927
+ return true;
13928
+ }
13929
+ var keys = Object.keys(obj);
13930
+ for(var _iterator = _create_for_of_iterator_helper_loose(keys), _step; !(_step = _iterator()).done;){
13931
+ var key = _step.value;
13932
+ if (isObject(obj[key]) && isObjTooDeep(obj[key], limit - 1)) {
13933
+ return true;
13934
+ }
13935
+ }
13936
+ return false;
13937
+ }
13938
+ function stringify(obj, stringifyOptions) {
13939
+ var options = {
13940
+ numOfKeysLimit: 50,
13941
+ depthOfLimit: 4
13942
+ };
13943
+ Object.assign(options, stringifyOptions);
13944
+ var stack = [];
13945
+ var keys = [];
13946
+ return JSON.stringify(obj, function(key, value) {
13947
+ if (stack.length > 0) {
13948
+ var thisPos = stack.indexOf(this);
13949
+ ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
13950
+ ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
13951
+ if (~stack.indexOf(value)) {
13952
+ if (stack[0] === value) {
13953
+ value = "[Circular ~]";
13954
+ } else {
13955
+ value = "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
13956
+ }
13957
+ }
13958
+ } else {
13959
+ stack.push(value);
13960
+ }
13961
+ if (value === null) return value;
13962
+ if (value === void 0) return "undefined";
13963
+ if (shouldIgnore(value)) {
13964
+ return toString(value);
13965
+ }
13966
+ if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "bigint") {
13967
+ return value.toString() + "n";
13968
+ }
13969
+ if (_instanceof(value, Event)) {
13970
+ var eventResult = {};
13971
+ for(var eventKey in value){
13972
+ var eventValue = value[eventKey];
13973
+ if (Array.isArray(eventValue)) {
13974
+ eventResult[eventKey] = pathToSelector(eventValue.length ? eventValue[0] : null);
13975
+ } else {
13976
+ eventResult[eventKey] = eventValue;
13977
+ }
13978
+ }
13979
+ return eventResult;
13980
+ } else if (_instanceof(value, Node)) {
13981
+ if (_instanceof(value, HTMLElement)) {
13982
+ return value ? value.outerHTML : "";
13983
+ }
13984
+ return value.nodeName;
13985
+ } else if (_instanceof(value, Error)) {
13986
+ return value.stack ? value.stack + "\nEnd of stack for Error object" : value.name + ": " + value.message;
13987
+ }
13988
+ return value;
13989
+ });
13990
+ function shouldIgnore(_obj) {
13991
+ if (isObject(_obj) && Object.keys(_obj).length > options.numOfKeysLimit) {
13992
+ return true;
13993
+ }
13994
+ if (typeof _obj === "function") {
13995
+ return true;
13996
+ }
13997
+ if (isObject(_obj) && isObjTooDeep(_obj, options.depthOfLimit)) {
13998
+ return true;
13999
+ }
14000
+ return false;
14001
+ }
14002
+ function toString(_obj) {
14003
+ var str = _obj.toString();
14004
+ if (options.stringLengthLimit && str.length > options.stringLengthLimit) {
14005
+ str = "" + str.slice(0, options.stringLengthLimit) + "...";
14006
+ }
14007
+ return str;
14008
+ }
14009
+ }
14010
+ var defaultLogOptions = {
14011
+ level: [
14012
+ "assert",
14013
+ "clear",
14014
+ "count",
14015
+ "countReset",
14016
+ "debug",
14017
+ "dir",
14018
+ "dirxml",
14019
+ "error",
14020
+ "group",
14021
+ "groupCollapsed",
14022
+ "groupEnd",
14023
+ "info",
14024
+ "log",
14025
+ "table",
14026
+ "time",
14027
+ "timeEnd",
14028
+ "timeLog",
14029
+ "trace",
14030
+ "warn"
14031
+ ],
14032
+ lengthThreshold: 1e3,
14033
+ logger: "console"
14034
+ };
14035
+ function initLogObserver(cb, win, options) {
14036
+ var logOptions = options ? Object.assign({}, defaultLogOptions, options) : defaultLogOptions;
14037
+ var loggerType = logOptions.logger;
14038
+ if (!loggerType) {
14039
+ return function() {};
14040
+ }
14041
+ var logger;
14042
+ if (typeof loggerType === "string") {
14043
+ logger = win[loggerType];
14044
+ } else {
14045
+ logger = loggerType;
14046
+ }
14047
+ var logCount = 0;
14048
+ var inStack = false;
14049
+ var cancelHandlers = [];
14050
+ if (logOptions.level.includes("error")) {
14051
+ var errorHandler = function(event) {
14052
+ var message = event.message, error = event.error;
14053
+ var trace = ErrorStackParser.parse(error).map(function(stackFrame) {
14054
+ return stackFrame.toString();
14055
+ });
14056
+ var payload = [
14057
+ stringify(message, logOptions.stringifyOptions)
14058
+ ];
14059
+ cb({
14060
+ level: "error",
14061
+ trace: trace,
14062
+ payload: payload
14063
+ });
14064
+ };
14065
+ win.addEventListener("error", errorHandler);
14066
+ cancelHandlers.push(function() {
14067
+ win.removeEventListener("error", errorHandler);
14068
+ });
14069
+ var unhandledrejectionHandler = function(event) {
14070
+ var error;
14071
+ var payload;
14072
+ if (_instanceof(event.reason, Error)) {
14073
+ error = event.reason;
14074
+ payload = [
14075
+ stringify("Uncaught (in promise) " + error.name + ": " + error.message, logOptions.stringifyOptions)
14076
+ ];
14077
+ } else {
14078
+ error = new Error();
14079
+ payload = [
14080
+ stringify("Uncaught (in promise)", logOptions.stringifyOptions),
14081
+ stringify(event.reason, logOptions.stringifyOptions)
14082
+ ];
14083
+ }
14084
+ var trace = ErrorStackParser.parse(error).map(function(stackFrame) {
14085
+ return stackFrame.toString();
14086
+ });
14087
+ cb({
14088
+ level: "error",
14089
+ trace: trace,
14090
+ payload: payload
14091
+ });
14092
+ };
14093
+ win.addEventListener("unhandledrejection", unhandledrejectionHandler);
14094
+ cancelHandlers.push(function() {
14095
+ win.removeEventListener("unhandledrejection", unhandledrejectionHandler);
14096
+ });
14097
+ }
14098
+ for(var _iterator = _create_for_of_iterator_helper_loose(logOptions.level), _step; !(_step = _iterator()).done;){
14099
+ var levelType = _step.value;
14100
+ cancelHandlers.push(replace(logger, levelType));
14101
+ }
14102
+ return function() {
14103
+ cancelHandlers.forEach(function(h) {
14104
+ return h();
14105
+ });
14106
+ };
14107
+ function replace(_logger, level) {
14108
+ var _this = this;
14109
+ if (!_logger[level]) {
14110
+ return function() {};
14111
+ }
14112
+ return patch(_logger, level, function(original) {
14113
+ var _this1 = _this;
14114
+ return function() {
14115
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
14116
+ args[_key] = arguments[_key];
14117
+ }
14118
+ original.apply(_this1, args);
14119
+ if (level === "assert" && !!args[0]) {
14120
+ return;
14121
+ }
14122
+ if (inStack) {
14123
+ return;
14124
+ }
14125
+ inStack = true;
14126
+ try {
14127
+ var trace = ErrorStackParser.parse(new Error()).map(function(stackFrame) {
14128
+ return stackFrame.toString();
14129
+ }).splice(1);
14130
+ var argsForPayload = level === "assert" ? args.slice(1) : args;
14131
+ var payload = argsForPayload.map(function(s) {
14132
+ return stringify(s, logOptions.stringifyOptions);
14133
+ });
14134
+ logCount++;
14135
+ if (logCount < logOptions.lengthThreshold) {
14136
+ cb({
14137
+ level: level,
14138
+ trace: trace,
14139
+ payload: payload
14140
+ });
14141
+ } else if (logCount === logOptions.lengthThreshold) {
14142
+ cb({
14143
+ level: "warn",
14144
+ trace: [],
14145
+ payload: [
14146
+ stringify("The number of log records reached the threshold.")
14147
+ ]
14148
+ });
14149
+ }
14150
+ } catch (error) {
14151
+ original.apply(void 0, [].concat([
14152
+ "rrweb logger error:",
14153
+ error
14154
+ ], args));
14155
+ } finally{
14156
+ inStack = false;
14157
+ }
14158
+ };
14159
+ });
14160
+ }
14161
+ }
14162
+ var PLUGIN_NAME = "rrweb/console@1";
14163
+ var getRecordConsolePlugin = function(options) {
14164
+ return {
14165
+ name: PLUGIN_NAME,
14166
+ observer: initLogObserver,
14167
+ options: options
14168
+ };
14169
+ };
13679
14170
 
13680
14171
  var setImmediate = win['setImmediate'];
13681
14172
  var builtInProp, cycle, schedulingQueue,
@@ -14041,7 +14532,7 @@ if (typeof Promise !== 'undefined' && Promise.toString().indexOf('[native code]'
14041
14532
 
14042
14533
  var Config = {
14043
14534
  DEBUG: false,
14044
- LIB_VERSION: '2.71.1'
14535
+ LIB_VERSION: '2.73.0'
14045
14536
  };
14046
14537
 
14047
14538
  /* eslint camelcase: "off", eqeqeq: "off" */
@@ -15781,6 +16272,28 @@ if (typeof JSON !== 'undefined') {
15781
16272
  JSONStringify = JSONStringify || _.JSONEncode;
15782
16273
  JSONParse = JSONParse || _.JSONDecode;
15783
16274
 
16275
+ /**
16276
+ * Determines if CompressionStream API should be used.
16277
+ * Returns false for Safari 16.4 and 16.5 which have breaking CompressionStream bugs.
16278
+ * https://bugs.webkit.org/show_bug.cgi?id=254021
16279
+ * fixed in 16.6 https://developer.apple.com/documentation/safari-release-notes/safari-16_6-release-notes
16280
+ */
16281
+ var canUseCompressionStream = function(userAgent, vendor, opera) {
16282
+ if (!win.CompressionStream) {
16283
+ return false;
16284
+ }
16285
+
16286
+ var browser = _.info.browser(userAgent, vendor, opera);
16287
+ var version = _.info.browserVersion(userAgent, vendor, opera);
16288
+ if (browser === 'Safari' || browser === 'Mobile Safari') {
16289
+ if (version >= 16.4 && version < 16.6) {
16290
+ return false;
16291
+ }
16292
+ }
16293
+
16294
+ return true;
16295
+ };
16296
+
15784
16297
  // UNMINIFIED EXPORTS (for closure compiler)
15785
16298
  _['info'] = _.info;
15786
16299
  _['info']['browser'] = _.info.browser;
@@ -17156,6 +17669,7 @@ function isUserEvent(ev) {
17156
17669
  * @property {number} idleExpires
17157
17670
  * @property {number} maxExpires
17158
17671
  * @property {number} replayStartTime
17672
+ * @property {number} lastEventTimestamp
17159
17673
  * @property {number} seqNo
17160
17674
  * @property {string} batchStartUrl
17161
17675
  * @property {string} replayId
@@ -17176,6 +17690,7 @@ function isUserEvent(ev) {
17176
17690
  * @property {number} idleExpires
17177
17691
  * @property {number} maxExpires
17178
17692
  * @property {number} replayStartTime
17693
+ * @property {number} lastEventTimestamp - the unix timestamp of the last recorded event from rrweb
17179
17694
  * @property {number} seqNo
17180
17695
  * @property {string} batchStartUrl
17181
17696
  * @property {string} replayStartUrl
@@ -17209,6 +17724,7 @@ var SessionRecording = function(options) {
17209
17724
  this.idleExpires = options.idleExpires || null;
17210
17725
  this.maxExpires = options.maxExpires || null;
17211
17726
  this.replayStartTime = options.replayStartTime || null;
17727
+ this.lastEventTimestamp = options.lastEventTimestamp || null;
17212
17728
  this.seqNo = options.seqNo || 0;
17213
17729
 
17214
17730
  this.idleTimeoutId = null;
@@ -17268,10 +17784,20 @@ SessionRecording.prototype.getUserIdInfo = function () {
17268
17784
 
17269
17785
  SessionRecording.prototype.unloadPersistedData = function () {
17270
17786
  this.batcher.stop();
17271
- return this.batcher.flush()
17272
- .then(function () {
17787
+
17788
+ return this.queueStorage.init().catch(function () {
17789
+ this.reportError('Error initializing IndexedDB storage for unloading persisted data.');
17790
+ }.bind(this)).then(function () {
17791
+ // if the recording is too short, just delete any stored events without flushing
17792
+ if (this.getDurationMs() < this._getRecordMinMs()) {
17273
17793
  return this.queueStorage.removeItem(this.batcherKey);
17274
- }.bind(this));
17794
+ }
17795
+
17796
+ return this.batcher.flush()
17797
+ .then(function () {
17798
+ return this.queueStorage.removeItem(this.batcherKey);
17799
+ }.bind(this));
17800
+ }.bind(this));
17275
17801
  };
17276
17802
 
17277
17803
  SessionRecording.prototype.getConfig = function(configVar) {
@@ -17306,11 +17832,7 @@ SessionRecording.prototype.startRecording = function (shouldStopBatcher) {
17306
17832
  this.maxExpires = new Date().getTime() + this.recordMaxMs;
17307
17833
  }
17308
17834
 
17309
- this.recordMinMs = this.getConfig('record_min_ms');
17310
- if (this.recordMinMs > MAX_VALUE_FOR_MIN_RECORDING_MS) {
17311
- this.recordMinMs = MAX_VALUE_FOR_MIN_RECORDING_MS;
17312
- logger$3.critical('record_min_ms cannot be greater than ' + MAX_VALUE_FOR_MIN_RECORDING_MS + 'ms. Capping value.');
17313
- }
17835
+ this.recordMinMs = this._getRecordMinMs();
17314
17836
 
17315
17837
  if (!this.replayStartTime) {
17316
17838
  this.replayStartTime = new Date().getTime();
@@ -17358,6 +17880,11 @@ SessionRecording.prototype.startRecording = function (shouldStopBatcher) {
17358
17880
  }
17359
17881
  // promise only used to await during tests
17360
17882
  this.__enqueuePromise = this.batcher.enqueue(ev);
17883
+
17884
+ // Capture the timestamp of the last event for duration calculation.
17885
+ if (this.lastEventTimestamp === null || ev.timestamp > this.lastEventTimestamp) {
17886
+ this.lastEventTimestamp = ev.timestamp;
17887
+ }
17361
17888
  }.bind(this),
17362
17889
  'blockClass': this.getConfig('record_block_class'),
17363
17890
  'blockSelector': blockSelector,
@@ -17372,7 +17899,16 @@ SessionRecording.prototype.startRecording = function (shouldStopBatcher) {
17372
17899
  'recordCanvas': this.getConfig('record_canvas'),
17373
17900
  'sampling': {
17374
17901
  'canvas': 15
17375
- }
17902
+ },
17903
+ 'plugins': this.getConfig('record_console') ? [
17904
+ getRecordConsolePlugin({
17905
+ stringifyOptions: {
17906
+ stringLengthLimit: 1000,
17907
+ numOfKeysLimit: 50,
17908
+ depthOfLimit: 2
17909
+ }
17910
+ })
17911
+ ] : []
17376
17912
  });
17377
17913
  } catch (err) {
17378
17914
  this.reportError('Unexpected error when starting rrweb recording.', err);
@@ -17457,6 +17993,7 @@ SessionRecording.prototype.serialize = function () {
17457
17993
  'replayStartTime': this.replayStartTime,
17458
17994
  'batchStartUrl': this.batchStartUrl,
17459
17995
  'replayStartUrl': this.replayStartUrl,
17996
+ 'lastEventTimestamp': this.lastEventTimestamp,
17460
17997
  'idleExpires': this.idleExpires,
17461
17998
  'maxExpires': this.maxExpires,
17462
17999
  'tabId': tabId,
@@ -17478,6 +18015,7 @@ SessionRecording.deserialize = function (serializedRecording, options) {
17478
18015
  idleExpires: serializedRecording['idleExpires'],
17479
18016
  maxExpires: serializedRecording['maxExpires'],
17480
18017
  replayStartTime: serializedRecording['replayStartTime'],
18018
+ lastEventTimestamp: serializedRecording['lastEventTimestamp'],
17481
18019
  seqNo: serializedRecording['seqNo'],
17482
18020
  sharedLockStorage: options.sharedLockStorage,
17483
18021
  }));
@@ -17568,7 +18106,7 @@ SessionRecording.prototype._flushEvents = addOptOutCheckMixpanelLib(function (da
17568
18106
  var eventsJson = JSON.stringify(data);
17569
18107
  Object.assign(reqParams, this.getUserIdInfo());
17570
18108
 
17571
- if (CompressionStream) {
18109
+ if (canUseCompressionStream(userAgent, navigator.vendor, windowOpera)) {
17572
18110
  var jsonStream = new Blob([eventsJson], {type: 'application/json'}).stream();
17573
18111
  var gzipStream = jsonStream.pipeThrough(new CompressionStream('gzip'));
17574
18112
  new Response(gzipStream)
@@ -17597,6 +18135,38 @@ SessionRecording.prototype.reportError = function(msg, err) {
17597
18135
  }
17598
18136
  };
17599
18137
 
18138
+ /**
18139
+ * Calculates the duration of the recording in milliseconds, based on the start time and time of last recorded event.
18140
+ * @returns {number} The duration of the recording in milliseconds. Returns 0 if recording hasn't started.
18141
+ */
18142
+ SessionRecording.prototype.getDurationMs = function() {
18143
+ if (this.replayStartTime === null) {
18144
+ return 0;
18145
+ }
18146
+
18147
+ // If the recording has no events, assume it is in progress and use the current time as the end time.
18148
+ if (this.lastEventTimestamp === null) {
18149
+ return new Date().getTime() - this.replayStartTime;
18150
+ }
18151
+
18152
+ return this.lastEventTimestamp - this.replayStartTime;
18153
+ };
18154
+
18155
+ /**
18156
+ * Lazily loads the minimum recording length config in milliseconds, respecting the maximum limit.
18157
+ * @returns {number} The minimum recording length in milliseconds.
18158
+ */
18159
+ SessionRecording.prototype._getRecordMinMs = function() {
18160
+ var configValue = this.getConfig('record_min_ms');
18161
+
18162
+ if (configValue > MAX_VALUE_FOR_MIN_RECORDING_MS) {
18163
+ logger$3.critical('record_min_ms cannot be greater than ' + MAX_VALUE_FOR_MIN_RECORDING_MS + 'ms. Capping value.');
18164
+ return MAX_VALUE_FOR_MIN_RECORDING_MS;
18165
+ }
18166
+
18167
+ return configValue;
18168
+ };
18169
+
17600
18170
  /**
17601
18171
  * Module for handling the storage and retrieval of recording metadata as well as any active recordings.
17602
18172
  * Makes sure that only one tab can be recording at a time.
@@ -18606,20 +19176,65 @@ function isDefinitelyNonInteractive(element) {
18606
19176
  return false;
18607
19177
  }
18608
19178
 
19179
+ /**
19180
+ * Get the composed path of a click event for elements embedded in shadow DOM.
19181
+ * @param {Event} event - event to get the composed path from
19182
+ * @returns {Array} the composed path of the click event
19183
+ */
19184
+ function getClickEventComposedPath(event) {
19185
+ if ('composedPath' in event) {
19186
+ return event['composedPath']();
19187
+ }
19188
+
19189
+ return [];
19190
+ }
19191
+
19192
+ /**
19193
+ * Get the element from a click event, accounting for elements embedded in shadow DOM.
19194
+ * @param {Event} event - event to get the target from
19195
+ * @returns {Element | null} the element that was the target of the click event
19196
+ */
19197
+ function getClickEventTargetElement(event) {
19198
+ var path = getClickEventComposedPath(event);
19199
+
19200
+ if (path && path.length > 0) {
19201
+ return path[0];
19202
+ }
19203
+
19204
+ return event['target'] || event['srcElement'];
19205
+ }
19206
+
18609
19207
  /** @const */ var DEFAULT_RAGE_CLICK_THRESHOLD_PX = 30;
18610
19208
  /** @const */ var DEFAULT_RAGE_CLICK_TIMEOUT_MS = 1000;
18611
19209
  /** @const */ var DEFAULT_RAGE_CLICK_CLICK_COUNT = 4;
19210
+ /** @const */ var DEFAULT_RAGE_CLICK_INTERACTIVE_ELEMENTS_ONLY = false;
18612
19211
 
18613
19212
  function RageClickTracker() {
18614
19213
  this.clicks = [];
18615
19214
  }
18616
19215
 
18617
- RageClickTracker.prototype.isRageClick = function(x, y, options) {
19216
+ /**
19217
+ * Determines if a click event is part of a rage click sequence.
19218
+ * @param {Event} event - the original click event.
19219
+ * @param {import('../index.d.ts').RageClickConfig} options - configuration options for rage click detection.
19220
+ * @returns {boolean} - true if the click is considered a rage click, false otherwise.
19221
+ */
19222
+ RageClickTracker.prototype.isRageClick = function(event, options) {
18618
19223
  options = options || {};
18619
19224
  var thresholdPx = options['threshold_px'] || DEFAULT_RAGE_CLICK_THRESHOLD_PX;
18620
19225
  var timeoutMs = options['timeout_ms'] || DEFAULT_RAGE_CLICK_TIMEOUT_MS;
18621
19226
  var clickCount = options['click_count'] || DEFAULT_RAGE_CLICK_CLICK_COUNT;
19227
+ var interactiveElementsOnly = options['interactive_elements_only'] || DEFAULT_RAGE_CLICK_INTERACTIVE_ELEMENTS_ONLY;
19228
+
19229
+ if (interactiveElementsOnly) {
19230
+ var target = getClickEventTargetElement(event);
19231
+ if (!target || isDefinitelyNonInteractive(target)) {
19232
+ return false;
19233
+ }
19234
+ }
19235
+
18622
19236
  var timestamp = Date.now();
19237
+ var x = event['pageX'], y = event['pageY'];
18623
19238
 
18624
19239
  var lastClick = this.clicks[this.clicks.length - 1];
18625
19240
  if (
@@ -18650,28 +19265,16 @@ ShadowDOMObserver.prototype.getEventTarget = function(event) {
18650
19265
  if (!this.observedShadowRoots) {
18651
19266
  return;
18652
19267
  }
18653
- var path = this.getComposedPath(event);
18654
- if (path && path.length) {
18655
- return path[0];
18656
- }
18657
19268
 
18658
- return event['target'] || event['srcElement'];
19269
+ return getClickEventTargetElement(event);
18659
19270
  };
18660
19271
 
18661
-
18662
- ShadowDOMObserver.prototype.getComposedPath = function(event) {
18663
- if ('composedPath' in event) {
18664
- return event['composedPath']();
18665
- }
18666
-
18667
- return [];
18668
- };
18669
19272
  ShadowDOMObserver.prototype.observeFromEvent = function(event) {
18670
19273
  if (!this.observedShadowRoots) {
18671
19274
  return;
18672
19275
  }
18673
19276
 
18674
- var path = this.getComposedPath(event);
19277
+ var path = getClickEventComposedPath(event);
18675
19278
 
18676
19279
  // Check each element in path for shadow roots
18677
19280
  for (var i = 0; i < path.length; i++) {
@@ -19423,7 +20026,7 @@ Autocapture.prototype.initRageClickTracking = function() {
19423
20026
  return;
19424
20027
  }
19425
20028
 
19426
- if (this._rageClickTracker.isRageClick(ev['pageX'], ev['pageY'], currentRageClickConfig)) {
20029
+ if (this._rageClickTracker.isRageClick(ev, currentRageClickConfig)) {
19427
20030
  this.trackDomEvent(ev, MP_EV_RAGE_CLICK);
19428
20031
  }
19429
20032
  }.bind(this);
@@ -21197,8 +21800,6 @@ var mixpanel_master; // main mixpanel instance / object
21197
21800
  var INIT_MODULE = 0;
21198
21801
  var INIT_SNIPPET = 1;
21199
21802
 
21200
- var IDENTITY_FUNC = function(x) {return x;};
21201
-
21202
21803
  /** @const */ var PRIMARY_INSTANCE_NAME = 'mixpanel';
21203
21804
  /** @const */ var PAYLOAD_TYPE_BASE64 = 'base64';
21204
21805
  /** @const */ var PAYLOAD_TYPE_JSON = 'json';
@@ -21292,6 +21893,7 @@ var DEFAULT_CONFIG = {
21292
21893
  'record_block_selector': 'img, video, audio',
21293
21894
  'record_canvas': false,
21294
21895
  'record_collect_fonts': false,
21896
+ 'record_console': true,
21295
21897
  'record_heatmap_data': false,
21296
21898
  'record_idle_timeout_ms': 30 * 60 * 1000, // 30 minutes
21297
21899
  'record_mask_text_class': new RegExp('^(mp-mask|fs-mask|amp-mask|rr-mask|ph-mask)$'),
@@ -21363,6 +21965,17 @@ var create_mplib = function(token, config, name) {
21363
21965
  // global debug to be true
21364
21966
  Config.DEBUG = Config.DEBUG || instance.get_config('debug');
21365
21967
 
21968
+ var source = init_type === INIT_MODULE ? 'module' : 'snippet';
21969
+ win.dispatchEvent(new win.CustomEvent('$mp_sdk_to_extension_event', {
21970
+ 'detail': {
21971
+ 'instance': instance,
21972
+ 'source': source,
21973
+ 'token': token,
21974
+ 'name': name,
21975
+ 'info': _.info
21976
+ }
21977
+ }));
21978
+
21366
21979
  // if target is not defined, we called init after the lib already
21367
21980
  // loaded, so there won't be an array of things to execute
21368
21981
  if (!_.isUndefined(target) && _.isArray(target)) {
@@ -21433,6 +22046,8 @@ MixpanelLib.prototype._init = function(token, config, name) {
21433
22046
  }
21434
22047
  }
21435
22048
 
22049
+ this.hooks = {};
22050
+
21436
22051
  this.set_config(_.extend({}, DEFAULT_CONFIG, variable_features, config, {
21437
22052
  'name': name,
21438
22053
  'token': token,
@@ -22033,7 +22648,12 @@ MixpanelLib.prototype.init_batchers = function() {
22033
22648
  );
22034
22649
  }, this),
22035
22650
  beforeSendHook: _.bind(function(item) {
22036
- return this._run_hook('before_send_' + attrs.type, item);
22651
+ var ret = this._run_hook('before_send_' + attrs.type, item);
22652
+ if (ret) {
22653
+ return ret[0];
22654
+ } else {
22655
+ return null;
22656
+ }
22037
22657
  }, this),
22038
22658
  stopAllBatchingFunc: _.bind(this.stop_batch_senders, this),
22039
22659
  usePersistence: true,
@@ -22126,6 +22746,9 @@ MixpanelLib.prototype._track_or_batch = function(options, callback) {
22126
22746
  var send_request_immediately = _.bind(function() {
22127
22747
  if (!send_request_options.skip_hooks) {
22128
22748
  truncated_data = this._run_hook('before_send_' + options.type, truncated_data);
22749
+ if (truncated_data) {
22750
+ truncated_data = truncated_data[0];
22751
+ }
22129
22752
  }
22130
22753
  if (truncated_data) {
22131
22754
  console$1.log('MIXPANEL REQUEST:');
@@ -22180,6 +22803,17 @@ MixpanelLib.prototype._track_or_batch = function(options, callback) {
22180
22803
  * with the tracking payload sent to the API server is returned; otherwise false.
22181
22804
  */
22182
22805
  MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, properties, options, callback) {
22806
+ var ret;
22807
+ if (!(options && options.skip_hooks)) {
22808
+ ret = this._run_hook('before_track', event_name, properties);
22809
+ if (ret === null) {
22810
+ return;
22811
+ } else {
22812
+ event_name = ret[0];
22813
+ properties = ret[1];
22814
+ }
22815
+ }
22816
+
22183
22817
  if (!callback && typeof options === 'function') {
22184
22818
  callback = options;
22185
22819
  options = null;
@@ -22249,7 +22883,7 @@ MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, pro
22249
22883
  'event': event_name,
22250
22884
  'properties': properties
22251
22885
  };
22252
- var ret = this._track_or_batch({
22886
+ ret = this._track_or_batch({
22253
22887
  type: 'events',
22254
22888
  data: data,
22255
22889
  endpoint: this.get_api_host('events') + '/' + this.get_config('api_routes')['track'],
@@ -22595,6 +23229,14 @@ var options_for_register = function(days_or_options) {
22595
23229
  * @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
22596
23230
  */
22597
23231
  MixpanelLib.prototype.register = function(props, days_or_options) {
23232
+ var ret = this._run_hook('before_register', props, days_or_options);
23233
+ if (ret === null) {
23234
+ return;
23235
+ } else {
23236
+ props = ret[0];
23237
+ days_or_options = ret[1];
23238
+ }
23239
+
22598
23240
  var options = options_for_register(days_or_options);
22599
23241
  if (options['persistent']) {
22600
23242
  this['persistence'].register(props, options['days']);
@@ -22631,6 +23273,15 @@ MixpanelLib.prototype.register = function(props, days_or_options) {
22631
23273
  * @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
22632
23274
  */
22633
23275
  MixpanelLib.prototype.register_once = function(props, default_value, days_or_options) {
23276
+ var ret = this._run_hook('before_register_once', props, default_value, days_or_options);
23277
+ if (ret === null) {
23278
+ return;
23279
+ } else {
23280
+ props = ret[0];
23281
+ default_value = ret[1];
23282
+ days_or_options = ret[2];
23283
+ }
23284
+
22634
23285
  var options = options_for_register(days_or_options);
22635
23286
  if (options['persistent']) {
22636
23287
  this['persistence'].register_once(props, default_value, options['days']);
@@ -22654,6 +23305,14 @@ MixpanelLib.prototype.register_once = function(props, default_value, days_or_opt
22654
23305
  * @param {boolean} [options.persistent=true] - whether to look in persistent storage (cookie/localStorage)
22655
23306
  */
22656
23307
  MixpanelLib.prototype.unregister = function(property, options) {
23308
+ var ret = this._run_hook('before_unregister', property, options);
23309
+ if (ret === null) {
23310
+ return;
23311
+ } else {
23312
+ property = ret[0];
23313
+ options = ret[1];
23314
+ }
23315
+
22657
23316
  options = options_for_register(options);
22658
23317
  if (options['persistent']) {
22659
23318
  this['persistence'].unregister(property);
@@ -22702,6 +23361,13 @@ MixpanelLib.prototype.identify = function(
22702
23361
  // _set_once_callback:function A callback to be run if and when the People set_once queue is flushed
22703
23362
  // _union_callback:function A callback to be run if and when the People union queue is flushed
22704
23363
  // _unset_callback:function A callback to be run if and when the People unset queue is flushed
23364
+ var ret = this._run_hook('before_identify', new_distinct_id);
23365
+
23366
+ if (ret === null) {
23367
+ return -1;
23368
+ } else {
23369
+ new_distinct_id = ret[0];
23370
+ }
22705
23371
 
22706
23372
  var previous_distinct_id = this.get_distinct_id();
22707
23373
  if (new_distinct_id && previous_distinct_id !== new_distinct_id) {
@@ -23026,6 +23692,25 @@ MixpanelLib.prototype.set_config = function(config) {
23026
23692
  if (('autocapture' in config || 'record_heatmap_data' in config) && this.autocapture) {
23027
23693
  this.autocapture.init();
23028
23694
  }
23695
+
23696
+ if (_.isObject(config['hooks'])) {
23697
+ this.hooks = {};
23698
+ _.each(config['hooks'], function(hook_value, hook_name) {
23699
+ if (_.isFunction(hook_value)) {
23700
+ this.hooks[hook_name] = [hook_value];
23701
+ } else if (_.isArray(hook_value)) {
23702
+ this.hooks[hook_name] = [];
23703
+ for (var i = 0; i < hook_value.length; i++) {
23704
+ if (!_.isFunction(hook_value[i])) {
23705
+ console$1.critical('Invalid hook added. Hook is not a function');
23706
+ }
23707
+ this.hooks[hook_name].push(hook_value[i]);
23708
+ }
23709
+ } else {
23710
+ console$1.critical('Invalid hooks added. Ensure that the hook values passed into config.hooks are functions or arrays of functions.');
23711
+ }
23712
+ }, this);
23713
+ }
23029
23714
  }
23030
23715
  };
23031
23716
 
@@ -23043,12 +23728,26 @@ MixpanelLib.prototype.get_config = function(prop_name) {
23043
23728
  * @returns {any|null} return value of user-provided hook, or null if nothing was returned
23044
23729
  */
23045
23730
  MixpanelLib.prototype._run_hook = function(hook_name) {
23046
- var ret = (this['config']['hooks'][hook_name] || IDENTITY_FUNC).apply(this, slice.call(arguments, 1));
23047
- if (typeof ret === 'undefined') {
23048
- this.report_error(hook_name + ' hook did not return a value');
23049
- ret = null;
23050
- }
23051
- return ret;
23731
+ var hook_data = slice.call(arguments, 1);
23732
+ _.each(this.hooks[hook_name], function(hook) {
23733
+ if (hook_data === null) {
23734
+ return null;
23735
+ }
23736
+
23737
+ var ret = hook.apply(this, hook_data);
23738
+
23739
+ if (typeof ret === 'undefined') {
23740
+ this.report_error(hook_name + ' hook did not return a valid value');
23741
+ hook_data = null;
23742
+ } else {
23743
+ if (!_.isArray(ret)) {
23744
+ ret = [ret];
23745
+ }
23746
+ hook_data.splice.apply(hook_data, [0, ret.length].concat(ret));
23747
+ }
23748
+ }, this);
23749
+
23750
+ return hook_data;
23052
23751
  };
23053
23752
 
23054
23753
  /**
@@ -23359,6 +24058,25 @@ MixpanelLib.prototype.report_error = function(msg, err) {
23359
24058
  }
23360
24059
  };
23361
24060
 
24061
+ MixpanelLib.prototype.add_hook = function(hook_name, hook_fn) {
24062
+ if (!this.hooks[hook_name]) {
24063
+ this.hooks[hook_name] = [];
24064
+ }
24065
+ this.hooks[hook_name].push(hook_fn);
24066
+ };
24067
+
24068
+ MixpanelLib.prototype.remove_hook = function(hook_name, hook_fn) {
24069
+ var fn_index;
24070
+ if (this.hooks[hook_name]) {
24071
+ fn_index = this.hooks[hook_name].indexOf(hook_fn);
24072
+ if (fn_index !== -1) {
24073
+ this.hooks[hook_name].splice(fn_index, 1);
24074
+ } else {
24075
+ console$1.log('remove_hook failed. Matching hook was not found');
24076
+ }
24077
+ }
24078
+ };
24079
+
23362
24080
  // EXPORTS (for closure compiler)
23363
24081
 
23364
24082
  // MixpanelLib Exports
@@ -23391,6 +24109,8 @@ MixpanelLib.prototype['get_group'] = MixpanelLib.protot
23391
24109
  MixpanelLib.prototype['set_group'] = MixpanelLib.prototype.set_group;
23392
24110
  MixpanelLib.prototype['add_group'] = MixpanelLib.prototype.add_group;
23393
24111
  MixpanelLib.prototype['remove_group'] = MixpanelLib.prototype.remove_group;
24112
+ MixpanelLib.prototype['add_hook'] = MixpanelLib.prototype.add_hook;
24113
+ MixpanelLib.prototype['remove_hook'] = MixpanelLib.prototype.remove_hook;
23394
24114
  MixpanelLib.prototype['track_with_groups'] = MixpanelLib.prototype.track_with_groups;
23395
24115
  MixpanelLib.prototype['start_batch_senders'] = MixpanelLib.prototype.start_batch_senders;
23396
24116
  MixpanelLib.prototype['stop_batch_senders'] = MixpanelLib.prototype.stop_batch_senders;