mixpanel-browser 2.74.0 → 2.75.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.
- package/.github/workflows/unit-tests.yml +1 -1
- package/CHANGELOG.md +5 -0
- package/README.md +2 -2
- package/dist/mixpanel-core.cjs.js +318 -20
- package/dist/mixpanel-recorder.js +127 -15
- package/dist/mixpanel-recorder.min.js +1 -1
- package/dist/mixpanel-recorder.min.js.map +1 -1
- package/dist/mixpanel-targeting.js +2576 -0
- package/dist/mixpanel-targeting.min.js +2 -0
- package/dist/mixpanel-targeting.min.js.map +1 -0
- package/dist/mixpanel-with-async-modules.cjs.d.ts +522 -0
- package/dist/mixpanel-with-async-modules.cjs.js +9700 -0
- package/dist/mixpanel-with-async-recorder.cjs.js +318 -20
- package/dist/mixpanel-with-recorder.js +435 -26
- package/dist/mixpanel-with-recorder.min.js +1 -1
- package/dist/mixpanel.amd.js +1020 -28
- package/dist/mixpanel.cjs.js +1020 -28
- package/dist/mixpanel.globals.js +318 -20
- package/dist/mixpanel.min.js +179 -172
- package/dist/mixpanel.module.js +1020 -28
- package/dist/mixpanel.umd.js +1020 -28
- package/dist/rrweb-bundled.js +119 -5
- package/dist/rrweb-compiled.js +116 -5
- package/package.json +4 -3
- package/rollup.config.mjs +34 -2
- package/src/config.js +1 -1
- package/src/flags/index.js +269 -8
- package/src/globals.js +14 -0
- package/src/loaders/loader-module.js +1 -0
- package/src/mixpanel-core.js +12 -3
- package/src/recorder/index.js +2 -1
- package/src/targeting/event-matcher.js +97 -0
- package/src/targeting/index.js +11 -0
- package/src/targeting/loader.js +36 -0
- package/src/utils.js +1 -8
- package/.claude/settings.local.json +0 -12
- /package/src/loaders/{loader-module-with-async-recorder.js → loader-module-with-async-modules.js} +0 -0
|
@@ -26,6 +26,14 @@
|
|
|
26
26
|
win = window;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Shared global window property names used across modules
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
// Recorder library global (used by recorder and mixpanel-core)
|
|
35
|
+
var RECORDER_GLOBAL_NAME = '__mp_recorder';
|
|
36
|
+
|
|
29
37
|
function _array_like_to_array(arr, len) {
|
|
30
38
|
if (len == null || len > arr.length) len = arr.length;
|
|
31
39
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
@@ -640,14 +648,16 @@
|
|
|
640
648
|
return this.nodeMetaMap.get(n2) || null;
|
|
641
649
|
};
|
|
642
650
|
// removes the node from idNodeMap
|
|
643
|
-
//
|
|
644
|
-
_proto.removeNodeFromMap = function removeNodeFromMap(n2) {
|
|
651
|
+
// if permanent is true, also removes from nodeMetaMap
|
|
652
|
+
_proto.removeNodeFromMap = function removeNodeFromMap(n2, permanent) {
|
|
645
653
|
var _this = this;
|
|
654
|
+
if (permanent === void 0) permanent = false;
|
|
646
655
|
var id = this.getId(n2);
|
|
647
656
|
this.idNodeMap.delete(id);
|
|
657
|
+
if (permanent) this.nodeMetaMap.delete(n2);
|
|
648
658
|
if (n2.childNodes) {
|
|
649
659
|
n2.childNodes.forEach(function(childNode) {
|
|
650
|
-
return _this.removeNodeFromMap(childNode);
|
|
660
|
+
return _this.removeNodeFromMap(childNode, permanent);
|
|
651
661
|
});
|
|
652
662
|
}
|
|
653
663
|
};
|
|
@@ -10389,6 +10399,15 @@
|
|
|
10389
10399
|
_proto.generateId = function generateId() {
|
|
10390
10400
|
return this.id++;
|
|
10391
10401
|
};
|
|
10402
|
+
_proto.remove = function remove(stylesheet) {
|
|
10403
|
+
var id = this.styleIDMap.get(stylesheet);
|
|
10404
|
+
if (id !== void 0) {
|
|
10405
|
+
this.styleIDMap.delete(stylesheet);
|
|
10406
|
+
this.idStyleMap.delete(id);
|
|
10407
|
+
return true;
|
|
10408
|
+
}
|
|
10409
|
+
return false;
|
|
10410
|
+
};
|
|
10392
10411
|
return StyleSheetMirror;
|
|
10393
10412
|
}();
|
|
10394
10413
|
function getShadowHost(n2) {
|
|
@@ -10711,7 +10730,15 @@
|
|
|
10711
10730
|
}
|
|
10712
10731
|
};
|
|
10713
10732
|
while(_this.mapRemoves.length){
|
|
10714
|
-
_this.
|
|
10733
|
+
var removedNode = _this.mapRemoves.shift();
|
|
10734
|
+
if (removedNode.nodeName === "IFRAME") {
|
|
10735
|
+
try {
|
|
10736
|
+
_this.iframeManager.removeIframe(removedNode);
|
|
10737
|
+
} catch (e2) {}
|
|
10738
|
+
} else {
|
|
10739
|
+
_this.stylesheetManager.cleanupStylesheetsForRemovedNode(removedNode);
|
|
10740
|
+
}
|
|
10741
|
+
_this.mirror.removeNodeFromMap(removedNode);
|
|
10715
10742
|
}
|
|
10716
10743
|
for(var _iterator = _create_for_of_iterator_helper_loose(_this.movedSet), _step; !(_step = _iterator()).done;){
|
|
10717
10744
|
var n2 = _step.value;
|
|
@@ -11085,6 +11112,9 @@
|
|
|
11085
11112
|
this.shadowDomManager.reset();
|
|
11086
11113
|
this.canvasManager.reset();
|
|
11087
11114
|
};
|
|
11115
|
+
_proto.getDoc = function getDoc() {
|
|
11116
|
+
return this.doc;
|
|
11117
|
+
};
|
|
11088
11118
|
return MutationBuffer;
|
|
11089
11119
|
}();
|
|
11090
11120
|
function deepDelete(addsSet, n2) {
|
|
@@ -11185,6 +11215,14 @@
|
|
|
11185
11215
|
});
|
|
11186
11216
|
return observer;
|
|
11187
11217
|
}
|
|
11218
|
+
function removeMutationBufferForDoc(doc) {
|
|
11219
|
+
for(var i2 = mutationBuffers.length - 1; i2 >= 0; i2--){
|
|
11220
|
+
var buffer = mutationBuffers[i2];
|
|
11221
|
+
if (buffer.getDoc() === doc) {
|
|
11222
|
+
mutationBuffers.splice(i2, 1);
|
|
11223
|
+
}
|
|
11224
|
+
}
|
|
11225
|
+
}
|
|
11188
11226
|
function initMoveObserver(param) {
|
|
11189
11227
|
var mousemoveCb = param.mousemoveCb, sampling = param.sampling, doc = param.doc, mirror2 = param.mirror;
|
|
11190
11228
|
if (sampling.mousemove === false) {
|
|
@@ -12200,6 +12238,8 @@
|
|
|
12200
12238
|
__publicField$1(this, "crossOriginIframeMirror", new CrossOriginIframeMirror(genId));
|
|
12201
12239
|
__publicField$1(this, "crossOriginIframeStyleMirror");
|
|
12202
12240
|
__publicField$1(this, "crossOriginIframeRootIdMap", /* @__PURE__ */ new WeakMap());
|
|
12241
|
+
__publicField$1(this, "iframeContentDocumentMap", /* @__PURE__ */ new WeakMap());
|
|
12242
|
+
__publicField$1(this, "iframeObserverCleanupMap", /* @__PURE__ */ new WeakMap());
|
|
12203
12243
|
__publicField$1(this, "mirror");
|
|
12204
12244
|
__publicField$1(this, "mutationCb");
|
|
12205
12245
|
__publicField$1(this, "wrappedEmit");
|
|
@@ -12221,6 +12261,31 @@
|
|
|
12221
12261
|
this.iframes.set(iframeEl, true);
|
|
12222
12262
|
if (iframeEl.contentWindow) this.crossOriginIframeMap.set(iframeEl.contentWindow, iframeEl);
|
|
12223
12263
|
};
|
|
12264
|
+
_proto.getIframeContentDocument = function getIframeContentDocument(iframeEl) {
|
|
12265
|
+
return this.iframeContentDocumentMap.get(iframeEl);
|
|
12266
|
+
};
|
|
12267
|
+
_proto.setObserverCleanup = function setObserverCleanup(iframeEl, cleanup) {
|
|
12268
|
+
this.iframeObserverCleanupMap.set(iframeEl, cleanup);
|
|
12269
|
+
};
|
|
12270
|
+
_proto.getObserverCleanup = function getObserverCleanup(iframeEl) {
|
|
12271
|
+
return this.iframeObserverCleanupMap.get(iframeEl);
|
|
12272
|
+
};
|
|
12273
|
+
_proto.removeIframe = function removeIframe(iframeEl) {
|
|
12274
|
+
var storedDoc = this.iframeContentDocumentMap.get(iframeEl);
|
|
12275
|
+
if (storedDoc) {
|
|
12276
|
+
this.stylesheetManager.cleanupStylesheetsForRemovedNode(storedDoc);
|
|
12277
|
+
this.mirror.removeNodeFromMap(storedDoc, true);
|
|
12278
|
+
}
|
|
12279
|
+
this.iframes.delete(iframeEl);
|
|
12280
|
+
this.iframeContentDocumentMap.delete(iframeEl);
|
|
12281
|
+
var observerCleanup = this.iframeObserverCleanupMap.get(iframeEl);
|
|
12282
|
+
if (observerCleanup) {
|
|
12283
|
+
try {
|
|
12284
|
+
observerCleanup();
|
|
12285
|
+
} catch (e2) {}
|
|
12286
|
+
this.iframeObserverCleanupMap.delete(iframeEl);
|
|
12287
|
+
}
|
|
12288
|
+
};
|
|
12224
12289
|
_proto.addLoadListener = function addLoadListener(cb) {
|
|
12225
12290
|
this.loadListener = cb;
|
|
12226
12291
|
};
|
|
@@ -12239,6 +12304,9 @@
|
|
|
12239
12304
|
attributes: [],
|
|
12240
12305
|
isAttachIframe: true
|
|
12241
12306
|
});
|
|
12307
|
+
if (iframeEl.contentDocument) {
|
|
12308
|
+
this.iframeContentDocumentMap.set(iframeEl, iframeEl.contentDocument);
|
|
12309
|
+
}
|
|
12242
12310
|
if (this.recordCrossOriginIframes) (_a2 = iframeEl.contentWindow) == null ? void 0 : _a2.addEventListener("message", this.handleMessage.bind(this));
|
|
12243
12311
|
(_b = this.loadListener) == null ? void 0 : _b.call(this, iframeEl);
|
|
12244
12312
|
if (iframeEl.contentDocument && iframeEl.contentDocument.adoptedStyleSheets && iframeEl.contentDocument.adoptedStyleSheets.length > 0) this.stylesheetManager.adoptStyleSheets(iframeEl.contentDocument.adoptedStyleSheets, this.mirror.getId(iframeEl.contentDocument));
|
|
@@ -13151,6 +13219,41 @@
|
|
|
13151
13219
|
this.styleMirror.reset();
|
|
13152
13220
|
this.trackedLinkElements = /* @__PURE__ */ new WeakSet();
|
|
13153
13221
|
};
|
|
13222
|
+
/**
|
|
13223
|
+
* Cleans up stylesheets associated with a removed node.
|
|
13224
|
+
*
|
|
13225
|
+
* @param removedNode - The node that was removed from the DOM.
|
|
13226
|
+
*/ _proto.cleanupStylesheetsForRemovedNode = function cleanupStylesheetsForRemovedNode(removedNode) {
|
|
13227
|
+
var _this = this;
|
|
13228
|
+
try {
|
|
13229
|
+
if (removedNode.nodeType === Node.DOCUMENT_NODE) {
|
|
13230
|
+
var doc = removedNode;
|
|
13231
|
+
if (doc.adoptedStyleSheets) {
|
|
13232
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(doc.adoptedStyleSheets), _step; !(_step = _iterator()).done;){
|
|
13233
|
+
var sheet = _step.value;
|
|
13234
|
+
this.styleMirror.remove(sheet);
|
|
13235
|
+
}
|
|
13236
|
+
}
|
|
13237
|
+
}
|
|
13238
|
+
if (removedNode.nodeName === "STYLE") {
|
|
13239
|
+
var styleEl = removedNode;
|
|
13240
|
+
if (styleEl.sheet) {
|
|
13241
|
+
this.styleMirror.remove(styleEl.sheet);
|
|
13242
|
+
}
|
|
13243
|
+
}
|
|
13244
|
+
if (removedNode.nodeName === "LINK" && removedNode.rel === "stylesheet") {
|
|
13245
|
+
var linkEl = removedNode;
|
|
13246
|
+
if (linkEl.sheet) {
|
|
13247
|
+
this.styleMirror.remove(linkEl.sheet);
|
|
13248
|
+
}
|
|
13249
|
+
}
|
|
13250
|
+
if (removedNode.childNodes) {
|
|
13251
|
+
removedNode.childNodes.forEach(function(child) {
|
|
13252
|
+
_this.cleanupStylesheetsForRemovedNode(child);
|
|
13253
|
+
});
|
|
13254
|
+
}
|
|
13255
|
+
} catch (e2) {}
|
|
13256
|
+
};
|
|
13154
13257
|
// TODO: take snapshot on stylesheet reload by applying event listener
|
|
13155
13258
|
_proto.trackStylesheetInLinkElement = function trackStylesheetInLinkElement(_linkEl) {};
|
|
13156
13259
|
return StylesheetManager;
|
|
@@ -13605,7 +13708,23 @@
|
|
|
13605
13708
|
};
|
|
13606
13709
|
iframeManager.addLoadListener(function(iframeEl) {
|
|
13607
13710
|
try {
|
|
13608
|
-
|
|
13711
|
+
var iframeDoc = iframeEl.contentDocument;
|
|
13712
|
+
var iframeHandler = observe(iframeDoc);
|
|
13713
|
+
handlers.push(iframeHandler);
|
|
13714
|
+
var existingCleanup = iframeManager.getObserverCleanup(iframeEl);
|
|
13715
|
+
iframeManager.setObserverCleanup(iframeEl, function() {
|
|
13716
|
+
if (existingCleanup) {
|
|
13717
|
+
try {
|
|
13718
|
+
existingCleanup();
|
|
13719
|
+
} catch (e2) {}
|
|
13720
|
+
}
|
|
13721
|
+
try {
|
|
13722
|
+
iframeHandler();
|
|
13723
|
+
var idx = handlers.indexOf(iframeHandler);
|
|
13724
|
+
if (idx !== -1) handlers.splice(idx, 1);
|
|
13725
|
+
removeMutationBufferForDoc(iframeDoc);
|
|
13726
|
+
} catch (e2) {}
|
|
13727
|
+
});
|
|
13609
13728
|
} catch (error) {
|
|
13610
13729
|
console.warn(error);
|
|
13611
13730
|
}
|
|
@@ -18853,7 +18972,7 @@
|
|
|
18853
18972
|
}
|
|
18854
18973
|
|
|
18855
18974
|
var Config = {
|
|
18856
|
-
LIB_VERSION: '2.
|
|
18975
|
+
LIB_VERSION: '2.75.0'
|
|
18857
18976
|
};
|
|
18858
18977
|
|
|
18859
18978
|
/* eslint camelcase: "off", eqeqeq: "off" */
|
|
@@ -19007,15 +19126,8 @@
|
|
|
19007
19126
|
return toString.call(obj) === '[object Array]';
|
|
19008
19127
|
};
|
|
19009
19128
|
|
|
19010
|
-
// from a comment on http://dbj.org/dbj/?p=286
|
|
19011
|
-
// fails on only one very rare and deliberate custom object:
|
|
19012
|
-
// var bomb = { toString : undefined, valueOf: function(o) { return "function BOMBA!"; }};
|
|
19013
19129
|
_.isFunction = function(f) {
|
|
19014
|
-
|
|
19015
|
-
return /^\s*\bfunction\b/.test(f);
|
|
19016
|
-
} catch (x) {
|
|
19017
|
-
return false;
|
|
19018
|
-
}
|
|
19130
|
+
return typeof f === 'function';
|
|
19019
19131
|
};
|
|
19020
19132
|
|
|
19021
19133
|
_.isArguments = function(obj) {
|
|
@@ -22802,6 +22914,6 @@
|
|
|
22802
22914
|
}
|
|
22803
22915
|
});
|
|
22804
22916
|
|
|
22805
|
-
win[
|
|
22917
|
+
win[RECORDER_GLOBAL_NAME] = MixpanelRecorder;
|
|
22806
22918
|
|
|
22807
22919
|
})();
|