@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
@@ -721,6 +721,7 @@ class IssueReporter {
721
721
 
722
722
 
723
723
 
724
+
724
725
 
725
726
  constructor() {
726
727
  addLevelsTo(this);
@@ -732,12 +733,17 @@ class IssueReporter {
732
733
  this.bufferTimeout = null;
733
734
  this._boundProcessBuffer = this._processBuffer.bind(this);
734
735
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
736
+ this._callback = null;
735
737
  }
736
738
 
737
739
  init() {
738
740
  this._catchConsole();
739
741
  }
740
742
 
743
+ setCallback(cb ) {
744
+ this._callback = cb;
745
+ }
746
+
741
747
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
742
748
  this.remoteClientConfiguration = configuration;
743
749
  }
@@ -773,6 +779,7 @@ class IssueReporter {
773
779
 
774
780
  // Handle category label
775
781
  let category = null;
782
+ let skipSendToRemote = false;
776
783
  let extra = {};
777
784
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
778
785
  category = args[0].split('=')[1];
@@ -788,6 +795,7 @@ class IssueReporter {
788
795
  errorMessage: lastArg.message,
789
796
  errorStack: lastArg.stack,
790
797
  errorType: lastArg.constructor.name,
798
+ skipSendToRemote: lastArg.skipSendToRemote,
791
799
  };
792
800
  } else {
793
801
  extra = lastArg;
@@ -796,6 +804,11 @@ class IssueReporter {
796
804
  args.splice(1, 1);
797
805
  }
798
806
 
807
+ if (extra.skipSendToRemote) {
808
+ skipSendToRemote = true;
809
+ delete extra.skipSendToRemote;
810
+ }
811
+
799
812
  const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
800
813
  const message = args.join(', ');
801
814
  let consoleMessage = message;
@@ -816,7 +829,13 @@ class IssueReporter {
816
829
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
817
830
  oldMethod.apply(oldMethod, [date, consoleMessage]);
818
831
 
819
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
832
+ if (this._callback) {
833
+ this._callback(level, consoleMessage);
834
+ }
835
+
836
+ if (!skipSendToRemote) {
837
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
838
+ }
820
839
  }
821
840
 
822
841
  logRequest(url , options , response , start ) {
@@ -961,7 +980,11 @@ class IssueReporter {
961
980
  },
962
981
  // $FlowFixMe
963
982
  body,
964
- }).catch(() => {
983
+ }).catch((e ) => {
984
+ // $FlowFixMe
985
+ e.skipSendToRemote = true;
986
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
987
+
965
988
  setTimeout(() => {
966
989
  if (isArray) {
967
990
  payload = payload.map(message => {
@@ -973,7 +996,7 @@ class IssueReporter {
973
996
  payload._retry = retry + 1;
974
997
  }
975
998
 
976
- this._sendDebugToGrafana(body, retry + 1);
999
+ this._sendDebugToGrafana(payload, retry + 1);
977
1000
  }, 5000 + retry * 1000);
978
1001
  });
979
1002
  }
@@ -3165,7 +3188,8 @@ class ExternalApp {
3165
3188
 
3166
3189
 
3167
3190
 
3168
-
3191
+
3192
+
3169
3193
 
3170
3194
 
3171
3195
  class Meeting {
@@ -3177,6 +3201,7 @@ class Meeting {
3177
3201
 
3178
3202
 
3179
3203
 
3204
+
3180
3205
 
3181
3206
 
3182
3207
  static parse(plain ) {
@@ -3188,14 +3213,28 @@ class Meeting {
3188
3213
  port: plain.port,
3189
3214
  uuid: plain.uuid,
3190
3215
  number: plain.number,
3216
+ persistent: plain.persistent,
3191
3217
  });
3192
3218
  }
3193
3219
 
3220
+ static parseMany(items ) {
3221
+ return items.map(plain => Meeting.parse(plain));
3222
+ }
3223
+
3194
3224
  static newFrom(meeting ) {
3195
3225
  return newFrom(meeting, Meeting);
3196
3226
  }
3197
3227
 
3198
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number } = {}) {
3228
+ constructor({
3229
+ uuid,
3230
+ name,
3231
+ guestSipAuthorization,
3232
+ ownerUuids,
3233
+ port,
3234
+ uri,
3235
+ number,
3236
+ persistent,
3237
+ } = {}) {
3199
3238
  this.guestSipAuthorization = guestSipAuthorization;
3200
3239
  this.uri = uri;
3201
3240
  this.name = name;
@@ -3203,6 +3242,7 @@ class Meeting {
3203
3242
  this.port = port;
3204
3243
  this.uuid = uuid;
3205
3244
  this.number = number;
3245
+ this.persistent = persistent;
3206
3246
 
3207
3247
  // Useful to compare instead of instanceof with minified code
3208
3248
  this.type = 'Meeting';
@@ -3280,8 +3320,11 @@ var confdMethods = (client , baseUrl ) => ({
3280
3320
  }
3281
3321
  },
3282
3322
 
3283
- createMyMeeting: (name ) =>
3284
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
3323
+ getMyMeetings: () =>
3324
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
3325
+
3326
+ createMyMeeting: (name , persistent ) =>
3327
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
3285
3328
 
3286
3329
  deleteMyMeeting: (meetingUuid ) =>
3287
3330
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -3586,7 +3629,7 @@ class Recording {
3586
3629
 
3587
3630
 
3588
3631
 
3589
- static parseMany(recordings ) {
3632
+ static parseMany(recordings = []) {
3590
3633
  return recordings.map(item => Recording.parse(item));
3591
3634
  }
3592
3635
 
@@ -3712,7 +3755,7 @@ class CallLog {
3712
3755
  duration: (plain.duration || 0) * 1000, // duration is in seconds
3713
3756
  start: moment__default['default'](plain.start).toDate(),
3714
3757
  end: plain.end ? moment__default['default'](plain.end).toDate() : null,
3715
- recordings: Recording.parseMany(plain.recordings),
3758
+ recordings: Recording.parseMany(plain.recordings || []),
3716
3759
  });
3717
3760
  }
3718
3761
 
@@ -6293,6 +6336,7 @@ const ON_REINVITE$1 = 'reinvite';
6293
6336
  const ON_ERROR = 'onError';
6294
6337
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
6295
6338
  const ON_NETWORK_STATS$1 = 'onNetworkStats';
6339
+ const ON_DISCONNECTED$1 = 'onDisconnected';
6296
6340
 
6297
6341
  const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6298
6342
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
@@ -6369,6 +6413,7 @@ class WebRTCClient extends Emitter {
6369
6413
 
6370
6414
 
6371
6415
 
6416
+
6372
6417
 
6373
6418
  static isAPrivateIp(ip ) {
6374
6419
  const regex = /^(?:10|127|172\.(?:1[6-9]|2[0-9]|3[01])|192\.168)\..*/;
@@ -6434,6 +6479,7 @@ class WebRTCClient extends Emitter {
6434
6479
  this.ON_ERROR = ON_ERROR;
6435
6480
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6436
6481
  this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6482
+ this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6437
6483
  }
6438
6484
 
6439
6485
  configureMedia(media ) {
@@ -6699,7 +6745,9 @@ class WebRTCClient extends Emitter {
6699
6745
  const inviteOptions = {
6700
6746
  requestDelegate: {
6701
6747
  onAccept: (response ) => {
6702
- session.sessionDescriptionHandler.peerConnection.sfu = conference;
6748
+ if (session.sessionDescriptionHandler.peerConnection) {
6749
+ session.sessionDescriptionHandler.peerConnection.sfu = conference;
6750
+ }
6703
6751
  this._onAccepted(session, response.session, true);
6704
6752
  },
6705
6753
  onReject: (response ) => {
@@ -7035,7 +7083,7 @@ class WebRTCClient extends Emitter {
7035
7083
  // We search for the last transceiver without `video-` in the mid (video- means remote transceiver)
7036
7084
  const transceivers = pc.getTransceivers();
7037
7085
  const transceiverIdx = lastIndexOf(transceivers, transceiver =>
7038
- transceiver.sender.track === null && transceiver.mid.indexOf('video') === -1);
7086
+ transceiver.sender.track === null && transceiver.mid && transceiver.mid.indexOf('video') === -1);
7039
7087
 
7040
7088
  videoSender = transceiverIdx !== -1 ? transceivers[transceiverIdx].sender : null;
7041
7089
  } else {
@@ -7571,6 +7619,16 @@ class WebRTCClient extends Emitter {
7571
7619
  return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
7572
7620
  }
7573
7621
 
7622
+ // Useful in a react-native environment when remoteMediaStream is not updated
7623
+ getRemoteVideoStreamFromPc(sessionId ) {
7624
+ const pc = this.getPeerConnection(sessionId);
7625
+ if (!pc) {
7626
+ return null;
7627
+ }
7628
+
7629
+ return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
7630
+ }
7631
+
7574
7632
  hasVideo(sessionId ) {
7575
7633
  return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
7576
7634
  }
@@ -8060,6 +8118,7 @@ class WebRTCClient extends Emitter {
8060
8118
 
8061
8119
  this.updateRemoteStream(this.getSipSessionId(session));
8062
8120
 
8121
+ const pc = session.sessionDescriptionHandler.peerConnection;
8063
8122
  const onTrack = (event ) => {
8064
8123
  const isAudioOnly = this._isAudioOnly(session);
8065
8124
  const { kind, label, readyState, id, muted } = event.track;
@@ -8079,6 +8138,12 @@ class WebRTCClient extends Emitter {
8079
8138
 
8080
8139
  session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
8081
8140
 
8141
+ pc.oniceconnectionstatechange = () => {
8142
+ if (pc.iceConnectionState === 'disconnected') {
8143
+ this.eventEmitter.emit(ON_DISCONNECTED$1);
8144
+ }
8145
+ };
8146
+
8082
8147
  if (withEvent) {
8083
8148
  this.eventEmitter.emit(ACCEPTED, session, sessionDialog);
8084
8149
  }
@@ -8298,6 +8363,7 @@ class WebRTCClient extends Emitter {
8298
8363
  let videoBytesReceived = 0;
8299
8364
  let transportSent = 0;
8300
8365
  let transportReceived = 0;
8366
+ let packetsLost = 0;
8301
8367
 
8302
8368
  stats.forEach(report => {
8303
8369
  if (report.type === 'outbound-rtp' && report.kind === 'audio') {
@@ -8310,7 +8376,7 @@ class WebRTCClient extends Emitter {
8310
8376
  videoBytesSent += report.bytesSent + report.headerBytesSent;
8311
8377
  }
8312
8378
  if (report.type === 'inbound-rtp' && report.kind === 'audio') {
8313
- networkStats.packetsLost = report.packetsLost;
8379
+ packetsLost += report.packetsLost;
8314
8380
  networkStats.packetsReceived = report.packetsReceived;
8315
8381
  audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
8316
8382
  }
@@ -8327,27 +8393,36 @@ class WebRTCClient extends Emitter {
8327
8393
  }
8328
8394
  }
8329
8395
  if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
8396
+ packetsLost += report.packetsLost;
8330
8397
  networkStats.roundTripTime = report.roundTripTime;
8331
8398
  networkStats.jitter = report.jitter;
8332
8399
  }
8400
+ if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
8401
+ packetsLost += report.packetsLost;
8402
+ }
8333
8403
  if (report.type === 'transport') {
8334
8404
  transportSent += report.bytesSent;
8335
8405
  transportReceived += report.bytesReceived;
8336
8406
  }
8337
8407
  });
8338
8408
 
8339
- networkStats.audioBytesSent = audioBytesSent;
8409
+ networkStats.packetsLost = packetsLost;
8410
+ networkStats.totalAudioBytesSent = audioBytesSent;
8411
+ networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
8412
+ networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
8340
8413
  networkStats.audioBytesReceived = audioBytesReceived;
8341
- networkStats.videoBytesSent = videoBytesSent;
8342
- networkStats.videoBytesReceived = videoBytesReceived;
8414
+ networkStats.totalVideoBytesSent = videoBytesSent;
8415
+ networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
8416
+ networkStats.totalVideoBytesReceived = videoBytesReceived;
8417
+ networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
8418
+ networkStats.totalTransportSent = transportSent - lastTransportSent;
8343
8419
  networkStats.transportSent = transportSent;
8344
- networkStats.transportReceived = transportReceived;
8420
+ networkStats.totalTransportReceived = transportReceived;
8421
+ networkStats.transportReceived = transportReceived - lastTransportReceived;
8345
8422
 
8346
- const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
8347
- + (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
8348
- + (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
8349
-
8350
- networkStats.bandwidth = bandwidth;
8423
+ networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
8424
+ + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
8425
+ + networkStats.transportSent;
8351
8426
 
8352
8427
  this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
8353
8428
  this.sessionNetworkStats[sessionId].push(networkStats);
@@ -8396,6 +8471,7 @@ const ON_MESSAGE_TRACK_UPDATED = 'onTrackUpdated';
8396
8471
  const ON_NETWORK_STATS = 'onNetworkStats';
8397
8472
  const ON_CHAT = 'phone/ON_CHAT';
8398
8473
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8474
+ const ON_DISCONNECTED = 'onDisconnected';
8399
8475
 
8400
8476
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8401
8477
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
@@ -8435,6 +8511,7 @@ const events = [
8435
8511
  ON_CHAT,
8436
8512
  ON_SIGNAL,
8437
8513
  ON_NETWORK_STATS,
8514
+ ON_DISCONNECTED,
8438
8515
  ];
8439
8516
 
8440
8517
  const logger$8 = IssueReporter$1.loggerFor('webrtc-phone');
@@ -8756,9 +8833,11 @@ class WebRTCPhone extends Emitter {
8756
8833
  case sessionState.SessionState.Terminated: {
8757
8834
  logger$8.info('WebRTC phone - call terminated', { sipId: sipSession.id });
8758
8835
 
8836
+ // Should be called before `_onCallTerminated` or the callCount will not decrement...
8837
+ const callSession = this._createCallSession(sipSession);
8759
8838
  const wasCurrentSession = this._onCallTerminated(sipSession);
8760
8839
 
8761
- return this.eventEmitter.emit(ON_CALL_ENDED, this._createCallSession(sipSession), wasCurrentSession);
8840
+ return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
8762
8841
  }
8763
8842
  }
8764
8843
  });
@@ -9706,6 +9785,10 @@ class WebRTCPhone extends Emitter {
9706
9785
  return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
9707
9786
  }
9708
9787
 
9788
+ getRemoteVideoStreamFromPc(callSession ) {
9789
+ return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
9790
+ }
9791
+
9709
9792
  hasRemoteVideo(callSession ) {
9710
9793
  return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
9711
9794
  }
@@ -9787,6 +9870,11 @@ class WebRTCPhone extends Emitter {
9787
9870
  this.eventEmitter.emit(ON_UNREGISTERED);
9788
9871
  });
9789
9872
 
9873
+ this.client.on(this.client.ON_DISCONNECTED, () => {
9874
+ logger$8.info('WebRTC disconnected');
9875
+ this.eventEmitter.emit(ON_DISCONNECTED);
9876
+ });
9877
+
9790
9878
  this.client.on(this.client.REGISTERED, () => {
9791
9879
  logger$8.info('WebRTC registered', {
9792
9880
  shouldSendReinvite: this.shouldSendReinvite,
@@ -10043,6 +10131,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10043
10131
  ON_NETWORK_STATS: ON_NETWORK_STATS,
10044
10132
  ON_CHAT: ON_CHAT,
10045
10133
  ON_SIGNAL: ON_SIGNAL,
10134
+ ON_DISCONNECTED: ON_DISCONNECTED,
10046
10135
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10047
10136
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10048
10137
  events: events,
@@ -10401,6 +10490,7 @@ const AGENT_PAUSED = 'agent_paused';
10401
10490
  const AGENT_UNPAUSED = 'agent_unpaused';
10402
10491
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
10403
10492
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
10493
+ const MEETING_USER_PROGRESS = 'meeting_user_progress';
10404
10494
 
10405
10495
  const BLACKLIST_EVENTS = [
10406
10496
  CHAT_MESSAGE_SENT,
@@ -10751,6 +10841,7 @@ WebSocketClient.eventLists = [
10751
10841
  AGENT_UNPAUSED,
10752
10842
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
10753
10843
  CONFERENCE_ADHOC_DELETED,
10844
+ MEETING_USER_PROGRESS,
10754
10845
  ];
10755
10846
 
10756
10847
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -10821,6 +10912,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
10821
10912
  AGENT_UNPAUSED: AGENT_UNPAUSED,
10822
10913
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
10823
10914
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
10915
+ MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
10824
10916
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
10825
10917
  'default': WebSocketClient
10826
10918
  });
@@ -13540,6 +13632,11 @@ class Phone extends Emitter {
13540
13632
  return this.getRemoteVideoStream(callSession);
13541
13633
  }
13542
13634
 
13635
+ // Useful in a react-native environment when remoteMediaStream is not updated
13636
+ getRemoteVideoStreamFromPc(callSession ) {
13637
+ return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
13638
+ }
13639
+
13543
13640
  hasVideo(callSession ) {
13544
13641
  return this.phone ? this.phone.hasVideo(callSession) : false;
13545
13642
  }
@@ -129,6 +129,7 @@ class IssueReporter {
129
129
 
130
130
 
131
131
 
132
+
132
133
 
133
134
  constructor() {
134
135
  addLevelsTo(this);
@@ -140,12 +141,17 @@ class IssueReporter {
140
141
  this.bufferTimeout = null;
141
142
  this._boundProcessBuffer = this._processBuffer.bind(this);
142
143
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
144
+ this._callback = null;
143
145
  }
144
146
 
145
147
  init() {
146
148
  this._catchConsole();
147
149
  }
148
150
 
151
+ setCallback(cb ) {
152
+ this._callback = cb;
153
+ }
154
+
149
155
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
150
156
  this.remoteClientConfiguration = configuration;
151
157
  }
@@ -181,6 +187,7 @@ class IssueReporter {
181
187
 
182
188
  // Handle category label
183
189
  let category = null;
190
+ let skipSendToRemote = false;
184
191
  let extra = {};
185
192
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
186
193
  category = args[0].split('=')[1];
@@ -196,6 +203,7 @@ class IssueReporter {
196
203
  errorMessage: lastArg.message,
197
204
  errorStack: lastArg.stack,
198
205
  errorType: lastArg.constructor.name,
206
+ skipSendToRemote: lastArg.skipSendToRemote,
199
207
  };
200
208
  } else {
201
209
  extra = lastArg;
@@ -204,6 +212,11 @@ class IssueReporter {
204
212
  args.splice(1, 1);
205
213
  }
206
214
 
215
+ if (extra.skipSendToRemote) {
216
+ skipSendToRemote = true;
217
+ delete extra.skipSendToRemote;
218
+ }
219
+
207
220
  const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
208
221
  const message = args.join(', ');
209
222
  let consoleMessage = message;
@@ -224,7 +237,13 @@ class IssueReporter {
224
237
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
225
238
  oldMethod.apply(oldMethod, [date, consoleMessage]);
226
239
 
227
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
240
+ if (this._callback) {
241
+ this._callback(level, consoleMessage);
242
+ }
243
+
244
+ if (!skipSendToRemote) {
245
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
246
+ }
228
247
  }
229
248
 
230
249
  logRequest(url , options , response , start ) {
@@ -369,7 +388,11 @@ class IssueReporter {
369
388
  },
370
389
  // $FlowFixMe
371
390
  body,
372
- }).catch(() => {
391
+ }).catch((e ) => {
392
+ // $FlowFixMe
393
+ e.skipSendToRemote = true;
394
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
395
+
373
396
  setTimeout(() => {
374
397
  if (isArray) {
375
398
  payload = payload.map(message => {
@@ -381,7 +404,7 @@ class IssueReporter {
381
404
  payload._retry = retry + 1;
382
405
  }
383
406
 
384
- this._sendDebugToGrafana(body, retry + 1);
407
+ this._sendDebugToGrafana(payload, retry + 1);
385
408
  }, 5000 + retry * 1000);
386
409
  });
387
410
  }
@@ -586,6 +609,7 @@ const AGENT_PAUSED = 'agent_paused';
586
609
  const AGENT_UNPAUSED = 'agent_unpaused';
587
610
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
588
611
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
612
+ const MEETING_USER_PROGRESS = 'meeting_user_progress';
589
613
 
590
614
  const BLACKLIST_EVENTS = [
591
615
  CHAT_MESSAGE_SENT,
@@ -936,6 +960,7 @@ WebSocketClient.eventLists = [
936
960
  AGENT_UNPAUSED,
937
961
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
938
962
  CONFERENCE_ADHOC_DELETED,
963
+ MEETING_USER_PROGRESS,
939
964
  ];
940
965
 
941
966
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -1006,6 +1031,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
1006
1031
  AGENT_UNPAUSED: AGENT_UNPAUSED,
1007
1032
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
1008
1033
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
1034
+ MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
1009
1035
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
1010
1036
  'default': WebSocketClient
1011
1037
  });