Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

CallStats.js 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  1. /* global callstats */
  2. import RTCBrowserType from '../RTC/RTCBrowserType';
  3. import GlobalOnErrorHandler from '../util/GlobalOnErrorHandler';
  4. const logger = require('jitsi-meet-logger').getLogger(__filename);
  5. /**
  6. * We define enumeration of wrtcFuncNames as we need them before
  7. * callstats is initialized to queue events.
  8. * @const
  9. * @see http://www.callstats.io/api/#enumeration-of-wrtcfuncnames
  10. */
  11. const wrtcFuncNames = {
  12. createOffer: 'createOffer',
  13. createAnswer: 'createAnswer',
  14. setLocalDescription: 'setLocalDescription',
  15. setRemoteDescription: 'setRemoteDescription',
  16. addIceCandidate: 'addIceCandidate',
  17. getUserMedia: 'getUserMedia',
  18. iceConnectionFailure: 'iceConnectionFailure',
  19. signalingError: 'signalingError',
  20. applicationLog: 'applicationLog'
  21. };
  22. /**
  23. * We define enumeration of fabricEvent as we need them before
  24. * callstats is initialized to queue events.
  25. * @const
  26. * @see http://www.callstats.io/api/#enumeration-of-fabricevent
  27. */
  28. const fabricEvent = {
  29. fabricHold: 'fabricHold',
  30. fabricResume: 'fabricResume',
  31. audioMute: 'audioMute',
  32. audioUnmute: 'audioUnmute',
  33. videoPause: 'videoPause',
  34. videoResume: 'videoResume',
  35. fabricUsageEvent: 'fabricUsageEvent',
  36. fabricStats: 'fabricStats',
  37. fabricTerminated: 'fabricTerminated',
  38. screenShareStart: 'screenShareStart',
  39. screenShareStop: 'screenShareStop',
  40. dominantSpeaker: 'dominantSpeaker',
  41. activeDeviceList: 'activeDeviceList'
  42. };
  43. /**
  44. * The user id to report to callstats as destination.
  45. * @type {string}
  46. */
  47. const DEFAULT_REMOTE_USER = 'jitsi';
  48. /**
  49. * Type of pending reports, can be event or an error.
  50. * @type {{ERROR: string, EVENT: string}}
  51. */
  52. const reportType = {
  53. ERROR: 'error',
  54. EVENT: 'event',
  55. MST_WITH_USERID: 'mstWithUserID'
  56. };
  57. /**
  58. * Set of currently existing {@link CallStats} instances.
  59. * @type {Set<CallStats>}
  60. */
  61. let _fabrics;
  62. /**
  63. * An instance of this class is a wrapper for the CallStats API fabric. A fabric
  64. * reports one peer connection the the CallStats backend and is allocated with
  65. * {@link callstats.addNewFabric}. It has a bunch of instance methods for
  66. * reporting various events. A fabric is considered disposed when
  67. * {@link CallStats.sendTerminateEvent} is executed.
  68. *
  69. * Currently only one backend instance can be created ever and it's done using
  70. * {@link CallStats.initBackend}. At the time of this writing there is no way to
  71. * explicitly shutdown the backend, but it's supposed to close it's connection
  72. * automatically, after all fabrics have been terminated.
  73. */
  74. export default class CallStats {
  75. /**
  76. * A callback passed to {@link callstats.addNewFabric}.
  77. * @param {string} error 'success' means ok
  78. * @param {string} msg some more details
  79. * @private
  80. */
  81. static _addNewFabricCallback(error, msg) {
  82. if (CallStats.backend && error !== 'success') {
  83. logger.error(`Monitoring status: ${error} msg: ${msg}`);
  84. }
  85. }
  86. /**
  87. * Callback passed to {@link callstats.initialize} (backend initialization)
  88. * @param {string} error 'success' means ok
  89. * @param {String} msg
  90. * @private
  91. */
  92. static _initCallback(error, msg) {
  93. logger.log(`CallStats Status: err=${error} msg=${msg}`);
  94. // there is no lib, nothing to report to
  95. if (error !== 'success') {
  96. return;
  97. }
  98. // I hate that
  99. let atLeastOneFabric = false;
  100. let defaultInstance = null;
  101. for (const callStatsInstance of CallStats.fabrics.values()) {
  102. if (!callStatsInstance.hasFabric) {
  103. logger.debug('addNewFabric - initCallback');
  104. if (callStatsInstance._addNewFabric()) {
  105. atLeastOneFabric = true;
  106. if (!defaultInstance) {
  107. defaultInstance = callStatsInstance;
  108. }
  109. }
  110. }
  111. }
  112. if (!atLeastOneFabric) {
  113. return;
  114. }
  115. CallStats.initialized = true;
  116. // There is no conference ID nor a PeerConnection available when some of
  117. // the events are scheduled on the reportsQueue, so those will be
  118. // reported on the first initialized fabric.
  119. const defaultConfID = defaultInstance.confID;
  120. const defaultPC = defaultInstance.peerconnection;
  121. // notify callstats about failures if there were any
  122. for (const report of CallStats.reportsQueue) {
  123. if (report.type === reportType.ERROR) {
  124. const errorData = report.data;
  125. CallStats._reportError(
  126. defaultInstance,
  127. errorData.type,
  128. errorData.error,
  129. errorData.pc || defaultPC);
  130. } else if (report.type === reportType.EVENT) {
  131. // if we have and event to report and we failed to add
  132. // fabric this event will not be reported anyway, returning
  133. // an error
  134. const eventData = report.data;
  135. CallStats.backend.sendFabricEvent(
  136. report.pc || defaultPC,
  137. eventData.event,
  138. defaultConfID,
  139. eventData.eventData);
  140. } else if (report.type === reportType.MST_WITH_USERID) {
  141. const data = report.data;
  142. CallStats.backend.associateMstWithUserID(
  143. report.pc || defaultPC,
  144. data.callStatsId,
  145. defaultConfID,
  146. data.ssrc,
  147. data.usageLabel,
  148. data.containerId
  149. );
  150. }
  151. }
  152. CallStats.reportsQueue.length = 0;
  153. }
  154. /* eslint-disable max-params */
  155. /**
  156. * Reports an error to callstats.
  157. *
  158. * @param {CallStats} [cs]
  159. * @param type the type of the error, which will be one of the wrtcFuncNames
  160. * @param error the error
  161. * @param pc the peerconnection
  162. * @private
  163. */
  164. static _reportError(cs, type, error, pc) {
  165. let _error = error;
  166. if (!_error) {
  167. logger.warn('No error is passed!');
  168. _error = new Error('Unknown error');
  169. }
  170. if (CallStats.initialized && cs) {
  171. CallStats.backend.reportError(pc, cs.confID, type, _error);
  172. } else {
  173. CallStats.reportsQueue.push({
  174. type: reportType.ERROR,
  175. data: {
  176. error: _error,
  177. pc,
  178. type
  179. }
  180. });
  181. }
  182. // else just ignore it
  183. }
  184. /* eslint-enable max-params */
  185. /**
  186. * Reports an error to callstats.
  187. *
  188. * @param {CallStats} cs
  189. * @param event the type of the event, which will be one of the fabricEvent
  190. * @param eventData additional data to pass to event
  191. * @private
  192. */
  193. static _reportEvent(cs, event, eventData) {
  194. const pc = cs && cs.peerconnection;
  195. const confID = cs && cs.confID;
  196. if (CallStats.initialized && cs) {
  197. CallStats.backend.sendFabricEvent(pc, event, confID, eventData);
  198. } else {
  199. CallStats.reportsQueue.push({
  200. confID,
  201. pc,
  202. type: reportType.EVENT,
  203. data: { event,
  204. eventData }
  205. });
  206. }
  207. }
  208. /**
  209. * Wraps some of the CallStats API method and logs their calls with
  210. * arguments on the debug logging level. Also wraps some of the backend
  211. * methods execution into try catch blocks to not crash the app in case
  212. * there is a problem with the backend itself.
  213. * @param {callstats} theBackend
  214. * @private
  215. */
  216. static _traceAndCatchBackendCalls(theBackend) {
  217. const tryCatchMethods = [
  218. 'associateMstWithUserID',
  219. 'sendFabricEvent',
  220. 'sendUserFeedback'
  221. // 'reportError', - this one needs special handling - see code below
  222. ];
  223. for (const methodName of tryCatchMethods) {
  224. const originalMethod = theBackend[methodName];
  225. theBackend[methodName] = function(...theArguments) {
  226. try {
  227. return originalMethod.apply(theBackend, theArguments);
  228. } catch (e) {
  229. GlobalOnErrorHandler.callErrorHandler(e);
  230. }
  231. };
  232. }
  233. const debugMethods = [
  234. 'associateMstWithUserID',
  235. 'sendFabricEvent',
  236. 'sendUserFeedback'
  237. // 'reportError', - this one needs special handling - see code below
  238. ];
  239. for (const methodName of debugMethods) {
  240. const originalMethod = theBackend[methodName];
  241. theBackend[methodName] = function(...theArguments) {
  242. logger.debug(methodName, theArguments);
  243. originalMethod.apply(theBackend, theArguments);
  244. };
  245. }
  246. const originalReportError = theBackend.reportError;
  247. /* eslint-disable max-params */
  248. theBackend.reportError = function(pc, cs, type, ...args) {
  249. // Logs from the logger are submitted on the applicationLog event
  250. // "type". Logging the arguments on the logger will create endless
  251. // loop, because it will put all the logs to the logger queue again.
  252. if (type === wrtcFuncNames.applicationLog) {
  253. // NOTE otherArguments are not logged to the console on purpose
  254. // to not log the whole log batch
  255. // FIXME check the current logging level (currently not exposed
  256. // by the logger implementation)
  257. // NOTE it is not safe to log whole objects on react-native as
  258. // those contain too many circular references and may crash
  259. // the app.
  260. if (!RTCBrowserType.isReactNative()) {
  261. console && console.debug('reportError', pc, cs, type);
  262. }
  263. } else {
  264. logger.debug('reportError', pc, cs, type, ...args);
  265. }
  266. try {
  267. originalReportError.call(theBackend, pc, cs, type, ...args);
  268. } catch (exception) {
  269. if (type === wrtcFuncNames.applicationLog) {
  270. console && console.error('reportError', exception);
  271. } else {
  272. GlobalOnErrorHandler.callErrorHandler(exception);
  273. }
  274. }
  275. };
  276. /* eslint-enable max-params */
  277. }
  278. /**
  279. * Returns the Set with the currently existing {@link CallStats} instances.
  280. * Lazily initializes the Set to allow any Set polyfills to be applied.
  281. * @type {Set<CallStats>}
  282. */
  283. static get fabrics() {
  284. if (!_fabrics) {
  285. _fabrics = new Set();
  286. }
  287. return _fabrics;
  288. }
  289. /**
  290. * Initializes the CallStats backend. Should be called only if
  291. * {@link CallStats.isBackendInitialized} returns <tt>false</tt>.
  292. * @param {object} options
  293. * @param {String} options.callStatsID CallStats credentials - ID
  294. * @param {String} options.callStatsSecret CallStats credentials - secret
  295. * @param {string} options.aliasName the <tt>aliasName</tt> part of
  296. * the <tt>userID</tt> aka endpoint ID, see CallStats docs for more info.
  297. * @param {string} options.userName the <tt>userName</tt> part of
  298. * the <tt>userID</tt> aka display name, see CallStats docs for more info.
  299. *
  300. */
  301. static initBackend(options) {
  302. if (CallStats.backend) {
  303. throw new Error('CallStats backend has been initialized already!');
  304. }
  305. try {
  306. // In react-native we need to import the callstats module, but
  307. // imports are only allowed at top-level, so we must use require
  308. // here. Sigh.
  309. const CallStatsBackend
  310. = RTCBrowserType.isReactNative()
  311. ? require('react-native-callstats/callstats')
  312. : callstats;
  313. CallStats.backend = new CallStatsBackend();
  314. CallStats._traceAndCatchBackendCalls(CallStats.backend);
  315. CallStats.userID = {
  316. aliasName: options.aliasName,
  317. userName: options.userName
  318. };
  319. CallStats.callStatsID = options.callStatsID;
  320. CallStats.callStatsSecret = options.callStatsSecret;
  321. let configParams;
  322. if (options.applicationName) {
  323. configParams = {
  324. applicationVersion:
  325. `${options.applicationName} (${
  326. RTCBrowserType.getBrowserName()})`
  327. };
  328. }
  329. // userID is generated or given by the origin server
  330. CallStats.backend.initialize(
  331. CallStats.callStatsID,
  332. CallStats.callStatsSecret,
  333. CallStats.userID,
  334. CallStats._initCallback,
  335. undefined,
  336. configParams);
  337. return true;
  338. } catch (e) {
  339. // The callstats.io API failed to initialize (e.g. because its
  340. // download did not succeed in general or on time). Further attempts
  341. // to utilize it cannot possibly succeed.
  342. GlobalOnErrorHandler.callErrorHandler(e);
  343. CallStats.backend = null;
  344. logger.error(e);
  345. return false;
  346. }
  347. }
  348. /**
  349. * Checks if the CallStats backend has been created. It does not mean that
  350. * it has been initialized, but only that the API instance has been
  351. * allocated successfully.
  352. * @return {boolean} <tt>true</tt> if backend exists or <tt>false</tt>
  353. * otherwise
  354. */
  355. static isBackendInitialized() {
  356. return Boolean(CallStats.backend);
  357. }
  358. /**
  359. * Notifies CallStats about active device.
  360. * @param {{deviceList: {String:String}}} devicesData list of devices with
  361. * their data
  362. * @param {CallStats} cs callstats instance related to the event
  363. */
  364. static sendActiveDeviceListEvent(devicesData, cs) {
  365. CallStats._reportEvent(cs, fabricEvent.activeDeviceList, devicesData);
  366. }
  367. /**
  368. * Notifies CallStats that there is a log we want to report.
  369. *
  370. * @param {Error} e error to send or {String} message
  371. * @param {CallStats} cs callstats instance related to the error (optional)
  372. */
  373. static sendApplicationLog(e, cs) {
  374. try {
  375. CallStats._reportError(
  376. cs,
  377. wrtcFuncNames.applicationLog,
  378. e,
  379. cs && cs.peerconnection);
  380. } catch (error) {
  381. // If sendApplicationLog fails it should not be printed to
  382. // the logger, because it will try to push the logs again
  383. // (through sendApplicationLog) and an endless loop is created.
  384. if (console && (typeof console.error === 'function')) {
  385. // FIXME send analytics event as well
  386. console.error('sendApplicationLog failed', error);
  387. }
  388. }
  389. }
  390. /**
  391. * Sends the given feedback through CallStats.
  392. *
  393. * @param {string} conferenceID the conference ID for which the feedback
  394. * will be reported.
  395. * @param overallFeedback an integer between 1 and 5 indicating the
  396. * user feedback
  397. * @param detailedFeedback detailed feedback from the user. Not yet used
  398. */
  399. static sendFeedback(conferenceID, overallFeedback, detailedFeedback) {
  400. if (CallStats.backend) {
  401. CallStats.backend.sendUserFeedback(
  402. conferenceID, {
  403. userID: CallStats.userID,
  404. overall: overallFeedback,
  405. comment: detailedFeedback
  406. });
  407. } else {
  408. logger.error('Failed to submit feedback to CallStats - no backend');
  409. }
  410. }
  411. /**
  412. * Notifies CallStats that getUserMedia failed.
  413. *
  414. * @param {Error} e error to send
  415. * @param {CallStats} cs callstats instance related to the error (optional)
  416. */
  417. static sendGetUserMediaFailed(e, cs) {
  418. CallStats._reportError(cs, wrtcFuncNames.getUserMedia, e, null);
  419. }
  420. /**
  421. * Notifies CallStats for mute events
  422. * @param mute {boolean} true for muted and false for not muted
  423. * @param type {String} "audio"/"video"
  424. * @param {CallStats} cs callstats instance related to the event
  425. */
  426. static sendMuteEvent(mute, type, cs) {
  427. let event;
  428. if (type === 'video') {
  429. event = mute ? fabricEvent.videoPause : fabricEvent.videoResume;
  430. } else {
  431. event = mute ? fabricEvent.audioMute : fabricEvent.audioUnmute;
  432. }
  433. CallStats._reportEvent(cs, event);
  434. }
  435. /**
  436. * Creates new CallStats instance that handles all callstats API calls for
  437. * given {@link TraceablePeerConnection}. Each instance is meant to handle
  438. * one CallStats fabric added with 'addFabric' API method for the
  439. * {@link TraceablePeerConnection} instance passed in the constructor.
  440. * @param {TraceablePeerConnection} tpc
  441. * @param {Object} options
  442. * @param {string} options.confID the conference ID that wil be used to
  443. * report the session.
  444. * @param {string} [options.remoteUserID='jitsi'] the remote user ID to
  445. * which given <tt>tpc</tt> is connected.
  446. */
  447. constructor(tpc, options) {
  448. this.confID = options.confID;
  449. this.tpc = tpc;
  450. this.peerconnection = tpc.peerconnection;
  451. this.remoteUserID = options.remoteUserID || DEFAULT_REMOTE_USER;
  452. this.hasFabric = false;
  453. CallStats.fabrics.add(this);
  454. if (CallStats.initialized) {
  455. this._addNewFabric();
  456. }
  457. }
  458. /**
  459. * Initializes CallStats fabric by calling "addNewFabric" for
  460. * the peer connection associated with this instance.
  461. * @return {boolean} true if the call was successful or false otherwise.
  462. */
  463. _addNewFabric() {
  464. logger.info('addNewFabric', this.remoteUserID);
  465. try {
  466. const fabricAttributes = {
  467. remoteEndpointType:
  468. this.tpc.isP2P
  469. ? CallStats.backend.endpointType.peer
  470. : CallStats.backend.endpointType.server
  471. };
  472. const ret
  473. = CallStats.backend.addNewFabric(
  474. this.peerconnection,
  475. this.remoteUserID,
  476. CallStats.backend.fabricUsage.multiplex,
  477. this.confID,
  478. fabricAttributes,
  479. CallStats._addNewFabricCallback);
  480. this.hasFabric = true;
  481. const success = ret.status === 'success';
  482. if (!success) {
  483. logger.error('callstats fabric not initilized', ret.message);
  484. }
  485. return success;
  486. } catch (error) {
  487. GlobalOnErrorHandler.callErrorHandler(error);
  488. return false;
  489. }
  490. }
  491. /* eslint-disable max-params */
  492. /**
  493. * Lets CallStats module know where is given SSRC rendered by providing
  494. * renderer tag ID.
  495. * If the lib is not initialized yet queue the call for later, when it's
  496. * ready.
  497. * @param {number} ssrc the SSRC of the stream
  498. * @param {boolean} isLocal indicates whether this the stream is local
  499. * @param {string|null} streamEndpointId if the stream is not local the it
  500. * needs to contain the stream owner's ID
  501. * @param {string} usageLabel meaningful usage label of this stream like
  502. * 'microphone', 'camera' or 'screen'.
  503. * @param {string} containerId the id of media 'audio' or 'video' tag which
  504. * renders the stream.
  505. */
  506. associateStreamWithVideoTag(
  507. ssrc,
  508. isLocal,
  509. streamEndpointId,
  510. usageLabel,
  511. containerId) {
  512. if (!CallStats.backend) {
  513. return;
  514. }
  515. const callStatsId = isLocal ? CallStats.userID : streamEndpointId;
  516. if (CallStats.initialized) {
  517. CallStats.backend.associateMstWithUserID(
  518. this.peerconnection,
  519. callStatsId,
  520. this.confID,
  521. ssrc,
  522. usageLabel,
  523. containerId);
  524. } else {
  525. CallStats.reportsQueue.push({
  526. type: reportType.MST_WITH_USERID,
  527. pc: this.peerconnection,
  528. data: {
  529. callStatsId,
  530. containerId,
  531. ssrc,
  532. usageLabel
  533. }
  534. });
  535. }
  536. }
  537. /* eslint-enable max-params */
  538. /**
  539. * Notifies CallStats that we are the new dominant speaker in the
  540. * conference.
  541. */
  542. sendDominantSpeakerEvent() {
  543. CallStats._reportEvent(this, fabricEvent.dominantSpeaker);
  544. }
  545. /**
  546. * Notifies CallStats that the fabric for the underlying peerconnection was
  547. * closed and no evens should be reported, after this call.
  548. */
  549. sendTerminateEvent() {
  550. if (CallStats.initialized) {
  551. CallStats.backend.sendFabricEvent(
  552. this.peerconnection,
  553. CallStats.backend.fabricEvent.fabricTerminated,
  554. this.confID);
  555. }
  556. CallStats.fabrics.delete(this);
  557. }
  558. /**
  559. * Notifies CallStats for ice connection failed
  560. */
  561. sendIceConnectionFailedEvent() {
  562. CallStats._reportError(
  563. this,
  564. wrtcFuncNames.iceConnectionFailure,
  565. null,
  566. this.peerconnection);
  567. }
  568. /**
  569. * Notifies CallStats that peer connection failed to create offer.
  570. *
  571. * @param {Error} e error to send
  572. */
  573. sendCreateOfferFailed(e) {
  574. CallStats._reportError(
  575. this, wrtcFuncNames.createOffer, e, this.peerconnection);
  576. }
  577. /**
  578. * Notifies CallStats that peer connection failed to create answer.
  579. *
  580. * @param {Error} e error to send
  581. */
  582. sendCreateAnswerFailed(e) {
  583. CallStats._reportError(
  584. this, wrtcFuncNames.createAnswer, e, this.peerconnection);
  585. }
  586. /**
  587. * Sends either resume or hold event for the fabric associated with
  588. * the underlying peerconnection.
  589. * @param {boolean} isResume true to resume or false to hold
  590. */
  591. sendResumeOrHoldEvent(isResume) {
  592. CallStats._reportEvent(
  593. this,
  594. isResume ? fabricEvent.fabricResume : fabricEvent.fabricHold);
  595. }
  596. /**
  597. * Notifies CallStats for screen sharing events
  598. * @param {boolean} start true for starting screen sharing and
  599. * false for not stopping
  600. */
  601. sendScreenSharingEvent(start) {
  602. CallStats._reportEvent(
  603. this,
  604. start ? fabricEvent.screenShareStart : fabricEvent.screenShareStop);
  605. }
  606. /**
  607. * Notifies CallStats that peer connection failed to set local description.
  608. *
  609. * @param {Error} e error to send
  610. */
  611. sendSetLocalDescFailed(e) {
  612. CallStats._reportError(
  613. this, wrtcFuncNames.setLocalDescription, e, this.peerconnection);
  614. }
  615. /**
  616. * Notifies CallStats that peer connection failed to set remote description.
  617. *
  618. * @param {Error} e error to send
  619. */
  620. sendSetRemoteDescFailed(e) {
  621. CallStats._reportError(
  622. this, wrtcFuncNames.setRemoteDescription, e, this.peerconnection);
  623. }
  624. /**
  625. * Notifies CallStats that peer connection failed to add ICE candidate.
  626. *
  627. * @param {Error} e error to send
  628. */
  629. sendAddIceCandidateFailed(e) {
  630. CallStats._reportError(
  631. this, wrtcFuncNames.addIceCandidate, e, this.peerconnection);
  632. }
  633. }
  634. /**
  635. * The CallStats API backend instance
  636. * @type {callstats}
  637. */
  638. CallStats.backend = null;
  639. // some errors/events may happen before CallStats init
  640. // in this case we accumulate them in this array
  641. // and send them to callstats on init
  642. CallStats.reportsQueue = [];
  643. /**
  644. * Whether the library was successfully initialized using its initialize method.
  645. * And whether we had successfully called addNewFabric at least once.
  646. * @type {boolean}
  647. */
  648. CallStats.initialized = false;
  649. /**
  650. * Part of the CallStats credentials - application ID
  651. * @type {string}
  652. */
  653. CallStats.callStatsID = null;
  654. /**
  655. * Part of the CallStats credentials - application secret
  656. * @type {string}
  657. */
  658. CallStats.callStatsSecret = null;
  659. /**
  660. * Local CallStats user ID structure. Can be set only once when
  661. * {@link backend} is initialized, so it's static for the time being.
  662. * See CallStats API for more info:
  663. * https://www.callstats.io/api/#userid
  664. * @type {object}
  665. */
  666. CallStats.userID = null;