@wazo/sdk 0.37.17 → 0.37.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/dist/wazo-sdk.js +3 -3
  2. package/esm/__tests__/api-client.test.js +52 -9
  3. package/esm/__tests__/web-rtc-client.test.js +96 -21
  4. package/esm/api/agentd.js +26 -3
  5. package/esm/api/amid.js +26 -3
  6. package/esm/api/application.js +26 -3
  7. package/esm/api/auth.js +26 -3
  8. package/esm/api/call-logd.js +28 -5
  9. package/esm/api/calld.js +26 -3
  10. package/esm/api/chatd.js +26 -3
  11. package/esm/api/confd.js +50 -7
  12. package/esm/api/ctid-ng.js +26 -3
  13. package/esm/api/dird.js +26 -3
  14. package/esm/api/webhookd.js +26 -3
  15. package/esm/api-client.js +52 -9
  16. package/esm/checker/Checker.js +98 -21
  17. package/esm/checker/checks/aor.js +52 -9
  18. package/esm/checker/checks/api.js +52 -9
  19. package/esm/checker/checks/index.js +98 -21
  20. package/esm/checker/checks/wazo-websocket.js +28 -3
  21. package/esm/checker/checks/webrtc-transport.js +96 -21
  22. package/esm/checker/checks/webrtc.js +96 -21
  23. package/esm/domain/AdHocAPIConference.js +52 -9
  24. package/esm/domain/CallLog.js +2 -2
  25. package/esm/domain/Features.js +52 -9
  26. package/esm/domain/Meeting.js +19 -2
  27. package/esm/domain/Phone/CTIPhone.js +52 -9
  28. package/esm/domain/Phone/WebRTCPhone.js +41 -5
  29. package/esm/domain/Recording.js +1 -1
  30. package/esm/domain/__tests__/CallLog.test.js +2 -2
  31. package/esm/index.js +119 -22
  32. package/esm/lib/WazoSessionDescriptionHandler.js +26 -3
  33. package/esm/service/CallApi.js +52 -9
  34. package/esm/service/IssueReporter.js +26 -3
  35. package/esm/service/__tests__/IssueReporter.test.js +26 -3
  36. package/esm/service/getApiClient.js +52 -9
  37. package/esm/simple/Auth.js +119 -22
  38. package/esm/simple/Configuration.js +119 -22
  39. package/esm/simple/Directory.js +52 -9
  40. package/esm/simple/Phone.js +119 -22
  41. package/esm/simple/Websocket.js +29 -3
  42. package/esm/simple/index.js +119 -22
  43. package/esm/simple/room/LocalParticipant.js +119 -22
  44. package/esm/simple/room/Participant.js +119 -22
  45. package/esm/simple/room/RemoteParticipant.js +119 -22
  46. package/esm/simple/room/Room.js +119 -22
  47. package/esm/simple/room/SipRoom.js +119 -22
  48. package/esm/simple/room/Stream.js +119 -22
  49. package/esm/simple/room/__tests__/RemoteParticipant.test.js +119 -22
  50. package/esm/simple/utils.js +119 -22
  51. package/esm/utils/__tests__/api-requester.test.js +26 -3
  52. package/esm/utils/api-requester.js +26 -3
  53. package/esm/web-rtc-client.js +96 -21
  54. package/esm/websocket-client.js +29 -4
  55. package/lib/__tests__/api-client.test.js +52 -9
  56. package/lib/__tests__/web-rtc-client.test.js +96 -21
  57. package/lib/api/agentd.js +26 -3
  58. package/lib/api/amid.js +26 -3
  59. package/lib/api/application.js +26 -3
  60. package/lib/api/auth.js +26 -3
  61. package/lib/api/call-logd.js +28 -5
  62. package/lib/api/calld.js +26 -3
  63. package/lib/api/chatd.js +26 -3
  64. package/lib/api/confd.js +50 -7
  65. package/lib/api/ctid-ng.js +26 -3
  66. package/lib/api/dird.js +26 -3
  67. package/lib/api/webhookd.js +26 -3
  68. package/lib/api-client.js +52 -9
  69. package/lib/checker/Checker.js +98 -21
  70. package/lib/checker/checks/aor.js +52 -9
  71. package/lib/checker/checks/api.js +52 -9
  72. package/lib/checker/checks/index.js +98 -21
  73. package/lib/checker/checks/wazo-websocket.js +28 -3
  74. package/lib/checker/checks/webrtc-transport.js +96 -21
  75. package/lib/checker/checks/webrtc.js +96 -21
  76. package/lib/domain/AdHocAPIConference.js +52 -9
  77. package/lib/domain/CallLog.js +2 -2
  78. package/lib/domain/Features.js +52 -9
  79. package/lib/domain/Meeting.js +19 -2
  80. package/lib/domain/Phone/CTIPhone.js +52 -9
  81. package/lib/domain/Phone/WebRTCPhone.js +41 -4
  82. package/lib/domain/Recording.js +1 -1
  83. package/lib/domain/__tests__/CallLog.test.js +2 -2
  84. package/lib/index.js +119 -22
  85. package/lib/lib/WazoSessionDescriptionHandler.js +26 -3
  86. package/lib/service/CallApi.js +52 -9
  87. package/lib/service/IssueReporter.js +26 -3
  88. package/lib/service/__tests__/IssueReporter.test.js +26 -3
  89. package/lib/service/getApiClient.js +52 -9
  90. package/lib/simple/Auth.js +119 -22
  91. package/lib/simple/Configuration.js +119 -22
  92. package/lib/simple/Directory.js +52 -9
  93. package/lib/simple/Phone.js +119 -22
  94. package/lib/simple/Websocket.js +29 -3
  95. package/lib/simple/index.js +119 -22
  96. package/lib/simple/room/LocalParticipant.js +119 -22
  97. package/lib/simple/room/Participant.js +119 -22
  98. package/lib/simple/room/RemoteParticipant.js +119 -22
  99. package/lib/simple/room/Room.js +119 -22
  100. package/lib/simple/room/SipRoom.js +119 -22
  101. package/lib/simple/room/Stream.js +119 -22
  102. package/lib/simple/room/__tests__/RemoteParticipant.test.js +119 -22
  103. package/lib/simple/utils.js +119 -22
  104. package/lib/utils/__tests__/api-requester.test.js +26 -3
  105. package/lib/utils/api-requester.js +26 -3
  106. package/lib/web-rtc-client.js +96 -21
  107. package/lib/websocket-client.js +29 -3
  108. package/package.json +2 -2
  109. package/src/api/confd.js +5 -2
  110. package/src/domain/CallLog.js +1 -1
  111. package/src/domain/Meeting.js +19 -2
  112. package/src/domain/Phone/WebRTCPhone.js +14 -1
  113. package/src/domain/Recording.js +1 -1
  114. package/src/service/IssueReporter.js +26 -3
  115. package/src/simple/Phone.js +5 -0
  116. package/src/types/WebSocketMessage.js +5 -1
  117. package/src/web-rtc-client.js +44 -12
  118. package/src/websocket-client.js +2 -0
@@ -711,6 +711,7 @@ class IssueReporter {
711
711
 
712
712
 
713
713
 
714
+
714
715
 
715
716
  constructor() {
716
717
  addLevelsTo(this);
@@ -722,12 +723,17 @@ class IssueReporter {
722
723
  this.bufferTimeout = null;
723
724
  this._boundProcessBuffer = this._processBuffer.bind(this);
724
725
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
726
+ this._callback = null;
725
727
  }
726
728
 
727
729
  init() {
728
730
  this._catchConsole();
729
731
  }
730
732
 
733
+ setCallback(cb ) {
734
+ this._callback = cb;
735
+ }
736
+
731
737
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
732
738
  this.remoteClientConfiguration = configuration;
733
739
  }
@@ -763,6 +769,7 @@ class IssueReporter {
763
769
 
764
770
  // Handle category label
765
771
  let category = null;
772
+ let skipSendToRemote = false;
766
773
  let extra = {};
767
774
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
768
775
  category = args[0].split('=')[1];
@@ -778,6 +785,7 @@ class IssueReporter {
778
785
  errorMessage: lastArg.message,
779
786
  errorStack: lastArg.stack,
780
787
  errorType: lastArg.constructor.name,
788
+ skipSendToRemote: lastArg.skipSendToRemote,
781
789
  };
782
790
  } else {
783
791
  extra = lastArg;
@@ -786,6 +794,11 @@ class IssueReporter {
786
794
  args.splice(1, 1);
787
795
  }
788
796
 
797
+ if (extra.skipSendToRemote) {
798
+ skipSendToRemote = true;
799
+ delete extra.skipSendToRemote;
800
+ }
801
+
789
802
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
790
803
  const message = args.join(', ');
791
804
  let consoleMessage = message;
@@ -806,7 +819,13 @@ class IssueReporter {
806
819
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
807
820
  oldMethod.apply(oldMethod, [date, consoleMessage]);
808
821
 
809
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
822
+ if (this._callback) {
823
+ this._callback(level, consoleMessage);
824
+ }
825
+
826
+ if (!skipSendToRemote) {
827
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
828
+ }
810
829
  }
811
830
 
812
831
  logRequest(url , options , response , start ) {
@@ -951,7 +970,11 @@ class IssueReporter {
951
970
  },
952
971
  // $FlowFixMe
953
972
  body,
954
- }).catch(() => {
973
+ }).catch((e ) => {
974
+ // $FlowFixMe
975
+ e.skipSendToRemote = true;
976
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
977
+
955
978
  setTimeout(() => {
956
979
  if (isArray) {
957
980
  payload = payload.map(message => {
@@ -963,7 +986,7 @@ class IssueReporter {
963
986
  payload._retry = retry + 1;
964
987
  }
965
988
 
966
- this._sendDebugToGrafana(body, retry + 1);
989
+ this._sendDebugToGrafana(payload, retry + 1);
967
990
  }, 5000 + retry * 1000);
968
991
  });
969
992
  }
@@ -3155,7 +3178,8 @@ class ExternalApp {
3155
3178
 
3156
3179
 
3157
3180
 
3158
-
3181
+
3182
+
3159
3183
 
3160
3184
 
3161
3185
  class Meeting {
@@ -3167,6 +3191,7 @@ class Meeting {
3167
3191
 
3168
3192
 
3169
3193
 
3194
+
3170
3195
 
3171
3196
 
3172
3197
  static parse(plain ) {
@@ -3178,14 +3203,28 @@ class Meeting {
3178
3203
  port: plain.port,
3179
3204
  uuid: plain.uuid,
3180
3205
  number: plain.number,
3206
+ persistent: plain.persistent,
3181
3207
  });
3182
3208
  }
3183
3209
 
3210
+ static parseMany(items ) {
3211
+ return items.map(plain => Meeting.parse(plain));
3212
+ }
3213
+
3184
3214
  static newFrom(meeting ) {
3185
3215
  return newFrom(meeting, Meeting);
3186
3216
  }
3187
3217
 
3188
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number } = {}) {
3218
+ constructor({
3219
+ uuid,
3220
+ name,
3221
+ guestSipAuthorization,
3222
+ ownerUuids,
3223
+ port,
3224
+ uri,
3225
+ number,
3226
+ persistent,
3227
+ } = {}) {
3189
3228
  this.guestSipAuthorization = guestSipAuthorization;
3190
3229
  this.uri = uri;
3191
3230
  this.name = name;
@@ -3193,6 +3232,7 @@ class Meeting {
3193
3232
  this.port = port;
3194
3233
  this.uuid = uuid;
3195
3234
  this.number = number;
3235
+ this.persistent = persistent;
3196
3236
 
3197
3237
  // Useful to compare instead of instanceof with minified code
3198
3238
  this.type = 'Meeting';
@@ -3270,8 +3310,11 @@ var confdMethods = (client , baseUrl ) => ({
3270
3310
  }
3271
3311
  },
3272
3312
 
3273
- createMyMeeting: (name ) =>
3274
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
3313
+ getMyMeetings: () =>
3314
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
3315
+
3316
+ createMyMeeting: (name , persistent ) =>
3317
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
3275
3318
 
3276
3319
  deleteMyMeeting: (meetingUuid ) =>
3277
3320
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -3576,7 +3619,7 @@ class Recording {
3576
3619
 
3577
3620
 
3578
3621
 
3579
- static parseMany(recordings ) {
3622
+ static parseMany(recordings = []) {
3580
3623
  return recordings.map(item => Recording.parse(item));
3581
3624
  }
3582
3625
 
@@ -3702,7 +3745,7 @@ class CallLog {
3702
3745
  duration: (plain.duration || 0) * 1000, // duration is in seconds
3703
3746
  start: moment(plain.start).toDate(),
3704
3747
  end: plain.end ? moment(plain.end).toDate() : null,
3705
- recordings: Recording.parseMany(plain.recordings),
3748
+ recordings: Recording.parseMany(plain.recordings || []),
3706
3749
  });
3707
3750
  }
3708
3751
 
@@ -6283,6 +6326,7 @@ const ON_REINVITE$1 = 'reinvite';
6283
6326
  const ON_ERROR = 'onError';
6284
6327
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
6285
6328
  const ON_NETWORK_STATS$1 = 'onNetworkStats';
6329
+ const ON_DISCONNECTED$1 = 'onDisconnected';
6286
6330
 
6287
6331
  const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6288
6332
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
@@ -6359,6 +6403,7 @@ class WebRTCClient extends Emitter {
6359
6403
 
6360
6404
 
6361
6405
 
6406
+
6362
6407
 
6363
6408
  static isAPrivateIp(ip ) {
6364
6409
  const regex = /^(?:10|127|172\.(?:1[6-9]|2[0-9]|3[01])|192\.168)\..*/;
@@ -6424,6 +6469,7 @@ class WebRTCClient extends Emitter {
6424
6469
  this.ON_ERROR = ON_ERROR;
6425
6470
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6426
6471
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6472
+ this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6427
6473
  }
6428
6474
 
6429
6475
  configureMedia(media ) {
@@ -6689,7 +6735,9 @@ class WebRTCClient extends Emitter {
6689
6735
  const inviteOptions = {
6690
6736
  requestDelegate: {
6691
6737
  onAccept: (response ) => {
6692
- session.sessionDescriptionHandler.peerConnection.sfu = conference;
6738
+ if (session.sessionDescriptionHandler.peerConnection) {
6739
+ session.sessionDescriptionHandler.peerConnection.sfu = conference;
6740
+ }
6693
6741
  this._onAccepted(session, response.session, true);
6694
6742
  },
6695
6743
  onReject: (response ) => {
@@ -7025,7 +7073,7 @@ class WebRTCClient extends Emitter {
7025
7073
  // We search for the last transceiver without `video-` in the mid (video- means remote transceiver)
7026
7074
  const transceivers = pc.getTransceivers();
7027
7075
  const transceiverIdx = lastIndexOf(transceivers, transceiver =>
7028
- transceiver.sender.track === null && transceiver.mid.indexOf('video') === -1);
7076
+ transceiver.sender.track === null && transceiver.mid && transceiver.mid.indexOf('video') === -1);
7029
7077
 
7030
7078
  videoSender = transceiverIdx !== -1 ? transceivers[transceiverIdx].sender : null;
7031
7079
  } else {
@@ -7561,6 +7609,16 @@ class WebRTCClient extends Emitter {
7561
7609
  return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
7562
7610
  }
7563
7611
 
7612
+ // Useful in a react-native environment when remoteMediaStream is not updated
7613
+ getRemoteVideoStreamFromPc(sessionId ) {
7614
+ const pc = this.getPeerConnection(sessionId);
7615
+ if (!pc) {
7616
+ return null;
7617
+ }
7618
+
7619
+ return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
7620
+ }
7621
+
7564
7622
  hasVideo(sessionId ) {
7565
7623
  return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
7566
7624
  }
@@ -8050,6 +8108,7 @@ class WebRTCClient extends Emitter {
8050
8108
 
8051
8109
  this.updateRemoteStream(this.getSipSessionId(session));
8052
8110
 
8111
+ const pc = session.sessionDescriptionHandler.peerConnection;
8053
8112
  const onTrack = (event ) => {
8054
8113
  const isAudioOnly = this._isAudioOnly(session);
8055
8114
  const { kind, label, readyState, id, muted } = event.track;
@@ -8069,6 +8128,12 @@ class WebRTCClient extends Emitter {
8069
8128
 
8070
8129
  session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
8071
8130
 
8131
+ pc.oniceconnectionstatechange = () => {
8132
+ if (pc.iceConnectionState === 'disconnected') {
8133
+ this.eventEmitter.emit(ON_DISCONNECTED$1);
8134
+ }
8135
+ };
8136
+
8072
8137
  if (withEvent) {
8073
8138
  this.eventEmitter.emit(ACCEPTED, session, sessionDialog);
8074
8139
  }
@@ -8288,6 +8353,7 @@ class WebRTCClient extends Emitter {
8288
8353
  let videoBytesReceived = 0;
8289
8354
  let transportSent = 0;
8290
8355
  let transportReceived = 0;
8356
+ let packetsLost = 0;
8291
8357
 
8292
8358
  stats.forEach(report => {
8293
8359
  if (report.type === 'outbound-rtp' && report.kind === 'audio') {
@@ -8300,7 +8366,7 @@ class WebRTCClient extends Emitter {
8300
8366
  videoBytesSent += report.bytesSent + report.headerBytesSent;
8301
8367
  }
8302
8368
  if (report.type === 'inbound-rtp' && report.kind === 'audio') {
8303
- networkStats.packetsLost = report.packetsLost;
8369
+ packetsLost += report.packetsLost;
8304
8370
  networkStats.packetsReceived = report.packetsReceived;
8305
8371
  audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
8306
8372
  }
@@ -8317,27 +8383,36 @@ class WebRTCClient extends Emitter {
8317
8383
  }
8318
8384
  }
8319
8385
  if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
8386
+ packetsLost += report.packetsLost;
8320
8387
  networkStats.roundTripTime = report.roundTripTime;
8321
8388
  networkStats.jitter = report.jitter;
8322
8389
  }
8390
+ if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
8391
+ packetsLost += report.packetsLost;
8392
+ }
8323
8393
  if (report.type === 'transport') {
8324
8394
  transportSent += report.bytesSent;
8325
8395
  transportReceived += report.bytesReceived;
8326
8396
  }
8327
8397
  });
8328
8398
 
8329
- networkStats.audioBytesSent = audioBytesSent;
8399
+ networkStats.packetsLost = packetsLost;
8400
+ networkStats.totalAudioBytesSent = audioBytesSent;
8401
+ networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
8402
+ networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
8330
8403
  networkStats.audioBytesReceived = audioBytesReceived;
8331
- networkStats.videoBytesSent = videoBytesSent;
8332
- networkStats.videoBytesReceived = videoBytesReceived;
8404
+ networkStats.totalVideoBytesSent = videoBytesSent;
8405
+ networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
8406
+ networkStats.totalVideoBytesReceived = videoBytesReceived;
8407
+ networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
8408
+ networkStats.totalTransportSent = transportSent - lastTransportSent;
8333
8409
  networkStats.transportSent = transportSent;
8334
- networkStats.transportReceived = transportReceived;
8410
+ networkStats.totalTransportReceived = transportReceived;
8411
+ networkStats.transportReceived = transportReceived - lastTransportReceived;
8335
8412
 
8336
- const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
8337
- + (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
8338
- + (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
8339
-
8340
- networkStats.bandwidth = bandwidth;
8413
+ networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
8414
+ + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
8415
+ + networkStats.transportSent;
8341
8416
 
8342
8417
  this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
8343
8418
  this.sessionNetworkStats[sessionId].push(networkStats);
@@ -8386,6 +8461,7 @@ const ON_MESSAGE_TRACK_UPDATED = 'onTrackUpdated';
8386
8461
  const ON_NETWORK_STATS = 'onNetworkStats';
8387
8462
  const ON_CHAT = 'phone/ON_CHAT';
8388
8463
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8464
+ const ON_DISCONNECTED = 'onDisconnected';
8389
8465
 
8390
8466
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8391
8467
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -8425,6 +8501,7 @@ const events = [
8425
8501
  ON_CHAT,
8426
8502
  ON_SIGNAL,
8427
8503
  ON_NETWORK_STATS,
8504
+ ON_DISCONNECTED,
8428
8505
  ];
8429
8506
 
8430
8507
  const logger$8 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -8746,9 +8823,11 @@ class WebRTCPhone extends Emitter {
8746
8823
  case SessionState.Terminated: {
8747
8824
  logger$8.info('WebRTC phone - call terminated', { sipId: sipSession.id });
8748
8825
 
8826
+ // Should be called before `_onCallTerminated` or the callCount will not decrement...
8827
+ const callSession = this._createCallSession(sipSession);
8749
8828
  const wasCurrentSession = this._onCallTerminated(sipSession);
8750
8829
 
8751
- return this.eventEmitter.emit(ON_CALL_ENDED, this._createCallSession(sipSession), wasCurrentSession);
8830
+ return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
8752
8831
  }
8753
8832
  }
8754
8833
  });
@@ -9696,6 +9775,10 @@ class WebRTCPhone extends Emitter {
9696
9775
  return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
9697
9776
  }
9698
9777
 
9778
+ getRemoteVideoStreamFromPc(callSession ) {
9779
+ return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
9780
+ }
9781
+
9699
9782
  hasRemoteVideo(callSession ) {
9700
9783
  return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
9701
9784
  }
@@ -9777,6 +9860,11 @@ class WebRTCPhone extends Emitter {
9777
9860
  this.eventEmitter.emit(ON_UNREGISTERED);
9778
9861
  });
9779
9862
 
9863
+ this.client.on(this.client.ON_DISCONNECTED, () => {
9864
+ logger$8.info('WebRTC disconnected');
9865
+ this.eventEmitter.emit(ON_DISCONNECTED);
9866
+ });
9867
+
9780
9868
  this.client.on(this.client.REGISTERED, () => {
9781
9869
  logger$8.info('WebRTC registered', {
9782
9870
  shouldSendReinvite: this.shouldSendReinvite,
@@ -10033,6 +10121,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10033
10121
  ON_NETWORK_STATS: ON_NETWORK_STATS,
10034
10122
  ON_CHAT: ON_CHAT,
10035
10123
  ON_SIGNAL: ON_SIGNAL,
10124
+ ON_DISCONNECTED: ON_DISCONNECTED,
10036
10125
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10037
10126
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10038
10127
  events: events,
@@ -10391,6 +10480,7 @@ const AGENT_PAUSED = 'agent_paused';
10391
10480
  const AGENT_UNPAUSED = 'agent_unpaused';
10392
10481
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
10393
10482
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
10483
+ const MEETING_USER_PROGRESS = 'meeting_user_progress';
10394
10484
 
10395
10485
  const BLACKLIST_EVENTS = [
10396
10486
  CHAT_MESSAGE_SENT,
@@ -10741,6 +10831,7 @@ WebSocketClient.eventLists = [
10741
10831
  AGENT_UNPAUSED,
10742
10832
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
10743
10833
  CONFERENCE_ADHOC_DELETED,
10834
+ MEETING_USER_PROGRESS,
10744
10835
  ];
10745
10836
 
10746
10837
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -10811,6 +10902,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
10811
10902
  AGENT_UNPAUSED: AGENT_UNPAUSED,
10812
10903
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
10813
10904
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
10905
+ MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
10814
10906
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
10815
10907
  'default': WebSocketClient
10816
10908
  });
@@ -13530,6 +13622,11 @@ class Phone extends Emitter {
13530
13622
  return this.getRemoteVideoStream(callSession);
13531
13623
  }
13532
13624
 
13625
+ // Useful in a react-native environment when remoteMediaStream is not updated
13626
+ getRemoteVideoStreamFromPc(callSession ) {
13627
+ return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
13628
+ }
13629
+
13533
13630
  hasVideo(callSession ) {
13534
13631
  return this.phone ? this.phone.hasVideo(callSession) : false;
13535
13632
  }
@@ -121,6 +121,7 @@ class IssueReporter {
121
121
 
122
122
 
123
123
 
124
+
124
125
 
125
126
  constructor() {
126
127
  addLevelsTo(this);
@@ -132,12 +133,17 @@ class IssueReporter {
132
133
  this.bufferTimeout = null;
133
134
  this._boundProcessBuffer = this._processBuffer.bind(this);
134
135
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
136
+ this._callback = null;
135
137
  }
136
138
 
137
139
  init() {
138
140
  this._catchConsole();
139
141
  }
140
142
 
143
+ setCallback(cb ) {
144
+ this._callback = cb;
145
+ }
146
+
141
147
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
142
148
  this.remoteClientConfiguration = configuration;
143
149
  }
@@ -173,6 +179,7 @@ class IssueReporter {
173
179
 
174
180
  // Handle category label
175
181
  let category = null;
182
+ let skipSendToRemote = false;
176
183
  let extra = {};
177
184
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
178
185
  category = args[0].split('=')[1];
@@ -188,6 +195,7 @@ class IssueReporter {
188
195
  errorMessage: lastArg.message,
189
196
  errorStack: lastArg.stack,
190
197
  errorType: lastArg.constructor.name,
198
+ skipSendToRemote: lastArg.skipSendToRemote,
191
199
  };
192
200
  } else {
193
201
  extra = lastArg;
@@ -196,6 +204,11 @@ class IssueReporter {
196
204
  args.splice(1, 1);
197
205
  }
198
206
 
207
+ if (extra.skipSendToRemote) {
208
+ skipSendToRemote = true;
209
+ delete extra.skipSendToRemote;
210
+ }
211
+
199
212
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
200
213
  const message = args.join(', ');
201
214
  let consoleMessage = message;
@@ -216,7 +229,13 @@ class IssueReporter {
216
229
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
217
230
  oldMethod.apply(oldMethod, [date, consoleMessage]);
218
231
 
219
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
232
+ if (this._callback) {
233
+ this._callback(level, consoleMessage);
234
+ }
235
+
236
+ if (!skipSendToRemote) {
237
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
238
+ }
220
239
  }
221
240
 
222
241
  logRequest(url , options , response , start ) {
@@ -361,7 +380,11 @@ class IssueReporter {
361
380
  },
362
381
  // $FlowFixMe
363
382
  body,
364
- }).catch(() => {
383
+ }).catch((e ) => {
384
+ // $FlowFixMe
385
+ e.skipSendToRemote = true;
386
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
387
+
365
388
  setTimeout(() => {
366
389
  if (isArray) {
367
390
  payload = payload.map(message => {
@@ -373,7 +396,7 @@ class IssueReporter {
373
396
  payload._retry = retry + 1;
374
397
  }
375
398
 
376
- this._sendDebugToGrafana(body, retry + 1);
399
+ this._sendDebugToGrafana(payload, retry + 1);
377
400
  }, 5000 + retry * 1000);
378
401
  });
379
402
  }
@@ -578,6 +601,7 @@ const AGENT_PAUSED = 'agent_paused';
578
601
  const AGENT_UNPAUSED = 'agent_unpaused';
579
602
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
580
603
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
604
+ const MEETING_USER_PROGRESS = 'meeting_user_progress';
581
605
 
582
606
  const BLACKLIST_EVENTS = [
583
607
  CHAT_MESSAGE_SENT,
@@ -928,6 +952,7 @@ WebSocketClient.eventLists = [
928
952
  AGENT_UNPAUSED,
929
953
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
930
954
  CONFERENCE_ADHOC_DELETED,
955
+ MEETING_USER_PROGRESS,
931
956
  ];
932
957
 
933
958
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -998,6 +1023,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
998
1023
  AGENT_UNPAUSED: AGENT_UNPAUSED,
999
1024
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
1000
1025
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
1026
+ MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
1001
1027
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
1002
1028
  'default': WebSocketClient
1003
1029
  });