@openreplay/tracker 13.0.1 → 14.0.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/CHANGELOG.md +14 -0
- package/bun.lockb +0 -0
- package/cjs/app/canvas.d.ts +2 -0
- package/cjs/app/canvas.js +6 -5
- package/cjs/app/index.d.ts +55 -16
- package/cjs/app/index.js +417 -236
- package/cjs/app/messages.gen.d.ts +6 -3
- package/cjs/app/messages.gen.js +44 -10
- package/cjs/app/nodes.d.ts +2 -0
- package/cjs/app/nodes.js +15 -1
- package/cjs/app/observer/iframe_observer.d.ts +1 -0
- package/cjs/app/observer/iframe_observer.js +9 -0
- package/cjs/app/observer/iframe_offsets.js +0 -1
- package/cjs/app/observer/top_observer.d.ts +1 -0
- package/cjs/app/observer/top_observer.js +14 -0
- package/cjs/common/messages.gen.d.ts +38 -10
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +17 -8
- package/cjs/modules/conditionsManager.js +2 -2
- package/cjs/modules/mouse.js +14 -1
- package/cjs/modules/scroll.d.ts +1 -1
- package/cjs/modules/scroll.js +9 -4
- package/cjs/modules/viewport.js +2 -2
- package/cjs/utils.d.ts +2 -1
- package/cjs/utils.js +33 -6
- package/lib/app/canvas.d.ts +2 -0
- package/lib/app/canvas.js +6 -5
- package/lib/app/index.d.ts +55 -16
- package/lib/app/index.js +399 -218
- package/lib/app/messages.gen.d.ts +6 -3
- package/lib/app/messages.gen.js +37 -6
- package/lib/app/nodes.d.ts +2 -0
- package/lib/app/nodes.js +15 -1
- package/lib/app/observer/iframe_observer.d.ts +1 -0
- package/lib/app/observer/iframe_observer.js +9 -0
- package/lib/app/observer/iframe_offsets.js +0 -1
- package/lib/app/observer/top_observer.d.ts +1 -0
- package/lib/app/observer/top_observer.js +14 -0
- package/lib/common/messages.gen.d.ts +38 -10
- package/lib/common/tsconfig.tsbuildinfo +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +18 -9
- package/lib/modules/conditionsManager.js +2 -2
- package/lib/modules/mouse.js +14 -1
- package/lib/modules/scroll.d.ts +1 -1
- package/lib/modules/scroll.js +9 -4
- package/lib/modules/viewport.js +2 -2
- package/lib/utils.d.ts +2 -1
- package/lib/utils.js +31 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# 15.0.0
|
|
2
|
+
|
|
3
|
+
- updated graphql plugin and messages
|
|
4
|
+
|
|
5
|
+
# 14.0.0
|
|
6
|
+
|
|
7
|
+
- titles for tabs
|
|
8
|
+
- new `MouseClick` message to introduce heatmaps instead of clickmaps
|
|
9
|
+
- crossdomain iframe tracking functionality
|
|
10
|
+
|
|
11
|
+
# 13.0.2
|
|
12
|
+
|
|
13
|
+
- more file extensions for canvas
|
|
14
|
+
|
|
1
15
|
# 13.0.1
|
|
2
16
|
|
|
3
17
|
- moved canvas snapshots to webp, additional option to utilize useAnimationFrame method (for webgl)
|
package/bun.lockb
CHANGED
|
Binary file
|
package/cjs/app/canvas.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ interface Options {
|
|
|
5
5
|
isDebug?: boolean;
|
|
6
6
|
fixedScaling?: boolean;
|
|
7
7
|
useAnimationFrame?: boolean;
|
|
8
|
+
fileExt?: 'webp' | 'png' | 'jpeg' | 'avif';
|
|
8
9
|
}
|
|
9
10
|
declare class CanvasRecorder {
|
|
10
11
|
private readonly app;
|
|
@@ -12,6 +13,7 @@ declare class CanvasRecorder {
|
|
|
12
13
|
private snapshots;
|
|
13
14
|
private readonly intervals;
|
|
14
15
|
private readonly interval;
|
|
16
|
+
private readonly fileExt;
|
|
15
17
|
constructor(app: App, options: Options);
|
|
16
18
|
startTracking(): void;
|
|
17
19
|
restartTracking: () => void;
|
package/cjs/app/canvas.js
CHANGED
|
@@ -59,7 +59,7 @@ class CanvasRecorder {
|
|
|
59
59
|
const canvasMsg = (0, messages_gen_js_1.CanvasNode)(id.toString(), ts);
|
|
60
60
|
this.app.send(canvasMsg);
|
|
61
61
|
const captureFn = (canvas) => {
|
|
62
|
-
captureSnapshot(canvas, this.options.quality, this.snapshots[id].dummy, this.options.fixedScaling, (blob) => {
|
|
62
|
+
captureSnapshot(canvas, this.options.quality, this.snapshots[id].dummy, this.options.fixedScaling, this.fileExt, (blob) => {
|
|
63
63
|
if (!blob)
|
|
64
64
|
return;
|
|
65
65
|
this.snapshots[id].images.push({ id: this.app.timestamp(), data: blob });
|
|
@@ -91,6 +91,7 @@ class CanvasRecorder {
|
|
|
91
91
|
}, this.interval);
|
|
92
92
|
this.intervals.push(int);
|
|
93
93
|
};
|
|
94
|
+
this.fileExt = options.fileExt ?? 'webp';
|
|
94
95
|
this.interval = 1000 / options.fps;
|
|
95
96
|
}
|
|
96
97
|
startTracking() {
|
|
@@ -110,9 +111,9 @@ class CanvasRecorder {
|
|
|
110
111
|
const blob = snapshot.data;
|
|
111
112
|
if (!blob)
|
|
112
113
|
return;
|
|
113
|
-
formData.append('snapshot', blob, `${createdAt}_${canvasId}_${snapshot.id}.
|
|
114
|
+
formData.append('snapshot', blob, `${createdAt}_${canvasId}_${snapshot.id}.${this.fileExt}`);
|
|
114
115
|
if (this.options.isDebug) {
|
|
115
|
-
saveImageData(blob, `${createdAt}_${canvasId}_${snapshot.id}.
|
|
116
|
+
saveImageData(blob, `${createdAt}_${canvasId}_${snapshot.id}.${this.fileExt}`);
|
|
116
117
|
}
|
|
117
118
|
});
|
|
118
119
|
fetch(this.app.options.ingestPoint + '/v1/web/images', {
|
|
@@ -139,8 +140,8 @@ const qualityInt = {
|
|
|
139
140
|
medium: 0.55,
|
|
140
141
|
high: 0.8,
|
|
141
142
|
};
|
|
142
|
-
function captureSnapshot(canvas, quality = 'medium', dummy, fixedScaling = false, onBlob) {
|
|
143
|
-
const imageFormat =
|
|
143
|
+
function captureSnapshot(canvas, quality = 'medium', dummy, fixedScaling = false, fileExt, onBlob) {
|
|
144
|
+
const imageFormat = `image/${fileExt}`;
|
|
144
145
|
if (fixedScaling) {
|
|
145
146
|
const canvasScaleRatio = window.devicePixelRatio || 1;
|
|
146
147
|
dummy.width = canvas.width / canvasScaleRatio;
|
package/cjs/app/index.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
+
import type { Options as WebworkerOptions } from '../common/interaction.js';
|
|
2
|
+
import AttributeSender from '../modules/attributeSender.js';
|
|
1
3
|
import FeatureFlags from '../modules/featureFlags.js';
|
|
4
|
+
import type { Options as NetworkOptions } from '../modules/network.js';
|
|
5
|
+
import Logger, { ILogLevel } from './logger.js';
|
|
2
6
|
import Message from './messages.gen.js';
|
|
3
7
|
import Nodes from './nodes.js';
|
|
4
|
-
import Observer from './observer/top_observer.js';
|
|
5
|
-
import Sanitizer from './sanitizer.js';
|
|
6
|
-
import Ticker from './ticker.js';
|
|
7
|
-
import Logger, { ILogLevel } from './logger.js';
|
|
8
|
-
import Session from './session.js';
|
|
9
|
-
import AttributeSender from '../modules/attributeSender.js';
|
|
10
8
|
import type { Options as ObserverOptions } from './observer/top_observer.js';
|
|
9
|
+
import Observer from './observer/top_observer.js';
|
|
11
10
|
import type { Options as SanitizerOptions } from './sanitizer.js';
|
|
11
|
+
import Sanitizer from './sanitizer.js';
|
|
12
12
|
import type { Options as SessOptions } from './session.js';
|
|
13
|
-
import
|
|
14
|
-
import
|
|
13
|
+
import Session from './session.js';
|
|
14
|
+
import Ticker from './ticker.js';
|
|
15
15
|
export interface StartOptions {
|
|
16
16
|
userID?: string;
|
|
17
17
|
metadata?: Record<string, string>;
|
|
@@ -50,28 +50,56 @@ type AppOptions = {
|
|
|
50
50
|
__is_snippet: boolean;
|
|
51
51
|
__debug_report_edp: string | null;
|
|
52
52
|
__debug__?: ILogLevel;
|
|
53
|
+
/** @deprecated see canvas prop */
|
|
53
54
|
__save_canvas_locally?: boolean;
|
|
55
|
+
/** @deprecated see canvas prop */
|
|
54
56
|
fixedCanvasScaling?: boolean;
|
|
55
57
|
localStorage: Storage | null;
|
|
56
58
|
sessionStorage: Storage | null;
|
|
57
59
|
forceSingleTab?: boolean;
|
|
60
|
+
/** Sometimes helps to prevent session breaking due to dict reset */
|
|
58
61
|
disableStringDict?: boolean;
|
|
59
62
|
assistSocketHost?: string;
|
|
63
|
+
/** @deprecated see canvas prop */
|
|
60
64
|
disableCanvas?: boolean;
|
|
61
65
|
canvas: {
|
|
62
66
|
disableCanvas?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* If you expect HI-DPI users mostly, this will render canvas
|
|
69
|
+
* in 1:1 pixel ratio
|
|
70
|
+
* */
|
|
63
71
|
fixedCanvasScaling?: boolean;
|
|
64
72
|
__save_canvas_locally?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Use with care since it hijacks one frame each time it captures
|
|
75
|
+
* snapshot for every canvas
|
|
76
|
+
* */
|
|
65
77
|
useAnimationFrame?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Use webp unless it produces too big images
|
|
80
|
+
* @default webp
|
|
81
|
+
* */
|
|
82
|
+
fileExt?: 'webp' | 'png' | 'jpeg' | 'avif';
|
|
83
|
+
};
|
|
84
|
+
crossdomain?: {
|
|
85
|
+
/**
|
|
86
|
+
* @default false
|
|
87
|
+
* */
|
|
88
|
+
enabled?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* used to send message up, will be '*' by default
|
|
91
|
+
* (check your CSP settings)
|
|
92
|
+
* @default '*'
|
|
93
|
+
* */
|
|
94
|
+
parentDomain?: string;
|
|
66
95
|
};
|
|
67
|
-
/** @deprecated */
|
|
68
|
-
onStart?: StartCallback;
|
|
69
96
|
network?: NetworkOptions;
|
|
70
97
|
} & WebworkerOptions & SessOptions;
|
|
71
98
|
export type Options = AppOptions & ObserverOptions & SanitizerOptions;
|
|
72
99
|
export declare const DEFAULT_INGEST_POINT = "https://api.openreplay.com/ingest";
|
|
73
100
|
export default class App {
|
|
74
101
|
private readonly signalError;
|
|
102
|
+
private readonly insideIframe;
|
|
75
103
|
readonly nodes: Nodes;
|
|
76
104
|
readonly ticker: Ticker;
|
|
77
105
|
readonly projectKey: string;
|
|
@@ -97,21 +125,29 @@ export default class App {
|
|
|
97
125
|
private readonly revID;
|
|
98
126
|
private activityState;
|
|
99
127
|
private readonly version;
|
|
100
|
-
private
|
|
128
|
+
private worker?;
|
|
101
129
|
attributeSender: AttributeSender;
|
|
102
130
|
featureFlags: FeatureFlags;
|
|
103
131
|
socketMode: boolean;
|
|
104
132
|
private compressionThreshold;
|
|
105
|
-
private restartAttempts;
|
|
106
133
|
private readonly bc;
|
|
107
134
|
private readonly contextId;
|
|
108
135
|
private canvasRecorder;
|
|
109
136
|
private uxtManager;
|
|
110
137
|
private conditionsManager;
|
|
111
138
|
private readonly tagWatcher;
|
|
112
|
-
|
|
139
|
+
private canStart;
|
|
140
|
+
private rootId;
|
|
141
|
+
private pageFrames;
|
|
142
|
+
private frameOderNumber;
|
|
143
|
+
private readonly initialHostName;
|
|
144
|
+
constructor(projectKey: string, sessionToken: string | undefined, options: Partial<Options>, signalError: (error: string, apis: string[]) => void, insideIframe: boolean);
|
|
145
|
+
startTimeout: ReturnType<typeof setTimeout> | null;
|
|
146
|
+
private allowAppStart;
|
|
147
|
+
private checkNodeId;
|
|
148
|
+
private initWorker;
|
|
149
|
+
private handleWorkerMsg;
|
|
113
150
|
private _debug;
|
|
114
|
-
private _usingOldFetchPlugin;
|
|
115
151
|
send(message: Message, urgent?: boolean): void;
|
|
116
152
|
/**
|
|
117
153
|
* Normal workflow: add timestamp and tab data to batch, then commit it
|
|
@@ -168,10 +204,11 @@ export default class App {
|
|
|
168
204
|
private checkSessionToken;
|
|
169
205
|
/**
|
|
170
206
|
* start buffering messages without starting the actual session, which gives
|
|
171
|
-
* user 30 seconds to "activate" and record session by calling `start()` on conditional trigger
|
|
207
|
+
* user 30 seconds to "activate" and record session by calling `start()` on conditional trigger,
|
|
172
208
|
* and we will then send buffered batch, so it won't get lost
|
|
173
209
|
* */
|
|
174
210
|
coldStart(startOpts?: StartOptions, conditional?: boolean): Promise<void>;
|
|
211
|
+
private setupConditionalStart;
|
|
175
212
|
onSessionSent: () => void;
|
|
176
213
|
/**
|
|
177
214
|
* Starts offline session recording
|
|
@@ -186,7 +223,7 @@ export default class App {
|
|
|
186
223
|
/**
|
|
187
224
|
* Saves the captured messages in localStorage (or whatever is used in its place)
|
|
188
225
|
*
|
|
189
|
-
* Then when this.offlineRecording is called, it will preload this messages and clear the storage item
|
|
226
|
+
* Then, when this.offlineRecording is called, it will preload this messages and clear the storage item
|
|
190
227
|
*
|
|
191
228
|
* Keeping the size of local storage reasonable is up to the end users of this library
|
|
192
229
|
* */
|
|
@@ -213,6 +250,8 @@ export default class App {
|
|
|
213
250
|
onUxtCb: never[];
|
|
214
251
|
addOnUxtCb(cb: (id: number) => void): void;
|
|
215
252
|
getUxtId(): number | null;
|
|
253
|
+
waitStart(): Promise<unknown>;
|
|
254
|
+
waitStarted(): Promise<unknown>;
|
|
216
255
|
/**
|
|
217
256
|
* basically we ask other tabs during constructor
|
|
218
257
|
* and here we just apply 10ms delay just in case
|