@observertc/observer-js 0.40.26 → 0.40.27
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/Observer.d.ts +2 -0
- package/lib/Observer.d.ts.map +1 -1
- package/lib/Observer.js +20 -0
- package/lib/monitors/ClientIssueMonitor.d.ts +35 -0
- package/lib/monitors/ClientIssueMonitor.d.ts.map +1 -0
- package/lib/monitors/ClientIssueMonitor.js +49 -0
- package/package.json +1 -1
- package/src/Observer.ts +27 -0
- package/src/monitors/ClientIssueMonitor.ts +89 -0
package/lib/Observer.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { ObserverSinkContext } from './common/types';
|
|
|
7
7
|
import { ObservedSfu, ObservedSfuModel } from './ObservedSfu';
|
|
8
8
|
import { CallSummaryMonitor, CallSummaryMonitorConfig } from './monitors/CallSummaryMonitor';
|
|
9
9
|
import { TurnUsageMonitor } from './monitors/TurnUsageMonitor';
|
|
10
|
+
import { ClientIssueMonitor } from './monitors/ClientIssueMonitor';
|
|
10
11
|
export type ObserverEvents = {
|
|
11
12
|
'newcall': [ObservedCall];
|
|
12
13
|
'newsfu': [ObservedSfu];
|
|
@@ -59,6 +60,7 @@ export declare class Observer extends EventEmitter {
|
|
|
59
60
|
timeoutAfterCallClose?: number;
|
|
60
61
|
}): CallSummaryMonitor;
|
|
61
62
|
createTurnUsageMonitor(): TurnUsageMonitor;
|
|
63
|
+
createClientIssueMonitor(): ClientIssueMonitor;
|
|
62
64
|
get observedCalls(): ReadonlyMap<string, ObservedCall>;
|
|
63
65
|
get observedSfus(): ReadonlyMap<string, ObservedSfu>;
|
|
64
66
|
get closed(): boolean;
|
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,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC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CAAgC;IACrD,OAAO,CAAC,OAAO,CAAS;gBAEP,MAAM,EAAE,cAAc;IAyBhC,kBAAkB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpF,MAAM,EAAE,SAAS,CAAC,iBAAiB,EAAE,WAAW,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;QAAC,eAAe,CAAC,EAAE,OAAO,CAAA;KAAE,GAC1I,YAAY,CAAC,CAAC,CAAC;IA2CX,iBAAiB,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzF,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,OAAO,GACd,WAAW,CAAC,OAAO,CAAC;IAoBhB,wBAAwB,CAAC,OAAO,CAAC,EAAE,wBAAwB,GAAG;QAAE,qBAAqB,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,kBAAkB;IAkCrH,sBAAsB;IA+CtB,wBAAwB;IA0B/B,IAAW,aAAa,IAAI,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,CAE5D;IAED,IAAW,YAAY,IAAI,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,CAE1D;IAED,IAAW,MAAM,YAEhB;IAEM,KAAK;IAWZ,OAAO,CAAC,YAAY;CAepB"}
|
package/lib/Observer.js
CHANGED
|
@@ -20,6 +20,7 @@ const callEventReports_1 = require("./common/callEventReports");
|
|
|
20
20
|
const ObservedSfu_1 = require("./ObservedSfu");
|
|
21
21
|
const CallSummaryMonitor_1 = require("./monitors/CallSummaryMonitor");
|
|
22
22
|
const TurnUsageMonitor_1 = require("./monitors/TurnUsageMonitor");
|
|
23
|
+
const ClientIssueMonitor_1 = require("./monitors/ClientIssueMonitor");
|
|
23
24
|
const logger = (0, logger_1.createLogger)('Observer');
|
|
24
25
|
class Observer extends events_1.EventEmitter {
|
|
25
26
|
static create(providedConfig) {
|
|
@@ -163,6 +164,25 @@ class Observer extends events_1.EventEmitter {
|
|
|
163
164
|
});
|
|
164
165
|
return monitor;
|
|
165
166
|
}
|
|
167
|
+
createClientIssueMonitor() {
|
|
168
|
+
if (this._closed)
|
|
169
|
+
throw new Error('Cannot create a turn usage monitor on a closed observer');
|
|
170
|
+
const existingMonitor = this._monitors.get(ClientIssueMonitor_1.ClientIssueMonitor.name);
|
|
171
|
+
if (existingMonitor)
|
|
172
|
+
return existingMonitor;
|
|
173
|
+
const monitor = new ClientIssueMonitor_1.ClientIssueMonitor();
|
|
174
|
+
const onNewCall = (call) => monitor.addCall(call);
|
|
175
|
+
monitor.once('close', () => {
|
|
176
|
+
this._monitors.delete(CallSummaryMonitor_1.CallSummaryMonitor.name);
|
|
177
|
+
this.off('newcall', onNewCall);
|
|
178
|
+
});
|
|
179
|
+
this._monitors.set(CallSummaryMonitor_1.CallSummaryMonitor.name, monitor);
|
|
180
|
+
this.on('newcall', onNewCall);
|
|
181
|
+
this.once('close', () => {
|
|
182
|
+
monitor.close();
|
|
183
|
+
});
|
|
184
|
+
return monitor;
|
|
185
|
+
}
|
|
166
186
|
get observedCalls() {
|
|
167
187
|
return this._observedCalls;
|
|
168
188
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import { ObservedCall } from '../ObservedCall';
|
|
4
|
+
import { ClientIssue } from './CallSummary';
|
|
5
|
+
export type ClientIssueMonitorEmittedIssueEvent = ClientIssue & {
|
|
6
|
+
clientId: string;
|
|
7
|
+
callId: string;
|
|
8
|
+
};
|
|
9
|
+
export type ClientIssueMonitorEvents = {
|
|
10
|
+
close: [];
|
|
11
|
+
issue: [ClientIssueMonitorEmittedIssueEvent];
|
|
12
|
+
major: [ClientIssueMonitorEmittedIssueEvent];
|
|
13
|
+
minor: [ClientIssueMonitorEmittedIssueEvent];
|
|
14
|
+
critical: [ClientIssueMonitorEmittedIssueEvent];
|
|
15
|
+
};
|
|
16
|
+
export type ClientIssueMonitorConfig = {
|
|
17
|
+
detectUserMediaClientIssues?: boolean;
|
|
18
|
+
detectMediaTrackQualityLimitationClientIssues?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export declare interface ClientIssueMonitor {
|
|
21
|
+
on<U extends keyof ClientIssueMonitorEvents>(event: U, listener: (...args: ClientIssueMonitorEvents[U]) => void): this;
|
|
22
|
+
off<U extends keyof ClientIssueMonitorEvents>(event: U, listener: (...args: ClientIssueMonitorEvents[U]) => void): this;
|
|
23
|
+
once<U extends keyof ClientIssueMonitorEvents>(event: U, listener: (...args: ClientIssueMonitorEvents[U]) => void): this;
|
|
24
|
+
emit<U extends keyof ClientIssueMonitorEvents>(event: U, ...args: ClientIssueMonitorEvents[U]): boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare class ClientIssueMonitor extends EventEmitter {
|
|
27
|
+
readonly config: ClientIssueMonitorConfig;
|
|
28
|
+
private _closed;
|
|
29
|
+
constructor(config?: ClientIssueMonitorConfig);
|
|
30
|
+
addCall(call: ObservedCall): void;
|
|
31
|
+
private _addClient;
|
|
32
|
+
get closed(): boolean;
|
|
33
|
+
close(): void;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=ClientIssueMonitor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientIssueMonitor.d.ts","sourceRoot":"","sources":["../../src/monitors/ClientIssueMonitor.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,MAAM,mCAAmC,GAAG,WAAW,GAAG;IAC/D,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AM,GAAE,wBAA6B;IAM/C,OAAO,CAAC,IAAI,EAAE,YAAY;IAajC,OAAO,CAAC,UAAU;IAyBlB,IAAW,MAAM,YAEhB;IAEM,KAAK;CAMZ"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientIssueMonitor = void 0;
|
|
4
|
+
const events_1 = require("events");
|
|
5
|
+
class ClientIssueMonitor extends events_1.EventEmitter {
|
|
6
|
+
constructor(config = {}) {
|
|
7
|
+
super();
|
|
8
|
+
this.config = config;
|
|
9
|
+
this._closed = false;
|
|
10
|
+
this.setMaxListeners(Infinity);
|
|
11
|
+
}
|
|
12
|
+
addCall(call) {
|
|
13
|
+
if (this.closed)
|
|
14
|
+
return;
|
|
15
|
+
const onNewClient = (client) => {
|
|
16
|
+
this._addClient(call, client);
|
|
17
|
+
};
|
|
18
|
+
call.once('close', () => {
|
|
19
|
+
call.off('newclient', onNewClient);
|
|
20
|
+
});
|
|
21
|
+
call.on('newclient', onNewClient);
|
|
22
|
+
}
|
|
23
|
+
_addClient(call, client) {
|
|
24
|
+
if (this.closed)
|
|
25
|
+
return;
|
|
26
|
+
const { callId } = call;
|
|
27
|
+
const { clientId } = client;
|
|
28
|
+
const onIssue = (issue) => {
|
|
29
|
+
const event = Object.assign(Object.assign({}, issue), { clientId,
|
|
30
|
+
callId });
|
|
31
|
+
this.emit(issue.severity, event);
|
|
32
|
+
this.emit('issue', event);
|
|
33
|
+
};
|
|
34
|
+
client.once('close', () => {
|
|
35
|
+
client.off('issue', onIssue);
|
|
36
|
+
});
|
|
37
|
+
client.on('issue', onIssue);
|
|
38
|
+
}
|
|
39
|
+
get closed() {
|
|
40
|
+
return this._closed;
|
|
41
|
+
}
|
|
42
|
+
close() {
|
|
43
|
+
if (this._closed)
|
|
44
|
+
return;
|
|
45
|
+
this._closed = true;
|
|
46
|
+
this.emit('close');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.ClientIssueMonitor = ClientIssueMonitor;
|
package/package.json
CHANGED
package/src/Observer.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { CallSummaryMonitor, CallSummaryMonitorConfig } from './monitors/CallSum
|
|
|
10
10
|
import { TurnUsageMonitor } from './monitors/TurnUsageMonitor';
|
|
11
11
|
import { ObservedClient } from './ObservedClient';
|
|
12
12
|
import { ObservedPeerConnection } from './ObservedPeerConnection';
|
|
13
|
+
import { ClientIssueMonitor } from './monitors/ClientIssueMonitor';
|
|
13
14
|
|
|
14
15
|
const logger = createLogger('Observer');
|
|
15
16
|
|
|
@@ -252,6 +253,32 @@ export class Observer extends EventEmitter {
|
|
|
252
253
|
return monitor;
|
|
253
254
|
}
|
|
254
255
|
|
|
256
|
+
public createClientIssueMonitor() {
|
|
257
|
+
if (this._closed) throw new Error('Cannot create a turn usage monitor on a closed observer');
|
|
258
|
+
|
|
259
|
+
const existingMonitor = this._monitors.get(ClientIssueMonitor.name);
|
|
260
|
+
|
|
261
|
+
if (existingMonitor) return existingMonitor as ClientIssueMonitor;
|
|
262
|
+
|
|
263
|
+
const monitor = new ClientIssueMonitor();
|
|
264
|
+
|
|
265
|
+
const onNewCall = (call: ObservedCall) => monitor.addCall(call);
|
|
266
|
+
|
|
267
|
+
monitor.once('close', () => {
|
|
268
|
+
this._monitors.delete(CallSummaryMonitor.name);
|
|
269
|
+
this.off('newcall', onNewCall);
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
this._monitors.set(CallSummaryMonitor.name, monitor);
|
|
273
|
+
this.on('newcall', onNewCall);
|
|
274
|
+
|
|
275
|
+
this.once('close', () => {
|
|
276
|
+
monitor.close();
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
return monitor;
|
|
280
|
+
}
|
|
281
|
+
|
|
255
282
|
public get observedCalls(): ReadonlyMap<string, ObservedCall> {
|
|
256
283
|
return this._observedCalls;
|
|
257
284
|
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
import { ObservedCall } from '../ObservedCall';
|
|
3
|
+
import { ObservedClient } from '../ObservedClient';
|
|
4
|
+
import { ClientIssue } from './CallSummary';
|
|
5
|
+
|
|
6
|
+
export type ClientIssueMonitorEmittedIssueEvent = ClientIssue & {
|
|
7
|
+
clientId: string,
|
|
8
|
+
callId: string,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type ClientIssueMonitorEvents = {
|
|
12
|
+
close: [],
|
|
13
|
+
issue: [ClientIssueMonitorEmittedIssueEvent],
|
|
14
|
+
major: [ClientIssueMonitorEmittedIssueEvent],
|
|
15
|
+
minor: [ClientIssueMonitorEmittedIssueEvent],
|
|
16
|
+
critical: [ClientIssueMonitorEmittedIssueEvent],
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type ClientIssueMonitorConfig = {
|
|
21
|
+
detectUserMediaClientIssues?: boolean;
|
|
22
|
+
detectMediaTrackQualityLimitationClientIssues?: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export declare interface ClientIssueMonitor {
|
|
26
|
+
on<U extends keyof ClientIssueMonitorEvents>(event: U, listener: (...args: ClientIssueMonitorEvents[U]) => void): this;
|
|
27
|
+
off<U extends keyof ClientIssueMonitorEvents>(event: U, listener: (...args: ClientIssueMonitorEvents[U]) => void): this;
|
|
28
|
+
once<U extends keyof ClientIssueMonitorEvents>(event: U, listener: (...args: ClientIssueMonitorEvents[U]) => void): this;
|
|
29
|
+
emit<U extends keyof ClientIssueMonitorEvents>(event: U, ...args: ClientIssueMonitorEvents[U]): boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export class ClientIssueMonitor extends EventEmitter {
|
|
33
|
+
private _closed = false;
|
|
34
|
+
public constructor(
|
|
35
|
+
public readonly config: ClientIssueMonitorConfig = {},
|
|
36
|
+
) {
|
|
37
|
+
super();
|
|
38
|
+
this.setMaxListeners(Infinity);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public addCall(call: ObservedCall) {
|
|
42
|
+
if (this.closed) return;
|
|
43
|
+
|
|
44
|
+
const onNewClient = (client: ObservedClient) => {
|
|
45
|
+
this._addClient(call, client);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
call.once('close', () => {
|
|
49
|
+
call.off('newclient', onNewClient);
|
|
50
|
+
});
|
|
51
|
+
call.on('newclient', onNewClient);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private _addClient(call: ObservedCall, client: ObservedClient) {
|
|
55
|
+
if (this.closed) return;
|
|
56
|
+
const {
|
|
57
|
+
callId
|
|
58
|
+
} = call;
|
|
59
|
+
const {
|
|
60
|
+
clientId
|
|
61
|
+
} = client;
|
|
62
|
+
const onIssue = (issue: ClientIssue) => {
|
|
63
|
+
const event: ClientIssueMonitorEmittedIssueEvent = {
|
|
64
|
+
...issue,
|
|
65
|
+
clientId,
|
|
66
|
+
callId,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
this.emit(issue.severity, event);
|
|
70
|
+
this.emit('issue', event);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
client.once('close', () => {
|
|
74
|
+
client.off('issue', onIssue);
|
|
75
|
+
});
|
|
76
|
+
client.on('issue', onIssue);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public get closed() {
|
|
80
|
+
return this._closed;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
public close() {
|
|
84
|
+
if (this._closed) return;
|
|
85
|
+
this._closed = true;
|
|
86
|
+
|
|
87
|
+
this.emit('close');
|
|
88
|
+
}
|
|
89
|
+
}
|