Table of contents
Introduction
watchRTC requires you to integrate an SDK with your own running code. For that purpose, you will need to add the watchRTC Javascript SDK to your JS application
To start using the watchRTC JavaScript SDK library to collect WebRTC-related data from your web application, you need to perform a few basic tasks first. Then you can begin to log and analyze your data.
For integration with the SDK, you will first need to have a watchRTC API key. If you haven’t already done so, please make sure to create a watchRTC API key before you continue.
Install the SDK
Add the watchRTC JS SDK to your JS application using one of the following methods.
via NPM
yarn add @testrtc/watchrtc-sdk
via Yarn
yarn add @testrtc/watchrtc-sdk
via CDN
<script src="https://unpkg.com/@testrtc/watchrtc-sdk/lib/index.js"></script>
Initialize the SDK
Once installed, to initialize our SDK, add the following setup code in your application, prior to using WebRTC APIs. To do this, use one of the following initialization sequences:
Note: The watchRTC.init() needs to take place prior to including or loading any 3rd party SDKs that interact with WebRTC. Failing to do so may hinder our ability to collect data!
javascript (ES6+)
const watchRTC = require("@testrtc/watchrtc-sdk");
watchRTC.init();
Typescript
import watchRTC from "@testrtc/watchrtc-sdk";
watchRTC.init();
javascript (ES5+)
Using CDN.
<!DOCTYPE html>
<html lang="en">
<head>
<title>watchRT SDK</title>
</head>
<body>
<script src="https://unpkg.com/@testrtc/watchrtc-sdk/lib/index.js"></script>
<script>
watchRTC.init();
</script>
</body>
</html>
Once initialized, find where you create peer connections in your code and pass along the additional parameters necessary.
Usage
Open/Close connection to the server
By default, the watchRTC Javascript SDK will automatically establish a connection with the watchRTC server and close it after an idle period. At times, it might make sense for your application to manually open and close that connection explicitly. This is done by calling watchRTC.connect() and watchRTC.disconnect().
Read more about manually connecting/disconnecting to watchRTC servers.
watchRTC.connect();
watchRTC.disconnect();
Some things to remember:
- Once installed and initialized, you should decide on how to allocate rooms and peers
- There are more configuration settings available. These are documented on the watchRTC SDK installation page.
- If you don’t see any results, you can try to troubleshoot it yourself.