Skip to content

Commit 7da32a3

Browse files
authored
Develop version 3.0.0 (#16)
* refactored collectors and sampler * `clientMontior.os` is moved to `clientMonitor.meta.operationSystem` * `clientMontior.engine` is moved to `clientMonitor.meta.engine` * `clientMontior.browser` is moved to `clientMonitor.meta.browser` * `clientMontior.audioInputs` is moved to `clientMonitor.meta.audioInputs` * `clientMontior.audioOutputs` is moved to `clientMonitor.meta.audioOutputs` * `clientMontior.videoInputs` is moved to `clientMonitor.meta.videoInputs` * `clientMonitor.alerts` is removed, `clientMonitor.audioDesyncDetector`, `clientMonitor.cpuPerformanceDetector`, and `clientMonitor.congestionDetector` * all `updates` fields in storage entries are moved to the entries of the `storage` * `metrics` field is removed `elapsedSinceLastCollectInMs` and `elapsedSinceLastSampleInMs` is added to the `stats-collected`, and `sample-created` events * refactored mediasoup-collector * add events are collected automatically * simplified configuration, and detectors configurations are moved to create detectors
1 parent 95fb3ba commit 7da32a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+6510
-9673
lines changed

CHANGELOG.md

+18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
## 2.3.0
2+
* refactored collectors and sampler
3+
* `clientMontior.os` is moved to `clientMonitor.meta.operationSystem`
4+
* `clientMontior.engine` is moved to `clientMonitor.meta.engine`
5+
* `clientMontior.browser` is moved to `clientMonitor.meta.browser`
6+
* `clientMontior.audioInputs` is moved to `clientMonitor.meta.audioInputs`
7+
* `clientMontior.audioOutputs` is moved to `clientMonitor.meta.audioOutputs`
8+
* `clientMontior.videoInputs` is moved to `clientMonitor.meta.videoInputs`
9+
* `clientMonitor.alerts` is removed, `clientMonitor.audioDesyncDetector`, `clientMonitor.cpuPerformanceDetector`, and `clientMonitor.congestionDetector`
10+
* all `updates` fields in storage entries are moved to the entries of the `storage`
11+
* `metrics` field is removed `elapsedSinceLastCollectInMs` and `elapsedSinceLastSampleInMs` is added to the `stats-collected`, and `sample-created` events
12+
* refactored mediasoup-collector
13+
* add events are collected automatically
14+
* simplified configuration, and detectors configurations are moved to create detectors
15+
16+
17+
18+
119
## 2.1.0
220
* Remove dependency @observertc/samples-schema
321
* Add Samples and W3cStats to the source under the `./src/schema` library

README.md

+79-190
Large diffs are not rendered by default.

package.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@observertc/client-monitor-js",
3-
"version": "2.2.3",
3+
"version": "3.0.0",
44
"description": "ObserveRTC Client Integration Javascript Library",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",
@@ -32,17 +32,17 @@
3232
"uuid": "^8.3.2"
3333
},
3434
"devDependencies": {
35-
"@types/jest": "^27.5.2",
35+
"@jest/globals": "^29.6.2",
36+
"@types/jest": "^29.5.3",
3637
"@typescript-eslint/eslint-plugin": "^5.38.0",
3738
"@typescript-eslint/parser": "^5.38.0",
3839
"bufferutil": "^4.0.6",
3940
"eslint": "^8.24.0",
40-
"jest": "^27.5.0",
41-
"ts-jest": "^27.1.5",
42-
"typedoc": "^0.22.18",
41+
"jest": "^29.6.2",
42+
"pkgfiles": "^2.3.2",
43+
"ts-jest": "^29.1.1",
4344
"typescript": "^4.8.3",
44-
"utf-8-validate": "^5.0.8",
45-
"pkgfiles": "2.3.0"
45+
"utf-8-validate": "^5.0.8"
4646
},
4747
"repository": {
4848
"type": "git",

src/Accumulator.ts

-99
This file was deleted.

src/ClientDevices.ts

-118
This file was deleted.

src/ClientMetaData.ts

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
import * as Bowser from "bowser";
2+
import { createLogger } from "./utils/logger";
3+
4+
import { OperationSystem, Browser, Platform, Engine, MediaDevice } from './schema/Samples';
5+
import { IndexedMap } from "./utils/IndexedMap";
6+
import { Sampler } from "./Sampler";
7+
8+
// import * as proto from "./ProtobufSamples"
9+
const logger = createLogger("ClientDevices");
10+
11+
const UNKNOWN_OS: OperationSystem = {
12+
name: "Unkown",
13+
version: undefined,
14+
versionName: undefined,
15+
};
16+
17+
const UNKNOWN_BROWSER: Browser = {
18+
name: "Unknown",
19+
version: undefined,
20+
};
21+
22+
const UNKNOWN_PLATFORM: Platform = {
23+
type: "Unknown",
24+
vendor: undefined,
25+
model: undefined,
26+
};
27+
28+
const UNKNOWN_ENGINE: Engine = {
29+
name: "Unknown",
30+
version: undefined,
31+
};
32+
33+
const MEDIA_DEVICE_KIND = 'mediaDeviceKind';
34+
35+
export type StoredMediaDevice = MediaDevice & {
36+
sampled: boolean,
37+
}
38+
39+
export class ClientMetaData {
40+
public readonly operationSystem: OperationSystem;
41+
public readonly browser: Browser;
42+
public readonly platform: Platform;
43+
public readonly engine: Engine;
44+
private readonly _mediaDevices: IndexedMap<string, StoredMediaDevice, MediaDeviceKind>;
45+
46+
public constructor(
47+
48+
) {
49+
try {
50+
/* eslint-disable @typescript-eslint/no-explicit-any */
51+
let outerNavigator: any = undefined;
52+
if (navigator !== undefined) outerNavigator = navigator;
53+
else if (window !== undefined && window.navigator !== undefined) outerNavigator = window.navigator;
54+
else throw new Error(`navigator is not available`);
55+
const parsedResult = Bowser.parse(outerNavigator.userAgent);
56+
this.browser = parsedResult.browser;
57+
this.engine = parsedResult.engine;
58+
this.operationSystem = parsedResult.os;
59+
this.platform = parsedResult.platform;
60+
} catch (err) {
61+
logger.warn(`Cannot collect media devices and navigator data, because an error occurred`, err);
62+
this.operationSystem = UNKNOWN_OS;
63+
this.browser = UNKNOWN_BROWSER;
64+
this.platform = UNKNOWN_PLATFORM;
65+
this.engine = UNKNOWN_ENGINE;
66+
}
67+
68+
this._mediaDevices = new IndexedMap<string, StoredMediaDevice, MediaDeviceKind>()
69+
.addIndex(MEDIA_DEVICE_KIND, (device) => device.kind)
70+
;
71+
72+
}
73+
74+
public set mediaDevices(values: MediaDevice[]) {
75+
const visited = new Set<string>();
76+
for (const mediaDevice of values) {
77+
if (!mediaDevice.id) continue;
78+
visited.add(mediaDevice.id);
79+
if (this._mediaDevices.has(mediaDevice.id)) continue;
80+
this._mediaDevices.set(mediaDevice.id, {
81+
...mediaDevice,
82+
sampled: false,
83+
});
84+
}
85+
for (const [id] of this._mediaDevices.entries()) {
86+
if (visited.has(id)) continue;
87+
this._mediaDevices.delete(id);
88+
}
89+
}
90+
91+
public get mediaDevices(): MediaDevice[] {
92+
return Array.from(this._mediaDevices.values());
93+
}
94+
95+
/**
96+
* Iterable iterator for the audio input devices obtained by the observer.
97+
*/
98+
public audioInputs(): IterableIterator<StoredMediaDevice> {
99+
return this._mediaDevices.values(MEDIA_DEVICE_KIND, "audioinput");
100+
}
101+
102+
/**
103+
* Iterable iterator for the audio output devices obtained by the observer.
104+
*/
105+
public audioOutputs(): IterableIterator<StoredMediaDevice> {
106+
return this._mediaDevices.values(MEDIA_DEVICE_KIND, "audiooutput");
107+
}
108+
109+
/**
110+
* Iterable iterator for the video input devices obtained by the observer.
111+
*/
112+
public videoInputs(): IterableIterator<StoredMediaDevice> {
113+
return this._mediaDevices.values(MEDIA_DEVICE_KIND, "videoinput");
114+
}
115+
}

0 commit comments

Comments
 (0)