@openreplay/tracker 13.0.0 → 13.0.1
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/CHANGELOG.md +5 -0
- package/cjs/app/canvas.d.ts +2 -1
- package/cjs/app/canvas.js +27 -13
- package/cjs/app/index.d.ts +6 -0
- package/cjs/app/index.js +23 -4
- package/cjs/index.js +1 -1
- package/coverage/clover.xml +1054 -964
- package/coverage/coverage-final.json +21 -21
- package/coverage/lcov-report/index.html +43 -43
- package/coverage/lcov-report/main/app/canvas.ts.html +224 -47
- package/coverage/lcov-report/main/app/guards.ts.html +26 -26
- package/coverage/lcov-report/main/app/index.html +42 -42
- package/coverage/lcov-report/main/app/index.ts.html +157 -37
- package/coverage/lcov-report/main/app/logger.ts.html +1 -1
- package/coverage/lcov-report/main/app/messages.gen.ts.html +244 -154
- package/coverage/lcov-report/main/app/nodes.ts.html +7 -4
- package/coverage/lcov-report/main/app/observer/iframe_observer.ts.html +1 -1
- package/coverage/lcov-report/main/app/observer/iframe_offsets.ts.html +1 -1
- package/coverage/lcov-report/main/app/observer/index.html +5 -5
- package/coverage/lcov-report/main/app/observer/shadow_root_observer.ts.html +1 -1
- package/coverage/lcov-report/main/app/observer/top_observer.ts.html +7 -4
- package/coverage/lcov-report/main/app/sanitizer.ts.html +2 -2
- package/coverage/lcov-report/main/app/session.ts.html +2 -2
- package/coverage/lcov-report/main/app/ticker.ts.html +1 -1
- package/coverage/lcov-report/main/index.html +13 -13
- package/coverage/lcov-report/main/index.ts.html +32 -14
- package/coverage/lcov-report/main/modules/Network/beaconProxy.ts.html +17 -8
- package/coverage/lcov-report/main/modules/Network/fetchProxy.ts.html +40 -13
- package/coverage/lcov-report/main/modules/Network/index.html +21 -21
- package/coverage/lcov-report/main/modules/Network/index.ts.html +2 -2
- package/coverage/lcov-report/main/modules/Network/networkMessage.ts.html +12 -6
- package/coverage/lcov-report/main/modules/Network/utils.ts.html +17 -8
- package/coverage/lcov-report/main/modules/Network/xhrProxy.ts.html +39 -12
- package/coverage/lcov-report/main/modules/attributeSender.ts.html +1 -1
- package/coverage/lcov-report/main/modules/axiosSpy.ts.html +1 -1
- package/coverage/lcov-report/main/modules/conditionsManager.ts.html +4 -22
- package/coverage/lcov-report/main/modules/connection.ts.html +1 -1
- package/coverage/lcov-report/main/modules/console.ts.html +1 -1
- package/coverage/lcov-report/main/modules/constructedStyleSheets.ts.html +3 -3
- package/coverage/lcov-report/main/modules/cssrules.ts.html +1 -1
- package/coverage/lcov-report/main/modules/exception.ts.html +1 -1
- package/coverage/lcov-report/main/modules/featureFlags.ts.html +1 -1
- package/coverage/lcov-report/main/modules/focus.ts.html +1 -1
- package/coverage/lcov-report/main/modules/fonts.ts.html +1 -1
- package/coverage/lcov-report/main/modules/img.ts.html +4 -4
- package/coverage/lcov-report/main/modules/index.html +24 -24
- package/coverage/lcov-report/main/modules/input.ts.html +1 -1
- package/coverage/lcov-report/main/modules/mouse.ts.html +1 -1
- package/coverage/lcov-report/main/modules/network.ts.html +2 -2
- package/coverage/lcov-report/main/modules/performance.ts.html +1 -1
- package/coverage/lcov-report/main/modules/scroll.ts.html +1 -1
- package/coverage/lcov-report/main/modules/selection.ts.html +1 -1
- package/coverage/lcov-report/main/modules/tabs.ts.html +1 -1
- package/coverage/lcov-report/main/modules/tagWatcher.ts.html +95 -92
- package/coverage/lcov-report/main/modules/timing.ts.html +1 -1
- package/coverage/lcov-report/main/modules/userTesting/SignalManager.ts.html +1 -1
- package/coverage/lcov-report/main/modules/userTesting/dnd.ts.html +1 -1
- package/coverage/lcov-report/main/modules/userTesting/index.html +1 -1
- package/coverage/lcov-report/main/modules/userTesting/index.ts.html +1 -1
- package/coverage/lcov-report/main/modules/userTesting/recorder.ts.html +1 -1
- package/coverage/lcov-report/main/modules/userTesting/styles.ts.html +1 -1
- package/coverage/lcov-report/main/modules/userTesting/utils.ts.html +1 -1
- package/coverage/lcov-report/main/modules/viewport.ts.html +4 -4
- package/coverage/lcov-report/main/utils.ts.html +181 -31
- package/coverage/lcov-report/webworker/BatchWriter.ts.html +1 -1
- package/coverage/lcov-report/webworker/MessageEncoder.gen.ts.html +31 -7
- package/coverage/lcov-report/webworker/PrimitiveEncoder.ts.html +1 -1
- package/coverage/lcov-report/webworker/QueueSender.ts.html +48 -18
- package/coverage/lcov-report/webworker/index.html +14 -14
- package/coverage/lcov-report/webworker/index.ts.html +51 -21
- package/coverage/lcov.info +1882 -1653
- package/lib/app/canvas.d.ts +2 -1
- package/lib/app/canvas.js +27 -13
- package/lib/app/index.d.ts +6 -0
- package/lib/app/index.js +23 -4
- package/lib/index.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/cjs/app/canvas.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ interface Options {
|
|
|
4
4
|
quality: 'low' | 'medium' | 'high';
|
|
5
5
|
isDebug?: boolean;
|
|
6
6
|
fixedScaling?: boolean;
|
|
7
|
+
useAnimationFrame?: boolean;
|
|
7
8
|
}
|
|
8
9
|
declare class CanvasRecorder {
|
|
9
10
|
private readonly app;
|
|
@@ -17,7 +18,7 @@ declare class CanvasRecorder {
|
|
|
17
18
|
captureCanvas: (node: Node) => void;
|
|
18
19
|
recordCanvas: (node: Node, id: number) => void;
|
|
19
20
|
sendSnaps(images: {
|
|
20
|
-
data:
|
|
21
|
+
data: Blob;
|
|
21
22
|
id: number;
|
|
22
23
|
}[], canvasId: number, createdAt: number): void;
|
|
23
24
|
clear(): void;
|
package/cjs/app/canvas.js
CHANGED
|
@@ -58,6 +58,17 @@ class CanvasRecorder {
|
|
|
58
58
|
};
|
|
59
59
|
const canvasMsg = (0, messages_gen_js_1.CanvasNode)(id.toString(), ts);
|
|
60
60
|
this.app.send(canvasMsg);
|
|
61
|
+
const captureFn = (canvas) => {
|
|
62
|
+
captureSnapshot(canvas, this.options.quality, this.snapshots[id].dummy, this.options.fixedScaling, (blob) => {
|
|
63
|
+
if (!blob)
|
|
64
|
+
return;
|
|
65
|
+
this.snapshots[id].images.push({ id: this.app.timestamp(), data: blob });
|
|
66
|
+
if (this.snapshots[id].images.length > 9) {
|
|
67
|
+
this.sendSnaps(this.snapshots[id].images, id, this.snapshots[id].createdAt);
|
|
68
|
+
this.snapshots[id].images = [];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
};
|
|
61
72
|
const int = setInterval(() => {
|
|
62
73
|
const cid = this.app.nodes.getID(node);
|
|
63
74
|
const canvas = cid ? this.app.nodes.getNode(cid) : undefined;
|
|
@@ -67,11 +78,13 @@ class CanvasRecorder {
|
|
|
67
78
|
}
|
|
68
79
|
else {
|
|
69
80
|
if (!this.snapshots[id].paused) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
81
|
+
if (this.options.useAnimationFrame) {
|
|
82
|
+
requestAnimationFrame(() => {
|
|
83
|
+
captureFn(canvas);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
captureFn(canvas);
|
|
75
88
|
}
|
|
76
89
|
}
|
|
77
90
|
}
|
|
@@ -94,12 +107,12 @@ class CanvasRecorder {
|
|
|
94
107
|
}
|
|
95
108
|
const formData = new FormData();
|
|
96
109
|
images.forEach((snapshot) => {
|
|
97
|
-
const blob =
|
|
110
|
+
const blob = snapshot.data;
|
|
98
111
|
if (!blob)
|
|
99
112
|
return;
|
|
100
|
-
formData.append('snapshot', blob
|
|
113
|
+
formData.append('snapshot', blob, `${createdAt}_${canvasId}_${snapshot.id}.webp`);
|
|
101
114
|
if (this.options.isDebug) {
|
|
102
|
-
saveImageData(
|
|
115
|
+
saveImageData(blob, `${createdAt}_${canvasId}_${snapshot.id}.webp`);
|
|
103
116
|
}
|
|
104
117
|
});
|
|
105
118
|
fetch(this.app.options.ingestPoint + '/v1/web/images', {
|
|
@@ -126,8 +139,8 @@ const qualityInt = {
|
|
|
126
139
|
medium: 0.55,
|
|
127
140
|
high: 0.8,
|
|
128
141
|
};
|
|
129
|
-
function captureSnapshot(canvas, quality = 'medium', dummy, fixedScaling = false) {
|
|
130
|
-
const imageFormat = 'image/
|
|
142
|
+
function captureSnapshot(canvas, quality = 'medium', dummy, fixedScaling = false, onBlob) {
|
|
143
|
+
const imageFormat = 'image/webp';
|
|
131
144
|
if (fixedScaling) {
|
|
132
145
|
const canvasScaleRatio = window.devicePixelRatio || 1;
|
|
133
146
|
dummy.width = canvas.width / canvasScaleRatio;
|
|
@@ -137,10 +150,10 @@ function captureSnapshot(canvas, quality = 'medium', dummy, fixedScaling = false
|
|
|
137
150
|
return '';
|
|
138
151
|
}
|
|
139
152
|
ctx.drawImage(canvas, 0, 0, dummy.width, dummy.height);
|
|
140
|
-
|
|
153
|
+
dummy.toBlob(onBlob, imageFormat, qualityInt[quality]);
|
|
141
154
|
}
|
|
142
155
|
else {
|
|
143
|
-
|
|
156
|
+
canvas.toBlob(onBlob, imageFormat, qualityInt[quality]);
|
|
144
157
|
}
|
|
145
158
|
}
|
|
146
159
|
function dataUrlToBlob(dataUrl) {
|
|
@@ -159,7 +172,8 @@ function dataUrlToBlob(dataUrl) {
|
|
|
159
172
|
}
|
|
160
173
|
return [new Blob([u8arr], { type: mime }), u8arr];
|
|
161
174
|
}
|
|
162
|
-
function saveImageData(
|
|
175
|
+
function saveImageData(imageDataBlob, name) {
|
|
176
|
+
const imageDataUrl = URL.createObjectURL(imageDataBlob);
|
|
163
177
|
const link = document.createElement('a');
|
|
164
178
|
link.href = imageDataUrl;
|
|
165
179
|
link.download = name;
|
package/cjs/app/index.d.ts
CHANGED
|
@@ -58,6 +58,12 @@ type AppOptions = {
|
|
|
58
58
|
disableStringDict?: boolean;
|
|
59
59
|
assistSocketHost?: string;
|
|
60
60
|
disableCanvas?: boolean;
|
|
61
|
+
canvas: {
|
|
62
|
+
disableCanvas?: boolean;
|
|
63
|
+
fixedCanvasScaling?: boolean;
|
|
64
|
+
__save_canvas_locally?: boolean;
|
|
65
|
+
useAnimationFrame?: boolean;
|
|
66
|
+
};
|
|
61
67
|
/** @deprecated */
|
|
62
68
|
onStart?: StartCallback;
|
|
63
69
|
network?: NetworkOptions;
|
package/cjs/app/index.js
CHANGED
|
@@ -80,7 +80,7 @@ class App {
|
|
|
80
80
|
this.stopCallbacks = [];
|
|
81
81
|
this.commitCallbacks = [];
|
|
82
82
|
this.activityState = ActivityState.NotActive;
|
|
83
|
-
this.version = '13.0.
|
|
83
|
+
this.version = '13.0.1'; // TODO: version compatability check inside each plugin.
|
|
84
84
|
this.socketMode = false;
|
|
85
85
|
this.compressionThreshold = 24 * 1000;
|
|
86
86
|
this.restartAttempts = 0;
|
|
@@ -118,6 +118,18 @@ class App {
|
|
|
118
118
|
});
|
|
119
119
|
};
|
|
120
120
|
this.onUxtCb = [];
|
|
121
|
+
if (Object.keys(options).findIndex((k) => ['fixedCanvasScaling', 'disableCanvas'].includes(k)) !==
|
|
122
|
+
-1) {
|
|
123
|
+
console.warn('Openreplay: canvas options are moving to separate key "canvas" in next update. Please update your configuration.');
|
|
124
|
+
options = {
|
|
125
|
+
...options,
|
|
126
|
+
canvas: {
|
|
127
|
+
__save_canvas_locally: options.__save_canvas_locally,
|
|
128
|
+
fixedCanvasScaling: options.fixedCanvasScaling,
|
|
129
|
+
disableCanvas: options.disableCanvas,
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
}
|
|
121
133
|
this.contextId = Math.random().toString(36).slice(2);
|
|
122
134
|
this.projectKey = projectKey;
|
|
123
135
|
this.networkOptions = options.network;
|
|
@@ -143,6 +155,12 @@ class App {
|
|
|
143
155
|
fixedCanvasScaling: false,
|
|
144
156
|
disableCanvas: false,
|
|
145
157
|
assistOnly: false,
|
|
158
|
+
canvas: {
|
|
159
|
+
disableCanvas: false,
|
|
160
|
+
fixedCanvasScaling: false,
|
|
161
|
+
__save_canvas_locally: false,
|
|
162
|
+
useAnimationFrame: false,
|
|
163
|
+
},
|
|
146
164
|
}, options);
|
|
147
165
|
if (!this.options.forceSingleTab && globalThis && 'BroadcastChannel' in globalThis) {
|
|
148
166
|
const host = location.hostname.split('.').slice(-2).join('_');
|
|
@@ -887,14 +905,15 @@ class App {
|
|
|
887
905
|
void this.featureFlags.reloadFlags();
|
|
888
906
|
await this.tagWatcher.fetchTags(this.options.ingestPoint, token);
|
|
889
907
|
this.activityState = ActivityState.Active;
|
|
890
|
-
if (canvasEnabled && !this.options.disableCanvas) {
|
|
908
|
+
if (canvasEnabled && !this.options.canvas.disableCanvas) {
|
|
891
909
|
this.canvasRecorder =
|
|
892
910
|
this.canvasRecorder ??
|
|
893
911
|
new canvas_js_1.default(this, {
|
|
894
912
|
fps: canvasFPS,
|
|
895
913
|
quality: canvasQuality,
|
|
896
|
-
isDebug: this.options.__save_canvas_locally,
|
|
897
|
-
fixedScaling: this.options.fixedCanvasScaling,
|
|
914
|
+
isDebug: this.options.canvas.__save_canvas_locally,
|
|
915
|
+
fixedScaling: this.options.canvas.fixedCanvasScaling,
|
|
916
|
+
useAnimationFrame: this.options.canvas.useAnimationFrame,
|
|
898
917
|
});
|
|
899
918
|
this.canvasRecorder.startTracking();
|
|
900
919
|
}
|
package/cjs/index.js
CHANGED
|
@@ -97,7 +97,7 @@ class API {
|
|
|
97
97
|
const orig = this.options.ingestPoint || index_js_1.DEFAULT_INGEST_POINT;
|
|
98
98
|
req.open('POST', orig + '/v1/web/not-started');
|
|
99
99
|
req.send(JSON.stringify({
|
|
100
|
-
trackerVersion: '13.0.
|
|
100
|
+
trackerVersion: '13.0.1',
|
|
101
101
|
projectKey: this.options.projectKey,
|
|
102
102
|
doNotTrack,
|
|
103
103
|
reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,
|