@wazo/sdk 0.37.20 → 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 (110) hide show
  1. package/dist/wazo-sdk.js +5 -5
  2. package/esm/__tests__/api-client.test.js +44 -5
  3. package/esm/__tests__/web-rtc-client.test.js +70 -15
  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 +25 -2
  9. package/esm/api/calld.js +25 -2
  10. package/esm/api/chatd.js +25 -2
  11. package/esm/api/confd.js +44 -5
  12. package/esm/api/ctid-ng.js +25 -2
  13. package/esm/api/dird.js +25 -2
  14. package/esm/api/webhookd.js +25 -2
  15. package/esm/api-client.js +44 -5
  16. package/esm/checker/Checker.js +72 -15
  17. package/esm/checker/checks/aor.js +44 -5
  18. package/esm/checker/checks/api.js +44 -5
  19. package/esm/checker/checks/index.js +72 -15
  20. package/esm/checker/checks/wazo-websocket.js +27 -2
  21. package/esm/checker/checks/webrtc-transport.js +70 -15
  22. package/esm/checker/checks/webrtc.js +70 -15
  23. package/esm/domain/AdHocAPIConference.js +44 -5
  24. package/esm/domain/Features.js +44 -5
  25. package/esm/domain/Meeting.js +14 -1
  26. package/esm/domain/Phone/CTIPhone.js +44 -5
  27. package/esm/domain/Phone/WebRTCPhone.js +32 -3
  28. package/esm/index.js +85 -16
  29. package/esm/lib/WazoSessionDescriptionHandler.js +25 -2
  30. package/esm/service/CallApi.js +44 -5
  31. package/esm/service/IssueReporter.js +25 -2
  32. package/esm/service/__tests__/IssueReporter.test.js +25 -2
  33. package/esm/service/getApiClient.js +44 -5
  34. package/esm/simple/Auth.js +85 -16
  35. package/esm/simple/Configuration.js +85 -16
  36. package/esm/simple/Directory.js +44 -5
  37. package/esm/simple/Phone.js +85 -16
  38. package/esm/simple/Websocket.js +28 -2
  39. package/esm/simple/index.js +85 -16
  40. package/esm/simple/room/LocalParticipant.js +85 -16
  41. package/esm/simple/room/Participant.js +85 -16
  42. package/esm/simple/room/RemoteParticipant.js +85 -16
  43. package/esm/simple/room/Room.js +85 -16
  44. package/esm/simple/room/SipRoom.js +85 -16
  45. package/esm/simple/room/Stream.js +85 -16
  46. package/esm/simple/room/__tests__/RemoteParticipant.test.js +85 -16
  47. package/esm/simple/utils.js +85 -16
  48. package/esm/utils/__tests__/api-requester.test.js +25 -2
  49. package/esm/utils/api-requester.js +25 -2
  50. package/esm/web-rtc-client.js +70 -15
  51. package/esm/websocket-client.js +28 -3
  52. package/lib/__tests__/api-client.test.js +44 -5
  53. package/lib/__tests__/web-rtc-client.test.js +70 -15
  54. package/lib/api/agentd.js +25 -2
  55. package/lib/api/amid.js +25 -2
  56. package/lib/api/application.js +25 -2
  57. package/lib/api/auth.js +25 -2
  58. package/lib/api/call-logd.js +25 -2
  59. package/lib/api/calld.js +25 -2
  60. package/lib/api/chatd.js +25 -2
  61. package/lib/api/confd.js +44 -5
  62. package/lib/api/ctid-ng.js +25 -2
  63. package/lib/api/dird.js +25 -2
  64. package/lib/api/webhookd.js +25 -2
  65. package/lib/api-client.js +44 -5
  66. package/lib/checker/Checker.js +72 -15
  67. package/lib/checker/checks/aor.js +44 -5
  68. package/lib/checker/checks/api.js +44 -5
  69. package/lib/checker/checks/index.js +72 -15
  70. package/lib/checker/checks/wazo-websocket.js +27 -2
  71. package/lib/checker/checks/webrtc-transport.js +70 -15
  72. package/lib/checker/checks/webrtc.js +70 -15
  73. package/lib/domain/AdHocAPIConference.js +44 -5
  74. package/lib/domain/Features.js +44 -5
  75. package/lib/domain/Meeting.js +14 -1
  76. package/lib/domain/Phone/CTIPhone.js +44 -5
  77. package/lib/domain/Phone/WebRTCPhone.js +32 -3
  78. package/lib/index.js +85 -16
  79. package/lib/lib/WazoSessionDescriptionHandler.js +25 -2
  80. package/lib/service/CallApi.js +44 -5
  81. package/lib/service/IssueReporter.js +25 -2
  82. package/lib/service/__tests__/IssueReporter.test.js +25 -2
  83. package/lib/service/getApiClient.js +44 -5
  84. package/lib/simple/Auth.js +85 -16
  85. package/lib/simple/Configuration.js +85 -16
  86. package/lib/simple/Directory.js +44 -5
  87. package/lib/simple/Phone.js +85 -16
  88. package/lib/simple/Websocket.js +28 -2
  89. package/lib/simple/index.js +85 -16
  90. package/lib/simple/room/LocalParticipant.js +85 -16
  91. package/lib/simple/room/Participant.js +85 -16
  92. package/lib/simple/room/RemoteParticipant.js +85 -16
  93. package/lib/simple/room/Room.js +85 -16
  94. package/lib/simple/room/SipRoom.js +85 -16
  95. package/lib/simple/room/Stream.js +85 -16
  96. package/lib/simple/room/__tests__/RemoteParticipant.test.js +85 -16
  97. package/lib/simple/utils.js +85 -16
  98. package/lib/utils/__tests__/api-requester.test.js +25 -2
  99. package/lib/utils/api-requester.js +25 -2
  100. package/lib/web-rtc-client.js +70 -15
  101. package/lib/websocket-client.js +28 -2
  102. package/package.json +1 -1
  103. package/src/api/confd.js +5 -2
  104. package/src/domain/Meeting.js +14 -1
  105. package/src/domain/Phone/WebRTCPhone.js +7 -1
  106. package/src/service/IssueReporter.js +25 -2
  107. package/src/simple/Phone.js +5 -0
  108. package/src/types/WebSocketMessage.js +5 -1
  109. package/src/web-rtc-client.js +26 -10
  110. package/src/websocket-client.js +2 -0
@@ -1634,6 +1634,7 @@ class IssueReporter {
1634
1634
 
1635
1635
 
1636
1636
 
1637
+
1637
1638
 
1638
1639
  constructor() {
1639
1640
  addLevelsTo(this);
@@ -1645,12 +1646,17 @@ class IssueReporter {
1645
1646
  this.bufferTimeout = null;
1646
1647
  this._boundProcessBuffer = this._processBuffer.bind(this);
1647
1648
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
1649
+ this._callback = null;
1648
1650
  }
1649
1651
 
1650
1652
  init() {
1651
1653
  this._catchConsole();
1652
1654
  }
1653
1655
 
1656
+ setCallback(cb ) {
1657
+ this._callback = cb;
1658
+ }
1659
+
1654
1660
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
1655
1661
  this.remoteClientConfiguration = configuration;
1656
1662
  }
@@ -1686,6 +1692,7 @@ class IssueReporter {
1686
1692
 
1687
1693
  // Handle category label
1688
1694
  let category = null;
1695
+ let skipSendToRemote = false;
1689
1696
  let extra = {};
1690
1697
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
1691
1698
  category = args[0].split('=')[1];
@@ -1701,6 +1708,7 @@ class IssueReporter {
1701
1708
  errorMessage: lastArg.message,
1702
1709
  errorStack: lastArg.stack,
1703
1710
  errorType: lastArg.constructor.name,
1711
+ skipSendToRemote: lastArg.skipSendToRemote,
1704
1712
  };
1705
1713
  } else {
1706
1714
  extra = lastArg;
@@ -1709,6 +1717,11 @@ class IssueReporter {
1709
1717
  args.splice(1, 1);
1710
1718
  }
1711
1719
 
1720
+ if (extra.skipSendToRemote) {
1721
+ skipSendToRemote = true;
1722
+ delete extra.skipSendToRemote;
1723
+ }
1724
+
1712
1725
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
1713
1726
  const message = args.join(', ');
1714
1727
  let consoleMessage = message;
@@ -1729,7 +1742,13 @@ class IssueReporter {
1729
1742
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
1730
1743
  oldMethod.apply(oldMethod, [date, consoleMessage]);
1731
1744
 
1732
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
1745
+ if (this._callback) {
1746
+ this._callback(level, consoleMessage);
1747
+ }
1748
+
1749
+ if (!skipSendToRemote) {
1750
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
1751
+ }
1733
1752
  }
1734
1753
 
1735
1754
  logRequest(url , options , response , start ) {
@@ -1874,7 +1893,11 @@ class IssueReporter {
1874
1893
  },
1875
1894
  // $FlowFixMe
1876
1895
  body,
1877
- }).catch(() => {
1896
+ }).catch((e ) => {
1897
+ // $FlowFixMe
1898
+ e.skipSendToRemote = true;
1899
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
1900
+
1878
1901
  setTimeout(() => {
1879
1902
  if (isArray) {
1880
1903
  payload = payload.map(message => {
@@ -2633,11 +2656,24 @@ class Meeting {
2633
2656
  });
2634
2657
  }
2635
2658
 
2659
+ static parseMany(items ) {
2660
+ return items.map(plain => Meeting.parse(plain));
2661
+ }
2662
+
2636
2663
  static newFrom(meeting ) {
2637
2664
  return newFrom(meeting, Meeting);
2638
2665
  }
2639
2666
 
2640
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number, persistent } = {}) {
2667
+ constructor({
2668
+ uuid,
2669
+ name,
2670
+ guestSipAuthorization,
2671
+ ownerUuids,
2672
+ port,
2673
+ uri,
2674
+ number,
2675
+ persistent,
2676
+ } = {}) {
2641
2677
  this.guestSipAuthorization = guestSipAuthorization;
2642
2678
  this.uri = uri;
2643
2679
  this.name = name;
@@ -2723,8 +2759,11 @@ var confdMethods = (client , baseUrl ) => ({
2723
2759
  }
2724
2760
  },
2725
2761
 
2726
- createMyMeeting: (name ) =>
2727
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
2762
+ getMyMeetings: () =>
2763
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2764
+
2765
+ createMyMeeting: (name , persistent ) =>
2766
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2728
2767
 
2729
2768
  deleteMyMeeting: (meetingUuid ) =>
2730
2769
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -6960,7 +6999,9 @@ class WebRTCClient extends Emitter {
6960
6999
  const inviteOptions = {
6961
7000
  requestDelegate: {
6962
7001
  onAccept: (response ) => {
6963
- session.sessionDescriptionHandler.peerConnection.sfu = conference;
7002
+ if (session.sessionDescriptionHandler.peerConnection) {
7003
+ session.sessionDescriptionHandler.peerConnection.sfu = conference;
7004
+ }
6964
7005
  this._onAccepted(session, response.session, true);
6965
7006
  },
6966
7007
  onReject: (response ) => {
@@ -7832,6 +7873,16 @@ class WebRTCClient extends Emitter {
7832
7873
  return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
7833
7874
  }
7834
7875
 
7876
+ // Useful in a react-native environment when remoteMediaStream is not updated
7877
+ getRemoteVideoStreamFromPc(sessionId ) {
7878
+ const pc = this.getPeerConnection(sessionId);
7879
+ if (!pc) {
7880
+ return null;
7881
+ }
7882
+
7883
+ return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
7884
+ }
7885
+
7835
7886
  hasVideo(sessionId ) {
7836
7887
  return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
7837
7888
  }
@@ -8610,18 +8661,22 @@ class WebRTCClient extends Emitter {
8610
8661
  });
8611
8662
 
8612
8663
  networkStats.packetsLost = packetsLost;
8613
- networkStats.audioBytesSent = audioBytesSent;
8664
+ networkStats.totalAudioBytesSent = audioBytesSent;
8665
+ networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
8666
+ networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
8614
8667
  networkStats.audioBytesReceived = audioBytesReceived;
8615
- networkStats.videoBytesSent = videoBytesSent;
8616
- networkStats.videoBytesReceived = videoBytesReceived;
8668
+ networkStats.totalVideoBytesSent = videoBytesSent;
8669
+ networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
8670
+ networkStats.totalVideoBytesReceived = videoBytesReceived;
8671
+ networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
8672
+ networkStats.totalTransportSent = transportSent - lastTransportSent;
8617
8673
  networkStats.transportSent = transportSent;
8618
- networkStats.transportReceived = transportReceived;
8674
+ networkStats.totalTransportReceived = transportReceived;
8675
+ networkStats.transportReceived = transportReceived - lastTransportReceived;
8619
8676
 
8620
- const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
8621
- + (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
8622
- + (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
8623
-
8624
- networkStats.bandwidth = bandwidth;
8677
+ networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
8678
+ + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
8679
+ + networkStats.transportSent;
8625
8680
 
8626
8681
  this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
8627
8682
  this.sessionNetworkStats[sessionId].push(networkStats);
@@ -9032,9 +9087,11 @@ class WebRTCPhone extends Emitter {
9032
9087
  case SessionState.Terminated: {
9033
9088
  logger$7.info('WebRTC phone - call terminated', { sipId: sipSession.id });
9034
9089
 
9090
+ // Should be called before `_onCallTerminated` or the callCount will not decrement...
9091
+ const callSession = this._createCallSession(sipSession);
9035
9092
  const wasCurrentSession = this._onCallTerminated(sipSession);
9036
9093
 
9037
- return this.eventEmitter.emit(ON_CALL_ENDED, this._createCallSession(sipSession), wasCurrentSession);
9094
+ return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
9038
9095
  }
9039
9096
  }
9040
9097
  });
@@ -9982,6 +10039,10 @@ class WebRTCPhone extends Emitter {
9982
10039
  return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
9983
10040
  }
9984
10041
 
10042
+ getRemoteVideoStreamFromPc(callSession ) {
10043
+ return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
10044
+ }
10045
+
9985
10046
  hasRemoteVideo(callSession ) {
9986
10047
  return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
9987
10048
  }
@@ -10665,6 +10726,11 @@ class Phone extends Emitter {
10665
10726
  return this.getRemoteVideoStream(callSession);
10666
10727
  }
10667
10728
 
10729
+ // Useful in a react-native environment when remoteMediaStream is not updated
10730
+ getRemoteVideoStreamFromPc(callSession ) {
10731
+ return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
10732
+ }
10733
+
10668
10734
  hasVideo(callSession ) {
10669
10735
  return this.phone ? this.phone.hasVideo(callSession) : false;
10670
10736
  }
@@ -10824,6 +10890,7 @@ const AGENT_PAUSED = 'agent_paused';
10824
10890
  const AGENT_UNPAUSED = 'agent_unpaused';
10825
10891
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
10826
10892
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
10893
+ const MEETING_USER_PROGRESS = 'meeting_user_progress';
10827
10894
 
10828
10895
  const BLACKLIST_EVENTS = [
10829
10896
  CHAT_MESSAGE_SENT,
@@ -11174,6 +11241,7 @@ WebSocketClient.eventLists = [
11174
11241
  AGENT_UNPAUSED,
11175
11242
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11176
11243
  CONFERENCE_ADHOC_DELETED,
11244
+ MEETING_USER_PROGRESS,
11177
11245
  ];
11178
11246
 
11179
11247
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
@@ -11244,6 +11312,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11244
11312
  AGENT_UNPAUSED: AGENT_UNPAUSED,
11245
11313
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11246
11314
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
11315
+ MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
11247
11316
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
11248
11317
  'default': WebSocketClient
11249
11318
  });
@@ -126,6 +126,7 @@ class IssueReporter {
126
126
 
127
127
 
128
128
 
129
+
129
130
 
130
131
  constructor() {
131
132
  addLevelsTo(this);
@@ -137,12 +138,17 @@ class IssueReporter {
137
138
  this.bufferTimeout = null;
138
139
  this._boundProcessBuffer = this._processBuffer.bind(this);
139
140
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
141
+ this._callback = null;
140
142
  }
141
143
 
142
144
  init() {
143
145
  this._catchConsole();
144
146
  }
145
147
 
148
+ setCallback(cb ) {
149
+ this._callback = cb;
150
+ }
151
+
146
152
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
147
153
  this.remoteClientConfiguration = configuration;
148
154
  }
@@ -178,6 +184,7 @@ class IssueReporter {
178
184
 
179
185
  // Handle category label
180
186
  let category = null;
187
+ let skipSendToRemote = false;
181
188
  let extra = {};
182
189
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
183
190
  category = args[0].split('=')[1];
@@ -193,6 +200,7 @@ class IssueReporter {
193
200
  errorMessage: lastArg.message,
194
201
  errorStack: lastArg.stack,
195
202
  errorType: lastArg.constructor.name,
203
+ skipSendToRemote: lastArg.skipSendToRemote,
196
204
  };
197
205
  } else {
198
206
  extra = lastArg;
@@ -201,6 +209,11 @@ class IssueReporter {
201
209
  args.splice(1, 1);
202
210
  }
203
211
 
212
+ if (extra.skipSendToRemote) {
213
+ skipSendToRemote = true;
214
+ delete extra.skipSendToRemote;
215
+ }
216
+
204
217
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
205
218
  const message = args.join(', ');
206
219
  let consoleMessage = message;
@@ -221,7 +234,13 @@ class IssueReporter {
221
234
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
222
235
  oldMethod.apply(oldMethod, [date, consoleMessage]);
223
236
 
224
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
237
+ if (this._callback) {
238
+ this._callback(level, consoleMessage);
239
+ }
240
+
241
+ if (!skipSendToRemote) {
242
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
243
+ }
225
244
  }
226
245
 
227
246
  logRequest(url , options , response , start ) {
@@ -366,7 +385,11 @@ class IssueReporter {
366
385
  },
367
386
  // $FlowFixMe
368
387
  body,
369
- }).catch(() => {
388
+ }).catch((e ) => {
389
+ // $FlowFixMe
390
+ e.skipSendToRemote = true;
391
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
392
+
370
393
  setTimeout(() => {
371
394
  if (isArray) {
372
395
  payload = payload.map(message => {
@@ -126,6 +126,7 @@ class IssueReporter {
126
126
 
127
127
 
128
128
 
129
+
129
130
 
130
131
  constructor() {
131
132
  addLevelsTo(this);
@@ -137,12 +138,17 @@ class IssueReporter {
137
138
  this.bufferTimeout = null;
138
139
  this._boundProcessBuffer = this._processBuffer.bind(this);
139
140
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
141
+ this._callback = null;
140
142
  }
141
143
 
142
144
  init() {
143
145
  this._catchConsole();
144
146
  }
145
147
 
148
+ setCallback(cb ) {
149
+ this._callback = cb;
150
+ }
151
+
146
152
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
147
153
  this.remoteClientConfiguration = configuration;
148
154
  }
@@ -178,6 +184,7 @@ class IssueReporter {
178
184
 
179
185
  // Handle category label
180
186
  let category = null;
187
+ let skipSendToRemote = false;
181
188
  let extra = {};
182
189
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
183
190
  category = args[0].split('=')[1];
@@ -193,6 +200,7 @@ class IssueReporter {
193
200
  errorMessage: lastArg.message,
194
201
  errorStack: lastArg.stack,
195
202
  errorType: lastArg.constructor.name,
203
+ skipSendToRemote: lastArg.skipSendToRemote,
196
204
  };
197
205
  } else {
198
206
  extra = lastArg;
@@ -201,6 +209,11 @@ class IssueReporter {
201
209
  args.splice(1, 1);
202
210
  }
203
211
 
212
+ if (extra.skipSendToRemote) {
213
+ skipSendToRemote = true;
214
+ delete extra.skipSendToRemote;
215
+ }
216
+
204
217
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
205
218
  const message = args.join(', ');
206
219
  let consoleMessage = message;
@@ -221,7 +234,13 @@ class IssueReporter {
221
234
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
222
235
  oldMethod.apply(oldMethod, [date, consoleMessage]);
223
236
 
224
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
237
+ if (this._callback) {
238
+ this._callback(level, consoleMessage);
239
+ }
240
+
241
+ if (!skipSendToRemote) {
242
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
243
+ }
225
244
  }
226
245
 
227
246
  logRequest(url , options , response , start ) {
@@ -366,7 +385,11 @@ class IssueReporter {
366
385
  },
367
386
  // $FlowFixMe
368
387
  body,
369
- }).catch(() => {
388
+ }).catch((e ) => {
389
+ // $FlowFixMe
390
+ e.skipSendToRemote = true;
391
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
392
+
370
393
  setTimeout(() => {
371
394
  if (isArray) {
372
395
  payload = payload.map(message => {
@@ -412,6 +412,7 @@ class IssueReporter {
412
412
 
413
413
 
414
414
 
415
+
415
416
 
416
417
  constructor() {
417
418
  addLevelsTo(this);
@@ -423,12 +424,17 @@ class IssueReporter {
423
424
  this.bufferTimeout = null;
424
425
  this._boundProcessBuffer = this._processBuffer.bind(this);
425
426
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
427
+ this._callback = null;
426
428
  }
427
429
 
428
430
  init() {
429
431
  this._catchConsole();
430
432
  }
431
433
 
434
+ setCallback(cb ) {
435
+ this._callback = cb;
436
+ }
437
+
432
438
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
433
439
  this.remoteClientConfiguration = configuration;
434
440
  }
@@ -464,6 +470,7 @@ class IssueReporter {
464
470
 
465
471
  // Handle category label
466
472
  let category = null;
473
+ let skipSendToRemote = false;
467
474
  let extra = {};
468
475
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
469
476
  category = args[0].split('=')[1];
@@ -479,6 +486,7 @@ class IssueReporter {
479
486
  errorMessage: lastArg.message,
480
487
  errorStack: lastArg.stack,
481
488
  errorType: lastArg.constructor.name,
489
+ skipSendToRemote: lastArg.skipSendToRemote,
482
490
  };
483
491
  } else {
484
492
  extra = lastArg;
@@ -487,6 +495,11 @@ class IssueReporter {
487
495
  args.splice(1, 1);
488
496
  }
489
497
 
498
+ if (extra.skipSendToRemote) {
499
+ skipSendToRemote = true;
500
+ delete extra.skipSendToRemote;
501
+ }
502
+
490
503
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
491
504
  const message = args.join(', ');
492
505
  let consoleMessage = message;
@@ -507,7 +520,13 @@ class IssueReporter {
507
520
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
508
521
  oldMethod.apply(oldMethod, [date, consoleMessage]);
509
522
 
510
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
523
+ if (this._callback) {
524
+ this._callback(level, consoleMessage);
525
+ }
526
+
527
+ if (!skipSendToRemote) {
528
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
529
+ }
511
530
  }
512
531
 
513
532
  logRequest(url , options , response , start ) {
@@ -652,7 +671,11 @@ class IssueReporter {
652
671
  },
653
672
  // $FlowFixMe
654
673
  body,
655
- }).catch(() => {
674
+ }).catch((e ) => {
675
+ // $FlowFixMe
676
+ e.skipSendToRemote = true;
677
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
678
+
656
679
  setTimeout(() => {
657
680
  if (isArray) {
658
681
  payload = payload.map(message => {
@@ -3195,11 +3218,24 @@ class Meeting {
3195
3218
  });
3196
3219
  }
3197
3220
 
3221
+ static parseMany(items ) {
3222
+ return items.map(plain => Meeting.parse(plain));
3223
+ }
3224
+
3198
3225
  static newFrom(meeting ) {
3199
3226
  return newFrom(meeting, Meeting);
3200
3227
  }
3201
3228
 
3202
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number, persistent } = {}) {
3229
+ constructor({
3230
+ uuid,
3231
+ name,
3232
+ guestSipAuthorization,
3233
+ ownerUuids,
3234
+ port,
3235
+ uri,
3236
+ number,
3237
+ persistent,
3238
+ } = {}) {
3203
3239
  this.guestSipAuthorization = guestSipAuthorization;
3204
3240
  this.uri = uri;
3205
3241
  this.name = name;
@@ -3285,8 +3321,11 @@ var confdMethods = (client , baseUrl ) => ({
3285
3321
  }
3286
3322
  },
3287
3323
 
3288
- createMyMeeting: (name ) =>
3289
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
3324
+ getMyMeetings: () =>
3325
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
3326
+
3327
+ createMyMeeting: (name , persistent ) =>
3328
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
3290
3329
 
3291
3330
  deleteMyMeeting: (meetingUuid ) =>
3292
3331
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -5701,7 +5740,9 @@ class WebRTCClient extends Emitter {
5701
5740
  const inviteOptions = {
5702
5741
  requestDelegate: {
5703
5742
  onAccept: (response ) => {
5704
- session.sessionDescriptionHandler.peerConnection.sfu = conference;
5743
+ if (session.sessionDescriptionHandler.peerConnection) {
5744
+ session.sessionDescriptionHandler.peerConnection.sfu = conference;
5745
+ }
5705
5746
  this._onAccepted(session, response.session, true);
5706
5747
  },
5707
5748
  onReject: (response ) => {
@@ -6573,6 +6614,16 @@ class WebRTCClient extends Emitter {
6573
6614
  return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
6574
6615
  }
6575
6616
 
6617
+ // Useful in a react-native environment when remoteMediaStream is not updated
6618
+ getRemoteVideoStreamFromPc(sessionId ) {
6619
+ const pc = this.getPeerConnection(sessionId);
6620
+ if (!pc) {
6621
+ return null;
6622
+ }
6623
+
6624
+ return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
6625
+ }
6626
+
6576
6627
  hasVideo(sessionId ) {
6577
6628
  return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
6578
6629
  }
@@ -7351,18 +7402,22 @@ class WebRTCClient extends Emitter {
7351
7402
  });
7352
7403
 
7353
7404
  networkStats.packetsLost = packetsLost;
7354
- networkStats.audioBytesSent = audioBytesSent;
7405
+ networkStats.totalAudioBytesSent = audioBytesSent;
7406
+ networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
7407
+ networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
7355
7408
  networkStats.audioBytesReceived = audioBytesReceived;
7356
- networkStats.videoBytesSent = videoBytesSent;
7357
- networkStats.videoBytesReceived = videoBytesReceived;
7409
+ networkStats.totalVideoBytesSent = videoBytesSent;
7410
+ networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
7411
+ networkStats.totalVideoBytesReceived = videoBytesReceived;
7412
+ networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
7413
+ networkStats.totalTransportSent = transportSent - lastTransportSent;
7358
7414
  networkStats.transportSent = transportSent;
7359
- networkStats.transportReceived = transportReceived;
7360
-
7361
- const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
7362
- + (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
7363
- + (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
7415
+ networkStats.totalTransportReceived = transportReceived;
7416
+ networkStats.transportReceived = transportReceived - lastTransportReceived;
7364
7417
 
7365
- networkStats.bandwidth = bandwidth;
7418
+ networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
7419
+ + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
7420
+ + networkStats.transportSent;
7366
7421
 
7367
7422
  this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
7368
7423
  this.sessionNetworkStats[sessionId].push(networkStats);
@@ -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 => {
@@ -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,7 +952,8 @@ 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
  export default WebSocketClient;
934
- export { AGENT_PAUSED, AGENT_STATUS_UPDATE, AGENT_UNPAUSED, APPLICATION_CALL_ANSWERED, APPLICATION_CALL_DELETED, APPLICATION_CALL_DTMF_RECEIVED, APPLICATION_CALL_ENTERED, APPLICATION_CALL_INITIATED, APPLICATION_CALL_UPDATED, APPLICATION_DESTINATION_NODE_CREATED, APPLICATION_NODE_CREATED, APPLICATION_NODE_DELETED, APPLICATION_NODE_UPDATED, APPLICATION_PLAYBACK_CREATED, APPLICATION_PLAYBACK_DELETED, APPLICATION_PROGRESS_STARTED, APPLICATION_PROGRESS_STOPPED, APPLICATION_SNOOP_CREATED, APPLICATION_SNOOP_DELETED, APPLICATION_SNOOP_UPDATED, APPLICATION_USER_OUTGOING_CALL_CREATED, AUTH_SESSION_EXPIRE_SOON, AUTH_USER_EXTERNAL_AUTH_ADDED, AUTH_USER_EXTERNAL_AUTH_DELETED, CALL_ANSWERED, CALL_CREATED, CALL_DTMF_CREATED, CALL_ENDED, CALL_HELD, CALL_LOG_USER_CREATED, CALL_RESUMED, CALL_UPDATED, CHATD_PRESENCE_UPDATED, CHATD_USER_ROOM_CREATED, CHATD_USER_ROOM_MESSAGE_CREATED, CHAT_MESSAGE_RECEIVED, CHAT_MESSAGE_SENT, CONFERENCE_ADHOC_DELETED, CONFERENCE_ADHOC_PARTICIPANT_LEFT, CONFERENCE_USER_PARTICIPANT_JOINED, CONFERENCE_USER_PARTICIPANT_LEFT, CONFERENCE_USER_PARTICIPANT_TALK_STARTED, CONFERENCE_USER_PARTICIPANT_TALK_STOPPED, ENDPOINT_STATUS_UPDATE, FAVORITE_ADDED, FAVORITE_DELETED, FAX_OUTBOUND_USER_CREATED, FAX_OUTBOUND_USER_FAILED, FAX_OUTBOUND_USER_SUCCEEDED, HEARTBEAT_ENGINE_VERSION, LINE_STATUS_UPDATED, MEETING_USER_PARTICIPANT_JOINED, MEETING_USER_PARTICIPANT_LEFT, SOCKET_EVENTS, SWITCHBOARD_HELD_CALLS_UPDATED, SWITCHBOARD_HELD_CALL_ANSWERED, SWITCHBOARD_QUEUED_CALLS_UPDATED, SWITCHBOARD_QUEUED_CALL_ANSWERED, TRUNK_STATUS_UPDATED, USERS_FORWARDS_BUSY_UPDATED, USERS_FORWARDS_NOANSWER_UPDATED, USERS_FORWARDS_UNCONDITIONAL_UPDATED, USERS_SERVICES_DND_UPDATED, USER_STATUS_UPDATE, USER_VOICEMAIL_MESSAGE_CREATED, USER_VOICEMAIL_MESSAGE_DELETED, USER_VOICEMAIL_MESSAGE_UPDATED };
959
+ export { AGENT_PAUSED, AGENT_STATUS_UPDATE, AGENT_UNPAUSED, APPLICATION_CALL_ANSWERED, APPLICATION_CALL_DELETED, APPLICATION_CALL_DTMF_RECEIVED, APPLICATION_CALL_ENTERED, APPLICATION_CALL_INITIATED, APPLICATION_CALL_UPDATED, APPLICATION_DESTINATION_NODE_CREATED, APPLICATION_NODE_CREATED, APPLICATION_NODE_DELETED, APPLICATION_NODE_UPDATED, APPLICATION_PLAYBACK_CREATED, APPLICATION_PLAYBACK_DELETED, APPLICATION_PROGRESS_STARTED, APPLICATION_PROGRESS_STOPPED, APPLICATION_SNOOP_CREATED, APPLICATION_SNOOP_DELETED, APPLICATION_SNOOP_UPDATED, APPLICATION_USER_OUTGOING_CALL_CREATED, AUTH_SESSION_EXPIRE_SOON, AUTH_USER_EXTERNAL_AUTH_ADDED, AUTH_USER_EXTERNAL_AUTH_DELETED, CALL_ANSWERED, CALL_CREATED, CALL_DTMF_CREATED, CALL_ENDED, CALL_HELD, CALL_LOG_USER_CREATED, CALL_RESUMED, CALL_UPDATED, CHATD_PRESENCE_UPDATED, CHATD_USER_ROOM_CREATED, CHATD_USER_ROOM_MESSAGE_CREATED, CHAT_MESSAGE_RECEIVED, CHAT_MESSAGE_SENT, CONFERENCE_ADHOC_DELETED, CONFERENCE_ADHOC_PARTICIPANT_LEFT, CONFERENCE_USER_PARTICIPANT_JOINED, CONFERENCE_USER_PARTICIPANT_LEFT, CONFERENCE_USER_PARTICIPANT_TALK_STARTED, CONFERENCE_USER_PARTICIPANT_TALK_STOPPED, ENDPOINT_STATUS_UPDATE, FAVORITE_ADDED, FAVORITE_DELETED, FAX_OUTBOUND_USER_CREATED, FAX_OUTBOUND_USER_FAILED, FAX_OUTBOUND_USER_SUCCEEDED, HEARTBEAT_ENGINE_VERSION, LINE_STATUS_UPDATED, MEETING_USER_PARTICIPANT_JOINED, MEETING_USER_PARTICIPANT_LEFT, MEETING_USER_PROGRESS, SOCKET_EVENTS, SWITCHBOARD_HELD_CALLS_UPDATED, SWITCHBOARD_HELD_CALL_ANSWERED, SWITCHBOARD_QUEUED_CALLS_UPDATED, SWITCHBOARD_QUEUED_CALL_ANSWERED, TRUNK_STATUS_UPDATED, USERS_FORWARDS_BUSY_UPDATED, USERS_FORWARDS_NOANSWER_UPDATED, USERS_FORWARDS_UNCONDITIONAL_UPDATED, USERS_SERVICES_DND_UPDATED, USER_STATUS_UPDATE, USER_VOICEMAIL_MESSAGE_CREATED, USER_VOICEMAIL_MESSAGE_DELETED, USER_VOICEMAIL_MESSAGE_UPDATED };