Coder Social home page Coder Social logo

twilio / twilio-video-room-monitor.js Goto Github PK

View Code? Open in Web Editor NEW
24.0 4.0 17.0 2.78 MB

A browser-based tool that displays information and metrics about Twilio Video JavaScript applications

License: Apache License 2.0

JavaScript 0.23% TypeScript 99.77%
twilio video devtool webrtc

twilio-video-room-monitor.js's Introduction

Twilio Video Room Monitor

CircleCI

Warning

We are no longer allowing new customers to onboard to Twilio Video. Effective December 5th, 2024, Twilio Video will End of Life (EOL) and will cease to function for all customers. Customers may transition to any video provider they choose, however, we are recommending customers migrate to the Zoom Video SDK and we have prepared a Migration Guide. Additional information on this EOL is available in our Help Center here.

What is it

A browser-based tool that provides Twilio Video JavaScript developers visibility into the inner workings of their video application. It displays near real-time information and metrics from the Room object and can be added to any Twilio Video JavaScript application with a few lines of code.

Room Monitor gif

The Twilio Video Room Monitor can be used as a tool during all phases of development or can be forked, customized, and provided to end-users as an in-call troubleshooting view.

To learn more, visit the Video Room Monitor Documentation.

Changelog

View Changelog.md for details about our releases.

Browser Support

Chrome Edge (Chromium) Firefox Safari
Android - -
iOS - -
Linux - -
macOS
Windows -

Getting Started

NPM

You can install directly from npm.

npm install @twilio/video-room-monitor --save

Using this method, you can import @twilio/video-room-monitor and open the monitor like so:

import Video from 'twilio-video';
import { VideoRoomMonitor } from '@twilio/video-room-monitor';

Video.connect('token').then((room) => {
  VideoRoomMonitor.registerVideoRoom(room);
  VideoRoomMonitor.openMonitor();
});

Script Tag

You can also copy twilio-video-room-monitor.min.js from the dist/browser folder and include it directly in your web app using a <script> tag.

<script src="https://my-server-path/twilio-video-room-monitor.min.js"></script>

Using this method, you can register a room and open the room monitor like so:

window.Twilio.VideoRoomMonitor.registerVideoRoom(room);
window.Twilio.VideoRoomMonitor.openMonitor();

Console Script Quickstart (not for production use)

As a way to quickly use the Video Room Monitor in any Twilio Video JavaScript application, you can also run the following snippet in the browser console to open the Monitor:

(() => {
  const script = document.createElement('script');
  script.src = 'https://cdn.jsdelivr.net/npm/@twilio/video-room-monitor/dist/browser/twilio-video-room-monitor.min.js';
  script.onload = () => {
    // Register your Twilio Video Room here
    window.Twilio.VideoRoomMonitor.registerVideoRoom(twilioRoom);
    window.Twilio.VideoRoomMonitor.openMonitor();
  };
  document.body.appendChild(script);
})();

Note that the Room object must be exposed as a global variable (twilioRoom as seen in the above example) so that it can be registered with the Monitor.

Using this method, you can then close or toggle the monitor like so:

Twilio.VideoRoomMonitor.closeMonitor();
Twilio.VideoRoomMonitor.toggleMonitor();

NOTE: This method is not recommended for production use due to the CDN, as we don't have control of the availability of cdn.jsdelivr.net.

Usage

registerVideoRoom()

This is a required step to be able to use the Video Room Monitor. This registers a Twilio Video Room. To register a room, you can run the following line of code:

VideoRoomMonitor.registerVideoRoom(newRoom);

openMonitor()

This opens the monitor and emits the opened event. To open the monitor, you can run this line of code in the console:

VideoRoomMonitor.openMonitor();

To listen for the opened event, you can run the following line of code:

VideoRoomMonitor.on('opened', () => console.log('the monitor has been opened'));

closeMonitor()

This closes the monitor and emits the closed event. To close the monitor, you can run this line of code in the console:

VideoRoomMonitor.closeMonitor();

To listen for the closed event, you can run the following line of code:

VideoRoomMonitor.on('closed', () => console.log('the monitor has been closed'));

toggleMonitor()

This toggles the monitor to be either open or closed. If the monitor is currently closed, then it will open the monitor (and emit the opened event) and vice versa. To toggle the monitor, you can run this line of code in the console:

VideoRoomMonitor.toggleMonitor();

isOpen

This is a boolean value that indicates whether or not the monitor is currently open.

VideoRoomMonitor.isOpen;

Local Development

Prerequisites

You must have the following installed:

  • Node.js v14+
  • NPM v7+ (comes installed with newer Node versions)

Install dependencies

Fork and clone the repository, then install all dependencies with

npm install

Scripts

npm start

Compile the app (in watch mode) into a directory (dist/node) that will allow users to install the Monitor locally with NPM.

npm install -S <path_to_monitor>

NPM will install the Monitor as a symlink, so as files are edited, saved, and re-compiled, they will automatically be reflected in the application that has installed the Monitor locally.

Any TypeScript errors that are found will be displayed in the console.

npm run build

This will build both Node.js and browser versions of the Monitor in the dist/ directory.

npm run ts

Run this command to check the types in the app.

npm test

Runs all unit tests.

npm run lint

Runs the linter.

npm run parcel:watch

This will host the app on a local server. This server can then be used to run the tool in the browser by using a script tag:

<script src="http://localhost:1234/twilio-video-room-monitor.js></script>

Or by running this code snippet in the console of your browser:

(() => {
  const script = document.createElement('script');
  script.src = 'http://localhost:1234/twilio-video-room-monitor.js';
  script.onload = () => {
    // Register your Twilio Video Room here
    window.Twilio.VideoRoomMonitor.registerVideoRoom(twilioRoom);
    window.Twilio.VideoRoomMonitor.openMonitor();
  };
  document.body.appendChild(script);
})();

After this has finished running, you can run commands to open and close the monitor within the console.

License

See LICENSE.

twilio-video-room-monitor.js's People

Contributors

anna-vasilko avatar charliesantos avatar deepsourcebot avatar makarandp0 avatar mhuynh5757 avatar olipyskoty avatar pikajoyce avatar seancoleman2 avatar vwbai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

twilio-video-room-monitor.js's Issues

Monitor crashes on Stats tab using the `min.js` file.

I'm testing out the Video Room Monitor and using it by pulling the twilio-video-room-monitor.min.js file directly into my web app and loading it with a <script> tag. The monitor appears and I can see everything on the Info tab, but when I try to load the Stats tab, it crashes (the whole monitor disappears -- stack trace below).

Screen Shot 2021-09-30 at 8 02 36 AM

When I use the regular .js file instead of the min.js file, everything works and I can use the Stats tab.

I downloaded the room monitor files with npm install and am using the 1.0.0-beta.1 version.

React 17+ Support

Hi there :)

Unfortunately, there is no support for React v17+ for the @twilio/video-room-monitor package.
It would be really appreciated if you updated dependencies and added support for the newer ReactJS versions.

How can we customize CSS without making changes in JS file?

Hi there,

I am using Twilio video JS SDK version 2.21.1. I have integrated Twilio video room monitor feature in my project. I want to change modal CSS when it will open. So how can I customize the CSS without making any changes in JS file?

Support for React 18

Hi Team,

Is there a timeline for when twilio video will support React 18?

Looking forward to hearing from you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.