Skip to content

Commit

Permalink
Develop version 3.0.0 (#16)
Browse files Browse the repository at this point in the history
 * 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
  • Loading branch information
balazskreith authored Jul 31, 2023
1 parent 95fb3ba commit 7da32a3
Show file tree
Hide file tree
Showing 72 changed files with 6,510 additions and 9,673 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
## 2.3.0
* 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




## 2.1.0
* Remove dependency @observertc/samples-schema
* Add Samples and W3cStats to the source under the `./src/schema` library
Expand Down
269 changes: 79 additions & 190 deletions README.md

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@observertc/client-monitor-js",
"version": "2.2.3",
"version": "3.0.0",
"description": "ObserveRTC Client Integration Javascript Library",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -32,17 +32,17 @@
"uuid": "^8.3.2"
},
"devDependencies": {
"@types/jest": "^27.5.2",
"@jest/globals": "^29.6.2",
"@types/jest": "^29.5.3",
"@typescript-eslint/eslint-plugin": "^5.38.0",
"@typescript-eslint/parser": "^5.38.0",
"bufferutil": "^4.0.6",
"eslint": "^8.24.0",
"jest": "^27.5.0",
"ts-jest": "^27.1.5",
"typedoc": "^0.22.18",
"jest": "^29.6.2",
"pkgfiles": "^2.3.2",
"ts-jest": "^29.1.1",
"typescript": "^4.8.3",
"utf-8-validate": "^5.0.8",
"pkgfiles": "2.3.0"
"utf-8-validate": "^5.0.8"
},
"repository": {
"type": "git",
Expand Down
99 changes: 0 additions & 99 deletions src/Accumulator.ts

This file was deleted.

118 changes: 0 additions & 118 deletions src/ClientDevices.ts

This file was deleted.

115 changes: 115 additions & 0 deletions src/ClientMetaData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import * as Bowser from "bowser";
import { createLogger } from "./utils/logger";

import { OperationSystem, Browser, Platform, Engine, MediaDevice } from './schema/Samples';
import { IndexedMap } from "./utils/IndexedMap";
import { Sampler } from "./Sampler";

// import * as proto from "./ProtobufSamples"
const logger = createLogger("ClientDevices");

const UNKNOWN_OS: OperationSystem = {
name: "Unkown",
version: undefined,
versionName: undefined,
};

const UNKNOWN_BROWSER: Browser = {
name: "Unknown",
version: undefined,
};

const UNKNOWN_PLATFORM: Platform = {
type: "Unknown",
vendor: undefined,
model: undefined,
};

const UNKNOWN_ENGINE: Engine = {
name: "Unknown",
version: undefined,
};

const MEDIA_DEVICE_KIND = 'mediaDeviceKind';

export type StoredMediaDevice = MediaDevice & {
sampled: boolean,
}

export class ClientMetaData {
public readonly operationSystem: OperationSystem;
public readonly browser: Browser;
public readonly platform: Platform;
public readonly engine: Engine;
private readonly _mediaDevices: IndexedMap<string, StoredMediaDevice, MediaDeviceKind>;

public constructor(

) {
try {
/* eslint-disable @typescript-eslint/no-explicit-any */
let outerNavigator: any = undefined;
if (navigator !== undefined) outerNavigator = navigator;
else if (window !== undefined && window.navigator !== undefined) outerNavigator = window.navigator;
else throw new Error(`navigator is not available`);
const parsedResult = Bowser.parse(outerNavigator.userAgent);
this.browser = parsedResult.browser;
this.engine = parsedResult.engine;
this.operationSystem = parsedResult.os;
this.platform = parsedResult.platform;
} catch (err) {
logger.warn(`Cannot collect media devices and navigator data, because an error occurred`, err);
this.operationSystem = UNKNOWN_OS;
this.browser = UNKNOWN_BROWSER;
this.platform = UNKNOWN_PLATFORM;
this.engine = UNKNOWN_ENGINE;
}

this._mediaDevices = new IndexedMap<string, StoredMediaDevice, MediaDeviceKind>()
.addIndex(MEDIA_DEVICE_KIND, (device) => device.kind)
;

}

public set mediaDevices(values: MediaDevice[]) {
const visited = new Set<string>();
for (const mediaDevice of values) {
if (!mediaDevice.id) continue;
visited.add(mediaDevice.id);
if (this._mediaDevices.has(mediaDevice.id)) continue;
this._mediaDevices.set(mediaDevice.id, {
...mediaDevice,
sampled: false,
});
}
for (const [id] of this._mediaDevices.entries()) {
if (visited.has(id)) continue;
this._mediaDevices.delete(id);
}
}

public get mediaDevices(): MediaDevice[] {
return Array.from(this._mediaDevices.values());
}

/**
* Iterable iterator for the audio input devices obtained by the observer.
*/
public audioInputs(): IterableIterator<StoredMediaDevice> {
return this._mediaDevices.values(MEDIA_DEVICE_KIND, "audioinput");
}

/**
* Iterable iterator for the audio output devices obtained by the observer.
*/
public audioOutputs(): IterableIterator<StoredMediaDevice> {
return this._mediaDevices.values(MEDIA_DEVICE_KIND, "audiooutput");
}

/**
* Iterable iterator for the video input devices obtained by the observer.
*/
public videoInputs(): IterableIterator<StoredMediaDevice> {
return this._mediaDevices.values(MEDIA_DEVICE_KIND, "videoinput");
}
}
Loading

0 comments on commit 7da32a3

Please sign in to comment.