@openreplay/tracker 12.0.6 → 12.0.7-beta.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/cjs/app/canvas.js +1 -2
- package/cjs/app/index.js +66 -48
- package/cjs/app/observer/iframe_offsets.js +2 -4
- package/cjs/app/observer/observer.js +1 -1
- package/cjs/index.js +8 -15
- package/cjs/modules/Network/beaconProxy.js +1 -2
- package/cjs/modules/Network/fetchProxy.js +5 -5
- package/cjs/modules/Network/index.js +1 -2
- package/cjs/modules/Network/xhrProxy.js +3 -3
- package/cjs/modules/axiosSpy.js +2 -3
- package/cjs/modules/conditionsManager.js +1 -1
- package/cjs/modules/constructedStyleSheets.js +5 -2
- package/cjs/modules/featureFlags.js +2 -3
- package/cjs/modules/mouse.js +4 -4
- package/cjs/modules/network.js +2 -2
- package/cjs/modules/tagWatcher.js +1 -2
- package/cjs/modules/timing.js +1 -2
- package/cjs/modules/userTesting/index.js +18 -23
- package/cjs/modules/userTesting/recorder.js +3 -4
- package/cjs/modules/userTesting/styles.js +17 -2
- package/lib/app/canvas.js +1 -2
- package/lib/app/index.js +66 -48
- package/lib/app/observer/iframe_offsets.js +2 -4
- package/lib/app/observer/observer.js +1 -1
- package/lib/common/tsconfig.tsbuildinfo +1 -1
- package/lib/index.js +8 -15
- package/lib/modules/Network/beaconProxy.js +1 -2
- package/lib/modules/Network/fetchProxy.js +5 -5
- package/lib/modules/Network/index.js +1 -2
- package/lib/modules/Network/xhrProxy.js +3 -3
- package/lib/modules/axiosSpy.js +2 -3
- package/lib/modules/conditionsManager.js +1 -1
- package/lib/modules/constructedStyleSheets.js +5 -2
- package/lib/modules/featureFlags.js +2 -3
- package/lib/modules/mouse.js +4 -4
- package/lib/modules/network.js +2 -2
- package/lib/modules/tagWatcher.js +1 -2
- package/lib/modules/timing.js +1 -2
- package/lib/modules/userTesting/index.js +18 -23
- package/lib/modules/userTesting/recorder.js +3 -4
- package/lib/modules/userTesting/styles.js +17 -2
- package/package.json +1 -1
- package/tsconfig-base.json +1 -1
package/cjs/app/canvas.js
CHANGED
|
@@ -89,7 +89,6 @@ class CanvasRecorder {
|
|
|
89
89
|
}, 500);
|
|
90
90
|
}
|
|
91
91
|
sendSnaps(images, canvasId, createdAt) {
|
|
92
|
-
var _a;
|
|
93
92
|
if (Object.keys(this.snapshots).length === 0) {
|
|
94
93
|
return;
|
|
95
94
|
}
|
|
@@ -106,7 +105,7 @@ class CanvasRecorder {
|
|
|
106
105
|
fetch(this.app.options.ingestPoint + '/v1/web/images', {
|
|
107
106
|
method: 'POST',
|
|
108
107
|
headers: {
|
|
109
|
-
Authorization: `Bearer ${
|
|
108
|
+
Authorization: `Bearer ${this.app.session.getSessionToken() ?? ''}`,
|
|
110
109
|
},
|
|
111
110
|
body: formData,
|
|
112
111
|
})
|
package/cjs/app/index.js
CHANGED
|
@@ -49,7 +49,7 @@ const uxtStorageKey = 'or_uxt_active';
|
|
|
49
49
|
const bufferStorageKey = 'or_buffer_1';
|
|
50
50
|
const START_ERROR = ':(';
|
|
51
51
|
const UnsuccessfulStart = (reason) => ({ reason, success: false });
|
|
52
|
-
const SuccessfulStart = (body) => (
|
|
52
|
+
const SuccessfulStart = (body) => ({ ...body, success: true });
|
|
53
53
|
var ActivityState;
|
|
54
54
|
(function (ActivityState) {
|
|
55
55
|
ActivityState[ActivityState["NotActive"] = 0] = "NotActive";
|
|
@@ -68,7 +68,6 @@ function getTimezone() {
|
|
|
68
68
|
}
|
|
69
69
|
class App {
|
|
70
70
|
constructor(projectKey, sessionToken, options, signalError) {
|
|
71
|
-
var _a, _b;
|
|
72
71
|
this.signalError = signalError;
|
|
73
72
|
this.messages = [];
|
|
74
73
|
/**
|
|
@@ -81,7 +80,7 @@ class App {
|
|
|
81
80
|
this.stopCallbacks = [];
|
|
82
81
|
this.commitCallbacks = [];
|
|
83
82
|
this.activityState = ActivityState.NotActive;
|
|
84
|
-
this.version = '12.0.
|
|
83
|
+
this.version = '12.0.7-beta.1'; // TODO: version compatability check inside each plugin.
|
|
85
84
|
this.compressionThreshold = 24 * 1000;
|
|
86
85
|
this.restartAttempts = 0;
|
|
87
86
|
this.bc = null;
|
|
@@ -98,8 +97,7 @@ class App {
|
|
|
98
97
|
return;
|
|
99
98
|
};
|
|
100
99
|
this.restartCanvasTracking = () => {
|
|
101
|
-
|
|
102
|
-
(_a = this.canvasRecorder) === null || _a === void 0 ? void 0 : _a.restartTracking();
|
|
100
|
+
this.canvasRecorder?.restartTracking();
|
|
103
101
|
};
|
|
104
102
|
this.flushBuffer = async (buffer) => {
|
|
105
103
|
return new Promise((res) => {
|
|
@@ -149,8 +147,8 @@ class App {
|
|
|
149
147
|
this.bc = (0, utils_js_1.inIframe)() ? null : new BroadcastChannel(`rick_${host}`);
|
|
150
148
|
}
|
|
151
149
|
this.revID = this.options.revID;
|
|
152
|
-
this.localStorage =
|
|
153
|
-
this.sessionStorage =
|
|
150
|
+
this.localStorage = this.options.localStorage ?? window.localStorage;
|
|
151
|
+
this.sessionStorage = this.options.sessionStorage ?? window.sessionStorage;
|
|
154
152
|
this.sanitizer = new sanitizer_js_1.default(this, options);
|
|
155
153
|
this.nodes = new nodes_js_1.default(this.options.node_id);
|
|
156
154
|
this.observer = new top_observer_js_1.default(this, options);
|
|
@@ -182,7 +180,6 @@ class App {
|
|
|
182
180
|
this._debug('webworker_error', e);
|
|
183
181
|
};
|
|
184
182
|
this.worker.onmessage = ({ data }) => {
|
|
185
|
-
var _a;
|
|
186
183
|
if (data === 'restart') {
|
|
187
184
|
this.stop(false);
|
|
188
185
|
void this.start({}, true);
|
|
@@ -200,18 +197,17 @@ class App {
|
|
|
200
197
|
const batchSize = batch.byteLength;
|
|
201
198
|
if (batchSize > this.compressionThreshold) {
|
|
202
199
|
(0, fflate_1.gzip)(data.batch, { mtime: 0 }, (err, result) => {
|
|
203
|
-
var _a, _b;
|
|
204
200
|
if (err) {
|
|
205
201
|
this.debug.error('Openreplay compression error:', err);
|
|
206
|
-
|
|
202
|
+
this.worker?.postMessage({ type: 'uncompressed', batch: batch });
|
|
207
203
|
}
|
|
208
204
|
else {
|
|
209
|
-
|
|
205
|
+
this.worker?.postMessage({ type: 'compressed', batch: result });
|
|
210
206
|
}
|
|
211
207
|
});
|
|
212
208
|
}
|
|
213
209
|
else {
|
|
214
|
-
|
|
210
|
+
this.worker?.postMessage({ type: 'uncompressed', batch: batch });
|
|
215
211
|
}
|
|
216
212
|
}
|
|
217
213
|
else if (data.type === 'queue_empty') {
|
|
@@ -291,7 +287,6 @@ class App {
|
|
|
291
287
|
this.debug.error('OpenReplay error: ', context, e);
|
|
292
288
|
}
|
|
293
289
|
send(message, urgent = false) {
|
|
294
|
-
var _a;
|
|
295
290
|
if (this.activityState === ActivityState.NotActive) {
|
|
296
291
|
return;
|
|
297
292
|
}
|
|
@@ -310,7 +305,7 @@ class App {
|
|
|
310
305
|
if (!this.singleBuffer) {
|
|
311
306
|
this.bufferedMessages2.push(message);
|
|
312
307
|
}
|
|
313
|
-
|
|
308
|
+
this.conditionsManager?.processMessage(message);
|
|
314
309
|
}
|
|
315
310
|
else {
|
|
316
311
|
this.messages.push(message);
|
|
@@ -331,11 +326,10 @@ class App {
|
|
|
331
326
|
_nCommit() {
|
|
332
327
|
if (this.worker !== undefined && this.messages.length) {
|
|
333
328
|
(0, utils_js_1.requestIdleCb)(() => {
|
|
334
|
-
var _a;
|
|
335
329
|
this.messages.unshift((0, messages_gen_js_2.TabData)(this.session.getTabId()));
|
|
336
330
|
this.messages.unshift((0, messages_gen_js_2.Timestamp)(this.timestamp()));
|
|
337
331
|
// why I need to add opt chaining?
|
|
338
|
-
|
|
332
|
+
this.worker?.postMessage(this.messages);
|
|
339
333
|
this.commitCallbacks.forEach((cb) => cb(this.messages));
|
|
340
334
|
this.messages.length = 0;
|
|
341
335
|
});
|
|
@@ -366,8 +360,7 @@ class App {
|
|
|
366
360
|
}
|
|
367
361
|
}
|
|
368
362
|
postToWorker(messages) {
|
|
369
|
-
|
|
370
|
-
(_a = this.worker) === null || _a === void 0 ? void 0 : _a.postMessage(messages);
|
|
363
|
+
this.worker?.postMessage(messages);
|
|
371
364
|
this.commitCallbacks.forEach((cb) => cb(messages));
|
|
372
365
|
messages.length = 0;
|
|
373
366
|
}
|
|
@@ -439,7 +432,10 @@ class App {
|
|
|
439
432
|
};
|
|
440
433
|
}
|
|
441
434
|
getSessionInfo() {
|
|
442
|
-
return
|
|
435
|
+
return {
|
|
436
|
+
...this.session.getInfo(),
|
|
437
|
+
...this.getTrackerInfo(),
|
|
438
|
+
};
|
|
443
439
|
}
|
|
444
440
|
getSessionToken() {
|
|
445
441
|
return this.session.getSessionToken();
|
|
@@ -457,7 +453,7 @@ class App {
|
|
|
457
453
|
const isSaas = /api\.openreplay\.com/.test(ingest);
|
|
458
454
|
const projectPath = isSaas ? 'https://app.openreplay.com/ingest' : ingest;
|
|
459
455
|
const url = projectPath.replace(/ingest$/, `${projectID}/session/${sessionID}`);
|
|
460
|
-
if (options
|
|
456
|
+
if (options?.withCurrentTime) {
|
|
461
457
|
const jumpTo = (0, utils_js_1.now)() - timestamp;
|
|
462
458
|
return `${url}?jumpto=${jumpTo}`;
|
|
463
459
|
}
|
|
@@ -470,7 +466,6 @@ class App {
|
|
|
470
466
|
return this.projectKey;
|
|
471
467
|
}
|
|
472
468
|
getBaseHref() {
|
|
473
|
-
var _a, _b;
|
|
474
469
|
if (typeof this.options.resourceBaseHref === 'string') {
|
|
475
470
|
return this.options.resourceBaseHref;
|
|
476
471
|
}
|
|
@@ -481,7 +476,7 @@ class App {
|
|
|
481
476
|
return document.baseURI;
|
|
482
477
|
}
|
|
483
478
|
// IE only
|
|
484
|
-
return (
|
|
479
|
+
return (document.head?.getElementsByTagName('base')[0]?.getAttribute('href') ||
|
|
485
480
|
location.origin + location.pathname);
|
|
486
481
|
}
|
|
487
482
|
resolveResourceURL(resourceURL) {
|
|
@@ -516,7 +511,6 @@ class App {
|
|
|
516
511
|
* and we will then send buffered batch, so it won't get lost
|
|
517
512
|
* */
|
|
518
513
|
async coldStart(startOpts = {}, conditional) {
|
|
519
|
-
var _a, _b;
|
|
520
514
|
this.singleBuffer = false;
|
|
521
515
|
const second = 1000;
|
|
522
516
|
if (conditional) {
|
|
@@ -529,8 +523,17 @@ class App {
|
|
|
529
523
|
headers: {
|
|
530
524
|
'Content-Type': 'application/json',
|
|
531
525
|
},
|
|
532
|
-
body: JSON.stringify(
|
|
533
|
-
|
|
526
|
+
body: JSON.stringify({
|
|
527
|
+
...this.getTrackerInfo(),
|
|
528
|
+
timestamp: (0, utils_js_1.now)(),
|
|
529
|
+
doNotRecord: true,
|
|
530
|
+
bufferDiff: 0,
|
|
531
|
+
userID: this.session.getInfo().userID,
|
|
532
|
+
token: undefined,
|
|
533
|
+
deviceMemory: performance_js_1.deviceMemory,
|
|
534
|
+
jsHeapSizeLimit: performance_js_1.jsHeapSizeLimit,
|
|
535
|
+
timezone: getTimezone(),
|
|
536
|
+
}),
|
|
534
537
|
});
|
|
535
538
|
const {
|
|
536
539
|
// this token is needed to fetch conditions and flags,
|
|
@@ -547,10 +550,10 @@ class App {
|
|
|
547
550
|
});
|
|
548
551
|
const onStartInfo = { sessionToken: token, userUUID: '', sessionID: '' };
|
|
549
552
|
this.startCallbacks.forEach((cb) => cb(onStartInfo));
|
|
550
|
-
await
|
|
553
|
+
await this.conditionsManager?.fetchConditions(projectID, token);
|
|
551
554
|
await this.featureFlags.reloadFlags(token);
|
|
552
555
|
await this.tagWatcher.fetchTags(this.options.ingestPoint, token);
|
|
553
|
-
|
|
556
|
+
this.conditionsManager?.processFlags(this.featureFlags.flags);
|
|
554
557
|
}
|
|
555
558
|
const cycle = () => {
|
|
556
559
|
this.orderNumber += 1;
|
|
@@ -665,10 +668,9 @@ class App {
|
|
|
665
668
|
* @reject {string} - error message
|
|
666
669
|
* */
|
|
667
670
|
async uploadOfflineRecording() {
|
|
668
|
-
var _a, _b;
|
|
669
671
|
this.stop(false);
|
|
670
672
|
const timestamp = (0, utils_js_1.now)();
|
|
671
|
-
|
|
673
|
+
this.worker?.postMessage({
|
|
672
674
|
type: 'start',
|
|
673
675
|
pageNo: this.session.incPageNo(),
|
|
674
676
|
ingestPoint: this.options.ingestPoint,
|
|
@@ -683,11 +685,20 @@ class App {
|
|
|
683
685
|
headers: {
|
|
684
686
|
'Content-Type': 'application/json',
|
|
685
687
|
},
|
|
686
|
-
body: JSON.stringify(
|
|
687
|
-
|
|
688
|
+
body: JSON.stringify({
|
|
689
|
+
...this.getTrackerInfo(),
|
|
690
|
+
timestamp: timestamp,
|
|
691
|
+
doNotRecord: false,
|
|
692
|
+
bufferDiff: timestamp - this.coldStartTs,
|
|
693
|
+
userID: this.session.getInfo().userID,
|
|
694
|
+
token: undefined,
|
|
695
|
+
deviceMemory: performance_js_1.deviceMemory,
|
|
696
|
+
jsHeapSizeLimit: performance_js_1.jsHeapSizeLimit,
|
|
697
|
+
timezone: getTimezone(),
|
|
698
|
+
}),
|
|
688
699
|
});
|
|
689
700
|
const { token, userBrowser, userCity, userCountry, userDevice, userOS, userState, beaconSizeLimit, projectID, } = await r.json();
|
|
690
|
-
|
|
701
|
+
this.worker?.postMessage({
|
|
691
702
|
type: 'auth',
|
|
692
703
|
token,
|
|
693
704
|
beaconSizeLimit,
|
|
@@ -759,8 +770,18 @@ class App {
|
|
|
759
770
|
headers: {
|
|
760
771
|
'Content-Type': 'application/json',
|
|
761
772
|
},
|
|
762
|
-
body: JSON.stringify(
|
|
763
|
-
|
|
773
|
+
body: JSON.stringify({
|
|
774
|
+
...this.getTrackerInfo(),
|
|
775
|
+
timestamp,
|
|
776
|
+
doNotRecord: false,
|
|
777
|
+
bufferDiff: timestamp - this.coldStartTs,
|
|
778
|
+
userID: this.session.getInfo().userID,
|
|
779
|
+
token: isNewSession ? undefined : sessionToken,
|
|
780
|
+
deviceMemory: performance_js_1.deviceMemory,
|
|
781
|
+
jsHeapSizeLimit: performance_js_1.jsHeapSizeLimit,
|
|
782
|
+
timezone: getTimezone(),
|
|
783
|
+
condition: conditionName,
|
|
784
|
+
}),
|
|
764
785
|
})
|
|
765
786
|
.then((r) => {
|
|
766
787
|
if (r.status === 200) {
|
|
@@ -775,7 +796,6 @@ class App {
|
|
|
775
796
|
}
|
|
776
797
|
})
|
|
777
798
|
.then(async (r) => {
|
|
778
|
-
var _a;
|
|
779
799
|
if (!this.worker) {
|
|
780
800
|
const reason = 'no worker found after start request (this might not happen)';
|
|
781
801
|
this.signalError(reason, []);
|
|
@@ -839,12 +859,13 @@ class App {
|
|
|
839
859
|
this.activityState = ActivityState.Active;
|
|
840
860
|
if (canvasEnabled && !this.options.disableCanvas) {
|
|
841
861
|
this.canvasRecorder =
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
862
|
+
this.canvasRecorder ??
|
|
863
|
+
new canvas_js_1.default(this, {
|
|
864
|
+
fps: canvasFPS,
|
|
865
|
+
quality: canvasQuality,
|
|
866
|
+
isDebug: this.options.__save_canvas_locally,
|
|
867
|
+
fixedScaling: this.options.fixedCanvasScaling,
|
|
868
|
+
});
|
|
848
869
|
this.canvasRecorder.startTracking();
|
|
849
870
|
}
|
|
850
871
|
/** --------------- COLD START BUFFER ------------------*/
|
|
@@ -876,7 +897,7 @@ class App {
|
|
|
876
897
|
if (savedUxtTag) {
|
|
877
898
|
uxtId = parseInt(savedUxtTag, 10);
|
|
878
899
|
}
|
|
879
|
-
if (location
|
|
900
|
+
if (location?.search) {
|
|
880
901
|
const query = new URLSearchParams(location.search);
|
|
881
902
|
if (query.has('oruxt')) {
|
|
882
903
|
const qId = query.get('oruxt');
|
|
@@ -916,8 +937,7 @@ class App {
|
|
|
916
937
|
this.onUxtCb.push(cb);
|
|
917
938
|
}
|
|
918
939
|
getUxtId() {
|
|
919
|
-
|
|
920
|
-
return (_a = this.uxtManager) === null || _a === void 0 ? void 0 : _a.getTestId();
|
|
940
|
+
return this.uxtManager?.getTestId();
|
|
921
941
|
}
|
|
922
942
|
/**
|
|
923
943
|
* basically we ask other tabs during constructor
|
|
@@ -946,8 +966,7 @@ class App {
|
|
|
946
966
|
}
|
|
947
967
|
}
|
|
948
968
|
forceFlushBatch() {
|
|
949
|
-
|
|
950
|
-
(_a = this.worker) === null || _a === void 0 ? void 0 : _a.postMessage('forceFlushBatch');
|
|
969
|
+
this.worker?.postMessage('forceFlushBatch');
|
|
951
970
|
}
|
|
952
971
|
getTabId() {
|
|
953
972
|
return this.session.getTabId();
|
|
@@ -974,7 +993,6 @@ class App {
|
|
|
974
993
|
};
|
|
975
994
|
}
|
|
976
995
|
stop(stopWorker = true) {
|
|
977
|
-
var _a;
|
|
978
996
|
if (this.activityState !== ActivityState.NotActive) {
|
|
979
997
|
try {
|
|
980
998
|
this.attributeSender.clear();
|
|
@@ -988,7 +1006,7 @@ class App {
|
|
|
988
1006
|
if (this.worker && stopWorker) {
|
|
989
1007
|
this.worker.postMessage('stop');
|
|
990
1008
|
}
|
|
991
|
-
|
|
1009
|
+
this.canvasRecorder?.clear();
|
|
992
1010
|
}
|
|
993
1011
|
finally {
|
|
994
1012
|
this.activityState = ActivityState.NotActive;
|
|
@@ -26,7 +26,6 @@ class IFrameOffsets {
|
|
|
26
26
|
return this.calcOffset(state);
|
|
27
27
|
}
|
|
28
28
|
observe(iFrame) {
|
|
29
|
-
var _a;
|
|
30
29
|
const doc = iFrame.contentDocument;
|
|
31
30
|
if (!doc) {
|
|
32
31
|
return;
|
|
@@ -38,9 +37,8 @@ class IFrameOffsets {
|
|
|
38
37
|
iFrame,
|
|
39
38
|
parent: parentState || null,
|
|
40
39
|
clear: () => {
|
|
41
|
-
var _a;
|
|
42
40
|
parentDoc.removeEventListener('scroll', invalidateOffset);
|
|
43
|
-
|
|
41
|
+
parentDoc.defaultView?.removeEventListener('resize', invalidateOffset);
|
|
44
42
|
},
|
|
45
43
|
};
|
|
46
44
|
const invalidateOffset = () => {
|
|
@@ -48,7 +46,7 @@ class IFrameOffsets {
|
|
|
48
46
|
};
|
|
49
47
|
// anything more reliable? This does not cover all cases (layout changes are ignored, for ex.)
|
|
50
48
|
parentDoc.addEventListener('scroll', invalidateOffset);
|
|
51
|
-
|
|
49
|
+
parentDoc.defaultView?.addEventListener('resize', invalidateOffset);
|
|
52
50
|
this.states.set(doc, state);
|
|
53
51
|
}
|
|
54
52
|
clear() {
|
|
@@ -17,7 +17,7 @@ function isIgnored(node) {
|
|
|
17
17
|
if (tag === 'LINK') {
|
|
18
18
|
const rel = node.getAttribute('rel');
|
|
19
19
|
const as = node.getAttribute('as');
|
|
20
|
-
return !(
|
|
20
|
+
return !(rel?.includes('stylesheet') || as === 'style' || as === 'font');
|
|
21
21
|
}
|
|
22
22
|
return (tag === 'SCRIPT' || tag === 'NOSCRIPT' || tag === 'META' || tag === 'TITLE' || tag === 'BASE');
|
|
23
23
|
}
|
package/cjs/index.js
CHANGED
|
@@ -83,7 +83,6 @@ function processOptions(obj) {
|
|
|
83
83
|
}
|
|
84
84
|
class API {
|
|
85
85
|
constructor(options) {
|
|
86
|
-
var _a;
|
|
87
86
|
this.options = options;
|
|
88
87
|
this.app = null;
|
|
89
88
|
this.checkDoNotTrack = () => {
|
|
@@ -98,7 +97,7 @@ class API {
|
|
|
98
97
|
const orig = this.options.ingestPoint || index_js_1.DEFAULT_INGEST_POINT;
|
|
99
98
|
req.open('POST', orig + '/v1/web/not-started');
|
|
100
99
|
req.send(JSON.stringify({
|
|
101
|
-
trackerVersion: '12.0.
|
|
100
|
+
trackerVersion: '12.0.7-beta.1',
|
|
102
101
|
projectKey: this.options.projectKey,
|
|
103
102
|
doNotTrack,
|
|
104
103
|
reason,
|
|
@@ -201,15 +200,14 @@ class API {
|
|
|
201
200
|
(0, selection_js_1.default)(app);
|
|
202
201
|
(0, tabs_js_1.default)(app);
|
|
203
202
|
window.__OPENREPLAY__ = this;
|
|
204
|
-
if (
|
|
203
|
+
if (options.flags?.onFlagsLoad) {
|
|
205
204
|
this.onFlagsLoad(options.flags.onFlagsLoad);
|
|
206
205
|
}
|
|
207
206
|
const wOpen = window.open;
|
|
208
207
|
if (options.autoResetOnWindowOpen || options.resetTabOnWindowOpen) {
|
|
209
208
|
app.attachStartCallback(() => {
|
|
210
|
-
var _a;
|
|
211
209
|
const tabId = app.getTabId();
|
|
212
|
-
const sessStorage =
|
|
210
|
+
const sessStorage = app.sessionStorage ?? window.sessionStorage;
|
|
213
211
|
// @ts-ignore ?
|
|
214
212
|
window.open = function (...args) {
|
|
215
213
|
if (options.autoResetOnWindowOpen) {
|
|
@@ -232,24 +230,19 @@ class API {
|
|
|
232
230
|
return this.featureFlags.isFlagEnabled(flagName);
|
|
233
231
|
}
|
|
234
232
|
onFlagsLoad(callback) {
|
|
235
|
-
|
|
236
|
-
(_a = this.app) === null || _a === void 0 ? void 0 : _a.featureFlags.onFlagsLoad(callback);
|
|
233
|
+
this.app?.featureFlags.onFlagsLoad(callback);
|
|
237
234
|
}
|
|
238
235
|
clearPersistFlags() {
|
|
239
|
-
|
|
240
|
-
(_a = this.app) === null || _a === void 0 ? void 0 : _a.featureFlags.clearPersistFlags();
|
|
236
|
+
this.app?.featureFlags.clearPersistFlags();
|
|
241
237
|
}
|
|
242
238
|
reloadFlags() {
|
|
243
|
-
|
|
244
|
-
return (_a = this.app) === null || _a === void 0 ? void 0 : _a.featureFlags.reloadFlags();
|
|
239
|
+
return this.app?.featureFlags.reloadFlags();
|
|
245
240
|
}
|
|
246
241
|
getFeatureFlag(flagName) {
|
|
247
|
-
|
|
248
|
-
return (_a = this.app) === null || _a === void 0 ? void 0 : _a.featureFlags.getFeatureFlag(flagName);
|
|
242
|
+
return this.app?.featureFlags.getFeatureFlag(flagName);
|
|
249
243
|
}
|
|
250
244
|
getAllFeatureFlags() {
|
|
251
|
-
|
|
252
|
-
return (_a = this.app) === null || _a === void 0 ? void 0 : _a.featureFlags.flags;
|
|
245
|
+
return this.app?.featureFlags.flags;
|
|
253
246
|
}
|
|
254
247
|
use(fn) {
|
|
255
248
|
return fn(this.app, this.options);
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
var _a;
|
|
6
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
6
|
exports.BeaconProxyHandler = void 0;
|
|
8
7
|
const networkMessage_js_1 = __importDefault(require("./networkMessage.js"));
|
|
@@ -85,4 +84,4 @@ class BeaconProxy {
|
|
|
85
84
|
}
|
|
86
85
|
}
|
|
87
86
|
exports.default = BeaconProxy;
|
|
88
|
-
BeaconProxy.origSendBeacon =
|
|
87
|
+
BeaconProxy.origSendBeacon = window?.navigator?.sendBeacon;
|
|
@@ -142,7 +142,7 @@ class FetchProxyHandler {
|
|
|
142
142
|
const init = argsList[1];
|
|
143
143
|
if (!input ||
|
|
144
144
|
// @ts-ignore
|
|
145
|
-
(typeof input !== 'string' && !
|
|
145
|
+
(typeof input !== 'string' && !input?.url)) {
|
|
146
146
|
return target.apply(window, argsList);
|
|
147
147
|
}
|
|
148
148
|
const isORUrl = input instanceof URL || typeof input === 'string'
|
|
@@ -166,7 +166,7 @@ class FetchProxyHandler {
|
|
|
166
166
|
if (!argsList[1])
|
|
167
167
|
argsList[1] = {};
|
|
168
168
|
if (argsList[1].headers === undefined) {
|
|
169
|
-
argsList[1] =
|
|
169
|
+
argsList[1] = { ...argsList[1], headers: {} };
|
|
170
170
|
}
|
|
171
171
|
if (argsList[1].headers instanceof Headers) {
|
|
172
172
|
argsList[1].headers.append(name, value);
|
|
@@ -194,9 +194,9 @@ class FetchProxyHandler {
|
|
|
194
194
|
// handle `input` content
|
|
195
195
|
if (typeof input === 'string') {
|
|
196
196
|
// when `input` is a string
|
|
197
|
-
method =
|
|
197
|
+
method = init?.method || 'GET';
|
|
198
198
|
url = (0, utils_js_1.getURL)(input);
|
|
199
|
-
requestHeader =
|
|
199
|
+
requestHeader = init?.headers || {};
|
|
200
200
|
}
|
|
201
201
|
else {
|
|
202
202
|
// when `input` is a `Request` object
|
|
@@ -233,7 +233,7 @@ class FetchProxyHandler {
|
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
235
|
// save POST data
|
|
236
|
-
if (init
|
|
236
|
+
if (init?.body) {
|
|
237
237
|
item.requestData = (0, utils_js_1.genStringBody)(init.body);
|
|
238
238
|
}
|
|
239
239
|
}
|
|
@@ -9,7 +9,6 @@ const beaconProxy_js_1 = __importDefault(require("./beaconProxy.js"));
|
|
|
9
9
|
const getWarning = (api) => console.warn(`Openreplay: Can't find ${api} in global context.
|
|
10
10
|
If you're using serverside rendering in your app, make sure that tracker is loaded dynamically, otherwise ${api} won't be tracked.`);
|
|
11
11
|
function setProxy(context, ignoredHeaders, setSessionTokenHeader, sanitize, sendMessage, isServiceUrl, tokenUrlMatcher) {
|
|
12
|
-
var _a;
|
|
13
12
|
if (context.XMLHttpRequest) {
|
|
14
13
|
context.XMLHttpRequest = xhrProxy_js_1.default.create(ignoredHeaders, setSessionTokenHeader, sanitize, sendMessage, isServiceUrl, tokenUrlMatcher);
|
|
15
14
|
}
|
|
@@ -22,7 +21,7 @@ function setProxy(context, ignoredHeaders, setSessionTokenHeader, sanitize, send
|
|
|
22
21
|
else {
|
|
23
22
|
getWarning('fetch');
|
|
24
23
|
}
|
|
25
|
-
if (
|
|
24
|
+
if (context?.navigator?.sendBeacon) {
|
|
26
25
|
context.navigator.sendBeacon = beaconProxy_js_1.default.create(ignoredHeaders, setSessionTokenHeader, sanitize, sendMessage, isServiceUrl);
|
|
27
26
|
}
|
|
28
27
|
}
|
|
@@ -134,8 +134,8 @@ class XHRProxyHandler {
|
|
|
134
134
|
const method = args[0];
|
|
135
135
|
const url = args[1];
|
|
136
136
|
this.item.method = method ? method.toUpperCase() : 'GET';
|
|
137
|
-
this.item.url = url || '';
|
|
138
|
-
this.item.name = this.item.url
|
|
137
|
+
this.item.url = url.toString?.() || '';
|
|
138
|
+
this.item.name = this.item.url?.replace(new RegExp('/*$'), '').split('/').pop() ?? '';
|
|
139
139
|
this.item.getData = (0, utils_js_1.genGetDataByUrl)(this.item.url, {});
|
|
140
140
|
return targetFunction.apply(target, args);
|
|
141
141
|
};
|
|
@@ -162,7 +162,7 @@ class XHRProxyHandler {
|
|
|
162
162
|
setOnReadyStateChange(target, key, orscFunction) {
|
|
163
163
|
return Reflect.set(target, key, (...args) => {
|
|
164
164
|
this.onReadyStateChange();
|
|
165
|
-
orscFunction
|
|
165
|
+
orscFunction?.apply(target, args);
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
168
|
setOnAbort(target, key, oaFunction) {
|
package/cjs/modules/axiosSpy.js
CHANGED
|
@@ -109,9 +109,8 @@ function default_1(app, instance, opts, sanitize, stringify) {
|
|
|
109
109
|
synchronous: true,
|
|
110
110
|
});
|
|
111
111
|
app.attachStopCallback(() => {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
(_d = (_c = instance.interceptors.response).eject) === null || _d === void 0 ? void 0 : _d.call(_c, resInt);
|
|
112
|
+
instance.interceptors.request.eject?.(reqInt);
|
|
113
|
+
instance.interceptors.response.eject?.(resInt);
|
|
115
114
|
});
|
|
116
115
|
}
|
|
117
116
|
exports.default = default_1;
|
|
@@ -55,7 +55,7 @@ class ConditionsManager {
|
|
|
55
55
|
if (cond.type === 'session_duration') {
|
|
56
56
|
this.processDuration(cond.value[0], c.name);
|
|
57
57
|
}
|
|
58
|
-
mappedConditions.push(
|
|
58
|
+
mappedConditions.push({ ...cond, name: c.name });
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
});
|
|
@@ -76,12 +76,15 @@ function default_1(app) {
|
|
|
76
76
|
function patchAdoptedStyleSheets(prototype) {
|
|
77
77
|
const nativeAdoptedStyleSheetsDescriptor = Object.getOwnPropertyDescriptor(prototype, 'adoptedStyleSheets');
|
|
78
78
|
if (nativeAdoptedStyleSheetsDescriptor) {
|
|
79
|
-
Object.defineProperty(prototype, 'adoptedStyleSheets',
|
|
79
|
+
Object.defineProperty(prototype, 'adoptedStyleSheets', {
|
|
80
|
+
...nativeAdoptedStyleSheetsDescriptor,
|
|
81
|
+
set: function (value) {
|
|
80
82
|
// @ts-ignore
|
|
81
83
|
const retVal = nativeAdoptedStyleSheetsDescriptor.set.call(this, value);
|
|
82
84
|
sendAdoptedStyleSheetsUpdate(this);
|
|
83
85
|
return retVal;
|
|
84
|
-
}
|
|
86
|
+
},
|
|
87
|
+
});
|
|
85
88
|
}
|
|
86
89
|
}
|
|
87
90
|
const patchContext = (context) => {
|
|
@@ -45,7 +45,7 @@ class FeatureFlags {
|
|
|
45
45
|
browser: userInfo.userBrowser,
|
|
46
46
|
persistFlags: persistFlags,
|
|
47
47
|
};
|
|
48
|
-
const authToken = token
|
|
48
|
+
const authToken = token ?? this.app.session.getSessionToken();
|
|
49
49
|
const resp = await fetch(this.app.options.ingestPoint + '/v1/web/feature-flags', {
|
|
50
50
|
method: 'POST',
|
|
51
51
|
headers: {
|
|
@@ -60,7 +60,6 @@ class FeatureFlags {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
handleFlags(flags) {
|
|
63
|
-
var _a;
|
|
64
63
|
const persistFlags = [];
|
|
65
64
|
flags.forEach((flag) => {
|
|
66
65
|
if (flag.is_persist)
|
|
@@ -73,7 +72,7 @@ class FeatureFlags {
|
|
|
73
72
|
});
|
|
74
73
|
this.app.sessionStorage.setItem(this.storageKey, str);
|
|
75
74
|
this.flags = flags;
|
|
76
|
-
return
|
|
75
|
+
return this.onFlagsCb?.(flags);
|
|
77
76
|
}
|
|
78
77
|
clearPersistFlags() {
|
|
79
78
|
this.app.sessionStorage.removeItem(this.storageKey);
|
package/cjs/modules/mouse.js
CHANGED
|
@@ -9,9 +9,9 @@ function _getSelector(target, document, options) {
|
|
|
9
9
|
const selector = (0, finder_1.finder)(target, {
|
|
10
10
|
root: document.body,
|
|
11
11
|
seedMinLength: 3,
|
|
12
|
-
optimizedMinLength:
|
|
13
|
-
threshold:
|
|
14
|
-
maxNumberOfTries:
|
|
12
|
+
optimizedMinLength: options?.minSelectorDepth || 2,
|
|
13
|
+
threshold: options?.nthThreshold || 1000,
|
|
14
|
+
maxNumberOfTries: options?.maxOptimiseTries || 10000,
|
|
15
15
|
});
|
|
16
16
|
return selector;
|
|
17
17
|
}
|
|
@@ -177,6 +177,6 @@ function default_1(app, options) {
|
|
|
177
177
|
}
|
|
178
178
|
});
|
|
179
179
|
patchDocument(document, true);
|
|
180
|
-
app.ticker.attach(sendMouseMove,
|
|
180
|
+
app.ticker.attach(sendMouseMove, options?.trackingOffset || 7);
|
|
181
181
|
}
|
|
182
182
|
exports.default = default_1;
|
package/cjs/modules/network.js
CHANGED
|
@@ -58,7 +58,7 @@ function default_1(app, opts = {}) {
|
|
|
58
58
|
try {
|
|
59
59
|
reqResInfo.response.body = JSON.parse(resBody);
|
|
60
60
|
}
|
|
61
|
-
catch
|
|
61
|
+
catch { }
|
|
62
62
|
}
|
|
63
63
|
return options.sanitizer(reqResInfo);
|
|
64
64
|
}
|
|
@@ -69,7 +69,7 @@ function default_1(app, opts = {}) {
|
|
|
69
69
|
try {
|
|
70
70
|
r.body = JSON.stringify(r.body);
|
|
71
71
|
}
|
|
72
|
-
catch
|
|
72
|
+
catch {
|
|
73
73
|
r.body = '<unable to stringify>';
|
|
74
74
|
app.notify.warn("Openreplay fetch couldn't stringify body:", r.body);
|
|
75
75
|
}
|
|
@@ -4,13 +4,12 @@ exports.WATCHED_TAGS_KEY = void 0;
|
|
|
4
4
|
exports.WATCHED_TAGS_KEY = '__or__watched_tags__';
|
|
5
5
|
class TagWatcher {
|
|
6
6
|
constructor(sessionStorage, errLog, onTag) {
|
|
7
|
-
var _a;
|
|
8
7
|
this.sessionStorage = sessionStorage;
|
|
9
8
|
this.errLog = errLog;
|
|
10
9
|
this.onTag = onTag;
|
|
11
10
|
this.intervals = {};
|
|
12
11
|
this.tags = [];
|
|
13
|
-
const tags = JSON.parse(
|
|
12
|
+
const tags = JSON.parse(sessionStorage.getItem(exports.WATCHED_TAGS_KEY) ?? '[]');
|
|
14
13
|
this.setTags(tags);
|
|
15
14
|
this.observer = new IntersectionObserver((entries) => {
|
|
16
15
|
entries.forEach((entry) => {
|