You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754
  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. if (!CallStats.backend) {
  449. throw new Error('CallStats backend not intiialized!');
  450. }
  451. this.confID = options.confID;
  452. this.tpc = tpc;
  453. this.peerconnection = tpc.peerconnection;
  454. this.remoteUserID = options.remoteUserID || DEFAULT_REMOTE_USER;
  455. this.hasFabric = false;
  456. CallStats.fabrics.add(this);
  457. if (CallStats.initialized) {
  458. this._addNewFabric();
  459. }
  460. }
  461. /**
  462. * Initializes CallStats fabric by calling "addNewFabric" for
  463. * the peer connection associated with this instance.
  464. * @return {boolean} true if the call was successful or false otherwise.
  465. */
  466. _addNewFabric() {
  467. logger.info('addNewFabric', this.remoteUserID);
  468. try {
  469. const fabricAttributes = {
  470. remoteEndpointType:
  471. this.tpc.isP2P
  472. ? CallStats.backend.endpointType.peer
  473. : CallStats.backend.endpointType.server
  474. };
  475. const ret
  476. = CallStats.backend.addNewFabric(
  477. this.peerconnection,
  478. this.remoteUserID,
  479. CallStats.backend.fabricUsage.multiplex,
  480. this.confID,
  481. fabricAttributes,
  482. CallStats._addNewFabricCallback);
  483. this.hasFabric = true;
  484. const success = ret.status === 'success';
  485. if (!success) {
  486. logger.error('callstats fabric not initilized', ret.message);
  487. }
  488. return success;
  489. } catch (error) {
  490. GlobalOnErrorHandler.callErrorHandler(error);
  491. return false;
  492. }
  493. }
  494. /* eslint-disable max-params */
  495. /**
  496. * Lets CallStats module know where is given SSRC rendered by providing
  497. * renderer tag ID.
  498. * If the lib is not initialized yet queue the call for later, when it's
  499. * ready.
  500. * @param {number} ssrc the SSRC of the stream
  501. * @param {boolean} isLocal indicates whether this the stream is local
  502. * @param {string|null} streamEndpointId if the stream is not local the it
  503. * needs to contain the stream owner's ID
  504. * @param {string} usageLabel meaningful usage label of this stream like
  505. * 'microphone', 'camera' or 'screen'.
  506. * @param {string} containerId the id of media 'audio' or 'video' tag which
  507. * renders the stream.
  508. */
  509. associateStreamWithVideoTag(
  510. ssrc,
  511. isLocal,
  512. streamEndpointId,
  513. usageLabel,
  514. containerId) {
  515. if (!CallStats.backend) {
  516. return;
  517. }
  518. const callStatsId = isLocal ? CallStats.userID : streamEndpointId;
  519. if (CallStats.initialized) {
  520. CallStats.backend.associateMstWithUserID(
  521. this.peerconnection,
  522. callStatsId,
  523. this.confID,
  524. ssrc,
  525. usageLabel,
  526. containerId);
  527. } else {
  528. CallStats.reportsQueue.push({
  529. type: reportType.MST_WITH_USERID,
  530. pc: this.peerconnection,
  531. data: {
  532. callStatsId,
  533. containerId,
  534. ssrc,
  535. usageLabel
  536. }
  537. });
  538. }
  539. }
  540. /* eslint-enable max-params */
  541. /**
  542. * Notifies CallStats that we are the new dominant speaker in the
  543. * conference.
  544. */
  545. sendDominantSpeakerEvent() {
  546. CallStats._reportEvent(this, fabricEvent.dominantSpeaker);
  547. }
  548. /**
  549. * Notifies CallStats that the fabric for the underlying peerconnection was
  550. * closed and no evens should be reported, after this call.
  551. */
  552. sendTerminateEvent() {
  553. if (CallStats.initialized) {
  554. CallStats.backend.sendFabricEvent(
  555. this.peerconnection,
  556. CallStats.backend.fabricEvent.fabricTerminated,
  557. this.confID);
  558. }
  559. CallStats.fabrics.delete(this);
  560. }
  561. /**
  562. * Notifies CallStats for ice connection failed
  563. */
  564. sendIceConnectionFailedEvent() {
  565. CallStats._reportError(
  566. this,
  567. wrtcFuncNames.iceConnectionFailure,
  568. null,
  569. this.peerconnection);
  570. }
  571. /**
  572. * Notifies CallStats that peer connection failed to create offer.
  573. *
  574. * @param {Error} e error to send
  575. */
  576. sendCreateOfferFailed(e) {
  577. CallStats._reportError(
  578. this, wrtcFuncNames.createOffer, e, this.peerconnection);
  579. }
  580. /**
  581. * Notifies CallStats that peer connection failed to create answer.
  582. *
  583. * @param {Error} e error to send
  584. */
  585. sendCreateAnswerFailed(e) {
  586. CallStats._reportError(
  587. this, wrtcFuncNames.createAnswer, e, this.peerconnection);
  588. }
  589. /**
  590. * Sends either resume or hold event for the fabric associated with
  591. * the underlying peerconnection.
  592. * @param {boolean} isResume true to resume or false to hold
  593. */
  594. sendResumeOrHoldEvent(isResume) {
  595. CallStats._reportEvent(
  596. this,
  597. isResume ? fabricEvent.fabricResume : fabricEvent.fabricHold);
  598. }
  599. /**
  600. * Notifies CallStats for screen sharing events
  601. * @param {boolean} start true for starting screen sharing and
  602. * false for not stopping
  603. */
  604. sendScreenSharingEvent(start) {
  605. CallStats._reportEvent(
  606. this,
  607. start ? fabricEvent.screenShareStart : fabricEvent.screenShareStop);
  608. }
  609. /**
  610. * Notifies CallStats that peer connection failed to set local description.
  611. *
  612. * @param {Error} e error to send
  613. */
  614. sendSetLocalDescFailed(e) {
  615. CallStats._reportError(
  616. this, wrtcFuncNames.setLocalDescription, e, this.peerconnection);
  617. }
  618. /**
  619. * Notifies CallStats that peer connection failed to set remote description.
  620. *
  621. * @param {Error} e error to send
  622. */
  623. sendSetRemoteDescFailed(e) {
  624. CallStats._reportError(
  625. this, wrtcFuncNames.setRemoteDescription, e, this.peerconnection);
  626. }
  627. /**
  628. * Notifies CallStats that peer connection failed to add ICE candidate.
  629. *
  630. * @param {Error} e error to send
  631. */
  632. sendAddIceCandidateFailed(e) {
  633. CallStats._reportError(
  634. this, wrtcFuncNames.addIceCandidate, e, this.peerconnection);
  635. }
  636. }
  637. /**
  638. * The CallStats API backend instance
  639. * @type {callstats}
  640. */
  641. CallStats.backend = null;
  642. // some errors/events may happen before CallStats init
  643. // in this case we accumulate them in this array
  644. // and send them to callstats on init
  645. CallStats.reportsQueue = [];
  646. /**
  647. * Whether the library was successfully initialized using its initialize method.
  648. * And whether we had successfully called addNewFabric at least once.
  649. * @type {boolean}
  650. */
  651. CallStats.initialized = false;
  652. /**
  653. * Part of the CallStats credentials - application ID
  654. * @type {string}
  655. */
  656. CallStats.callStatsID = null;
  657. /**
  658. * Part of the CallStats credentials - application secret
  659. * @type {string}
  660. */
  661. CallStats.callStatsSecret = null;
  662. /**
  663. * Local CallStats user ID structure. Can be set only once when
  664. * {@link backend} is initialized, so it's static for the time being.
  665. * See CallStats API for more info:
  666. * https://www.callstats.io/api/#userid
  667. * @type {object}
  668. */
  669. CallStats.userID = null;