@observertc/observer-js 0.30.0-beta → 0.30.1-beta
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/lib/ObservedCall.d.ts +1 -1
- package/lib/ObservedCall.d.ts.map +1 -1
- package/lib/ObservedCall.js +0 -7
- package/lib/ObservedClient.d.ts +12 -4
- package/lib/ObservedClient.d.ts.map +1 -1
- package/lib/ObservedClient.js +57 -8
- package/lib/Observer.d.ts +1 -4
- package/lib/Observer.d.ts.map +1 -1
- package/lib/Observer.js +1 -0
- package/package.json +1 -1
- package/src/ObservedCall.ts +3 -29
- package/src/ObservedClient.ts +93 -11
- package/src/Observer.ts +4 -5
package/lib/ObservedCall.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ export declare class ObservedCall<AppData extends Record<string, unknown> = Reco
|
|
|
47
47
|
mediaUnitId?: string;
|
|
48
48
|
appData: ClientAppData;
|
|
49
49
|
joined?: number;
|
|
50
|
-
}): Promise<ObservedClient
|
|
50
|
+
}): Promise<ObservedClient<ClientAppData>>;
|
|
51
51
|
save(): Promise<void>;
|
|
52
52
|
private _createObservedClient;
|
|
53
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservedCall.d.ts","sourceRoot":"","sources":["../src/ObservedCall.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAwB,MAAM,kBAAkB,CAAC;AAExE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"ObservedCall.d.ts","sourceRoot":"","sources":["../src/ObservedCall.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAwB,MAAM,kBAAkB,CAAC;AAExE,O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OAAO,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;IAoB5B,IAAI;YASH,qBAAqB;CAqBnC"}
|
package/lib/ObservedCall.js
CHANGED
|
@@ -37,7 +37,6 @@ const events_1 = require("events");
|
|
|
37
37
|
const Models = __importStar(require("./models/Models"));
|
|
38
38
|
const ObservedClient_1 = require("./ObservedClient");
|
|
39
39
|
const SingleExecutor_1 = require("./common/SingleExecutor");
|
|
40
|
-
const callEventReports_1 = require("./common/callEventReports");
|
|
41
40
|
class ObservedCall extends events_1.EventEmitter {
|
|
42
41
|
static create(config, observer) {
|
|
43
42
|
var _a;
|
|
@@ -149,16 +148,10 @@ class ObservedCall extends events_1.EventEmitter {
|
|
|
149
148
|
this._clients.delete(clientId);
|
|
150
149
|
this._model.clientIds = this._model.clientIds.filter((id) => id !== clientId);
|
|
151
150
|
this.save().catch(() => void 0);
|
|
152
|
-
if (this.observer.config.addJoinAndDetachClientEvent) {
|
|
153
|
-
this.reports.addCallEventReport((0, callEventReports_1.createClientLeftEventReport)(this.serviceId, client.mediaUnitId, this.roomId, this.callId, client.clientId, client.joined, client.userId, client.marker));
|
|
154
|
-
}
|
|
155
151
|
});
|
|
156
152
|
client.on('update', onUpdate);
|
|
157
153
|
this._clients.set(clientId, client);
|
|
158
154
|
this._model.clientIds.push(clientId);
|
|
159
|
-
if (this.observer.config.addJoinAndDetachClientEvent) {
|
|
160
|
-
this.reports.addCallEventReport((0, callEventReports_1.createClientJoinedEventReport)(this.serviceId, client.mediaUnitId, this.roomId, this.callId, client.clientId, client.joined, client.userId, client.marker));
|
|
161
|
-
}
|
|
162
155
|
return client;
|
|
163
156
|
});
|
|
164
157
|
}
|
package/lib/ObservedClient.d.ts
CHANGED
|
@@ -12,6 +12,10 @@ export type ObservedClientConfig<AppData extends Record<string, unknown> = Recor
|
|
|
12
12
|
appData: AppData;
|
|
13
13
|
overflowingProcessingThreshold?: number;
|
|
14
14
|
joined?: number;
|
|
15
|
+
/**
|
|
16
|
+
* before client-monitor-js 3.4.0 the client joined event was generated by the observer, this flag is to keep the compatibility with the old behavior
|
|
17
|
+
*/
|
|
18
|
+
addJoinAndDetachClientEvent?: boolean;
|
|
15
19
|
};
|
|
16
20
|
export type ObservedClientEvents = {
|
|
17
21
|
update: [];
|
|
@@ -40,8 +44,10 @@ export declare class ObservedClient<AppData extends Record<string, unknown> = Re
|
|
|
40
44
|
private _updated;
|
|
41
45
|
private _acceptedSample;
|
|
42
46
|
private _processingSample;
|
|
43
|
-
private
|
|
44
|
-
private
|
|
47
|
+
private _selectedLocalIceCandidate?;
|
|
48
|
+
private _selectedRemoteIceCandidate?;
|
|
49
|
+
private _timeZoneOffsetInHours?;
|
|
50
|
+
private _leaveReported;
|
|
45
51
|
readonly mediaDevices: string[];
|
|
46
52
|
readonly codecs: string[];
|
|
47
53
|
readonly userMediaErrors: string[];
|
|
@@ -54,8 +60,9 @@ export declare class ObservedClient<AppData extends Record<string, unknown> = Re
|
|
|
54
60
|
get mediaUnitId(): string;
|
|
55
61
|
get reports(): import("./ReportsCollector").ReportsCollector;
|
|
56
62
|
get userId(): string | undefined;
|
|
57
|
-
get
|
|
58
|
-
get
|
|
63
|
+
get selectedLocalIceCandidate(): IceLocalCandidate | undefined;
|
|
64
|
+
get selectedRemoteIceCandidate(): IceLocalCandidate | undefined;
|
|
65
|
+
get timeZoneOffsetInHours(): number | undefined;
|
|
59
66
|
get marker(): string | undefined;
|
|
60
67
|
get browser(): Samples_ClientSample_Browser | undefined;
|
|
61
68
|
get engine(): Samples_ClientSample_Engine | undefined;
|
|
@@ -69,5 +76,6 @@ export declare class ObservedClient<AppData extends Record<string, unknown> = Re
|
|
|
69
76
|
accept(sample: ClientSample): Promise<void>;
|
|
70
77
|
private _createPeerConnection;
|
|
71
78
|
private _save;
|
|
79
|
+
private _addClientLeftReport;
|
|
72
80
|
}
|
|
73
81
|
//# sourceMappingURL=ObservedClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservedClient.d.ts","sourceRoot":"","sources":["../src/ObservedClient.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAIlE,OAAO,EAAE,4BAA4B,EAAE,2BAA2B,EAAE,oCAAoC,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"ObservedClient.d.ts","sourceRoot":"","sources":["../src/ObservedClient.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAIlE,OAAO,EAAE,4BAA4B,EAAE,2BAA2B,EAAE,oCAAoC,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AAOrK,MAAM,MAAM,oBAAoB,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;IACrG,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,8BAA8B,CAAC,EAAE,MAAM,CAAC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,2BAA2B,C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4CAEhB;IAED,IAAW,eAAe,qDAEzB;IAED,IAAW,QAAQ,8CAElB;IAED,IAAW,cAAc,WAExB;IAED,IAAW,OAAO,WAEjB;IAED,IAAW,MAAM,YAEhB;IAED,IAAW,eAAe,IAAI,WAAW,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAExE;IAEM,KAAK;IAWC,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;YA4f1C,qBAAqB;YAmBrB,KAAK;IAMnB,OAAO,CAAC,oBAAoB;CAe5B"}
|
package/lib/ObservedClient.js
CHANGED
|
@@ -53,6 +53,7 @@ const callMetaReports_1 = require("./common/callMetaReports");
|
|
|
53
53
|
// eslint-disable-next-line camelcase
|
|
54
54
|
const samples_pb_1 = require("./models/samples_pb");
|
|
55
55
|
const utils_1 = require("./common/utils");
|
|
56
|
+
const callEventReports_1 = require("./common/callEventReports");
|
|
56
57
|
const logger = (0, logger_1.createLogger)('ObservedClient');
|
|
57
58
|
class ObservedClient extends events_1.EventEmitter {
|
|
58
59
|
static create(config, call, storageProvider) {
|
|
@@ -73,6 +74,10 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
73
74
|
if (alreadyInserted)
|
|
74
75
|
throw new Error(`Client with id ${clientId} already exists`);
|
|
75
76
|
result._overflowingProcessingThreshold = (_b = config.overflowingProcessingThreshold) !== null && _b !== void 0 ? _b : 0;
|
|
77
|
+
if (config.addJoinAndDetachClientEvent) {
|
|
78
|
+
call.reports.addCallEventReport((0, callEventReports_1.createClientJoinedEventReport)(call.serviceId, result.mediaUnitId, call.roomId, call.callId, result.clientId, result.joined, result.userId, result.marker));
|
|
79
|
+
}
|
|
80
|
+
result.once('close', () => result._addClientLeftReport());
|
|
76
81
|
return result;
|
|
77
82
|
});
|
|
78
83
|
}
|
|
@@ -89,6 +94,7 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
89
94
|
this._updated = Date.now();
|
|
90
95
|
this._acceptedSample = 0;
|
|
91
96
|
this._processingSample = 0;
|
|
97
|
+
this._leaveReported = false;
|
|
92
98
|
this.mediaDevices = [];
|
|
93
99
|
this.codecs = [];
|
|
94
100
|
this.userMediaErrors = [];
|
|
@@ -123,11 +129,14 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
123
129
|
get userId() {
|
|
124
130
|
return this._model.userId;
|
|
125
131
|
}
|
|
126
|
-
get
|
|
127
|
-
return this.
|
|
132
|
+
get selectedLocalIceCandidate() {
|
|
133
|
+
return this._selectedLocalIceCandidate;
|
|
134
|
+
}
|
|
135
|
+
get selectedRemoteIceCandidate() {
|
|
136
|
+
return this._selectedRemoteIceCandidate;
|
|
128
137
|
}
|
|
129
|
-
get
|
|
130
|
-
return this.
|
|
138
|
+
get timeZoneOffsetInHours() {
|
|
139
|
+
return this._timeZoneOffsetInHours;
|
|
131
140
|
}
|
|
132
141
|
get marker() {
|
|
133
142
|
return this._model.marker;
|
|
@@ -188,6 +197,10 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
188
197
|
this._model.marker = sample.marker;
|
|
189
198
|
executeSave = true;
|
|
190
199
|
}
|
|
200
|
+
if (this._timeZoneOffsetInHours !== sample.timeZoneOffsetInHours) {
|
|
201
|
+
this._timeZoneOffsetInHours = sample.timeZoneOffsetInHours;
|
|
202
|
+
executeSave = true;
|
|
203
|
+
}
|
|
191
204
|
if (sample.os && (((_a = this._model.operationSystem) === null || _a === void 0 ? void 0 : _a.name) !== sample.os.name ||
|
|
192
205
|
((_b = this._model.operationSystem) === null || _b === void 0 ? void 0 : _b.version) !== sample.os.version ||
|
|
193
206
|
((_c = this._model.operationSystem) === null || _c === void 0 ? void 0 : _c.versionName) !== sample.os.versionName)) {
|
|
@@ -259,6 +272,8 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
259
272
|
}
|
|
260
273
|
for (let _17 of (_p = sample.customCallEvents) !== null && _p !== void 0 ? _p : []) {
|
|
261
274
|
const { timestamp = Date.now() } = _17, callEvent = __rest(_17, ["timestamp"]);
|
|
275
|
+
if (callEvent.name === 'CLIENT_LEFT')
|
|
276
|
+
this._leaveReported = true;
|
|
262
277
|
this.reports.addCallEventReport(Object.assign({ serviceId: this.serviceId, mediaUnitId: this.mediaUnitId, roomId: this.roomId, callId: this.callId, clientId: this.clientId, userId: this.userId, timestamp }, callEvent));
|
|
263
278
|
}
|
|
264
279
|
for (const userMediaError of (_q = sample.userMediaErrors) !== null && _q !== void 0 ? _q : []) {
|
|
@@ -322,8 +337,8 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
322
337
|
for (const iceLocalCandidate of (_x = sample.iceLocalCandidates) !== null && _x !== void 0 ? _x : []) {
|
|
323
338
|
if (iceLocalCandidate.id && selectedLocalCandidateId &&
|
|
324
339
|
iceLocalCandidate.id === selectedLocalCandidateId &&
|
|
325
|
-
((_y = this.
|
|
326
|
-
this.
|
|
340
|
+
((_y = this._selectedLocalIceCandidate) === null || _y === void 0 ? void 0 : _y.id) !== iceLocalCandidate.id) {
|
|
341
|
+
this._selectedLocalIceCandidate = iceLocalCandidate;
|
|
327
342
|
changeIceCandidatePair = true;
|
|
328
343
|
}
|
|
329
344
|
const callMetaReport = (0, callMetaReports_1.createCallMetaReport)(this.serviceId, this.mediaUnitId, this.roomId, this.callId, this.clientId, {
|
|
@@ -335,8 +350,8 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
335
350
|
for (const iceRemoteCandidate of (_z = sample.iceRemoteCandidates) !== null && _z !== void 0 ? _z : []) {
|
|
336
351
|
if (iceRemoteCandidate.id && selectedRemoteCandidateId &&
|
|
337
352
|
iceRemoteCandidate.id === selectedRemoteCandidateId &&
|
|
338
|
-
((_0 = this.
|
|
339
|
-
this.
|
|
353
|
+
((_0 = this._selectedRemoteIceCandidate) === null || _0 === void 0 ? void 0 : _0.id) !== iceRemoteCandidate.id) {
|
|
354
|
+
this._selectedRemoteIceCandidate = iceRemoteCandidate;
|
|
340
355
|
changeIceCandidatePair = true;
|
|
341
356
|
}
|
|
342
357
|
const callMetaReport = (0, callMetaReports_1.createCallMetaReport)(this.serviceId, this.mediaUnitId, this.roomId, this.callId, this.clientId, {
|
|
@@ -447,6 +462,34 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
447
462
|
logger.error(`Error creating outbound video track: ${err === null || err === void 0 ? void 0 : err.message}`);
|
|
448
463
|
}
|
|
449
464
|
}
|
|
465
|
+
// close entries that are idle for too long
|
|
466
|
+
if (this.call.observer.config.maxEntryIdleTimeInMs && this._updated < sample.timestamp) {
|
|
467
|
+
for (const peerConnection of this._peerConnections.values()) {
|
|
468
|
+
if (this.call.observer.config.maxEntryIdleTimeInMs < sample.timestamp - peerConnection.updated) {
|
|
469
|
+
logger.debug(`Closing peer connection ${peerConnection.peerConnectionId} due to inactivity`);
|
|
470
|
+
peerConnection.close();
|
|
471
|
+
continue;
|
|
472
|
+
}
|
|
473
|
+
for (const track of peerConnection.inboundAudioTracks.values()) {
|
|
474
|
+
if (this.call.observer.config.maxEntryIdleTimeInMs < sample.timestamp - track.updated) {
|
|
475
|
+
logger.debug(`Closing inbound audio track ${track.trackId} due to inactivity`);
|
|
476
|
+
track.close();
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
for (const track of peerConnection.inboundVideoTracks.values()) {
|
|
480
|
+
if (this.call.observer.config.maxEntryIdleTimeInMs < sample.timestamp - track.updated) {
|
|
481
|
+
logger.debug(`Closing inbound video track ${track.trackId} due to inactivity`);
|
|
482
|
+
track.close();
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
for (const track of peerConnection.outboundAudioTracks.values()) {
|
|
486
|
+
if (this.call.observer.config.maxEntryIdleTimeInMs < sample.timestamp - track.updated) {
|
|
487
|
+
logger.debug(`Closing outbound audio track ${track.trackId} due to inactivity`);
|
|
488
|
+
track.close();
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
450
493
|
if (changeIceCandidatePair) {
|
|
451
494
|
this.emit('candidate-pair-change');
|
|
452
495
|
}
|
|
@@ -483,5 +526,11 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
483
526
|
return this._storageProvider.clientStorage.set(this.clientId, this._model);
|
|
484
527
|
});
|
|
485
528
|
}
|
|
529
|
+
_addClientLeftReport() {
|
|
530
|
+
if (this._leaveReported)
|
|
531
|
+
return;
|
|
532
|
+
this._leaveReported = true;
|
|
533
|
+
this.reports.addCallEventReport((0, callEventReports_1.createClientLeftEventReport)(this.serviceId, this.mediaUnitId, this.roomId, this.callId, this.clientId, this.joined, this.userId, this.marker));
|
|
534
|
+
}
|
|
486
535
|
}
|
|
487
536
|
exports.ObservedClient = ObservedClient;
|
package/lib/Observer.d.ts
CHANGED
|
@@ -25,11 +25,8 @@ export type ObserverConfig = {
|
|
|
25
25
|
defaultMediaUnitId: string;
|
|
26
26
|
maxReports?: number | undefined;
|
|
27
27
|
maxCollectingTimeInMs?: number | undefined;
|
|
28
|
+
maxEntryIdleTimeInMs?: number | undefined;
|
|
28
29
|
storages?: StorageProvider;
|
|
29
|
-
/**
|
|
30
|
-
* before client-monitor-js 3.4.0 the client joined event was generated by the observer, this flag is to keep the compatibility with the old behavior
|
|
31
|
-
*/
|
|
32
|
-
addJoinAndDetachClientEvent?: boolean;
|
|
33
30
|
};
|
|
34
31
|
export declare interface Observer {
|
|
35
32
|
on<U extends keyof ObserverEvents>(event: U, listener: (...args: ObserverEvents[U]) => void): this;
|
package/lib/Observer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Observer.d.ts","sourceRoot":"","sources":["../src/Observer.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,eAAe,EAA+B,MAAM,4BAA4B,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EA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,IAAI,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,CAE5D;IAED,IAAW,MAAM,YAEhB;IAEM,KAAK;IASZ,OAAO,CAAC,YAAY;CAepB"}
|
package/lib/Observer.js
CHANGED
package/package.json
CHANGED
package/src/ObservedCall.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { ObservedClient, ObservedClientConfig } from './ObservedClient';
|
|
|
4
4
|
import { createSingleExecutor } from './common/SingleExecutor';
|
|
5
5
|
import { ObservedOutboundTrack } from './ObservedOutboundTrack';
|
|
6
6
|
import { Observer } from './Observer';
|
|
7
|
-
import { createClientJoinedEventReport, createClientLeftEventReport } from './common/callEventReports';
|
|
8
7
|
|
|
9
8
|
export type ObservedCallConfig<AppData extends Record<string, unknown> = Record<string, unknown>> = {
|
|
10
9
|
serviceId: string;
|
|
@@ -123,11 +122,11 @@ export class ObservedCall<AppData extends Record<string, unknown> = Record<strin
|
|
|
123
122
|
public async createClient<ClientAppData extends Record<string, unknown> = Record<string, unknown>>(
|
|
124
123
|
clientId: string,
|
|
125
124
|
config: { mediaUnitId?: string, appData: ClientAppData, joined?: number }
|
|
126
|
-
): Promise<ObservedClient
|
|
125
|
+
): Promise<ObservedClient<ClientAppData>> {
|
|
127
126
|
if (this._closed) throw new Error(`Call ${this.callId} is closed`);
|
|
128
127
|
let creating = this._creatingClients.get(clientId);
|
|
129
128
|
|
|
130
|
-
if (creating) return creating
|
|
129
|
+
if (creating) return creating as Promise<ObservedClient<ClientAppData>>;
|
|
131
130
|
|
|
132
131
|
creating = this._createObservedClient<ClientAppData>(clientId, {
|
|
133
132
|
callId: this.callId,
|
|
@@ -140,7 +139,7 @@ export class ObservedCall<AppData extends Record<string, unknown> = Record<strin
|
|
|
140
139
|
|
|
141
140
|
this._creatingClients.set(clientId, creating);
|
|
142
141
|
|
|
143
|
-
return creating
|
|
142
|
+
return creating as Promise<ObservedClient<ClientAppData>>;
|
|
144
143
|
}
|
|
145
144
|
|
|
146
145
|
public async save() {
|
|
@@ -165,36 +164,11 @@ export class ObservedCall<AppData extends Record<string, unknown> = Record<strin
|
|
|
165
164
|
this._model.clientIds = this._model.clientIds.filter((id) => id !== clientId);
|
|
166
165
|
this.save().catch(() => void 0);
|
|
167
166
|
|
|
168
|
-
if (this.observer.config.addJoinAndDetachClientEvent) {
|
|
169
|
-
this.reports.addCallEventReport(createClientLeftEventReport(
|
|
170
|
-
this.serviceId,
|
|
171
|
-
client.mediaUnitId,
|
|
172
|
-
this.roomId,
|
|
173
|
-
this.callId,
|
|
174
|
-
client.clientId,
|
|
175
|
-
client.joined,
|
|
176
|
-
client.userId,
|
|
177
|
-
client.marker,
|
|
178
|
-
));
|
|
179
|
-
}
|
|
180
167
|
});
|
|
181
168
|
|
|
182
169
|
client.on('update', onUpdate);
|
|
183
170
|
this._clients.set(clientId, client);
|
|
184
171
|
this._model.clientIds.push(clientId);
|
|
185
|
-
|
|
186
|
-
if (this.observer.config.addJoinAndDetachClientEvent) {
|
|
187
|
-
this.reports.addCallEventReport(createClientJoinedEventReport(
|
|
188
|
-
this.serviceId,
|
|
189
|
-
client.mediaUnitId,
|
|
190
|
-
this.roomId,
|
|
191
|
-
this.callId,
|
|
192
|
-
client.clientId,
|
|
193
|
-
client.joined,
|
|
194
|
-
client.userId,
|
|
195
|
-
client.marker,
|
|
196
|
-
));
|
|
197
|
-
}
|
|
198
172
|
|
|
199
173
|
return client;
|
|
200
174
|
}
|
package/src/ObservedClient.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { CallMetaType, createCallMetaReport } from './common/callMetaReports';
|
|
|
11
11
|
import { Samples_ClientSample_Browser, Samples_ClientSample_Engine, Samples_ClientSample_OperationSystem, Samples_ClientSample_Platform } from './models/samples_pb';
|
|
12
12
|
import { IceCandidatePairReport } from '@observertc/report-schemas-js';
|
|
13
13
|
import { isValidUuid } from './common/utils';
|
|
14
|
+
import { createClientJoinedEventReport, createClientLeftEventReport } from './common/callEventReports';
|
|
14
15
|
|
|
15
16
|
const logger = createLogger('ObservedClient');
|
|
16
17
|
|
|
@@ -21,6 +22,11 @@ export type ObservedClientConfig<AppData extends Record<string, unknown> = Recor
|
|
|
21
22
|
appData: AppData;
|
|
22
23
|
overflowingProcessingThreshold?: number;
|
|
23
24
|
joined?: number,
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* before client-monitor-js 3.4.0 the client joined event was generated by the observer, this flag is to keep the compatibility with the old behavior
|
|
28
|
+
*/
|
|
29
|
+
addJoinAndDetachClientEvent?: boolean;
|
|
24
30
|
};
|
|
25
31
|
|
|
26
32
|
export type ObservedClientEvents = {
|
|
@@ -65,6 +71,21 @@ export class ObservedClient<AppData extends Record<string, unknown> = Record<str
|
|
|
65
71
|
|
|
66
72
|
result._overflowingProcessingThreshold = config.overflowingProcessingThreshold ?? 0;
|
|
67
73
|
|
|
74
|
+
if (config.addJoinAndDetachClientEvent) {
|
|
75
|
+
call.reports.addCallEventReport(createClientJoinedEventReport(
|
|
76
|
+
call.serviceId,
|
|
77
|
+
result.mediaUnitId,
|
|
78
|
+
call.roomId,
|
|
79
|
+
call.callId,
|
|
80
|
+
result.clientId,
|
|
81
|
+
result.joined,
|
|
82
|
+
result.userId,
|
|
83
|
+
result.marker,
|
|
84
|
+
));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
result.once('close', () => result._addClientLeftReport());
|
|
88
|
+
|
|
68
89
|
return result;
|
|
69
90
|
}
|
|
70
91
|
|
|
@@ -76,9 +97,11 @@ export class ObservedClient<AppData extends Record<string, unknown> = Record<str
|
|
|
76
97
|
private _updated = Date.now();
|
|
77
98
|
private _acceptedSample = 0;
|
|
78
99
|
private _processingSample = 0;
|
|
79
|
-
private
|
|
80
|
-
private
|
|
81
|
-
|
|
100
|
+
private _selectedLocalIceCandidate?: IceLocalCandidate;
|
|
101
|
+
private _selectedRemoteIceCandidate?: IceLocalCandidate;
|
|
102
|
+
private _timeZoneOffsetInHours?: number;
|
|
103
|
+
private _leaveReported = false;
|
|
104
|
+
|
|
82
105
|
public readonly mediaDevices: string[] = [];
|
|
83
106
|
public readonly codecs: string[] = [];
|
|
84
107
|
public readonly userMediaErrors: string[] = [];
|
|
@@ -130,12 +153,16 @@ export class ObservedClient<AppData extends Record<string, unknown> = Record<str
|
|
|
130
153
|
return this._model.userId;
|
|
131
154
|
}
|
|
132
155
|
|
|
133
|
-
public get
|
|
134
|
-
return this.
|
|
156
|
+
public get selectedLocalIceCandidate() {
|
|
157
|
+
return this._selectedLocalIceCandidate;
|
|
135
158
|
}
|
|
136
159
|
|
|
137
|
-
public get
|
|
138
|
-
return this.
|
|
160
|
+
public get selectedRemoteIceCandidate() {
|
|
161
|
+
return this._selectedRemoteIceCandidate;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
public get timeZoneOffsetInHours() {
|
|
165
|
+
return this._timeZoneOffsetInHours;
|
|
139
166
|
}
|
|
140
167
|
|
|
141
168
|
public get marker() {
|
|
@@ -209,6 +236,11 @@ export class ObservedClient<AppData extends Record<string, unknown> = Record<str
|
|
|
209
236
|
executeSave = true;
|
|
210
237
|
}
|
|
211
238
|
|
|
239
|
+
if (this._timeZoneOffsetInHours !== sample.timeZoneOffsetInHours) {
|
|
240
|
+
this._timeZoneOffsetInHours = sample.timeZoneOffsetInHours;
|
|
241
|
+
executeSave = true;
|
|
242
|
+
}
|
|
243
|
+
|
|
212
244
|
if (sample.os && (
|
|
213
245
|
this._model.operationSystem?.name !== sample.os.name ||
|
|
214
246
|
this._model.operationSystem?.version !== sample.os.version ||
|
|
@@ -348,6 +380,8 @@ export class ObservedClient<AppData extends Record<string, unknown> = Record<str
|
|
|
348
380
|
}
|
|
349
381
|
|
|
350
382
|
for (const { timestamp = Date.now(), ...callEvent } of sample.customCallEvents ?? []) {
|
|
383
|
+
if (callEvent.name === 'CLIENT_LEFT') this._leaveReported = true;
|
|
384
|
+
|
|
351
385
|
this.reports.addCallEventReport({
|
|
352
386
|
serviceId: this.serviceId,
|
|
353
387
|
mediaUnitId: this.mediaUnitId,
|
|
@@ -468,6 +502,7 @@ export class ObservedClient<AppData extends Record<string, unknown> = Record<str
|
|
|
468
502
|
};
|
|
469
503
|
|
|
470
504
|
this.reports.addIceCandidatePairReport(report);
|
|
505
|
+
|
|
471
506
|
}
|
|
472
507
|
|
|
473
508
|
let changeIceCandidatePair = false;
|
|
@@ -476,9 +511,9 @@ export class ObservedClient<AppData extends Record<string, unknown> = Record<str
|
|
|
476
511
|
if (
|
|
477
512
|
iceLocalCandidate.id && selectedLocalCandidateId &&
|
|
478
513
|
iceLocalCandidate.id === selectedLocalCandidateId &&
|
|
479
|
-
this.
|
|
514
|
+
this._selectedLocalIceCandidate?.id !== iceLocalCandidate.id
|
|
480
515
|
) {
|
|
481
|
-
this.
|
|
516
|
+
this._selectedLocalIceCandidate = iceLocalCandidate;
|
|
482
517
|
changeIceCandidatePair = true;
|
|
483
518
|
}
|
|
484
519
|
const callMetaReport = createCallMetaReport(
|
|
@@ -498,9 +533,9 @@ export class ObservedClient<AppData extends Record<string, unknown> = Record<str
|
|
|
498
533
|
if (
|
|
499
534
|
iceRemoteCandidate.id && selectedRemoteCandidateId &&
|
|
500
535
|
iceRemoteCandidate.id === selectedRemoteCandidateId &&
|
|
501
|
-
this.
|
|
536
|
+
this._selectedRemoteIceCandidate?.id !== iceRemoteCandidate.id
|
|
502
537
|
) {
|
|
503
|
-
this.
|
|
538
|
+
this._selectedRemoteIceCandidate = iceRemoteCandidate;
|
|
504
539
|
changeIceCandidatePair = true;
|
|
505
540
|
}
|
|
506
541
|
const callMetaReport = createCallMetaReport(
|
|
@@ -640,6 +675,37 @@ export class ObservedClient<AppData extends Record<string, unknown> = Record<str
|
|
|
640
675
|
logger.error(`Error creating outbound video track: ${(err as Error)?.message}`);
|
|
641
676
|
}
|
|
642
677
|
}
|
|
678
|
+
|
|
679
|
+
// close entries that are idle for too long
|
|
680
|
+
if (this.call.observer.config.maxEntryIdleTimeInMs && this._updated < sample.timestamp) {
|
|
681
|
+
|
|
682
|
+
for (const peerConnection of this._peerConnections.values()) {
|
|
683
|
+
if (this.call.observer.config.maxEntryIdleTimeInMs < sample.timestamp - peerConnection.updated) {
|
|
684
|
+
logger.debug(`Closing peer connection ${peerConnection.peerConnectionId} due to inactivity`);
|
|
685
|
+
peerConnection.close();
|
|
686
|
+
|
|
687
|
+
continue;
|
|
688
|
+
}
|
|
689
|
+
for (const track of peerConnection.inboundAudioTracks.values()) {
|
|
690
|
+
if (this.call.observer.config.maxEntryIdleTimeInMs < sample.timestamp - track.updated) {
|
|
691
|
+
logger.debug(`Closing inbound audio track ${track.trackId} due to inactivity`);
|
|
692
|
+
track.close();
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
for (const track of peerConnection.inboundVideoTracks.values()) {
|
|
696
|
+
if (this.call.observer.config.maxEntryIdleTimeInMs < sample.timestamp - track.updated) {
|
|
697
|
+
logger.debug(`Closing inbound video track ${track.trackId} due to inactivity`);
|
|
698
|
+
track.close();
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
for (const track of peerConnection.outboundAudioTracks.values()) {
|
|
702
|
+
if (this.call.observer.config.maxEntryIdleTimeInMs < sample.timestamp - track.updated) {
|
|
703
|
+
logger.debug(`Closing outbound audio track ${track.trackId} due to inactivity`);
|
|
704
|
+
track.close();
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
}
|
|
643
709
|
|
|
644
710
|
if (changeIceCandidatePair) {
|
|
645
711
|
this.emit('candidate-pair-change');
|
|
@@ -678,4 +744,20 @@ export class ObservedClient<AppData extends Record<string, unknown> = Record<str
|
|
|
678
744
|
|
|
679
745
|
return this._storageProvider.clientStorage.set(this.clientId, this._model);
|
|
680
746
|
}
|
|
747
|
+
|
|
748
|
+
private _addClientLeftReport() {
|
|
749
|
+
if (this._leaveReported) return;
|
|
750
|
+
this._leaveReported = true;
|
|
751
|
+
|
|
752
|
+
this.reports.addCallEventReport(createClientLeftEventReport(
|
|
753
|
+
this.serviceId,
|
|
754
|
+
this.mediaUnitId,
|
|
755
|
+
this.roomId,
|
|
756
|
+
this.callId,
|
|
757
|
+
this.clientId,
|
|
758
|
+
this.joined,
|
|
759
|
+
this.userId,
|
|
760
|
+
this.marker,
|
|
761
|
+
));
|
|
762
|
+
}
|
|
681
763
|
}
|
package/src/Observer.ts
CHANGED
|
@@ -34,13 +34,10 @@ export type ObserverConfig = {
|
|
|
34
34
|
|
|
35
35
|
maxReports?: number | undefined;
|
|
36
36
|
maxCollectingTimeInMs?: number | undefined;
|
|
37
|
+
|
|
38
|
+
maxEntryIdleTimeInMs?: number | undefined;
|
|
37
39
|
|
|
38
40
|
storages?: StorageProvider;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* before client-monitor-js 3.4.0 the client joined event was generated by the observer, this flag is to keep the compatibility with the old behavior
|
|
42
|
-
*/
|
|
43
|
-
addJoinAndDetachClientEvent?: boolean;
|
|
44
41
|
};
|
|
45
42
|
|
|
46
43
|
export declare interface Observer {
|
|
@@ -88,6 +85,8 @@ export class Observer extends EventEmitter {
|
|
|
88
85
|
}
|
|
89
86
|
};
|
|
90
87
|
|
|
88
|
+
this._emitReports();
|
|
89
|
+
|
|
91
90
|
this.once('close', () => this.reports.off('newreport', onNewReport));
|
|
92
91
|
this.reports.on('newreport', onNewReport);
|
|
93
92
|
}
|