@openreplay/tracker 7.0.2-beta.2 → 7.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/cjs/app/index.js +18 -23
- package/cjs/app/observer/iframe_offsets.js +4 -2
- package/cjs/app/observer/observer.js +1 -1
- package/cjs/index.js +1 -1
- package/cjs/modules/axiosSpy.d.ts +1 -0
- package/cjs/modules/axiosSpy.js +29 -5
- package/cjs/modules/constructedStyleSheets.js +2 -5
- package/cjs/modules/mouse.js +12 -21
- package/cjs/modules/network.js +13 -11
- package/cjs/utils.js +2 -1
- package/coverage/clover.xml +2461 -0
- package/coverage/coverage-final.json +38 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +176 -0
- package/coverage/lcov-report/main/app/guards.ts.html +229 -0
- package/coverage/lcov-report/main/app/index.html +206 -0
- package/coverage/lcov-report/main/app/index.ts.html +2053 -0
- package/coverage/lcov-report/main/app/logger.ts.html +277 -0
- package/coverage/lcov-report/main/app/messages.gen.ts.html +2752 -0
- package/coverage/lcov-report/main/app/nodes.ts.html +367 -0
- package/coverage/lcov-report/main/app/observer/iframe_observer.ts.html +148 -0
- package/coverage/lcov-report/main/app/observer/iframe_offsets.ts.html +289 -0
- package/coverage/lcov-report/main/app/observer/index.html +161 -0
- package/coverage/lcov-report/main/app/observer/observer.ts.html +1282 -0
- package/coverage/lcov-report/main/app/observer/shadow_root_observer.ts.html +142 -0
- package/coverage/lcov-report/main/app/observer/top_observer.ts.html +535 -0
- package/coverage/lcov-report/main/app/sanitizer.ts.html +394 -0
- package/coverage/lcov-report/main/app/session.ts.html +559 -0
- package/coverage/lcov-report/main/app/ticker.ts.html +250 -0
- package/coverage/lcov-report/main/index.html +131 -0
- package/coverage/lcov-report/main/index.ts.html +1012 -0
- package/coverage/lcov-report/main/modules/axiosSpy.ts.html +700 -0
- package/coverage/lcov-report/main/modules/connection.ts.html +160 -0
- package/coverage/lcov-report/main/modules/console.ts.html +508 -0
- package/coverage/lcov-report/main/modules/constructedStyleSheets.ts.html +559 -0
- package/coverage/lcov-report/main/modules/cssrules.ts.html +418 -0
- package/coverage/lcov-report/main/modules/exception.ts.html +385 -0
- package/coverage/lcov-report/main/modules/focus.ts.html +220 -0
- package/coverage/lcov-report/main/modules/fonts.ts.html +289 -0
- package/coverage/lcov-report/main/modules/img.ts.html +433 -0
- package/coverage/lcov-report/main/modules/index.html +371 -0
- package/coverage/lcov-report/main/modules/input.ts.html +811 -0
- package/coverage/lcov-report/main/modules/mouse.ts.html +826 -0
- package/coverage/lcov-report/main/modules/network.ts.html +1129 -0
- package/coverage/lcov-report/main/modules/performance.ts.html +367 -0
- package/coverage/lcov-report/main/modules/scroll.ts.html +364 -0
- package/coverage/lcov-report/main/modules/selection.ts.html +202 -0
- package/coverage/lcov-report/main/modules/tabs.ts.html +124 -0
- package/coverage/lcov-report/main/modules/timing.ts.html +841 -0
- package/coverage/lcov-report/main/modules/viewport.ts.html +250 -0
- package/coverage/lcov-report/main/utils.ts.html +406 -0
- package/coverage/lcov-report/main/vendors/finder/finder.ts.html +1381 -0
- package/coverage/lcov-report/main/vendors/finder/index.html +116 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/webworker/BatchWriter.ts.html +532 -0
- package/coverage/lcov-report/webworker/MessageEncoder.gen.ts.html +949 -0
- package/coverage/lcov-report/webworker/PrimitiveEncoder.ts.html +436 -0
- package/coverage/lcov-report/webworker/QueueSender.ts.html +475 -0
- package/coverage/lcov-report/webworker/StringDictionary.ts.html +124 -0
- package/coverage/lcov-report/webworker/index.html +191 -0
- package/coverage/lcov-report/webworker/index.ts.html +592 -0
- package/coverage/lcov.info +4882 -0
- package/jest.config.js +2 -0
- package/lib/app/index.js +18 -23
- package/lib/app/observer/iframe_offsets.js +4 -2
- package/lib/app/observer/observer.js +1 -1
- package/lib/common/tsconfig.tsbuildinfo +1 -1
- package/lib/index.js +1 -1
- package/lib/modules/axiosSpy.d.ts +1 -0
- package/lib/modules/axiosSpy.js +29 -5
- package/lib/modules/constructedStyleSheets.js +2 -5
- package/lib/modules/mouse.js +12 -21
- package/lib/modules/network.js +13 -11
- package/lib/utils.js +2 -1
- package/package.json +2 -3
- package/tsconfig-base.json +2 -2
- package/cjs/vendors/finder/finder.d.ts +0 -12
- package/cjs/vendors/finder/finder.js +0 -352
- package/lib/vendors/finder/finder.d.ts +0 -12
- package/lib/vendors/finder/finder.js +0 -348
package/CHANGELOG.md
CHANGED
package/cjs/app/index.js
CHANGED
|
@@ -14,7 +14,7 @@ const performance_js_1 = require("../modules/performance.js");
|
|
|
14
14
|
const CANCELED = 'canceled';
|
|
15
15
|
const START_ERROR = ':(';
|
|
16
16
|
const UnsuccessfulStart = (reason) => ({ reason, success: false });
|
|
17
|
-
const SuccessfulStart = (body) => ({
|
|
17
|
+
const SuccessfulStart = (body) => (Object.assign(Object.assign({}, body), { success: true }));
|
|
18
18
|
var ActivityState;
|
|
19
19
|
(function (ActivityState) {
|
|
20
20
|
ActivityState[ActivityState["NotActive"] = 0] = "NotActive";
|
|
@@ -28,12 +28,13 @@ class App {
|
|
|
28
28
|
// if (options.onStart !== undefined) {
|
|
29
29
|
// deprecationWarn("'onStart' option", "tracker.start().then(/* handle session info */)")
|
|
30
30
|
// } ?? maybe onStart is good
|
|
31
|
+
var _a, _b;
|
|
31
32
|
this.messages = [];
|
|
32
33
|
this.startCallbacks = [];
|
|
33
34
|
this.stopCallbacks = [];
|
|
34
35
|
this.commitCallbacks = [];
|
|
35
36
|
this.activityState = ActivityState.NotActive;
|
|
36
|
-
this.version = '7.0.
|
|
37
|
+
this.version = '7.0.3'; // TODO: version compatability check inside each plugin.
|
|
37
38
|
this.compressionThreshold = 24 * 1000;
|
|
38
39
|
this.restartAttempts = 0;
|
|
39
40
|
this._usingOldFetchPlugin = false;
|
|
@@ -56,8 +57,8 @@ class App {
|
|
|
56
57
|
sessionStorage: null,
|
|
57
58
|
}, options);
|
|
58
59
|
this.revID = this.options.revID;
|
|
59
|
-
this.localStorage = this.options.localStorage
|
|
60
|
-
this.sessionStorage = this.options.sessionStorage
|
|
60
|
+
this.localStorage = (_a = this.options.localStorage) !== null && _a !== void 0 ? _a : window.localStorage;
|
|
61
|
+
this.sessionStorage = (_b = this.options.sessionStorage) !== null && _b !== void 0 ? _b : window.sessionStorage;
|
|
61
62
|
this.sanitizer = new sanitizer_js_1.default(this, options);
|
|
62
63
|
this.nodes = new nodes_js_1.default(this.options.node_id);
|
|
63
64
|
this.observer = new top_observer_js_1.default(this, options);
|
|
@@ -80,11 +81,12 @@ class App {
|
|
|
80
81
|
this.session.applySessionHash(sessionToken);
|
|
81
82
|
}
|
|
82
83
|
try {
|
|
83
|
-
this.worker = new Worker(URL.createObjectURL(new Blob(['"use strict";class t{constructor(t,i,s,e=10,n=1e3,h){this.onUnauthorised=i,this.onFailure=s,this.MAX_ATTEMPTS_COUNT=e,this.ATTEMPT_TIMEOUT=n,this.onCompress=h,this.attemptsCount=0,this.busy=!1,this.queue=[],this.token=null,this.isCompressing=!1,this.ingestURL=t+"/v1/web/i",void 0!==h&&(this.isCompressing=!0)}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,i){this.attemptsCount>=this.MAX_ATTEMPTS_COUNT?this.onFailure(`Failed to send batch after ${this.attemptsCount} attempts.`):(this.attemptsCount++,setTimeout(()=>this.sendBatch(t,i),this.ATTEMPT_TIMEOUT*this.attemptsCount))}sendBatch(t,i){this.busy=!0;const s={Authorization:"Bearer "+this.token};i&&(s["Content-Encoding"]="gzip"),null!==this.token?fetch(this.ingestURL,{body:t,method:"POST",headers:s,keepalive:t.length<65536}).then(s=>{if(401===s.status)return this.busy=!1,void this.onUnauthorised();s.status>=400?this.retry(t,i):(this.attemptsCount=0,this.sendNext())}).catch(s=>{console.warn("OpenReplay:",s),this.retry(t,i)}):setTimeout(()=>{this.sendBatch(t,i)},500)}sendCompressed(t){this.sendBatch(t,!0)}sendUncompressed(t){this.sendBatch(t,!1)}clean(){this.queue.length=0,this.token=null}}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,h=0,r=0;r!==i;){if(n=t.charCodeAt(r),r+=1,n>=55296&&n<=56319){if(r===i){s[e+=1]=239,s[e+=1]=191,s[e+=1]=189;break}if(h=t.charCodeAt(r),!(h>=56320&&h<=57343)){s[e+=1]=239,s[e+=1]=191,s[e+=1]=189;continue}if(n=1024*(n-55296)+h-56320+65536,r+=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}get 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 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 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: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 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 50:return this.uint(t[1])&&this.string(t[2]);case 51:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3]);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 78:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4]);case 79:return this.string(t[1])&&this.string(t[2]);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 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 114:case 115:return this.uint(t[1]);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 e{constructor(){this.idx=1,this.backDict={}}getKey(t){let i=!1;return this.backDict[t]||(i=!0,this.backDict[t]=this.idx++),[this.backDict[t],i]}}class n{constructor(t,i,n,h){this.pageNo=t,this.timestamp=i,this.url=n,this.onBatch=h,this.nextIndex=0,this.beaconSize=2e5,this.encoder=new s(this.beaconSize),this.strDict=new e,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}applyDict(t){const[i,s]=this.strDict.getKey(t);return s&&this.writeMessage([50,i,t]),i}writeMessage(t){0===t[0]&&(this.timestamp=t[1]),4===t[0]&&(this.url=t[1]),12===t[0]&&(t=[51,t[1],this.applyDict(t[2]),this.applyDict(t[3])]),this.writeWithSize(t)||(this.finaliseBatch(),this.writeWithSize(t)||(this.encoder=new s(this.beaconSizeLimit),this.prepare(),this.writeWithSize(t)?this.finaliseBatch():console.warn("OpenReplay: beacon size overflow. Skipping large message.",t,this),this.encoder=new s(this.beaconSize),this.prepare()))}finaliseBatch(){this.isEmpty||(this.onBatch(this.encoder.flush()),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"}(h||(h={}));let r=null,u=null;function a(){u&&u.finaliseBatch()}function o(){h.Stopping,null!==p&&(clearInterval(p),p=null),u&&(u.clean(),u=null),r&&(r.clean(),r=null),h.NotActive}function c(){postMessage("restart"),o()}h.NotActive;let g,p=null;self.onmessage=({data:i})=>{if(null!=i){if("stop"===i)return a(),void o();if(!Array.isArray(i)){if("compressed"===i.type){if(!r)return console.debug("WebWorker: sender not initialised. Compressed batch."),void c();r.sendCompressed(i.batch)}if("uncompressed"===i.type){if(!r)return console.debug("WebWorker: sender not initialised. Uncompressed batch."),void c();r.sendUncompressed(i.batch)}return"start"===i.type?(h.Starting,r=new t(i.ingestPoint,()=>{c()},t=>{!function(t){postMessage({type:"failure",reason:t}),o()}(t)},i.connAttemptCount,i.connAttemptGap,t=>{postMessage({type:"compress",batch:t},[t.buffer])}),u=new n(i.pageNo,i.timestamp,i.url,t=>r&&r.push(t)),null===p&&(p=setInterval(a,1e4)),h.Active):"auth"===i.type?r?u?(r.authorise(i.token),void(i.beaconSizeLimit&&u.setBeaconSizeLimit(i.beaconSizeLimit))):(console.debug("WebWorker: writer not initialised. Received auth."),void c()):(console.debug("WebWorker: sender not initialised. Received auth."),void c()):void 0}if(null!==u){const t=u;i.forEach(i=>{55===i[0]&&(i[1]?g=setTimeout(()=>c(),18e5):clearTimeout(g)),t.writeMessage(i)})}u||(postMessage("not_init"),c())}else a()};'], { type: 'text/javascript' })));
|
|
84
|
+
this.worker = new Worker(URL.createObjectURL(new Blob(['"use strict";class t{constructor(t,i,s,e=10,n=1e3,r){this.onUnauthorised=i,this.onFailure=s,this.MAX_ATTEMPTS_COUNT=e,this.ATTEMPT_TIMEOUT=n,this.onCompress=r,this.attemptsCount=0,this.busy=!1,this.queue=[],this.token=null,this.ingestURL=t+"/v1/web/i",this.isCompressing=void 0!==r}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,i){this.attemptsCount>=this.MAX_ATTEMPTS_COUNT?this.onFailure(`Failed to send batch after ${this.attemptsCount} attempts.`):(this.attemptsCount++,setTimeout(()=>this.sendBatch(t,i),this.ATTEMPT_TIMEOUT*this.attemptsCount))}sendBatch(t,i){this.busy=!0;const s={Authorization:"Bearer "+this.token};i&&(s["Content-Encoding"]="gzip"),null!==this.token?fetch(this.ingestURL,{body:t,method:"POST",headers:s,keepalive:t.length<65536}).then(s=>{if(401===s.status)return this.busy=!1,void this.onUnauthorised();s.status>=400?this.retry(t,i):(this.attemptsCount=0,this.sendNext())}).catch(s=>{console.warn("OpenReplay:",s),this.retry(t,i)}):setTimeout(()=>{this.sendBatch(t,i)},500)}sendCompressed(t){this.sendBatch(t,!0)}sendUncompressed(t){this.sendBatch(t,!1)}clean(){this.sendNext(),setTimeout(()=>{this.token=null,this.queue.length=0},100)}}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}get 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 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 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: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 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 50:return this.uint(t[1])&&this.string(t[2]);case 51:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3]);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 78:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4]);case 79:return this.string(t[1])&&this.string(t[2]);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 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 114:case 115:return this.uint(t[1]);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 e{constructor(){this.idx=1,this.backDict={}}getKey(t){let i=!1;return this.backDict[t]||(i=!0,this.backDict[t]=this.idx++),[this.backDict[t],i]}}class n{constructor(t,i,n,r){this.pageNo=t,this.timestamp=i,this.url=n,this.onBatch=r,this.nextIndex=0,this.beaconSize=2e5,this.encoder=new s(this.beaconSize),this.strDict=new e,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}applyDict(t){const[i,s]=this.strDict.getKey(t);return s&&this.writeMessage([50,i,t]),i}writeMessage(t){0===t[0]&&(this.timestamp=t[1]),4===t[0]&&(this.url=t[1]),12===t[0]&&(t=[51,t[1],this.applyDict(t[2]),this.applyDict(t[3])]),this.writeWithSize(t)||(this.finaliseBatch(),this.writeWithSize(t)||(this.encoder=new s(this.beaconSizeLimit),this.prepare(),this.writeWithSize(t)?this.finaliseBatch():console.warn("OpenReplay: beacon size overflow. Skipping large message.",t,this),this.encoder=new s(this.beaconSize),this.prepare()))}finaliseBatch(){if(this.isEmpty)return;const t=this.encoder.flush();this.onBatch(t),this.prepare()}clean(){this.encoder.reset()}}var r;!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"}(r||(r={}));let h=null,u=null,a=r.NotActive;function o(){u&&u.finaliseBatch()}function c(){a=r.Stopping,null!==l&&(clearInterval(l),l=null),u&&(u.clean(),u=null),h&&(h.clean(),setTimeout(()=>{h=null},500)),a=r.NotActive}function g(){a!==r.Stopped&&(postMessage("restart"),c())}let p,l=null;self.onmessage=({data:i})=>{if(null!=i){if("stop"===i)return o(),c(),a=r.Stopped;if(!Array.isArray(i)){if("compressed"===i.type){if(!h)return console.debug("WebWorker: sender not initialised. Compressed batch."),void g();h.sendCompressed(i.batch)}if("uncompressed"===i.type){if(!h)return console.debug("WebWorker: sender not initialised. Uncompressed batch."),void g();h.sendUncompressed(i.batch)}return"start"===i.type?(a=r.Starting,h=new t(i.ingestPoint,()=>{g()},t=>{!function(t){postMessage({type:"failure",reason:t}),c()}(t)},i.connAttemptCount,i.connAttemptGap,t=>{postMessage({type:"compress",batch:t},[t.buffer])}),u=new n(i.pageNo,i.timestamp,i.url,t=>h&&h.push(t)),null===l&&(l=setInterval(o,1e4)),a=r.Active):"auth"===i.type?h?u?(h.authorise(i.token),void(i.beaconSizeLimit&&u.setBeaconSizeLimit(i.beaconSizeLimit))):(console.debug("WebWorker: writer not initialised. Received auth."),void g()):(console.debug("WebWorker: sender not initialised. Received auth."),void g()):void 0}if(null!==u){const t=u;i.forEach(i=>{55===i[0]&&(i[1]?p=setTimeout(()=>g(),18e5):clearTimeout(p)),t.writeMessage(i)})}u||(postMessage("not_init"),g())}else o()};'], { type: 'text/javascript' })));
|
|
84
85
|
this.worker.onerror = (e) => {
|
|
85
86
|
this._debug('webworker_error', e);
|
|
86
87
|
};
|
|
87
88
|
this.worker.onmessage = ({ data }) => {
|
|
89
|
+
var _a;
|
|
88
90
|
if (data === 'restart') {
|
|
89
91
|
this.stop(false);
|
|
90
92
|
void this.start({}, true);
|
|
@@ -101,6 +103,7 @@ class App {
|
|
|
101
103
|
const batchSize = batch.byteLength;
|
|
102
104
|
if (batchSize > this.compressionThreshold) {
|
|
103
105
|
(0, fflate_1.gzip)(data.batch, { mtime: 0 }, (err, result) => {
|
|
106
|
+
var _a;
|
|
104
107
|
if (err) {
|
|
105
108
|
console.error('Openreplay compression error:', err);
|
|
106
109
|
this.stop(false);
|
|
@@ -110,11 +113,11 @@ class App {
|
|
|
110
113
|
}
|
|
111
114
|
}
|
|
112
115
|
// @ts-ignore
|
|
113
|
-
this.worker
|
|
116
|
+
(_a = this.worker) === null || _a === void 0 ? void 0 : _a.postMessage({ type: 'compressed', batch: result });
|
|
114
117
|
});
|
|
115
118
|
}
|
|
116
119
|
else {
|
|
117
|
-
this.worker
|
|
120
|
+
(_a = this.worker) === null || _a === void 0 ? void 0 : _a.postMessage({ type: 'uncompressed', batch: batch });
|
|
118
121
|
}
|
|
119
122
|
}
|
|
120
123
|
};
|
|
@@ -217,8 +220,8 @@ class App {
|
|
|
217
220
|
if (useSafe) {
|
|
218
221
|
listener = this.safe(listener);
|
|
219
222
|
}
|
|
220
|
-
this.attachStartCallback(() => target
|
|
221
|
-
this.attachStopCallback(() => target
|
|
223
|
+
this.attachStartCallback(() => target === null || target === void 0 ? void 0 : target.addEventListener(type, listener, useCapture), useSafe);
|
|
224
|
+
this.attachStopCallback(() => target === null || target === void 0 ? void 0 : target.removeEventListener(type, listener, useCapture), useSafe);
|
|
222
225
|
}
|
|
223
226
|
// TODO: full correct semantic
|
|
224
227
|
checkRequiredVersion(version) {
|
|
@@ -247,10 +250,7 @@ class App {
|
|
|
247
250
|
};
|
|
248
251
|
}
|
|
249
252
|
getSessionInfo() {
|
|
250
|
-
return {
|
|
251
|
-
...this.session.getInfo(),
|
|
252
|
-
...this.getTrackerInfo(),
|
|
253
|
-
};
|
|
253
|
+
return Object.assign(Object.assign({}, this.session.getInfo()), this.getTrackerInfo());
|
|
254
254
|
}
|
|
255
255
|
getSessionToken() {
|
|
256
256
|
return this.session.getSessionToken();
|
|
@@ -268,7 +268,7 @@ class App {
|
|
|
268
268
|
const isSaas = /api\.openreplay\.com/.test(ingest);
|
|
269
269
|
const projectPath = isSaas ? 'https://openreplay.com/ingest' : ingest;
|
|
270
270
|
const url = projectPath.replace(/ingest$/, `${projectID}/session/${sessionID}`);
|
|
271
|
-
if (options
|
|
271
|
+
if (options === null || options === void 0 ? void 0 : options.withCurrentTime) {
|
|
272
272
|
const jumpTo = (0, utils_js_1.now)() - timestamp;
|
|
273
273
|
return `${url}?jumpto=${jumpTo}`;
|
|
274
274
|
}
|
|
@@ -281,6 +281,7 @@ class App {
|
|
|
281
281
|
return this.projectKey;
|
|
282
282
|
}
|
|
283
283
|
getBaseHref() {
|
|
284
|
+
var _a, _b;
|
|
284
285
|
if (typeof this.options.resourceBaseHref === 'string') {
|
|
285
286
|
return this.options.resourceBaseHref;
|
|
286
287
|
}
|
|
@@ -291,7 +292,7 @@ class App {
|
|
|
291
292
|
return document.baseURI;
|
|
292
293
|
}
|
|
293
294
|
// IE only
|
|
294
|
-
return (document.head
|
|
295
|
+
return (((_b = (_a = document.head) === null || _a === void 0 ? void 0 : _a.getElementsByTagName('base')[0]) === null || _b === void 0 ? void 0 : _b.getAttribute('href')) ||
|
|
295
296
|
location.origin + location.pathname);
|
|
296
297
|
}
|
|
297
298
|
resolveResourceURL(resourceURL) {
|
|
@@ -354,14 +355,8 @@ class App {
|
|
|
354
355
|
headers: {
|
|
355
356
|
'Content-Type': 'application/json',
|
|
356
357
|
},
|
|
357
|
-
body: JSON.stringify({
|
|
358
|
-
|
|
359
|
-
timestamp,
|
|
360
|
-
userID: this.session.getInfo().userID,
|
|
361
|
-
token: needNewSessionID ? undefined : this.session.getSessionToken(),
|
|
362
|
-
deviceMemory: performance_js_1.deviceMemory,
|
|
363
|
-
jsHeapSizeLimit: performance_js_1.jsHeapSizeLimit,
|
|
364
|
-
}),
|
|
358
|
+
body: JSON.stringify(Object.assign(Object.assign({}, this.getTrackerInfo()), { timestamp, userID: this.session.getInfo().userID, token: needNewSessionID ? undefined : this.session.getSessionToken(), deviceMemory: performance_js_1.deviceMemory,
|
|
359
|
+
jsHeapSizeLimit: performance_js_1.jsHeapSizeLimit })),
|
|
365
360
|
})
|
|
366
361
|
.then((r) => {
|
|
367
362
|
if (r.status === 200) {
|
|
@@ -26,6 +26,7 @@ class IFrameOffsets {
|
|
|
26
26
|
return this.calcOffset(state);
|
|
27
27
|
}
|
|
28
28
|
observe(iFrame) {
|
|
29
|
+
var _a;
|
|
29
30
|
const doc = iFrame.contentDocument;
|
|
30
31
|
if (!doc) {
|
|
31
32
|
return;
|
|
@@ -37,8 +38,9 @@ class IFrameOffsets {
|
|
|
37
38
|
iFrame,
|
|
38
39
|
parent: parentState || null,
|
|
39
40
|
clear: () => {
|
|
41
|
+
var _a;
|
|
40
42
|
parentDoc.removeEventListener('scroll', invalidateOffset);
|
|
41
|
-
parentDoc.defaultView
|
|
43
|
+
(_a = parentDoc.defaultView) === null || _a === void 0 ? void 0 : _a.removeEventListener('resize', invalidateOffset);
|
|
42
44
|
},
|
|
43
45
|
};
|
|
44
46
|
const invalidateOffset = () => {
|
|
@@ -46,7 +48,7 @@ class IFrameOffsets {
|
|
|
46
48
|
};
|
|
47
49
|
// anything more reliable? This does not cover all cases (layout changes are ignored, for ex.)
|
|
48
50
|
parentDoc.addEventListener('scroll', invalidateOffset);
|
|
49
|
-
parentDoc.defaultView
|
|
51
|
+
(_a = parentDoc.defaultView) === null || _a === void 0 ? void 0 : _a.addEventListener('resize', invalidateOffset);
|
|
50
52
|
this.states.set(doc, state);
|
|
51
53
|
}
|
|
52
54
|
clear() {
|
|
@@ -16,7 +16,7 @@ function isIgnored(node) {
|
|
|
16
16
|
if (tag === 'LINK') {
|
|
17
17
|
const rel = node.getAttribute('rel');
|
|
18
18
|
const as = node.getAttribute('as');
|
|
19
|
-
return !(rel
|
|
19
|
+
return !((rel === null || rel === void 0 ? void 0 : rel.includes('stylesheet')) || as === 'style' || as === 'font');
|
|
20
20
|
}
|
|
21
21
|
return (tag === 'SCRIPT' || tag === 'NOSCRIPT' || tag === 'META' || tag === 'TITLE' || tag === 'BASE');
|
|
22
22
|
}
|
package/cjs/index.js
CHANGED
|
@@ -142,7 +142,7 @@ class API {
|
|
|
142
142
|
// no-cors issue only with text/plain or not-set Content-Type
|
|
143
143
|
// req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
|
144
144
|
req.send(JSON.stringify({
|
|
145
|
-
trackerVersion: '7.0.
|
|
145
|
+
trackerVersion: '7.0.3',
|
|
146
146
|
projectKey: options.projectKey,
|
|
147
147
|
doNotTrack,
|
|
148
148
|
// TODO: add precise reason (an exact API missing)
|
|
@@ -33,6 +33,7 @@ interface AxiosResponse<T = any> {
|
|
|
33
33
|
response?: AxiosRequestConfig;
|
|
34
34
|
}
|
|
35
35
|
export interface AxiosInstance extends Record<string, any> {
|
|
36
|
+
getUri: (config?: AxiosRequestConfig) => string;
|
|
36
37
|
interceptors: {
|
|
37
38
|
request: AxiosInterceptorManager<InternalAxiosRequestConfig>;
|
|
38
39
|
response: AxiosInterceptorManager<AxiosResponse>;
|
package/cjs/modules/axiosSpy.js
CHANGED
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const messages_gen_js_1 = require("../app/messages.gen.js");
|
|
4
4
|
const utils_js_1 = require("../utils.js");
|
|
5
|
+
const exception_js_1 = require("./exception.js");
|
|
5
6
|
function default_1(app, instance, opts, sanitize, stringify) {
|
|
7
|
+
app.debug.log('Openreplay: attaching axios spy to instance', instance);
|
|
6
8
|
function captureResponseData(axiosResponseObj) {
|
|
7
|
-
|
|
9
|
+
app.debug.log('Openreplay: capturing axios response data', axiosResponseObj);
|
|
10
|
+
const { headers: reqHs, data: reqData, method, url, baseURL } = axiosResponseObj.config;
|
|
8
11
|
const { data: rData, headers: rHs, status: globStatus, response } = axiosResponseObj;
|
|
9
12
|
const { data: resData, headers: resHs, status: resStatus } = response || {};
|
|
10
13
|
const ihOpt = opts.ignoreHeaders;
|
|
@@ -58,13 +61,16 @@ function default_1(app, instance, opts, sanitize, stringify) {
|
|
|
58
61
|
},
|
|
59
62
|
});
|
|
60
63
|
if (!reqResInfo) {
|
|
64
|
+
app.debug.log('Openreplay: empty request/response info, skipping');
|
|
61
65
|
return;
|
|
62
66
|
}
|
|
63
67
|
const requestStart = axiosResponseObj.config.__openreplay_timing;
|
|
64
68
|
const duration = performance.now() - requestStart;
|
|
69
|
+
app.debug.log('Openreplay: final req object', reqResInfo);
|
|
65
70
|
app.send((0, messages_gen_js_1.NetworkRequest)('xhr', String(method), String(reqResInfo.url), stringify(reqResInfo.request), stringify(reqResInfo.response), reqResInfo.status, requestStart + (0, utils_js_1.getTimeOrigin)(), duration));
|
|
66
71
|
}
|
|
67
72
|
function getStartTime(config) {
|
|
73
|
+
app.debug.log('Openreplay: capturing API request', config);
|
|
68
74
|
config.__openreplay_timing = performance.now();
|
|
69
75
|
if (opts.sessionTokenHeader) {
|
|
70
76
|
const header = typeof opts.sessionTokenHeader === 'string'
|
|
@@ -84,16 +90,34 @@ function default_1(app, instance, opts, sanitize, stringify) {
|
|
|
84
90
|
return response;
|
|
85
91
|
}
|
|
86
92
|
function captureNetworkError(error) {
|
|
87
|
-
|
|
93
|
+
app.debug.log('Openreplay: capturing API request error', error);
|
|
94
|
+
if (isAxiosError(error)) {
|
|
95
|
+
captureResponseData(error.response);
|
|
96
|
+
}
|
|
97
|
+
else if (error instanceof Error) {
|
|
98
|
+
app.send((0, exception_js_1.getExceptionMessage)(error, []));
|
|
99
|
+
}
|
|
88
100
|
return Promise.reject(error);
|
|
89
101
|
}
|
|
90
|
-
|
|
102
|
+
function logRequestError(ev) {
|
|
103
|
+
app.debug.log('Openreplay: failed API request, skipping', ev);
|
|
104
|
+
}
|
|
105
|
+
const reqInt = instance.interceptors.request.use(getStartTime, logRequestError, {
|
|
106
|
+
synchronous: true,
|
|
107
|
+
});
|
|
91
108
|
const resInt = instance.interceptors.response.use(captureNetworkRequest, captureNetworkError, {
|
|
92
109
|
synchronous: true,
|
|
93
110
|
});
|
|
94
111
|
app.attachStopCallback(() => {
|
|
95
|
-
|
|
96
|
-
instance.interceptors.
|
|
112
|
+
var _a, _b, _c, _d;
|
|
113
|
+
(_b = (_a = instance.interceptors.request).eject) === null || _b === void 0 ? void 0 : _b.call(_a, reqInt);
|
|
114
|
+
(_d = (_c = instance.interceptors.response).eject) === null || _d === void 0 ? void 0 : _d.call(_c, resInt);
|
|
97
115
|
});
|
|
98
116
|
}
|
|
99
117
|
exports.default = default_1;
|
|
118
|
+
function isAxiosError(payload) {
|
|
119
|
+
return isObject(payload) && payload.isAxiosError === true;
|
|
120
|
+
}
|
|
121
|
+
function isObject(thing) {
|
|
122
|
+
return thing !== null && typeof thing === 'object';
|
|
123
|
+
}
|
|
@@ -72,15 +72,12 @@ function default_1(app) {
|
|
|
72
72
|
function patchAdoptedStyleSheets(prototype) {
|
|
73
73
|
const nativeAdoptedStyleSheetsDescriptor = Object.getOwnPropertyDescriptor(prototype, 'adoptedStyleSheets');
|
|
74
74
|
if (nativeAdoptedStyleSheetsDescriptor) {
|
|
75
|
-
Object.defineProperty(prototype, 'adoptedStyleSheets', {
|
|
76
|
-
...nativeAdoptedStyleSheetsDescriptor,
|
|
77
|
-
set: function (value) {
|
|
75
|
+
Object.defineProperty(prototype, 'adoptedStyleSheets', Object.assign(Object.assign({}, nativeAdoptedStyleSheetsDescriptor), { set: function (value) {
|
|
78
76
|
// @ts-ignore
|
|
79
77
|
const retVal = nativeAdoptedStyleSheetsDescriptor.set.call(this, value);
|
|
80
78
|
sendAdoptedStyleSheetsUpdate(this);
|
|
81
79
|
return retVal;
|
|
82
|
-
}
|
|
83
|
-
});
|
|
80
|
+
} }));
|
|
84
81
|
}
|
|
85
82
|
}
|
|
86
83
|
const patchContext = (context) => {
|
package/cjs/modules/mouse.js
CHANGED
|
@@ -4,21 +4,16 @@ const guards_js_1 = require("../app/guards.js");
|
|
|
4
4
|
const utils_js_1 = require("../utils.js");
|
|
5
5
|
const messages_gen_js_1 = require("../app/messages.gen.js");
|
|
6
6
|
const input_js_1 = require("./input.js");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
async function _getSelector(target, document, options) {
|
|
11
|
-
if (!finderLib) {
|
|
12
|
-
const { finder } = await import('@medv/finder');
|
|
13
|
-
finderLib = finder;
|
|
14
|
-
}
|
|
15
|
-
return finderLib(target, {
|
|
7
|
+
const finder_1 = require("@medv/finder");
|
|
8
|
+
function _getSelector(target, document, options) {
|
|
9
|
+
const selector = (0, finder_1.finder)(target, {
|
|
16
10
|
root: document.body,
|
|
17
11
|
seedMinLength: 3,
|
|
18
|
-
optimizedMinLength: options
|
|
19
|
-
threshold: options
|
|
20
|
-
maxNumberOfTries: options
|
|
12
|
+
optimizedMinLength: (options === null || options === void 0 ? void 0 : options.minSelectorDepth) || 2,
|
|
13
|
+
threshold: (options === null || options === void 0 ? void 0 : options.nthThreshold) || 1000,
|
|
14
|
+
maxNumberOfTries: (options === null || options === void 0 ? void 0 : options.maxOptimiseTries) || 10000,
|
|
21
15
|
});
|
|
16
|
+
return selector;
|
|
22
17
|
}
|
|
23
18
|
function isClickable(element) {
|
|
24
19
|
const tag = element.tagName.toUpperCase();
|
|
@@ -138,12 +133,8 @@ function default_1(app, options) {
|
|
|
138
133
|
}
|
|
139
134
|
};
|
|
140
135
|
const patchDocument = (document, topframe = false) => {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
return selectorMap[id];
|
|
144
|
-
}
|
|
145
|
-
const selector = await _getSelector(target, document, options);
|
|
146
|
-
return selector;
|
|
136
|
+
function getSelector(id, target, options) {
|
|
137
|
+
return (selectorMap[id] = selectorMap[id] || _getSelector(target, document, options));
|
|
147
138
|
}
|
|
148
139
|
const attachListener = topframe
|
|
149
140
|
? app.attachEventListener.bind(app) // attached/removed on start/stop
|
|
@@ -167,7 +158,7 @@ function default_1(app, options) {
|
|
|
167
158
|
directionChangeCount++;
|
|
168
159
|
}
|
|
169
160
|
}, false);
|
|
170
|
-
attachListener(document, 'click',
|
|
161
|
+
attachListener(document, 'click', (e) => {
|
|
171
162
|
const target = getTarget(e.target, document);
|
|
172
163
|
if ((!e.clientX && !e.clientY) || target === null) {
|
|
173
164
|
return;
|
|
@@ -175,7 +166,7 @@ function default_1(app, options) {
|
|
|
175
166
|
const id = app.nodes.getID(target);
|
|
176
167
|
if (id !== undefined) {
|
|
177
168
|
sendMouseMove();
|
|
178
|
-
app.send((0, messages_gen_js_1.MouseClick)(id, mouseTarget === target ? Math.round(performance.now() - mouseTargetTime) : 0, getTargetLabel(target), isClickable(target) && !disableClickmaps ?
|
|
169
|
+
app.send((0, messages_gen_js_1.MouseClick)(id, mouseTarget === target ? Math.round(performance.now() - mouseTargetTime) : 0, getTargetLabel(target), isClickable(target) && !disableClickmaps ? getSelector(id, target, options) : ''), true);
|
|
179
170
|
}
|
|
180
171
|
mouseTarget = null;
|
|
181
172
|
});
|
|
@@ -186,6 +177,6 @@ function default_1(app, options) {
|
|
|
186
177
|
}
|
|
187
178
|
});
|
|
188
179
|
patchDocument(document, true);
|
|
189
|
-
app.ticker.attach(sendMouseMove, options
|
|
180
|
+
app.ticker.attach(sendMouseMove, (options === null || options === void 0 ? void 0 : options.trackingOffset) || 7);
|
|
190
181
|
}
|
|
191
182
|
exports.default = default_1;
|
package/cjs/modules/network.js
CHANGED
|
@@ -49,7 +49,7 @@ function default_1(app, opts = {}) {
|
|
|
49
49
|
try {
|
|
50
50
|
reqResInfo.response.body = JSON.parse(resBody);
|
|
51
51
|
}
|
|
52
|
-
catch { }
|
|
52
|
+
catch (_a) { }
|
|
53
53
|
}
|
|
54
54
|
return options.sanitizer(reqResInfo);
|
|
55
55
|
}
|
|
@@ -60,7 +60,7 @@ function default_1(app, opts = {}) {
|
|
|
60
60
|
try {
|
|
61
61
|
r.body = JSON.stringify(r.body);
|
|
62
62
|
}
|
|
63
|
-
catch {
|
|
63
|
+
catch (_a) {
|
|
64
64
|
r.body = '<unable to stringify>';
|
|
65
65
|
app.notify.warn("Openreplay fetch couldn't stringify body:", r.body);
|
|
66
66
|
}
|
|
@@ -160,14 +160,16 @@ function default_1(app, opts = {}) {
|
|
|
160
160
|
xhr.addEventListener('load', app.safe((e) => {
|
|
161
161
|
const { headers: reqHs, body: reqBody } = getXHRRequestDataObject(xhr);
|
|
162
162
|
const duration = startTime > 0 ? e.timeStamp - startTime : 0;
|
|
163
|
-
const hString =
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
163
|
+
const hString = xhr.getAllResponseHeaders() || ''; // might be null (only if no response received though)
|
|
164
|
+
const headersArr = hString.trim().split(/[\r\n]+/);
|
|
165
|
+
const headerMap = {};
|
|
166
|
+
headersArr.forEach(function (line) {
|
|
167
|
+
const parts = line.split(': ');
|
|
168
|
+
const header = parts.shift();
|
|
169
|
+
if (!isHIgnored(header)) {
|
|
170
|
+
headerMap[header] = parts.join(': ');
|
|
171
|
+
}
|
|
172
|
+
});
|
|
171
173
|
const method = strMethod(initMethod);
|
|
172
174
|
const reqResInfo = sanitize({
|
|
173
175
|
url: String(url),
|
|
@@ -178,7 +180,7 @@ function default_1(app, opts = {}) {
|
|
|
178
180
|
body: reqBody,
|
|
179
181
|
},
|
|
180
182
|
response: {
|
|
181
|
-
headers:
|
|
183
|
+
headers: headerMap,
|
|
182
184
|
body: xhr.response,
|
|
183
185
|
},
|
|
184
186
|
});
|
package/cjs/utils.js
CHANGED
|
@@ -70,8 +70,9 @@ function hasOpenreplayAttribute(e, attr) {
|
|
|
70
70
|
}
|
|
71
71
|
exports.hasOpenreplayAttribute = hasOpenreplayAttribute;
|
|
72
72
|
function isIframeCrossdomain(e) {
|
|
73
|
+
var _a;
|
|
73
74
|
try {
|
|
74
|
-
return e.contentWindow
|
|
75
|
+
return ((_a = e.contentWindow) === null || _a === void 0 ? void 0 : _a.location.href) !== window.location.href;
|
|
75
76
|
}
|
|
76
77
|
catch (e) {
|
|
77
78
|
return true;
|