@openreplay/tracker 11.0.6 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -2
- package/cjs/app/index.d.ts +84 -6
- package/cjs/app/index.js +427 -58
- package/cjs/app/logger.d.ts +7 -17
- package/cjs/app/logger.js +11 -19
- package/cjs/app/messages.gen.d.ts +2 -0
- package/cjs/app/messages.gen.js +20 -1
- package/cjs/app/observer/iframe_observer.js +4 -1
- package/cjs/app/observer/shadow_root_observer.js +4 -1
- package/cjs/app/observer/top_observer.js +7 -4
- package/cjs/common/interaction.d.ts +5 -2
- package/cjs/common/messages.gen.d.ts +17 -2
- package/cjs/index.d.ts +45 -2
- package/cjs/index.js +237 -106
- package/cjs/modules/Network/beaconProxy.js +4 -1
- package/cjs/modules/Network/fetchProxy.js +24 -1
- package/cjs/modules/Network/index.js +6 -3
- package/cjs/modules/Network/xhrProxy.js +24 -1
- package/cjs/modules/conditionsManager.d.ts +84 -0
- package/cjs/modules/conditionsManager.js +343 -0
- package/cjs/modules/exception.js +4 -1
- package/cjs/modules/featureFlags.d.ts +1 -1
- package/cjs/modules/featureFlags.js +36 -46
- package/cjs/modules/network.js +5 -2
- package/cjs/modules/tagWatcher.d.ts +21 -0
- package/cjs/modules/tagWatcher.js +77 -0
- package/cjs/modules/userTesting/index.js +30 -4
- package/cjs/modules/userTesting/recorder.js +71 -88
- package/coverage/clover.xml +577 -544
- package/coverage/coverage-final.json +8 -8
- package/coverage/lcov-report/index.html +28 -28
- package/coverage/lcov-report/main/app/canvas.ts.html +97 -46
- package/coverage/lcov-report/main/app/guards.ts.html +1 -1
- package/coverage/lcov-report/main/app/index.html +19 -19
- package/coverage/lcov-report/main/app/index.ts.html +62 -35
- package/coverage/lcov-report/main/app/logger.ts.html +1 -1
- package/coverage/lcov-report/main/app/messages.gen.ts.html +32 -5
- package/coverage/lcov-report/main/app/nodes.ts.html +17 -5
- package/coverage/lcov-report/main/app/observer/iframe_observer.ts.html +1 -1
- package/coverage/lcov-report/main/app/observer/iframe_offsets.ts.html +1 -1
- package/coverage/lcov-report/main/app/observer/index.html +1 -1
- package/coverage/lcov-report/main/app/observer/shadow_root_observer.ts.html +1 -1
- package/coverage/lcov-report/main/app/observer/top_observer.ts.html +1 -1
- package/coverage/lcov-report/main/app/sanitizer.ts.html +1 -1
- package/coverage/lcov-report/main/app/session.ts.html +1 -1
- package/coverage/lcov-report/main/app/ticker.ts.html +1 -1
- package/coverage/lcov-report/main/index.html +9 -9
- package/coverage/lcov-report/main/index.ts.html +27 -6
- package/coverage/lcov-report/main/modules/Network/beaconProxy.ts.html +1 -1
- package/coverage/lcov-report/main/modules/Network/fetchProxy.ts.html +1 -1
- package/coverage/lcov-report/main/modules/Network/index.html +1 -1
- package/coverage/lcov-report/main/modules/Network/index.ts.html +1 -1
- package/coverage/lcov-report/main/modules/Network/networkMessage.ts.html +1 -1
- package/coverage/lcov-report/main/modules/Network/utils.ts.html +1 -1
- package/coverage/lcov-report/main/modules/Network/xhrProxy.ts.html +1 -1
- package/coverage/lcov-report/main/modules/attributeSender.ts.html +1 -1
- package/coverage/lcov-report/main/modules/axiosSpy.ts.html +1 -1
- package/coverage/lcov-report/main/modules/conditionsManager.ts.html +92 -38
- package/coverage/lcov-report/main/modules/connection.ts.html +1 -1
- package/coverage/lcov-report/main/modules/console.ts.html +1 -1
- package/coverage/lcov-report/main/modules/constructedStyleSheets.ts.html +1 -1
- package/coverage/lcov-report/main/modules/cssrules.ts.html +1 -1
- package/coverage/lcov-report/main/modules/exception.ts.html +1 -1
- package/coverage/lcov-report/main/modules/featureFlags.ts.html +1 -1
- package/coverage/lcov-report/main/modules/focus.ts.html +1 -1
- package/coverage/lcov-report/main/modules/fonts.ts.html +1 -1
- package/coverage/lcov-report/main/modules/img.ts.html +1 -1
- package/coverage/lcov-report/main/modules/index.html +21 -21
- package/coverage/lcov-report/main/modules/input.ts.html +1 -1
- package/coverage/lcov-report/main/modules/mouse.ts.html +1 -1
- package/coverage/lcov-report/main/modules/network.ts.html +1 -1
- package/coverage/lcov-report/main/modules/performance.ts.html +1 -1
- package/coverage/lcov-report/main/modules/scroll.ts.html +1 -1
- package/coverage/lcov-report/main/modules/selection.ts.html +1 -1
- package/coverage/lcov-report/main/modules/tabs.ts.html +1 -1
- package/coverage/lcov-report/main/modules/tagWatcher.ts.html +54 -27
- package/coverage/lcov-report/main/modules/timing.ts.html +1 -1
- package/coverage/lcov-report/main/modules/userTesting/SignalManager.ts.html +1 -1
- package/coverage/lcov-report/main/modules/userTesting/dnd.ts.html +1 -1
- package/coverage/lcov-report/main/modules/userTesting/index.html +1 -1
- package/coverage/lcov-report/main/modules/userTesting/index.ts.html +1 -1
- package/coverage/lcov-report/main/modules/userTesting/recorder.ts.html +1 -1
- package/coverage/lcov-report/main/modules/userTesting/styles.ts.html +1 -1
- package/coverage/lcov-report/main/modules/userTesting/utils.ts.html +1 -1
- package/coverage/lcov-report/main/modules/viewport.ts.html +1 -1
- package/coverage/lcov-report/main/utils.ts.html +1 -1
- package/coverage/lcov-report/webworker/BatchWriter.ts.html +1 -1
- package/coverage/lcov-report/webworker/MessageEncoder.gen.ts.html +17 -5
- package/coverage/lcov-report/webworker/PrimitiveEncoder.ts.html +1 -1
- package/coverage/lcov-report/webworker/QueueSender.ts.html +1 -1
- package/coverage/lcov-report/webworker/index.html +7 -7
- package/coverage/lcov-report/webworker/index.ts.html +1 -1
- package/coverage/lcov.info +1100 -1033
- package/lib/app/index.d.ts +84 -6
- package/lib/app/index.js +387 -44
- package/lib/app/logger.d.ts +7 -17
- package/lib/app/logger.js +11 -19
- package/lib/app/messages.gen.d.ts +2 -0
- package/lib/app/messages.gen.js +17 -0
- package/lib/common/interaction.d.ts +5 -2
- package/lib/common/messages.gen.d.ts +17 -2
- package/lib/common/tsconfig.tsbuildinfo +1 -1
- package/lib/index.d.ts +45 -2
- package/lib/index.js +191 -86
- package/lib/modules/conditionsManager.d.ts +84 -0
- package/lib/modules/conditionsManager.js +340 -0
- package/lib/modules/featureFlags.d.ts +1 -1
- package/lib/modules/featureFlags.js +36 -46
- package/lib/modules/tagWatcher.d.ts +21 -0
- package/lib/modules/tagWatcher.js +74 -0
- package/lib/modules/userTesting/recorder.js +71 -88
- package/package.json +1 -1
- package/tsconfig-base.json +3 -2
package/cjs/app/index.js
CHANGED
|
@@ -1,21 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
2
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
29
|
exports.DEFAULT_INGEST_POINT = void 0;
|
|
30
|
+
const conditionsManager_js_1 = __importDefault(require("../modules/conditionsManager.js"));
|
|
31
|
+
const featureFlags_js_1 = __importDefault(require("../modules/featureFlags.js"));
|
|
4
32
|
const messages_gen_js_1 = require("./messages.gen.js");
|
|
33
|
+
const messages_gen_js_2 = require("./messages.gen.js");
|
|
5
34
|
const utils_js_1 = require("../utils.js");
|
|
6
|
-
const nodes_js_1 = require("./nodes.js");
|
|
7
|
-
const top_observer_js_1 = require("./observer/top_observer.js");
|
|
8
|
-
const sanitizer_js_1 = require("./sanitizer.js");
|
|
9
|
-
const ticker_js_1 = require("./ticker.js");
|
|
10
|
-
const logger_js_1 = require("./logger.js");
|
|
11
|
-
const session_js_1 = require("./session.js");
|
|
35
|
+
const nodes_js_1 = __importDefault(require("./nodes.js"));
|
|
36
|
+
const top_observer_js_1 = __importDefault(require("./observer/top_observer.js"));
|
|
37
|
+
const sanitizer_js_1 = __importDefault(require("./sanitizer.js"));
|
|
38
|
+
const ticker_js_1 = __importDefault(require("./ticker.js"));
|
|
39
|
+
const logger_js_1 = __importStar(require("./logger.js"));
|
|
40
|
+
const session_js_1 = __importDefault(require("./session.js"));
|
|
12
41
|
const fflate_1 = require("fflate");
|
|
13
42
|
const performance_js_1 = require("../modules/performance.js");
|
|
14
|
-
const attributeSender_js_1 = require("../modules/attributeSender.js");
|
|
15
|
-
const canvas_js_1 = require("./canvas.js");
|
|
16
|
-
const index_js_1 = require("../modules/userTesting/index.js");
|
|
43
|
+
const attributeSender_js_1 = __importDefault(require("../modules/attributeSender.js"));
|
|
44
|
+
const canvas_js_1 = __importDefault(require("./canvas.js"));
|
|
45
|
+
const index_js_1 = __importDefault(require("../modules/userTesting/index.js"));
|
|
46
|
+
const tagWatcher_js_1 = __importDefault(require("../modules/tagWatcher.js"));
|
|
17
47
|
const CANCELED = 'canceled';
|
|
18
48
|
const uxtStorageKey = 'or_uxt_active';
|
|
49
|
+
const bufferStorageKey = 'or_buffer_1';
|
|
19
50
|
const START_ERROR = ':(';
|
|
20
51
|
const UnsuccessfulStart = (reason) => ({ reason, success: false });
|
|
21
52
|
const SuccessfulStart = (body) => (Object.assign(Object.assign({}, body), { success: true }));
|
|
@@ -24,6 +55,7 @@ var ActivityState;
|
|
|
24
55
|
ActivityState[ActivityState["NotActive"] = 0] = "NotActive";
|
|
25
56
|
ActivityState[ActivityState["Starting"] = 1] = "Starting";
|
|
26
57
|
ActivityState[ActivityState["Active"] = 2] = "Active";
|
|
58
|
+
ActivityState[ActivityState["ColdStart"] = 3] = "ColdStart";
|
|
27
59
|
})(ActivityState || (ActivityState = {}));
|
|
28
60
|
// TODO: use backendHost only
|
|
29
61
|
exports.DEFAULT_INGEST_POINT = 'https://api.openreplay.com/ingest';
|
|
@@ -35,28 +67,58 @@ function getTimezone() {
|
|
|
35
67
|
return `UTC${sign}${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}`;
|
|
36
68
|
}
|
|
37
69
|
class App {
|
|
38
|
-
constructor(projectKey, sessionToken, options) {
|
|
70
|
+
constructor(projectKey, sessionToken, options, signalError) {
|
|
39
71
|
var _a, _b;
|
|
72
|
+
this.signalError = signalError;
|
|
40
73
|
this.messages = [];
|
|
74
|
+
/**
|
|
75
|
+
* we need 2 buffers, so we don't lose anything
|
|
76
|
+
* @read coldStart implementation
|
|
77
|
+
* */
|
|
78
|
+
this.bufferedMessages1 = [];
|
|
79
|
+
this.bufferedMessages2 = [];
|
|
41
80
|
this.startCallbacks = [];
|
|
42
81
|
this.stopCallbacks = [];
|
|
43
82
|
this.commitCallbacks = [];
|
|
44
83
|
this.activityState = ActivityState.NotActive;
|
|
45
|
-
this.version = '
|
|
84
|
+
this.version = '12.0.0'; // TODO: version compatability check inside each plugin.
|
|
46
85
|
this.compressionThreshold = 24 * 1000;
|
|
47
86
|
this.restartAttempts = 0;
|
|
48
87
|
this.bc = null;
|
|
49
88
|
this.canvasRecorder = null;
|
|
89
|
+
this.conditionsManager = null;
|
|
50
90
|
this._usingOldFetchPlugin = false;
|
|
91
|
+
this.coldStartCommitN = 0;
|
|
51
92
|
this.delay = 0;
|
|
93
|
+
this.coldInterval = null;
|
|
94
|
+
this.orderNumber = 0;
|
|
95
|
+
this.coldStartTs = 0;
|
|
96
|
+
this.singleBuffer = false;
|
|
97
|
+
this.onSessionSent = () => {
|
|
98
|
+
return;
|
|
99
|
+
};
|
|
52
100
|
this.restartCanvasTracking = () => {
|
|
53
101
|
var _a;
|
|
54
102
|
(_a = this.canvasRecorder) === null || _a === void 0 ? void 0 : _a.restartTracking();
|
|
55
103
|
};
|
|
104
|
+
this.flushBuffer = async (buffer) => {
|
|
105
|
+
return new Promise((res) => {
|
|
106
|
+
let ended = false;
|
|
107
|
+
const messagesBatch = [buffer.shift()];
|
|
108
|
+
while (!ended) {
|
|
109
|
+
const nextMsg = buffer[0];
|
|
110
|
+
if (!nextMsg || nextMsg[0] === 0 /* MType.Timestamp */) {
|
|
111
|
+
ended = true;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
messagesBatch.push(buffer.shift());
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
this.postToWorker(messagesBatch);
|
|
118
|
+
res(null);
|
|
119
|
+
});
|
|
120
|
+
};
|
|
56
121
|
this.onUxtCb = [];
|
|
57
|
-
// if (options.onStart !== undefined) {
|
|
58
|
-
// deprecationWarn("'onStart' option", "tracker.start().then(/* handle session info */)")
|
|
59
|
-
// } ?? maybe onStart is good
|
|
60
122
|
this.contextId = Math.random().toString(36).slice(2);
|
|
61
123
|
this.projectKey = projectKey;
|
|
62
124
|
this.networkOptions = options.network;
|
|
@@ -70,9 +132,9 @@ class App {
|
|
|
70
132
|
local_uuid_key: '__openreplay_uuid',
|
|
71
133
|
ingestPoint: exports.DEFAULT_INGEST_POINT,
|
|
72
134
|
resourceBaseHref: null,
|
|
73
|
-
verbose: false,
|
|
74
135
|
__is_snippet: false,
|
|
75
136
|
__debug_report_edp: null,
|
|
137
|
+
__debug__: logger_js_1.LogLevel.Silent,
|
|
76
138
|
__save_canvas_locally: false,
|
|
77
139
|
localStorage: null,
|
|
78
140
|
sessionStorage: null,
|
|
@@ -93,16 +155,19 @@ class App {
|
|
|
93
155
|
this.ticker = new ticker_js_1.default(this);
|
|
94
156
|
this.ticker.attach(() => this.commit());
|
|
95
157
|
this.debug = new logger_js_1.default(this.options.__debug__);
|
|
96
|
-
this.notify = new logger_js_1.default(this.options.verbose ? logger_js_1.LogLevel.Warnings : logger_js_1.LogLevel.Silent);
|
|
97
158
|
this.session = new session_js_1.default(this, this.options);
|
|
98
159
|
this.attributeSender = new attributeSender_js_1.default(this, Boolean(this.options.disableStringDict));
|
|
160
|
+
this.featureFlags = new featureFlags_js_1.default(this);
|
|
161
|
+
this.tagWatcher = new tagWatcher_js_1.default(this.sessionStorage, this.debug.error, (tag) => {
|
|
162
|
+
this.send((0, messages_gen_js_1.TagTrigger)(tag));
|
|
163
|
+
});
|
|
99
164
|
this.session.attachUpdateCallback(({ userID, metadata }) => {
|
|
100
165
|
if (userID != null) {
|
|
101
166
|
// TODO: nullable userID
|
|
102
|
-
this.send((0,
|
|
167
|
+
this.send((0, messages_gen_js_2.UserID)(userID));
|
|
103
168
|
}
|
|
104
169
|
if (metadata != null) {
|
|
105
|
-
Object.entries(metadata).forEach(([key, value]) => this.send((0,
|
|
170
|
+
Object.entries(metadata).forEach(([key, value]) => this.send((0, messages_gen_js_2.Metadata)(key, value)));
|
|
106
171
|
}
|
|
107
172
|
});
|
|
108
173
|
// @deprecated (use sessionHash on start instead)
|
|
@@ -110,7 +175,7 @@ class App {
|
|
|
110
175
|
this.session.applySessionHash(sessionToken);
|
|
111
176
|
}
|
|
112
177
|
try {
|
|
113
|
-
this.worker = new Worker(URL.createObjectURL(new Blob(['"use strict";class t{constructor(t,s,i,e=10,n=1e3,h){this.onUnauthorised=s,this.onFailure=i,this.MAX_ATTEMPTS_COUNT=e,this.ATTEMPT_TIMEOUT=n,this.onCompress=h,this.attemptsCount=0,this.busy=!1,this.queue=[],this.token=null,this.ingestURL=t+"/v1/web/i",this.isCompressing=void 0!==h}authorise(t){this.token=t,this.busy||this.sendNext()}push(t){this.busy||!this.token?this.queue.push(t):(this.busy=!0,this.isCompressing&&this.onCompress?this.onCompress(t):this.sendBatch(t))}sendNext(){const t=this.queue.shift();t?(this.busy=!0,this.isCompressing&&this.onCompress?this.onCompress(t):this.sendBatch(t)):this.busy=!1}retry(t,s){this.attemptsCount>=this.MAX_ATTEMPTS_COUNT?this.onFailure(`Failed to send batch after ${this.attemptsCount} attempts.`):(this.attemptsCount++,setTimeout((()=>this.sendBatch(t,s)),this.ATTEMPT_TIMEOUT*this.attemptsCount))}sendBatch(t,s){this.busy=!0;const i={Authorization:`Bearer ${this.token}`};s&&(i["Content-Encoding"]="gzip"),null!==this.token?fetch(this.ingestURL,{body:t,method:"POST",headers:i,keepalive:t.length<65536}).then((i=>{if(401===i.status)return this.busy=!1,void this.onUnauthorised();i.status>=400?this.retry(t,s):(this.attemptsCount=0,this.sendNext())})).catch((i=>{console.warn("OpenReplay:",i),this.retry(t,s)})):setTimeout((()=>{this.sendBatch(t,s)}),500)}sendCompressed(t){this.sendBatch(t,!0)}sendUncompressed(t){this.sendBatch(t,!1)}clean(){this.sendNext(),setTimeout((()=>{this.token=null,this.queue.length=0}),10)}}const s="function"==typeof TextEncoder?new TextEncoder:{encode(t){const s=t.length,i=new Uint8Array(3*s);let e=-1;for(let n=0,h=0,r=0;r!==s;){if(n=t.charCodeAt(r),r+=1,n>=55296&&n<=56319){if(r===s){i[e+=1]=239,i[e+=1]=191,i[e+=1]=189;break}if(h=t.charCodeAt(r),!(h>=56320&&h<=57343)){i[e+=1]=239,i[e+=1]=191,i[e+=1]=189;continue}if(n=1024*(n-55296)+h-56320+65536,r+=1,n>65535){i[e+=1]=240|n>>>18,i[e+=1]=128|n>>>12&63,i[e+=1]=128|n>>>6&63,i[e+=1]=128|63&n;continue}}n<=127?i[e+=1]=0|n:n<=2047?(i[e+=1]=192|n>>>6,i[e+=1]=128|63&n):(i[e+=1]=224|n>>>12,i[e+=1]=128|n>>>6&63,i[e+=1]=128|63&n)}return i.subarray(0,e+1)}};class i{constructor(t){this.size=t,this.offset=0,this.checkpointOffset=0,this.data=new Uint8Array(t)}getCurrentOffset(){return this.offset}checkpoint(){this.checkpointOffset=this.offset}get isEmpty(){return 0===this.offset}skip(t){return this.offset+=t,this.offset<=this.size}set(t,s){this.data.set(t,s)}boolean(t){return this.data[this.offset++]=+t,this.offset<=this.size}uint(t){for((t<0||t>Number.MAX_SAFE_INTEGER)&&(t=0);t>=128;)this.data[this.offset++]=t%256|128,t=Math.floor(t/128);return this.data[this.offset++]=t,this.offset<=this.size}int(t){return t=Math.round(t),this.uint(t>=0?2*t:-2*t-1)}string(t){const i=s.encode(t),e=i.byteLength;return!(!this.uint(e)||this.offset+e>this.size)&&(this.data.set(i,this.offset),this.offset+=e,!0)}reset(){this.offset=0,this.checkpointOffset=0}flush(){const t=this.data.slice(0,this.checkpointOffset);return this.reset(),t}}class e extends i{encode(t){switch(t[0]){case 0:case 11:case 114:case 115:return this.uint(t[1]);case 4:case 44:case 47:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3]);case 5:case 20:case 38:case 70:case 75:case 76:case 77:case 82:return this.uint(t[1])&&this.uint(t[2]);case 6:return this.int(t[1])&&this.int(t[2]);case 7:return!0;case 8:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.string(t[4])&&this.boolean(t[5]);case 9:case 10:case 24:case 51:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3]);case 12:case 61:case 71:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3]);case 13:case 14:case 17:case 50:case 54:return this.uint(t[1])&&this.string(t[2]);case 16:return this.uint(t[1])&&this.int(t[2])&&this.int(t[3]);case 18:return this.uint(t[1])&&this.string(t[2])&&this.int(t[3]);case 19:return this.uint(t[1])&&this.boolean(t[2]);case 21:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.string(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8]);case 22:case 27:case 30:case 41:case 45:case 46:case 63:case 64:case 79:return this.string(t[1])&&this.string(t[2]);case 23:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8])&&this.uint(t[9]);case 28:case 29:case 42:case 117:case 118:return this.string(t[1]);case 37:return this.uint(t[1])&&this.string(t[2])&&this.uint(t[3]);case 39:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.uint(t[7]);case 40:return this.string(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4]);case 48:case 78:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4]);case 49:return this.int(t[1])&&this.int(t[2])&&this.uint(t[3])&&this.uint(t[4]);case 53:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.string(t[7])&&this.string(t[8]);case 55:return this.boolean(t[1]);case 57:case 60:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4]);case 58:return this.int(t[1]);case 59:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.string(t[5])&&this.string(t[6])&&this.string(t[7]);case 67:case 73:return this.uint(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.string(t[4]);case 69:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4]);case 81:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.int(t[4])&&this.string(t[5]);case 83:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.string(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8])&&this.uint(t[9]);case 112:return this.uint(t[1])&&this.string(t[2])&&this.boolean(t[3])&&this.string(t[4])&&this.int(t[5])&&this.int(t[6]);case 113:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3]);case 116:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.string(t[7])&&this.string(t[8])&&this.uint(t[9])&&this.boolean(t[10]);case 119:return this.string(t[1])&&this.uint(t[2])}}}class n{constructor(t,s,i,n,h){this.pageNo=t,this.timestamp=s,this.url=i,this.onBatch=n,this.tabId=h,this.nextIndex=0,this.beaconSize=2e5,this.encoder=new e(this.beaconSize),this.sizeBuffer=new Uint8Array(3),this.isEmpty=!0,this.beaconSizeLimit=1e6,this.prepare()}writeType(t){return this.encoder.uint(t[0])}writeFields(t){return this.encoder.encode(t)}writeSizeAt(t,s){for(let s=0;s<3;s++)this.sizeBuffer[s]=t>>8*s;this.encoder.set(this.sizeBuffer,s)}prepare(){if(!this.encoder.isEmpty)return;const t=[81,1,this.pageNo,this.nextIndex,this.timestamp,this.url],s=[118,this.tabId];this.writeType(t),this.writeFields(t),this.writeWithSize(s),this.isEmpty=!0}writeWithSize(t){const s=this.encoder;if(!this.writeType(t)||!s.skip(3))return!1;const i=s.getCurrentOffset(),e=this.writeFields(t);if(e){const e=s.getCurrentOffset()-i;if(e>16777215)return console.warn("OpenReplay: max message size overflow."),!1;this.writeSizeAt(e,i-3),s.checkpoint(),this.isEmpty=this.isEmpty&&0===t[0],this.nextIndex++}return e}setBeaconSizeLimit(t){this.beaconSizeLimit=t}writeMessage(t){0===t[0]&&(this.timestamp=t[1]),4===t[0]&&(this.url=t[1]),this.writeWithSize(t)||(this.finaliseBatch(),this.writeWithSize(t)||(this.encoder=new e(this.beaconSizeLimit),this.prepare(),this.writeWithSize(t)?this.finaliseBatch():console.warn("OpenReplay: beacon size overflow. Skipping large message.",t,this),this.encoder=new e(this.beaconSize),this.prepare()))}finaliseBatch(){if(this.isEmpty)return;const t=this.encoder.flush();this.onBatch(t),this.prepare()}clean(){this.encoder.reset()}}var h;!function(t){t[t.NotActive=0]="NotActive",t[t.Starting=1]="Starting",t[t.Stopping=2]="Stopping",t[t.Active=3]="Active",t[t.Stopped=4]="Stopped"}(h||(h={}));let r=null,
|
|
178
|
+
this.worker = new Worker(URL.createObjectURL(new Blob(['"use strict";class t{constructor(t,s,i,e=10,n=1e3,h){this.onUnauthorised=s,this.onFailure=i,this.MAX_ATTEMPTS_COUNT=e,this.ATTEMPT_TIMEOUT=n,this.onCompress=h,this.attemptsCount=0,this.busy=!1,this.queue=[],this.token=null,this.ingestURL=t+"/v1/web/i",this.isCompressing=void 0!==h}getQueueStatus(){return 0===this.queue.length&&!this.busy}authorise(t){this.token=t,this.busy||this.sendNext()}push(t){this.busy||!this.token?this.queue.push(t):(this.busy=!0,this.isCompressing&&this.onCompress?this.onCompress(t):this.sendBatch(t))}sendNext(){const t=this.queue.shift();t?(this.busy=!0,this.isCompressing&&this.onCompress?this.onCompress(t):this.sendBatch(t)):this.busy=!1}retry(t,s){this.attemptsCount>=this.MAX_ATTEMPTS_COUNT?this.onFailure(`Failed to send batch after ${this.attemptsCount} attempts.`):(this.attemptsCount++,setTimeout((()=>this.sendBatch(t,s)),this.ATTEMPT_TIMEOUT*this.attemptsCount))}sendBatch(t,s){this.busy=!0;const i={Authorization:`Bearer ${this.token}`};s&&(i["Content-Encoding"]="gzip"),null!==this.token?fetch(this.ingestURL,{body:t,method:"POST",headers:i,keepalive:t.length<65536}).then((i=>{if(401===i.status)return this.busy=!1,void this.onUnauthorised();i.status>=400?this.retry(t,s):(this.attemptsCount=0,this.sendNext())})).catch((i=>{console.warn("OpenReplay:",i),this.retry(t,s)})):setTimeout((()=>{this.sendBatch(t,s)}),500)}sendCompressed(t){this.sendBatch(t,!0)}sendUncompressed(t){this.sendBatch(t,!1)}clean(){this.sendNext(),setTimeout((()=>{this.token=null,this.queue.length=0}),10)}}const s="function"==typeof TextEncoder?new TextEncoder:{encode(t){const s=t.length,i=new Uint8Array(3*s);let e=-1;for(let n=0,h=0,r=0;r!==s;){if(n=t.charCodeAt(r),r+=1,n>=55296&&n<=56319){if(r===s){i[e+=1]=239,i[e+=1]=191,i[e+=1]=189;break}if(h=t.charCodeAt(r),!(h>=56320&&h<=57343)){i[e+=1]=239,i[e+=1]=191,i[e+=1]=189;continue}if(n=1024*(n-55296)+h-56320+65536,r+=1,n>65535){i[e+=1]=240|n>>>18,i[e+=1]=128|n>>>12&63,i[e+=1]=128|n>>>6&63,i[e+=1]=128|63&n;continue}}n<=127?i[e+=1]=0|n:n<=2047?(i[e+=1]=192|n>>>6,i[e+=1]=128|63&n):(i[e+=1]=224|n>>>12,i[e+=1]=128|n>>>6&63,i[e+=1]=128|63&n)}return i.subarray(0,e+1)}};class i{constructor(t){this.size=t,this.offset=0,this.checkpointOffset=0,this.data=new Uint8Array(t)}getCurrentOffset(){return this.offset}checkpoint(){this.checkpointOffset=this.offset}get isEmpty(){return 0===this.offset}skip(t){return this.offset+=t,this.offset<=this.size}set(t,s){this.data.set(t,s)}boolean(t){return this.data[this.offset++]=+t,this.offset<=this.size}uint(t){for((t<0||t>Number.MAX_SAFE_INTEGER)&&(t=0);t>=128;)this.data[this.offset++]=t%256|128,t=Math.floor(t/128);return this.data[this.offset++]=t,this.offset<=this.size}int(t){return t=Math.round(t),this.uint(t>=0?2*t:-2*t-1)}string(t){const i=s.encode(t),e=i.byteLength;return!(!this.uint(e)||this.offset+e>this.size)&&(this.data.set(i,this.offset),this.offset+=e,!0)}reset(){this.offset=0,this.checkpointOffset=0}flush(){const t=this.data.slice(0,this.checkpointOffset);return this.reset(),t}}class e extends i{encode(t){switch(t[0]){case 0:case 11:case 114:case 115:return this.uint(t[1]);case 4:case 44:case 47:return this.string(t[1])&&this.string(t[2])&&this.uint(t[3]);case 5:case 20:case 38:case 70:case 75:case 76:case 77:case 82:return this.uint(t[1])&&this.uint(t[2]);case 6:return this.int(t[1])&&this.int(t[2]);case 7:return!0;case 8:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.string(t[4])&&this.boolean(t[5]);case 9:case 10:case 24:case 51:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3]);case 12:case 61:case 71:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3]);case 13:case 14:case 17:case 50:case 54:return this.uint(t[1])&&this.string(t[2]);case 16:return this.uint(t[1])&&this.int(t[2])&&this.int(t[3]);case 18:return this.uint(t[1])&&this.string(t[2])&&this.int(t[3]);case 19:return this.uint(t[1])&&this.boolean(t[2]);case 21:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.string(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8]);case 22:case 27:case 30:case 41:case 45:case 46:case 63:case 64:case 79:return this.string(t[1])&&this.string(t[2]);case 23:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8])&&this.uint(t[9]);case 28:case 29:case 42:case 117:case 118:return this.string(t[1]);case 37:return this.uint(t[1])&&this.string(t[2])&&this.uint(t[3]);case 39:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.uint(t[7]);case 40:return this.string(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4]);case 48:case 78:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4]);case 49:return this.int(t[1])&&this.int(t[2])&&this.uint(t[3])&&this.uint(t[4]);case 53:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.string(t[7])&&this.string(t[8]);case 55:return this.boolean(t[1]);case 57:case 60:return this.uint(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4]);case 58:case 120:return this.int(t[1]);case 59:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.string(t[5])&&this.string(t[6])&&this.string(t[7]);case 67:case 73:return this.uint(t[1])&&this.string(t[2])&&this.uint(t[3])&&this.string(t[4]);case 69:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3])&&this.string(t[4]);case 81:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.int(t[4])&&this.string(t[5]);case 83:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.string(t[4])&&this.string(t[5])&&this.uint(t[6])&&this.uint(t[7])&&this.uint(t[8])&&this.uint(t[9]);case 84:return this.string(t[1])&&this.string(t[2])&&this.string(t[3])&&this.uint(t[4])&&this.string(t[5])&&this.string(t[6]);case 112:return this.uint(t[1])&&this.string(t[2])&&this.boolean(t[3])&&this.string(t[4])&&this.int(t[5])&&this.int(t[6]);case 113:return this.uint(t[1])&&this.uint(t[2])&&this.string(t[3]);case 116:return this.uint(t[1])&&this.uint(t[2])&&this.uint(t[3])&&this.uint(t[4])&&this.uint(t[5])&&this.uint(t[6])&&this.string(t[7])&&this.string(t[8])&&this.uint(t[9])&&this.boolean(t[10]);case 119:return this.string(t[1])&&this.uint(t[2])}}}class n{constructor(t,s,i,n,h,r){this.pageNo=t,this.timestamp=s,this.url=i,this.onBatch=n,this.tabId=h,this.onOfflineEnd=r,this.nextIndex=0,this.beaconSize=2e5,this.encoder=new e(this.beaconSize),this.sizeBuffer=new Uint8Array(3),this.isEmpty=!0,this.beaconSizeLimit=1e6,this.prepare()}writeType(t){return this.encoder.uint(t[0])}writeFields(t){return this.encoder.encode(t)}writeSizeAt(t,s){for(let s=0;s<3;s++)this.sizeBuffer[s]=t>>8*s;this.encoder.set(this.sizeBuffer,s)}prepare(){if(!this.encoder.isEmpty)return;const t=[81,1,this.pageNo,this.nextIndex,this.timestamp,this.url],s=[118,this.tabId];this.writeType(t),this.writeFields(t),this.writeWithSize(s),this.isEmpty=!0}writeWithSize(t){const s=this.encoder;if(!this.writeType(t)||!s.skip(3))return!1;const i=s.getCurrentOffset(),e=this.writeFields(t);if(e){const e=s.getCurrentOffset()-i;if(e>16777215)return console.warn("OpenReplay: max message size overflow."),!1;this.writeSizeAt(e,i-3),s.checkpoint(),this.isEmpty=this.isEmpty&&0===t[0],this.nextIndex++}return e}setBeaconSizeLimit(t){this.beaconSizeLimit=t}writeMessage(t){if("q_end"===t[0])return this.finaliseBatch(),this.onOfflineEnd();0===t[0]&&(this.timestamp=t[1]),4===t[0]&&(this.url=t[1]),this.writeWithSize(t)||(this.finaliseBatch(),this.writeWithSize(t)||(this.encoder=new e(this.beaconSizeLimit),this.prepare(),this.writeWithSize(t)?this.finaliseBatch():console.warn("OpenReplay: beacon size overflow. Skipping large message.",t,this),this.encoder=new e(this.beaconSize),this.prepare()))}finaliseBatch(){if(this.isEmpty)return;const t=this.encoder.flush();this.onBatch(t),this.prepare()}clean(){this.encoder.reset()}}var h;!function(t){t[t.NotActive=0]="NotActive",t[t.Starting=1]="Starting",t[t.Stopping=2]="Stopping",t[t.Active=3]="Active",t[t.Stopped=4]="Stopped"}(h||(h={}));let r=null,u=null,a=h.NotActive;function o(){u&&u.finaliseBatch()}function c(){a=h.Stopping,null!==g&&(clearInterval(g),g=null),u&&(u.clean(),u=null),r&&(r.clean(),setTimeout((()=>{r=null}),20)),setTimeout((()=>{a=h.NotActive}),100)}function p(){a!==h.Stopped&&(postMessage("restart"),c())}let f,g=null;self.onmessage=({data:s})=>{if(null!=s){if("stop"===s)return o(),c(),a=h.Stopped;if("forceFlushBatch"!==s){if(!Array.isArray(s)){if("compressed"===s.type){if(!r)return console.debug("OR WebWorker: sender not initialised. Compressed batch."),void p();s.batch&&r.sendCompressed(s.batch)}if("uncompressed"===s.type){if(!r)return console.debug("OR WebWorker: sender not initialised. Uncompressed batch."),void p();s.batch&&r.sendUncompressed(s.batch)}return"start"===s.type?(a=h.Starting,r=new t(s.ingestPoint,(()=>{p()}),(t=>{!function(t){postMessage({type:"failure",reason:t}),c()}(t)}),s.connAttemptCount,s.connAttemptGap,(t=>{postMessage({type:"compress",batch:t},[t.buffer])})),u=new n(s.pageNo,s.timestamp,s.url,(t=>{r&&r.push(t)}),s.tabId,(()=>postMessage({type:"queue_empty"}))),null===g&&(g=setInterval(o,1e4)),a=h.Active):"auth"===s.type?r?u?(r.authorise(s.token),void(s.beaconSizeLimit&&u.setBeaconSizeLimit(s.beaconSizeLimit))):(console.debug("OR WebWorker: writer not initialised. Received auth."),void p()):(console.debug("OR WebWorker: sender not initialised. Received auth."),void p()):void 0}if(u){const t=u;s.forEach((s=>{55===s[0]&&(s[1]?f=setTimeout((()=>p()),18e5):clearTimeout(f)),t.writeMessage(s)}))}else postMessage("not_init"),p()}else o()}else o()};'], { type: 'text/javascript' })));
|
|
114
179
|
this.worker.onerror = (e) => {
|
|
115
180
|
this._debug('webworker_error', e);
|
|
116
181
|
};
|
|
@@ -142,14 +207,18 @@ class App {
|
|
|
142
207
|
void this.start({}, true);
|
|
143
208
|
}
|
|
144
209
|
}
|
|
145
|
-
|
|
146
|
-
|
|
210
|
+
else {
|
|
211
|
+
(_a = this.worker) === null || _a === void 0 ? void 0 : _a.postMessage({ type: 'compressed', batch: result });
|
|
212
|
+
}
|
|
147
213
|
});
|
|
148
214
|
}
|
|
149
215
|
else {
|
|
150
216
|
(_a = this.worker) === null || _a === void 0 ? void 0 : _a.postMessage({ type: 'uncompressed', batch: batch });
|
|
151
217
|
}
|
|
152
218
|
}
|
|
219
|
+
else if (data.type === 'queue_empty') {
|
|
220
|
+
this.onSessionSent();
|
|
221
|
+
}
|
|
153
222
|
};
|
|
154
223
|
const alertWorker = () => {
|
|
155
224
|
if (this.worker) {
|
|
@@ -224,6 +293,7 @@ class App {
|
|
|
224
293
|
this.debug.error('OpenReplay error: ', context, e);
|
|
225
294
|
}
|
|
226
295
|
send(message, urgent = false) {
|
|
296
|
+
var _a;
|
|
227
297
|
if (this.activityState === ActivityState.NotActive) {
|
|
228
298
|
return;
|
|
229
299
|
}
|
|
@@ -237,22 +307,35 @@ class App {
|
|
|
237
307
|
return;
|
|
238
308
|
}
|
|
239
309
|
// ====================================================
|
|
240
|
-
this.
|
|
310
|
+
if (this.activityState === ActivityState.ColdStart) {
|
|
311
|
+
this.bufferedMessages1.push(message);
|
|
312
|
+
if (!this.singleBuffer) {
|
|
313
|
+
this.bufferedMessages2.push(message);
|
|
314
|
+
}
|
|
315
|
+
(_a = this.conditionsManager) === null || _a === void 0 ? void 0 : _a.processMessage(message);
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
this.messages.push(message);
|
|
319
|
+
}
|
|
241
320
|
// TODO: commit on start if there were `urgent` sends;
|
|
242
321
|
// Clarify where urgent can be used for;
|
|
243
322
|
// Clarify workflow for each type of message in case it was sent before start
|
|
244
323
|
// (like Fetch before start; maybe add an option "preCapture: boolean" or sth alike)
|
|
245
|
-
// Careful: `this.delay` is equal to zero before start
|
|
324
|
+
// Careful: `this.delay` is equal to zero before start so all Timestamp-s will have to be updated on start
|
|
246
325
|
if (this.activityState === ActivityState.Active && urgent) {
|
|
247
326
|
this.commit();
|
|
248
327
|
}
|
|
249
328
|
}
|
|
250
|
-
|
|
329
|
+
/**
|
|
330
|
+
* Normal workflow: add timestamp and tab data to batch, then commit it
|
|
331
|
+
* every ~30ms
|
|
332
|
+
* */
|
|
333
|
+
_nCommit() {
|
|
251
334
|
if (this.worker !== undefined && this.messages.length) {
|
|
252
335
|
(0, utils_js_1.requestIdleCb)(() => {
|
|
253
336
|
var _a;
|
|
254
|
-
this.messages.unshift((0,
|
|
255
|
-
this.messages.unshift((0,
|
|
337
|
+
this.messages.unshift((0, messages_gen_js_2.TabData)(this.session.getTabId()));
|
|
338
|
+
this.messages.unshift((0, messages_gen_js_2.Timestamp)(this.timestamp()));
|
|
256
339
|
// why I need to add opt chaining?
|
|
257
340
|
(_a = this.worker) === null || _a === void 0 ? void 0 : _a.postMessage(this.messages);
|
|
258
341
|
this.commitCallbacks.forEach((cb) => cb(this.messages));
|
|
@@ -260,6 +343,36 @@ class App {
|
|
|
260
343
|
});
|
|
261
344
|
}
|
|
262
345
|
}
|
|
346
|
+
/**
|
|
347
|
+
* Cold start: add timestamp and tab data to both batches
|
|
348
|
+
* every 2nd tick, ~60ms
|
|
349
|
+
* this will make batches a bit larger and replay will work with bigger jumps every frame
|
|
350
|
+
* but in turn we don't overload batch writer on session start with 1000 batches
|
|
351
|
+
* */
|
|
352
|
+
_cStartCommit() {
|
|
353
|
+
this.coldStartCommitN += 1;
|
|
354
|
+
if (this.coldStartCommitN === 2) {
|
|
355
|
+
this.bufferedMessages1.push((0, messages_gen_js_2.Timestamp)(this.timestamp()));
|
|
356
|
+
this.bufferedMessages1.push((0, messages_gen_js_2.TabData)(this.session.getTabId()));
|
|
357
|
+
this.bufferedMessages2.push((0, messages_gen_js_2.Timestamp)(this.timestamp()));
|
|
358
|
+
this.bufferedMessages2.push((0, messages_gen_js_2.TabData)(this.session.getTabId()));
|
|
359
|
+
this.coldStartCommitN = 0;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
commit() {
|
|
363
|
+
if (this.activityState === ActivityState.ColdStart) {
|
|
364
|
+
this._cStartCommit();
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
this._nCommit();
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
postToWorker(messages) {
|
|
371
|
+
var _a;
|
|
372
|
+
(_a = this.worker) === null || _a === void 0 ? void 0 : _a.postMessage(messages);
|
|
373
|
+
this.commitCallbacks.forEach((cb) => cb(messages));
|
|
374
|
+
messages.length = 0;
|
|
375
|
+
}
|
|
263
376
|
timestamp() {
|
|
264
377
|
return (0, utils_js_1.now)() + this.delay;
|
|
265
378
|
}
|
|
@@ -393,15 +506,228 @@ class App {
|
|
|
393
506
|
this.sessionStorage.removeItem(this.options.session_reset_key);
|
|
394
507
|
}
|
|
395
508
|
}
|
|
396
|
-
|
|
509
|
+
checkSessionToken(forceNew) {
|
|
510
|
+
const lsReset = this.sessionStorage.getItem(this.options.session_reset_key) !== null;
|
|
511
|
+
const needNewSessionID = forceNew || lsReset;
|
|
512
|
+
const sessionToken = this.session.getSessionToken();
|
|
513
|
+
return needNewSessionID || !sessionToken;
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* start buffering messages without starting the actual session, which gives
|
|
517
|
+
* user 30 seconds to "activate" and record session by calling `start()` on conditional trigger
|
|
518
|
+
* and we will then send buffered batch, so it won't get lost
|
|
519
|
+
* */
|
|
520
|
+
async coldStart(startOpts = {}, conditional) {
|
|
521
|
+
var _a, _b;
|
|
522
|
+
this.singleBuffer = false;
|
|
523
|
+
const second = 1000;
|
|
524
|
+
if (conditional) {
|
|
525
|
+
this.conditionsManager = new conditionsManager_js_1.default(this, startOpts);
|
|
526
|
+
}
|
|
527
|
+
const isNewSession = this.checkSessionToken(startOpts.forceNew);
|
|
528
|
+
if (conditional) {
|
|
529
|
+
const r = await fetch(this.options.ingestPoint + '/v1/web/start', {
|
|
530
|
+
method: 'POST',
|
|
531
|
+
headers: {
|
|
532
|
+
'Content-Type': 'application/json',
|
|
533
|
+
},
|
|
534
|
+
body: JSON.stringify(Object.assign(Object.assign({}, this.getTrackerInfo()), { timestamp: (0, utils_js_1.now)(), doNotRecord: true, bufferDiff: 0, userID: this.session.getInfo().userID, token: undefined, deviceMemory: performance_js_1.deviceMemory,
|
|
535
|
+
jsHeapSizeLimit: performance_js_1.jsHeapSizeLimit, timezone: getTimezone() })),
|
|
536
|
+
});
|
|
537
|
+
const {
|
|
538
|
+
// this token is needed to fetch conditions and flags,
|
|
539
|
+
// but it can't be used to record a session
|
|
540
|
+
token, userBrowser, userCity, userCountry, userDevice, userOS, userState, projectID, } = await r.json();
|
|
541
|
+
this.session.assign({ projectID });
|
|
542
|
+
this.session.setUserInfo({
|
|
543
|
+
userBrowser,
|
|
544
|
+
userCity,
|
|
545
|
+
userCountry,
|
|
546
|
+
userDevice,
|
|
547
|
+
userOS,
|
|
548
|
+
userState,
|
|
549
|
+
});
|
|
550
|
+
const onStartInfo = { sessionToken: token, userUUID: '', sessionID: '' };
|
|
551
|
+
this.startCallbacks.forEach((cb) => cb(onStartInfo));
|
|
552
|
+
await ((_a = this.conditionsManager) === null || _a === void 0 ? void 0 : _a.fetchConditions(projectID, token));
|
|
553
|
+
await this.featureFlags.reloadFlags(token);
|
|
554
|
+
await this.tagWatcher.fetchTags(this.options.ingestPoint, token);
|
|
555
|
+
(_b = this.conditionsManager) === null || _b === void 0 ? void 0 : _b.processFlags(this.featureFlags.flags);
|
|
556
|
+
}
|
|
557
|
+
const cycle = () => {
|
|
558
|
+
this.orderNumber += 1;
|
|
559
|
+
(0, utils_js_1.adjustTimeOrigin)();
|
|
560
|
+
this.coldStartTs = (0, utils_js_1.now)();
|
|
561
|
+
if (this.orderNumber % 2 === 0) {
|
|
562
|
+
this.bufferedMessages1.length = 0;
|
|
563
|
+
this.bufferedMessages1.push((0, messages_gen_js_2.Timestamp)(this.timestamp()));
|
|
564
|
+
this.bufferedMessages1.push((0, messages_gen_js_2.TabData)(this.session.getTabId()));
|
|
565
|
+
}
|
|
566
|
+
else {
|
|
567
|
+
this.bufferedMessages2.length = 0;
|
|
568
|
+
this.bufferedMessages2.push((0, messages_gen_js_2.Timestamp)(this.timestamp()));
|
|
569
|
+
this.bufferedMessages2.push((0, messages_gen_js_2.TabData)(this.session.getTabId()));
|
|
570
|
+
}
|
|
571
|
+
this.stop(false);
|
|
572
|
+
this.activityState = ActivityState.ColdStart;
|
|
573
|
+
if (startOpts.sessionHash) {
|
|
574
|
+
this.session.applySessionHash(startOpts.sessionHash);
|
|
575
|
+
}
|
|
576
|
+
if (startOpts.forceNew) {
|
|
577
|
+
this.session.reset();
|
|
578
|
+
}
|
|
579
|
+
this.session.assign({
|
|
580
|
+
userID: startOpts.userID,
|
|
581
|
+
metadata: startOpts.metadata,
|
|
582
|
+
});
|
|
583
|
+
if (!isNewSession) {
|
|
584
|
+
this.debug.log('continuing session on new tab', this.session.getTabId());
|
|
585
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
586
|
+
this.send((0, messages_gen_js_2.TabChange)(this.session.getTabId()));
|
|
587
|
+
}
|
|
588
|
+
this.observer.observe();
|
|
589
|
+
this.ticker.start();
|
|
590
|
+
};
|
|
591
|
+
this.coldInterval = setInterval(() => {
|
|
592
|
+
cycle();
|
|
593
|
+
}, 30 * second);
|
|
594
|
+
cycle();
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Starts offline session recording
|
|
598
|
+
* @param {Object} startOpts - options for session start, same as .start()
|
|
599
|
+
* @param {Function} onSessionSent - callback that will be called once session is fully sent
|
|
600
|
+
* */
|
|
601
|
+
offlineRecording(startOpts = {}, onSessionSent) {
|
|
602
|
+
this.onSessionSent = onSessionSent;
|
|
603
|
+
this.singleBuffer = true;
|
|
604
|
+
const isNewSession = this.checkSessionToken(startOpts.forceNew);
|
|
605
|
+
(0, utils_js_1.adjustTimeOrigin)();
|
|
606
|
+
this.coldStartTs = (0, utils_js_1.now)();
|
|
607
|
+
const saverBuffer = this.localStorage.getItem(bufferStorageKey);
|
|
608
|
+
if (saverBuffer) {
|
|
609
|
+
const data = JSON.parse(saverBuffer);
|
|
610
|
+
this.bufferedMessages1 = Array.isArray(data) ? data : this.bufferedMessages1;
|
|
611
|
+
this.localStorage.removeItem(bufferStorageKey);
|
|
612
|
+
}
|
|
613
|
+
this.bufferedMessages1.push((0, messages_gen_js_2.Timestamp)(this.timestamp()));
|
|
614
|
+
this.bufferedMessages1.push((0, messages_gen_js_2.TabData)(this.session.getTabId()));
|
|
615
|
+
this.activityState = ActivityState.ColdStart;
|
|
616
|
+
if (startOpts.sessionHash) {
|
|
617
|
+
this.session.applySessionHash(startOpts.sessionHash);
|
|
618
|
+
}
|
|
619
|
+
if (startOpts.forceNew) {
|
|
620
|
+
this.session.reset();
|
|
621
|
+
}
|
|
622
|
+
this.session.assign({
|
|
623
|
+
userID: startOpts.userID,
|
|
624
|
+
metadata: startOpts.metadata,
|
|
625
|
+
});
|
|
626
|
+
const onStartInfo = { sessionToken: '', userUUID: '', sessionID: '' };
|
|
627
|
+
this.startCallbacks.forEach((cb) => cb(onStartInfo));
|
|
628
|
+
if (!isNewSession) {
|
|
629
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
630
|
+
this.send((0, messages_gen_js_2.TabChange)(this.session.getTabId()));
|
|
631
|
+
}
|
|
632
|
+
this.observer.observe();
|
|
633
|
+
this.ticker.start();
|
|
634
|
+
return {
|
|
635
|
+
saveBuffer: this.saveBuffer,
|
|
636
|
+
getBuffer: this.getBuffer,
|
|
637
|
+
setBuffer: this.setBuffer,
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Saves the captured messages in localStorage (or whatever is used in its place)
|
|
642
|
+
*
|
|
643
|
+
* Then when this.offlineRecording is called, it will preload this messages and clear the storage item
|
|
644
|
+
*
|
|
645
|
+
* Keeping the size of local storage reasonable is up to the end users of this library
|
|
646
|
+
* */
|
|
647
|
+
saveBuffer() {
|
|
648
|
+
this.localStorage.setItem(bufferStorageKey, JSON.stringify(this.bufferedMessages1));
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* @returns buffer with stored messages for offline recording
|
|
652
|
+
* */
|
|
653
|
+
getBuffer() {
|
|
654
|
+
return this.bufferedMessages1;
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* Used to set a buffer with messages array
|
|
658
|
+
* */
|
|
659
|
+
setBuffer(buffer) {
|
|
660
|
+
this.bufferedMessages1 = buffer;
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Uploads the stored session buffer to backend
|
|
664
|
+
* @returns promise that resolves once messages are loaded, it has to be awaited
|
|
665
|
+
* so the session can be uploaded properly
|
|
666
|
+
* @resolve - if messages were loaded in service worker successfully
|
|
667
|
+
* @reject {string} - error message
|
|
668
|
+
* */
|
|
669
|
+
async uploadOfflineRecording() {
|
|
670
|
+
var _a, _b;
|
|
671
|
+
this.stop(false);
|
|
672
|
+
const timestamp = (0, utils_js_1.now)();
|
|
673
|
+
(_a = this.worker) === null || _a === void 0 ? void 0 : _a.postMessage({
|
|
674
|
+
type: 'start',
|
|
675
|
+
pageNo: this.session.incPageNo(),
|
|
676
|
+
ingestPoint: this.options.ingestPoint,
|
|
677
|
+
timestamp: this.coldStartTs,
|
|
678
|
+
url: document.URL,
|
|
679
|
+
connAttemptCount: this.options.connAttemptCount,
|
|
680
|
+
connAttemptGap: this.options.connAttemptGap,
|
|
681
|
+
tabId: this.session.getTabId(),
|
|
682
|
+
});
|
|
683
|
+
const r = await fetch(this.options.ingestPoint + '/v1/web/start', {
|
|
684
|
+
method: 'POST',
|
|
685
|
+
headers: {
|
|
686
|
+
'Content-Type': 'application/json',
|
|
687
|
+
},
|
|
688
|
+
body: JSON.stringify(Object.assign(Object.assign({}, this.getTrackerInfo()), { timestamp: timestamp, doNotRecord: false, bufferDiff: timestamp - this.coldStartTs, userID: this.session.getInfo().userID, token: undefined, deviceMemory: performance_js_1.deviceMemory,
|
|
689
|
+
jsHeapSizeLimit: performance_js_1.jsHeapSizeLimit, timezone: getTimezone() })),
|
|
690
|
+
});
|
|
691
|
+
const { token, userBrowser, userCity, userCountry, userDevice, userOS, userState, beaconSizeLimit, projectID, } = await r.json();
|
|
692
|
+
(_b = this.worker) === null || _b === void 0 ? void 0 : _b.postMessage({
|
|
693
|
+
type: 'auth',
|
|
694
|
+
token,
|
|
695
|
+
beaconSizeLimit,
|
|
696
|
+
});
|
|
697
|
+
this.session.assign({ projectID });
|
|
698
|
+
this.session.setUserInfo({
|
|
699
|
+
userBrowser,
|
|
700
|
+
userCity,
|
|
701
|
+
userCountry,
|
|
702
|
+
userDevice,
|
|
703
|
+
userOS,
|
|
704
|
+
userState,
|
|
705
|
+
});
|
|
706
|
+
while (this.bufferedMessages1.length > 0) {
|
|
707
|
+
await this.flushBuffer(this.bufferedMessages1);
|
|
708
|
+
}
|
|
709
|
+
this.postToWorker([['q_end']]);
|
|
710
|
+
this.clearBuffers();
|
|
711
|
+
}
|
|
712
|
+
_start(startOpts = {}, resetByWorker = false, conditionName) {
|
|
713
|
+
const isColdStart = this.activityState === ActivityState.ColdStart;
|
|
714
|
+
if (isColdStart && this.coldInterval) {
|
|
715
|
+
clearInterval(this.coldInterval);
|
|
716
|
+
}
|
|
397
717
|
if (!this.worker) {
|
|
398
|
-
|
|
718
|
+
const reason = 'No worker found: perhaps, CSP is not set.';
|
|
719
|
+
this.signalError(reason, []);
|
|
720
|
+
return Promise.resolve(UnsuccessfulStart(reason));
|
|
399
721
|
}
|
|
400
|
-
if (this.activityState
|
|
401
|
-
|
|
722
|
+
if (this.activityState === ActivityState.Active ||
|
|
723
|
+
this.activityState === ActivityState.Starting) {
|
|
724
|
+
const reason = 'OpenReplay: trying to call `start()` on the instance that has been started already.';
|
|
725
|
+
return Promise.resolve(UnsuccessfulStart(reason));
|
|
402
726
|
}
|
|
403
727
|
this.activityState = ActivityState.Starting;
|
|
404
|
-
|
|
728
|
+
if (!isColdStart) {
|
|
729
|
+
(0, utils_js_1.adjustTimeOrigin)();
|
|
730
|
+
}
|
|
405
731
|
if (startOpts.sessionHash) {
|
|
406
732
|
this.session.applySessionHash(startOpts.sessionHash);
|
|
407
733
|
}
|
|
@@ -419,26 +745,24 @@ class App {
|
|
|
419
745
|
type: 'start',
|
|
420
746
|
pageNo: this.session.incPageNo(),
|
|
421
747
|
ingestPoint: this.options.ingestPoint,
|
|
422
|
-
timestamp,
|
|
748
|
+
timestamp: isColdStart ? this.coldStartTs : timestamp,
|
|
423
749
|
url: document.URL,
|
|
424
750
|
connAttemptCount: this.options.connAttemptCount,
|
|
425
751
|
connAttemptGap: this.options.connAttemptGap,
|
|
426
752
|
tabId: this.session.getTabId(),
|
|
427
753
|
});
|
|
428
|
-
const lsReset = this.sessionStorage.getItem(this.options.session_reset_key) !== null;
|
|
429
|
-
this.sessionStorage.removeItem(this.options.session_reset_key);
|
|
430
|
-
const needNewSessionID = startOpts.forceNew || lsReset || resetByWorker;
|
|
431
754
|
const sessionToken = this.session.getSessionToken();
|
|
432
|
-
const isNewSession =
|
|
433
|
-
this.
|
|
755
|
+
const isNewSession = this.checkSessionToken(startOpts.forceNew);
|
|
756
|
+
this.sessionStorage.removeItem(this.options.session_reset_key);
|
|
757
|
+
this.debug.log('OpenReplay: starting session; need new session id?', isNewSession, 'session token: ', sessionToken);
|
|
434
758
|
return window
|
|
435
759
|
.fetch(this.options.ingestPoint + '/v1/web/start', {
|
|
436
760
|
method: 'POST',
|
|
437
761
|
headers: {
|
|
438
762
|
'Content-Type': 'application/json',
|
|
439
763
|
},
|
|
440
|
-
body: JSON.stringify(Object.assign(Object.assign({}, this.getTrackerInfo()), { timestamp, userID: this.session.getInfo().userID, token: isNewSession ? undefined : sessionToken, deviceMemory: performance_js_1.deviceMemory,
|
|
441
|
-
jsHeapSizeLimit: performance_js_1.jsHeapSizeLimit, timezone: getTimezone() })),
|
|
764
|
+
body: JSON.stringify(Object.assign(Object.assign({}, this.getTrackerInfo()), { timestamp, doNotRecord: false, bufferDiff: timestamp - this.coldStartTs, userID: this.session.getInfo().userID, token: isNewSession ? undefined : sessionToken, deviceMemory: performance_js_1.deviceMemory,
|
|
765
|
+
jsHeapSizeLimit: performance_js_1.jsHeapSizeLimit, timezone: getTimezone(), condition: conditionName })),
|
|
442
766
|
})
|
|
443
767
|
.then((r) => {
|
|
444
768
|
if (r.status === 200) {
|
|
@@ -452,13 +776,17 @@ class App {
|
|
|
452
776
|
: Promise.reject(`Server error: ${r.status}. ${text}`));
|
|
453
777
|
}
|
|
454
778
|
})
|
|
455
|
-
.then((r) => {
|
|
779
|
+
.then(async (r) => {
|
|
456
780
|
var _a;
|
|
457
781
|
if (!this.worker) {
|
|
458
|
-
|
|
782
|
+
const reason = 'no worker found after start request (this might not happen)';
|
|
783
|
+
this.signalError(reason, []);
|
|
784
|
+
return Promise.reject(reason);
|
|
459
785
|
}
|
|
460
786
|
if (this.activityState === ActivityState.NotActive) {
|
|
461
|
-
|
|
787
|
+
const reason = 'Tracker stopped during authorization';
|
|
788
|
+
this.signalError(reason, []);
|
|
789
|
+
return Promise.reject(reason);
|
|
462
790
|
}
|
|
463
791
|
const { token, userUUID, projectID, beaconSizeLimit, compressionThreshold, // how big the batch should be before we decide to compress it
|
|
464
792
|
delay, // derived from token
|
|
@@ -471,7 +799,9 @@ class App {
|
|
|
471
799
|
typeof sessionID !== 'string' ||
|
|
472
800
|
typeof delay !== 'number' ||
|
|
473
801
|
(typeof beaconSizeLimit !== 'number' && typeof beaconSizeLimit !== 'undefined')) {
|
|
474
|
-
|
|
802
|
+
const reason = `Incorrect server response: ${JSON.stringify(r)}`;
|
|
803
|
+
this.signalError(reason, []);
|
|
804
|
+
return Promise.reject(reason);
|
|
475
805
|
}
|
|
476
806
|
this.delay = delay;
|
|
477
807
|
this.session.setSessionToken(token);
|
|
@@ -488,21 +818,27 @@ class App {
|
|
|
488
818
|
timestamp: startTimestamp || timestamp,
|
|
489
819
|
projectID,
|
|
490
820
|
});
|
|
821
|
+
this.worker.postMessage({
|
|
822
|
+
type: 'auth',
|
|
823
|
+
token,
|
|
824
|
+
beaconSizeLimit,
|
|
825
|
+
});
|
|
491
826
|
if (!isNewSession && token === sessionToken) {
|
|
492
827
|
this.debug.log('continuing session on new tab', this.session.getTabId());
|
|
493
828
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
494
|
-
this.send((0,
|
|
829
|
+
this.send((0, messages_gen_js_2.TabChange)(this.session.getTabId()));
|
|
495
830
|
}
|
|
496
831
|
// (Re)send Metadata for the case of a new session
|
|
497
|
-
Object.entries(this.session.getInfo().metadata).forEach(([key, value]) => this.send((0,
|
|
832
|
+
Object.entries(this.session.getInfo().metadata).forEach(([key, value]) => this.send((0, messages_gen_js_2.Metadata)(key, value)));
|
|
498
833
|
this.localStorage.setItem(this.options.local_uuid_key, userUUID);
|
|
499
|
-
this.worker.postMessage({
|
|
500
|
-
type: 'auth',
|
|
501
|
-
token,
|
|
502
|
-
beaconSizeLimit,
|
|
503
|
-
});
|
|
504
834
|
this.compressionThreshold = compressionThreshold;
|
|
505
835
|
const onStartInfo = { sessionToken: token, userUUID, sessionID };
|
|
836
|
+
// TODO: start as early as possible (before receiving the token)
|
|
837
|
+
/** after start */
|
|
838
|
+
this.startCallbacks.forEach((cb) => cb(onStartInfo)); // MBTODO: callbacks after DOM "mounted" (observed)
|
|
839
|
+
void this.featureFlags.reloadFlags();
|
|
840
|
+
await this.tagWatcher.fetchTags(this.options.ingestPoint, token);
|
|
841
|
+
this.activityState = ActivityState.Active;
|
|
506
842
|
if (canvasEnabled) {
|
|
507
843
|
this.canvasRecorder =
|
|
508
844
|
(_a = this.canvasRecorder) !== null && _a !== void 0 ? _a : new canvas_js_1.default(this, {
|
|
@@ -512,12 +848,22 @@ class App {
|
|
|
512
848
|
});
|
|
513
849
|
this.canvasRecorder.startTracking();
|
|
514
850
|
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
851
|
+
/** --------------- COLD START BUFFER ------------------*/
|
|
852
|
+
if (isColdStart) {
|
|
853
|
+
const biggestBuffer = this.bufferedMessages1.length > this.bufferedMessages2.length
|
|
854
|
+
? this.bufferedMessages1
|
|
855
|
+
: this.bufferedMessages2;
|
|
856
|
+
while (biggestBuffer.length > 0) {
|
|
857
|
+
await this.flushBuffer(biggestBuffer);
|
|
858
|
+
}
|
|
859
|
+
this.clearBuffers();
|
|
860
|
+
this.commit();
|
|
861
|
+
/** --------------- COLD START BUFFER ------------------*/
|
|
862
|
+
}
|
|
863
|
+
else {
|
|
864
|
+
this.observer.observe();
|
|
865
|
+
this.ticker.start();
|
|
866
|
+
}
|
|
521
867
|
// get rid of onStart ?
|
|
522
868
|
if (typeof this.options.onStart === 'function') {
|
|
523
869
|
this.options.onStart(onStartInfo);
|
|
@@ -558,10 +904,11 @@ class App {
|
|
|
558
904
|
this.stop();
|
|
559
905
|
this.session.reset();
|
|
560
906
|
if (reason === CANCELED) {
|
|
907
|
+
this.signalError(CANCELED, []);
|
|
561
908
|
return UnsuccessfulStart(CANCELED);
|
|
562
909
|
}
|
|
563
|
-
this.notify.log('OpenReplay was unable to start. ', reason);
|
|
564
910
|
this._debug('session_start', reason);
|
|
911
|
+
this.signalError(START_ERROR, []);
|
|
565
912
|
return UnsuccessfulStart(START_ERROR);
|
|
566
913
|
});
|
|
567
914
|
}
|
|
@@ -606,6 +953,27 @@ class App {
|
|
|
606
953
|
getTabId() {
|
|
607
954
|
return this.session.getTabId();
|
|
608
955
|
}
|
|
956
|
+
clearBuffers() {
|
|
957
|
+
this.bufferedMessages1.length = 0;
|
|
958
|
+
this.bufferedMessages2.length = 0;
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Creates a named hook that expects event name, data string and msg direction (up/down),
|
|
962
|
+
* it will skip any message bigger than 5 mb or event name bigger than 255 symbols
|
|
963
|
+
* @returns {(msgType: string, data: string, dir: "up" | "down") => void}
|
|
964
|
+
* */
|
|
965
|
+
trackWs(channelName) {
|
|
966
|
+
const channel = channelName;
|
|
967
|
+
return (msgType, data, dir = 'down') => {
|
|
968
|
+
if (typeof msgType !== 'string' ||
|
|
969
|
+
typeof data !== 'string' ||
|
|
970
|
+
data.length > 5 * 1024 * 1024 ||
|
|
971
|
+
msgType.length > 255) {
|
|
972
|
+
return;
|
|
973
|
+
}
|
|
974
|
+
this.send((0, messages_gen_js_2.WSChannel)('websocket', channel, data, this.timestamp(), dir, msgType));
|
|
975
|
+
};
|
|
976
|
+
}
|
|
609
977
|
stop(stopWorker = true) {
|
|
610
978
|
var _a;
|
|
611
979
|
if (this.activityState !== ActivityState.NotActive) {
|
|
@@ -616,7 +984,8 @@ class App {
|
|
|
616
984
|
this.nodes.clear();
|
|
617
985
|
this.ticker.stop();
|
|
618
986
|
this.stopCallbacks.forEach((cb) => cb());
|
|
619
|
-
this.
|
|
987
|
+
this.debug.log('OpenReplay tracking stopped.');
|
|
988
|
+
this.tagWatcher.clear();
|
|
620
989
|
if (this.worker && stopWorker) {
|
|
621
990
|
this.worker.postMessage('stop');
|
|
622
991
|
}
|