@openreplay/tracker 15.0.6 → 15.0.8-beta.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/dist/cjs/index.js +51 -15
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/main/app/observer/observer.d.ts +5 -1
- package/dist/cjs/main/app/observer/top_observer.d.ts +1 -0
- package/dist/lib/index.js +51 -15
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/main/app/observer/observer.d.ts +5 -1
- package/dist/lib/main/app/observer/top_observer.d.ts +1 -0
- package/dist/types/main/app/observer/observer.d.ts +5 -1
- package/dist/types/main/app/observer/top_observer.d.ts +1 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -3729,8 +3729,8 @@ class Nodes {
|
|
|
3729
3729
|
}
|
|
3730
3730
|
|
|
3731
3731
|
const iconCache = {};
|
|
3732
|
-
const
|
|
3733
|
-
async function parseUseEl(useElement, mode) {
|
|
3732
|
+
const svgUrlCache = {};
|
|
3733
|
+
async function parseUseEl(useElement, mode, domParser) {
|
|
3734
3734
|
try {
|
|
3735
3735
|
const href = useElement.getAttribute('xlink:href') || useElement.getAttribute('href');
|
|
3736
3736
|
if (!href) {
|
|
@@ -3745,13 +3745,43 @@ async function parseUseEl(useElement, mode) {
|
|
|
3745
3745
|
if (iconCache[symbolId]) {
|
|
3746
3746
|
return iconCache[symbolId];
|
|
3747
3747
|
}
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3748
|
+
let svgDoc;
|
|
3749
|
+
if (svgUrlCache[url]) {
|
|
3750
|
+
if (svgUrlCache[url] === 1) {
|
|
3751
|
+
await new Promise((resolve) => {
|
|
3752
|
+
let tries = 0;
|
|
3753
|
+
const interval = setInterval(() => {
|
|
3754
|
+
if (tries > 100) {
|
|
3755
|
+
clearInterval(interval);
|
|
3756
|
+
resolve(false);
|
|
3757
|
+
}
|
|
3758
|
+
if (svgUrlCache[url] !== 1) {
|
|
3759
|
+
svgDoc = svgUrlCache[url];
|
|
3760
|
+
clearInterval(interval);
|
|
3761
|
+
resolve(true);
|
|
3762
|
+
}
|
|
3763
|
+
else {
|
|
3764
|
+
tries++;
|
|
3765
|
+
}
|
|
3766
|
+
}, 100);
|
|
3767
|
+
});
|
|
3768
|
+
}
|
|
3769
|
+
else {
|
|
3770
|
+
svgDoc = svgUrlCache[url] ?? `<svg xmlns="http://www.w3.org/2000/svg"></svg>`;
|
|
3771
|
+
}
|
|
3772
|
+
}
|
|
3773
|
+
else {
|
|
3774
|
+
svgUrlCache[url] = 1;
|
|
3775
|
+
const response = await fetch(url);
|
|
3776
|
+
const svgText = await response.text();
|
|
3777
|
+
svgDoc = domParser.parseFromString(svgText, 'image/svg+xml');
|
|
3778
|
+
svgUrlCache[url] = svgDoc;
|
|
3779
|
+
}
|
|
3780
|
+
// @ts-ignore
|
|
3751
3781
|
const symbol = svgDoc.getElementById(symbolId);
|
|
3752
3782
|
if (!symbol) {
|
|
3753
3783
|
console.debug('Openreplay: Symbol not found in SVG.');
|
|
3754
|
-
return;
|
|
3784
|
+
return '';
|
|
3755
3785
|
}
|
|
3756
3786
|
if (mode === 'inline') ;
|
|
3757
3787
|
if (mode === 'svgtext') {
|
|
@@ -3806,7 +3836,7 @@ var RecentsType;
|
|
|
3806
3836
|
RecentsType[RecentsType["Changed"] = 2] = "Changed";
|
|
3807
3837
|
})(RecentsType || (RecentsType = {}));
|
|
3808
3838
|
class Observer {
|
|
3809
|
-
constructor(app, isTopContext = false) {
|
|
3839
|
+
constructor(app, isTopContext = false, options = { disableSprites: false }) {
|
|
3810
3840
|
this.app = app;
|
|
3811
3841
|
this.isTopContext = isTopContext;
|
|
3812
3842
|
this.commited = [];
|
|
@@ -3814,6 +3844,9 @@ class Observer {
|
|
|
3814
3844
|
this.indexes = [];
|
|
3815
3845
|
this.attributesMap = new Map();
|
|
3816
3846
|
this.textSet = new Set();
|
|
3847
|
+
this.disableSprites = false;
|
|
3848
|
+
this.domParser = new DOMParser();
|
|
3849
|
+
this.disableSprites = options.disableSprites;
|
|
3817
3850
|
this.observer = createMutationObserver(this.app.safe((mutations) => {
|
|
3818
3851
|
for (const mutation of mutations) {
|
|
3819
3852
|
// mutations order is sequential
|
|
@@ -3908,8 +3941,8 @@ class Observer {
|
|
|
3908
3941
|
if (value === null) {
|
|
3909
3942
|
this.app.send(RemoveNodeAttribute(id, name));
|
|
3910
3943
|
}
|
|
3911
|
-
if (isUseElement(node) && name === 'href') {
|
|
3912
|
-
parseUseEl(node, 'svgtext')
|
|
3944
|
+
if (isUseElement(node) && name === 'href' && !this.disableSprites) {
|
|
3945
|
+
parseUseEl(node, 'svgtext', this.domParser)
|
|
3913
3946
|
.then((svgData) => {
|
|
3914
3947
|
if (svgData) {
|
|
3915
3948
|
this.app.send(SetNodeAttribute(id, name, `_$OPENREPLAY_SPRITE$_${svgData}`));
|
|
@@ -4262,7 +4295,11 @@ class IFrameOffsets {
|
|
|
4262
4295
|
const attachShadowNativeFn = IN_BROWSER ? Element.prototype.attachShadow : () => new ShadowRoot();
|
|
4263
4296
|
class TopObserver extends Observer {
|
|
4264
4297
|
constructor(params) {
|
|
4265
|
-
|
|
4298
|
+
const opts = Object.assign({
|
|
4299
|
+
captureIFrames: true,
|
|
4300
|
+
disableSprites: false,
|
|
4301
|
+
}, params.options);
|
|
4302
|
+
super(params.app, true, opts);
|
|
4266
4303
|
this.iframeOffsets = new IFrameOffsets();
|
|
4267
4304
|
this.contextCallbacks = [];
|
|
4268
4305
|
// Attached once per Tracker instance
|
|
@@ -4272,9 +4309,7 @@ class TopObserver extends Observer {
|
|
|
4272
4309
|
this.docObservers = new WeakMap();
|
|
4273
4310
|
this.shadowRootObservers = new WeakMap();
|
|
4274
4311
|
this.app = params.app;
|
|
4275
|
-
this.options =
|
|
4276
|
-
captureIFrames: true,
|
|
4277
|
-
}, params.options);
|
|
4312
|
+
this.options = opts;
|
|
4278
4313
|
// IFrames
|
|
4279
4314
|
this.app.nodes.attachNodeCallback((node) => {
|
|
4280
4315
|
if (hasTag(node, 'iframe') &&
|
|
@@ -4703,7 +4738,7 @@ class App {
|
|
|
4703
4738
|
this.stopCallbacks = [];
|
|
4704
4739
|
this.commitCallbacks = [];
|
|
4705
4740
|
this.activityState = ActivityState.NotActive;
|
|
4706
|
-
this.version = '15.0.
|
|
4741
|
+
this.version = '15.0.8-beta.0'; // TODO: version compatability check inside each plugin.
|
|
4707
4742
|
this.socketMode = false;
|
|
4708
4743
|
this.compressionThreshold = 24 * 1000;
|
|
4709
4744
|
this.bc = null;
|
|
@@ -5036,6 +5071,7 @@ class App {
|
|
|
5036
5071
|
fixedCanvasScaling: false,
|
|
5037
5072
|
disableCanvas: false,
|
|
5038
5073
|
captureIFrames: true,
|
|
5074
|
+
disableSprites: false,
|
|
5039
5075
|
obscureTextEmails: true,
|
|
5040
5076
|
obscureTextNumbers: false,
|
|
5041
5077
|
crossdomain: {
|
|
@@ -9165,7 +9201,7 @@ class API {
|
|
|
9165
9201
|
this.signalStartIssue = (reason, missingApi) => {
|
|
9166
9202
|
const doNotTrack = this.checkDoNotTrack();
|
|
9167
9203
|
console.log("Tracker couldn't start due to:", JSON.stringify({
|
|
9168
|
-
trackerVersion: '15.0.
|
|
9204
|
+
trackerVersion: '15.0.8-beta.0',
|
|
9169
9205
|
projectKey: this.options.projectKey,
|
|
9170
9206
|
doNotTrack,
|
|
9171
9207
|
reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,
|