There are two way you can integrate with Peer metric's SDK:
-
Usage with Webpack, Browserify, & Other Bundlers
To use with your existing build process just install and import the NPM package
npm install @peermetrics/sdk
And then import it
import {PeerMetrics} from '@peermetrics/sdk'
-
Usage in the browser
To use it directly in the browser, just add the snippet near the end of the body tag
<script src="//cdn.peermetrics.io/js/sdk/peermetrics.min.js"></script>
To initialize the the sdk, use:
let peerMetrics = new PeerMetrics({
apiKey: '672f73bbe6b94ebc87ad43f3e1af1079',
userId: '1',
userName: 'John Doe',
conferenceId: '1',
conferenceName: 'Conference name',
appVersion: '1.0.0',
})
await peerMetrics.initialize()
And, to start collecting metrics from your calls, use the addConnection() method:
peerMetrics.addConnection({
pc: peerConnection, // the RTCPeerConnection instance
peerId: '1' // the participant id of this specific peer
})
You can read the docs on how to use the sdk here.