@openreplay/tracker 10.0.3 → 11.0.0-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.
Files changed (42) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/bun.lockb +0 -0
  3. package/cjs/app/canvas.d.ts +20 -0
  4. package/cjs/app/canvas.js +107 -0
  5. package/cjs/app/guards.d.ts +1 -0
  6. package/cjs/app/index.d.ts +2 -0
  7. package/cjs/app/index.js +35 -6
  8. package/cjs/app/messages.gen.d.ts +1 -0
  9. package/cjs/app/messages.gen.js +9 -1
  10. package/cjs/common/messages.gen.d.ts +8 -2
  11. package/cjs/index.js +1 -1
  12. package/cjs/modules/Network/fetchProxy.d.ts +1 -1
  13. package/cjs/modules/Network/fetchProxy.js +1 -1
  14. package/cjs/modules/userTesting/dnd.d.ts +1 -0
  15. package/cjs/modules/userTesting/dnd.js +40 -0
  16. package/cjs/modules/userTesting/index.d.ts +45 -0
  17. package/cjs/modules/userTesting/index.js +469 -0
  18. package/cjs/modules/userTesting/recorder.d.ts +24 -0
  19. package/cjs/modules/userTesting/recorder.js +119 -0
  20. package/cjs/modules/userTesting/styles.d.ts +260 -0
  21. package/cjs/modules/userTesting/styles.js +229 -0
  22. package/lib/app/canvas.d.ts +20 -0
  23. package/lib/app/canvas.js +105 -0
  24. package/lib/app/guards.d.ts +1 -0
  25. package/lib/app/index.d.ts +2 -0
  26. package/lib/app/index.js +35 -6
  27. package/lib/app/messages.gen.d.ts +1 -0
  28. package/lib/app/messages.gen.js +7 -0
  29. package/lib/common/messages.gen.d.ts +8 -2
  30. package/lib/common/tsconfig.tsbuildinfo +1 -1
  31. package/lib/index.js +1 -1
  32. package/lib/modules/Network/fetchProxy.d.ts +1 -1
  33. package/lib/modules/Network/fetchProxy.js +1 -1
  34. package/lib/modules/userTesting/dnd.d.ts +1 -0
  35. package/lib/modules/userTesting/dnd.js +37 -0
  36. package/lib/modules/userTesting/index.d.ts +45 -0
  37. package/lib/modules/userTesting/index.js +466 -0
  38. package/lib/modules/userTesting/recorder.d.ts +24 -0
  39. package/lib/modules/userTesting/recorder.js +115 -0
  40. package/lib/modules/userTesting/styles.d.ts +260 -0
  41. package/lib/modules/userTesting/styles.js +226 -0
  42. package/package.json +4 -3
package/CHANGELOG.md CHANGED
@@ -1,6 +1,8 @@
1
- # 10.0.3
1
+ # 11.0.0
2
2
 
3
+ - canvas support
3
4
  - some safety guards for iframe components
5
+ - user testing module
4
6
 
5
7
  # 10.0.2
6
8
 
package/bun.lockb CHANGED
Binary file
@@ -0,0 +1,20 @@
1
+ import App from '../app/index.js';
2
+ interface Options {
3
+ fps: number;
4
+ quality: 'low' | 'medium' | 'high';
5
+ }
6
+ declare class CanvasRecorder {
7
+ private readonly app;
8
+ private readonly options;
9
+ private snapshots;
10
+ private readonly intervals;
11
+ private readonly interval;
12
+ constructor(app: App, options: Options);
13
+ startTracking(): void;
14
+ sendSnaps(images: {
15
+ data: string;
16
+ id: number;
17
+ }[], canvasId: number, createdAt: number): void;
18
+ clear(): void;
19
+ }
20
+ export default CanvasRecorder;
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const guards_js_1 = require("./guards.js");
4
+ const messages_gen_js_1 = require("./messages.gen.js");
5
+ class CanvasRecorder {
6
+ constructor(app, options) {
7
+ this.app = app;
8
+ this.options = options;
9
+ this.snapshots = {};
10
+ this.intervals = [];
11
+ this.interval = 1000 / options.fps;
12
+ }
13
+ startTracking() {
14
+ this.app.nodes.attachNodeCallback((node) => {
15
+ const id = this.app.nodes.getID(node);
16
+ if (!id || !(0, guards_js_1.hasTag)(node, 'canvas') || this.snapshots[id]) {
17
+ return;
18
+ }
19
+ const ts = this.app.timestamp();
20
+ this.snapshots[id] = {
21
+ images: [],
22
+ createdAt: ts,
23
+ };
24
+ const canvasMsg = (0, messages_gen_js_1.CanvasNode)(id.toString(), ts);
25
+ this.app.send(canvasMsg);
26
+ const int = setInterval(() => {
27
+ const cid = this.app.nodes.getID(node);
28
+ const canvas = cid ? this.app.nodes.getNode(cid) : undefined;
29
+ if (!canvas || !(0, guards_js_1.hasTag)(canvas, 'canvas') || canvas !== node) {
30
+ console.log('Canvas element not in sync');
31
+ clearInterval(int);
32
+ }
33
+ else {
34
+ const snapshot = captureSnapshot(canvas, this.options.quality);
35
+ this.snapshots[id].images.push({ id: this.app.timestamp(), data: snapshot });
36
+ if (this.snapshots[id].images.length > 9) {
37
+ this.sendSnaps(this.snapshots[id].images, id, this.snapshots[id].createdAt);
38
+ this.snapshots[id].images = [];
39
+ }
40
+ }
41
+ }, this.interval);
42
+ this.intervals.push(int);
43
+ });
44
+ }
45
+ sendSnaps(images, canvasId, createdAt) {
46
+ var _a;
47
+ if (Object.keys(this.snapshots).length === 0) {
48
+ console.log(this.snapshots);
49
+ return;
50
+ }
51
+ const formData = new FormData();
52
+ images.forEach((snapshot) => {
53
+ const blob = dataUrlToBlob(snapshot.data)[0];
54
+ formData.append('snapshot', blob, `${createdAt}_${canvasId}_${snapshot.id}.jpeg`);
55
+ // saveImageData(snapshot.data, `${createdAt}_${canvasId}_${snapshot.id}.jpeg`)
56
+ });
57
+ fetch(this.app.options.ingestPoint + '/v1/web/images', {
58
+ method: 'POST',
59
+ headers: {
60
+ Authorization: `Bearer ${(_a = this.app.session.getSessionToken()) !== null && _a !== void 0 ? _a : ''}`,
61
+ },
62
+ body: formData,
63
+ })
64
+ .then((r) => {
65
+ console.log('done', r);
66
+ })
67
+ .catch((e) => {
68
+ console.error('error saving canvas', e);
69
+ });
70
+ }
71
+ clear() {
72
+ console.log('cleaning up');
73
+ this.intervals.forEach((int) => clearInterval(int));
74
+ this.snapshots = {};
75
+ }
76
+ }
77
+ const qualityInt = {
78
+ low: 0.33,
79
+ medium: 0.55,
80
+ high: 0.8,
81
+ };
82
+ function captureSnapshot(canvas, quality = 'medium') {
83
+ const imageFormat = 'image/jpeg'; // or /png'
84
+ return canvas.toDataURL(imageFormat, qualityInt[quality]);
85
+ }
86
+ function dataUrlToBlob(dataUrl) {
87
+ const [header, base64] = dataUrl.split(',');
88
+ // @ts-ignore
89
+ const mime = header.match(/:(.*?);/)[1];
90
+ const blobStr = atob(base64);
91
+ let n = blobStr.length;
92
+ const u8arr = new Uint8Array(n);
93
+ while (n--) {
94
+ u8arr[n] = blobStr.charCodeAt(n);
95
+ }
96
+ return [new Blob([u8arr], { type: mime }), u8arr];
97
+ }
98
+ function saveImageData(imageDataUrl, name) {
99
+ const link = document.createElement('a');
100
+ link.href = imageDataUrl;
101
+ link.download = name;
102
+ link.style.display = 'none';
103
+ document.body.appendChild(link);
104
+ link.click();
105
+ document.body.removeChild(link);
106
+ }
107
+ exports.default = CanvasRecorder;
@@ -16,6 +16,7 @@ type TagTypeMap = {
16
16
  iframe: HTMLIFrameElement;
17
17
  style: HTMLStyleElement | SVGStyleElement;
18
18
  link: HTMLLinkElement;
19
+ canvas: HTMLCanvasElement;
19
20
  };
20
21
  export declare function hasTag<T extends keyof TagTypeMap>(el: Node, tagName: T): el is TagTypeMap[typeof tagName];
21
22
  export {};
@@ -85,6 +85,8 @@ export default class App {
85
85
  private readonly bc;
86
86
  private readonly contextId;
87
87
  attributeSender: AttributeSender;
88
+ private canvasRecorder;
89
+ private uxtManager;
88
90
  constructor(projectKey: string, sessionToken: string | undefined, options: Partial<Options>);
89
91
  private _debug;
90
92
  private _usingOldFetchPlugin;
package/cjs/app/index.js CHANGED
@@ -12,7 +12,10 @@ const session_js_1 = require("./session.js");
12
12
  const fflate_1 = require("fflate");
13
13
  const performance_js_1 = require("../modules/performance.js");
14
14
  const attributeSender_js_1 = require("../modules/attributeSender.js");
15
+ const canvas_js_1 = require("./canvas.js");
16
+ const index_js_1 = require("../modules/userTesting/index.js");
15
17
  const CANCELED = 'canceled';
18
+ const uxtStorageKey = 'or_uxt_active';
16
19
  const START_ERROR = ':(';
17
20
  const UnsuccessfulStart = (reason) => ({ reason, success: false });
18
21
  const SuccessfulStart = (body) => (Object.assign(Object.assign({}, body), { success: true }));
@@ -39,10 +42,11 @@ class App {
39
42
  this.stopCallbacks = [];
40
43
  this.commitCallbacks = [];
41
44
  this.activityState = ActivityState.NotActive;
42
- this.version = '10.0.3'; // TODO: version compatability check inside each plugin.
45
+ this.version = '11.0.0-beta.1'; // TODO: version compatability check inside each plugin.
43
46
  this.compressionThreshold = 24 * 1000;
44
47
  this.restartAttempts = 0;
45
48
  this.bc = null;
49
+ this.canvasRecorder = null;
46
50
  this._usingOldFetchPlugin = false;
47
51
  this.delay = 0;
48
52
  // if (options.onStart !== undefined) {
@@ -70,7 +74,8 @@ class App {
70
74
  forceSingleTab: false,
71
75
  }, options);
72
76
  if (!this.options.forceSingleTab && globalThis && 'BroadcastChannel' in globalThis) {
73
- this.bc = (0, utils_js_1.inIframe)() ? null : new BroadcastChannel('rick');
77
+ const host = location.hostname.split('.').slice(-2).join('_');
78
+ this.bc = (0, utils_js_1.inIframe)() ? null : new BroadcastChannel(`rick_${host}`);
74
79
  }
75
80
  this.revID = this.options.revID;
76
81
  this.localStorage = (_a = this.options.localStorage) !== null && _a !== void 0 ? _a : window.localStorage;
@@ -98,7 +103,7 @@ class App {
98
103
  this.session.applySessionHash(sessionToken);
99
104
  }
100
105
  try {
101
- this.worker = new Worker(URL.createObjectURL(new Blob(['"use strict";class t{constructor(t,s,i,e=10,n=1e3,h){this.onUnauthorised=s,this.onFailure=i,this.MAX_ATTEMPTS_COUNT=e,this.ATTEMPT_TIMEOUT=n,this.onCompress=h,this.attemptsCount=0,this.busy=!1,this.queue=[],this.token=null,this.ingestURL=t+"/v1/web/i",this.isCompressing=void 0!==h}authorise(t){this.token=t,this.busy||this.sendNext()}push(t){this.busy||!this.token?this.queue.push(t):(this.busy=!0,this.isCompressing&&this.onCompress?this.onCompress(t):this.sendBatch(t))}sendNext(){const t=this.queue.shift();t?(this.busy=!0,this.isCompressing&&this.onCompress?this.onCompress(t):this.sendBatch(t)):this.busy=!1}retry(t,s){this.attemptsCount>=this.MAX_ATTEMPTS_COUNT?this.onFailure(`Failed to send batch after ${this.attemptsCount} attempts.`):(this.attemptsCount++,setTimeout((()=>this.sendBatch(t,s)),this.ATTEMPT_TIMEOUT*this.attemptsCount))}sendBatch(t,s){this.busy=!0;const i={Authorization:`Bearer ${this.token}`};s&&(i["Content-Encoding"]="gzip"),null!==this.token?fetch(this.ingestURL,{body:t,method:"POST",headers:i,keepalive:t.length<65536}).then((i=>{if(401===i.status)return this.busy=!1,void this.onUnauthorised();i.status>=400?this.retry(t,s):(this.attemptsCount=0,this.sendNext())})).catch((i=>{console.warn("OpenReplay:",i),this.retry(t,s)})):setTimeout((()=>{this.sendBatch(t,s)}),500)}sendCompressed(t){this.sendBatch(t,!0)}sendUncompressed(t){this.sendBatch(t,!1)}clean(){this.sendNext(),setTimeout((()=>{this.token=null,this.queue.length=0}),10)}}const s="function"==typeof TextEncoder?new TextEncoder:{encode(t){const s=t.length,i=new Uint8Array(3*s);let e=-1;for(let n=0,h=0,r=0;r!==s;){if(n=t.charCodeAt(r),r+=1,n>=55296&&n<=56319){if(r===s){i[e+=1]=239,i[e+=1]=191,i[e+=1]=189;break}if(h=t.charCodeAt(r),!(h>=56320&&h<=57343)){i[e+=1]=239,i[e+=1]=191,i[e+=1]=189;continue}if(n=1024*(n-55296)+h-56320+65536,r+=1,n>65535){i[e+=1]=240|n>>>18,i[e+=1]=128|n>>>12&63,i[e+=1]=128|n>>>6&63,i[e+=1]=128|63&n;continue}}n<=127?i[e+=1]=0|n:n<=2047?(i[e+=1]=192|n>>>6,i[e+=1]=128|63&n):(i[e+=1]=224|n>>>12,i[e+=1]=128|n>>>6&63,i[e+=1]=128|63&n)}return i.subarray(0,e+1)}};class i{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}get isEmpty(){return 0===this.offset}skip(t){return this.offset+=t,this.offset<=this.size}set(t,s){this.data.set(t,s)}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 i=s.encode(t),e=i.byteLength;return!(!this.uint(e)||this.offset+e>this.size)&&(this.data.set(i,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}}class e extends i{encode(t){switch(t[0]){case 0:case 11:case 114:case 115:return this.uint(t[1]);case 4:case 44:case 47:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3]);case 5:case 20:case 38:case 70:case 75:case 76:case 77:case 82: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:case 24:case 51:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3]);case 12:case 61:case 71:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3]);case 13:case 14:case 17:case 50:case 54: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 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 21:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.string(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8]);case 22:case 27:case 30:case 41:case 45:case 46:case 63:case 64:case 79: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 28:case 29:case 42:case 117:case 118:return this.string(t[1]);case 37:return this.uint(t[1])&&this.string(t[2])&&this.uint(t[3]);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 48:case 78: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 55:return this.boolean(t[1]);case 57:case 60: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 67:case 73: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 81:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.int(t[4])&&this.string(t[5]);case 83:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.string(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8])&&this.uint(t[9]);case 112:return this.uint(t[1])&&this.string(t[2])&&this.boolean(t[3])&&this.string(t[4])&&this.int(t[5])&&this.int(t[6]);case 113:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3]);case 116: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])&&this.uint(t[9])&&this.boolean(t[10])}}}class n{constructor(t,s,i,n,h){this.pageNo=t,this.timestamp=s,this.url=i,this.onBatch=n,this.tabId=h,this.nextIndex=0,this.beaconSize=2e5,this.encoder=new e(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,s){for(let s=0;s<3;s++)this.sizeBuffer[s]=t>>8*s;this.encoder.set(this.sizeBuffer,s)}prepare(){if(!this.encoder.isEmpty)return;const t=[81,1,this.pageNo,this.nextIndex,this.timestamp,this.url],s=[118,this.tabId];this.writeType(t),this.writeFields(t),this.writeWithSize(s),this.isEmpty=!0}writeWithSize(t){const s=this.encoder;if(!this.writeType(t)||!s.skip(3))return!1;const i=s.getCurrentOffset(),e=this.writeFields(t);if(e){const e=s.getCurrentOffset()-i;if(e>16777215)return console.warn("OpenReplay: max message size overflow."),!1;this.writeSizeAt(e,i-3),s.checkpoint(),this.isEmpty=this.isEmpty&&0===t[0],this.nextIndex++}return e}setBeaconSizeLimit(t){this.beaconSizeLimit=t}writeMessage(t){0===t[0]&&(this.timestamp=t[1]),4===t[0]&&(this.url=t[1]),this.writeWithSize(t)||(this.finaliseBatch(),this.writeWithSize(t)||(this.encoder=new e(this.beaconSizeLimit),this.prepare(),this.writeWithSize(t)?this.finaliseBatch():console.warn("OpenReplay: beacon size overflow. Skipping large message.",t,this),this.encoder=new e(this.beaconSize),this.prepare()))}finaliseBatch(){if(this.isEmpty)return;const t=this.encoder.flush();this.onBatch(t),this.prepare()}clean(){this.encoder.reset()}}var h;!function(t){t[t.NotActive=0]="NotActive",t[t.Starting=1]="Starting",t[t.Stopping=2]="Stopping",t[t.Active=3]="Active",t[t.Stopped=4]="Stopped"}(h||(h={}));let r=null,a=null,u=h.NotActive;function o(){a&&a.finaliseBatch()}function c(){u=h.Stopping,null!==d&&(clearInterval(d),d=null),a&&(a.clean(),a=null),r&&(r.clean(),setTimeout((()=>{r=null}),20)),setTimeout((()=>{u=h.NotActive}),100)}function p(){u!==h.Stopped&&(postMessage("restart"),c())}let f,d=null;self.onmessage=({data:s})=>{if(null!=s){if("stop"===s)return o(),c(),u=h.Stopped;if("forceFlushBatch"!==s){if(!Array.isArray(s)){if("compressed"===s.type){if(!r)return console.debug("WebWorker: sender not initialised. Compressed batch."),void p();r.sendCompressed(s.batch)}if("uncompressed"===s.type){if(!r)return console.debug("WebWorker: sender not initialised. Uncompressed batch."),void p();r.sendUncompressed(s.batch)}return"start"===s.type?(u=h.Starting,r=new t(s.ingestPoint,(()=>{p()}),(t=>{!function(t){postMessage({type:"failure",reason:t}),c()}(t)}),s.connAttemptCount,s.connAttemptGap,(t=>{postMessage({type:"compress",batch:t},[t.buffer])})),a=new n(s.pageNo,s.timestamp,s.url,(t=>r&&r.push(t)),s.tabId),null===d&&(d=setInterval(o,1e4)),u=h.Active):"auth"===s.type?r?a?(r.authorise(s.token),void(s.beaconSizeLimit&&a.setBeaconSizeLimit(s.beaconSizeLimit))):(console.debug("WebWorker: writer not initialised. Received auth."),void p()):(console.debug("WebWorker: sender not initialised. Received auth."),void p()):void 0}if(null!==a){const t=a;s.forEach((s=>{55===s[0]&&(s[1]?f=setTimeout((()=>p()),18e5):clearTimeout(f)),t.writeMessage(s)}))}a||(postMessage("not_init"),p())}else o()}else o()};'], { type: 'text/javascript' })));
106
+ this.worker = new Worker(URL.createObjectURL(new Blob(['"use strict";class t{constructor(t,s,i,e=10,n=1e3,h){this.onUnauthorised=s,this.onFailure=i,this.MAX_ATTEMPTS_COUNT=e,this.ATTEMPT_TIMEOUT=n,this.onCompress=h,this.attemptsCount=0,this.busy=!1,this.queue=[],this.token=null,this.ingestURL=t+"/v1/web/i",this.isCompressing=void 0!==h}authorise(t){this.token=t,this.busy||this.sendNext()}push(t){this.busy||!this.token?this.queue.push(t):(this.busy=!0,this.isCompressing&&this.onCompress?this.onCompress(t):this.sendBatch(t))}sendNext(){const t=this.queue.shift();t?(this.busy=!0,this.isCompressing&&this.onCompress?this.onCompress(t):this.sendBatch(t)):this.busy=!1}retry(t,s){this.attemptsCount>=this.MAX_ATTEMPTS_COUNT?this.onFailure(`Failed to send batch after ${this.attemptsCount} attempts.`):(this.attemptsCount++,setTimeout((()=>this.sendBatch(t,s)),this.ATTEMPT_TIMEOUT*this.attemptsCount))}sendBatch(t,s){this.busy=!0;const i={Authorization:`Bearer ${this.token}`};s&&(i["Content-Encoding"]="gzip"),null!==this.token?fetch(this.ingestURL,{body:t,method:"POST",headers:i,keepalive:t.length<65536}).then((i=>{if(401===i.status)return this.busy=!1,void this.onUnauthorised();i.status>=400?this.retry(t,s):(this.attemptsCount=0,this.sendNext())})).catch((i=>{console.warn("OpenReplay:",i),this.retry(t,s)})):setTimeout((()=>{this.sendBatch(t,s)}),500)}sendCompressed(t){this.sendBatch(t,!0)}sendUncompressed(t){this.sendBatch(t,!1)}clean(){this.sendNext(),setTimeout((()=>{this.token=null,this.queue.length=0}),10)}}const s="function"==typeof TextEncoder?new TextEncoder:{encode(t){const s=t.length,i=new Uint8Array(3*s);let e=-1;for(let n=0,h=0,r=0;r!==s;){if(n=t.charCodeAt(r),r+=1,n>=55296&&n<=56319){if(r===s){i[e+=1]=239,i[e+=1]=191,i[e+=1]=189;break}if(h=t.charCodeAt(r),!(h>=56320&&h<=57343)){i[e+=1]=239,i[e+=1]=191,i[e+=1]=189;continue}if(n=1024*(n-55296)+h-56320+65536,r+=1,n>65535){i[e+=1]=240|n>>>18,i[e+=1]=128|n>>>12&63,i[e+=1]=128|n>>>6&63,i[e+=1]=128|63&n;continue}}n<=127?i[e+=1]=0|n:n<=2047?(i[e+=1]=192|n>>>6,i[e+=1]=128|63&n):(i[e+=1]=224|n>>>12,i[e+=1]=128|n>>>6&63,i[e+=1]=128|63&n)}return i.subarray(0,e+1)}};class i{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}get isEmpty(){return 0===this.offset}skip(t){return this.offset+=t,this.offset<=this.size}set(t,s){this.data.set(t,s)}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 i=s.encode(t),e=i.byteLength;return!(!this.uint(e)||this.offset+e>this.size)&&(this.data.set(i,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}}class e extends i{encode(t){switch(t[0]){case 0:case 11:case 114:case 115:return this.uint(t[1]);case 4:case 44:case 47:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3]);case 5:case 20:case 38:case 70:case 75:case 76:case 77:case 82: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:case 24:case 51:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3]);case 12:case 61:case 71:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3]);case 13:case 14:case 17:case 50:case 54: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 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 21:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.string(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8]);case 22:case 27:case 30:case 41:case 45:case 46:case 63:case 64:case 79: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 28:case 29:case 42:case 117:case 118:return this.string(t[1]);case 37:return this.uint(t[1])&&this.string(t[2])&&this.uint(t[3]);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 48:case 78: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 55:return this.boolean(t[1]);case 57:case 60: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 67:case 73: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 81:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.int(t[4])&&this.string(t[5]);case 83:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.string(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8])&&this.uint(t[9]);case 112:return this.uint(t[1])&&this.string(t[2])&&this.boolean(t[3])&&this.string(t[4])&&this.int(t[5])&&this.int(t[6]);case 113:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3]);case 116: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])&&this.uint(t[9])&&this.boolean(t[10]);case 119:return this.string(t[1])&&this.uint(t[2])}}}class n{constructor(t,s,i,n,h){this.pageNo=t,this.timestamp=s,this.url=i,this.onBatch=n,this.tabId=h,this.nextIndex=0,this.beaconSize=2e5,this.encoder=new e(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,s){for(let s=0;s<3;s++)this.sizeBuffer[s]=t>>8*s;this.encoder.set(this.sizeBuffer,s)}prepare(){if(!this.encoder.isEmpty)return;const t=[81,1,this.pageNo,this.nextIndex,this.timestamp,this.url],s=[118,this.tabId];this.writeType(t),this.writeFields(t),this.writeWithSize(s),this.isEmpty=!0}writeWithSize(t){const s=this.encoder;if(!this.writeType(t)||!s.skip(3))return!1;const i=s.getCurrentOffset(),e=this.writeFields(t);if(e){const e=s.getCurrentOffset()-i;if(e>16777215)return console.warn("OpenReplay: max message size overflow."),!1;this.writeSizeAt(e,i-3),s.checkpoint(),this.isEmpty=this.isEmpty&&0===t[0],this.nextIndex++}return e}setBeaconSizeLimit(t){this.beaconSizeLimit=t}writeMessage(t){0===t[0]&&(this.timestamp=t[1]),4===t[0]&&(this.url=t[1]),this.writeWithSize(t)||(this.finaliseBatch(),this.writeWithSize(t)||(this.encoder=new e(this.beaconSizeLimit),this.prepare(),this.writeWithSize(t)?this.finaliseBatch():console.warn("OpenReplay: beacon size overflow. Skipping large message.",t,this),this.encoder=new e(this.beaconSize),this.prepare()))}finaliseBatch(){if(this.isEmpty)return;const t=this.encoder.flush();this.onBatch(t),this.prepare()}clean(){this.encoder.reset()}}var h;!function(t){t[t.NotActive=0]="NotActive",t[t.Starting=1]="Starting",t[t.Stopping=2]="Stopping",t[t.Active=3]="Active",t[t.Stopped=4]="Stopped"}(h||(h={}));let r=null,a=null,u=h.NotActive;function o(){a&&a.finaliseBatch()}function c(){u=h.Stopping,null!==d&&(clearInterval(d),d=null),a&&(a.clean(),a=null),r&&(r.clean(),setTimeout((()=>{r=null}),20)),setTimeout((()=>{u=h.NotActive}),100)}function p(){u!==h.Stopped&&(postMessage("restart"),c())}let f,d=null;self.onmessage=({data:s})=>{if(null!=s){if("stop"===s)return o(),c(),u=h.Stopped;if("forceFlushBatch"!==s){if(!Array.isArray(s)){if("compressed"===s.type){if(!r)return console.debug("WebWorker: sender not initialised. Compressed batch."),void p();r.sendCompressed(s.batch)}if("uncompressed"===s.type){if(!r)return console.debug("WebWorker: sender not initialised. Uncompressed batch."),void p();r.sendUncompressed(s.batch)}return"start"===s.type?(u=h.Starting,r=new t(s.ingestPoint,(()=>{p()}),(t=>{!function(t){postMessage({type:"failure",reason:t}),c()}(t)}),s.connAttemptCount,s.connAttemptGap,(t=>{postMessage({type:"compress",batch:t},[t.buffer])})),a=new n(s.pageNo,s.timestamp,s.url,(t=>r&&r.push(t)),s.tabId),null===d&&(d=setInterval(o,1e4)),u=h.Active):"auth"===s.type?r?a?(r.authorise(s.token),void(s.beaconSizeLimit&&a.setBeaconSizeLimit(s.beaconSizeLimit))):(console.debug("WebWorker: writer not initialised. Received auth."),void p()):(console.debug("WebWorker: sender not initialised. Received auth."),void p()):void 0}if(null!==a){const t=a;s.forEach((s=>{55===s[0]&&(s[1]?f=setTimeout((()=>p()),18e5):clearTimeout(f)),t.writeMessage(s)}))}a||(postMessage("not_init"),p())}else o()}else o()};'], { type: 'text/javascript' })));
102
107
  this.worker.onerror = (e) => {
103
108
  this._debug('webworker_error', e);
104
109
  };
@@ -195,6 +200,7 @@ class App {
195
200
  }
196
201
  };
197
202
  }
203
+ this.uxtManager = new index_js_1.default(this, uxtStorageKey);
198
204
  }
199
205
  _debug(context, e) {
200
206
  if (this.options.__debug_report_edp !== null) {
@@ -237,10 +243,11 @@ class App {
237
243
  commit() {
238
244
  if (this.worker !== undefined && this.messages.length) {
239
245
  (0, utils_js_1.requestIdleCb)(() => {
246
+ var _a;
240
247
  this.messages.unshift((0, messages_gen_js_1.TabData)(this.session.getTabId()));
241
248
  this.messages.unshift((0, messages_gen_js_1.Timestamp)(this.timestamp()));
242
- // ? why I need to do this?
243
- this.worker.postMessage(this.messages);
249
+ // why I need to add opt chaining?
250
+ (_a = this.worker) === null || _a === void 0 ? void 0 : _a.postMessage(this.messages);
244
251
  this.commitCallbacks.forEach((cb) => cb(this.messages));
245
252
  this.messages.length = 0;
246
253
  });
@@ -439,6 +446,7 @@ class App {
439
446
  }
440
447
  })
441
448
  .then((r) => {
449
+ var _a;
442
450
  if (!this.worker) {
443
451
  return Promise.reject('no worker found after start request (this might not happen)');
444
452
  }
@@ -449,7 +457,7 @@ class App {
449
457
  delay, // derived from token
450
458
  sessionID, // derived from token
451
459
  startTimestamp, // real startTS (server time), derived from sessionID
452
- userBrowser, userCity, userCountry, userDevice, userOS, userState, } = r;
460
+ userBrowser, userCity, userCountry, userDevice, userOS, userState, canvasEnabled, canvasQuality, canvasFPS, } = r;
453
461
  if (typeof token !== 'string' ||
454
462
  typeof userUUID !== 'string' ||
455
463
  (typeof startTimestamp !== 'number' && typeof startTimestamp !== 'undefined') ||
@@ -492,6 +500,11 @@ class App {
492
500
  this.startCallbacks.forEach((cb) => cb(onStartInfo)); // MBTODO: callbacks after DOM "mounted" (observed)
493
501
  this.observer.observe();
494
502
  this.ticker.start();
503
+ if (canvasEnabled) {
504
+ this.canvasRecorder =
505
+ (_a = this.canvasRecorder) !== null && _a !== void 0 ? _a : new canvas_js_1.default(this, { fps: canvasFPS, quality: canvasQuality });
506
+ this.canvasRecorder.startTracking();
507
+ }
495
508
  this.activityState = ActivityState.Active;
496
509
  this.notify.log('OpenReplay tracking started.');
497
510
  // get rid of onStart ?
@@ -499,6 +512,20 @@ class App {
499
512
  this.options.onStart(onStartInfo);
500
513
  }
501
514
  this.restartAttempts = 0;
515
+ let uxtId;
516
+ const savedUxtTag = this.localStorage.getItem(uxtStorageKey);
517
+ if (savedUxtTag) {
518
+ uxtId = parseInt(savedUxtTag, 10);
519
+ }
520
+ if (location === null || location === void 0 ? void 0 : location.search) {
521
+ const query = new URLSearchParams(location.search);
522
+ if (query.has('oruxt')) {
523
+ const qId = query.get('oruxt');
524
+ uxtId = qId ? parseInt(qId, 10) : undefined;
525
+ }
526
+ }
527
+ if (uxtId)
528
+ this.uxtManager.getTest(uxtId, token, Boolean(savedUxtTag));
502
529
  return SuccessfulStart(onStartInfo);
503
530
  })
504
531
  .catch((reason) => {
@@ -546,6 +573,7 @@ class App {
546
573
  return this.session.getTabId();
547
574
  }
548
575
  stop(stopWorker = true) {
576
+ var _a;
549
577
  if (this.activityState !== ActivityState.NotActive) {
550
578
  try {
551
579
  this.attributeSender.clear();
@@ -558,6 +586,7 @@ class App {
558
586
  if (this.worker && stopWorker) {
559
587
  this.worker.postMessage('stop');
560
588
  }
589
+ (_a = this.canvasRecorder) === null || _a === void 0 ? void 0 : _a.clear();
561
590
  }
562
591
  finally {
563
592
  this.activityState = ActivityState.NotActive;
@@ -69,3 +69,4 @@ export declare function UnbindNodes(totalRemovedPercent: number): Messages.Unbin
69
69
  export declare function ResourceTiming(timestamp: number, duration: number, ttfb: number, headerSize: number, encodedBodySize: number, decodedBodySize: number, url: string, initiator: string, transferredSize: number, cached: boolean): Messages.ResourceTiming;
70
70
  export declare function TabChange(tabId: string): Messages.TabChange;
71
71
  export declare function TabData(tabId: string): Messages.TabData;
72
+ export declare function CanvasNode(nodeId: string, timestamp: number): Messages.CanvasNode;
@@ -3,7 +3,7 @@
3
3
  /* eslint-disable */
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.CSSInsertRuleURLBased = exports.CustomIssue = exports.TechnicalInfo = exports.SetCSSDataURLBased = exports.SetNodeAttributeURLBased = exports.LongTask = exports.SetNodeFocus = exports.LoadFontFace = exports.SetPageVisibility = exports.ConnectionInformation = exports.ResourceTimingDeprecated = exports.SetNodeAttributeDict = exports.StringDict = 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.CustomEvent = exports.PageRenderTiming = exports.PageLoadTiming = exports.ConsoleLog = exports.NetworkRequestDeprecated = 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 = void 0;
6
- exports.TabData = exports.TabChange = exports.ResourceTiming = exports.UnbindNodes = exports.MouseThrashing = exports.SelectionChange = exports.InputChange = exports.NetworkRequest = exports.PartitionedMessage = exports.BatchMetadata = exports.Zustand = exports.JSException = exports.AdoptedSSRemoveOwner = exports.AdoptedSSAddOwner = exports.AdoptedSSDeleteRule = exports.AdoptedSSInsertRuleURLBased = exports.AdoptedSSReplaceURLBased = exports.CreateIFrameDocument = exports.MouseClick = void 0;
6
+ exports.CanvasNode = exports.TabData = exports.TabChange = exports.ResourceTiming = exports.UnbindNodes = exports.MouseThrashing = exports.SelectionChange = exports.InputChange = exports.NetworkRequest = exports.PartitionedMessage = exports.BatchMetadata = exports.Zustand = exports.JSException = exports.AdoptedSSRemoveOwner = exports.AdoptedSSAddOwner = exports.AdoptedSSDeleteRule = exports.AdoptedSSInsertRuleURLBased = exports.AdoptedSSReplaceURLBased = exports.CreateIFrameDocument = exports.MouseClick = void 0;
7
7
  function Timestamp(timestamp) {
8
8
  return [
9
9
  0 /* Messages.Type.Timestamp */,
@@ -629,3 +629,11 @@ function TabData(tabId) {
629
629
  ];
630
630
  }
631
631
  exports.TabData = TabData;
632
+ function CanvasNode(nodeId, timestamp) {
633
+ return [
634
+ 119 /* Messages.Type.CanvasNode */,
635
+ nodeId,
636
+ timestamp,
637
+ ];
638
+ }
639
+ exports.CanvasNode = CanvasNode;
@@ -67,7 +67,8 @@ export declare const enum Type {
67
67
  UnbindNodes = 115,
68
68
  ResourceTiming = 116,
69
69
  TabChange = 117,
70
- TabData = 118
70
+ TabData = 118,
71
+ CanvasNode = 119
71
72
  }
72
73
  export type Timestamp = [
73
74
  Type.Timestamp,
@@ -487,5 +488,10 @@ export type TabData = [
487
488
  Type.TabData,
488
489
  string
489
490
  ];
490
- type Message = Timestamp | SetPageLocation | SetViewportSize | SetViewportScroll | CreateDocument | CreateElementNode | CreateTextNode | MoveNode | RemoveNode | SetNodeAttribute | RemoveNodeAttribute | SetNodeData | SetNodeScroll | SetInputTarget | SetInputValue | SetInputChecked | MouseMove | NetworkRequestDeprecated | ConsoleLog | PageLoadTiming | PageRenderTiming | CustomEvent | UserID | UserAnonymousID | Metadata | CSSInsertRule | CSSDeleteRule | Fetch | Profiler | OTable | StateAction | Redux | Vuex | MobX | NgRx | GraphQL | PerformanceTrack | StringDict | SetNodeAttributeDict | ResourceTimingDeprecated | ConnectionInformation | SetPageVisibility | LoadFontFace | SetNodeFocus | LongTask | SetNodeAttributeURLBased | SetCSSDataURLBased | TechnicalInfo | CustomIssue | CSSInsertRuleURLBased | MouseClick | CreateIFrameDocument | AdoptedSSReplaceURLBased | AdoptedSSInsertRuleURLBased | AdoptedSSDeleteRule | AdoptedSSAddOwner | AdoptedSSRemoveOwner | JSException | Zustand | BatchMetadata | PartitionedMessage | NetworkRequest | InputChange | SelectionChange | MouseThrashing | UnbindNodes | ResourceTiming | TabChange | TabData;
491
+ export type CanvasNode = [
492
+ Type.CanvasNode,
493
+ string,
494
+ number
495
+ ];
496
+ type Message = Timestamp | SetPageLocation | SetViewportSize | SetViewportScroll | CreateDocument | CreateElementNode | CreateTextNode | MoveNode | RemoveNode | SetNodeAttribute | RemoveNodeAttribute | SetNodeData | SetNodeScroll | SetInputTarget | SetInputValue | SetInputChecked | MouseMove | NetworkRequestDeprecated | ConsoleLog | PageLoadTiming | PageRenderTiming | CustomEvent | UserID | UserAnonymousID | Metadata | CSSInsertRule | CSSDeleteRule | Fetch | Profiler | OTable | StateAction | Redux | Vuex | MobX | NgRx | GraphQL | PerformanceTrack | StringDict | SetNodeAttributeDict | ResourceTimingDeprecated | ConnectionInformation | SetPageVisibility | LoadFontFace | SetNodeFocus | LongTask | SetNodeAttributeURLBased | SetCSSDataURLBased | TechnicalInfo | CustomIssue | CSSInsertRuleURLBased | MouseClick | CreateIFrameDocument | AdoptedSSReplaceURLBased | AdoptedSSInsertRuleURLBased | AdoptedSSDeleteRule | AdoptedSSAddOwner | AdoptedSSRemoveOwner | JSException | Zustand | BatchMetadata | PartitionedMessage | NetworkRequest | InputChange | SelectionChange | MouseThrashing | UnbindNodes | ResourceTiming | TabChange | TabData | CanvasNode;
491
497
  export default Message;
package/cjs/index.js CHANGED
@@ -162,7 +162,7 @@ class API {
162
162
  // no-cors issue only with text/plain or not-set Content-Type
163
163
  // req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
164
164
  req.send(JSON.stringify({
165
- trackerVersion: '10.0.3',
165
+ trackerVersion: '11.0.0-beta.1',
166
166
  projectKey: options.projectKey,
167
167
  doNotTrack,
168
168
  // TODO: add precise reason (an exact API missing)
@@ -25,7 +25,7 @@ export declare class FetchProxyHandler<T extends typeof fetch> implements ProxyH
25
25
  private readonly tokenUrlMatcher?;
26
26
  constructor(ignoredHeaders: boolean | string[], setSessionTokenHeader: (cb: (name: string, value: string) => void) => void, sanitize: (data: RequestResponseData) => RequestResponseData, sendMessage: (item: NetworkRequest) => void, isServiceUrl: (url: string) => boolean, tokenUrlMatcher?: ((url: string) => boolean) | undefined);
27
27
  apply(target: T, _: typeof window, argsList: [RequestInfo | URL, RequestInit]): any;
28
- protected beforeFetch(item: NetworkMessage, input: RequestInfo, init?: RequestInit): void;
28
+ protected beforeFetch(item: NetworkMessage, input: RequestInfo | string, init?: RequestInit): void;
29
29
  protected afterFetch(item: NetworkMessage): (resp: Response) => Response;
30
30
  protected handleResponseBody(resp: Response, item: NetworkMessage): Promise<ArrayBuffer> | Promise<string>;
31
31
  }
@@ -118,7 +118,7 @@ class FetchProxyHandler {
118
118
  const input = argsList[0];
119
119
  const init = argsList[1];
120
120
  // @ts-ignore
121
- if (!(input === null || input === void 0 ? void 0 : input.url) && !input)
121
+ if (!input || !(input === null || input === void 0 ? void 0 : input.url))
122
122
  return target.apply(window, argsList);
123
123
  const isORUrl = input instanceof URL || typeof input === 'string'
124
124
  ? this.isServiceUrl(String(input))
@@ -0,0 +1 @@
1
+ export default function attachDND(element: any, dragTarget: any): void;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ function attachDND(element, dragTarget) {
5
+ dragTarget.onmousedown = function (event) {
6
+ const clientRect = element.getBoundingClientRect();
7
+ const shiftX = event.clientX - clientRect.left;
8
+ const shiftY = event.clientY - clientRect.top;
9
+ element.style.position = 'fixed';
10
+ element.style.zIndex = 99999999999999;
11
+ moveAt(event.pageX, event.pageY);
12
+ function moveAt(pageX, pageY) {
13
+ let leftC = pageX - shiftX;
14
+ let topC = pageY - shiftY;
15
+ if (leftC <= 5)
16
+ leftC = 5;
17
+ if (topC <= 5)
18
+ topC = 5;
19
+ if (leftC >= window.innerWidth - clientRect.width)
20
+ leftC = window.innerWidth - clientRect.width;
21
+ if (topC >= window.innerHeight - clientRect.height)
22
+ topC = window.innerHeight - clientRect.height;
23
+ element.style.left = `${leftC}px`;
24
+ element.style.top = `${topC}px`;
25
+ }
26
+ function onMouseMove(event) {
27
+ moveAt(event.pageX, event.pageY);
28
+ }
29
+ document.addEventListener('mousemove', onMouseMove);
30
+ const clearAll = () => {
31
+ document.removeEventListener('mousemove', onMouseMove);
32
+ document.removeEventListener('mouseup', clearAll);
33
+ };
34
+ document.addEventListener('mouseup', clearAll);
35
+ };
36
+ dragTarget.ondragstart = function () {
37
+ return false;
38
+ };
39
+ }
40
+ exports.default = attachDND;
@@ -0,0 +1,45 @@
1
+ import App from '../../app/index.js';
2
+ export default class UserTestManager {
3
+ private readonly app;
4
+ private readonly storageKey;
5
+ private readonly userRecorder;
6
+ private readonly bg;
7
+ private readonly container;
8
+ private widgetGuidelinesVisible;
9
+ private widgetTasksVisible;
10
+ private widgetVisible;
11
+ private descriptionSection;
12
+ private taskSection;
13
+ private endSection;
14
+ private stopButton;
15
+ private test;
16
+ private testId;
17
+ private token;
18
+ private readonly durations;
19
+ constructor(app: App, storageKey: string);
20
+ signalTask: (taskId: number, status: 'begin' | 'done' | 'skipped', answer?: string) => void | Promise<Response>;
21
+ signalTest: (status: 'begin' | 'done' | 'skipped') => Promise<Response>;
22
+ getTest: (id: number, token: string, inProgress?: boolean) => void;
23
+ hideTaskSection: () => boolean;
24
+ showTaskSection: () => boolean;
25
+ collapseWidget: () => boolean;
26
+ removeGreeting: () => boolean;
27
+ createGreeting(title: string, micRequired: boolean, cameraRequired: boolean): void;
28
+ showWidget(description: string, tasks: {
29
+ title: string;
30
+ description: string;
31
+ task_id: number;
32
+ allow_typing: boolean;
33
+ }[], inProgress?: boolean): void;
34
+ createTitleSection(): HTMLElement;
35
+ toggleDescriptionVisibility: () => void;
36
+ createDescriptionSection(description: string): HTMLElement;
37
+ currentTaskIndex: number;
38
+ createTasksSection(tasks: {
39
+ title: string;
40
+ description: string;
41
+ task_id: number;
42
+ allow_typing: boolean;
43
+ }[]): HTMLElement;
44
+ showEndSection(): void;
45
+ }