@openreplay/tracker 9.0.12 → 10.0.2
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/.nvmrc +1 -0
- package/CHANGELOG.md +15 -0
- package/README.md +4 -0
- package/bun.lockb +0 -0
- package/cjs/app/index.js +14 -11
- package/cjs/app/logger.d.ts +1 -1
- package/cjs/app/messages.gen.d.ts +2 -1
- package/cjs/app/messages.gen.js +20 -5
- package/cjs/app/nodes.js +4 -3
- package/cjs/app/observer/observer.js +2 -1
- package/cjs/common/messages.gen.d.ts +17 -4
- package/cjs/index.js +1 -1
- package/cjs/modules/Network/beaconProxy.d.ts +16 -0
- package/cjs/modules/Network/beaconProxy.js +82 -0
- package/cjs/modules/Network/fetchProxy.d.ts +0 -1
- package/cjs/modules/Network/fetchProxy.js +3 -1
- package/cjs/modules/Network/index.js +5 -0
- package/cjs/modules/Network/networkMessage.d.ts +1 -1
- package/cjs/modules/Network/networkMessage.js +7 -4
- package/cjs/modules/Network/xhrProxy.d.ts +0 -9
- package/cjs/modules/Network/xhrProxy.js +0 -1
- package/cjs/modules/axiosSpy.js +1 -1
- package/cjs/modules/constructedStyleSheets.js +25 -21
- package/cjs/modules/featureFlags.js +0 -1
- package/cjs/modules/img.js +2 -2
- package/cjs/modules/network.js +5 -4
- package/cjs/utils.d.ts +16 -0
- package/cjs/utils.js +53 -1
- package/coverage/clover.xml +829 -1064
- package/coverage/coverage-final.json +17 -21
- package/coverage/lcov-report/index.html +40 -55
- package/coverage/lcov-report/main/app/guards.ts.html +1 -1
- package/coverage/lcov-report/main/app/index.html +23 -23
- package/coverage/lcov-report/main/app/index.ts.html +212 -29
- package/coverage/lcov-report/main/app/logger.ts.html +2 -2
- package/coverage/lcov-report/main/app/messages.gen.ts.html +144 -144
- package/coverage/lcov-report/main/app/nodes.ts.html +13 -7
- 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 +1 -1
- 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 +1 -1
- package/coverage/lcov-report/main/app/sanitizer.ts.html +12 -3
- package/coverage/lcov-report/main/app/session.ts.html +30 -9
- package/coverage/lcov-report/main/app/ticker.ts.html +1 -1
- package/coverage/lcov-report/main/index.html +21 -21
- package/coverage/lcov-report/main/index.ts.html +26 -26
- package/coverage/lcov-report/main/modules/Network/beaconProxy.ts.html +19 -19
- package/coverage/lcov-report/main/modules/Network/fetchProxy.ts.html +102 -96
- package/coverage/lcov-report/main/modules/Network/index.html +65 -65
- package/coverage/lcov-report/main/modules/Network/index.ts.html +33 -33
- package/coverage/lcov-report/main/modules/Network/networkMessage.ts.html +71 -71
- package/coverage/lcov-report/main/modules/Network/utils.ts.html +34 -34
- package/coverage/lcov-report/main/modules/Network/xhrProxy.ts.html +13 -13
- package/coverage/lcov-report/main/modules/attributeSender.ts.html +13 -4
- package/coverage/lcov-report/main/modules/axiosSpy.ts.html +1 -1
- 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 +42 -30
- 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 +23 -20
- package/coverage/lcov-report/main/modules/index.html +13 -13
- 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/timing.ts.html +42 -6
- package/coverage/lcov-report/main/modules/viewport.ts.html +1 -1
- package/coverage/lcov-report/main/utils.ts.html +255 -39
- package/coverage/lcov-report/webworker/BatchWriter.ts.html +1 -1
- package/coverage/lcov-report/webworker/MessageEncoder.gen.ts.html +1 -1
- package/coverage/lcov-report/webworker/PrimitiveEncoder.ts.html +1 -1
- package/coverage/lcov-report/webworker/QueueSender.ts.html +1 -1
- package/coverage/lcov-report/webworker/index.html +1 -1
- package/coverage/lcov-report/webworker/index.ts.html +1 -1
- package/coverage/lcov.info +1376 -1729
- package/lib/app/index.js +15 -12
- package/lib/app/logger.d.ts +1 -1
- package/lib/app/messages.gen.d.ts +2 -1
- package/lib/app/messages.gen.js +16 -2
- package/lib/app/nodes.js +4 -3
- package/lib/app/observer/observer.js +2 -1
- package/lib/common/messages.gen.d.ts +17 -4
- package/lib/common/tsconfig.tsbuildinfo +1 -1
- package/lib/index.js +1 -1
- package/lib/modules/Network/beaconProxy.d.ts +16 -0
- package/lib/modules/Network/beaconProxy.js +77 -0
- package/lib/modules/Network/fetchProxy.d.ts +0 -1
- package/lib/modules/Network/fetchProxy.js +3 -1
- package/lib/modules/Network/index.js +5 -0
- package/lib/modules/Network/networkMessage.d.ts +1 -1
- package/lib/modules/Network/networkMessage.js +7 -4
- package/lib/modules/Network/xhrProxy.d.ts +0 -9
- package/lib/modules/Network/xhrProxy.js +0 -1
- package/lib/modules/axiosSpy.js +1 -1
- package/lib/modules/constructedStyleSheets.js +25 -21
- package/lib/modules/featureFlags.js +0 -1
- package/lib/modules/img.js +3 -3
- package/lib/modules/network.js +5 -4
- package/lib/utils.d.ts +16 -0
- package/lib/utils.js +47 -0
- package/package.json +13 -13
- package/rollup.config.js +4 -4
|
@@ -113,6 +113,9 @@ export class FetchProxyHandler {
|
|
|
113
113
|
apply(target, _, argsList) {
|
|
114
114
|
const input = argsList[0];
|
|
115
115
|
const init = argsList[1];
|
|
116
|
+
// @ts-ignore
|
|
117
|
+
if (!(input === null || input === void 0 ? void 0 : input.url) && !input)
|
|
118
|
+
return target.apply(window, argsList);
|
|
116
119
|
const isORUrl = input instanceof URL || typeof input === 'string'
|
|
117
120
|
? this.isServiceUrl(String(input))
|
|
118
121
|
: this.isServiceUrl(String(input.url));
|
|
@@ -261,4 +264,3 @@ export default class FetchProxy {
|
|
|
261
264
|
return new Proxy(fetch, new FetchProxyHandler(ignoredHeaders, setSessionTokenHeader, sanitize, sendMessage, isServiceUrl, tokenUrlMatcher));
|
|
262
265
|
}
|
|
263
266
|
}
|
|
264
|
-
FetchProxy.origFetch = fetch;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import FetchProxy from './fetchProxy.js';
|
|
2
2
|
import XHRProxy from './xhrProxy.js';
|
|
3
|
+
import BeaconProxy from './beaconProxy.js';
|
|
3
4
|
const getWarning = (api) => console.warn(`Openreplay: Can't find ${api} in global context.
|
|
4
5
|
If you're using serverside rendering in your app, make sure that tracker is loaded dynamically, otherwise ${api} won't be tracked.`);
|
|
5
6
|
export default function setProxy(context, ignoredHeaders, setSessionTokenHeader, sanitize, sendMessage, isServiceUrl, tokenUrlMatcher) {
|
|
7
|
+
var _a;
|
|
6
8
|
if (context.XMLHttpRequest) {
|
|
7
9
|
context.XMLHttpRequest = XHRProxy.create(ignoredHeaders, setSessionTokenHeader, sanitize, sendMessage, isServiceUrl, tokenUrlMatcher);
|
|
8
10
|
}
|
|
@@ -15,4 +17,7 @@ export default function setProxy(context, ignoredHeaders, setSessionTokenHeader,
|
|
|
15
17
|
else {
|
|
16
18
|
getWarning('fetch');
|
|
17
19
|
}
|
|
20
|
+
if ((_a = context === null || context === void 0 ? void 0 : context.navigator) === null || _a === void 0 ? void 0 : _a.sendBeacon) {
|
|
21
|
+
context.navigator.sendBeacon = BeaconProxy.create(ignoredHeaders, setSessionTokenHeader, sanitize, sendMessage, isServiceUrl);
|
|
22
|
+
}
|
|
18
23
|
}
|
|
@@ -27,7 +27,7 @@ export default class NetworkMessage {
|
|
|
27
27
|
[key: string]: string;
|
|
28
28
|
};
|
|
29
29
|
responseType: XMLHttpRequest['responseType'];
|
|
30
|
-
requestType: 'xhr' | 'fetch' | 'ping' | 'custom';
|
|
30
|
+
requestType: 'xhr' | 'fetch' | 'ping' | 'custom' | 'beacon';
|
|
31
31
|
requestHeader: HeadersInit;
|
|
32
32
|
response: any;
|
|
33
33
|
responseSize: number;
|
|
@@ -50,7 +50,7 @@ export default class NetworkMessage {
|
|
|
50
50
|
request,
|
|
51
51
|
response,
|
|
52
52
|
});
|
|
53
|
-
return NetworkRequest(this.requestType, messageInfo.method, messageInfo.url, JSON.stringify(messageInfo.request), JSON.stringify(messageInfo.response), messageInfo.status, this.startTime + getTimeOrigin(), this.duration);
|
|
53
|
+
return NetworkRequest(this.requestType, messageInfo.method, messageInfo.url, JSON.stringify(messageInfo.request), JSON.stringify(messageInfo.response), messageInfo.status, this.startTime + getTimeOrigin(), this.duration, this.responseSize);
|
|
54
54
|
}
|
|
55
55
|
writeHeaders() {
|
|
56
56
|
const reqHs = {};
|
|
@@ -71,8 +71,11 @@ export default class NetworkMessage {
|
|
|
71
71
|
return { reqHs, resHs };
|
|
72
72
|
}
|
|
73
73
|
isHeaderIgnored(key) {
|
|
74
|
-
if (Array.isArray(this.ignoredHeaders))
|
|
75
|
-
return this.ignoredHeaders.includes(key);
|
|
76
|
-
|
|
74
|
+
if (Array.isArray(this.ignoredHeaders)) {
|
|
75
|
+
return this.ignoredHeaders.map((k) => k.toLowerCase()).includes(key.toLowerCase());
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
return this.ignoredHeaders;
|
|
79
|
+
}
|
|
77
80
|
}
|
|
78
81
|
}
|
|
@@ -35,14 +35,5 @@ export declare class XHRProxyHandler<T extends XMLHttpRequest> implements ProxyH
|
|
|
35
35
|
protected updateItemByReadyState(): void;
|
|
36
36
|
}
|
|
37
37
|
export default class XHRProxy {
|
|
38
|
-
static origXMLHttpRequest: {
|
|
39
|
-
new (): XMLHttpRequest;
|
|
40
|
-
prototype: XMLHttpRequest;
|
|
41
|
-
readonly DONE: number;
|
|
42
|
-
readonly HEADERS_RECEIVED: number;
|
|
43
|
-
readonly LOADING: number;
|
|
44
|
-
readonly OPENED: number;
|
|
45
|
-
readonly UNSENT: number;
|
|
46
|
-
};
|
|
47
38
|
static create(ignoredHeaders: boolean | string[], setSessionTokenHeader: (cb: (name: string, value: string) => void) => void, sanitize: (data: RequestResponseData) => RequestResponseData, sendMessage: (data: NetworkRequest) => void, isServiceUrl: (url: string) => boolean, tokenUrlMatcher?: (url: string) => boolean): any;
|
|
48
39
|
}
|
package/lib/modules/axiosSpy.js
CHANGED
|
@@ -65,7 +65,7 @@ export default function (app, instance, opts, sanitize, stringify) {
|
|
|
65
65
|
const requestStart = axiosResponseObj.config.__openreplay_timing;
|
|
66
66
|
const duration = performance.now() - requestStart;
|
|
67
67
|
app.debug.log('Openreplay: final req object', reqResInfo);
|
|
68
|
-
app.send(NetworkRequest('xhr', String(method), String(reqResInfo.url), stringify(reqResInfo.request), stringify(reqResInfo.response), reqResInfo.status, requestStart + getTimeOrigin(), duration));
|
|
68
|
+
app.send(NetworkRequest('xhr', String(method), String(reqResInfo.url), stringify(reqResInfo.request), stringify(reqResInfo.response), reqResInfo.status, requestStart + getTimeOrigin(), duration, 0));
|
|
69
69
|
}
|
|
70
70
|
function getStartTime(config) {
|
|
71
71
|
app.debug.log('Openreplay: capturing API request', config);
|
|
@@ -5,7 +5,7 @@ function hasAdoptedSS(node) {
|
|
|
5
5
|
// @ts-ignore
|
|
6
6
|
!!node.adoptedStyleSheets);
|
|
7
7
|
}
|
|
8
|
-
// TODO:
|
|
8
|
+
// TODO: encapsulate to be init-ed on-start and join with cssrules.ts under one folder
|
|
9
9
|
let _id = 0xf;
|
|
10
10
|
export function nextID() {
|
|
11
11
|
return _id++;
|
|
@@ -34,35 +34,39 @@ export default function (app) {
|
|
|
34
34
|
}
|
|
35
35
|
const nowOwning = [];
|
|
36
36
|
const styleSheets = root.adoptedStyleSheets;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (init) {
|
|
48
|
-
const rules = s.cssRules;
|
|
49
|
-
for (let i = 0; i < rules.length; i++) {
|
|
50
|
-
app.send(AdoptedSSInsertRuleURLBased(sheetID, rules[i].cssText, i, app.getBaseHref()));
|
|
37
|
+
if (Symbol.iterator in styleSheets) {
|
|
38
|
+
for (const s of styleSheets) {
|
|
39
|
+
let sheetID = styleSheetIDMap.get(s);
|
|
40
|
+
const init = !sheetID;
|
|
41
|
+
if (!sheetID) {
|
|
42
|
+
sheetID = nextID();
|
|
43
|
+
styleSheetIDMap.set(s, sheetID);
|
|
44
|
+
}
|
|
45
|
+
if (!pastOwning.includes(sheetID)) {
|
|
46
|
+
app.send(AdoptedSSAddOwner(sheetID, nodeID));
|
|
51
47
|
}
|
|
48
|
+
if (init) {
|
|
49
|
+
const rules = s.cssRules;
|
|
50
|
+
for (let i = 0; i < rules.length; i++) {
|
|
51
|
+
app.send(AdoptedSSInsertRuleURLBased(sheetID, rules[i].cssText, i, app.getBaseHref()));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
nowOwning.push(sheetID);
|
|
52
55
|
}
|
|
53
|
-
nowOwning.push(sheetID);
|
|
54
56
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
if (Symbol.iterator in pastOwning) {
|
|
58
|
+
for (const sheetID of pastOwning) {
|
|
59
|
+
if (!nowOwning.includes(sheetID)) {
|
|
60
|
+
app.send(AdoptedSSRemoveOwner(sheetID, nodeID));
|
|
61
|
+
}
|
|
58
62
|
}
|
|
59
63
|
}
|
|
60
64
|
adoptedStyleSheetsOwnings.set(nodeID, nowOwning);
|
|
61
|
-
}, 20); //
|
|
65
|
+
}, 20); // Mysterious bug:
|
|
62
66
|
/* On the page https://explore.fast.design/components/fast-accordion
|
|
63
67
|
the only rule inside the only adoptedStyleSheet of the iframe-s document
|
|
64
68
|
gets changed during first milliseconds after the load.
|
|
65
|
-
|
|
69
|
+
However, none of the documented methods (replace, insertRule) is triggered.
|
|
66
70
|
The rule is not substituted (remains the same object), however the text gets changed.
|
|
67
71
|
*/
|
|
68
72
|
function patchAdoptedStyleSheets(prototype) {
|
package/lib/modules/img.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isURL, IS_FIREFOX, MAX_STR_LEN } from '../utils.js';
|
|
1
|
+
import { isURL, IS_FIREFOX, MAX_STR_LEN, createMutationObserver } from '../utils.js';
|
|
2
2
|
import { ResourceTiming, SetNodeAttributeURLBased } from '../app/messages.gen.js';
|
|
3
3
|
import { hasTag } from '../app/guards.js';
|
|
4
4
|
function resolveURL(url, location = document.location) {
|
|
@@ -75,7 +75,7 @@ export default function (app) {
|
|
|
75
75
|
sendSrcset(id, img);
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
|
-
const observer =
|
|
78
|
+
const observer = createMutationObserver(app.safe((mutations) => {
|
|
79
79
|
for (const mutation of mutations) {
|
|
80
80
|
if (mutation.type === 'attributes') {
|
|
81
81
|
const target = mutation.target;
|
|
@@ -91,7 +91,7 @@ export default function (app) {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
});
|
|
94
|
+
}));
|
|
95
95
|
app.attachStopCallback(() => {
|
|
96
96
|
observer.disconnect();
|
|
97
97
|
});
|
package/lib/modules/network.js
CHANGED
|
@@ -17,12 +17,12 @@ function strMethod(method) {
|
|
|
17
17
|
export default function (app, opts = {}) {
|
|
18
18
|
const options = Object.assign({
|
|
19
19
|
failuresOnly: false,
|
|
20
|
-
ignoreHeaders: ['
|
|
20
|
+
ignoreHeaders: ['cookie', 'set-cookie', 'authorization'],
|
|
21
21
|
capturePayload: false,
|
|
22
22
|
sessionTokenHeader: false,
|
|
23
23
|
captureInIframes: true,
|
|
24
24
|
axiosInstances: undefined,
|
|
25
|
-
useProxy:
|
|
25
|
+
useProxy: true,
|
|
26
26
|
}, opts);
|
|
27
27
|
if (options.useProxy === false) {
|
|
28
28
|
app.debug.warn('Network module is migrating to proxy api, to gradually migrate and test it set useProxy to true');
|
|
@@ -147,12 +147,13 @@ export default function (app, opts = {}) {
|
|
|
147
147
|
if (!reqResInfo) {
|
|
148
148
|
return;
|
|
149
149
|
}
|
|
150
|
-
app.send(NetworkRequest('fetch', method, String(reqResInfo.url), stringify(reqResInfo.request), stringify(reqResInfo.response), r.status, startTime + getTimeOrigin(), duration));
|
|
150
|
+
app.send(NetworkRequest('fetch', method, String(reqResInfo.url), stringify(reqResInfo.request), stringify(reqResInfo.response), r.status, startTime + getTimeOrigin(), duration, 0));
|
|
151
151
|
})
|
|
152
152
|
.catch((e) => app.debug.error('Could not process Fetch response:', e));
|
|
153
153
|
return response;
|
|
154
154
|
});
|
|
155
155
|
};
|
|
156
|
+
// @ts-ignore
|
|
156
157
|
context.fetch = trackFetch;
|
|
157
158
|
/* ====== <> ====== */
|
|
158
159
|
/* ====== XHR ====== */
|
|
@@ -197,7 +198,7 @@ export default function (app, opts = {}) {
|
|
|
197
198
|
if (!reqResInfo) {
|
|
198
199
|
return;
|
|
199
200
|
}
|
|
200
|
-
app.send(NetworkRequest('xhr', method, String(reqResInfo.url), stringify(reqResInfo.request), stringify(reqResInfo.response), xhr.status, startTime + getTimeOrigin(), duration));
|
|
201
|
+
app.send(NetworkRequest('xhr', method, String(reqResInfo.url), stringify(reqResInfo.request), stringify(reqResInfo.response), xhr.status, startTime + getTimeOrigin(), duration, 0));
|
|
201
202
|
}));
|
|
202
203
|
//TODO: handle error (though it has no Error API nor any useful information)
|
|
203
204
|
//xhr.addEventListener('error', (e) => {})
|
package/lib/utils.d.ts
CHANGED
|
@@ -17,3 +17,19 @@ export declare function hasOpenreplayAttribute(e: Element, attr: string): boolea
|
|
|
17
17
|
export declare function canAccessIframe(iframe: HTMLIFrameElement): boolean;
|
|
18
18
|
export declare function generateRandomId(len?: number): string;
|
|
19
19
|
export declare function inIframe(): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Because angular devs decided that its a good idea to override a browser apis
|
|
22
|
+
* we need to use this to achieve safe behavior
|
|
23
|
+
* */
|
|
24
|
+
export declare function ngSafeBrowserMethod(method: string): string;
|
|
25
|
+
export declare function createMutationObserver(cb: MutationCallback): MutationObserver;
|
|
26
|
+
export declare function createEventListener(target: EventTarget, event: string, cb: EventListenerOrEventListenerObject, capture?: boolean): void;
|
|
27
|
+
export declare function deleteEventListener(target: EventTarget, event: string, cb: EventListenerOrEventListenerObject, capture?: boolean): void;
|
|
28
|
+
/**
|
|
29
|
+
* This is a brief polyfill that suits our needs
|
|
30
|
+
* I took inspiration from Microsoft Clarity polyfill on this one
|
|
31
|
+
* then adapted it a little bit
|
|
32
|
+
*
|
|
33
|
+
* I'm very grateful for their bright idea
|
|
34
|
+
* */
|
|
35
|
+
export declare function requestIdleCb(callback: () => void): number | undefined;
|
package/lib/utils.js
CHANGED
|
@@ -89,3 +89,50 @@ export function inIframe() {
|
|
|
89
89
|
return true;
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Because angular devs decided that its a good idea to override a browser apis
|
|
94
|
+
* we need to use this to achieve safe behavior
|
|
95
|
+
* */
|
|
96
|
+
export function ngSafeBrowserMethod(method) {
|
|
97
|
+
// @ts-ignore
|
|
98
|
+
return window.Zone && '__symbol__' in window.Zone
|
|
99
|
+
? // @ts-ignore
|
|
100
|
+
window['Zone']['__symbol__'](method)
|
|
101
|
+
: method;
|
|
102
|
+
}
|
|
103
|
+
export function createMutationObserver(cb) {
|
|
104
|
+
const mObserver = ngSafeBrowserMethod('MutationObserver');
|
|
105
|
+
return new window[mObserver](cb);
|
|
106
|
+
}
|
|
107
|
+
export function createEventListener(target, event, cb, capture) {
|
|
108
|
+
const safeAddEventListener = ngSafeBrowserMethod('addEventListener');
|
|
109
|
+
target[safeAddEventListener](event, cb, capture);
|
|
110
|
+
}
|
|
111
|
+
export function deleteEventListener(target, event, cb, capture) {
|
|
112
|
+
const safeRemoveEventListener = ngSafeBrowserMethod('removeEventListener');
|
|
113
|
+
target[safeRemoveEventListener](event, cb, capture);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* This is a brief polyfill that suits our needs
|
|
117
|
+
* I took inspiration from Microsoft Clarity polyfill on this one
|
|
118
|
+
* then adapted it a little bit
|
|
119
|
+
*
|
|
120
|
+
* I'm very grateful for their bright idea
|
|
121
|
+
* */
|
|
122
|
+
export function requestIdleCb(callback) {
|
|
123
|
+
const taskTimeout = 3000;
|
|
124
|
+
if (window.requestIdleCallback) {
|
|
125
|
+
return window.requestIdleCallback(callback, { timeout: taskTimeout });
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
const channel = new MessageChannel();
|
|
129
|
+
const incoming = channel.port1;
|
|
130
|
+
const outgoing = channel.port2;
|
|
131
|
+
incoming.onmessage = () => {
|
|
132
|
+
callback();
|
|
133
|
+
};
|
|
134
|
+
requestAnimationFrame(() => {
|
|
135
|
+
outgoing.postMessage(1);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openreplay/tracker",
|
|
3
3
|
"description": "The OpenReplay tracker main package",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "10.0.2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"logging",
|
|
7
7
|
"replay"
|
|
@@ -19,40 +19,40 @@
|
|
|
19
19
|
"tscRun": "tsc -b src/main && tsc -b src/webworker && tsc --project src/main/tsconfig-cjs.json",
|
|
20
20
|
"rollup": "rollup --config rollup.config.js",
|
|
21
21
|
"compile": "node --experimental-modules --experimental-json-modules scripts/compile.cjs",
|
|
22
|
-
"build": "
|
|
22
|
+
"build": "bun run clean && bun run tscRun && bun run rollup && bun run compile",
|
|
23
23
|
"prepare": "cd ../../ && husky install tracker/.husky/",
|
|
24
24
|
"lint-front": "lint-staged",
|
|
25
25
|
"test": "jest --coverage=false",
|
|
26
26
|
"test:ci": "jest --coverage=true",
|
|
27
|
-
"postversion": "
|
|
28
|
-
"prepublishOnly": "
|
|
27
|
+
"postversion": "bun run build",
|
|
28
|
+
"prepublishOnly": "bun run build"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@babel/core": "^7.10.2",
|
|
32
32
|
"@jest/globals": "^29.3.1",
|
|
33
|
-
"@rollup/plugin-babel": "^
|
|
34
|
-
"@rollup/plugin-node-resolve": "^
|
|
33
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
34
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
35
35
|
"@typescript-eslint/eslint-plugin": "^5.30.0",
|
|
36
36
|
"@typescript-eslint/parser": "^5.30.0",
|
|
37
37
|
"eslint": "^7.8.0",
|
|
38
|
-
"eslint-config-prettier": "^
|
|
39
|
-
"eslint-plugin-prettier": "^
|
|
38
|
+
"eslint-config-prettier": "^9.0.0",
|
|
39
|
+
"eslint-plugin-prettier": "^5.0.1",
|
|
40
40
|
"husky": "^8.0.1",
|
|
41
41
|
"jest": "^29.3.1",
|
|
42
42
|
"jest-environment-jsdom": "^29.3.1",
|
|
43
43
|
"lint-staged": "^13.0.3",
|
|
44
|
-
"prettier": "^
|
|
44
|
+
"prettier": "^3.0.3",
|
|
45
45
|
"replace-in-files": "^2.0.3",
|
|
46
|
-
"rollup": "^
|
|
47
|
-
"rollup-plugin-terser": "^
|
|
46
|
+
"rollup": "^4.1.4",
|
|
47
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
48
48
|
"semver": "^6.3.0",
|
|
49
49
|
"ts-jest": "^29.0.3",
|
|
50
50
|
"typescript": "^4.9.4"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@medv/finder": "^3.
|
|
53
|
+
"@medv/finder": "^3.1.0",
|
|
54
54
|
"error-stack-parser": "^2.0.6",
|
|
55
|
-
"fflate": "^0.
|
|
55
|
+
"fflate": "^0.8.1"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|
|
58
58
|
"node": ">=14.0"
|
package/rollup.config.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import resolve from '@rollup/plugin-node-resolve'
|
|
2
|
-
import babel from '@rollup/plugin-babel'
|
|
3
|
-
import { terser } from 'rollup-plugin-terser'
|
|
1
|
+
import resolve from '@rollup/plugin-node-resolve'
|
|
2
|
+
import { babel } from '@rollup/plugin-babel'
|
|
3
|
+
import { terser } from 'rollup-plugin-terser'
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
6
|
input: 'build/webworker/index.js',
|
|
@@ -9,4 +9,4 @@ export default {
|
|
|
9
9
|
format: 'cjs',
|
|
10
10
|
},
|
|
11
11
|
plugins: [resolve(), babel({ babelHelpers: 'bundled' }), terser({ mangle: { reserved: ['$'] } })],
|
|
12
|
-
}
|
|
12
|
+
}
|