Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@openreplay/tracker

Package Overview
Dependencies
Maintainers
3
Versions
219
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@openreplay/tracker - npm Package Compare versions

Comparing version 3.3.1 to 3.4.0-debug.0

7

cjs/app/index.d.ts

@@ -18,4 +18,6 @@ import Message from '../messages/message';

ingestPoint: string;
resourceBaseHref: string | null;
__is_snippet: boolean;
__debug_report_edp: string | null;
__debug_log: boolean;
onStart?: (info: OnStartInfo) => void;

@@ -42,3 +44,3 @@ } & ObserverOptions & WebworkerOptions;

constructor(projectKey: string, sessionToken: string | null | undefined, opts: Partial<Options>);
private sendDebugReport;
private _debug;
send(message: Message, urgent?: boolean): void;

@@ -54,2 +56,5 @@ private commit;

getHost(): string;
getProjectKey(): string;
getBaseHref(): string;
resolveResourceURL(resourceURL: string): string;
isServiceURL(url: string): boolean;

@@ -56,0 +61,0 @@ active(): boolean;

68

cjs/app/index.js

@@ -20,3 +20,3 @@ "use strict";

this.isActive = false;
this.version = '3.3.1';
this.version = '3.4.0-debug.0';
this.projectKey = projectKey;

@@ -30,6 +30,9 @@ this.options = Object.assign({

ingestPoint: exports.DEFAULT_INGEST_POINT,
resourceBaseHref: null,
__is_snippet: false,
__debug_report_edp: null,
__debug_log: true,
obscureTextEmails: true,
obscureTextNumbers: false,
captureIFrames: false,
}, opts);

@@ -45,8 +48,7 @@ if (sessionToken != null) {

try {
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 k=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,k);const E=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,E);const z=t(class{constructor(t){this.id=t,this._id=28}encode(t){return t.uint(28)&&t.string(this.id)}});s.set(28,z);const w=t(class{constructor(t){this.id=t,this._id=29}encode(t){return t.uint(29)&&t.string(this.id)}});s.set(29,w);const I=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,I);const L=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,L);const T=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,T);const C=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,C);const A=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,A);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 U=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,U);const N=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,N);const O=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,O);const q=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,q);const D=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,D);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 K=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,K);const G=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,G);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="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 Z{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>=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=Y.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 tt,st=1e6,it=4e5,nt=new Z(it),et="",rt="",ot=0,ht=0,ct=0,ut=0,at=!0;function dt(){return new i(ot,ut,ht).encode(nt)}const lt=[];let gt,ft=!1,pt=0,mt=8e3,_t=10;function yt(){if(at||""===rt||""===et)return;const t=nt.flush();ft?lt.push(t):(ft=!0,function t(s){const i=new XMLHttpRequest;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(this.status>=400)return vt(),lt.length=0,403===this.status?void self.postMessage("restart"):void self.postMessage(null);const s=lt.shift();s?t(s):ft=!1}},i.onerror=function(i){if(pt>=_t)return vt(),void self.postMessage(null);pt++,setTimeout(()=>t(s),mt)},i.send(s.buffer)}(t)),at=!0,dt()}function vt(){et="",rt="",clearInterval(tt),nt.reset()}self.onmessage=({data:t})=>{if(null!==t)return"stop"===t?(yt(),void vt()):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?gt=setTimeout(()=>self.postMessage("restart"),3e5):clearTimeout(gt)),nt.checkpoint(),!i.encode(nt)&&(yt(),!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 Z(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,_t=t.connAttemptCount||_t,mt=t.connAttemptGap||mt,st=t.beaconSizeLimit||st,it=Math.min(st,t.beaconSize||it),nt.isEmpty()&&dt(),void(null==tt&&(tt=setInterval(yt,2e4))));yt()};
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 f=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,f);const g=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,g);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 z=t(class{constructor(t){this.id=t,this._id=28}encode(t){return t.uint(28)&&t.string(this.id)}});s.set(28,z);const I=t(class{constructor(t){this.id=t,this._id=29}encode(t){return t.uint(29)&&t.string(this.id)}});s.set(29,I);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 R=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,R);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 A=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,A);const M=t(class{constructor(t){this.type=t,this._id=42}encode(t){return t.uint(42)&&t.string(this.type)}});s.set(42,M);const O=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,O);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 N=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,N);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 K=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,K);const G=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,G);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>=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,it=1e6,nt=4e5,et=new tt(nt),rt="",ot="",ht=0,ct=0,ut=0,at=0,dt=!0;function lt(){return new i(ht,at,ct).encode(et)}const ft=[];let gt,pt=!1,mt=0,_t=8e3,yt=10;function vt(){if(dt||""===ot||""===rt)return;const t=et.flush();pt?ft.push(t):(pt=!0,function t(s){const i=new XMLHttpRequest;i.open("POST",rt+"/v1/web/i",!1),i.setRequestHeader("Authorization","Bearer "+ot),i.onreadystatechange=function(){if(4===this.readyState){if(0==this.status)return;if(this.status>=400)return St(),ft.length=0,401===this.status?void self.postMessage("restart"):(console.log("OpenReplay Response Error: ","status ",this.status,this.statusText,s.buffer),void self.postMessage(null));const i=ft.shift();i?t(i):pt=!1}},i.onerror=function(i){if(console.log("OpenReplay Send Error: ",i,s.buffer),mt>=yt)return St(),void self.postMessage(null);mt++,setTimeout(()=>t(s),_t)},i.send(s.buffer)}(t)),dt=!0,lt()}function St(){rt="",ot="",clearInterval(st),et.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?ct=i.timestamp:i instanceof J&&(i.hidden?gt=setTimeout(()=>self.postMessage("restart"),3e5):clearTimeout(gt)),et.checkpoint(),!i.encode(et)&&(vt(),!i.encode(et)))for(;!i.encode(et);){if(nt===it)return console.warn("OpenReplay: beacon size overflow."),et.reset(),void lt();nt=Math.min(2*nt,it),et=new tt(nt),lt()}at++,dt=!1}):(rt=t.ingestPoint||rt,ot=t.token||ot,ht=t.pageNo||ht,ct=t.startTimestamp||ct,ut=t.timeAdjustment||ut,yt=t.connAttemptCount||yt,_t=t.connAttemptGap||_t,it=t.beaconSizeLimit||it,nt=Math.min(it,t.beaconSize||nt),et.isEmpty()&&lt(),void(null==st&&(st=setInterval(vt,2e4))));vt()};
`], { type: 'text/javascript' })));
// this.worker.onerror = e => {
// this.send(new TechnicalInfo("webworker_error", JSON.stringify(e)));
// /* TODO: send report */
// }
this.worker.onerror = e => {
this._debug("webworker_error", e);
};
let lastTs = utils_1.timestamp();

@@ -68,2 +70,3 @@ let fileno = 0;

};
// TODO:on start
// TODO: keep better tactics, discard others (look https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon)

@@ -75,9 +78,10 @@ this.attachEventListener(window, 'beforeunload', alertWorker, false);

catch (e) {
this.sendDebugReport("worker_start", e);
this._debug("worker_start", e);
}
}
sendDebugReport(context, e) {
_debug(context, e) {
if (this.options.__debug_report_edp !== null) {
fetch(this.options.__debug_report_edp, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({

@@ -89,2 +93,5 @@ context,

}
if (this.options.__debug_log) {
utils_1.warn("OpenReplay errror: ", context, e);
}
}

@@ -118,8 +125,7 @@ send(message, urgent = false) {

catch (e) {
app.send(new messages_1.TechnicalInfo("error", JSON.stringify({
time: utils_1.timestamp(),
name: e.name,
message: e.message,
stack: e.stack
})));
this._debug("safe_fn_call", e);
// time: timestamp(),
// name: e.name,
// message: e.message,
// stack: e.stack
}

@@ -151,4 +157,27 @@ }; // TODO: correct typing

getHost() {
return new URL(this.options.ingestPoint).host;
return new URL(this.options.ingestPoint).hostname;
}
getProjectKey() {
return this.projectKey;
}
getBaseHref() {
var _a, _b;
if (typeof this.options.resourceBaseHref === 'string') {
return this.options.resourceBaseHref;
}
else if (typeof this.options.resourceBaseHref === 'object') {
//switch between types
}
if (document.baseURI) {
return document.baseURI;
}
// IE only
return ((_b = (_a = document.head) === null || _a === void 0 ? void 0 : _a.getElementsByTagName("base")[0]) === null || _b === void 0 ? void 0 : _b.getAttribute("href")) || location.origin + location.pathname;
}
resolveResourceURL(resourceURL) {
const base = new URL(this.getBaseHref());
base.pathname += "/" + new URL(resourceURL).pathname;
base.pathname.replace(/\/+/g, "/");
return base.toString();
}
isServiceURL(url) {

@@ -162,6 +191,6 @@ return url.startsWith(this.options.ingestPoint);

if (!this.isActive) {
this.isActive = true;
if (!this.worker) {
throw new Error("Stranger things: no worker found");
return Promise.reject("No worker found: perhaps, CSP is not set.");
}
this.isActive = true;
let pageNo = 0;

@@ -224,3 +253,3 @@ const pageNoStr = sessionStorage.getItem(this.options.session_pageno_key);

if (!this.worker) {
throw new Error("Stranger things: no worker found after start request");
throw new Error("no worker found after start request (this might not happen)");
}

@@ -240,3 +269,4 @@ this.worker.postMessage({ token, beaconSizeLimit });

this.stop();
this.sendDebugReport("session_start", e);
utils_1.warn("OpenReplay was unable to start. ", e);
this._debug("session_start", e);
throw e;

@@ -243,0 +273,0 @@ });

import App from './index';
interface Window extends WindowProxy {
HTMLInputElement: typeof HTMLInputElement;
HTMLLinkElement: typeof HTMLLinkElement;
HTMLStyleElement: typeof HTMLStyleElement;
SVGStyleElement: typeof SVGStyleElement;
HTMLIFrameElement: typeof HTMLIFrameElement;
Text: typeof Text;
Element: typeof Element;
}
export interface Options {
obscureTextEmails: boolean;
obscureTextNumbers: boolean;
captureIFrames: boolean;
}
export default class Observer {
private readonly app;
private readonly options;
private readonly context;
private readonly observer;

@@ -15,5 +27,6 @@ private readonly commited;

private readonly textMasked;
private readonly options;
constructor(app: App, opts: Options);
constructor(app: App, options: Options, context?: Window);
private clear;
private isInstance;
private isIgnored;
private sendNodeAttribute;

@@ -27,4 +40,8 @@ private sendNodeData;

private commitNodes;
private iframeObservers;
private handleIframe;
private observeIframe;
observe(): void;
disconnect(): void;
}
export {};

@@ -8,32 +8,36 @@ "use strict";

}
function isIgnored(node) {
if (node instanceof Text) {
return false;
}
if (!(node instanceof Element)) {
return true;
}
const tag = node.tagName.toUpperCase();
if (tag === 'LINK') {
const rel = node.getAttribute('rel');
const as = node.getAttribute('as');
return !((rel === null || rel === void 0 ? void 0 : rel.includes('stylesheet')) || as === "style" || as === "font");
}
return (tag === 'SCRIPT' ||
tag === 'NOSCRIPT' ||
tag === 'META' ||
tag === 'TITLE' ||
tag === 'BASE');
}
class Observer {
constructor(app, opts) {
constructor(app, options, context = window) {
this.app = app;
this.options = opts;
this.options = options;
this.context = context;
this.iframeObservers = [];
this.observer = new MutationObserver(this.app.safe((mutations) => {
var _a;
for (const mutation of mutations) {
const target = mutation.target;
if (isIgnored(target) || !document.contains(target)) {
const type = mutation.type;
// Special case
// Document 'childList' might happen in case of iframe.
// TODO: generalize as much as possible
if (this.isInstance(target, Document)
&& type === 'childList'
//&& new Array(mutation.addedNodes).some(node => this.isInstance(node, HTMLHtmlElement))
) {
const parentFrame = (_a = target.defaultView) === null || _a === void 0 ? void 0 : _a.frameElement;
if (!parentFrame) {
continue;
}
this.bindTree(target.documentElement);
const frameID = this.app.nodes.getID(parentFrame);
const docID = this.app.nodes.getID(target.documentElement);
if (frameID === undefined || docID === undefined) {
continue;
}
this.app.send(messages_1.CreateIFrameDocument(frameID, docID));
continue;
}
const type = mutation.type;
if (this.isIgnored(target) || !context.document.contains(target)) {
continue;
}
if (type === 'childList') {

@@ -89,2 +93,35 @@ for (let i = 0; i < mutation.removedNodes.length; i++) {

}
// TODO: we need a type expert here so we won't have to ignore the lines
isInstance(node, constr) {
let context = this.context;
while (context.parent && context.parent !== context) {
// @ts-ignore
if (node instanceof context[constr.name]) {
return true;
}
// @ts-ignore
context = context.parent;
}
// @ts-ignore
return node instanceof context[constr.name];
}
isIgnored(node) {
if (this.isInstance(node, Text)) {
return false;
}
if (!this.isInstance(node, Element)) {
return true;
}
const tag = node.tagName.toUpperCase();
if (tag === 'LINK') {
const rel = node.getAttribute('rel');
const as = node.getAttribute('as');
return !((rel === null || rel === void 0 ? void 0 : rel.includes('stylesheet')) || as === "style" || as === "font");
}
return (tag === 'SCRIPT' ||
tag === 'NOSCRIPT' ||
tag === 'META' ||
tag === 'TITLE' ||
tag === 'BASE');
}
sendNodeAttribute(id, node, name, value) {

@@ -102,3 +139,3 @@ if (isSVGElement(node)) {

}
this.app.send(new messages_1.SetNodeAttributeURLBased(id, name, value, utils_1.getBaseURI()));
this.app.send(new messages_1.SetNodeAttributeURLBased(id, name, value, this.app.getBaseHref()));
}

@@ -119,3 +156,3 @@ else {

if (name === 'value' &&
node instanceof HTMLInputElement &&
this.isInstance(node, HTMLInputElement) &&
node.type !== 'button' &&

@@ -130,4 +167,4 @@ node.type !== 'reset' &&

}
if (name === 'style' || name === 'href' && node instanceof HTMLLinkElement) {
this.app.send(new messages_1.SetNodeAttributeURLBased(id, name, value, utils_1.getBaseURI()));
if (name === 'style' || name === 'href' && this.isInstance(node, HTMLLinkElement)) {
this.app.send(new messages_1.SetNodeAttributeURLBased(id, name, value, this.app.getBaseHref()));
return;

@@ -141,4 +178,4 @@ }

sendNodeData(id, parentElement, data) {
if (parentElement instanceof HTMLStyleElement || parentElement instanceof SVGStyleElement) {
this.app.send(new messages_1.SetCSSDataURLBased(id, data, utils_1.getBaseURI()));
if (this.isInstance(parentElement, HTMLStyleElement) || this.isInstance(parentElement, SVGStyleElement)) {
this.app.send(new messages_1.SetCSSDataURLBased(id, data, this.app.getBaseHref()));
return;

@@ -165,3 +202,3 @@ }

bindTree(node) {
if (isIgnored(node)) {
if (this.isIgnored(node)) {
return;

@@ -171,3 +208,3 @@ }

const walker = document.createTreeWalker(node, NodeFilter.SHOW_ELEMENT + NodeFilter.SHOW_TEXT, {
acceptNode: (node) => isIgnored(node) || this.app.nodes.getID(node) !== undefined
acceptNode: (node) => this.isIgnored(node) || this.app.nodes.getID(node) !== undefined
? NodeFilter.FILTER_REJECT

@@ -189,3 +226,6 @@ : NodeFilter.FILTER_ACCEPT,

let parentID;
if (id !== 0) {
if (this.isInstance(node, HTMLHtmlElement)) {
this.indexes[id] = 0;
}
else {
if (parent === null) {

@@ -205,3 +245,3 @@ this.unbindNode(node);

if (this.textMasked.has(parentID) ||
(node instanceof Element && utils_1.hasOpenreplayAttribute(node, 'masked'))) {
(this.isInstance(node, Element) && utils_1.hasOpenreplayAttribute(node, 'masked'))) {
this.textMasked.add(id);

@@ -229,3 +269,3 @@ }

if (isNew === true) {
if (node instanceof Element) {
if (this.isInstance(node, Element)) {
if (parentID !== undefined) {

@@ -238,4 +278,8 @@ this.app.send(new messages_1.CreateElementNode(id, parentID, index, node.tagName, isSVGElement(node)));

}
if (this.isInstance(node, HTMLIFrameElement) &&
(this.options.captureIFrames || node.getAttribute("data-openreplay-capture"))) {
this.handleIframe(node);
}
}
else if (node instanceof Text) {
else if (this.isInstance(node, Text)) {
// for text node id != 0, hence parentID !== undefined and parent is Element

@@ -252,3 +296,3 @@ this.app.send(new messages_1.CreateTextNode(id, parentID, index));

if (attr !== undefined) {
if (!(node instanceof Element)) {
if (!this.isInstance(node, Element)) {
throw 'commitNode: node is not an element';

@@ -261,3 +305,3 @@ }

if (this.textSet.has(id)) {
if (!(node instanceof Text)) {
if (!this.isInstance(node, Text)) {
throw 'commitNode: node is not a text';

@@ -291,4 +335,38 @@ }

}
handleIframe(iframe) {
const handle = () => {
const context = iframe.contentWindow;
const id = this.app.nodes.getID(iframe);
if (!context || id === undefined) {
return;
}
const observer = new Observer(this.app, this.options, context);
this.iframeObservers.push(observer);
observer.observeIframe(id, context);
};
this.app.attachEventListener(iframe, "load", handle);
handle();
}
// TODO: abstract common functionality, separate FrameObserver
observeIframe(id, context) {
const doc = context.document;
this.observer.observe(doc, {
childList: true,
attributes: true,
characterData: true,
subtree: true,
attributeOldValue: false,
characterDataOldValue: false,
});
this.bindTree(doc.documentElement);
const docID = this.app.nodes.getID(doc.documentElement);
if (docID === undefined) {
console.log("Wrong");
return;
}
this.app.send(messages_1.CreateIFrameDocument(id, docID));
this.commitNodes();
}
observe() {
this.observer.observe(document, {
this.observer.observe(this.context.document, {
childList: true,

@@ -302,6 +380,8 @@ attributes: true,

this.app.send(new messages_1.CreateDocument());
this.bindTree(document.documentElement);
this.bindTree(this.context.document.documentElement);
this.commitNodes();
}
disconnect() {
this.iframeObservers.forEach(o => o.disconnect());
this.iframeObservers = [];
this.observer.disconnect();

@@ -308,0 +388,0 @@ this.clear();

@@ -26,3 +26,3 @@ "use strict";

if (obj == null) {
console.error(`OpenReplay: invalid options argument type. Please, check documentation on https://docs.openreplay.com${DOCS_SETUP}`);
console.error(`OpenReplay: invalid options argument type. Please, check documentation on ${utils_1.DOCS_HOST}${DOCS_SETUP}`);
return false;

@@ -33,3 +33,3 @@ }

if (typeof obj.projectID !== 'number') { // Back compatability
console.error(`OpenReplay: projectKey is missing or wrong type (string is expected). Please, check https://docs.openreplay.com${DOCS_SETUP} for more information.`);
console.error(`OpenReplay: projectKey is missing or wrong type (string is expected). Please, check ${utils_1.DOCS_HOST}${DOCS_SETUP} for more information.`);
return false;

@@ -48,3 +48,3 @@ }

if (typeof obj.sessionToken !== 'string' && obj.sessionToken != null) {
console.warn(`OpenReplay: invalid options argument type. Please, check documentation on https://docs.openreplay.com${DOCS_SETUP}`);
console.warn(`OpenReplay: invalid options argument type. Please, check documentation on ${utils_1.DOCS_HOST}${DOCS_SETUP}`);
}

@@ -75,2 +75,6 @@ return true;

}
if (window.__OPENREPLAY__) {
console.error("OpenReplay: one tracker instance has been initialised already");
return;
}
if (!options.__DISABLE_SECURE_MODE && location.protocol !== 'https:') {

@@ -105,3 +109,3 @@ console.error("OpenReplay: Your website must be publicly accessible and running on SSL in order for OpenReplay to properly capture and replay the user session. You can disable this check by setting `__DISABLE_SECURE_MODE` option to `true` if you are testing in localhost. Keep in mind, that asset files on a local machine are not available to the outside world. This might affect tracking if you use css files.");

longtasks_1.default(this.app);
window.__OPENREPLAY__ = window.__OPENREPLAY__ || this;
window.__OPENREPLAY__ = this;
}

@@ -116,3 +120,3 @@ else {

req.send(JSON.stringify({
trackerVersion: '3.3.1',
trackerVersion: '3.4.0-debug.0',
projectKey: options.projectKey,

@@ -139,3 +143,3 @@ doNotTrack,

if (!utils_1.IN_BROWSER) {
console.error(`OpenReplay: you are trying to start Tracker on a node.js environment. If you want to use OpenReplay with SSR, please, use componentDidMount or useEffect API for placing the \`tracker.start()\` line. Check documentation on https://docs.openreplay.com${DOCS_SETUP}`);
console.error(`OpenReplay: you are trying to start Tracker on a node.js environment. If you want to use OpenReplay with SSR, please, use componentDidMount or useEffect API for placing the \`tracker.start()\` line. Check documentation on ${utils_1.DOCS_HOST}${DOCS_SETUP}`);
return;

@@ -142,0 +146,0 @@ }

@@ -437,2 +437,10 @@ import Message from './message';

export declare const MouseClick: typeof _MouseClick & ((id: number, hesitationTime: number, label: string, selector: string) => _MouseClick);
declare class _CreateIFrameDocument implements Message {
frameID: number;
id: number;
readonly _id: number;
constructor(frameID: number, id: number);
encode(writer: Writer): boolean;
}
export declare const CreateIFrameDocument: typeof _CreateIFrameDocument & ((frameID: number, id: number) => _CreateIFrameDocument);
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseClick = exports.CSSInsertRuleURLBased = exports.PageClose = exports.CustomIssue = exports.TechnicalInfo = exports.SetCSSDataURLBased = exports.SetNodeAttributeURLBased = exports.LongTask = exports.SetPageVisibility = exports.ConnectionInformation = exports.ResourceTiming = exports.PerformanceTrack = exports.GraphQL = exports.NgRx = exports.MobX = exports.Vuex = exports.Redux = exports.StateAction = exports.OTable = exports.Profiler = exports.Fetch = exports.CSSDeleteRule = exports.CSSInsertRule = exports.Metadata = exports.UserAnonymousID = exports.UserID = exports.RawCustomEvent = exports.JSException = exports.PageRenderTiming = exports.PageLoadTiming = exports.ConsoleLog = exports.MouseMove = exports.SetInputChecked = exports.SetInputValue = exports.SetInputTarget = exports.SetNodeScroll = exports.SetNodeData = exports.RemoveNodeAttribute = exports.SetNodeAttribute = exports.RemoveNode = exports.MoveNode = exports.CreateTextNode = exports.CreateElementNode = exports.CreateDocument = exports.SetViewportScroll = exports.SetViewportSize = exports.SetPageLocation = exports.Timestamp = exports.BatchMeta = exports.classes = void 0;
exports.CreateIFrameDocument = void 0;
function bindNew(Class) {

@@ -780,1 +781,15 @@ function _Class(...args) {

exports.classes.set(69, exports.MouseClick);
class _CreateIFrameDocument {
constructor(frameID, id) {
this.frameID = frameID;
this.id = id;
this._id = 70;
}
encode(writer) {
return writer.uint(70) &&
writer.uint(this.frameID) &&
writer.uint(this.id);
}
}
exports.CreateIFrameDocument = bindNew(_CreateIFrameDocument);
exports.classes.set(70, exports.CreateIFrameDocument);

@@ -5,2 +5,3 @@ export interface Options {

beaconSize?: number;
__debug_log?: boolean;
}

@@ -7,0 +8,0 @@ declare type Settings = {

@@ -104,3 +104,3 @@ "use strict";

if (consoleMethods.indexOf(method) === -1) {
console.error(`Asayer: unsupported console method ${method}`);
console.error(`OpenReplay: unsupported console method "${method}"`);
return;

@@ -107,0 +107,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const messages_1 = require("../messages");
const utils_1 = require("../utils");
function default_1(app) {

@@ -15,3 +14,3 @@ if (app === null) {

const sendMessage = typeof rule === 'string'
? (nodeID) => app.send(new messages_1.CSSInsertRuleURLBased(nodeID, rule, index, utils_1.getBaseURI()))
? (nodeID) => app.send(new messages_1.CSSInsertRuleURLBased(nodeID, rule, index, app.getBaseHref()))
: (nodeID) => app.send(new messages_1.CSSDeleteRule(nodeID, index));

@@ -18,0 +17,0 @@ // TODO: Extend messages to maintain nested rules (CSSGroupingRule prototype, as well as CSSKeyframesRule)

@@ -21,3 +21,3 @@ "use strict";

else if (src.length < 1e5) {
app.send(new messages_1.SetNodeAttributeURLBased(id, 'src', src, utils_1.getBaseURI()));
app.send(new messages_1.SetNodeAttributeURLBased(id, 'src', src, app.getBaseHref()));
}

@@ -34,3 +34,3 @@ });

const src = target.src;
app.send(new messages_1.SetNodeAttributeURLBased(id, 'src', src, utils_1.getBaseURI()));
app.send(new messages_1.SetNodeAttributeURLBased(id, 'src', src, app.getBaseHref()));
}

@@ -37,0 +37,0 @@ }

import type { Options as FinderOptions } from '../vendors/finder/finder';
import App from '../app';
interface HeatmapsOptions {
finder: FinderOptions;
}
export interface Options {
selectorFinder: boolean | FinderOptions;
heatmaps: boolean | HeatmapsOptions;
}
export default function (app: App, opts: Partial<Options>): void;
export {};

@@ -70,3 +70,8 @@ "use strict";

const options = Object.assign({
selectorFinder: true,
heatmaps: {
finder: {
threshold: 5,
maxNumberOfTries: 600,
},
},
}, opts);

@@ -92,7 +97,7 @@ let mousePositionX = -1;

function getSelector(id, target) {
if (options.selectorFinder === false) {
if (options.heatmaps === false) {
return '';
}
return selectorMap[id] = selectorMap[id] ||
finder_1.finder(target, options.selectorFinder === true ? undefined : options.selectorFinder);
finder_1.finder(target, options.heatmaps === true ? undefined : options.heatmaps.finder);
}

@@ -99,0 +104,0 @@ app.attachEventListener(document.documentElement, 'mouseover', (e) => {

@@ -71,8 +71,17 @@ "use strict";

if (!options.captureResourceTimings) {
options.capturePageLoadTimings = false;
options.capturePageRenderTimings = false;
return;
} // Resources are necessary for all timings
const mQueue = [];
function sendOnStart(m) {
if (app.active()) {
app.send(m);
}
else {
mQueue.push(m);
}
}
let resources = options.captureResourceTimings
? {}
: null;
app.attachStartCallback(function () {
mQueue.forEach(m => app.send(m));
});
let resources = {};
function resourceTiming(entry) {

@@ -84,3 +93,3 @@ if (entry.duration <= 0 || !utils_1.isURL(entry.name) || app.isServiceURL(entry.name))

}
app.send(new messages_1.ResourceTiming(entry.startTime + performance.timing.navigationStart, entry.duration, entry.responseStart && entry.startTime
sendOnStart(new messages_1.ResourceTiming(entry.startTime + performance.timing.navigationStart, entry.duration, entry.responseStart && entry.startTime
? entry.responseStart - entry.startTime

@@ -91,11 +100,7 @@ : 0, entry.transferSize > entry.encodedBodySize

}
const observer = options.captureResourceTimings
? new PerformanceObserver((list) => list.getEntries().forEach(resourceTiming))
: null;
if (observer !== null) {
performance.getEntriesByType('resource').forEach(resourceTiming);
observer.observe({ entryTypes: ['resource'] });
}
const observer = new PerformanceObserver((list) => list.getEntries().forEach(resourceTiming));
performance.getEntriesByType('resource').forEach(resourceTiming);
observer.observe({ entryTypes: ['resource'] });
let firstPaint = 0, firstContentfulPaint = 0;
if (options.capturePageLoadTimings && observer !== null) {
if (options.capturePageLoadTimings) {
let pageLoadTimingSent = false;

@@ -128,3 +133,3 @@ app.ticker.attach(() => {

}
if (options.capturePageRenderTimings && observer !== null) {
if (options.capturePageRenderTimings) {
let visuallyComplete = 0, interactiveWindowStartTime = 0, interactiveWindowTickTime = 0, paintBlocks = null;

@@ -131,0 +136,0 @@ let pageRenderTimingSent = false;

@@ -5,3 +5,2 @@ export declare function timestamp(): number;

export declare function isURL(s: string): boolean;
export declare function getBaseURI(): string;
export declare const IN_BROWSER: boolean;

@@ -16,4 +15,5 @@ export declare const log: {

};
export declare const DOCS_HOST = "https://docs.openreplay.com";
export declare function deprecationWarn(nameOfFeature: string, useInstead: string, docsPath?: string): void;
export declare function getLabelAttribute(e: Element): string | null;
export declare function hasOpenreplayAttribute(e: Element, name: string): boolean;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hasOpenreplayAttribute = exports.getLabelAttribute = exports.deprecationWarn = exports.warn = exports.log = exports.IN_BROWSER = exports.getBaseURI = exports.isURL = exports.normSpaces = exports.stars = exports.timestamp = void 0;
exports.hasOpenreplayAttribute = exports.getLabelAttribute = exports.deprecationWarn = exports.DOCS_HOST = exports.warn = exports.log = exports.IN_BROWSER = exports.isURL = exports.normSpaces = exports.stars = exports.timestamp = void 0;
function timestamp() {

@@ -20,15 +20,6 @@ return Math.round(performance.now()) + performance.timing.navigationStart;

exports.isURL = isURL;
function getBaseURI() {
var _a, _b;
if (document.baseURI) {
return document.baseURI;
}
// IE only
return ((_b = (_a = document.head) === null || _a === void 0 ? void 0 : _a.getElementsByTagName("base")[0]) === null || _b === void 0 ? void 0 : _b.getAttribute("href")) || location.origin + location.pathname;
}
exports.getBaseURI = getBaseURI;
exports.IN_BROWSER = !(typeof window === "undefined");
exports.log = console.log;
exports.warn = console.warn;
const DOCS_HOST = 'https://docs.openreplay.com';
exports.DOCS_HOST = 'https://docs.openreplay.com';
const warnedFeatures = {};

@@ -39,3 +30,3 @@ function deprecationWarn(nameOfFeature, useInstead, docsPath = "/") {

}
exports.warn(`OpenReplay: ${nameOfFeature} is deprecated. ${useInstead ? `Please, use ${useInstead} instead.` : ""} Visit ${DOCS_HOST}${docsPath} for more information.`);
exports.warn(`OpenReplay: ${nameOfFeature} is deprecated. ${useInstead ? `Please, use ${useInstead} instead.` : ""} Visit ${exports.DOCS_HOST}${docsPath} for more information.`);
warnedFeatures[nameOfFeature] = true;

@@ -42,0 +33,0 @@ }

@@ -18,4 +18,6 @@ import Message from '../messages/message';

ingestPoint: string;
resourceBaseHref: string | null;
__is_snippet: boolean;
__debug_report_edp: string | null;
__debug_log: boolean;
onStart?: (info: OnStartInfo) => void;

@@ -42,3 +44,3 @@ } & ObserverOptions & WebworkerOptions;

constructor(projectKey: string, sessionToken: string | null | undefined, opts: Partial<Options>);
private sendDebugReport;
private _debug;
send(message: Message, urgent?: boolean): void;

@@ -54,2 +56,5 @@ private commit;

getHost(): string;
getProjectKey(): string;
getBaseHref(): string;
resolveResourceURL(resourceURL: string): string;
isServiceURL(url: string): boolean;

@@ -56,0 +61,0 @@ active(): boolean;

@@ -1,3 +0,3 @@

import { timestamp, log } from '../utils';
import { Timestamp, TechnicalInfo } from '../messages';
import { timestamp, log, warn } from '../utils';
import { Timestamp } from '../messages';
import Nodes from './nodes';

@@ -17,3 +17,3 @@ import Observer from './observer';

this.isActive = false;
this.version = '3.3.1';
this.version = '3.4.0-debug.0';
this.projectKey = projectKey;

@@ -27,6 +27,9 @@ this.options = Object.assign({

ingestPoint: DEFAULT_INGEST_POINT,
resourceBaseHref: null,
__is_snippet: false,
__debug_report_edp: null,
__debug_log: true,
obscureTextEmails: true,
obscureTextNumbers: false,
captureIFrames: false,
}, opts);

@@ -42,8 +45,7 @@ if (sessionToken != null) {

try {
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 k=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,k);const E=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,E);const z=t(class{constructor(t){this.id=t,this._id=28}encode(t){return t.uint(28)&&t.string(this.id)}});s.set(28,z);const w=t(class{constructor(t){this.id=t,this._id=29}encode(t){return t.uint(29)&&t.string(this.id)}});s.set(29,w);const I=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,I);const L=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,L);const T=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,T);const C=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,C);const A=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,A);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 U=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,U);const N=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,N);const O=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,O);const q=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,q);const D=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,D);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 K=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,K);const G=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,G);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="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 Z{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>=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=Y.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 tt,st=1e6,it=4e5,nt=new Z(it),et="",rt="",ot=0,ht=0,ct=0,ut=0,at=!0;function dt(){return new i(ot,ut,ht).encode(nt)}const lt=[];let gt,ft=!1,pt=0,mt=8e3,_t=10;function yt(){if(at||""===rt||""===et)return;const t=nt.flush();ft?lt.push(t):(ft=!0,function t(s){const i=new XMLHttpRequest;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(this.status>=400)return vt(),lt.length=0,403===this.status?void self.postMessage("restart"):void self.postMessage(null);const s=lt.shift();s?t(s):ft=!1}},i.onerror=function(i){if(pt>=_t)return vt(),void self.postMessage(null);pt++,setTimeout(()=>t(s),mt)},i.send(s.buffer)}(t)),at=!0,dt()}function vt(){et="",rt="",clearInterval(tt),nt.reset()}self.onmessage=({data:t})=>{if(null!==t)return"stop"===t?(yt(),void vt()):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?gt=setTimeout(()=>self.postMessage("restart"),3e5):clearTimeout(gt)),nt.checkpoint(),!i.encode(nt)&&(yt(),!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 Z(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,_t=t.connAttemptCount||_t,mt=t.connAttemptGap||mt,st=t.beaconSizeLimit||st,it=Math.min(st,t.beaconSize||it),nt.isEmpty()&&dt(),void(null==tt&&(tt=setInterval(yt,2e4))));yt()};
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 f=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,f);const g=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,g);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 z=t(class{constructor(t){this.id=t,this._id=28}encode(t){return t.uint(28)&&t.string(this.id)}});s.set(28,z);const I=t(class{constructor(t){this.id=t,this._id=29}encode(t){return t.uint(29)&&t.string(this.id)}});s.set(29,I);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 R=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,R);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 A=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,A);const M=t(class{constructor(t){this.type=t,this._id=42}encode(t){return t.uint(42)&&t.string(this.type)}});s.set(42,M);const O=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,O);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 N=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,N);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 K=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,K);const G=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,G);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>=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,it=1e6,nt=4e5,et=new tt(nt),rt="",ot="",ht=0,ct=0,ut=0,at=0,dt=!0;function lt(){return new i(ht,at,ct).encode(et)}const ft=[];let gt,pt=!1,mt=0,_t=8e3,yt=10;function vt(){if(dt||""===ot||""===rt)return;const t=et.flush();pt?ft.push(t):(pt=!0,function t(s){const i=new XMLHttpRequest;i.open("POST",rt+"/v1/web/i",!1),i.setRequestHeader("Authorization","Bearer "+ot),i.onreadystatechange=function(){if(4===this.readyState){if(0==this.status)return;if(this.status>=400)return St(),ft.length=0,401===this.status?void self.postMessage("restart"):(console.log("OpenReplay Response Error: ","status ",this.status,this.statusText,s.buffer),void self.postMessage(null));const i=ft.shift();i?t(i):pt=!1}},i.onerror=function(i){if(console.log("OpenReplay Send Error: ",i,s.buffer),mt>=yt)return St(),void self.postMessage(null);mt++,setTimeout(()=>t(s),_t)},i.send(s.buffer)}(t)),dt=!0,lt()}function St(){rt="",ot="",clearInterval(st),et.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?ct=i.timestamp:i instanceof J&&(i.hidden?gt=setTimeout(()=>self.postMessage("restart"),3e5):clearTimeout(gt)),et.checkpoint(),!i.encode(et)&&(vt(),!i.encode(et)))for(;!i.encode(et);){if(nt===it)return console.warn("OpenReplay: beacon size overflow."),et.reset(),void lt();nt=Math.min(2*nt,it),et=new tt(nt),lt()}at++,dt=!1}):(rt=t.ingestPoint||rt,ot=t.token||ot,ht=t.pageNo||ht,ct=t.startTimestamp||ct,ut=t.timeAdjustment||ut,yt=t.connAttemptCount||yt,_t=t.connAttemptGap||_t,it=t.beaconSizeLimit||it,nt=Math.min(it,t.beaconSize||nt),et.isEmpty()&&lt(),void(null==st&&(st=setInterval(vt,2e4))));vt()};
`], { type: 'text/javascript' })));
// this.worker.onerror = e => {
// this.send(new TechnicalInfo("webworker_error", JSON.stringify(e)));
// /* TODO: send report */
// }
this.worker.onerror = e => {
this._debug("webworker_error", e);
};
let lastTs = timestamp();

@@ -65,2 +67,3 @@ let fileno = 0;

};
// TODO:on start
// TODO: keep better tactics, discard others (look https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon)

@@ -72,9 +75,10 @@ this.attachEventListener(window, 'beforeunload', alertWorker, false);

catch (e) {
this.sendDebugReport("worker_start", e);
this._debug("worker_start", e);
}
}
sendDebugReport(context, e) {
_debug(context, e) {
if (this.options.__debug_report_edp !== null) {
fetch(this.options.__debug_report_edp, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({

@@ -86,2 +90,5 @@ context,

}
if (this.options.__debug_log) {
warn("OpenReplay errror: ", context, e);
}
}

@@ -115,8 +122,7 @@ send(message, urgent = false) {

catch (e) {
app.send(new TechnicalInfo("error", JSON.stringify({
time: timestamp(),
name: e.name,
message: e.message,
stack: e.stack
})));
this._debug("safe_fn_call", e);
// time: timestamp(),
// name: e.name,
// message: e.message,
// stack: e.stack
}

@@ -148,4 +154,27 @@ }; // TODO: correct typing

getHost() {
return new URL(this.options.ingestPoint).host;
return new URL(this.options.ingestPoint).hostname;
}
getProjectKey() {
return this.projectKey;
}
getBaseHref() {
var _a, _b;
if (typeof this.options.resourceBaseHref === 'string') {
return this.options.resourceBaseHref;
}
else if (typeof this.options.resourceBaseHref === 'object') {
//switch between types
}
if (document.baseURI) {
return document.baseURI;
}
// IE only
return ((_b = (_a = document.head) === null || _a === void 0 ? void 0 : _a.getElementsByTagName("base")[0]) === null || _b === void 0 ? void 0 : _b.getAttribute("href")) || location.origin + location.pathname;
}
resolveResourceURL(resourceURL) {
const base = new URL(this.getBaseHref());
base.pathname += "/" + new URL(resourceURL).pathname;
base.pathname.replace(/\/+/g, "/");
return base.toString();
}
isServiceURL(url) {

@@ -159,6 +188,6 @@ return url.startsWith(this.options.ingestPoint);

if (!this.isActive) {
this.isActive = true;
if (!this.worker) {
throw new Error("Stranger things: no worker found");
return Promise.reject("No worker found: perhaps, CSP is not set.");
}
this.isActive = true;
let pageNo = 0;

@@ -221,3 +250,3 @@ const pageNoStr = sessionStorage.getItem(this.options.session_pageno_key);

if (!this.worker) {
throw new Error("Stranger things: no worker found after start request");
throw new Error("no worker found after start request (this might not happen)");
}

@@ -237,3 +266,4 @@ this.worker.postMessage({ token, beaconSizeLimit });

this.stop();
this.sendDebugReport("session_start", e);
warn("OpenReplay was unable to start. ", e);
this._debug("session_start", e);
throw e;

@@ -240,0 +270,0 @@ });

import App from './index';
interface Window extends WindowProxy {
HTMLInputElement: typeof HTMLInputElement;
HTMLLinkElement: typeof HTMLLinkElement;
HTMLStyleElement: typeof HTMLStyleElement;
SVGStyleElement: typeof SVGStyleElement;
HTMLIFrameElement: typeof HTMLIFrameElement;
Text: typeof Text;
Element: typeof Element;
}
export interface Options {
obscureTextEmails: boolean;
obscureTextNumbers: boolean;
captureIFrames: boolean;
}
export default class Observer {
private readonly app;
private readonly options;
private readonly context;
private readonly observer;

@@ -15,5 +27,6 @@ private readonly commited;

private readonly textMasked;
private readonly options;
constructor(app: App, opts: Options);
constructor(app: App, options: Options, context?: Window);
private clear;
private isInstance;
private isIgnored;
private sendNodeAttribute;

@@ -27,4 +40,8 @@ private sendNodeData;

private commitNodes;
private iframeObservers;
private handleIframe;
private observeIframe;
observe(): void;
disconnect(): void;
}
export {};

@@ -1,36 +0,40 @@

import { stars, hasOpenreplayAttribute, getBaseURI } from '../utils';
import { CreateDocument, CreateElementNode, CreateTextNode, SetNodeData, SetCSSDataURLBased, SetNodeAttribute, SetNodeAttributeURLBased, RemoveNodeAttribute, MoveNode, RemoveNode, } from '../messages';
import { stars, hasOpenreplayAttribute } from '../utils';
import { CreateDocument, CreateElementNode, CreateTextNode, SetNodeData, SetCSSDataURLBased, SetNodeAttribute, SetNodeAttributeURLBased, RemoveNodeAttribute, MoveNode, RemoveNode, CreateIFrameDocument, } from '../messages';
function isSVGElement(node) {
return node.namespaceURI === 'http://www.w3.org/2000/svg';
}
function isIgnored(node) {
if (node instanceof Text) {
return false;
}
if (!(node instanceof Element)) {
return true;
}
const tag = node.tagName.toUpperCase();
if (tag === 'LINK') {
const rel = node.getAttribute('rel');
const as = node.getAttribute('as');
return !((rel === null || rel === void 0 ? void 0 : rel.includes('stylesheet')) || as === "style" || as === "font");
}
return (tag === 'SCRIPT' ||
tag === 'NOSCRIPT' ||
tag === 'META' ||
tag === 'TITLE' ||
tag === 'BASE');
}
export default class Observer {
constructor(app, opts) {
constructor(app, options, context = window) {
this.app = app;
this.options = opts;
this.options = options;
this.context = context;
this.iframeObservers = [];
this.observer = new MutationObserver(this.app.safe((mutations) => {
var _a;
for (const mutation of mutations) {
const target = mutation.target;
if (isIgnored(target) || !document.contains(target)) {
const type = mutation.type;
// Special case
// Document 'childList' might happen in case of iframe.
// TODO: generalize as much as possible
if (this.isInstance(target, Document)
&& type === 'childList'
//&& new Array(mutation.addedNodes).some(node => this.isInstance(node, HTMLHtmlElement))
) {
const parentFrame = (_a = target.defaultView) === null || _a === void 0 ? void 0 : _a.frameElement;
if (!parentFrame) {
continue;
}
this.bindTree(target.documentElement);
const frameID = this.app.nodes.getID(parentFrame);
const docID = this.app.nodes.getID(target.documentElement);
if (frameID === undefined || docID === undefined) {
continue;
}
this.app.send(CreateIFrameDocument(frameID, docID));
continue;
}
const type = mutation.type;
if (this.isIgnored(target) || !context.document.contains(target)) {
continue;
}
if (type === 'childList') {

@@ -86,2 +90,35 @@ for (let i = 0; i < mutation.removedNodes.length; i++) {

}
// TODO: we need a type expert here so we won't have to ignore the lines
isInstance(node, constr) {
let context = this.context;
while (context.parent && context.parent !== context) {
// @ts-ignore
if (node instanceof context[constr.name]) {
return true;
}
// @ts-ignore
context = context.parent;
}
// @ts-ignore
return node instanceof context[constr.name];
}
isIgnored(node) {
if (this.isInstance(node, Text)) {
return false;
}
if (!this.isInstance(node, Element)) {
return true;
}
const tag = node.tagName.toUpperCase();
if (tag === 'LINK') {
const rel = node.getAttribute('rel');
const as = node.getAttribute('as');
return !((rel === null || rel === void 0 ? void 0 : rel.includes('stylesheet')) || as === "style" || as === "font");
}
return (tag === 'SCRIPT' ||
tag === 'NOSCRIPT' ||
tag === 'META' ||
tag === 'TITLE' ||
tag === 'BASE');
}
sendNodeAttribute(id, node, name, value) {

@@ -99,3 +136,3 @@ if (isSVGElement(node)) {

}
this.app.send(new SetNodeAttributeURLBased(id, name, value, getBaseURI()));
this.app.send(new SetNodeAttributeURLBased(id, name, value, this.app.getBaseHref()));
}

@@ -116,3 +153,3 @@ else {

if (name === 'value' &&
node instanceof HTMLInputElement &&
this.isInstance(node, HTMLInputElement) &&
node.type !== 'button' &&

@@ -127,4 +164,4 @@ node.type !== 'reset' &&

}
if (name === 'style' || name === 'href' && node instanceof HTMLLinkElement) {
this.app.send(new SetNodeAttributeURLBased(id, name, value, getBaseURI()));
if (name === 'style' || name === 'href' && this.isInstance(node, HTMLLinkElement)) {
this.app.send(new SetNodeAttributeURLBased(id, name, value, this.app.getBaseHref()));
return;

@@ -138,4 +175,4 @@ }

sendNodeData(id, parentElement, data) {
if (parentElement instanceof HTMLStyleElement || parentElement instanceof SVGStyleElement) {
this.app.send(new SetCSSDataURLBased(id, data, getBaseURI()));
if (this.isInstance(parentElement, HTMLStyleElement) || this.isInstance(parentElement, SVGStyleElement)) {
this.app.send(new SetCSSDataURLBased(id, data, this.app.getBaseHref()));
return;

@@ -162,3 +199,3 @@ }

bindTree(node) {
if (isIgnored(node)) {
if (this.isIgnored(node)) {
return;

@@ -168,3 +205,3 @@ }

const walker = document.createTreeWalker(node, NodeFilter.SHOW_ELEMENT + NodeFilter.SHOW_TEXT, {
acceptNode: (node) => isIgnored(node) || this.app.nodes.getID(node) !== undefined
acceptNode: (node) => this.isIgnored(node) || this.app.nodes.getID(node) !== undefined
? NodeFilter.FILTER_REJECT

@@ -186,3 +223,6 @@ : NodeFilter.FILTER_ACCEPT,

let parentID;
if (id !== 0) {
if (this.isInstance(node, HTMLHtmlElement)) {
this.indexes[id] = 0;
}
else {
if (parent === null) {

@@ -202,3 +242,3 @@ this.unbindNode(node);

if (this.textMasked.has(parentID) ||
(node instanceof Element && hasOpenreplayAttribute(node, 'masked'))) {
(this.isInstance(node, Element) && hasOpenreplayAttribute(node, 'masked'))) {
this.textMasked.add(id);

@@ -226,3 +266,3 @@ }

if (isNew === true) {
if (node instanceof Element) {
if (this.isInstance(node, Element)) {
if (parentID !== undefined) {

@@ -235,4 +275,8 @@ this.app.send(new CreateElementNode(id, parentID, index, node.tagName, isSVGElement(node)));

}
if (this.isInstance(node, HTMLIFrameElement) &&
(this.options.captureIFrames || node.getAttribute("data-openreplay-capture"))) {
this.handleIframe(node);
}
}
else if (node instanceof Text) {
else if (this.isInstance(node, Text)) {
// for text node id != 0, hence parentID !== undefined and parent is Element

@@ -249,3 +293,3 @@ this.app.send(new CreateTextNode(id, parentID, index));

if (attr !== undefined) {
if (!(node instanceof Element)) {
if (!this.isInstance(node, Element)) {
throw 'commitNode: node is not an element';

@@ -258,3 +302,3 @@ }

if (this.textSet.has(id)) {
if (!(node instanceof Text)) {
if (!this.isInstance(node, Text)) {
throw 'commitNode: node is not a text';

@@ -288,4 +332,38 @@ }

}
handleIframe(iframe) {
const handle = () => {
const context = iframe.contentWindow;
const id = this.app.nodes.getID(iframe);
if (!context || id === undefined) {
return;
}
const observer = new Observer(this.app, this.options, context);
this.iframeObservers.push(observer);
observer.observeIframe(id, context);
};
this.app.attachEventListener(iframe, "load", handle);
handle();
}
// TODO: abstract common functionality, separate FrameObserver
observeIframe(id, context) {
const doc = context.document;
this.observer.observe(doc, {
childList: true,
attributes: true,
characterData: true,
subtree: true,
attributeOldValue: false,
characterDataOldValue: false,
});
this.bindTree(doc.documentElement);
const docID = this.app.nodes.getID(doc.documentElement);
if (docID === undefined) {
console.log("Wrong");
return;
}
this.app.send(CreateIFrameDocument(id, docID));
this.commitNodes();
}
observe() {
this.observer.observe(document, {
this.observer.observe(this.context.document, {
childList: true,

@@ -299,6 +377,8 @@ attributes: true,

this.app.send(new CreateDocument());
this.bindTree(document.documentElement);
this.bindTree(this.context.document.documentElement);
this.commitNodes();
}
disconnect() {
this.iframeObservers.forEach(o => o.disconnect());
this.iframeObservers = [];
this.observer.disconnect();

@@ -305,0 +385,0 @@ this.clear();

@@ -18,7 +18,7 @@ import App, { DEFAULT_INGEST_POINT } from './app';

import CSSRules from './modules/cssrules';
import { IN_BROWSER, deprecationWarn } from './utils';
import { IN_BROWSER, deprecationWarn, DOCS_HOST } from './utils';
const DOCS_SETUP = '/installation/setup-or';
function processOptions(obj) {
if (obj == null) {
console.error(`OpenReplay: invalid options argument type. Please, check documentation on https://docs.openreplay.com${DOCS_SETUP}`);
console.error(`OpenReplay: invalid options argument type. Please, check documentation on ${DOCS_HOST}${DOCS_SETUP}`);
return false;

@@ -29,3 +29,3 @@ }

if (typeof obj.projectID !== 'number') { // Back compatability
console.error(`OpenReplay: projectKey is missing or wrong type (string is expected). Please, check https://docs.openreplay.com${DOCS_SETUP} for more information.`);
console.error(`OpenReplay: projectKey is missing or wrong type (string is expected). Please, check ${DOCS_HOST}${DOCS_SETUP} for more information.`);
return false;

@@ -44,3 +44,3 @@ }

if (typeof obj.sessionToken !== 'string' && obj.sessionToken != null) {
console.warn(`OpenReplay: invalid options argument type. Please, check documentation on https://docs.openreplay.com${DOCS_SETUP}`);
console.warn(`OpenReplay: invalid options argument type. Please, check documentation on ${DOCS_HOST}${DOCS_SETUP}`);
}

@@ -71,2 +71,6 @@ return true;

}
if (window.__OPENREPLAY__) {
console.error("OpenReplay: one tracker instance has been initialised already");
return;
}
if (!options.__DISABLE_SECURE_MODE && location.protocol !== 'https:') {

@@ -101,3 +105,3 @@ console.error("OpenReplay: Your website must be publicly accessible and running on SSL in order for OpenReplay to properly capture and replay the user session. You can disable this check by setting `__DISABLE_SECURE_MODE` option to `true` if you are testing in localhost. Keep in mind, that asset files on a local machine are not available to the outside world. This might affect tracking if you use css files.");

Longtasks(this.app);
window.__OPENREPLAY__ = window.__OPENREPLAY__ || this;
window.__OPENREPLAY__ = this;
}

@@ -112,3 +116,3 @@ else {

req.send(JSON.stringify({
trackerVersion: '3.3.1',
trackerVersion: '3.4.0-debug.0',
projectKey: options.projectKey,

@@ -135,3 +139,3 @@ doNotTrack,

if (!IN_BROWSER) {
console.error(`OpenReplay: you are trying to start Tracker on a node.js environment. If you want to use OpenReplay with SSR, please, use componentDidMount or useEffect API for placing the \`tracker.start()\` line. Check documentation on https://docs.openreplay.com${DOCS_SETUP}`);
console.error(`OpenReplay: you are trying to start Tracker on a node.js environment. If you want to use OpenReplay with SSR, please, use componentDidMount or useEffect API for placing the \`tracker.start()\` line. Check documentation on ${DOCS_HOST}${DOCS_SETUP}`);
return;

@@ -138,0 +142,0 @@ }

@@ -437,2 +437,10 @@ import Message from './message';

export declare const MouseClick: typeof _MouseClick & ((id: number, hesitationTime: number, label: string, selector: string) => _MouseClick);
declare class _CreateIFrameDocument implements Message {
frameID: number;
id: number;
readonly _id: number;
constructor(frameID: number, id: number);
encode(writer: Writer): boolean;
}
export declare const CreateIFrameDocument: typeof _CreateIFrameDocument & ((frameID: number, id: number) => _CreateIFrameDocument);
export {};

@@ -777,1 +777,15 @@ function bindNew(Class) {

classes.set(69, MouseClick);
class _CreateIFrameDocument {
constructor(frameID, id) {
this.frameID = frameID;
this.id = id;
this._id = 70;
}
encode(writer) {
return writer.uint(70) &&
writer.uint(this.frameID) &&
writer.uint(this.id);
}
}
export const CreateIFrameDocument = bindNew(_CreateIFrameDocument);
classes.set(70, CreateIFrameDocument);

@@ -5,2 +5,3 @@ export interface Options {

beaconSize?: number;
__debug_log?: boolean;
}

@@ -7,0 +8,0 @@ declare type Settings = {

@@ -102,3 +102,3 @@ import { IN_BROWSER } from '../utils';

if (consoleMethods.indexOf(method) === -1) {
console.error(`Asayer: unsupported console method ${method}`);
console.error(`OpenReplay: unsupported console method "${method}"`);
return;

@@ -105,0 +105,0 @@ }

import { CSSInsertRuleURLBased, CSSDeleteRule, TechnicalInfo } from '../messages';
import { getBaseURI } from '../utils';
export default function (app) {

@@ -13,3 +12,3 @@ if (app === null) {

const sendMessage = typeof rule === 'string'
? (nodeID) => app.send(new CSSInsertRuleURLBased(nodeID, rule, index, getBaseURI()))
? (nodeID) => app.send(new CSSInsertRuleURLBased(nodeID, rule, index, app.getBaseHref()))
: (nodeID) => app.send(new CSSDeleteRule(nodeID, index));

@@ -16,0 +15,0 @@ // TODO: Extend messages to maintain nested rules (CSSGroupingRule prototype, as well as CSSKeyframesRule)

@@ -1,2 +0,2 @@

import { timestamp, isURL, getBaseURI } from '../utils';
import { timestamp, isURL } from '../utils';
import { ResourceTiming, SetNodeAttributeURLBased } from '../messages';

@@ -19,3 +19,3 @@ export default function (app) {

else if (src.length < 1e5) {
app.send(new SetNodeAttributeURLBased(id, 'src', src, getBaseURI()));
app.send(new SetNodeAttributeURLBased(id, 'src', src, app.getBaseHref()));
}

@@ -32,3 +32,3 @@ });

const src = target.src;
app.send(new SetNodeAttributeURLBased(id, 'src', src, getBaseURI()));
app.send(new SetNodeAttributeURLBased(id, 'src', src, app.getBaseHref()));
}

@@ -35,0 +35,0 @@ }

import type { Options as FinderOptions } from '../vendors/finder/finder';
import App from '../app';
interface HeatmapsOptions {
finder: FinderOptions;
}
export interface Options {
selectorFinder: boolean | FinderOptions;
heatmaps: boolean | HeatmapsOptions;
}
export default function (app: App, opts: Partial<Options>): void;
export {};

@@ -68,3 +68,8 @@ import { finder } from '../vendors/finder/finder';

const options = Object.assign({
selectorFinder: true,
heatmaps: {
finder: {
threshold: 5,
maxNumberOfTries: 600,
},
},
}, opts);

@@ -90,7 +95,7 @@ let mousePositionX = -1;

function getSelector(id, target) {
if (options.selectorFinder === false) {
if (options.heatmaps === false) {
return '';
}
return selectorMap[id] = selectorMap[id] ||
finder(target, options.selectorFinder === true ? undefined : options.selectorFinder);
finder(target, options.heatmaps === true ? undefined : options.heatmaps.finder);
}

@@ -97,0 +102,0 @@ app.attachEventListener(document.documentElement, 'mouseover', (e) => {

@@ -69,8 +69,17 @@ import { isURL } from '../utils';

if (!options.captureResourceTimings) {
options.capturePageLoadTimings = false;
options.capturePageRenderTimings = false;
return;
} // Resources are necessary for all timings
const mQueue = [];
function sendOnStart(m) {
if (app.active()) {
app.send(m);
}
else {
mQueue.push(m);
}
}
let resources = options.captureResourceTimings
? {}
: null;
app.attachStartCallback(function () {
mQueue.forEach(m => app.send(m));
});
let resources = {};
function resourceTiming(entry) {

@@ -82,3 +91,3 @@ if (entry.duration <= 0 || !isURL(entry.name) || app.isServiceURL(entry.name))

}
app.send(new ResourceTiming(entry.startTime + performance.timing.navigationStart, entry.duration, entry.responseStart && entry.startTime
sendOnStart(new ResourceTiming(entry.startTime + performance.timing.navigationStart, entry.duration, entry.responseStart && entry.startTime
? entry.responseStart - entry.startTime

@@ -89,11 +98,7 @@ : 0, entry.transferSize > entry.encodedBodySize

}
const observer = options.captureResourceTimings
? new PerformanceObserver((list) => list.getEntries().forEach(resourceTiming))
: null;
if (observer !== null) {
performance.getEntriesByType('resource').forEach(resourceTiming);
observer.observe({ entryTypes: ['resource'] });
}
const observer = new PerformanceObserver((list) => list.getEntries().forEach(resourceTiming));
performance.getEntriesByType('resource').forEach(resourceTiming);
observer.observe({ entryTypes: ['resource'] });
let firstPaint = 0, firstContentfulPaint = 0;
if (options.capturePageLoadTimings && observer !== null) {
if (options.capturePageLoadTimings) {
let pageLoadTimingSent = false;

@@ -126,3 +131,3 @@ app.ticker.attach(() => {

}
if (options.capturePageRenderTimings && observer !== null) {
if (options.capturePageRenderTimings) {
let visuallyComplete = 0, interactiveWindowStartTime = 0, interactiveWindowTickTime = 0, paintBlocks = null;

@@ -129,0 +134,0 @@ let pageRenderTimingSent = false;

@@ -5,3 +5,2 @@ export declare function timestamp(): number;

export declare function isURL(s: string): boolean;
export declare function getBaseURI(): string;
export declare const IN_BROWSER: boolean;

@@ -16,4 +15,5 @@ export declare const log: {

};
export declare const DOCS_HOST = "https://docs.openreplay.com";
export declare function deprecationWarn(nameOfFeature: string, useInstead: string, docsPath?: string): void;
export declare function getLabelAttribute(e: Element): string | null;
export declare function hasOpenreplayAttribute(e: Element, name: string): boolean;

@@ -14,14 +14,6 @@ export function timestamp() {

}
export function getBaseURI() {
var _a, _b;
if (document.baseURI) {
return document.baseURI;
}
// IE only
return ((_b = (_a = document.head) === null || _a === void 0 ? void 0 : _a.getElementsByTagName("base")[0]) === null || _b === void 0 ? void 0 : _b.getAttribute("href")) || location.origin + location.pathname;
}
export const IN_BROWSER = !(typeof window === "undefined");
export const log = console.log;
export const warn = console.warn;
const DOCS_HOST = 'https://docs.openreplay.com';
export const DOCS_HOST = 'https://docs.openreplay.com';
const warnedFeatures = {};

@@ -28,0 +20,0 @@ export function deprecationWarn(nameOfFeature, useInstead, docsPath = "/") {

{
"name": "@openreplay/tracker",
"description": "The OpenReplay tracker main package",
"version": "3.3.1",
"version": "3.4.0-debug.0",
"keywords": [

@@ -6,0 +6,0 @@ "logging",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc