@openreplay/tracker 3.6.3 → 3.6.5
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/.eslintignore +8 -0
- package/cjs/app/guards.js +1 -2
- package/cjs/app/index.d.ts +15 -13
- package/cjs/app/index.js +56 -40
- package/cjs/app/logger.js +6 -3
- package/cjs/app/observer/iframe_observer.d.ts +1 -1
- package/cjs/app/observer/iframe_observer.js +1 -1
- package/cjs/app/observer/observer.d.ts +2 -3
- package/cjs/app/observer/observer.js +38 -40
- package/cjs/app/observer/shadow_root_observer.d.ts +1 -1
- package/cjs/app/observer/shadow_root_observer.js +1 -1
- package/cjs/app/observer/top_observer.d.ts +2 -2
- package/cjs/app/observer/top_observer.js +12 -11
- package/cjs/app/sanitizer.d.ts +1 -1
- package/cjs/app/sanitizer.js +5 -5
- package/cjs/app/session.d.ts +14 -2
- package/cjs/app/session.js +19 -6
- package/cjs/app/ticker.d.ts +1 -1
- package/cjs/common/messages.d.ts +1 -1
- package/cjs/common/messages.js +69 -120
- package/cjs/common/webworker.d.ts +3 -3
- package/cjs/index.d.ts +9 -8
- package/cjs/index.js +34 -28
- package/cjs/modules/connection.d.ts +1 -1
- package/cjs/modules/console.d.ts +1 -1
- package/cjs/modules/console.js +5 -5
- package/cjs/modules/cssrules.d.ts +1 -1
- package/cjs/modules/cssrules.js +3 -3
- package/cjs/modules/exception.d.ts +2 -2
- package/cjs/modules/exception.js +7 -6
- package/cjs/modules/img.d.ts +1 -1
- package/cjs/modules/img.js +15 -12
- package/cjs/modules/input.d.ts +1 -1
- package/cjs/modules/input.js +15 -15
- package/cjs/modules/longtasks.d.ts +1 -1
- package/cjs/modules/longtasks.js +13 -5
- package/cjs/modules/mouse.d.ts +1 -1
- package/cjs/modules/mouse.js +10 -12
- package/cjs/modules/performance.d.ts +1 -1
- package/cjs/modules/scroll.d.ts +1 -1
- package/cjs/modules/timing.d.ts +1 -1
- package/cjs/modules/timing.js +12 -24
- package/cjs/modules/viewport.d.ts +1 -1
- package/cjs/utils.js +7 -7
- package/cjs/vendors/finder/finder.js +53 -48
- package/lib/app/guards.js +1 -2
- package/lib/app/index.d.ts +15 -13
- package/lib/app/index.js +65 -49
- package/lib/app/logger.js +6 -3
- package/lib/app/observer/iframe_observer.d.ts +1 -1
- package/lib/app/observer/iframe_observer.js +3 -3
- package/lib/app/observer/observer.d.ts +2 -3
- package/lib/app/observer/observer.js +40 -42
- package/lib/app/observer/shadow_root_observer.d.ts +1 -1
- package/lib/app/observer/shadow_root_observer.js +3 -3
- package/lib/app/observer/top_observer.d.ts +2 -2
- package/lib/app/observer/top_observer.js +17 -16
- package/lib/app/sanitizer.d.ts +1 -1
- package/lib/app/sanitizer.js +7 -7
- package/lib/app/session.d.ts +14 -2
- package/lib/app/session.js +19 -6
- package/lib/app/ticker.d.ts +1 -1
- package/lib/common/messages.d.ts +1 -1
- package/lib/common/messages.js +69 -120
- package/lib/common/tsconfig.tsbuildinfo +1 -1
- package/lib/common/webworker.d.ts +3 -3
- package/lib/index.d.ts +9 -8
- package/lib/index.js +49 -43
- package/lib/modules/connection.d.ts +1 -1
- package/lib/modules/connection.js +1 -1
- package/lib/modules/console.d.ts +1 -1
- package/lib/modules/console.js +8 -8
- package/lib/modules/cssrules.d.ts +1 -1
- package/lib/modules/cssrules.js +5 -5
- package/lib/modules/exception.d.ts +2 -2
- package/lib/modules/exception.js +8 -7
- package/lib/modules/img.d.ts +1 -1
- package/lib/modules/img.js +18 -15
- package/lib/modules/input.d.ts +1 -1
- package/lib/modules/input.js +18 -18
- package/lib/modules/longtasks.d.ts +1 -1
- package/lib/modules/longtasks.js +14 -6
- package/lib/modules/mouse.d.ts +1 -1
- package/lib/modules/mouse.js +14 -16
- package/lib/modules/performance.d.ts +1 -1
- package/lib/modules/performance.js +2 -2
- package/lib/modules/scroll.d.ts +1 -1
- package/lib/modules/scroll.js +2 -2
- package/lib/modules/timing.d.ts +1 -1
- package/lib/modules/timing.js +15 -27
- package/lib/modules/viewport.d.ts +1 -1
- package/lib/modules/viewport.js +1 -1
- package/lib/utils.js +7 -7
- package/lib/vendors/finder/finder.js +53 -48
- package/package.json +28 -10
package/.eslintignore
ADDED
package/cjs/app/guards.js
CHANGED
|
@@ -14,8 +14,7 @@ function isTextNode(node) {
|
|
|
14
14
|
}
|
|
15
15
|
exports.isTextNode = isTextNode;
|
|
16
16
|
function isRootNode(node) {
|
|
17
|
-
return node.nodeType === Node.DOCUMENT_NODE ||
|
|
18
|
-
node.nodeType === Node.DOCUMENT_FRAGMENT_NODE;
|
|
17
|
+
return node.nodeType === Node.DOCUMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE;
|
|
19
18
|
}
|
|
20
19
|
exports.isRootNode = isRootNode;
|
|
21
20
|
function hasTag(el, tagName) {
|
package/cjs/app/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type Message from
|
|
2
|
-
import Nodes from
|
|
3
|
-
import Sanitizer from
|
|
4
|
-
import Ticker from
|
|
5
|
-
import Logger from
|
|
6
|
-
import Session from
|
|
7
|
-
import type { Options as ObserverOptions } from
|
|
8
|
-
import type { Options as SanitizerOptions } from
|
|
9
|
-
import type { Options as LoggerOptions } from
|
|
10
|
-
import type { Options as WebworkerOptions } from
|
|
1
|
+
import type Message from '../common/messages.js';
|
|
2
|
+
import Nodes from './nodes.js';
|
|
3
|
+
import Sanitizer from './sanitizer.js';
|
|
4
|
+
import Ticker from './ticker.js';
|
|
5
|
+
import Logger from './logger.js';
|
|
6
|
+
import Session from './session.js';
|
|
7
|
+
import type { Options as ObserverOptions } from './observer/top_observer.js';
|
|
8
|
+
import type { Options as SanitizerOptions } from './sanitizer.js';
|
|
9
|
+
import type { Options as LoggerOptions } from './logger.js';
|
|
10
|
+
import type { Options as WebworkerOptions } from '../common/webworker.js';
|
|
11
11
|
export interface StartOptions {
|
|
12
12
|
userID?: string;
|
|
13
13
|
metadata?: Record<string, string>;
|
|
@@ -68,7 +68,7 @@ export default class App {
|
|
|
68
68
|
private readonly options;
|
|
69
69
|
private readonly revID;
|
|
70
70
|
private activityState;
|
|
71
|
-
private version;
|
|
71
|
+
private readonly version;
|
|
72
72
|
private readonly worker?;
|
|
73
73
|
constructor(projectKey: string, sessionToken: string | null | undefined, options: Partial<Options>);
|
|
74
74
|
private _debug;
|
|
@@ -77,7 +77,7 @@ export default class App {
|
|
|
77
77
|
safe<T extends (...args: any[]) => void>(fn: T): T;
|
|
78
78
|
attachCommitCallback(cb: CommitCallback): void;
|
|
79
79
|
attachStartCallback(cb: StartCallback): void;
|
|
80
|
-
attachStopCallback(cb:
|
|
80
|
+
attachStopCallback(cb: () => any): void;
|
|
81
81
|
attachEventListener(target: EventTarget, type: string, listener: EventListener, useSafe?: boolean, useCapture?: boolean): void;
|
|
82
82
|
checkRequiredVersion(version: string): boolean;
|
|
83
83
|
private getStartInfo;
|
|
@@ -88,12 +88,14 @@ export default class App {
|
|
|
88
88
|
timestamp: number;
|
|
89
89
|
trackerVersion: string;
|
|
90
90
|
isSnippet: boolean;
|
|
91
|
-
sessionID: string |
|
|
91
|
+
sessionID: string | undefined;
|
|
92
92
|
metadata: Record<string, string>;
|
|
93
93
|
userID: string | null;
|
|
94
|
+
projectID?: string | undefined;
|
|
94
95
|
};
|
|
95
96
|
getSessionToken(): string | undefined;
|
|
96
97
|
getSessionID(): string | undefined;
|
|
98
|
+
getSessionURL(): string | undefined;
|
|
97
99
|
getHost(): string;
|
|
98
100
|
getProjectKey(): string;
|
|
99
101
|
getBaseHref(): string;
|
package/cjs/app/index.js
CHANGED
|
@@ -10,8 +10,8 @@ const ticker_js_1 = require("./ticker.js");
|
|
|
10
10
|
const logger_js_1 = require("./logger.js");
|
|
11
11
|
const session_js_1 = require("./session.js");
|
|
12
12
|
const performance_js_1 = require("../modules/performance.js");
|
|
13
|
-
const CANCELED =
|
|
14
|
-
const START_ERROR =
|
|
13
|
+
const CANCELED = 'canceled';
|
|
14
|
+
const START_ERROR = ':(';
|
|
15
15
|
const UnsuccessfulStart = (reason) => ({ reason, success: false });
|
|
16
16
|
const SuccessfulStart = (body) => (Object.assign(Object.assign({}, body), { success: true }));
|
|
17
17
|
var ActivityState;
|
|
@@ -32,7 +32,7 @@ class App {
|
|
|
32
32
|
this.stopCallbacks = [];
|
|
33
33
|
this.commitCallbacks = [];
|
|
34
34
|
this.activityState = ActivityState.NotActive;
|
|
35
|
-
this.version = '3.6.
|
|
35
|
+
this.version = '3.6.4'; // TODO: version compatability check inside each plugin.
|
|
36
36
|
this.projectKey = projectKey;
|
|
37
37
|
this.options = Object.assign({
|
|
38
38
|
revID: '',
|
|
@@ -57,9 +57,10 @@ class App {
|
|
|
57
57
|
this.ticker.attach(() => this.commit());
|
|
58
58
|
this.debug = new logger_js_1.default(this.options.__debug__);
|
|
59
59
|
this.notify = new logger_js_1.default(this.options.verbose ? logger_js_1.LogLevel.Warnings : logger_js_1.LogLevel.Silent);
|
|
60
|
-
this.session = new session_js_1.default();
|
|
60
|
+
this.session = new session_js_1.default(this, this.options);
|
|
61
61
|
this.session.attachUpdateCallback(({ userID, metadata }) => {
|
|
62
|
-
if (userID != null) {
|
|
62
|
+
if (userID != null) {
|
|
63
|
+
// TODO: nullable userID
|
|
63
64
|
this.send(new messages_js_1.UserID(userID));
|
|
64
65
|
}
|
|
65
66
|
if (metadata != null) {
|
|
@@ -72,17 +73,16 @@ class App {
|
|
|
72
73
|
this.sessionStorage.setItem(this.options.session_token_key, sessionToken);
|
|
73
74
|
}
|
|
74
75
|
try {
|
|
75
|
-
this.worker = new Worker(URL.createObjectURL(new Blob([`"use strict";function t(t){function i(...i){return new t(...i)}return i.prototype=t.prototype,i}const i=new Map;const s=t(class{constructor(t,i,s){this.pageNo=t,this.firstIndex=i,this.timestamp=s,this._id=80}encode(t){return t.uint(80)&&t.uint(this.pageNo)&&t.uint(this.firstIndex)&&t.int(this.timestamp)}});i.set(80,s);const e=t(class{constructor(t){this.timestamp=t,this._id=0}encode(t){return t.uint(0)&&t.uint(this.timestamp)}});i.set(0,e);const n=t(class{constructor(t,i,s){this.url=t,this.referrer=i,this.navigationStart=s,this._id=4}encode(t){return t.uint(4)&&t.string(this.url)&&t.string(this.referrer)&&t.uint(this.navigationStart)}});i.set(4,n);const r=t(class{constructor(t,i){this.width=t,this.height=i,this._id=5}encode(t){return t.uint(5)&&t.uint(this.width)&&t.uint(this.height)}});i.set(5,r);const h=t(class{constructor(t,i){this.x=t,this.y=i,this._id=6}encode(t){return t.uint(6)&&t.int(this.x)&&t.int(this.y)}});i.set(6,h);const o=t(class{constructor(){this._id=7}encode(t){return t.uint(7)}});i.set(7,o);const c=t(class{constructor(t,i,s,e,n){this.id=t,this.parentID=i,this.index=s,this.tag=e,this.svg=n,this._id=8}encode(t){return t.uint(8)&&t.uint(this.id)&&t.uint(this.parentID)&&t.uint(this.index)&&t.string(this.tag)&&t.boolean(this.svg)}});i.set(8,c);const a=t(class{constructor(t,i,s){this.id=t,this.parentID=i,this.index=s,this._id=9}encode(t){return t.uint(9)&&t.uint(this.id)&&t.uint(this.parentID)&&t.uint(this.index)}});i.set(9,a);const u=t(class{constructor(t,i,s){this.id=t,this.parentID=i,this.index=s,this._id=10}encode(t){return t.uint(10)&&t.uint(this.id)&&t.uint(this.parentID)&&t.uint(this.index)}});i.set(10,u);const d=t(class{constructor(t){this.id=t,this._id=11}encode(t){return t.uint(11)&&t.uint(this.id)}});i.set(11,d);const l=t(class{constructor(t,i,s){this.id=t,this.name=i,this.value=s,this._id=12}encode(t){return t.uint(12)&&t.uint(this.id)&&t.string(this.name)&&t.string(this.value)}});i.set(12,l);const p=t(class{constructor(t,i){this.id=t,this.name=i,this._id=13}encode(t){return t.uint(13)&&t.uint(this.id)&&t.string(this.name)}});i.set(13,p);const g=t(class{constructor(t,i){this.id=t,this.data=i,this._id=14}encode(t){return t.uint(14)&&t.uint(this.id)&&t.string(this.data)}});i.set(14,g);const m=t(class{constructor(t,i,s){this.id=t,this.x=i,this.y=s,this._id=16}encode(t){return t.uint(16)&&t.uint(this.id)&&t.int(this.x)&&t.int(this.y)}});i.set(16,m);const f=t(class{constructor(t,i){this.id=t,this.label=i,this._id=17}encode(t){return t.uint(17)&&t.uint(this.id)&&t.string(this.label)}});i.set(17,f);const y=t(class{constructor(t,i,s){this.id=t,this.value=i,this.mask=s,this._id=18}encode(t){return t.uint(18)&&t.uint(this.id)&&t.string(this.value)&&t.int(this.mask)}});i.set(18,y);const _=t(class{constructor(t,i){this.id=t,this.checked=i,this._id=19}encode(t){return t.uint(19)&&t.uint(this.id)&&t.boolean(this.checked)}});i.set(19,_);const v=t(class{constructor(t,i){this.x=t,this.y=i,this._id=20}encode(t){return t.uint(20)&&t.uint(this.x)&&t.uint(this.y)}});i.set(20,v);const S=t(class{constructor(t,i){this.level=t,this.value=i,this._id=22}encode(t){return t.uint(22)&&t.string(this.level)&&t.string(this.value)}});i.set(22,S);const b=t(class{constructor(t,i,s,e,n,r,h,o,c){this.requestStart=t,this.responseStart=i,this.responseEnd=s,this.domContentLoadedEventStart=e,this.domContentLoadedEventEnd=n,this.loadEventStart=r,this.loadEventEnd=h,this.firstPaint=o,this.firstContentfulPaint=c,this._id=23}encode(t){return t.uint(23)&&t.uint(this.requestStart)&&t.uint(this.responseStart)&&t.uint(this.responseEnd)&&t.uint(this.domContentLoadedEventStart)&&t.uint(this.domContentLoadedEventEnd)&&t.uint(this.loadEventStart)&&t.uint(this.loadEventEnd)&&t.uint(this.firstPaint)&&t.uint(this.firstContentfulPaint)}});i.set(23,b);const w=t(class{constructor(t,i,s){this.speedIndex=t,this.visuallyComplete=i,this.timeToInteractive=s,this._id=24}encode(t){return t.uint(24)&&t.uint(this.speedIndex)&&t.uint(this.visuallyComplete)&&t.uint(this.timeToInteractive)}});i.set(24,w);const E=t(class{constructor(t,i,s){this.name=t,this.message=i,this.payload=s,this._id=25}encode(t){return t.uint(25)&&t.string(this.name)&&t.string(this.message)&&t.string(this.payload)}});i.set(25,E);const x=t(class{constructor(t,i){this.name=t,this.payload=i,this._id=27}encode(t){return t.uint(27)&&t.string(this.name)&&t.string(this.payload)}});i.set(27,x);const T=t(class{constructor(t){this.id=t,this._id=28}encode(t){return t.uint(28)&&t.string(this.id)}});i.set(28,T);const z=t(class{constructor(t){this.id=t,this._id=29}encode(t){return t.uint(29)&&t.string(this.id)}});i.set(29,z);const k=t(class{constructor(t,i){this.key=t,this.value=i,this._id=30}encode(t){return t.uint(30)&&t.string(this.key)&&t.string(this.value)}});i.set(30,k);const A=t(class{constructor(t,i,s){this.id=t,this.rule=i,this.index=s,this._id=37}encode(t){return t.uint(37)&&t.uint(this.id)&&t.string(this.rule)&&t.uint(this.index)}});i.set(37,A);const I=t(class{constructor(t,i){this.id=t,this.index=i,this._id=38}encode(t){return t.uint(38)&&t.uint(this.id)&&t.uint(this.index)}});i.set(38,I);const L=t(class{constructor(t,i,s,e,n,r,h){this.method=t,this.url=i,this.request=s,this.response=e,this.status=n,this.timestamp=r,this.duration=h,this._id=39}encode(t){return t.uint(39)&&t.string(this.method)&&t.string(this.url)&&t.string(this.request)&&t.string(this.response)&&t.uint(this.status)&&t.uint(this.timestamp)&&t.uint(this.duration)}});i.set(39,L);const C=t(class{constructor(t,i,s,e){this.name=t,this.duration=i,this.args=s,this.result=e,this._id=40}encode(t){return t.uint(40)&&t.string(this.name)&&t.uint(this.duration)&&t.string(this.args)&&t.string(this.result)}});i.set(40,C);const M=t(class{constructor(t,i){this.key=t,this.value=i,this._id=41}encode(t){return t.uint(41)&&t.string(this.key)&&t.string(this.value)}});i.set(41,M);const N=t(class{constructor(t){this.type=t,this._id=42}encode(t){return t.uint(42)&&t.string(this.type)}});i.set(42,N);const B=t(class{constructor(t,i,s){this.action=t,this.state=i,this.duration=s,this._id=44}encode(t){return t.uint(44)&&t.string(this.action)&&t.string(this.state)&&t.uint(this.duration)}});i.set(44,B);const U=t(class{constructor(t,i){this.mutation=t,this.state=i,this._id=45}encode(t){return t.uint(45)&&t.string(this.mutation)&&t.string(this.state)}});i.set(45,U);const R=t(class{constructor(t,i){this.type=t,this.payload=i,this._id=46}encode(t){return t.uint(46)&&t.string(this.type)&&t.string(this.payload)}});i.set(46,R);const O=t(class{constructor(t,i,s){this.action=t,this.state=i,this.duration=s,this._id=47}encode(t){return t.uint(47)&&t.string(this.action)&&t.string(this.state)&&t.uint(this.duration)}});i.set(47,O);const P=t(class{constructor(t,i,s,e){this.operationKind=t,this.operationName=i,this.variables=s,this.response=e,this._id=48}encode(t){return t.uint(48)&&t.string(this.operationKind)&&t.string(this.operationName)&&t.string(this.variables)&&t.string(this.response)}});i.set(48,P);const q=t(class{constructor(t,i,s,e){this.frames=t,this.ticks=i,this.totalJSHeapSize=s,this.usedJSHeapSize=e,this._id=49}encode(t){return t.uint(49)&&t.int(this.frames)&&t.int(this.ticks)&&t.uint(this.totalJSHeapSize)&&t.uint(this.usedJSHeapSize)}});i.set(49,q);const D=t(class{constructor(t,i,s,e,n,r,h,o){this.timestamp=t,this.duration=i,this.ttfb=s,this.headerSize=e,this.encodedBodySize=n,this.decodedBodySize=r,this.url=h,this.initiator=o,this._id=53}encode(t){return t.uint(53)&&t.uint(this.timestamp)&&t.uint(this.duration)&&t.uint(this.ttfb)&&t.uint(this.headerSize)&&t.uint(this.encodedBodySize)&&t.uint(this.decodedBodySize)&&t.string(this.url)&&t.string(this.initiator)}});i.set(53,D);const W=t(class{constructor(t,i){this.downlink=t,this.type=i,this._id=54}encode(t){return t.uint(54)&&t.uint(this.downlink)&&t.string(this.type)}});i.set(54,W);const H=t(class{constructor(t){this.hidden=t,this._id=55}encode(t){return t.uint(55)&&t.boolean(this.hidden)}});i.set(55,H);const J=t(class{constructor(t,i,s,e,n,r,h){this.timestamp=t,this.duration=i,this.context=s,this.containerType=e,this.containerSrc=n,this.containerId=r,this.containerName=h,this._id=59}encode(t){return t.uint(59)&&t.uint(this.timestamp)&&t.uint(this.duration)&&t.uint(this.context)&&t.uint(this.containerType)&&t.string(this.containerSrc)&&t.string(this.containerId)&&t.string(this.containerName)}});i.set(59,J);const F=t(class{constructor(t,i,s,e){this.id=t,this.name=i,this.value=s,this.baseURL=e,this._id=60}encode(t){return t.uint(60)&&t.uint(this.id)&&t.string(this.name)&&t.string(this.value)&&t.string(this.baseURL)}});i.set(60,F);const X=t(class{constructor(t,i,s){this.id=t,this.data=i,this.baseURL=s,this._id=61}encode(t){return t.uint(61)&&t.uint(this.id)&&t.string(this.data)&&t.string(this.baseURL)}});i.set(61,X);const G=t(class{constructor(t,i){this.type=t,this.value=i,this._id=63}encode(t){return t.uint(63)&&t.string(this.type)&&t.string(this.value)}});i.set(63,G);const K=t(class{constructor(t,i){this.name=t,this.payload=i,this._id=64}encode(t){return t.uint(64)&&t.string(this.name)&&t.string(this.payload)}});i.set(64,K);const j=t(class{constructor(){this._id=65}encode(t){return t.uint(65)}});i.set(65,j);const Q=t(class{constructor(t,i,s,e){this.id=t,this.rule=i,this.index=s,this.baseURL=e,this._id=67}encode(t){return t.uint(67)&&t.uint(this.id)&&t.string(this.rule)&&t.uint(this.index)&&t.string(this.baseURL)}});i.set(67,Q);const V=t(class{constructor(t,i,s,e){this.id=t,this.hesitationTime=i,this.label=s,this.selector=e,this._id=69}encode(t){return t.uint(69)&&t.uint(this.id)&&t.uint(this.hesitationTime)&&t.string(this.label)&&t.string(this.selector)}});i.set(69,V);const Y=t(class{constructor(t,i){this.frameID=t,this.id=i,this._id=70}encode(t){return t.uint(70)&&t.uint(this.frameID)&&t.uint(this.id)}});i.set(70,Y);class Z{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 tt="function"==typeof TextEncoder?new TextEncoder:{encode(t){const i=t.length,s=new Uint8Array(3*i);let e=-1;for(var 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))>=56320&&r<=57343)){s[e+=1]=239,s[e+=1]=191,s[e+=1]=189;continue}if(h+=1,(n=1024*(n-55296)+r-56320+65536)>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 it{constructor(t){this.size=t,this.offset=0,this.checkpointOffset=0,this.data=new Uint8Array(t)}checkpoint(){this.checkpointOffset=this.offset}isEmpty(){return 0===this.offset}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=tt.encode(t),s=i.byteLength;return!(!this.uint(s)||this.offset+s>this.size)&&(this.data.set(i,this.offset),this.offset+=s,!0)}reset(){this.offset=0,this.checkpointOffset=0}flush(){const t=this.data.slice(0,this.checkpointOffset);return this.reset(),t}}class st{constructor(t,i,s){this.pageNo=t,this.timestamp=i,this.onBatch=s,this.nextIndex=0,this.beaconSize=2e5,this.writer=new it(this.beaconSize),this.isEmpty=!0,this.beaconSizeLimit=1e6,this.prepare()}prepare(){this.writer.isEmpty()&&new s(this.pageNo,this.nextIndex,this.timestamp).encode(this.writer)}write(t){const i=t.encode(this.writer);return i&&(this.isEmpty=!1,this.writer.checkpoint(),this.nextIndex++),i}setBeaconSizeLimit(t){this.beaconSizeLimit=t}writeMessage(t){for(t instanceof e&&(this.timestamp=t.timestamp);!this.write(t);){if(this.finaliseBatch(),this.beaconSize===this.beaconSizeLimit)return console.warn("OpenReplay: beacon size overflow. Skipping large message."),this.writer.reset(),this.prepare(),void(this.isEmpty=!0);this.beaconSize=Math.min(2*this.beaconSize,this.beaconSizeLimit),this.writer=new it(this.beaconSize),this.prepare(),this.isEmpty=!0}}finaliseBatch(){this.isEmpty||(this.onBatch(this.writer.flush()),this.prepare(),this.isEmpty=!0)}clean(){this.writer.reset()}}var et;!function(t){t[t.NotActive=0]="NotActive",t[t.Starting=1]="Starting",t[t.Stopping=2]="Stopping",t[t.Active=3]="Active"}(et||(et={}));let nt=null,rt=null;function ht(){rt&&rt.finaliseBatch()}function ot(){et.Stopping,null!==at&&(clearInterval(at),at=null),rt&&(rt.clean(),rt=null),et.NotActive}et.NotActive;let ct,at=null;self.onmessage=({data:t})=>{if(null!=t){if("stop"===t)return ht(),void ot();if(Array.isArray(t)){if(!rt)throw new Error("WebWorker: writer not initialised. Service Should be Started.");const s=rt;t.forEach(t=>{const e=new(i.get(t._id));Object.assign(e,t),e instanceof H&&(e.hidden?ct=setTimeout(()=>self.postMessage("restart"),18e5):clearTimeout(ct)),s.writeMessage(e)})}else{if("start"===t.type)return et.Starting,nt=new Z(t.ingestPoint,()=>{self.postMessage("restart")},()=>{nt&&(nt.clean(),nt=null),ot(),self.postMessage("failed")},t.connAttemptCount,t.connAttemptGap),rt=new st(t.pageNo,t.timestamp,t=>nt&&nt.push(t)),null===at&&(at=setInterval(ht,1e4)),et.Active;if("auth"===t.type){if(!nt)throw new Error("WebWorker: sender not initialised. Received auth.");if(!rt)throw new Error("WebWorker: writer not initialised. Received auth.");return nt.authorise(t.token),void(t.beaconSizeLimit&&rt.setBeaconSizeLimit(t.beaconSizeLimit))}}}else ht()};
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
this._debug("webworker_error", e);
|
|
76
|
+
this.worker = new Worker(URL.createObjectURL(new Blob(['"use strict";function t(t){function i(...i){return new t(...i)}return i.prototype=t.prototype,i}const i=new Map;const s=t(class{constructor(t,i,s){this.pageNo=t,this.firstIndex=i,this.timestamp=s,this._id=80}encode(t){return t.uint(80)&&t.uint(this.pageNo)&&t.uint(this.firstIndex)&&t.int(this.timestamp)}});i.set(80,s);const e=t(class{constructor(t){this.timestamp=t,this._id=0}encode(t){return t.uint(0)&&t.uint(this.timestamp)}});i.set(0,e);const n=t(class{constructor(t,i,s){this.url=t,this.referrer=i,this.navigationStart=s,this._id=4}encode(t){return t.uint(4)&&t.string(this.url)&&t.string(this.referrer)&&t.uint(this.navigationStart)}});i.set(4,n);const r=t(class{constructor(t,i){this.width=t,this.height=i,this._id=5}encode(t){return t.uint(5)&&t.uint(this.width)&&t.uint(this.height)}});i.set(5,r);const h=t(class{constructor(t,i){this.x=t,this.y=i,this._id=6}encode(t){return t.uint(6)&&t.int(this.x)&&t.int(this.y)}});i.set(6,h);const o=t(class{constructor(){this._id=7}encode(t){return t.uint(7)}});i.set(7,o);const c=t(class{constructor(t,i,s,e,n){this.id=t,this.parentID=i,this.index=s,this.tag=e,this.svg=n,this._id=8}encode(t){return t.uint(8)&&t.uint(this.id)&&t.uint(this.parentID)&&t.uint(this.index)&&t.string(this.tag)&&t.boolean(this.svg)}});i.set(8,c);const a=t(class{constructor(t,i,s){this.id=t,this.parentID=i,this.index=s,this._id=9}encode(t){return t.uint(9)&&t.uint(this.id)&&t.uint(this.parentID)&&t.uint(this.index)}});i.set(9,a);const u=t(class{constructor(t,i,s){this.id=t,this.parentID=i,this.index=s,this._id=10}encode(t){return t.uint(10)&&t.uint(this.id)&&t.uint(this.parentID)&&t.uint(this.index)}});i.set(10,u);const d=t(class{constructor(t){this.id=t,this._id=11}encode(t){return t.uint(11)&&t.uint(this.id)}});i.set(11,d);const l=t(class{constructor(t,i,s){this.id=t,this.name=i,this.value=s,this._id=12}encode(t){return t.uint(12)&&t.uint(this.id)&&t.string(this.name)&&t.string(this.value)}});i.set(12,l);const p=t(class{constructor(t,i){this.id=t,this.name=i,this._id=13}encode(t){return t.uint(13)&&t.uint(this.id)&&t.string(this.name)}});i.set(13,p);const g=t(class{constructor(t,i){this.id=t,this.data=i,this._id=14}encode(t){return t.uint(14)&&t.uint(this.id)&&t.string(this.data)}});i.set(14,g);const m=t(class{constructor(t,i,s){this.id=t,this.x=i,this.y=s,this._id=16}encode(t){return t.uint(16)&&t.uint(this.id)&&t.int(this.x)&&t.int(this.y)}});i.set(16,m);const f=t(class{constructor(t,i){this.id=t,this.label=i,this._id=17}encode(t){return t.uint(17)&&t.uint(this.id)&&t.string(this.label)}});i.set(17,f);const y=t(class{constructor(t,i,s){this.id=t,this.value=i,this.mask=s,this._id=18}encode(t){return t.uint(18)&&t.uint(this.id)&&t.string(this.value)&&t.int(this.mask)}});i.set(18,y);const _=t(class{constructor(t,i){this.id=t,this.checked=i,this._id=19}encode(t){return t.uint(19)&&t.uint(this.id)&&t.boolean(this.checked)}});i.set(19,_);const v=t(class{constructor(t,i){this.x=t,this.y=i,this._id=20}encode(t){return t.uint(20)&&t.uint(this.x)&&t.uint(this.y)}});i.set(20,v);const S=t(class{constructor(t,i){this.level=t,this.value=i,this._id=22}encode(t){return t.uint(22)&&t.string(this.level)&&t.string(this.value)}});i.set(22,S);const b=t(class{constructor(t,i,s,e,n,r,h,o,c){this.requestStart=t,this.responseStart=i,this.responseEnd=s,this.domContentLoadedEventStart=e,this.domContentLoadedEventEnd=n,this.loadEventStart=r,this.loadEventEnd=h,this.firstPaint=o,this.firstContentfulPaint=c,this._id=23}encode(t){return t.uint(23)&&t.uint(this.requestStart)&&t.uint(this.responseStart)&&t.uint(this.responseEnd)&&t.uint(this.domContentLoadedEventStart)&&t.uint(this.domContentLoadedEventEnd)&&t.uint(this.loadEventStart)&&t.uint(this.loadEventEnd)&&t.uint(this.firstPaint)&&t.uint(this.firstContentfulPaint)}});i.set(23,b);const w=t(class{constructor(t,i,s){this.speedIndex=t,this.visuallyComplete=i,this.timeToInteractive=s,this._id=24}encode(t){return t.uint(24)&&t.uint(this.speedIndex)&&t.uint(this.visuallyComplete)&&t.uint(this.timeToInteractive)}});i.set(24,w);const E=t(class{constructor(t,i,s){this.name=t,this.message=i,this.payload=s,this._id=25}encode(t){return t.uint(25)&&t.string(this.name)&&t.string(this.message)&&t.string(this.payload)}});i.set(25,E);const x=t(class{constructor(t,i){this.name=t,this.payload=i,this._id=27}encode(t){return t.uint(27)&&t.string(this.name)&&t.string(this.payload)}});i.set(27,x);const T=t(class{constructor(t){this.id=t,this._id=28}encode(t){return t.uint(28)&&t.string(this.id)}});i.set(28,T);const z=t(class{constructor(t){this.id=t,this._id=29}encode(t){return t.uint(29)&&t.string(this.id)}});i.set(29,z);const k=t(class{constructor(t,i){this.key=t,this.value=i,this._id=30}encode(t){return t.uint(30)&&t.string(this.key)&&t.string(this.value)}});i.set(30,k);const A=t(class{constructor(t,i,s){this.id=t,this.rule=i,this.index=s,this._id=37}encode(t){return t.uint(37)&&t.uint(this.id)&&t.string(this.rule)&&t.uint(this.index)}});i.set(37,A);const I=t(class{constructor(t,i){this.id=t,this.index=i,this._id=38}encode(t){return t.uint(38)&&t.uint(this.id)&&t.uint(this.index)}});i.set(38,I);const L=t(class{constructor(t,i,s,e,n,r,h){this.method=t,this.url=i,this.request=s,this.response=e,this.status=n,this.timestamp=r,this.duration=h,this._id=39}encode(t){return t.uint(39)&&t.string(this.method)&&t.string(this.url)&&t.string(this.request)&&t.string(this.response)&&t.uint(this.status)&&t.uint(this.timestamp)&&t.uint(this.duration)}});i.set(39,L);const C=t(class{constructor(t,i,s,e){this.name=t,this.duration=i,this.args=s,this.result=e,this._id=40}encode(t){return t.uint(40)&&t.string(this.name)&&t.uint(this.duration)&&t.string(this.args)&&t.string(this.result)}});i.set(40,C);const M=t(class{constructor(t,i){this.key=t,this.value=i,this._id=41}encode(t){return t.uint(41)&&t.string(this.key)&&t.string(this.value)}});i.set(41,M);const N=t(class{constructor(t){this.type=t,this._id=42}encode(t){return t.uint(42)&&t.string(this.type)}});i.set(42,N);const B=t(class{constructor(t,i,s){this.action=t,this.state=i,this.duration=s,this._id=44}encode(t){return t.uint(44)&&t.string(this.action)&&t.string(this.state)&&t.uint(this.duration)}});i.set(44,B);const U=t(class{constructor(t,i){this.mutation=t,this.state=i,this._id=45}encode(t){return t.uint(45)&&t.string(this.mutation)&&t.string(this.state)}});i.set(45,U);const R=t(class{constructor(t,i){this.type=t,this.payload=i,this._id=46}encode(t){return t.uint(46)&&t.string(this.type)&&t.string(this.payload)}});i.set(46,R);const O=t(class{constructor(t,i,s){this.action=t,this.state=i,this.duration=s,this._id=47}encode(t){return t.uint(47)&&t.string(this.action)&&t.string(this.state)&&t.uint(this.duration)}});i.set(47,O);const P=t(class{constructor(t,i,s,e){this.operationKind=t,this.operationName=i,this.variables=s,this.response=e,this._id=48}encode(t){return t.uint(48)&&t.string(this.operationKind)&&t.string(this.operationName)&&t.string(this.variables)&&t.string(this.response)}});i.set(48,P);const q=t(class{constructor(t,i,s,e){this.frames=t,this.ticks=i,this.totalJSHeapSize=s,this.usedJSHeapSize=e,this._id=49}encode(t){return t.uint(49)&&t.int(this.frames)&&t.int(this.ticks)&&t.uint(this.totalJSHeapSize)&&t.uint(this.usedJSHeapSize)}});i.set(49,q);const D=t(class{constructor(t,i,s,e,n,r,h,o){this.timestamp=t,this.duration=i,this.ttfb=s,this.headerSize=e,this.encodedBodySize=n,this.decodedBodySize=r,this.url=h,this.initiator=o,this._id=53}encode(t){return t.uint(53)&&t.uint(this.timestamp)&&t.uint(this.duration)&&t.uint(this.ttfb)&&t.uint(this.headerSize)&&t.uint(this.encodedBodySize)&&t.uint(this.decodedBodySize)&&t.string(this.url)&&t.string(this.initiator)}});i.set(53,D);const W=t(class{constructor(t,i){this.downlink=t,this.type=i,this._id=54}encode(t){return t.uint(54)&&t.uint(this.downlink)&&t.string(this.type)}});i.set(54,W);const H=t(class{constructor(t){this.hidden=t,this._id=55}encode(t){return t.uint(55)&&t.boolean(this.hidden)}});i.set(55,H);const J=t(class{constructor(t,i,s,e,n,r,h){this.timestamp=t,this.duration=i,this.context=s,this.containerType=e,this.containerSrc=n,this.containerId=r,this.containerName=h,this._id=59}encode(t){return t.uint(59)&&t.uint(this.timestamp)&&t.uint(this.duration)&&t.uint(this.context)&&t.uint(this.containerType)&&t.string(this.containerSrc)&&t.string(this.containerId)&&t.string(this.containerName)}});i.set(59,J);const F=t(class{constructor(t,i,s,e){this.id=t,this.name=i,this.value=s,this.baseURL=e,this._id=60}encode(t){return t.uint(60)&&t.uint(this.id)&&t.string(this.name)&&t.string(this.value)&&t.string(this.baseURL)}});i.set(60,F);const X=t(class{constructor(t,i,s){this.id=t,this.data=i,this.baseURL=s,this._id=61}encode(t){return t.uint(61)&&t.uint(this.id)&&t.string(this.data)&&t.string(this.baseURL)}});i.set(61,X);const G=t(class{constructor(t,i){this.type=t,this.value=i,this._id=63}encode(t){return t.uint(63)&&t.string(this.type)&&t.string(this.value)}});i.set(63,G);const K=t(class{constructor(t,i){this.name=t,this.payload=i,this._id=64}encode(t){return t.uint(64)&&t.string(this.name)&&t.string(this.payload)}});i.set(64,K);const j=t(class{constructor(){this._id=65}encode(t){return t.uint(65)}});i.set(65,j);const Q=t(class{constructor(t,i,s,e){this.id=t,this.rule=i,this.index=s,this.baseURL=e,this._id=67}encode(t){return t.uint(67)&&t.uint(this.id)&&t.string(this.rule)&&t.uint(this.index)&&t.string(this.baseURL)}});i.set(67,Q);const V=t(class{constructor(t,i,s,e){this.id=t,this.hesitationTime=i,this.label=s,this.selector=e,this._id=69}encode(t){return t.uint(69)&&t.uint(this.id)&&t.uint(this.hesitationTime)&&t.string(this.label)&&t.string(this.selector)}});i.set(69,V);const Y=t(class{constructor(t,i){this.frameID=t,this.id=i,this._id=70}encode(t){return t.uint(70)&&t.uint(this.frameID)&&t.uint(this.id)}});i.set(70,Y);class Z{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 tt="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 it{constructor(t){this.size=t,this.offset=0,this.checkpointOffset=0,this.data=new Uint8Array(t)}checkpoint(){this.checkpointOffset=this.offset}isEmpty(){return 0===this.offset}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=tt.encode(t),s=i.byteLength;return!(!this.uint(s)||this.offset+s>this.size)&&(this.data.set(i,this.offset),this.offset+=s,!0)}reset(){this.offset=0,this.checkpointOffset=0}flush(){const t=this.data.slice(0,this.checkpointOffset);return this.reset(),t}}class st{constructor(t,i,s){this.pageNo=t,this.timestamp=i,this.onBatch=s,this.nextIndex=0,this.beaconSize=2e5,this.writer=new it(this.beaconSize),this.isEmpty=!0,this.beaconSizeLimit=1e6,this.prepare()}prepare(){this.writer.isEmpty()&&new s(this.pageNo,this.nextIndex,this.timestamp).encode(this.writer)}write(t){const i=t.encode(this.writer);return i&&(this.isEmpty=!1,this.writer.checkpoint(),this.nextIndex++),i}setBeaconSizeLimit(t){this.beaconSizeLimit=t}writeMessage(t){for(t instanceof e&&(this.timestamp=t.timestamp);!this.write(t);){if(this.finaliseBatch(),this.beaconSize===this.beaconSizeLimit)return console.warn("OpenReplay: beacon size overflow. Skipping large message."),this.writer.reset(),this.prepare(),void(this.isEmpty=!0);this.beaconSize=Math.min(2*this.beaconSize,this.beaconSizeLimit),this.writer=new it(this.beaconSize),this.prepare(),this.isEmpty=!0}}finaliseBatch(){this.isEmpty||(this.onBatch(this.writer.flush()),this.prepare(),this.isEmpty=!0)}clean(){this.writer.reset()}}var et;!function(t){t[t.NotActive=0]="NotActive",t[t.Starting=1]="Starting",t[t.Stopping=2]="Stopping",t[t.Active=3]="Active"}(et||(et={}));let nt=null,rt=null;function ht(){rt&&rt.finaliseBatch()}function ot(){et.Stopping,null!==at&&(clearInterval(at),at=null),rt&&(rt.clean(),rt=null),et.NotActive}et.NotActive;let ct,at=null;self.onmessage=({data:t})=>{if(null!=t){if("stop"===t)return ht(),void ot();if(Array.isArray(t)){if(!rt)throw new Error("WebWorker: writer not initialised. Service Should be Started.");const s=rt;t.forEach(t=>{const e=new(i.get(t._id));Object.assign(e,t),e instanceof H&&(e.hidden?ct=setTimeout(()=>self.postMessage("restart"),18e5):clearTimeout(ct)),s.writeMessage(e)})}else{if("start"===t.type)return et.Starting,nt=new Z(t.ingestPoint,()=>{self.postMessage("restart")},()=>{nt&&(nt.clean(),nt=null),ot(),self.postMessage("failed")},t.connAttemptCount,t.connAttemptGap),rt=new st(t.pageNo,t.timestamp,t=>nt&&nt.push(t)),null===at&&(at=setInterval(ht,1e4)),et.Active;if("auth"===t.type){if(!nt)throw new Error("WebWorker: sender not initialised. Received auth.");if(!rt)throw new Error("WebWorker: writer not initialised. Received auth.");return nt.authorise(t.token),void(t.beaconSizeLimit&&rt.setBeaconSizeLimit(t.beaconSizeLimit))}}}else ht()};'], { type: 'text/javascript' })));
|
|
77
|
+
this.worker.onerror = (e) => {
|
|
78
|
+
this._debug('webworker_error', e);
|
|
79
79
|
};
|
|
80
80
|
this.worker.onmessage = ({ data }) => {
|
|
81
|
-
if (data ===
|
|
81
|
+
if (data === 'failed') {
|
|
82
82
|
this.stop();
|
|
83
|
-
this._debug(
|
|
83
|
+
this._debug('worker_failed', {}); // add context (from worker)
|
|
84
84
|
}
|
|
85
|
-
else if (data ===
|
|
85
|
+
else if (data === 'restart') {
|
|
86
86
|
this.stop();
|
|
87
87
|
this.start({ forceNew: true });
|
|
88
88
|
}
|
|
@@ -99,7 +99,7 @@ class App {
|
|
|
99
99
|
this.attachEventListener(document, 'visibilitychange', alertWorker, false);
|
|
100
100
|
}
|
|
101
101
|
catch (e) {
|
|
102
|
-
this._debug(
|
|
102
|
+
this._debug('worker_start', e);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
_debug(context, e) {
|
|
@@ -109,11 +109,11 @@ class App {
|
|
|
109
109
|
headers: { 'Content-Type': 'application/json' },
|
|
110
110
|
body: JSON.stringify({
|
|
111
111
|
context,
|
|
112
|
-
error: `${e}
|
|
113
|
-
})
|
|
112
|
+
error: `${e}`,
|
|
113
|
+
}),
|
|
114
114
|
});
|
|
115
115
|
}
|
|
116
|
-
this.debug.error(
|
|
116
|
+
this.debug.error('OpenReplay error: ', context, e);
|
|
117
117
|
}
|
|
118
118
|
send(message, urgent = false) {
|
|
119
119
|
if (this.activityState === ActivityState.NotActive) {
|
|
@@ -132,7 +132,7 @@ class App {
|
|
|
132
132
|
if (this.worker && this.messages.length) {
|
|
133
133
|
this.messages.unshift(new messages_js_1.Timestamp((0, utils_js_1.timestamp)()));
|
|
134
134
|
this.worker.postMessage(this.messages);
|
|
135
|
-
this.commitCallbacks.forEach(cb => cb(this.messages));
|
|
135
|
+
this.commitCallbacks.forEach((cb) => cb(this.messages));
|
|
136
136
|
this.messages.length = 0;
|
|
137
137
|
}
|
|
138
138
|
}
|
|
@@ -143,7 +143,7 @@ class App {
|
|
|
143
143
|
fn.apply(this, args);
|
|
144
144
|
}
|
|
145
145
|
catch (e) {
|
|
146
|
-
app._debug(
|
|
146
|
+
app._debug('safe_fn_call', e);
|
|
147
147
|
// time: timestamp(),
|
|
148
148
|
// name: e.name,
|
|
149
149
|
// message: e.message,
|
|
@@ -172,10 +172,13 @@ class App {
|
|
|
172
172
|
const reqVer = version.split(/[.-]/);
|
|
173
173
|
const ver = this.version.split(/[.-]/);
|
|
174
174
|
for (let i = 0; i < 3; i++) {
|
|
175
|
+
if (isNaN(Number(ver[i])) || isNaN(Number(reqVer[i]))) {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
175
178
|
if (Number(ver[i]) > Number(reqVer[i])) {
|
|
176
179
|
return true;
|
|
177
180
|
}
|
|
178
|
-
if (Number(ver[i]) < Number(reqVer[i])
|
|
181
|
+
if (Number(ver[i]) < Number(reqVer[i])) {
|
|
179
182
|
return false;
|
|
180
183
|
}
|
|
181
184
|
}
|
|
@@ -203,6 +206,14 @@ class App {
|
|
|
203
206
|
getSessionID() {
|
|
204
207
|
return this.session.getInfo().sessionID || undefined;
|
|
205
208
|
}
|
|
209
|
+
getSessionURL() {
|
|
210
|
+
const { projectID, sessionID } = this.session.getInfo();
|
|
211
|
+
if (!projectID || !sessionID) {
|
|
212
|
+
this.debug.error('OpenReplay error: Unable to build session URL');
|
|
213
|
+
return undefined;
|
|
214
|
+
}
|
|
215
|
+
return this.options.ingestPoint.replace(/ingest$/, `${projectID}/session/${sessionID}`);
|
|
216
|
+
}
|
|
206
217
|
getHost() {
|
|
207
218
|
return new URL(this.options.ingestPoint).hostname;
|
|
208
219
|
}
|
|
@@ -221,12 +232,13 @@ class App {
|
|
|
221
232
|
return document.baseURI;
|
|
222
233
|
}
|
|
223
234
|
// IE only
|
|
224
|
-
return ((_b = (_a = document.head) === null || _a === void 0 ? void 0 : _a.getElementsByTagName(
|
|
235
|
+
return (((_b = (_a = document.head) === null || _a === void 0 ? void 0 : _a.getElementsByTagName('base')[0]) === null || _b === void 0 ? void 0 : _b.getAttribute('href')) ||
|
|
236
|
+
location.origin + location.pathname);
|
|
225
237
|
}
|
|
226
238
|
resolveResourceURL(resourceURL) {
|
|
227
239
|
const base = new URL(this.getBaseHref());
|
|
228
|
-
base.pathname +=
|
|
229
|
-
base.pathname.replace(/\/+/g,
|
|
240
|
+
base.pathname += '/' + new URL(resourceURL).pathname;
|
|
241
|
+
base.pathname.replace(/\/+/g, '/');
|
|
230
242
|
return base.toString();
|
|
231
243
|
}
|
|
232
244
|
isServiceURL(url) {
|
|
@@ -245,10 +257,10 @@ class App {
|
|
|
245
257
|
}
|
|
246
258
|
_start(startOpts) {
|
|
247
259
|
if (!this.worker) {
|
|
248
|
-
return Promise.resolve(UnsuccessfulStart(
|
|
260
|
+
return Promise.resolve(UnsuccessfulStart('No worker found: perhaps, CSP is not set.'));
|
|
249
261
|
}
|
|
250
262
|
if (this.activityState !== ActivityState.NotActive) {
|
|
251
|
-
return Promise.resolve(UnsuccessfulStart(
|
|
263
|
+
return Promise.resolve(UnsuccessfulStart('OpenReplay: trying to call `start()` on the instance that has been started already.'));
|
|
252
264
|
}
|
|
253
265
|
this.activityState = ActivityState.Starting;
|
|
254
266
|
let pageNo = 0;
|
|
@@ -260,7 +272,7 @@ class App {
|
|
|
260
272
|
this.sessionStorage.setItem(this.options.session_pageno_key, pageNo.toString());
|
|
261
273
|
const startInfo = this.getStartInfo();
|
|
262
274
|
const startWorkerMsg = {
|
|
263
|
-
type:
|
|
275
|
+
type: 'start',
|
|
264
276
|
pageNo,
|
|
265
277
|
ingestPoint: this.options.ingestPoint,
|
|
266
278
|
timestamp: startInfo.timestamp,
|
|
@@ -269,6 +281,7 @@ class App {
|
|
|
269
281
|
};
|
|
270
282
|
this.worker.postMessage(startWorkerMsg);
|
|
271
283
|
this.session.update({
|
|
284
|
+
// TODO: transparent "session" module logic AND explicit internal api for plugins.
|
|
272
285
|
// "updating" with old metadata in order to trigger session's UpdateCallbacks.
|
|
273
286
|
// (for the case of internal .start() calls, like on "restart" webworker signal or assistent connection in tracker-assist )
|
|
274
287
|
metadata: startOpts.metadata || this.session.getInfo().metadata,
|
|
@@ -276,7 +289,8 @@ class App {
|
|
|
276
289
|
});
|
|
277
290
|
const sReset = this.sessionStorage.getItem(this.options.session_reset_key);
|
|
278
291
|
this.sessionStorage.removeItem(this.options.session_reset_key);
|
|
279
|
-
return window
|
|
292
|
+
return window
|
|
293
|
+
.fetch(this.options.ingestPoint + '/v1/web/start', {
|
|
280
294
|
method: 'POST',
|
|
281
295
|
headers: {
|
|
282
296
|
'Content-Type': 'application/json',
|
|
@@ -284,19 +298,21 @@ class App {
|
|
|
284
298
|
body: JSON.stringify(Object.assign(Object.assign({}, startInfo), { userID: this.session.getInfo().userID, token: this.sessionStorage.getItem(this.options.session_token_key), deviceMemory: performance_js_1.deviceMemory,
|
|
285
299
|
jsHeapSizeLimit: performance_js_1.jsHeapSizeLimit, reset: startOpts.forceNew || sReset !== null })),
|
|
286
300
|
})
|
|
287
|
-
.then(r => {
|
|
301
|
+
.then((r) => {
|
|
288
302
|
if (r.status === 200) {
|
|
289
303
|
return r.json();
|
|
290
304
|
}
|
|
291
305
|
else {
|
|
292
|
-
return r
|
|
306
|
+
return r
|
|
307
|
+
.text()
|
|
308
|
+
.then((text) => text === CANCELED
|
|
293
309
|
? Promise.reject(CANCELED)
|
|
294
310
|
: Promise.reject(`Server error: ${r.status}. ${text}`));
|
|
295
311
|
}
|
|
296
312
|
})
|
|
297
|
-
.then(r => {
|
|
313
|
+
.then((r) => {
|
|
298
314
|
if (!this.worker) {
|
|
299
|
-
return Promise.reject(
|
|
315
|
+
return Promise.reject('no worker found after start request (this might not happen)');
|
|
300
316
|
}
|
|
301
317
|
const { token, userUUID, sessionID, beaconSizeLimit } = r;
|
|
302
318
|
if (typeof token !== 'string' ||
|
|
@@ -308,9 +324,9 @@ class App {
|
|
|
308
324
|
this.localStorage.setItem(this.options.local_uuid_key, userUUID);
|
|
309
325
|
this.session.update({ sessionID }); // TODO: no no-explicit 'any'
|
|
310
326
|
const startWorkerMsg = {
|
|
311
|
-
type:
|
|
327
|
+
type: 'auth',
|
|
312
328
|
token,
|
|
313
|
-
beaconSizeLimit
|
|
329
|
+
beaconSizeLimit,
|
|
314
330
|
};
|
|
315
331
|
this.worker.postMessage(startWorkerMsg);
|
|
316
332
|
this.activityState = ActivityState.Active;
|
|
@@ -318,21 +334,21 @@ class App {
|
|
|
318
334
|
this.startCallbacks.forEach((cb) => cb(onStartInfo)); // TODO: start as early as possible (before receiving the token)
|
|
319
335
|
this.observer.observe();
|
|
320
336
|
this.ticker.start();
|
|
321
|
-
this.notify.log(
|
|
337
|
+
this.notify.log('OpenReplay tracking started.');
|
|
322
338
|
// get rid of onStart ?
|
|
323
339
|
if (typeof this.options.onStart === 'function') {
|
|
324
340
|
this.options.onStart(onStartInfo);
|
|
325
341
|
}
|
|
326
342
|
return SuccessfulStart(onStartInfo);
|
|
327
343
|
})
|
|
328
|
-
.catch(reason => {
|
|
344
|
+
.catch((reason) => {
|
|
329
345
|
this.sessionStorage.removeItem(this.options.session_token_key);
|
|
330
346
|
this.stop();
|
|
331
347
|
if (reason === CANCELED) {
|
|
332
348
|
return UnsuccessfulStart(CANCELED);
|
|
333
349
|
}
|
|
334
|
-
this.notify.log(
|
|
335
|
-
this._debug(
|
|
350
|
+
this.notify.log('OpenReplay was unable to start. ', reason);
|
|
351
|
+
this._debug('session_start', reason);
|
|
336
352
|
return UnsuccessfulStart(START_ERROR);
|
|
337
353
|
});
|
|
338
354
|
}
|
|
@@ -344,11 +360,11 @@ class App {
|
|
|
344
360
|
return new Promise((resolve) => {
|
|
345
361
|
const onVisibilityChange = () => {
|
|
346
362
|
if (!document.hidden) {
|
|
347
|
-
document.removeEventListener(
|
|
363
|
+
document.removeEventListener('visibilitychange', onVisibilityChange);
|
|
348
364
|
resolve(this._start(options));
|
|
349
365
|
}
|
|
350
366
|
};
|
|
351
|
-
document.addEventListener(
|
|
367
|
+
document.addEventListener('visibilitychange', onVisibilityChange);
|
|
352
368
|
});
|
|
353
369
|
}
|
|
354
370
|
}
|
|
@@ -363,9 +379,9 @@ class App {
|
|
|
363
379
|
if (calledFromAPI) {
|
|
364
380
|
this.session.reset();
|
|
365
381
|
}
|
|
366
|
-
this.notify.log(
|
|
382
|
+
this.notify.log('OpenReplay tracking stopped.');
|
|
367
383
|
if (this.worker && !restarting) {
|
|
368
|
-
this.worker.postMessage(
|
|
384
|
+
this.worker.postMessage('stop');
|
|
369
385
|
}
|
|
370
386
|
}
|
|
371
387
|
finally {
|
package/cjs/app/logger.js
CHANGED
|
@@ -13,9 +13,12 @@ function IsCustomLevel(l) {
|
|
|
13
13
|
}
|
|
14
14
|
class Logger {
|
|
15
15
|
constructor(options = exports.LogLevel.Silent) {
|
|
16
|
-
this.options =
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
this.options =
|
|
17
|
+
options === true
|
|
18
|
+
? { level: exports.LogLevel.Verbose }
|
|
19
|
+
: typeof options === 'number'
|
|
20
|
+
? { level: options }
|
|
21
|
+
: options;
|
|
19
22
|
}
|
|
20
23
|
log(...args) {
|
|
21
24
|
if (IsCustomLevel(this.options.level)
|
|
@@ -12,7 +12,7 @@ class IFrameObserver extends observer_js_1.default {
|
|
|
12
12
|
// Have to observe document, because the inner <html> might be changed
|
|
13
13
|
this.observeRoot(doc, (docID) => {
|
|
14
14
|
if (docID === undefined) {
|
|
15
|
-
console.log(
|
|
15
|
+
console.log('OpenReplay: Iframe document not bound');
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
18
|
this.app.send((0, messages_js_1.CreateIFrameDocument)(hostID, docID));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import App from
|
|
1
|
+
import App from '../index.js';
|
|
2
2
|
export default abstract class Observer {
|
|
3
3
|
protected readonly app: App;
|
|
4
4
|
protected readonly isTopContext: boolean;
|
|
@@ -13,9 +13,8 @@ export default abstract class Observer {
|
|
|
13
13
|
private sendNodeAttribute;
|
|
14
14
|
private sendNodeData;
|
|
15
15
|
private bindNode;
|
|
16
|
-
private unbindChildNode;
|
|
17
16
|
private bindTree;
|
|
18
|
-
private
|
|
17
|
+
private unbindTree;
|
|
19
18
|
private _commitNode;
|
|
20
19
|
private commitNode;
|
|
21
20
|
private commitNodes;
|