@openreplay/tracker 4.1.5 → 4.1.6
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/guards.d.ts +1 -0
- package/cjs/app/index.d.ts +2 -0
- package/cjs/app/index.js +34 -26
- package/cjs/app/messages.d.ts +1 -1
- package/cjs/app/messages.gen.d.ts +4 -1
- package/cjs/app/messages.gen.js +32 -5
- package/cjs/app/messages.js +2 -2
- package/cjs/app/nodes.d.ts +1 -1
- package/cjs/app/nodes.js +4 -4
- package/cjs/app/observer/top_observer.js +2 -0
- package/cjs/common/interaction.d.ts +6 -1
- package/cjs/common/messages.gen.d.ts +26 -5
- package/cjs/index.d.ts +3 -3
- package/cjs/index.js +11 -6
- package/cjs/modules/constructedStyleSheets.js +1 -5
- package/cjs/modules/cssrules.js +1 -1
- package/cjs/modules/exception.d.ts +2 -2
- package/cjs/modules/exception.js +7 -7
- package/cjs/modules/focus.d.ts +2 -0
- package/cjs/modules/focus.js +45 -0
- package/cjs/modules/fonts.d.ts +2 -0
- package/cjs/modules/fonts.js +57 -0
- package/cjs/modules/img.js +1 -1
- package/cjs/utils.d.ts +1 -1
- package/cjs/utils.js +2 -2
- package/lib/app/guards.d.ts +1 -0
- package/lib/app/index.d.ts +2 -0
- package/lib/app/index.js +34 -26
- package/lib/app/messages.d.ts +1 -1
- package/lib/app/messages.gen.d.ts +4 -1
- package/lib/app/messages.gen.js +26 -2
- package/lib/app/messages.js +2 -2
- package/lib/app/nodes.d.ts +1 -1
- package/lib/app/nodes.js +4 -4
- package/lib/app/observer/top_observer.js +2 -0
- package/lib/common/interaction.d.ts +6 -1
- package/lib/common/messages.gen.d.ts +26 -5
- package/lib/common/tsconfig.tsbuildinfo +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.js +11 -6
- package/lib/modules/constructedStyleSheets.js +2 -6
- package/lib/modules/cssrules.js +1 -1
- package/lib/modules/exception.d.ts +2 -2
- package/lib/modules/exception.js +7 -7
- package/lib/modules/focus.d.ts +2 -0
- package/lib/modules/focus.js +42 -0
- package/lib/modules/fonts.d.ts +2 -0
- package/lib/modules/fonts.js +54 -0
- package/lib/modules/img.js +2 -2
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js +1 -1
- package/package.json +1 -1
package/cjs/app/guards.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare function isDocument(node: Node): node is Document;
|
|
|
6
6
|
export declare function isRootNode(node: Node): node is Document | DocumentFragment;
|
|
7
7
|
declare type TagTypeMap = {
|
|
8
8
|
HTML: HTMLHtmlElement;
|
|
9
|
+
BODY: HTMLBodyElement;
|
|
9
10
|
IMG: HTMLImageElement;
|
|
10
11
|
INPUT: HTMLInputElement;
|
|
11
12
|
TEXTAREA: HTMLTextAreaElement;
|
package/cjs/app/index.d.ts
CHANGED
|
@@ -77,6 +77,8 @@ export default class App {
|
|
|
77
77
|
private _debug;
|
|
78
78
|
send(message: Message, urgent?: boolean): void;
|
|
79
79
|
private commit;
|
|
80
|
+
private delay;
|
|
81
|
+
timestamp(): number;
|
|
80
82
|
safe<T extends (this: any, ...args: any[]) => void>(fn: T): T;
|
|
81
83
|
attachCommitCallback(cb: CommitCallback): void;
|
|
82
84
|
attachStartCallback(cb: StartCallback, useSafe?: boolean): void;
|
package/cjs/app/index.js
CHANGED
|
@@ -27,12 +27,14 @@ class App {
|
|
|
27
27
|
// if (options.onStart !== undefined) {
|
|
28
28
|
// deprecationWarn("'onStart' option", "tracker.start().then(/* handle session info */)")
|
|
29
29
|
// } ?? maybe onStart is good
|
|
30
|
+
var _a, _b;
|
|
30
31
|
this.messages = [];
|
|
31
32
|
this.startCallbacks = [];
|
|
32
33
|
this.stopCallbacks = [];
|
|
33
34
|
this.commitCallbacks = [];
|
|
34
35
|
this.activityState = ActivityState.NotActive;
|
|
35
|
-
this.version = '4.1.
|
|
36
|
+
this.version = '4.1.6'; // TODO: version compatability check inside each plugin.
|
|
37
|
+
this.delay = 0;
|
|
36
38
|
this.projectKey = projectKey;
|
|
37
39
|
this.options = Object.assign({
|
|
38
40
|
revID: '',
|
|
@@ -46,10 +48,12 @@ class App {
|
|
|
46
48
|
verbose: false,
|
|
47
49
|
__is_snippet: false,
|
|
48
50
|
__debug_report_edp: null,
|
|
49
|
-
localStorage:
|
|
50
|
-
sessionStorage:
|
|
51
|
+
localStorage: null,
|
|
52
|
+
sessionStorage: null,
|
|
51
53
|
}, options);
|
|
52
54
|
this.revID = this.options.revID;
|
|
55
|
+
this.localStorage = (_a = this.options.localStorage) !== null && _a !== void 0 ? _a : window.localStorage;
|
|
56
|
+
this.sessionStorage = (_b = this.options.sessionStorage) !== null && _b !== void 0 ? _b : window.sessionStorage;
|
|
53
57
|
this.sanitizer = new sanitizer_js_1.default(this, options);
|
|
54
58
|
this.nodes = new nodes_js_1.default(this.options.node_id);
|
|
55
59
|
this.observer = new top_observer_js_1.default(this, options);
|
|
@@ -57,8 +61,6 @@ class App {
|
|
|
57
61
|
this.ticker.attach(() => this.commit());
|
|
58
62
|
this.debug = new logger_js_1.default(this.options.__debug__);
|
|
59
63
|
this.notify = new logger_js_1.default(this.options.verbose ? logger_js_1.LogLevel.Warnings : logger_js_1.LogLevel.Silent);
|
|
60
|
-
this.localStorage = this.options.localStorage || window.localStorage;
|
|
61
|
-
this.sessionStorage = this.options.sessionStorage || window.sessionStorage;
|
|
62
64
|
this.session = new session_js_1.default(this, this.options);
|
|
63
65
|
this.session.attachUpdateCallback(({ userID, metadata }) => {
|
|
64
66
|
if (userID != null) {
|
|
@@ -74,18 +76,18 @@ class App {
|
|
|
74
76
|
this.session.applySessionHash(sessionToken);
|
|
75
77
|
}
|
|
76
78
|
try {
|
|
77
|
-
this.worker = new Worker(URL.createObjectURL(new Blob(['"use strict";class t{constructor(t,i,s,e=10,n=1e3){this.onUnauthorised=i,this.onFailure=s,this.MAX_ATTEMPTS_COUNT=e,this.ATTEMPT_TIMEOUT=n,this.attemptsCount=0,this.busy=!1,this.queue=[],this.token=null,this.ingestURL=t+"/v1/web/i"}authorise(t){this.token=t}push(t){this.busy||!this.token?this.queue.push(t):this.sendBatch(t)}retry(t){this.attemptsCount>=this.MAX_ATTEMPTS_COUNT?this.onFailure():(this.attemptsCount++,setTimeout(()=>this.sendBatch(t),this.ATTEMPT_TIMEOUT*this.attemptsCount))}sendBatch(t){this.busy=!0,fetch(this.ingestURL,{body:t,method:"POST",headers:{Authorization:"Bearer "+this.token},keepalive:t.length<65536}).then(i=>{if(401===i.status)return this.busy=!1,void this.onUnauthorised();if(i.status>=400)return void this.retry(t);this.attemptsCount=0;const s=this.queue.shift();s?this.sendBatch(s):this.busy=!1}).catch(i=>{console.warn("OpenReplay:",i),this.retry(t)})}clean(){this.queue.length=0}}const i="function"==typeof TextEncoder?new TextEncoder:{encode(t){const i=t.length,s=new Uint8Array(3*i);let e=-1;for(let n=0,r=0,h=0;h!==i;){if(n=t.charCodeAt(h),h+=1,n>=55296&&n<=56319){if(h===i){s[e+=1]=239,s[e+=1]=191,s[e+=1]=189;break}if(r=t.charCodeAt(h),!(r>=56320&&r<=57343)){s[e+=1]=239,s[e+=1]=191,s[e+=1]=189;continue}if(n=1024*(n-55296)+r-56320+65536,h+=1,n>65535){s[e+=1]=240|n>>>18,s[e+=1]=128|n>>>12&63,s[e+=1]=128|n>>>6&63,s[e+=1]=128|63&n;continue}}n<=127?s[e+=1]=0|n:n<=2047?(s[e+=1]=192|n>>>6,s[e+=1]=128|63&n):(s[e+=1]=224|n>>>12,s[e+=1]=128|n>>>6&63,s[e+=1]=128|63&n)}return s.subarray(0,e+1)}};class s extends class{constructor(t){this.size=t,this.offset=0,this.checkpointOffset=0,this.data=new Uint8Array(t)}getCurrentOffset(){return this.offset}checkpoint(){this.checkpointOffset=this.offset}isEmpty(){return 0===this.offset}skip(t){return this.offset+=t,this.offset<=this.size}set(t,i){this.data.set(t,i)}boolean(t){return this.data[this.offset++]=+t,this.offset<=this.size}uint(t){for((t<0||t>Number.MAX_SAFE_INTEGER)&&(t=0);t>=128;)this.data[this.offset++]=t%256|128,t=Math.floor(t/128);return this.data[this.offset++]=t,this.offset<=this.size}int(t){return t=Math.round(t),this.uint(t>=0?2*t:-2*t-1)}string(t){const s=i.encode(t),e=s.byteLength;return!(!this.uint(e)||this.offset+e>this.size)&&(this.data.set(s,this.offset),this.offset+=e,!0)}reset(){this.offset=0,this.checkpointOffset=0}flush(){const t=this.data.slice(0,this.checkpointOffset);return this.reset(),t}}{encode(t){switch(t[0]){case 81:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.int(t[4])&&this.string(t[5]);case 82:return this.uint(t[1])&&this.uint(t[2]);case 0:return this.uint(t[1]);case 4:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3]);case 5:return this.uint(t[1])&&this.uint(t[2]);case 6:return this.int(t[1])&&this.int(t[2]);case 7:return!0;case 8:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.string(t[4])&&this.boolean(t[5]);case 9:case 10:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3]);case 11:return this.uint(t[1]);case 12:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3]);case 13:case 14:return this.uint(t[1])&&this.string(t[2]);case 16:return this.uint(t[1])&&this.int(t[2])&&this.int(t[3]);case 17:return this.uint(t[1])&&this.string(t[2]);case 18:return this.uint(t[1])&&this.string(t[2])&&this.int(t[3]);case 19:return this.uint(t[1])&&this.boolean(t[2]);case 20:return this.uint(t[1])&&this.uint(t[2]);case 22:return this.string(t[1])&&this.string(t[2]);case 23:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8])&&this.uint(t[9]);case 24:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3]);case 25:return this.string(t[1])&&this.string(t[2])&&this.string(t[3]);case 27:return this.string(t[1])&&this.string(t[2]);case 28:case 29:return this.string(t[1]);case 30:return this.string(t[1])&&this.string(t[2]);case 37:return this.uint(t[1])&&this.string(t[2])&&this.uint(t[3]);case 38:return this.uint(t[1])&&this.uint(t[2]);case 39:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.uint(t[7]);case 40:return this.string(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4]);case 41:return this.string(t[1])&&this.string(t[2]);case 42:return this.string(t[1]);case 44:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3]);case 45:case 46:return this.string(t[1])&&this.string(t[2]);case 47:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3]);case 48:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4]);case 49:return this.int(t[1])&&this.int(t[2])&&this.uint(t[3])&&this.uint(t[4]);case 53:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.string(t[7])&&this.string(t[8]);case 54:return this.uint(t[1])&&this.string(t[2]);case 55:return this.boolean(t[1]);case 59:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.string(t[5])&&this.string(t[6])&&this.string(t[7]);case 60:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4]);case 61:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3]);case 63:case 64:return this.string(t[1])&&this.string(t[2]);case 67:return this.uint(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.string(t[4]);case 69:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4]);case 70:return this.uint(t[1])&&this.uint(t[2]);case 71:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3]);case 73:return this.uint(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.string(t[4]);case 75:case 76:case 77:return this.uint(t[1])&&this.uint(t[2]);case 79:return this.string(t[1])&&this.string(t[2])}}}class e{constructor(t,i,e,n){this.pageNo=t,this.timestamp=i,this.url=e,this.onBatch=n,this.nextIndex=0,this.beaconSize=2e5,this.encoder=new s(this.beaconSize),this.sizeBuffer=new Uint8Array(3),this.isEmpty=!0,this.beaconSizeLimit=1e6,this.prepare()}writeType(t){return this.encoder.uint(t[0])}writeFields(t){return this.encoder.encode(t)}writeSizeAt(t,i){for(let i=0;i<3;i++)this.sizeBuffer[i]=t>>8*i;this.encoder.set(this.sizeBuffer,i)}prepare(){if(!this.encoder.isEmpty())return;const t=[81,1,this.pageNo,this.nextIndex,this.timestamp,this.url];this.writeType(t),this.writeFields(t),this.isEmpty=!0}writeWithSize(t){const i=this.encoder;if(!this.writeType(t)||!i.skip(3))return!1;const s=i.getCurrentOffset(),e=this.writeFields(t);if(e){const e=i.getCurrentOffset()-s;if(e>16777215)return console.warn("OpenReplay: max message size overflow."),!1;this.writeSizeAt(e,s-3),i.checkpoint(),this.isEmpty=this.isEmpty&&0===t[0],this.nextIndex++}return e}setBeaconSizeLimit(t){this.beaconSizeLimit=t}writeMessage(t){if(0===t[0]&&(this.timestamp=t[1]),4===t[0]&&(this.url=t[1]),!this.writeWithSize(t))for(this.finaliseBatch();!this.writeWithSize(t);){if(this.beaconSize===this.beaconSizeLimit)return console.warn("OpenReplay: beacon size overflow. Skipping large message.",t,this),this.encoder.reset(),void this.prepare();this.beaconSize=Math.min(2*this.beaconSize,this.beaconSizeLimit),this.encoder=new s(this.beaconSize),this.prepare()}}finaliseBatch(){this.isEmpty||(this.onBatch(this.encoder.flush()),this.prepare())}clean(){this.encoder.reset()}}var n;!function(t){t[t.NotActive=0]="NotActive",t[t.Starting=1]="Starting",t[t.Stopping=2]="Stopping",t[t.Active=3]="Active"}(n||(n={}));let r=null,h=null;function u(){h&&h.finaliseBatch()}function a(){n.Stopping,null!==
|
|
79
|
+
this.worker = new Worker(URL.createObjectURL(new Blob(['"use strict";class t{constructor(t,i,s,e=10,n=1e3){this.onUnauthorised=i,this.onFailure=s,this.MAX_ATTEMPTS_COUNT=e,this.ATTEMPT_TIMEOUT=n,this.attemptsCount=0,this.busy=!1,this.queue=[],this.token=null,this.ingestURL=t+"/v1/web/i"}authorise(t){this.token=t}push(t){this.busy||!this.token?this.queue.push(t):this.sendBatch(t)}retry(t){this.attemptsCount>=this.MAX_ATTEMPTS_COUNT?this.onFailure(`Failed to send batch after ${this.attemptsCount} attempts.`):(this.attemptsCount++,setTimeout(()=>this.sendBatch(t),this.ATTEMPT_TIMEOUT*this.attemptsCount))}sendBatch(t){this.busy=!0,fetch(this.ingestURL,{body:t,method:"POST",headers:{Authorization:"Bearer "+this.token},keepalive:t.length<65536}).then(i=>{if(401===i.status)return this.busy=!1,void this.onUnauthorised();if(i.status>=400)return void this.retry(t);this.attemptsCount=0;const s=this.queue.shift();s?this.sendBatch(s):this.busy=!1}).catch(i=>{console.warn("OpenReplay:",i),this.retry(t)})}clean(){this.queue.length=0}}const i="function"==typeof TextEncoder?new TextEncoder:{encode(t){const i=t.length,s=new Uint8Array(3*i);let e=-1;for(let n=0,r=0,h=0;h!==i;){if(n=t.charCodeAt(h),h+=1,n>=55296&&n<=56319){if(h===i){s[e+=1]=239,s[e+=1]=191,s[e+=1]=189;break}if(r=t.charCodeAt(h),!(r>=56320&&r<=57343)){s[e+=1]=239,s[e+=1]=191,s[e+=1]=189;continue}if(n=1024*(n-55296)+r-56320+65536,h+=1,n>65535){s[e+=1]=240|n>>>18,s[e+=1]=128|n>>>12&63,s[e+=1]=128|n>>>6&63,s[e+=1]=128|63&n;continue}}n<=127?s[e+=1]=0|n:n<=2047?(s[e+=1]=192|n>>>6,s[e+=1]=128|63&n):(s[e+=1]=224|n>>>12,s[e+=1]=128|n>>>6&63,s[e+=1]=128|63&n)}return s.subarray(0,e+1)}};class s extends class{constructor(t){this.size=t,this.offset=0,this.checkpointOffset=0,this.data=new Uint8Array(t)}getCurrentOffset(){return this.offset}checkpoint(){this.checkpointOffset=this.offset}isEmpty(){return 0===this.offset}skip(t){return this.offset+=t,this.offset<=this.size}set(t,i){this.data.set(t,i)}boolean(t){return this.data[this.offset++]=+t,this.offset<=this.size}uint(t){for((t<0||t>Number.MAX_SAFE_INTEGER)&&(t=0);t>=128;)this.data[this.offset++]=t%256|128,t=Math.floor(t/128);return this.data[this.offset++]=t,this.offset<=this.size}int(t){return t=Math.round(t),this.uint(t>=0?2*t:-2*t-1)}string(t){const s=i.encode(t),e=s.byteLength;return!(!this.uint(e)||this.offset+e>this.size)&&(this.data.set(s,this.offset),this.offset+=e,!0)}reset(){this.offset=0,this.checkpointOffset=0}flush(){const t=this.data.slice(0,this.checkpointOffset);return this.reset(),t}}{encode(t){switch(t[0]){case 81:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.int(t[4])&&this.string(t[5]);case 82:return this.uint(t[1])&&this.uint(t[2]);case 0:return this.uint(t[1]);case 4:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3]);case 5:return this.uint(t[1])&&this.uint(t[2]);case 6:return this.int(t[1])&&this.int(t[2]);case 7:return!0;case 8:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.string(t[4])&&this.boolean(t[5]);case 9:case 10:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3]);case 11:return this.uint(t[1]);case 12:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3]);case 13:case 14:return this.uint(t[1])&&this.string(t[2]);case 16:return this.uint(t[1])&&this.int(t[2])&&this.int(t[3]);case 17:return this.uint(t[1])&&this.string(t[2]);case 18:return this.uint(t[1])&&this.string(t[2])&&this.int(t[3]);case 19:return this.uint(t[1])&&this.boolean(t[2]);case 20:return this.uint(t[1])&&this.uint(t[2]);case 22:return this.string(t[1])&&this.string(t[2]);case 23:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8])&&this.uint(t[9]);case 24:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3]);case 25:return this.string(t[1])&&this.string(t[2])&&this.string(t[3]);case 27:return this.string(t[1])&&this.string(t[2]);case 28:case 29:return this.string(t[1]);case 30:return this.string(t[1])&&this.string(t[2]);case 37:return this.uint(t[1])&&this.string(t[2])&&this.uint(t[3]);case 38:return this.uint(t[1])&&this.uint(t[2]);case 39:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.uint(t[7]);case 40:return this.string(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4]);case 41:return this.string(t[1])&&this.string(t[2]);case 42:return this.string(t[1]);case 44:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3]);case 45:case 46:return this.string(t[1])&&this.string(t[2]);case 47:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3]);case 48:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4]);case 49:return this.int(t[1])&&this.int(t[2])&&this.uint(t[3])&&this.uint(t[4]);case 53:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.string(t[7])&&this.string(t[8]);case 54:return this.uint(t[1])&&this.string(t[2]);case 55:return this.boolean(t[1]);case 57:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4]);case 58:return this.int(t[1]);case 59:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.string(t[5])&&this.string(t[6])&&this.string(t[7]);case 60:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4]);case 61:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3]);case 63:case 64:return this.string(t[1])&&this.string(t[2]);case 67:return this.uint(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.string(t[4]);case 69:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4]);case 70:return this.uint(t[1])&&this.uint(t[2]);case 71:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3]);case 73:return this.uint(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.string(t[4]);case 75:case 76:case 77:return this.uint(t[1])&&this.uint(t[2]);case 79:return this.string(t[1])&&this.string(t[2]);case 78:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])}}}class e{constructor(t,i,e,n){this.pageNo=t,this.timestamp=i,this.url=e,this.onBatch=n,this.nextIndex=0,this.beaconSize=2e5,this.encoder=new s(this.beaconSize),this.sizeBuffer=new Uint8Array(3),this.isEmpty=!0,this.beaconSizeLimit=1e6,this.prepare()}writeType(t){return this.encoder.uint(t[0])}writeFields(t){return this.encoder.encode(t)}writeSizeAt(t,i){for(let i=0;i<3;i++)this.sizeBuffer[i]=t>>8*i;this.encoder.set(this.sizeBuffer,i)}prepare(){if(!this.encoder.isEmpty())return;const t=[81,1,this.pageNo,this.nextIndex,this.timestamp,this.url];this.writeType(t),this.writeFields(t),this.isEmpty=!0}writeWithSize(t){const i=this.encoder;if(!this.writeType(t)||!i.skip(3))return!1;const s=i.getCurrentOffset(),e=this.writeFields(t);if(e){const e=i.getCurrentOffset()-s;if(e>16777215)return console.warn("OpenReplay: max message size overflow."),!1;this.writeSizeAt(e,s-3),i.checkpoint(),this.isEmpty=this.isEmpty&&0===t[0],this.nextIndex++}return e}setBeaconSizeLimit(t){this.beaconSizeLimit=t}writeMessage(t){if(0===t[0]&&(this.timestamp=t[1]),4===t[0]&&(this.url=t[1]),!this.writeWithSize(t))for(this.finaliseBatch();!this.writeWithSize(t);){if(this.beaconSize===this.beaconSizeLimit)return console.warn("OpenReplay: beacon size overflow. Skipping large message.",t,this),this.encoder.reset(),void this.prepare();this.beaconSize=Math.min(2*this.beaconSize,this.beaconSizeLimit),this.encoder=new s(this.beaconSize),this.prepare()}}finaliseBatch(){this.isEmpty||(this.onBatch(this.encoder.flush()),this.prepare())}clean(){this.encoder.reset()}}var n;!function(t){t[t.NotActive=0]="NotActive",t[t.Starting=1]="Starting",t[t.Stopping=2]="Stopping",t[t.Active=3]="Active"}(n||(n={}));let r=null,h=null;function u(){h&&h.finaliseBatch()}function a(){n.Stopping,null!==g&&(clearInterval(g),g=null),h&&(h.clean(),h=null),r&&(r.clean(),r=null),n.NotActive}function o(){postMessage("restart"),a()}n.NotActive;let c,g=null;self.onmessage=({data:i})=>{if(null!=i){if("stop"===i)return u(),void a();if(Array.isArray(i)){if(!h)throw new Error("WebWorker: writer not initialised. Service Should be Started.");const t=h;i.forEach(i=>{55===i[0]&&(i[1]?c=setTimeout(()=>o(),18e5):clearTimeout(c)),t.writeMessage(i)})}else{if("start"===i.type)return n.Starting,r=new t(i.ingestPoint,()=>{o()},t=>{!function(t){postMessage({type:"failure",reason:t}),a()}(t)},i.connAttemptCount,i.connAttemptGap),h=new e(i.pageNo,i.timestamp,i.url,t=>r&&r.push(t)),null===g&&(g=setInterval(u,1e4)),n.Active;if("auth"===i.type){if(!r)throw new Error("WebWorker: sender not initialised. Received auth.");if(!h)throw new Error("WebWorker: writer not initialised. Received auth.");return r.authorise(i.token),void(i.beaconSizeLimit&&h.setBeaconSizeLimit(i.beaconSizeLimit))}}}else u()};'], { type: 'text/javascript' })));
|
|
78
80
|
this.worker.onerror = (e) => {
|
|
79
81
|
this._debug('webworker_error', e);
|
|
80
82
|
};
|
|
81
83
|
this.worker.onmessage = ({ data }) => {
|
|
82
|
-
if (data === '
|
|
84
|
+
if (data === 'restart') {
|
|
83
85
|
this.stop(false);
|
|
84
|
-
this.
|
|
86
|
+
this.start({ forceNew: true }); // TODO: keep userID & metadata (draw scenarios)
|
|
85
87
|
}
|
|
86
|
-
else if (data === '
|
|
88
|
+
else if (data.type === 'failure') {
|
|
87
89
|
this.stop(false);
|
|
88
|
-
this.
|
|
90
|
+
this._debug('worker_failed', data.reason);
|
|
89
91
|
}
|
|
90
92
|
};
|
|
91
93
|
const alertWorker = () => {
|
|
@@ -105,7 +107,7 @@ class App {
|
|
|
105
107
|
}
|
|
106
108
|
_debug(context, e) {
|
|
107
109
|
if (this.options.__debug_report_edp !== null) {
|
|
108
|
-
fetch(this.options.__debug_report_edp, {
|
|
110
|
+
void fetch(this.options.__debug_report_edp, {
|
|
109
111
|
method: 'POST',
|
|
110
112
|
headers: { 'Content-Type': 'application/json' },
|
|
111
113
|
body: JSON.stringify({
|
|
@@ -118,25 +120,30 @@ class App {
|
|
|
118
120
|
}
|
|
119
121
|
send(message, urgent = false) {
|
|
120
122
|
if (this.activityState === ActivityState.NotActive) {
|
|
123
|
+
// this.debug.log('SendiTrying to send when not active', message) <- crashing the app
|
|
121
124
|
return;
|
|
122
125
|
}
|
|
123
126
|
this.messages.push(message);
|
|
124
127
|
// TODO: commit on start if there were `urgent` sends;
|
|
125
|
-
//
|
|
126
|
-
//
|
|
128
|
+
// Clarify where urgent can be used for;
|
|
129
|
+
// Clarify workflow for each type of message in case it was sent before start
|
|
127
130
|
// (like Fetch before start; maybe add an option "preCapture: boolean" or sth alike)
|
|
131
|
+
// Careful: `this.delay` is equal to zero before start hense all Timestamp-s will have to be updated on start
|
|
128
132
|
if (this.activityState === ActivityState.Active && urgent) {
|
|
129
133
|
this.commit();
|
|
130
134
|
}
|
|
131
135
|
}
|
|
132
136
|
commit() {
|
|
133
137
|
if (this.worker && this.messages.length) {
|
|
134
|
-
this.messages.unshift((0, messages_gen_js_1.Timestamp)(
|
|
138
|
+
this.messages.unshift((0, messages_gen_js_1.Timestamp)(this.timestamp()));
|
|
135
139
|
this.worker.postMessage(this.messages);
|
|
136
140
|
this.commitCallbacks.forEach((cb) => cb(this.messages));
|
|
137
141
|
this.messages.length = 0;
|
|
138
142
|
}
|
|
139
143
|
}
|
|
144
|
+
timestamp() {
|
|
145
|
+
return (0, utils_js_1.now)() + this.delay;
|
|
146
|
+
}
|
|
140
147
|
safe(fn) {
|
|
141
148
|
const app = this;
|
|
142
149
|
return function (...args) {
|
|
@@ -145,7 +152,7 @@ class App {
|
|
|
145
152
|
}
|
|
146
153
|
catch (e) {
|
|
147
154
|
app._debug('safe_fn_call', e);
|
|
148
|
-
// time:
|
|
155
|
+
// time: this.timestamp(),
|
|
149
156
|
// name: e.name,
|
|
150
157
|
// message: e.message,
|
|
151
158
|
// stack: e.stack
|
|
@@ -172,8 +179,8 @@ class App {
|
|
|
172
179
|
if (useSafe) {
|
|
173
180
|
listener = this.safe(listener);
|
|
174
181
|
}
|
|
175
|
-
this.attachStartCallback(() => target.addEventListener(type, listener, useCapture), useSafe);
|
|
176
|
-
this.attachStopCallback(() => target.removeEventListener(type, listener, useCapture), useSafe);
|
|
182
|
+
this.attachStartCallback(() => target === null || target === void 0 ? void 0 : target.addEventListener(type, listener, useCapture), useSafe);
|
|
183
|
+
this.attachStopCallback(() => target === null || target === void 0 ? void 0 : target.removeEventListener(type, listener, useCapture), useSafe);
|
|
177
184
|
}
|
|
178
185
|
// TODO: full correct semantic
|
|
179
186
|
checkRequiredVersion(version) {
|
|
@@ -273,8 +280,8 @@ class App {
|
|
|
273
280
|
if (startOpts.sessionHash) {
|
|
274
281
|
this.session.applySessionHash(startOpts.sessionHash);
|
|
275
282
|
}
|
|
276
|
-
const timestamp = (0, utils_js_1.
|
|
277
|
-
|
|
283
|
+
const timestamp = (0, utils_js_1.now)();
|
|
284
|
+
this.worker.postMessage({
|
|
278
285
|
type: 'start',
|
|
279
286
|
pageNo: this.session.incPageNo(),
|
|
280
287
|
ingestPoint: this.options.ingestPoint,
|
|
@@ -282,8 +289,7 @@ class App {
|
|
|
282
289
|
url: document.URL,
|
|
283
290
|
connAttemptCount: this.options.connAttemptCount,
|
|
284
291
|
connAttemptGap: this.options.connAttemptGap,
|
|
285
|
-
};
|
|
286
|
-
this.worker.postMessage(startWorkerMsg);
|
|
292
|
+
});
|
|
287
293
|
this.session.update({
|
|
288
294
|
// TODO: transparent "session" module logic AND explicit internal api for plugins.
|
|
289
295
|
// "updating" with old metadata in order to trigger session's UpdateCallbacks.
|
|
@@ -323,14 +329,16 @@ class App {
|
|
|
323
329
|
return Promise.reject('Tracker stopped during authorisation');
|
|
324
330
|
}
|
|
325
331
|
const { token, userUUID, sessionID, projectID, beaconSizeLimit, startTimestamp, // real startTS, derived from sessionID
|
|
326
|
-
|
|
332
|
+
delay, } = r;
|
|
327
333
|
if (typeof token !== 'string' ||
|
|
328
334
|
typeof userUUID !== 'string' ||
|
|
329
335
|
//typeof startTimestamp !== 'number' ||
|
|
330
336
|
//typeof sessionID !== 'string' ||
|
|
337
|
+
typeof delay !== 'number' ||
|
|
331
338
|
(typeof beaconSizeLimit !== 'number' && typeof beaconSizeLimit !== 'undefined')) {
|
|
332
339
|
return Promise.reject(`Incorrect server response: ${JSON.stringify(r)}`);
|
|
333
340
|
}
|
|
341
|
+
this.delay = delay;
|
|
334
342
|
const prevSessionID = this.session.getInfo().sessionID;
|
|
335
343
|
if (prevSessionID && prevSessionID !== sessionID) {
|
|
336
344
|
this.session.reset();
|
|
@@ -338,14 +346,14 @@ class App {
|
|
|
338
346
|
this.session.setSessionToken(token);
|
|
339
347
|
this.session.update({ sessionID, timestamp: startTimestamp || timestamp, projectID }); // TODO: no no-explicit 'any'
|
|
340
348
|
this.localStorage.setItem(this.options.local_uuid_key, userUUID);
|
|
341
|
-
|
|
349
|
+
this.worker.postMessage({
|
|
342
350
|
type: 'auth',
|
|
343
351
|
token,
|
|
344
352
|
beaconSizeLimit,
|
|
345
|
-
};
|
|
346
|
-
this.worker.postMessage(startWorkerMsg);
|
|
353
|
+
});
|
|
347
354
|
const onStartInfo = { sessionToken: token, userUUID, sessionID };
|
|
348
|
-
|
|
355
|
+
// TODO: start as early as possible (before receiving the token)
|
|
356
|
+
this.startCallbacks.forEach((cb) => cb(onStartInfo)); // MBTODO: callbacks after DOM "mounted" (observed)
|
|
349
357
|
this.observer.observe();
|
|
350
358
|
this.ticker.start();
|
|
351
359
|
this.activityState = ActivityState.Active;
|
package/cjs/app/messages.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare function MouseMove(x: number, y: number): Messages.MouseMove;
|
|
|
22
22
|
export declare function ConsoleLog(level: string, value: string): Messages.ConsoleLog;
|
|
23
23
|
export declare function PageLoadTiming(requestStart: number, responseStart: number, responseEnd: number, domContentLoadedEventStart: number, domContentLoadedEventEnd: number, loadEventStart: number, loadEventEnd: number, firstPaint: number, firstContentfulPaint: number): Messages.PageLoadTiming;
|
|
24
24
|
export declare function PageRenderTiming(speedIndex: number, visuallyComplete: number, timeToInteractive: number): Messages.PageRenderTiming;
|
|
25
|
-
export declare function JSException(name: string, message: string, payload: string): Messages.JSException;
|
|
25
|
+
export declare function JSException(name: string, message: string, payload: string, metadata: string): Messages.JSException;
|
|
26
26
|
export declare function RawCustomEvent(name: string, payload: string): Messages.RawCustomEvent;
|
|
27
27
|
export declare function UserID(id: string): Messages.UserID;
|
|
28
28
|
export declare function UserAnonymousID(id: string): Messages.UserAnonymousID;
|
|
@@ -22,7 +22,7 @@ export declare function MouseMove(x: number, y: number): Messages.MouseMove;
|
|
|
22
22
|
export declare function ConsoleLog(level: string, value: string): Messages.ConsoleLog;
|
|
23
23
|
export declare function PageLoadTiming(requestStart: number, responseStart: number, responseEnd: number, domContentLoadedEventStart: number, domContentLoadedEventEnd: number, loadEventStart: number, loadEventEnd: number, firstPaint: number, firstContentfulPaint: number): Messages.PageLoadTiming;
|
|
24
24
|
export declare function PageRenderTiming(speedIndex: number, visuallyComplete: number, timeToInteractive: number): Messages.PageRenderTiming;
|
|
25
|
-
export declare function
|
|
25
|
+
export declare function JSExceptionDeprecated(name: string, message: string, payload: string): Messages.JSExceptionDeprecated;
|
|
26
26
|
export declare function RawCustomEvent(name: string, payload: string): Messages.RawCustomEvent;
|
|
27
27
|
export declare function UserID(id: string): Messages.UserID;
|
|
28
28
|
export declare function UserAnonymousID(id: string): Messages.UserAnonymousID;
|
|
@@ -42,6 +42,8 @@ export declare function PerformanceTrack(frames: number, ticks: number, totalJSH
|
|
|
42
42
|
export declare function ResourceTiming(timestamp: number, duration: number, ttfb: number, headerSize: number, encodedBodySize: number, decodedBodySize: number, url: string, initiator: string): Messages.ResourceTiming;
|
|
43
43
|
export declare function ConnectionInformation(downlink: number, type: string): Messages.ConnectionInformation;
|
|
44
44
|
export declare function SetPageVisibility(hidden: boolean): Messages.SetPageVisibility;
|
|
45
|
+
export declare function LoadFontFace(parentID: number, family: string, source: string, descriptors: string): Messages.LoadFontFace;
|
|
46
|
+
export declare function SetNodeFocus(id: number): Messages.SetNodeFocus;
|
|
45
47
|
export declare function LongTask(timestamp: number, duration: number, context: number, containerType: number, containerSrc: string, containerId: string, containerName: string): Messages.LongTask;
|
|
46
48
|
export declare function SetNodeAttributeURLBased(id: number, name: string, value: string, baseURL: string): Messages.SetNodeAttributeURLBased;
|
|
47
49
|
export declare function SetCSSDataURLBased(id: number, data: string, baseURL: string): Messages.SetCSSDataURLBased;
|
|
@@ -56,3 +58,4 @@ export declare function AdoptedSSDeleteRule(sheetID: number, index: number): Mes
|
|
|
56
58
|
export declare function AdoptedSSAddOwner(sheetID: number, id: number): Messages.AdoptedSSAddOwner;
|
|
57
59
|
export declare function AdoptedSSRemoveOwner(sheetID: number, id: number): Messages.AdoptedSSRemoveOwner;
|
|
58
60
|
export declare function Zustand(mutation: string, state: string): Messages.Zustand;
|
|
61
|
+
export declare function JSException(name: string, message: string, payload: string, metadata: string): Messages.JSException;
|
package/cjs/app/messages.gen.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// Auto-generated, do not edit
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.
|
|
6
|
-
exports.Zustand = exports.AdoptedSSRemoveOwner = exports.AdoptedSSAddOwner = exports.AdoptedSSDeleteRule = exports.AdoptedSSInsertRuleURLBased = exports.AdoptedSSReplaceURLBased = void 0;
|
|
5
|
+
exports.CSSInsertRuleURLBased = exports.CustomIssue = exports.TechnicalInfo = exports.SetCSSDataURLBased = exports.SetNodeAttributeURLBased = exports.LongTask = exports.SetNodeFocus = exports.LoadFontFace = exports.SetPageVisibility = exports.ConnectionInformation = exports.ResourceTiming = exports.PerformanceTrack = exports.GraphQL = exports.NgRx = exports.MobX = exports.Vuex = exports.Redux = exports.StateAction = exports.OTable = exports.Profiler = exports.Fetch = exports.CSSDeleteRule = exports.CSSInsertRule = exports.Metadata = exports.UserAnonymousID = exports.UserID = exports.RawCustomEvent = exports.JSExceptionDeprecated = exports.PageRenderTiming = exports.PageLoadTiming = exports.ConsoleLog = exports.MouseMove = exports.SetInputChecked = exports.SetInputValue = exports.SetInputTarget = exports.SetNodeScroll = exports.SetNodeData = exports.RemoveNodeAttribute = exports.SetNodeAttribute = exports.RemoveNode = exports.MoveNode = exports.CreateTextNode = exports.CreateElementNode = exports.CreateDocument = exports.SetViewportScroll = exports.SetViewportSize = exports.SetPageLocation = exports.Timestamp = exports.PartitionedMessage = exports.BatchMetadata = void 0;
|
|
6
|
+
exports.JSException = exports.Zustand = exports.AdoptedSSRemoveOwner = exports.AdoptedSSAddOwner = exports.AdoptedSSDeleteRule = exports.AdoptedSSInsertRuleURLBased = exports.AdoptedSSReplaceURLBased = exports.CreateIFrameDocument = exports.MouseClick = void 0;
|
|
7
7
|
function BatchMetadata(version, pageNo, firstIndex, timestamp, location) {
|
|
8
8
|
return [
|
|
9
9
|
81 /* BatchMetadata */,
|
|
@@ -196,15 +196,15 @@ function PageRenderTiming(speedIndex, visuallyComplete, timeToInteractive) {
|
|
|
196
196
|
];
|
|
197
197
|
}
|
|
198
198
|
exports.PageRenderTiming = PageRenderTiming;
|
|
199
|
-
function
|
|
199
|
+
function JSExceptionDeprecated(name, message, payload) {
|
|
200
200
|
return [
|
|
201
|
-
25 /*
|
|
201
|
+
25 /* JSExceptionDeprecated */,
|
|
202
202
|
name,
|
|
203
203
|
message,
|
|
204
204
|
payload,
|
|
205
205
|
];
|
|
206
206
|
}
|
|
207
|
-
exports.
|
|
207
|
+
exports.JSExceptionDeprecated = JSExceptionDeprecated;
|
|
208
208
|
function RawCustomEvent(name, payload) {
|
|
209
209
|
return [
|
|
210
210
|
27 /* RawCustomEvent */,
|
|
@@ -373,6 +373,23 @@ function SetPageVisibility(hidden) {
|
|
|
373
373
|
];
|
|
374
374
|
}
|
|
375
375
|
exports.SetPageVisibility = SetPageVisibility;
|
|
376
|
+
function LoadFontFace(parentID, family, source, descriptors) {
|
|
377
|
+
return [
|
|
378
|
+
57 /* LoadFontFace */,
|
|
379
|
+
parentID,
|
|
380
|
+
family,
|
|
381
|
+
source,
|
|
382
|
+
descriptors,
|
|
383
|
+
];
|
|
384
|
+
}
|
|
385
|
+
exports.LoadFontFace = LoadFontFace;
|
|
386
|
+
function SetNodeFocus(id) {
|
|
387
|
+
return [
|
|
388
|
+
58 /* SetNodeFocus */,
|
|
389
|
+
id,
|
|
390
|
+
];
|
|
391
|
+
}
|
|
392
|
+
exports.SetNodeFocus = SetNodeFocus;
|
|
376
393
|
function LongTask(timestamp, duration, context, containerType, containerSrc, containerId, containerName) {
|
|
377
394
|
return [
|
|
378
395
|
59 /* LongTask */,
|
|
@@ -500,3 +517,13 @@ function Zustand(mutation, state) {
|
|
|
500
517
|
];
|
|
501
518
|
}
|
|
502
519
|
exports.Zustand = Zustand;
|
|
520
|
+
function JSException(name, message, payload, metadata) {
|
|
521
|
+
return [
|
|
522
|
+
78 /* JSException */,
|
|
523
|
+
name,
|
|
524
|
+
message,
|
|
525
|
+
payload,
|
|
526
|
+
metadata,
|
|
527
|
+
];
|
|
528
|
+
}
|
|
529
|
+
exports.JSException = JSException;
|
package/cjs/app/messages.js
CHANGED
|
@@ -101,8 +101,8 @@ function PageRenderTiming(speedIndex, visuallyComplete, timeToInteractive) {
|
|
|
101
101
|
return [24 /* PageRenderTiming */, speedIndex, visuallyComplete, timeToInteractive];
|
|
102
102
|
}
|
|
103
103
|
exports.PageRenderTiming = PageRenderTiming;
|
|
104
|
-
function JSException(name, message, payload) {
|
|
105
|
-
return [
|
|
104
|
+
function JSException(name, message, payload, metadata) {
|
|
105
|
+
return [78 /* JSException */, name, message, payload, metadata];
|
|
106
106
|
}
|
|
107
107
|
exports.JSException = JSException;
|
|
108
108
|
function RawCustomEvent(name, payload) {
|
package/cjs/app/nodes.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export default class Nodes {
|
|
|
6
6
|
private readonly elementListeners;
|
|
7
7
|
constructor(node_id: string);
|
|
8
8
|
attachNodeCallback(nodeCallback: NodeCallback): void;
|
|
9
|
-
attachNodeListener(node: Node, type: string, listener: EventListener): void;
|
|
9
|
+
attachNodeListener(node: Node, type: string, listener: EventListener, useCapture?: boolean): void;
|
|
10
10
|
registerNode(node: Node): [/*id:*/ number, /*isNew:*/ boolean];
|
|
11
11
|
unregisterNode(node: Node): number | undefined;
|
|
12
12
|
cleanTree(): void;
|
package/cjs/app/nodes.js
CHANGED
|
@@ -11,18 +11,18 @@ class Nodes {
|
|
|
11
11
|
attachNodeCallback(nodeCallback) {
|
|
12
12
|
this.nodeCallbacks.push(nodeCallback);
|
|
13
13
|
}
|
|
14
|
-
attachNodeListener(node, type, listener) {
|
|
14
|
+
attachNodeListener(node, type, listener, useCapture = true) {
|
|
15
15
|
const id = this.getID(node);
|
|
16
16
|
if (id === undefined) {
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
-
node.addEventListener(type, listener);
|
|
19
|
+
node.addEventListener(type, listener, useCapture);
|
|
20
20
|
let listeners = this.elementListeners.get(id);
|
|
21
21
|
if (listeners === undefined) {
|
|
22
22
|
listeners = [];
|
|
23
23
|
this.elementListeners.set(id, listeners);
|
|
24
24
|
}
|
|
25
|
-
listeners.push([type, listener]);
|
|
25
|
+
listeners.push([type, listener, useCapture]);
|
|
26
26
|
}
|
|
27
27
|
registerNode(node) {
|
|
28
28
|
let id = node[this.node_id];
|
|
@@ -42,7 +42,7 @@ class Nodes {
|
|
|
42
42
|
const listeners = this.elementListeners.get(id);
|
|
43
43
|
if (listeners !== undefined) {
|
|
44
44
|
this.elementListeners.delete(id);
|
|
45
|
-
listeners.forEach((listener) => node.removeEventListener(listener[0], listener[1]));
|
|
45
|
+
listeners.forEach((listener) => node.removeEventListener(listener[0], listener[1], listener[2]));
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
return id;
|
|
@@ -96,6 +96,8 @@ class TopObserver extends observer_js_1.default {
|
|
|
96
96
|
// Alternatively - observe(#document) then bindNode(documentElement)
|
|
97
97
|
this.observeRoot(window.document, () => {
|
|
98
98
|
this.app.send((0, messages_gen_js_1.CreateDocument)());
|
|
99
|
+
// it has no node_id here
|
|
100
|
+
this.app.nodes.callNodeCallbacks(document, true);
|
|
99
101
|
}, window.document.documentElement);
|
|
100
102
|
}
|
|
101
103
|
disconnect() {
|
|
@@ -15,5 +15,10 @@ declare type Auth = {
|
|
|
15
15
|
token: string;
|
|
16
16
|
beaconSizeLimit?: number;
|
|
17
17
|
};
|
|
18
|
-
export declare type
|
|
18
|
+
export declare type ToWorkerData = null | 'stop' | Start | Auth | Array<Message>;
|
|
19
|
+
declare type Failure = {
|
|
20
|
+
type: 'failure';
|
|
21
|
+
reason: string;
|
|
22
|
+
};
|
|
23
|
+
export declare type FromWorkerData = 'restart' | Failure;
|
|
19
24
|
export {};
|
|
@@ -21,7 +21,7 @@ export declare const enum Type {
|
|
|
21
21
|
ConsoleLog = 22,
|
|
22
22
|
PageLoadTiming = 23,
|
|
23
23
|
PageRenderTiming = 24,
|
|
24
|
-
|
|
24
|
+
JSExceptionDeprecated = 25,
|
|
25
25
|
RawCustomEvent = 27,
|
|
26
26
|
UserID = 28,
|
|
27
27
|
UserAnonymousID = 29,
|
|
@@ -41,6 +41,8 @@ export declare const enum Type {
|
|
|
41
41
|
ResourceTiming = 53,
|
|
42
42
|
ConnectionInformation = 54,
|
|
43
43
|
SetPageVisibility = 55,
|
|
44
|
+
LoadFontFace = 57,
|
|
45
|
+
SetNodeFocus = 58,
|
|
44
46
|
LongTask = 59,
|
|
45
47
|
SetNodeAttributeURLBased = 60,
|
|
46
48
|
SetCSSDataURLBased = 61,
|
|
@@ -54,7 +56,8 @@ export declare const enum Type {
|
|
|
54
56
|
AdoptedSSDeleteRule = 75,
|
|
55
57
|
AdoptedSSAddOwner = 76,
|
|
56
58
|
AdoptedSSRemoveOwner = 77,
|
|
57
|
-
Zustand = 79
|
|
59
|
+
Zustand = 79,
|
|
60
|
+
JSException = 78
|
|
58
61
|
}
|
|
59
62
|
export declare type BatchMetadata = [
|
|
60
63
|
Type.BatchMetadata,
|
|
@@ -182,8 +185,8 @@ export declare type PageRenderTiming = [
|
|
|
182
185
|
number,
|
|
183
186
|
number
|
|
184
187
|
];
|
|
185
|
-
export declare type
|
|
186
|
-
Type.
|
|
188
|
+
export declare type JSExceptionDeprecated = [
|
|
189
|
+
Type.JSExceptionDeprecated,
|
|
187
190
|
string,
|
|
188
191
|
string,
|
|
189
192
|
string
|
|
@@ -299,6 +302,17 @@ export declare type SetPageVisibility = [
|
|
|
299
302
|
Type.SetPageVisibility,
|
|
300
303
|
boolean
|
|
301
304
|
];
|
|
305
|
+
export declare type LoadFontFace = [
|
|
306
|
+
Type.LoadFontFace,
|
|
307
|
+
number,
|
|
308
|
+
string,
|
|
309
|
+
string,
|
|
310
|
+
string
|
|
311
|
+
];
|
|
312
|
+
export declare type SetNodeFocus = [
|
|
313
|
+
Type.SetNodeFocus,
|
|
314
|
+
number
|
|
315
|
+
];
|
|
302
316
|
export declare type LongTask = [
|
|
303
317
|
Type.LongTask,
|
|
304
318
|
number,
|
|
@@ -384,5 +398,12 @@ export declare type Zustand = [
|
|
|
384
398
|
string,
|
|
385
399
|
string
|
|
386
400
|
];
|
|
387
|
-
declare type
|
|
401
|
+
export declare type JSException = [
|
|
402
|
+
Type.JSException,
|
|
403
|
+
string,
|
|
404
|
+
string,
|
|
405
|
+
string,
|
|
406
|
+
string
|
|
407
|
+
];
|
|
408
|
+
declare type Message = BatchMetadata | PartitionedMessage | Timestamp | SetPageLocation | SetViewportSize | SetViewportScroll | CreateDocument | CreateElementNode | CreateTextNode | MoveNode | RemoveNode | SetNodeAttribute | RemoveNodeAttribute | SetNodeData | SetNodeScroll | SetInputTarget | SetInputValue | SetInputChecked | MouseMove | ConsoleLog | PageLoadTiming | PageRenderTiming | JSExceptionDeprecated | RawCustomEvent | UserID | UserAnonymousID | Metadata | CSSInsertRule | CSSDeleteRule | Fetch | Profiler | OTable | StateAction | Redux | Vuex | MobX | NgRx | GraphQL | PerformanceTrack | ResourceTiming | ConnectionInformation | SetPageVisibility | LoadFontFace | SetNodeFocus | LongTask | SetNodeAttributeURLBased | SetCSSDataURLBased | TechnicalInfo | CustomIssue | CSSInsertRuleURLBased | MouseClick | CreateIFrameDocument | AdoptedSSReplaceURLBased | AdoptedSSInsertRuleURLBased | AdoptedSSDeleteRule | AdoptedSSAddOwner | AdoptedSSRemoveOwner | Zustand | JSException;
|
|
388
409
|
export default Message;
|
package/cjs/index.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export default class API {
|
|
|
37
37
|
userAnonymousID(id: string): void;
|
|
38
38
|
setMetadata(key: string, value: string): void;
|
|
39
39
|
metadata(key: string, value: string): void;
|
|
40
|
-
event(key: string, payload
|
|
41
|
-
issue(key: string, payload
|
|
42
|
-
handleError: (e: Error | ErrorEvent | PromiseRejectionEvent) => void;
|
|
40
|
+
event(key: string, payload?: any, issue?: boolean): void;
|
|
41
|
+
issue(key: string, payload?: any): void;
|
|
42
|
+
handleError: (e: Error | ErrorEvent | PromiseRejectionEvent, metadata?: Record<string, any>) => void;
|
|
43
43
|
}
|
package/cjs/index.js
CHANGED
|
@@ -20,6 +20,8 @@ const performance_js_1 = require("./modules/performance.js");
|
|
|
20
20
|
const scroll_js_1 = require("./modules/scroll.js");
|
|
21
21
|
const viewport_js_1 = require("./modules/viewport.js");
|
|
22
22
|
const cssrules_js_1 = require("./modules/cssrules.js");
|
|
23
|
+
const focus_js_1 = require("./modules/focus.js");
|
|
24
|
+
const fonts_js_1 = require("./modules/fonts.js");
|
|
23
25
|
const constructedStyleSheets_js_1 = require("./modules/constructedStyleSheets.js");
|
|
24
26
|
const utils_js_1 = require("./utils.js");
|
|
25
27
|
const DOCS_SETUP = '/installation/setup-or';
|
|
@@ -54,16 +56,17 @@ class API {
|
|
|
54
56
|
constructor(options) {
|
|
55
57
|
this.options = options;
|
|
56
58
|
this.app = null;
|
|
57
|
-
this.handleError = (e) => {
|
|
59
|
+
this.handleError = (e, metadata = {}) => {
|
|
58
60
|
if (this.app === null) {
|
|
59
61
|
return;
|
|
60
62
|
}
|
|
61
63
|
if (e instanceof Error) {
|
|
62
|
-
|
|
64
|
+
const msg = (0, exception_js_1.getExceptionMessage)(e, [], metadata);
|
|
65
|
+
this.app.send(msg);
|
|
63
66
|
}
|
|
64
67
|
else if (e instanceof ErrorEvent ||
|
|
65
68
|
('PromiseRejectionEvent' in window && e instanceof PromiseRejectionEvent)) {
|
|
66
|
-
const msg = (0, exception_js_1.getExceptionMessageFromEvent)(e);
|
|
69
|
+
const msg = (0, exception_js_1.getExceptionMessageFromEvent)(e, undefined, metadata);
|
|
67
70
|
if (msg != null) {
|
|
68
71
|
this.app.send(msg);
|
|
69
72
|
}
|
|
@@ -109,6 +112,8 @@ class API {
|
|
|
109
112
|
(0, timing_js_1.default)(app, options);
|
|
110
113
|
(0, performance_js_1.default)(app, options);
|
|
111
114
|
(0, scroll_js_1.default)(app);
|
|
115
|
+
(0, focus_js_1.default)(app);
|
|
116
|
+
(0, fonts_js_1.default)(app);
|
|
112
117
|
window.__OPENREPLAY__ = this;
|
|
113
118
|
if (options.autoResetOnWindowOpen) {
|
|
114
119
|
const wOpen = window.open;
|
|
@@ -133,7 +138,7 @@ class API {
|
|
|
133
138
|
// no-cors issue only with text/plain or not-set Content-Type
|
|
134
139
|
// req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
|
135
140
|
req.send(JSON.stringify({
|
|
136
|
-
trackerVersion: '4.1.
|
|
141
|
+
trackerVersion: '4.1.6',
|
|
137
142
|
projectKey: options.projectKey,
|
|
138
143
|
doNotTrack,
|
|
139
144
|
// TODO: add precise reason (an exact API missing)
|
|
@@ -216,7 +221,7 @@ class API {
|
|
|
216
221
|
(0, utils_js_1.deprecationWarn)("'metadata' method", "'setMetadata' method", '/');
|
|
217
222
|
this.setMetadata(key, value);
|
|
218
223
|
}
|
|
219
|
-
event(key, payload, issue = false) {
|
|
224
|
+
event(key, payload = null, issue = false) {
|
|
220
225
|
if (typeof key === 'string' && this.app !== null) {
|
|
221
226
|
if (issue) {
|
|
222
227
|
return this.issue(key, payload);
|
|
@@ -232,7 +237,7 @@ class API {
|
|
|
232
237
|
}
|
|
233
238
|
}
|
|
234
239
|
}
|
|
235
|
-
issue(key, payload) {
|
|
240
|
+
issue(key, payload = null) {
|
|
236
241
|
if (typeof key === 'string' && this.app !== null) {
|
|
237
242
|
try {
|
|
238
243
|
payload = JSON.stringify(payload);
|
|
@@ -20,10 +20,6 @@ function default_1(app) {
|
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
22
|
if (!hasAdoptedSS(document)) {
|
|
23
|
-
app.attachStartCallback(() => {
|
|
24
|
-
// MBTODO: pre-start sendQueue app
|
|
25
|
-
app.send((0, messages_gen_js_1.TechnicalInfo)('no_adopted_stylesheets', ''));
|
|
26
|
-
});
|
|
27
23
|
return;
|
|
28
24
|
}
|
|
29
25
|
const styleSheetIDMap = new Map();
|
|
@@ -66,7 +62,7 @@ function default_1(app) {
|
|
|
66
62
|
}
|
|
67
63
|
}
|
|
68
64
|
adoptedStyleSheetsOwnings.set(nodeID, nowOwning);
|
|
69
|
-
}, 20); // Misterious bug:
|
|
65
|
+
}, 20); // Misterious bug:
|
|
70
66
|
/* On the page https://explore.fast.design/components/fast-accordion
|
|
71
67
|
the only rule inside the only adoptedStyleSheet of the iframe-s document
|
|
72
68
|
gets changed during first milliseconds after the load.
|
package/cjs/modules/cssrules.js
CHANGED
|
@@ -53,7 +53,7 @@ function default_1(app) {
|
|
|
53
53
|
});
|
|
54
54
|
const patchContext = app.safe((context) => {
|
|
55
55
|
const { insertRule, deleteRule } = context.CSSStyleSheet.prototype;
|
|
56
|
-
const { insertRule: groupInsertRule, deleteRule: groupDeleteRule
|
|
56
|
+
const { insertRule: groupInsertRule, deleteRule: groupDeleteRule } = context.CSSGroupingRule.prototype;
|
|
57
57
|
context.CSSStyleSheet.prototype.insertRule = function (rule, index = 0) {
|
|
58
58
|
sendInsertDeleteRule(this, index, rule);
|
|
59
59
|
return insertRule.call(this, rule, index);
|
|
@@ -10,7 +10,7 @@ interface StackFrame {
|
|
|
10
10
|
functionName?: string;
|
|
11
11
|
source?: string;
|
|
12
12
|
}
|
|
13
|
-
export declare function getExceptionMessage(error: Error, fallbackStack: Array<StackFrame>): Message;
|
|
14
|
-
export declare function getExceptionMessageFromEvent(e: ErrorEvent | PromiseRejectionEvent, context?: typeof globalThis): Message | null;
|
|
13
|
+
export declare function getExceptionMessage(error: Error, fallbackStack: Array<StackFrame>, metadata?: Record<string, any>): Message;
|
|
14
|
+
export declare function getExceptionMessageFromEvent(e: ErrorEvent | PromiseRejectionEvent, context?: typeof globalThis, metadata?: Record<string, any>): Message | null;
|
|
15
15
|
export default function (app: App, opts: Partial<Options>): void;
|
|
16
16
|
export {};
|