@wazo/sdk 0.37.19 → 0.37.23

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 (142) hide show
  1. package/dist/wazo-sdk.js +5 -5
  2. package/esm/__tests__/api-client.test.js +70 -5
  3. package/esm/__tests__/web-rtc-client.test.js +111 -67
  4. package/esm/api/agentd.js +25 -2
  5. package/esm/api/amid.js +25 -2
  6. package/esm/api/application.js +25 -2
  7. package/esm/api/auth.js +25 -2
  8. package/esm/api/call-logd.js +32 -2
  9. package/esm/api/calld.js +35 -2
  10. package/esm/api/chatd.js +32 -2
  11. package/esm/api/confd.js +47 -5
  12. package/esm/api/ctid-ng.js +35 -2
  13. package/esm/api/dird.js +28 -2
  14. package/esm/api/webhookd.js +25 -2
  15. package/esm/api-client.js +70 -5
  16. package/esm/checker/Checker.js +113 -67
  17. package/esm/checker/checks/aor.js +70 -5
  18. package/esm/checker/checks/api.js +70 -5
  19. package/esm/checker/checks/index.js +113 -67
  20. package/esm/checker/checks/wazo-websocket.js +27 -2
  21. package/esm/checker/checks/webrtc-transport.js +111 -67
  22. package/esm/checker/checks/webrtc.js +111 -67
  23. package/esm/domain/AdHocAPIConference.js +70 -5
  24. package/esm/domain/Call.js +3 -0
  25. package/esm/domain/CallLog.js +7 -0
  26. package/esm/domain/ChatMessage.js +4 -0
  27. package/esm/domain/ChatRoom.js +3 -0
  28. package/esm/domain/Contact.js +3 -0
  29. package/esm/domain/Features.js +70 -5
  30. package/esm/domain/Meeting.js +17 -1
  31. package/esm/domain/Phone/CTIPhone.js +74 -5
  32. package/esm/domain/Phone/WebRTCPhone.js +50 -16
  33. package/esm/domain/Recording.js +3 -0
  34. package/esm/domain/Voicemail.js +3 -0
  35. package/esm/domain/__tests__/Call.test.js +3 -0
  36. package/esm/domain/__tests__/CallLog.test.js +7 -0
  37. package/esm/domain/__tests__/Contact.test.js +3 -0
  38. package/esm/domain/__tests__/Voicemail.test.js +3 -0
  39. package/esm/index.js +147 -80
  40. package/esm/lib/WazoSessionDescriptionHandler.js +25 -40
  41. package/esm/service/CallApi.js +70 -5
  42. package/esm/service/IssueReporter.js +25 -2
  43. package/esm/service/__tests__/IssueReporter.test.js +25 -2
  44. package/esm/service/getApiClient.js +70 -5
  45. package/esm/simple/Auth.js +147 -80
  46. package/esm/simple/Configuration.js +147 -80
  47. package/esm/simple/Directory.js +70 -5
  48. package/esm/simple/Phone.js +147 -80
  49. package/esm/simple/Websocket.js +28 -2
  50. package/esm/simple/index.js +147 -80
  51. package/esm/simple/room/LocalParticipant.js +147 -80
  52. package/esm/simple/room/Participant.js +147 -80
  53. package/esm/simple/room/RemoteParticipant.js +147 -80
  54. package/esm/simple/room/Room.js +147 -80
  55. package/esm/simple/room/SipRoom.js +147 -80
  56. package/esm/simple/room/Stream.js +147 -80
  57. package/esm/simple/room/__tests__/RemoteParticipant.test.js +147 -80
  58. package/esm/simple/utils.js +147 -80
  59. package/esm/utils/__tests__/api-requester.test.js +25 -2
  60. package/esm/utils/api-requester.js +25 -2
  61. package/esm/web-rtc-client.js +111 -67
  62. package/esm/websocket-client.js +28 -3
  63. package/lib/__tests__/api-client.test.js +70 -5
  64. package/lib/__tests__/web-rtc-client.test.js +111 -67
  65. package/lib/api/agentd.js +25 -2
  66. package/lib/api/amid.js +25 -2
  67. package/lib/api/application.js +25 -2
  68. package/lib/api/auth.js +25 -2
  69. package/lib/api/call-logd.js +32 -2
  70. package/lib/api/calld.js +35 -2
  71. package/lib/api/chatd.js +32 -2
  72. package/lib/api/confd.js +47 -5
  73. package/lib/api/ctid-ng.js +35 -2
  74. package/lib/api/dird.js +28 -2
  75. package/lib/api/webhookd.js +25 -2
  76. package/lib/api-client.js +70 -5
  77. package/lib/checker/Checker.js +113 -67
  78. package/lib/checker/checks/aor.js +70 -5
  79. package/lib/checker/checks/api.js +70 -5
  80. package/lib/checker/checks/index.js +113 -67
  81. package/lib/checker/checks/wazo-websocket.js +27 -2
  82. package/lib/checker/checks/webrtc-transport.js +111 -67
  83. package/lib/checker/checks/webrtc.js +111 -67
  84. package/lib/domain/AdHocAPIConference.js +70 -5
  85. package/lib/domain/Call.js +3 -0
  86. package/lib/domain/CallLog.js +7 -0
  87. package/lib/domain/ChatMessage.js +4 -0
  88. package/lib/domain/ChatRoom.js +3 -0
  89. package/lib/domain/Contact.js +3 -0
  90. package/lib/domain/Features.js +70 -5
  91. package/lib/domain/Meeting.js +17 -1
  92. package/lib/domain/Phone/CTIPhone.js +74 -5
  93. package/lib/domain/Phone/WebRTCPhone.js +50 -16
  94. package/lib/domain/Recording.js +3 -0
  95. package/lib/domain/Voicemail.js +3 -0
  96. package/lib/domain/__tests__/Call.test.js +3 -0
  97. package/lib/domain/__tests__/CallLog.test.js +7 -0
  98. package/lib/domain/__tests__/Contact.test.js +3 -0
  99. package/lib/domain/__tests__/Voicemail.test.js +3 -0
  100. package/lib/index.js +147 -80
  101. package/lib/lib/WazoSessionDescriptionHandler.js +25 -40
  102. package/lib/service/CallApi.js +70 -5
  103. package/lib/service/IssueReporter.js +25 -2
  104. package/lib/service/__tests__/IssueReporter.test.js +25 -2
  105. package/lib/service/getApiClient.js +70 -5
  106. package/lib/simple/Auth.js +147 -80
  107. package/lib/simple/Configuration.js +147 -80
  108. package/lib/simple/Directory.js +70 -5
  109. package/lib/simple/Phone.js +147 -80
  110. package/lib/simple/Websocket.js +28 -2
  111. package/lib/simple/index.js +147 -80
  112. package/lib/simple/room/LocalParticipant.js +147 -80
  113. package/lib/simple/room/Participant.js +147 -80
  114. package/lib/simple/room/RemoteParticipant.js +147 -80
  115. package/lib/simple/room/Room.js +147 -80
  116. package/lib/simple/room/SipRoom.js +147 -80
  117. package/lib/simple/room/Stream.js +147 -80
  118. package/lib/simple/room/__tests__/RemoteParticipant.test.js +147 -80
  119. package/lib/simple/utils.js +147 -80
  120. package/lib/utils/__tests__/api-requester.test.js +25 -2
  121. package/lib/utils/api-requester.js +25 -2
  122. package/lib/web-rtc-client.js +111 -67
  123. package/lib/websocket-client.js +28 -2
  124. package/package.json +2 -2
  125. package/src/api/confd.js +5 -2
  126. package/src/domain/Call.js +3 -0
  127. package/src/domain/CallLog.js +4 -0
  128. package/src/domain/ChatMessage.js +4 -0
  129. package/src/domain/ChatRoom.js +3 -0
  130. package/src/domain/Contact.js +3 -0
  131. package/src/domain/Meeting.js +17 -1
  132. package/src/domain/Phone/CTIPhone.js +4 -0
  133. package/src/domain/Phone/Phone.js +2 -0
  134. package/src/domain/Phone/WebRTCPhone.js +25 -14
  135. package/src/domain/Recording.js +3 -0
  136. package/src/domain/Voicemail.js +3 -0
  137. package/src/lib/WazoSessionDescriptionHandler.js +1 -35
  138. package/src/service/IssueReporter.js +25 -2
  139. package/src/simple/Phone.js +5 -0
  140. package/src/types/WebSocketMessage.js +5 -1
  141. package/src/web-rtc-client.js +41 -24
  142. package/src/websocket-client.js +2 -0
@@ -158,6 +158,7 @@ class IssueReporter {
158
158
 
159
159
 
160
160
 
161
+
161
162
 
162
163
  constructor() {
163
164
  addLevelsTo(this);
@@ -169,12 +170,17 @@ class IssueReporter {
169
170
  this.bufferTimeout = null;
170
171
  this._boundProcessBuffer = this._processBuffer.bind(this);
171
172
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
173
+ this._callback = null;
172
174
  }
173
175
 
174
176
  init() {
175
177
  this._catchConsole();
176
178
  }
177
179
 
180
+ setCallback(cb ) {
181
+ this._callback = cb;
182
+ }
183
+
178
184
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
179
185
  this.remoteClientConfiguration = configuration;
180
186
  }
@@ -210,6 +216,7 @@ class IssueReporter {
210
216
 
211
217
  // Handle category label
212
218
  let category = null;
219
+ let skipSendToRemote = false;
213
220
  let extra = {};
214
221
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
215
222
  category = args[0].split('=')[1];
@@ -225,6 +232,7 @@ class IssueReporter {
225
232
  errorMessage: lastArg.message,
226
233
  errorStack: lastArg.stack,
227
234
  errorType: lastArg.constructor.name,
235
+ skipSendToRemote: lastArg.skipSendToRemote,
228
236
  };
229
237
  } else {
230
238
  extra = lastArg;
@@ -233,6 +241,11 @@ class IssueReporter {
233
241
  args.splice(1, 1);
234
242
  }
235
243
 
244
+ if (extra.skipSendToRemote) {
245
+ skipSendToRemote = true;
246
+ delete extra.skipSendToRemote;
247
+ }
248
+
236
249
  const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
237
250
  const message = args.join(', ');
238
251
  let consoleMessage = message;
@@ -253,7 +266,13 @@ class IssueReporter {
253
266
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
254
267
  oldMethod.apply(oldMethod, [date, consoleMessage]);
255
268
 
256
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
269
+ if (this._callback) {
270
+ this._callback(level, consoleMessage);
271
+ }
272
+
273
+ if (!skipSendToRemote) {
274
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
275
+ }
257
276
  }
258
277
 
259
278
  logRequest(url , options , response , start ) {
@@ -398,7 +417,11 @@ class IssueReporter {
398
417
  },
399
418
  // $FlowFixMe
400
419
  body,
401
- }).catch(() => {
420
+ }).catch((e ) => {
421
+ // $FlowFixMe
422
+ e.skipSendToRemote = true;
423
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
424
+
402
425
  setTimeout(() => {
403
426
  if (isArray) {
404
427
  payload = payload.map(message => {
@@ -1536,6 +1559,9 @@ class Contact {
1536
1559
  }
1537
1560
 
1538
1561
  static parseMany(response ) {
1562
+ if (!response || !response.results) {
1563
+ return [];
1564
+ }
1539
1565
  return response.results.map(r => Contact.parse(r, response.column_types));
1540
1566
  }
1541
1567
 
@@ -2642,11 +2668,27 @@ class Meeting {
2642
2668
  });
2643
2669
  }
2644
2670
 
2671
+ static parseMany(items ) {
2672
+ if (!items) {
2673
+ return [];
2674
+ }
2675
+ return items.map(plain => Meeting.parse(plain));
2676
+ }
2677
+
2645
2678
  static newFrom(meeting ) {
2646
2679
  return newFrom(meeting, Meeting);
2647
2680
  }
2648
2681
 
2649
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number, persistent } = {}) {
2682
+ constructor({
2683
+ uuid,
2684
+ name,
2685
+ guestSipAuthorization,
2686
+ ownerUuids,
2687
+ port,
2688
+ uri,
2689
+ number,
2690
+ persistent,
2691
+ } = {}) {
2650
2692
  this.guestSipAuthorization = guestSipAuthorization;
2651
2693
  this.uri = uri;
2652
2694
  this.name = name;
@@ -2732,8 +2774,11 @@ var confdMethods = (client , baseUrl ) => ({
2732
2774
  }
2733
2775
  },
2734
2776
 
2735
- createMyMeeting: (name ) =>
2736
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
2777
+ getMyMeetings: () =>
2778
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2779
+
2780
+ createMyMeeting: (name , persistent ) =>
2781
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2737
2782
 
2738
2783
  deleteMyMeeting: (meetingUuid ) =>
2739
2784
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2829,6 +2874,10 @@ class ChatMessage {
2829
2874
 
2830
2875
 
2831
2876
  static parseMany(plain ) {
2877
+ if (!plain || !plain.items) {
2878
+ return [];
2879
+ }
2880
+
2832
2881
  return plain.items.map(item => ChatMessage.parse(item));
2833
2882
  }
2834
2883
 
@@ -2938,6 +2987,9 @@ class Voicemail {
2938
2987
  }
2939
2988
 
2940
2989
  static parseMany(plain ) {
2990
+ if (!plain) {
2991
+ return [];
2992
+ }
2941
2993
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
2942
2994
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
2943
2995
 
@@ -3047,6 +3099,9 @@ class Call {
3047
3099
 
3048
3100
 
3049
3101
  static parseMany(plain ) {
3102
+ if (!plain) {
3103
+ return [];
3104
+ }
3050
3105
  return plain.map((plainCall ) => Call.parse(plainCall));
3051
3106
  }
3052
3107
 
@@ -3245,6 +3300,9 @@ class Recording {
3245
3300
 
3246
3301
 
3247
3302
  static parseMany(recordings = []) {
3303
+ if (!recordings) {
3304
+ return [];
3305
+ }
3248
3306
  return recordings.map(item => Recording.parse(item));
3249
3307
  }
3250
3308
 
@@ -3346,6 +3404,10 @@ class CallLog {
3346
3404
  }
3347
3405
 
3348
3406
  static parseMany(plain ) {
3407
+ if (!plain || !plain.items) {
3408
+ return [];
3409
+ }
3410
+
3349
3411
  return plain.items.map(item => CallLog.parse(item));
3350
3412
  }
3351
3413
 
@@ -3918,6 +3980,9 @@ class ChatRoom {
3918
3980
 
3919
3981
 
3920
3982
  static parseMany(plain ) {
3983
+ if (!plain || !plain.items) {
3984
+ return [];
3985
+ }
3921
3986
  return plain.items.map(item => ChatRoom.parse(item));
3922
3987
  }
3923
3988
 
@@ -4913,6 +4978,7 @@ const AGENT_PAUSED = 'agent_paused';
4913
4978
  const AGENT_UNPAUSED = 'agent_unpaused';
4914
4979
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
4915
4980
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
4981
+ const MEETING_USER_PROGRESS = 'meeting_user_progress';
4916
4982
 
4917
4983
  const BLACKLIST_EVENTS = [
4918
4984
  CHAT_MESSAGE_SENT,
@@ -5263,6 +5329,7 @@ WebSocketClient.eventLists = [
5263
5329
  AGENT_UNPAUSED,
5264
5330
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
5265
5331
  CONFERENCE_ADHOC_DELETED,
5332
+ MEETING_USER_PROGRESS,
5266
5333
  ];
5267
5334
 
5268
5335
  var wazoWebsocket = {
@@ -5318,10 +5385,6 @@ const getSrflxOrRelay = (candidates ) =>
5318
5385
  candidates
5319
5386
  .filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
5320
5387
 
5321
- const areCandidateValid = (candidates ) =>
5322
- getSrflxOrRelay(candidates)
5323
- .length > 0;
5324
-
5325
5388
  const getVideoDirection = (sdp ) => {
5326
5389
  const parsedSdp = sdpParser__default['default'].parse(sdp);
5327
5390
  const videoMedia = parsedSdp.media.find(media => media.type === 'video');
@@ -5374,8 +5437,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
5374
5437
  /* global RTCSessionDescriptionInit, navigator */
5375
5438
 
5376
5439
  const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
5377
- const MAX_WAIT_FOR_ICE_TRIES = 20;
5378
- const WAIT_FOR_ICE_TIMEOUT = 500;
5379
5440
 
5380
5441
  // Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
5381
5442
  const wazoMediaStreamFactory = (constraints ) => {
@@ -5565,38 +5626,6 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
5565
5626
  this._peerConnection = undefined;
5566
5627
  }
5567
5628
 
5568
- async _waitForValidGatheredIce() {
5569
- let tries = 0;
5570
-
5571
- while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
5572
- wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
5573
- tries,
5574
- max: MAX_WAIT_FOR_ICE_TRIES,
5575
- });
5576
-
5577
- tries++;
5578
-
5579
- // eslint-disable-next-line no-await-in-loop
5580
- await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
5581
- }
5582
-
5583
- if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
5584
- const errorMsg = 'No valid candidates found, can\'t answer the call';
5585
- const error = new Error(errorMsg);
5586
- wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
5587
-
5588
- // Emit an error, because sip.js catches the exception and switch to status Terminated.
5589
- this.eventEmitter.emit('error', error);
5590
-
5591
- wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
5592
- }
5593
-
5594
- // eslint-disable-next-line
5595
- wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
5596
-
5597
- return this.getLocalSessionDescription();
5598
- }
5599
-
5600
5629
  // Overridden to send `inactive` in conference
5601
5630
  updateDirection(options , isConference = false,
5602
5631
  audioOnly = false) {
@@ -6291,7 +6320,9 @@ class WebRTCClient extends Emitter {
6291
6320
  const inviteOptions = {
6292
6321
  requestDelegate: {
6293
6322
  onAccept: (response ) => {
6294
- session.sessionDescriptionHandler.peerConnection.sfu = conference;
6323
+ if (session.sessionDescriptionHandler.peerConnection) {
6324
+ session.sessionDescriptionHandler.peerConnection.sfu = conference;
6325
+ }
6295
6326
  this._onAccepted(session, response.session, true);
6296
6327
  },
6297
6328
  onReject: (response ) => {
@@ -7163,6 +7194,16 @@ class WebRTCClient extends Emitter {
7163
7194
  return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
7164
7195
  }
7165
7196
 
7197
+ // Useful in a react-native environment when remoteMediaStream is not updated
7198
+ getRemoteVideoStreamFromPc(sessionId ) {
7199
+ const pc = this.getPeerConnection(sessionId);
7200
+ if (!pc) {
7201
+ return null;
7202
+ }
7203
+
7204
+ return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
7205
+ }
7206
+
7166
7207
  hasVideo(sessionId ) {
7167
7208
  return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
7168
7209
  }
@@ -7673,6 +7714,7 @@ class WebRTCClient extends Emitter {
7673
7714
  session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
7674
7715
 
7675
7716
  pc.oniceconnectionstatechange = () => {
7717
+ logger.info('on ice connection state changed', { state: pc.iceConnectionState });
7676
7718
  if (pc.iceConnectionState === 'disconnected') {
7677
7719
  this.eventEmitter.emit(ON_DISCONNECTED);
7678
7720
  }
@@ -7901,25 +7943,25 @@ class WebRTCClient extends Emitter {
7901
7943
 
7902
7944
  stats.forEach(report => {
7903
7945
  if (report.type === 'outbound-rtp' && report.kind === 'audio') {
7904
- audioBytesSent += report.bytesSent + report.headerBytesSent;
7946
+ audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
7905
7947
  }
7906
7948
  if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
7907
- audioBytesSent += report.bytesSent;
7949
+ audioBytesSent += Number(report.bytesSent);
7908
7950
  }
7909
7951
  if (report.type === 'outbound-rtp' && report.kind === 'video') {
7910
- videoBytesSent += report.bytesSent + report.headerBytesSent;
7952
+ videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
7911
7953
  }
7912
7954
  if (report.type === 'inbound-rtp' && report.kind === 'audio') {
7913
- packetsLost += report.packetsLost;
7914
- networkStats.packetsReceived = report.packetsReceived;
7915
- audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
7955
+ packetsLost += Number(report.packetsLost);
7956
+ networkStats.packetsReceived = Number(report.packetsReceived);
7957
+ audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
7916
7958
  }
7917
7959
  if (report.type === 'inbound-rtp' && report.kind === 'video') {
7918
- videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
7960
+ videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
7919
7961
  }
7920
7962
  if (report.type === 'outbound-rtp' && report.kind === 'video') {
7921
7963
  if ('framesPerSecond' in report) {
7922
- networkStats.framesPerSecond = report.framesPerSecond;
7964
+ networkStats.framesPerSecond = Number(report.framesPerSecond);
7923
7965
  }
7924
7966
  if ('framerateMean' in report) {
7925
7967
  // framerateMean is only available in FF
@@ -7927,32 +7969,36 @@ class WebRTCClient extends Emitter {
7927
7969
  }
7928
7970
  }
7929
7971
  if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
7930
- packetsLost += report.packetsLost;
7931
- networkStats.roundTripTime = report.roundTripTime;
7932
- networkStats.jitter = report.jitter;
7972
+ packetsLost += Number(report.packetsLost);
7973
+ networkStats.roundTripTime = Number(report.roundTripTime);
7974
+ networkStats.jitter = Number(report.jitter);
7933
7975
  }
7934
7976
  if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
7935
- packetsLost += report.packetsLost;
7977
+ packetsLost += Number(report.packetsLost);
7936
7978
  }
7937
7979
  if (report.type === 'transport') {
7938
- transportSent += report.bytesSent;
7939
- transportReceived += report.bytesReceived;
7980
+ transportSent += Number(report.bytesSent);
7981
+ transportReceived += Number(report.bytesReceived);
7940
7982
  }
7941
7983
  });
7942
7984
 
7943
7985
  networkStats.packetsLost = packetsLost;
7944
- networkStats.audioBytesSent = audioBytesSent;
7986
+ networkStats.totalAudioBytesSent = audioBytesSent;
7987
+ networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
7988
+ networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
7945
7989
  networkStats.audioBytesReceived = audioBytesReceived;
7946
- networkStats.videoBytesSent = videoBytesSent;
7947
- networkStats.videoBytesReceived = videoBytesReceived;
7990
+ networkStats.totalVideoBytesSent = videoBytesSent;
7991
+ networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
7992
+ networkStats.totalVideoBytesReceived = videoBytesReceived;
7993
+ networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
7994
+ networkStats.totalTransportSent = transportSent - lastTransportSent;
7948
7995
  networkStats.transportSent = transportSent;
7949
- networkStats.transportReceived = transportReceived;
7950
-
7951
- const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
7952
- + (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
7953
- + (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
7996
+ networkStats.totalTransportReceived = transportReceived;
7997
+ networkStats.transportReceived = transportReceived - lastTransportReceived;
7954
7998
 
7955
- networkStats.bandwidth = bandwidth;
7999
+ networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
8000
+ + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
8001
+ + networkStats.transportSent;
7956
8002
 
7957
8003
  this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
7958
8004
  this.sessionNetworkStats[sessionId].push(networkStats);
@@ -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 => {
@@ -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 wazoWebsocket = {