ObserveRTC / client-monitor-js

Javascript library to monitor browser-side webrtc app
https://observertc.org/docs/api/client-monitor-js-v2/
Apache License 2.0
31 stars 3 forks source link

Integrations->Mediasoup: outdated documentation #26

Closed GrishinAV closed 7 months ago

GrishinAV commented 7 months ago

Dear Developer, in Integrations->Mediasoup i see outdated documentation. Property 'collectFromMediasoupDevice' does not exist. How i can use ClientMonitor with Mediasoup?

balazskreith commented 7 months ago

Hi You were right, thanks for the notice. Somewhere between 3.0.y to 3.x the method is renamed from collectFromMediasoupDevice, to addMediaSoupDevice.

import { createClientMonitor } from "@observertc/client-monitor-js";
import mediasoup from "mediaousp-client";

const mediasoupDevice = new mediasoup.Device();
const config = {
    collectingPeriodInMs: 5000,
};
const monitor = createClientMonitor(config);
const collector = monitor.collectors.addMediasoupDevice(mediasoupDevice);

collector.onclose = () => {
    console.log(`mediasoup collector ${collector.id} is closed`);
}

monitor.on("stats-collected", () => {
    // do your stuff

    // you can close detach mediasoup
    // collector by calling the close
    collector.close();
});

I updated when the 3.5.0 is released, please note some of the metrics written down in README only available by updating your monitor to 3.5.0.

(hopefully) fixed: f1698d666f179bdc986384d695a6b67d58308009