@openreplay/tracker 3.5.8 → 3.5.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/app/context.js +4 -2
- package/cjs/app/index.d.ts +12 -13
- package/cjs/app/index.js +23 -21
- package/cjs/app/observer/iframe_observer.js +2 -2
- package/cjs/app/observer/observer.js +13 -13
- package/cjs/app/observer/shadow_root_observer.js +2 -2
- package/cjs/app/observer/top_observer.js +2 -2
- package/cjs/app/session.js +3 -3
- package/cjs/{messages/index.d.ts → common/messages.d.ts} +2 -3
- package/cjs/{messages/index.js → common/messages.js} +0 -0
- package/cjs/common/types.d.ts +9 -0
- package/cjs/{messages/message.js → common/types.js} +0 -0
- package/cjs/common/webworker.d.ts +19 -0
- package/cjs/{messages → common}/webworker.js +0 -0
- package/cjs/index.d.ts +2 -2
- package/cjs/index.js +7 -7
- package/cjs/modules/connection.js +2 -2
- package/cjs/modules/console.js +2 -2
- package/cjs/modules/cssrules.js +4 -4
- package/cjs/modules/exception.d.ts +1 -1
- package/cjs/modules/exception.js +4 -4
- package/cjs/modules/img.js +7 -7
- package/cjs/modules/input.js +5 -5
- package/cjs/modules/longtasks.js +2 -2
- package/cjs/modules/mouse.js +3 -7
- package/cjs/modules/performance.js +2 -2
- package/cjs/modules/scroll.js +3 -3
- package/cjs/modules/timing.js +15 -18
- package/cjs/modules/viewport.js +4 -4
- package/lib/app/context.js +4 -2
- package/lib/app/index.d.ts +12 -13
- package/lib/app/index.js +22 -20
- package/lib/app/observer/iframe_observer.js +1 -1
- package/lib/app/observer/observer.js +1 -1
- package/lib/app/observer/shadow_root_observer.js +1 -1
- package/lib/app/observer/top_observer.js +1 -1
- package/lib/app/session.js +1 -1
- package/lib/{messages/index.d.ts → common/messages.d.ts} +2 -3
- package/lib/{messages/index.js → common/messages.js} +0 -0
- package/lib/common/tsconfig.tsbuildinfo +1 -0
- package/lib/common/types.d.ts +9 -0
- package/lib/{messages/message.js → common/types.js} +0 -0
- package/lib/common/webworker.d.ts +19 -0
- package/lib/{messages → common}/webworker.js +0 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.js +4 -4
- package/lib/modules/connection.js +1 -1
- package/lib/modules/console.js +1 -1
- package/lib/modules/cssrules.js +1 -1
- package/lib/modules/exception.d.ts +1 -1
- package/lib/modules/exception.js +1 -1
- package/lib/modules/img.js +1 -1
- package/lib/modules/input.js +1 -1
- package/lib/modules/longtasks.js +1 -1
- package/lib/modules/mouse.js +1 -5
- package/lib/modules/performance.js +1 -1
- package/lib/modules/scroll.js +1 -1
- package/lib/modules/timing.js +13 -16
- package/lib/modules/viewport.js +1 -1
- package/package.json +1 -1
- package/cjs/messages/message.d.ts +0 -4
- package/cjs/messages/webworker.d.ts +0 -17
- package/cjs/messages/writer.d.ts +0 -15
- package/cjs/messages/writer.js +0 -115
- package/lib/messages/message.d.ts +0 -4
- package/lib/messages/tsconfig.tsbuildinfo +0 -1
- package/lib/messages/webworker.d.ts +0 -17
- package/lib/messages/writer.d.ts +0 -15
- package/lib/messages/writer.js +0 -112
package/cjs/app/context.js
CHANGED
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.inDocument = exports.isInstance = void 0;
|
|
4
4
|
// TODO: we need a type expert here so we won't have to ignore the lines
|
|
5
5
|
// TODO: use it everywhere (static function; export from which file? <-- global Window typing required)
|
|
6
|
+
// TODO: most efficient and common way
|
|
7
|
+
// Problem: on YouTube there is context[constr.name] undefined for constr=ShadowDom due to some minimisations
|
|
6
8
|
function isInstance(node, constr) {
|
|
7
9
|
const doc = node.ownerDocument;
|
|
8
10
|
if (!doc) { // null if Document
|
|
@@ -14,14 +16,14 @@ function isInstance(node, constr) {
|
|
|
14
16
|
doc.defaultView; // TODO: smart global typing for Window object
|
|
15
17
|
while (context !== window) {
|
|
16
18
|
// @ts-ignore
|
|
17
|
-
if (node instanceof context[constr.name]) {
|
|
19
|
+
if (context[constr.name] && node instanceof context[constr.name]) {
|
|
18
20
|
return true;
|
|
19
21
|
}
|
|
20
22
|
// @ts-ignore
|
|
21
23
|
context = context.parent || window;
|
|
22
24
|
}
|
|
23
25
|
// @ts-ignore
|
|
24
|
-
return node instanceof context[constr.name];
|
|
26
|
+
return context[constr.name] ? node instanceof context[constr.name] : node instanceof constr;
|
|
25
27
|
}
|
|
26
28
|
exports.isInstance = isInstance;
|
|
27
29
|
// TODO: ensure 1. it works in every cases (iframes/detached nodes) and 2. the most efficient
|
package/cjs/app/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Message from "../messages
|
|
1
|
+
import type Message from "../common/messages.js";
|
|
2
2
|
import Nodes from "./nodes.js";
|
|
3
3
|
import Sanitizer from "./sanitizer.js";
|
|
4
4
|
import Ticker from "./ticker.js";
|
|
@@ -7,17 +7,19 @@ import Session from "./session.js";
|
|
|
7
7
|
import type { Options as ObserverOptions } from "./observer/top_observer.js";
|
|
8
8
|
import type { Options as SanitizerOptions } from "./sanitizer.js";
|
|
9
9
|
import type { Options as LoggerOptions } from "./logger.js";
|
|
10
|
-
import type { Options as WebworkerOptions } from "../
|
|
11
|
-
export interface OnStartInfo {
|
|
12
|
-
sessionID: string;
|
|
13
|
-
sessionToken: string;
|
|
14
|
-
userUUID: string;
|
|
15
|
-
}
|
|
10
|
+
import type { Options as WebworkerOptions } from "../common/webworker.js";
|
|
16
11
|
export interface StartOptions {
|
|
17
12
|
userID?: string;
|
|
18
13
|
metadata?: Record<string, string>;
|
|
19
14
|
forceNew?: boolean;
|
|
20
15
|
}
|
|
16
|
+
export interface OnStartInfo {
|
|
17
|
+
sessionID: string;
|
|
18
|
+
sessionToken: string;
|
|
19
|
+
userUUID: string;
|
|
20
|
+
}
|
|
21
|
+
declare type StartCallback = (i: OnStartInfo) => void;
|
|
22
|
+
declare type CommitCallback = (messages: Array<Message>) => void;
|
|
21
23
|
declare type AppOptions = {
|
|
22
24
|
revID: string;
|
|
23
25
|
node_id: string;
|
|
@@ -31,11 +33,9 @@ declare type AppOptions = {
|
|
|
31
33
|
__is_snippet: boolean;
|
|
32
34
|
__debug_report_edp: string | null;
|
|
33
35
|
__debug__?: LoggerOptions;
|
|
34
|
-
onStart?:
|
|
36
|
+
onStart?: StartCallback;
|
|
35
37
|
} & WebworkerOptions;
|
|
36
38
|
export declare type Options = AppOptions & ObserverOptions & SanitizerOptions;
|
|
37
|
-
declare type Callback = () => void;
|
|
38
|
-
declare type CommitCallback = (messages: Array<Message>) => void;
|
|
39
39
|
export declare const CANCELED = "canceled";
|
|
40
40
|
export declare const DEFAULT_INGEST_POINT = "https://api.openreplay.com/ingest";
|
|
41
41
|
export default class App {
|
|
@@ -58,13 +58,12 @@ export default class App {
|
|
|
58
58
|
private readonly worker?;
|
|
59
59
|
constructor(projectKey: string, sessionToken: string | null | undefined, options: Partial<Options>);
|
|
60
60
|
private _debug;
|
|
61
|
-
private readonly preStartMessages;
|
|
62
61
|
send(message: Message, urgent?: boolean): void;
|
|
63
62
|
private commit;
|
|
64
63
|
safe<T extends (...args: any[]) => void>(fn: T): T;
|
|
65
64
|
attachCommitCallback(cb: CommitCallback): void;
|
|
66
|
-
attachStartCallback(cb:
|
|
67
|
-
attachStopCallback(cb:
|
|
65
|
+
attachStartCallback(cb: StartCallback): void;
|
|
66
|
+
attachStopCallback(cb: Function): void;
|
|
68
67
|
attachEventListener(target: EventTarget, type: string, listener: EventListener, useSafe?: boolean, useCapture?: boolean): void;
|
|
69
68
|
checkRequiredVersion(version: string): boolean;
|
|
70
69
|
private getStartInfo;
|
package/cjs/app/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DEFAULT_INGEST_POINT = exports.CANCELED = void 0;
|
|
4
|
+
const messages_js_1 = require("../common/messages.js");
|
|
4
5
|
const utils_js_1 = require("../utils.js");
|
|
5
|
-
const index_js_1 = require("../messages/index.js");
|
|
6
6
|
const nodes_js_1 = require("./nodes.js");
|
|
7
7
|
const top_observer_js_1 = require("./observer/top_observer.js");
|
|
8
8
|
const sanitizer_js_1 = require("./sanitizer.js");
|
|
@@ -29,8 +29,7 @@ class App {
|
|
|
29
29
|
this.stopCallbacks = [];
|
|
30
30
|
this.commitCallbacks = [];
|
|
31
31
|
this.activityState = ActivityState.NotActive;
|
|
32
|
-
this.version = '3.5.
|
|
33
|
-
this.preStartMessages = [];
|
|
32
|
+
this.version = '3.5.11'; // TODO: version compatability check inside each plugin.
|
|
34
33
|
this.projectKey = projectKey;
|
|
35
34
|
this.options = Object.assign({
|
|
36
35
|
revID: '',
|
|
@@ -58,13 +57,13 @@ class App {
|
|
|
58
57
|
this.notify = new logger_js_1.default(this.options.verbose ? logger_js_1.LogLevel.Warnings : logger_js_1.LogLevel.Silent);
|
|
59
58
|
this.session = new session_js_1.default(this);
|
|
60
59
|
try {
|
|
61
|
-
this.worker = new Worker(URL.createObjectURL(new Blob([`"use strict";function t(t){function s(...s){return new t(...s)}return s.prototype=t.prototype,s}const s=new Map;const i=t(class{constructor(t,s,i){this.pageNo=t,this.firstIndex=s,this.timestamp=i,this._id=80}encode(t){return t.uint(80)&&t.uint(this.pageNo)&&t.uint(this.firstIndex)&&t.int(this.timestamp)}});s.set(80,i);const n=t(class{constructor(t){this.timestamp=t,this._id=0}encode(t){return t.uint(0)&&t.uint(this.timestamp)}});s.set(0,n);const e=t(class{constructor(t,s,i){this.url=t,this.referrer=s,this.navigationStart=i,this._id=4}encode(t){return t.uint(4)&&t.string(this.url)&&t.string(this.referrer)&&t.uint(this.navigationStart)}});s.set(4,e);const r=t(class{constructor(t,s){this.width=t,this.height=s,this._id=5}encode(t){return t.uint(5)&&t.uint(this.width)&&t.uint(this.height)}});s.set(5,r);const o=t(class{constructor(t,s){this.x=t,this.y=s,this._id=6}encode(t){return t.uint(6)&&t.int(this.x)&&t.int(this.y)}});s.set(6,o);const h=t(class{constructor(){this._id=7}encode(t){return t.uint(7)}});s.set(7,h);const c=t(class{constructor(t,s,i,n,e){this.id=t,this.parentID=s,this.index=i,this.tag=n,this.svg=e,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)}});s.set(8,c);const u=t(class{constructor(t,s,i){this.id=t,this.parentID=s,this.index=i,this._id=9}encode(t){return t.uint(9)&&t.uint(this.id)&&t.uint(this.parentID)&&t.uint(this.index)}});s.set(9,u);const a=t(class{constructor(t,s,i){this.id=t,this.parentID=s,this.index=i,this._id=10}encode(t){return t.uint(10)&&t.uint(this.id)&&t.uint(this.parentID)&&t.uint(this.index)}});s.set(10,a);const d=t(class{constructor(t){this.id=t,this._id=11}encode(t){return t.uint(11)&&t.uint(this.id)}});s.set(11,d);const l=t(class{constructor(t,s,i){this.id=t,this.name=s,this.value=i,this._id=12}encode(t){return t.uint(12)&&t.uint(this.id)&&t.string(this.name)&&t.string(this.value)}});s.set(12,l);const g=t(class{constructor(t,s){this.id=t,this.name=s,this._id=13}encode(t){return t.uint(13)&&t.uint(this.id)&&t.string(this.name)}});s.set(13,g);const f=t(class{constructor(t,s){this.id=t,this.data=s,this._id=14}encode(t){return t.uint(14)&&t.uint(this.id)&&t.string(this.data)}});s.set(14,f);const p=t(class{constructor(t,s,i){this.id=t,this.x=s,this.y=i,this._id=16}encode(t){return t.uint(16)&&t.uint(this.id)&&t.int(this.x)&&t.int(this.y)}});s.set(16,p);const m=t(class{constructor(t,s){this.id=t,this.label=s,this._id=17}encode(t){return t.uint(17)&&t.uint(this.id)&&t.string(this.label)}});s.set(17,m);const _=t(class{constructor(t,s,i){this.id=t,this.value=s,this.mask=i,this._id=18}encode(t){return t.uint(18)&&t.uint(this.id)&&t.string(this.value)&&t.int(this.mask)}});s.set(18,_);const y=t(class{constructor(t,s){this.id=t,this.checked=s,this._id=19}encode(t){return t.uint(19)&&t.uint(this.id)&&t.boolean(this.checked)}});s.set(19,y);const v=t(class{constructor(t,s){this.x=t,this.y=s,this._id=20}encode(t){return t.uint(20)&&t.uint(this.x)&&t.uint(this.y)}});s.set(20,v);const S=t(class{constructor(t,s){this.level=t,this.value=s,this._id=22}encode(t){return t.uint(22)&&t.string(this.level)&&t.string(this.value)}});s.set(22,S);const b=t(class{constructor(t,s,i,n,e,r,o,h,c){this.requestStart=t,this.responseStart=s,this.responseEnd=i,this.domContentLoadedEventStart=n,this.domContentLoadedEventEnd=e,this.loadEventStart=r,this.loadEventEnd=o,this.firstPaint=h,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)}});s.set(23,b);const x=t(class{constructor(t,s,i){this.speedIndex=t,this.visuallyComplete=s,this.timeToInteractive=i,this._id=24}encode(t){return t.uint(24)&&t.uint(this.speedIndex)&&t.uint(this.visuallyComplete)&&t.uint(this.timeToInteractive)}});s.set(24,x);const E=t(class{constructor(t,s,i){this.name=t,this.message=s,this.payload=i,this._id=25}encode(t){return t.uint(25)&&t.string(this.name)&&t.string(this.message)&&t.string(this.payload)}});s.set(25,E);const k=t(class{constructor(t,s){this.name=t,this.payload=s,this._id=27}encode(t){return t.uint(27)&&t.string(this.name)&&t.string(this.payload)}});s.set(27,k);const I=t(class{constructor(t){this.id=t,this._id=28}encode(t){return t.uint(28)&&t.string(this.id)}});s.set(28,I);const z=t(class{constructor(t){this.id=t,this._id=29}encode(t){return t.uint(29)&&t.string(this.id)}});s.set(29,z);const w=t(class{constructor(t,s){this.key=t,this.value=s,this._id=30}encode(t){return t.uint(30)&&t.string(this.key)&&t.string(this.value)}});s.set(30,w);const T=t(class{constructor(t,s,i){this.id=t,this.rule=s,this.index=i,this._id=37}encode(t){return t.uint(37)&&t.uint(this.id)&&t.string(this.rule)&&t.uint(this.index)}});s.set(37,T);const L=t(class{constructor(t,s){this.id=t,this.index=s,this._id=38}encode(t){return t.uint(38)&&t.uint(this.id)&&t.uint(this.index)}});s.set(38,L);const A=t(class{constructor(t,s,i,n,e,r,o){this.method=t,this.url=s,this.request=i,this.response=n,this.status=e,this.timestamp=r,this.duration=o,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)}});s.set(39,A);const C=t(class{constructor(t,s,i,n){this.name=t,this.duration=s,this.args=i,this.result=n,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)}});s.set(40,C);const M=t(class{constructor(t,s){this.key=t,this.value=s,this._id=41}encode(t){return t.uint(41)&&t.string(this.key)&&t.string(this.value)}});s.set(41,M);const R=t(class{constructor(t){this.type=t,this._id=42}encode(t){return t.uint(42)&&t.string(this.type)}});s.set(42,R);const N=t(class{constructor(t,s,i){this.action=t,this.state=s,this.duration=i,this._id=44}encode(t){return t.uint(44)&&t.string(this.action)&&t.string(this.state)&&t.uint(this.duration)}});s.set(44,N);const D=t(class{constructor(t,s){this.mutation=t,this.state=s,this._id=45}encode(t){return t.uint(45)&&t.string(this.mutation)&&t.string(this.state)}});s.set(45,D);const U=t(class{constructor(t,s){this.type=t,this.payload=s,this._id=46}encode(t){return t.uint(46)&&t.string(this.type)&&t.string(this.payload)}});s.set(46,U);const O=t(class{constructor(t,s,i){this.action=t,this.state=s,this.duration=i,this._id=47}encode(t){return t.uint(47)&&t.string(this.action)&&t.string(this.state)&&t.uint(this.duration)}});s.set(47,O);const q=t(class{constructor(t,s,i,n){this.operationKind=t,this.operationName=s,this.variables=i,this.response=n,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)}});s.set(48,q);const H=t(class{constructor(t,s,i,n){this.frames=t,this.ticks=s,this.totalJSHeapSize=i,this.usedJSHeapSize=n,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)}});s.set(49,H);const P=t(class{constructor(t,s,i,n,e,r,o,h){this.timestamp=t,this.duration=s,this.ttfb=i,this.headerSize=n,this.encodedBodySize=e,this.decodedBodySize=r,this.url=o,this.initiator=h,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)}});s.set(53,P);const B=t(class{constructor(t,s){this.downlink=t,this.type=s,this._id=54}encode(t){return t.uint(54)&&t.uint(this.downlink)&&t.string(this.type)}});s.set(54,B);const J=t(class{constructor(t){this.hidden=t,this._id=55}encode(t){return t.uint(55)&&t.boolean(this.hidden)}});s.set(55,J);const j=t(class{constructor(t,s,i,n,e,r,o){this.timestamp=t,this.duration=s,this.context=i,this.containerType=n,this.containerSrc=e,this.containerId=r,this.containerName=o,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)}});s.set(59,j);const G=t(class{constructor(t,s,i,n){this.id=t,this.name=s,this.value=i,this.baseURL=n,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)}});s.set(60,G);const K=t(class{constructor(t,s,i){this.id=t,this.data=s,this.baseURL=i,this._id=61}encode(t){return t.uint(61)&&t.uint(this.id)&&t.string(this.data)&&t.string(this.baseURL)}});s.set(61,K);const X=t(class{constructor(t,s){this.type=t,this.value=s,this._id=63}encode(t){return t.uint(63)&&t.string(this.type)&&t.string(this.value)}});s.set(63,X);const F=t(class{constructor(t,s){this.name=t,this.payload=s,this._id=64}encode(t){return t.uint(64)&&t.string(this.name)&&t.string(this.payload)}});s.set(64,F);const Q=t(class{constructor(){this._id=65}encode(t){return t.uint(65)}});s.set(65,Q);const V=t(class{constructor(t,s,i,n){this.id=t,this.rule=s,this.index=i,this.baseURL=n,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)}});s.set(67,V);const W=t(class{constructor(t,s,i,n){this.id=t,this.hesitationTime=s,this.label=i,this.selector=n,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)}});s.set(69,W);const Y=t(class{constructor(t,s){this.frameID=t,this.id=s,this._id=70}encode(t){return t.uint(70)&&t.uint(this.frameID)&&t.uint(this.id)}});s.set(70,Y);const Z="function"==typeof TextEncoder?new TextEncoder:{encode(t){const s=t.length,i=new Uint8Array(3*s);let n=-1;for(var e=0,r=0,o=0;o!==s;){if(e=t.charCodeAt(o),o+=1,e>=55296&&e<=56319){if(o===s){i[n+=1]=239,i[n+=1]=191,i[n+=1]=189;break}if(!((r=t.charCodeAt(o))>=56320&&r<=57343)){i[n+=1]=239,i[n+=1]=191,i[n+=1]=189;continue}if(o+=1,(e=1024*(e-55296)+r-56320+65536)>65535){i[n+=1]=240|e>>>18,i[n+=1]=128|e>>>12&63,i[n+=1]=128|e>>>6&63,i[n+=1]=128|63&e;continue}}e<=127?i[n+=1]=0|e:e<=2047?(i[n+=1]=192|e>>>6,i[n+=1]=128|63&e):(i[n+=1]=224|e>>>12,i[n+=1]=128|e>>>6&63,i[n+=1]=128|63&e)}return i.subarray(0,n+1)}};class tt{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 s=Z.encode(t),i=s.byteLength;return!(!this.uint(i)||this.offset+i>this.size)&&(this.data.set(s,this.offset),this.offset+=i,!0)}reset(){this.offset=0,this.checkpointOffset=0}flush(){const t=this.data.slice(0,this.checkpointOffset);return this.reset(),t}}let st=1e6,it=2e5,nt=new tt(it),et="",rt="",ot=0,ht=0,ct=0,ut=0,at=!0;function dt(){return new i(ot,ut,ht).encode(nt)}let lt=null;const gt=[];let ft,pt=!1,mt=0,_t=3e3,yt=10;function vt(){if(at||""===rt||""===et)return;const t=nt.flush();pt?gt.push(t):(pt=!0,function t(s){const i=new XMLHttpRequest;function n(){if(mt>=yt)return St(),void self.postMessage(null);mt++,setTimeout(()=>t(s),_t)}i.open("POST",et+"/v1/web/i",!1),i.setRequestHeader("Authorization","Bearer "+rt),i.onreadystatechange=function(){if(4===this.readyState){if(0==this.status)return;if(401===this.status)return pt=!1,void self.postMessage("restart");if(this.status>=400)return void n();mt=0;const s=gt.shift();s?t(s):pt=!1}},i.onerror=n,i.send(s.buffer)}(t)),at=!0,dt()}function St(){et="",rt="",null!==lt&&(clearInterval(lt),lt=null),gt.length=0,nt.reset()}self.onmessage=({data:t})=>{if(null!==t)return"stop"===t?(vt(),void St()):Array.isArray(t)?void t.forEach(t=>{const i=new(s.get(t._id));if(Object.assign(i,t),i instanceof n?ht=i.timestamp:i instanceof J&&(i.hidden?ft=setTimeout(()=>self.postMessage("restart"),18e5):clearTimeout(ft)),nt.checkpoint(),!i.encode(nt)&&(vt(),!i.encode(nt)))for(;!i.encode(nt);){if(it===st)return console.warn("OpenReplay: beacon size overflow."),nt.reset(),void dt();it=Math.min(2*it,st),nt=new tt(it),dt()}ut++,at=!1}):(et=t.ingestPoint||et,rt=t.token||rt,ot=t.pageNo||ot,ht=t.startTimestamp||ht,ct=t.timeAdjustment||ct,yt=t.connAttemptCount||yt,_t=t.connAttemptGap||_t,st=t.beaconSizeLimit||st,it=Math.min(st,t.beaconSize||it),nt.isEmpty()&&dt(),void(null===lt&&(lt=setInterval(vt,1e4))));vt()};
|
|
60
|
+
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 m=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,m);const g=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,g);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 b=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,b);const S=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,S);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 I=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,I);const M=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,M);const B=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,B);const L=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,L);const C=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,C);const A=t(class{constructor(t){this.type=t,this._id=42}encode(t){return t.uint(42)&&t.string(this.type)}});i.set(42,A);const U=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,U);const N=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,N);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.prepareBatchMeta()}prepareBatchMeta(){return new s(this.pageNo,this.nextIndex,this.timestamp).encode(this.writer)}setBeaconSizeLimit(t){this.beaconSizeLimit=t}writeMessage(t){if(t instanceof e&&(this.timestamp=t.timestamp),!t.encode(this.writer))for(this.isEmpty||(this.onBatch(this.writer.flush()),this.prepareBatchMeta());!t.encode(this.writer);){if(this.beaconSize===this.beaconSizeLimit)return console.warn("OpenReplay: beacon size overflow. Skipping large message."),this.writer.reset(),this.prepareBatchMeta(),void(this.isEmpty=!0);this.beaconSize=Math.min(2*this.beaconSize,this.beaconSizeLimit),this.writer=new it(this.beaconSize),this.prepareBatchMeta()}this.writer.checkpoint(),this.nextIndex++,this.isEmpty=!1}finaliseBatch(){this.isEmpty||(this.onBatch(this.writer.flush()),this.prepareBatchMeta(),this.isEmpty=!0)}clean(){this.writer.reset()}}let et=null,nt=null;function rt(){nt&&nt.finaliseBatch()}function ht(){null!==ct&&(clearInterval(ct),ct=null),nt&&(nt.clean(),nt=null)}let ot,ct=null;self.onmessage=({data:t})=>{if(null!=t){if("stop"===t)return rt(),void ht();if(Array.isArray(t)){if(!nt)throw new Error("WebWorker: writer not initialised.");const s=nt;t.forEach(t=>{const e=new(i.get(t._id));Object.assign(e,t),e instanceof H&&(e.hidden?ot=setTimeout(()=>self.postMessage("restart"),18e5):clearTimeout(ot)),s.writeMessage(e)})}else{if("start"===t.type)return et=new Z(t.ingestPoint,()=>{self.postMessage("restart")},()=>{et&&(et.clean(),et=null),ht(),self.postMessage("failed")},t.connAttemptCount,t.connAttemptGap),nt=new st(t.pageNo,t.timestamp,t=>et&&et.push(t)),void(null===ct&&(ct=setInterval(rt,1e4)));if("auth"===t.type){if(!et)throw new Error("WebWorker: sender not initialised. Recieved auth.");if(!nt)throw new Error("WebWorker: writer not initialised. Recieved auth.");return et.authorise(t.token),void(t.beaconSizeLimit&&nt.setBeaconSizeLimit(t.beaconSizeLimit))}}}else rt()};
|
|
62
61
|
`], { type: 'text/javascript' })));
|
|
63
62
|
this.worker.onerror = e => {
|
|
64
63
|
this._debug("webworker_error", e);
|
|
65
64
|
};
|
|
66
65
|
this.worker.onmessage = ({ data }) => {
|
|
67
|
-
if (data ===
|
|
66
|
+
if (data === "failed") {
|
|
68
67
|
this.stop();
|
|
69
68
|
}
|
|
70
69
|
else if (data === "restart") {
|
|
@@ -103,21 +102,18 @@ class App {
|
|
|
103
102
|
if (this.activityState === ActivityState.NotActive) {
|
|
104
103
|
return;
|
|
105
104
|
}
|
|
106
|
-
if (this.activityState === ActivityState.Starting) {
|
|
107
|
-
this.preStartMessages.push(message);
|
|
108
|
-
}
|
|
109
|
-
if (this.preStartMessages.length) {
|
|
110
|
-
this.messages.push(...this.preStartMessages);
|
|
111
|
-
this.preStartMessages.length = 0;
|
|
112
|
-
}
|
|
113
105
|
this.messages.push(message);
|
|
114
|
-
if
|
|
106
|
+
// TODO: commit on start if there were `urgent` sends;
|
|
107
|
+
// Clearify where urgent can be used for;
|
|
108
|
+
// Clearify workflow for each type of message in case it was sent before start
|
|
109
|
+
// (like Fetch before start; maybe add an option "preCapture: boolean" or sth alike)
|
|
110
|
+
if (this.activityState === ActivityState.Active && urgent) {
|
|
115
111
|
this.commit();
|
|
116
112
|
}
|
|
117
113
|
}
|
|
118
114
|
commit() {
|
|
119
115
|
if (this.worker && this.messages.length) {
|
|
120
|
-
this.messages.unshift(new
|
|
116
|
+
this.messages.unshift(new messages_js_1.Timestamp((0, utils_js_1.timestamp)()));
|
|
121
117
|
this.worker.postMessage(this.messages);
|
|
122
118
|
this.commitCallbacks.forEach(cb => cb(this.messages));
|
|
123
119
|
this.messages.length = 0;
|
|
@@ -243,14 +239,15 @@ class App {
|
|
|
243
239
|
}
|
|
244
240
|
sessionStorage.setItem(this.options.session_pageno_key, pageNo.toString());
|
|
245
241
|
const startInfo = this.getStartInfo();
|
|
246
|
-
const
|
|
247
|
-
|
|
242
|
+
const startWorkerMsg = {
|
|
243
|
+
type: "start",
|
|
248
244
|
pageNo,
|
|
249
|
-
|
|
245
|
+
ingestPoint: this.options.ingestPoint,
|
|
246
|
+
timestamp: startInfo.timestamp,
|
|
250
247
|
connAttemptCount: this.options.connAttemptCount,
|
|
251
248
|
connAttemptGap: this.options.connAttemptGap,
|
|
252
249
|
};
|
|
253
|
-
this.worker.postMessage(
|
|
250
|
+
this.worker.postMessage(startWorkerMsg); // brings delay of 10th ms?
|
|
254
251
|
const sReset = sessionStorage.getItem(this.options.session_reset_key);
|
|
255
252
|
sessionStorage.removeItem(this.options.session_reset_key);
|
|
256
253
|
return window.fetch(this.options.ingestPoint + '/v1/web/start', {
|
|
@@ -285,13 +282,18 @@ class App {
|
|
|
285
282
|
localStorage.setItem(this.options.local_uuid_key, userUUID);
|
|
286
283
|
this.session.update(Object.assign({ sessionID }, startOpts));
|
|
287
284
|
this.activityState = ActivityState.Active;
|
|
288
|
-
|
|
289
|
-
|
|
285
|
+
const startWorkerMsg = {
|
|
286
|
+
type: "auth",
|
|
287
|
+
token,
|
|
288
|
+
beaconSizeLimit
|
|
289
|
+
};
|
|
290
|
+
this.worker.postMessage(startWorkerMsg);
|
|
291
|
+
const onStartInfo = { sessionToken: token, userUUID, sessionID };
|
|
292
|
+
this.startCallbacks.forEach((cb) => cb(onStartInfo));
|
|
290
293
|
this.observer.observe();
|
|
291
294
|
this.ticker.start();
|
|
292
295
|
this.notify.log("OpenReplay tracking started.");
|
|
293
296
|
// TODO: get rid of onStart
|
|
294
|
-
const onStartInfo = { sessionToken: token, userUUID, sessionID };
|
|
295
297
|
if (typeof this.options.onStart === 'function') {
|
|
296
298
|
this.options.onStart(onStartInfo);
|
|
297
299
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const observer_js_1 = require("./observer.js");
|
|
4
|
-
const
|
|
4
|
+
const messages_js_1 = require("../../common/messages.js");
|
|
5
5
|
class IFrameObserver extends observer_js_1.default {
|
|
6
6
|
observe(iframe) {
|
|
7
7
|
const doc = iframe.contentDocument;
|
|
@@ -15,7 +15,7 @@ class IFrameObserver extends observer_js_1.default {
|
|
|
15
15
|
console.log("OpenReplay: Iframe document not bound");
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
-
this.app.send((0,
|
|
18
|
+
this.app.send((0, messages_js_1.CreateIFrameDocument)(hostID, docID));
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const messages_js_1 = require("../../common/messages.js");
|
|
4
4
|
const context_js_1 = require("../context.js");
|
|
5
5
|
function isSVGElement(node) {
|
|
6
6
|
return node.namespaceURI === 'http://www.w3.org/2000/svg';
|
|
@@ -99,16 +99,16 @@ class Observer {
|
|
|
99
99
|
name = name.substr(6);
|
|
100
100
|
}
|
|
101
101
|
if (value === null) {
|
|
102
|
-
this.app.send(new
|
|
102
|
+
this.app.send(new messages_js_1.RemoveNodeAttribute(id, name));
|
|
103
103
|
}
|
|
104
104
|
else if (name === 'href') {
|
|
105
105
|
if (value.length > 1e5) {
|
|
106
106
|
value = '';
|
|
107
107
|
}
|
|
108
|
-
this.app.send(new
|
|
108
|
+
this.app.send(new messages_js_1.SetNodeAttributeURLBased(id, name, value, this.app.getBaseHref()));
|
|
109
109
|
}
|
|
110
110
|
else {
|
|
111
|
-
this.app.send(new
|
|
111
|
+
this.app.send(new messages_js_1.SetNodeAttribute(id, name, value));
|
|
112
112
|
}
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
@@ -128,25 +128,25 @@ class Observer {
|
|
|
128
128
|
return;
|
|
129
129
|
}
|
|
130
130
|
if (value === null) {
|
|
131
|
-
this.app.send(new
|
|
131
|
+
this.app.send(new messages_js_1.RemoveNodeAttribute(id, name));
|
|
132
132
|
return;
|
|
133
133
|
}
|
|
134
134
|
if (name === 'style' || name === 'href' && (0, context_js_1.isInstance)(node, HTMLLinkElement)) {
|
|
135
|
-
this.app.send(new
|
|
135
|
+
this.app.send(new messages_js_1.SetNodeAttributeURLBased(id, name, value, this.app.getBaseHref()));
|
|
136
136
|
return;
|
|
137
137
|
}
|
|
138
138
|
if (name === 'href' || value.length > 1e5) {
|
|
139
139
|
value = '';
|
|
140
140
|
}
|
|
141
|
-
this.app.send(new
|
|
141
|
+
this.app.send(new messages_js_1.SetNodeAttribute(id, name, value));
|
|
142
142
|
}
|
|
143
143
|
sendNodeData(id, parentElement, data) {
|
|
144
144
|
if ((0, context_js_1.isInstance)(parentElement, HTMLStyleElement) || (0, context_js_1.isInstance)(parentElement, SVGStyleElement)) {
|
|
145
|
-
this.app.send(new
|
|
145
|
+
this.app.send(new messages_js_1.SetCSSDataURLBased(id, data, this.app.getBaseHref()));
|
|
146
146
|
return;
|
|
147
147
|
}
|
|
148
148
|
data = this.app.sanitizer.sanitize(id, data);
|
|
149
|
-
this.app.send(new
|
|
149
|
+
this.app.send(new messages_js_1.SetNodeData(id, data));
|
|
150
150
|
}
|
|
151
151
|
bindNode(node) {
|
|
152
152
|
const r = this.app.nodes.registerNode(node);
|
|
@@ -173,7 +173,7 @@ class Observer {
|
|
|
173
173
|
unbindNode(node) {
|
|
174
174
|
const id = this.app.nodes.unregisterNode(node);
|
|
175
175
|
if (id !== undefined && this.recents[id] === false) {
|
|
176
|
-
this.app.send(new
|
|
176
|
+
this.app.send(new messages_js_1.RemoveNode(id));
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
_commitNode(id, node) {
|
|
@@ -222,7 +222,7 @@ class Observer {
|
|
|
222
222
|
if (isNew === true) {
|
|
223
223
|
if ((0, context_js_1.isInstance)(node, Element)) {
|
|
224
224
|
if (parentID !== undefined) {
|
|
225
|
-
this.app.send(new
|
|
225
|
+
this.app.send(new messages_js_1.CreateElementNode(id, parentID, index, node.tagName, isSVGElement(node)));
|
|
226
226
|
}
|
|
227
227
|
for (let i = 0; i < node.attributes.length; i++) {
|
|
228
228
|
const attr = node.attributes[i];
|
|
@@ -231,13 +231,13 @@ class Observer {
|
|
|
231
231
|
}
|
|
232
232
|
else if ((0, context_js_1.isInstance)(node, Text)) {
|
|
233
233
|
// for text node id != 0, hence parentID !== undefined and parent is Element
|
|
234
|
-
this.app.send(new
|
|
234
|
+
this.app.send(new messages_js_1.CreateTextNode(id, parentID, index));
|
|
235
235
|
this.sendNodeData(id, parent, node.data);
|
|
236
236
|
}
|
|
237
237
|
return true;
|
|
238
238
|
}
|
|
239
239
|
if (isNew === false && parentID !== undefined) {
|
|
240
|
-
this.app.send(new
|
|
240
|
+
this.app.send(new messages_js_1.MoveNode(id, parentID, index));
|
|
241
241
|
}
|
|
242
242
|
const attr = this.attributesList[id];
|
|
243
243
|
if (attr !== undefined) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const observer_js_1 = require("./observer.js");
|
|
4
|
-
const
|
|
4
|
+
const messages_js_1 = require("../../common/messages.js");
|
|
5
5
|
class ShadowRootObserver extends observer_js_1.default {
|
|
6
6
|
observe(el) {
|
|
7
7
|
const shRoot = el.shadowRoot;
|
|
@@ -14,7 +14,7 @@ class ShadowRootObserver extends observer_js_1.default {
|
|
|
14
14
|
console.log("OpenReplay: Shadow Root was not bound");
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
-
this.app.send((0,
|
|
17
|
+
this.app.send((0, messages_js_1.CreateIFrameDocument)(hostID, rootID));
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -4,7 +4,7 @@ const observer_js_1 = require("./observer.js");
|
|
|
4
4
|
const context_js_1 = require("../context.js");
|
|
5
5
|
const iframe_observer_js_1 = require("./iframe_observer.js");
|
|
6
6
|
const shadow_root_observer_js_1 = require("./shadow_root_observer.js");
|
|
7
|
-
const
|
|
7
|
+
const messages_js_1 = require("../../common/messages.js");
|
|
8
8
|
const utils_js_1 = require("../../utils.js");
|
|
9
9
|
const attachShadowNativeFn = utils_js_1.IN_BROWSER ? Element.prototype.attachShadow : () => new ShadowRoot();
|
|
10
10
|
class TopObserver extends observer_js_1.default {
|
|
@@ -71,7 +71,7 @@ class TopObserver extends observer_js_1.default {
|
|
|
71
71
|
// the 0-node ("fRoot") will become #document rather than documentElement as it is now.
|
|
72
72
|
// Alternatively - observe(#document) then bindNode(documentElement)
|
|
73
73
|
this.observeRoot(window.document, () => {
|
|
74
|
-
this.app.send(new
|
|
74
|
+
this.app.send(new messages_js_1.CreateDocument());
|
|
75
75
|
}, window.document.documentElement);
|
|
76
76
|
}
|
|
77
77
|
disconnect() {
|
package/cjs/app/session.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const messages_js_1 = require("../common/messages.js");
|
|
4
4
|
var ActivityState;
|
|
5
5
|
(function (ActivityState) {
|
|
6
6
|
ActivityState[ActivityState["NotActive"] = 0] = "NotActive";
|
|
@@ -42,11 +42,11 @@ class Session {
|
|
|
42
42
|
this.handleUpdate();
|
|
43
43
|
}
|
|
44
44
|
_setMetadata(key, value) {
|
|
45
|
-
this.app.send(new
|
|
45
|
+
this.app.send(new messages_js_1.Metadata(key, value));
|
|
46
46
|
this.metadata[key] = value;
|
|
47
47
|
}
|
|
48
48
|
_setUserID(userID) {
|
|
49
|
-
this.app.send(new
|
|
49
|
+
this.app.send(new messages_js_1.UserID(userID));
|
|
50
50
|
this.userID = userID;
|
|
51
51
|
}
|
|
52
52
|
setMetadata(key, value) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Message from "./
|
|
2
|
-
|
|
1
|
+
import type { Writer, Message } from "./types.js";
|
|
2
|
+
export default Message;
|
|
3
3
|
export declare const classes: Map<number, Function>;
|
|
4
4
|
declare class _BatchMeta implements Message {
|
|
5
5
|
pageNo: number;
|
|
@@ -442,4 +442,3 @@ declare class _CreateIFrameDocument implements Message {
|
|
|
442
442
|
encode(writer: Writer): boolean;
|
|
443
443
|
}
|
|
444
444
|
export declare const CreateIFrameDocument: typeof _CreateIFrameDocument & ((frameID: number, id: number) => _CreateIFrameDocument);
|
|
445
|
-
export {};
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface Options {
|
|
2
|
+
connAttemptCount?: number;
|
|
3
|
+
connAttemptGap?: number;
|
|
4
|
+
}
|
|
5
|
+
declare type Start = {
|
|
6
|
+
type: "start";
|
|
7
|
+
ingestPoint: string;
|
|
8
|
+
pageNo: number;
|
|
9
|
+
timestamp: number;
|
|
10
|
+
} & Options;
|
|
11
|
+
declare type Auth = {
|
|
12
|
+
type: "auth";
|
|
13
|
+
token: string;
|
|
14
|
+
beaconSizeLimit?: number;
|
|
15
|
+
};
|
|
16
|
+
export declare type WorkerMessageData = null | "stop" | Start | Auth | Array<{
|
|
17
|
+
_id: number;
|
|
18
|
+
}>;
|
|
19
|
+
export {};
|
|
File without changes
|
package/cjs/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import App from "./app/index.js";
|
|
2
2
|
export { default as App } from './app/index.js';
|
|
3
|
-
import * as _Messages from "./messages
|
|
3
|
+
import * as _Messages from "./common/messages.js";
|
|
4
4
|
export declare const Messages: typeof _Messages;
|
|
5
5
|
import type { Options as AppOptions } from "./app/index.js";
|
|
6
6
|
import type { Options as ConsoleOptions } from "./modules/console.js";
|
|
@@ -24,7 +24,7 @@ export default class API {
|
|
|
24
24
|
constructor(options: Options);
|
|
25
25
|
use<T>(fn: (app: App | null, options?: Options) => T): T;
|
|
26
26
|
isActive(): boolean;
|
|
27
|
-
start(startOpts?: StartOptions): Promise<OnStartInfo>;
|
|
27
|
+
start(startOpts?: Partial<StartOptions>): Promise<OnStartInfo>;
|
|
28
28
|
stop(): void;
|
|
29
29
|
getSessionToken(): string | null | undefined;
|
|
30
30
|
getSessionID(): string | null | undefined;
|
package/cjs/index.js
CHANGED
|
@@ -4,8 +4,8 @@ exports.Messages = exports.App = void 0;
|
|
|
4
4
|
const index_js_1 = require("./app/index.js");
|
|
5
5
|
var index_js_2 = require("./app/index.js");
|
|
6
6
|
Object.defineProperty(exports, "App", { enumerable: true, get: function () { return index_js_2.default; } });
|
|
7
|
-
const
|
|
8
|
-
const _Messages = require("./messages
|
|
7
|
+
const messages_js_1 = require("./common/messages.js");
|
|
8
|
+
const _Messages = require("./common/messages.js");
|
|
9
9
|
exports.Messages = _Messages;
|
|
10
10
|
const connection_js_1 = require("./modules/connection.js");
|
|
11
11
|
const console_js_1 = require("./modules/console.js");
|
|
@@ -127,7 +127,7 @@ class API {
|
|
|
127
127
|
// no-cors issue only with text/plain or not-set Content-Type
|
|
128
128
|
// req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
|
129
129
|
req.send(JSON.stringify({
|
|
130
|
-
trackerVersion: '3.5.
|
|
130
|
+
trackerVersion: '3.5.11',
|
|
131
131
|
projectKey: options.projectKey,
|
|
132
132
|
doNotTrack,
|
|
133
133
|
// TODO: add precise reason (an exact API missing)
|
|
@@ -151,7 +151,7 @@ class API {
|
|
|
151
151
|
if (this.app === null) {
|
|
152
152
|
return Promise.reject("Browser doesn't support required api, or doNotTrack is active.");
|
|
153
153
|
}
|
|
154
|
-
// TODO: check argument
|
|
154
|
+
// TODO: check argument type
|
|
155
155
|
return this.app.start(startOpts);
|
|
156
156
|
}
|
|
157
157
|
stop() {
|
|
@@ -187,7 +187,7 @@ class API {
|
|
|
187
187
|
}
|
|
188
188
|
setUserAnonymousID(id) {
|
|
189
189
|
if (typeof id === 'string' && this.app !== null) {
|
|
190
|
-
this.app.send(new
|
|
190
|
+
this.app.send(new messages_js_1.UserAnonymousID(id));
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
userAnonymousID(id) {
|
|
@@ -217,7 +217,7 @@ class API {
|
|
|
217
217
|
catch (e) {
|
|
218
218
|
return;
|
|
219
219
|
}
|
|
220
|
-
this.app.send(new
|
|
220
|
+
this.app.send(new messages_js_1.RawCustomEvent(key, payload));
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
}
|
|
@@ -229,7 +229,7 @@ class API {
|
|
|
229
229
|
catch (e) {
|
|
230
230
|
return;
|
|
231
231
|
}
|
|
232
|
-
this.app.send(new
|
|
232
|
+
this.app.send(new messages_js_1.CustomIssue(key, payload));
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
235
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const messages_js_1 = require("../common/messages.js");
|
|
4
4
|
function default_1(app) {
|
|
5
5
|
const connection = navigator.connection ||
|
|
6
6
|
navigator.mozConnection ||
|
|
@@ -8,7 +8,7 @@ function default_1(app) {
|
|
|
8
8
|
if (connection === undefined) {
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
|
-
const sendConnectionInformation = () => app.send(new
|
|
11
|
+
const sendConnectionInformation = () => app.send(new messages_js_1.ConnectionInformation(Math.round(connection.downlink * 1000), connection.type || 'unknown'));
|
|
12
12
|
sendConnectionInformation();
|
|
13
13
|
connection.addEventListener('change', sendConnectionInformation);
|
|
14
14
|
}
|
package/cjs/modules/console.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_js_1 = require("../utils.js");
|
|
4
|
-
const
|
|
4
|
+
const messages_js_1 = require("../common/messages.js");
|
|
5
5
|
const printError = utils_js_1.IN_BROWSER && 'InstallTrigger' in window // detect Firefox
|
|
6
6
|
? (e) => e.message + '\n' + e.stack
|
|
7
7
|
: (e) => e.stack || e.message;
|
|
@@ -92,7 +92,7 @@ function default_1(app, opts) {
|
|
|
92
92
|
options.consoleMethods.length === 0) {
|
|
93
93
|
return;
|
|
94
94
|
}
|
|
95
|
-
const sendConsoleLog = app.safe((level, args) => app.send(new
|
|
95
|
+
const sendConsoleLog = app.safe((level, args) => app.send(new messages_js_1.ConsoleLog(level, printf(args))));
|
|
96
96
|
let n;
|
|
97
97
|
const reset = () => {
|
|
98
98
|
n = 0;
|
package/cjs/modules/cssrules.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const messages_js_1 = require("../common/messages.js");
|
|
4
4
|
function default_1(app) {
|
|
5
5
|
if (app === null) {
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
8
8
|
if (!window.CSSStyleSheet) {
|
|
9
|
-
app.send(new
|
|
9
|
+
app.send(new messages_js_1.TechnicalInfo("no_stylesheet_prototype_in_window", ""));
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
12
|
const processOperation = app.safe((stylesheet, index, rule) => {
|
|
13
13
|
const sendMessage = typeof rule === 'string'
|
|
14
|
-
? (nodeID) => app.send(new
|
|
15
|
-
: (nodeID) => app.send(new
|
|
14
|
+
? (nodeID) => app.send(new messages_js_1.CSSInsertRuleURLBased(nodeID, rule, index, app.getBaseHref()))
|
|
15
|
+
: (nodeID) => app.send(new messages_js_1.CSSDeleteRule(nodeID, index));
|
|
16
16
|
// TODO: Extend messages to maintain nested rules (CSSGroupingRule prototype, as well as CSSKeyframesRule)
|
|
17
17
|
if (stylesheet.ownerNode == null) {
|
|
18
18
|
throw new Error("Owner Node not found");
|