@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/lib/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/lib/app/canvas.js
CHANGED
|
@@ -56,6 +56,17 @@ class CanvasRecorder {
|
|
|
56
56
|
};
|
|
57
57
|
const canvasMsg = CanvasNode(id.toString(), ts);
|
|
58
58
|
this.app.send(canvasMsg);
|
|
59
|
+
const captureFn = (canvas) => {
|
|
60
|
+
captureSnapshot(canvas, this.options.quality, this.snapshots[id].dummy, this.options.fixedScaling, (blob) => {
|
|
61
|
+
if (!blob)
|
|
62
|
+
return;
|
|
63
|
+
this.snapshots[id].images.push({ id: this.app.timestamp(), data: blob });
|
|
64
|
+
if (this.snapshots[id].images.length > 9) {
|
|
65
|
+
this.sendSnaps(this.snapshots[id].images, id, this.snapshots[id].createdAt);
|
|
66
|
+
this.snapshots[id].images = [];
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
};
|
|
59
70
|
const int = setInterval(() => {
|
|
60
71
|
const cid = this.app.nodes.getID(node);
|
|
61
72
|
const canvas = cid ? this.app.nodes.getNode(cid) : undefined;
|
|
@@ -65,11 +76,13 @@ class CanvasRecorder {
|
|
|
65
76
|
}
|
|
66
77
|
else {
|
|
67
78
|
if (!this.snapshots[id].paused) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
79
|
+
if (this.options.useAnimationFrame) {
|
|
80
|
+
requestAnimationFrame(() => {
|
|
81
|
+
captureFn(canvas);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
captureFn(canvas);
|
|
73
86
|
}
|
|
74
87
|
}
|
|
75
88
|
}
|
|
@@ -92,12 +105,12 @@ class CanvasRecorder {
|
|
|
92
105
|
}
|
|
93
106
|
const formData = new FormData();
|
|
94
107
|
images.forEach((snapshot) => {
|
|
95
|
-
const blob =
|
|
108
|
+
const blob = snapshot.data;
|
|
96
109
|
if (!blob)
|
|
97
110
|
return;
|
|
98
|
-
formData.append('snapshot', blob
|
|
111
|
+
formData.append('snapshot', blob, `${createdAt}_${canvasId}_${snapshot.id}.webp`);
|
|
99
112
|
if (this.options.isDebug) {
|
|
100
|
-
saveImageData(
|
|
113
|
+
saveImageData(blob, `${createdAt}_${canvasId}_${snapshot.id}.webp`);
|
|
101
114
|
}
|
|
102
115
|
});
|
|
103
116
|
fetch(this.app.options.ingestPoint + '/v1/web/images', {
|
|
@@ -124,8 +137,8 @@ const qualityInt = {
|
|
|
124
137
|
medium: 0.55,
|
|
125
138
|
high: 0.8,
|
|
126
139
|
};
|
|
127
|
-
function captureSnapshot(canvas, quality = 'medium', dummy, fixedScaling = false) {
|
|
128
|
-
const imageFormat = 'image/
|
|
140
|
+
function captureSnapshot(canvas, quality = 'medium', dummy, fixedScaling = false, onBlob) {
|
|
141
|
+
const imageFormat = 'image/webp';
|
|
129
142
|
if (fixedScaling) {
|
|
130
143
|
const canvasScaleRatio = window.devicePixelRatio || 1;
|
|
131
144
|
dummy.width = canvas.width / canvasScaleRatio;
|
|
@@ -135,10 +148,10 @@ function captureSnapshot(canvas, quality = 'medium', dummy, fixedScaling = false
|
|
|
135
148
|
return '';
|
|
136
149
|
}
|
|
137
150
|
ctx.drawImage(canvas, 0, 0, dummy.width, dummy.height);
|
|
138
|
-
|
|
151
|
+
dummy.toBlob(onBlob, imageFormat, qualityInt[quality]);
|
|
139
152
|
}
|
|
140
153
|
else {
|
|
141
|
-
|
|
154
|
+
canvas.toBlob(onBlob, imageFormat, qualityInt[quality]);
|
|
142
155
|
}
|
|
143
156
|
}
|
|
144
157
|
function dataUrlToBlob(dataUrl) {
|
|
@@ -157,7 +170,8 @@ function dataUrlToBlob(dataUrl) {
|
|
|
157
170
|
}
|
|
158
171
|
return [new Blob([u8arr], { type: mime }), u8arr];
|
|
159
172
|
}
|
|
160
|
-
function saveImageData(
|
|
173
|
+
function saveImageData(imageDataBlob, name) {
|
|
174
|
+
const imageDataUrl = URL.createObjectURL(imageDataBlob);
|
|
161
175
|
const link = document.createElement('a');
|
|
162
176
|
link.href = imageDataUrl;
|
|
163
177
|
link.download = name;
|
package/lib/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/lib/app/index.js
CHANGED
|
@@ -51,7 +51,7 @@ export default class App {
|
|
|
51
51
|
this.stopCallbacks = [];
|
|
52
52
|
this.commitCallbacks = [];
|
|
53
53
|
this.activityState = ActivityState.NotActive;
|
|
54
|
-
this.version = '13.0.
|
|
54
|
+
this.version = '13.0.1'; // TODO: version compatability check inside each plugin.
|
|
55
55
|
this.socketMode = false;
|
|
56
56
|
this.compressionThreshold = 24 * 1000;
|
|
57
57
|
this.restartAttempts = 0;
|
|
@@ -89,6 +89,18 @@ export default class App {
|
|
|
89
89
|
});
|
|
90
90
|
};
|
|
91
91
|
this.onUxtCb = [];
|
|
92
|
+
if (Object.keys(options).findIndex((k) => ['fixedCanvasScaling', 'disableCanvas'].includes(k)) !==
|
|
93
|
+
-1) {
|
|
94
|
+
console.warn('Openreplay: canvas options are moving to separate key "canvas" in next update. Please update your configuration.');
|
|
95
|
+
options = {
|
|
96
|
+
...options,
|
|
97
|
+
canvas: {
|
|
98
|
+
__save_canvas_locally: options.__save_canvas_locally,
|
|
99
|
+
fixedCanvasScaling: options.fixedCanvasScaling,
|
|
100
|
+
disableCanvas: options.disableCanvas,
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
92
104
|
this.contextId = Math.random().toString(36).slice(2);
|
|
93
105
|
this.projectKey = projectKey;
|
|
94
106
|
this.networkOptions = options.network;
|
|
@@ -114,6 +126,12 @@ export default class App {
|
|
|
114
126
|
fixedCanvasScaling: false,
|
|
115
127
|
disableCanvas: false,
|
|
116
128
|
assistOnly: false,
|
|
129
|
+
canvas: {
|
|
130
|
+
disableCanvas: false,
|
|
131
|
+
fixedCanvasScaling: false,
|
|
132
|
+
__save_canvas_locally: false,
|
|
133
|
+
useAnimationFrame: false,
|
|
134
|
+
},
|
|
117
135
|
}, options);
|
|
118
136
|
if (!this.options.forceSingleTab && globalThis && 'BroadcastChannel' in globalThis) {
|
|
119
137
|
const host = location.hostname.split('.').slice(-2).join('_');
|
|
@@ -858,14 +876,15 @@ export default class App {
|
|
|
858
876
|
void this.featureFlags.reloadFlags();
|
|
859
877
|
await this.tagWatcher.fetchTags(this.options.ingestPoint, token);
|
|
860
878
|
this.activityState = ActivityState.Active;
|
|
861
|
-
if (canvasEnabled && !this.options.disableCanvas) {
|
|
879
|
+
if (canvasEnabled && !this.options.canvas.disableCanvas) {
|
|
862
880
|
this.canvasRecorder =
|
|
863
881
|
this.canvasRecorder ??
|
|
864
882
|
new CanvasRecorder(this, {
|
|
865
883
|
fps: canvasFPS,
|
|
866
884
|
quality: canvasQuality,
|
|
867
|
-
isDebug: this.options.__save_canvas_locally,
|
|
868
|
-
fixedScaling: this.options.fixedCanvasScaling,
|
|
885
|
+
isDebug: this.options.canvas.__save_canvas_locally,
|
|
886
|
+
fixedScaling: this.options.canvas.fixedCanvasScaling,
|
|
887
|
+
useAnimationFrame: this.options.canvas.useAnimationFrame,
|
|
869
888
|
});
|
|
870
889
|
this.canvasRecorder.startTracking();
|
|
871
890
|
}
|
package/lib/index.js
CHANGED
|
@@ -66,7 +66,7 @@ export default class API {
|
|
|
66
66
|
const orig = this.options.ingestPoint || DEFAULT_INGEST_POINT;
|
|
67
67
|
req.open('POST', orig + '/v1/web/not-started');
|
|
68
68
|
req.send(JSON.stringify({
|
|
69
|
-
trackerVersion: '13.0.
|
|
69
|
+
trackerVersion: '13.0.1',
|
|
70
70
|
projectKey: this.options.projectKey,
|
|
71
71
|
doNotTrack,
|
|
72
72
|
reason: missingApi.length ? `missing api: ${missingApi.join(',')}` : reason,
|