@wazo/sdk 0.37.18 → 0.37.22
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.
- package/dist/wazo-sdk.js +13 -5
- package/esm/__tests__/api-client.test.js +52 -9
- package/esm/__tests__/web-rtc-client.test.js +80 -20
- package/esm/api/agentd.js +27 -4
- package/esm/api/amid.js +27 -4
- package/esm/api/application.js +27 -4
- package/esm/api/auth.js +29 -5
- package/esm/api/call-logd.js +29 -6
- package/esm/api/calld.js +27 -4
- package/esm/api/chatd.js +27 -4
- package/esm/api/confd.js +51 -8
- package/esm/api/ctid-ng.js +27 -4
- package/esm/api/dird.js +27 -4
- package/esm/api/webhookd.js +27 -4
- package/esm/api-client.js +54 -11
- package/esm/checker/Checker.js +83 -21
- package/esm/checker/checks/aor.js +54 -11
- package/esm/checker/checks/api.js +54 -11
- package/esm/checker/checks/ice-ipv4.js +1 -1
- package/esm/checker/checks/index.js +84 -22
- package/esm/checker/checks/symmetric-nat.js +1 -1
- package/esm/checker/checks/wazo-websocket.js +29 -4
- package/esm/checker/checks/webrtc-transport.js +82 -22
- package/esm/checker/checks/webrtc.js +82 -22
- package/esm/domain/AdHocAPIConference.js +54 -11
- package/esm/domain/Agent.js +1 -1
- package/esm/domain/BadResponse.js +1 -1
- package/esm/domain/Call.js +1 -1
- package/esm/domain/CallLog.js +3 -3
- package/esm/domain/CallSession.js +1 -1
- package/esm/domain/ChatMessage.js +1 -1
- package/esm/domain/ChatRoom.js +1 -1
- package/esm/domain/Contact.js +2 -1
- package/esm/domain/Country.js +1 -1
- package/esm/domain/Device/DebugDevice.js +1 -1
- package/esm/domain/ExternalApp.js +1 -1
- package/esm/domain/Features.js +54 -10
- package/esm/domain/ForwardOption.js +2 -1
- package/esm/domain/IndirectTransfer.js +1 -1
- package/esm/domain/Line.js +1 -1
- package/esm/domain/Meeting.js +20 -3
- package/esm/domain/NotificationOptions.js +1 -1
- package/esm/domain/Phone/CTIPhone.js +55 -11
- package/esm/domain/Phone/WebRTCPhone.js +39 -6
- package/esm/domain/Profile.js +2 -1
- package/esm/domain/Recording.js +2 -2
- package/esm/domain/Relocation.js +1 -1
- package/esm/domain/Room.js +1 -1
- package/esm/domain/ServerError.js +1 -1
- package/esm/domain/Session.js +2 -2
- package/esm/domain/SipLine.js +1 -1
- package/esm/domain/Subscription.js +1 -1
- package/esm/domain/SwitchboardCall.js +1 -1
- package/esm/domain/Voicemail.js +1 -1
- package/esm/domain/__tests__/CallLog.test.js +2 -2
- package/esm/index.js +101 -24
- package/esm/lib/WazoSessionDescriptionHandler.js +28 -4
- package/esm/service/CallApi.js +54 -11
- package/esm/service/IssueReporter.js +27 -4
- package/esm/service/__tests__/IssueReporter.test.js +26 -3
- package/esm/service/getApiClient.js +55 -11
- package/esm/simple/Auth.js +101 -23
- package/esm/simple/Configuration.js +100 -23
- package/esm/simple/Directory.js +53 -10
- package/esm/simple/Phone.js +100 -23
- package/esm/simple/Websocket.js +30 -4
- package/esm/simple/index.js +100 -23
- package/esm/simple/room/LocalParticipant.js +113 -40
- package/esm/simple/room/Participant.js +112 -37
- package/esm/simple/room/RemoteParticipant.js +114 -41
- package/esm/simple/room/Room.js +113 -37
- package/esm/simple/room/SipRoom.js +101 -26
- package/esm/simple/room/Stream.js +101 -26
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +99 -22
- package/esm/simple/utils.js +99 -22
- package/esm/utils/Emitter.js +1 -1
- package/esm/utils/Heartbeat.js +1 -1
- package/esm/utils/__tests__/api-requester.test.js +26 -3
- package/esm/utils/api-requester.js +28 -4
- package/esm/utils/compare-version.js +1 -1
- package/esm/utils/isMobile.js +1 -1
- package/esm/utils/new-from.js +1 -1
- package/esm/utils/once.js +1 -1
- package/esm/utils/update-from.js +1 -1
- package/esm/web-rtc-client.js +83 -22
- package/esm/websocket-client.js +30 -4
- package/lib/__tests__/api-client.test.js +61 -18
- package/lib/__tests__/web-rtc-client.test.js +97 -37
- package/lib/api/agentd.js +27 -4
- package/lib/api/amid.js +27 -4
- package/lib/api/application.js +27 -4
- package/lib/api/auth.js +28 -5
- package/lib/api/call-logd.js +34 -11
- package/lib/api/calld.js +30 -7
- package/lib/api/chatd.js +28 -5
- package/lib/api/confd.js +51 -8
- package/lib/api/ctid-ng.js +30 -7
- package/lib/api/dird.js +27 -4
- package/lib/api/webhookd.js +27 -4
- package/lib/api-client.js +61 -18
- package/lib/checker/Checker.js +100 -38
- package/lib/checker/checks/aor.js +61 -18
- package/lib/checker/checks/api.js +61 -18
- package/lib/checker/checks/index.js +100 -38
- package/lib/checker/checks/wazo-websocket.js +31 -6
- package/lib/checker/checks/webrtc-transport.js +97 -37
- package/lib/checker/checks/webrtc.js +97 -37
- package/lib/domain/AdHocAPIConference.js +61 -18
- package/lib/domain/Call.js +1 -1
- package/lib/domain/CallLog.js +7 -7
- package/lib/domain/ChatMessage.js +1 -1
- package/lib/domain/Contact.js +1 -1
- package/lib/domain/Features.js +62 -19
- package/lib/domain/ForwardOption.js +1 -1
- package/lib/domain/Meeting.js +19 -2
- package/lib/domain/Phone/CTIPhone.js +63 -20
- package/lib/domain/Phone/WebRTCPhone.js +40 -8
- package/lib/domain/Profile.js +1 -1
- package/lib/domain/Recording.js +3 -3
- package/lib/domain/Voicemail.js +1 -1
- package/lib/domain/__tests__/Call.test.js +1 -1
- package/lib/domain/__tests__/CallLog.test.js +13 -13
- package/lib/domain/__tests__/Voicemail.test.js +1 -1
- package/lib/index.js +120 -43
- package/lib/lib/WazoSessionDescriptionHandler.js +32 -9
- package/lib/service/CallApi.js +61 -18
- package/lib/service/IssueReporter.js +27 -4
- package/lib/service/__tests__/IssueReporter.test.js +27 -4
- package/lib/service/getApiClient.js +62 -19
- package/lib/simple/Auth.js +119 -42
- package/lib/simple/Configuration.js +118 -41
- package/lib/simple/Directory.js +61 -18
- package/lib/simple/Phone.js +118 -41
- package/lib/simple/Websocket.js +32 -6
- package/lib/simple/index.js +118 -41
- package/lib/simple/room/LocalParticipant.js +132 -59
- package/lib/simple/room/Participant.js +130 -55
- package/lib/simple/room/RemoteParticipant.js +133 -60
- package/lib/simple/room/Room.js +131 -56
- package/lib/simple/room/SipRoom.js +120 -45
- package/lib/simple/room/Stream.js +120 -45
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +118 -41
- package/lib/simple/utils.js +118 -41
- package/lib/utils/Emitter.js +1 -1
- package/lib/utils/PhoneNumberUtil.js +2 -2
- package/lib/utils/__tests__/PhoneNumberUtil.test.js +2 -2
- package/lib/utils/__tests__/api-requester.test.js +27 -4
- package/lib/utils/__tests__/sdp.test.js +12 -12
- package/lib/utils/api-requester.js +28 -5
- package/lib/utils/sdp.js +10 -10
- package/lib/web-rtc-client.js +98 -38
- package/lib/websocket-client.js +33 -7
- package/package.json +2 -2
- package/src/api/confd.js +5 -2
- package/src/domain/CallLog.js +1 -1
- package/src/domain/Meeting.js +19 -2
- package/src/domain/Phone/WebRTCPhone.js +11 -2
- package/src/domain/Recording.js +1 -1
- package/src/service/IssueReporter.js +26 -3
- package/src/simple/Phone.js +5 -0
- package/src/types/WebSocketMessage.js +5 -1
- package/src/web-rtc-client.js +28 -11
- package/src/websocket-client.js +2 -0
package/lib/api/amid.js
CHANGED
|
@@ -71,6 +71,7 @@ class IssueReporter {
|
|
|
71
71
|
|
|
72
72
|
|
|
73
73
|
|
|
74
|
+
|
|
74
75
|
|
|
75
76
|
constructor() {
|
|
76
77
|
addLevelsTo(this);
|
|
@@ -82,12 +83,17 @@ class IssueReporter {
|
|
|
82
83
|
this.bufferTimeout = null;
|
|
83
84
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
84
85
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
86
|
+
this._callback = null;
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
init() {
|
|
88
90
|
this._catchConsole();
|
|
89
91
|
}
|
|
90
92
|
|
|
93
|
+
setCallback(cb ) {
|
|
94
|
+
this._callback = cb;
|
|
95
|
+
}
|
|
96
|
+
|
|
91
97
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
92
98
|
this.remoteClientConfiguration = configuration;
|
|
93
99
|
}
|
|
@@ -123,6 +129,7 @@ class IssueReporter {
|
|
|
123
129
|
|
|
124
130
|
// Handle category label
|
|
125
131
|
let category = null;
|
|
132
|
+
let skipSendToRemote = false;
|
|
126
133
|
let extra = {};
|
|
127
134
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
128
135
|
category = args[0].split('=')[1];
|
|
@@ -138,6 +145,7 @@ class IssueReporter {
|
|
|
138
145
|
errorMessage: lastArg.message,
|
|
139
146
|
errorStack: lastArg.stack,
|
|
140
147
|
errorType: lastArg.constructor.name,
|
|
148
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
141
149
|
};
|
|
142
150
|
} else {
|
|
143
151
|
extra = lastArg;
|
|
@@ -146,7 +154,12 @@ class IssueReporter {
|
|
|
146
154
|
args.splice(1, 1);
|
|
147
155
|
}
|
|
148
156
|
|
|
149
|
-
|
|
157
|
+
if (extra.skipSendToRemote) {
|
|
158
|
+
skipSendToRemote = true;
|
|
159
|
+
delete extra.skipSendToRemote;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
150
163
|
const message = args.join(', ');
|
|
151
164
|
let consoleMessage = message;
|
|
152
165
|
|
|
@@ -166,7 +179,13 @@ class IssueReporter {
|
|
|
166
179
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
167
180
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
168
181
|
|
|
169
|
-
this.
|
|
182
|
+
if (this._callback) {
|
|
183
|
+
this._callback(level, consoleMessage);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (!skipSendToRemote) {
|
|
187
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
188
|
+
}
|
|
170
189
|
}
|
|
171
190
|
|
|
172
191
|
logRequest(url , options , response , start ) {
|
|
@@ -311,7 +330,11 @@ class IssueReporter {
|
|
|
311
330
|
},
|
|
312
331
|
// $FlowFixMe
|
|
313
332
|
body,
|
|
314
|
-
}).catch(() => {
|
|
333
|
+
}).catch((e ) => {
|
|
334
|
+
// $FlowFixMe
|
|
335
|
+
e.skipSendToRemote = true;
|
|
336
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
337
|
+
|
|
315
338
|
setTimeout(() => {
|
|
316
339
|
if (isArray) {
|
|
317
340
|
payload = payload.map(message => {
|
|
@@ -323,7 +346,7 @@ class IssueReporter {
|
|
|
323
346
|
payload._retry = retry + 1;
|
|
324
347
|
}
|
|
325
348
|
|
|
326
|
-
this._sendDebugToGrafana(
|
|
349
|
+
this._sendDebugToGrafana(payload, retry + 1);
|
|
327
350
|
}, 5000 + retry * 1000);
|
|
328
351
|
});
|
|
329
352
|
}
|
package/lib/api/application.js
CHANGED
|
@@ -132,6 +132,7 @@ class IssueReporter {
|
|
|
132
132
|
|
|
133
133
|
|
|
134
134
|
|
|
135
|
+
|
|
135
136
|
|
|
136
137
|
constructor() {
|
|
137
138
|
addLevelsTo(this);
|
|
@@ -143,12 +144,17 @@ class IssueReporter {
|
|
|
143
144
|
this.bufferTimeout = null;
|
|
144
145
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
145
146
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
147
|
+
this._callback = null;
|
|
146
148
|
}
|
|
147
149
|
|
|
148
150
|
init() {
|
|
149
151
|
this._catchConsole();
|
|
150
152
|
}
|
|
151
153
|
|
|
154
|
+
setCallback(cb ) {
|
|
155
|
+
this._callback = cb;
|
|
156
|
+
}
|
|
157
|
+
|
|
152
158
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
153
159
|
this.remoteClientConfiguration = configuration;
|
|
154
160
|
}
|
|
@@ -184,6 +190,7 @@ class IssueReporter {
|
|
|
184
190
|
|
|
185
191
|
// Handle category label
|
|
186
192
|
let category = null;
|
|
193
|
+
let skipSendToRemote = false;
|
|
187
194
|
let extra = {};
|
|
188
195
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
189
196
|
category = args[0].split('=')[1];
|
|
@@ -199,6 +206,7 @@ class IssueReporter {
|
|
|
199
206
|
errorMessage: lastArg.message,
|
|
200
207
|
errorStack: lastArg.stack,
|
|
201
208
|
errorType: lastArg.constructor.name,
|
|
209
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
202
210
|
};
|
|
203
211
|
} else {
|
|
204
212
|
extra = lastArg;
|
|
@@ -207,7 +215,12 @@ class IssueReporter {
|
|
|
207
215
|
args.splice(1, 1);
|
|
208
216
|
}
|
|
209
217
|
|
|
210
|
-
|
|
218
|
+
if (extra.skipSendToRemote) {
|
|
219
|
+
skipSendToRemote = true;
|
|
220
|
+
delete extra.skipSendToRemote;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
211
224
|
const message = args.join(', ');
|
|
212
225
|
let consoleMessage = message;
|
|
213
226
|
|
|
@@ -227,7 +240,13 @@ class IssueReporter {
|
|
|
227
240
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
228
241
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
229
242
|
|
|
230
|
-
this.
|
|
243
|
+
if (this._callback) {
|
|
244
|
+
this._callback(level, consoleMessage);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (!skipSendToRemote) {
|
|
248
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
249
|
+
}
|
|
231
250
|
}
|
|
232
251
|
|
|
233
252
|
logRequest(url , options , response , start ) {
|
|
@@ -372,7 +391,11 @@ class IssueReporter {
|
|
|
372
391
|
},
|
|
373
392
|
// $FlowFixMe
|
|
374
393
|
body,
|
|
375
|
-
}).catch(() => {
|
|
394
|
+
}).catch((e ) => {
|
|
395
|
+
// $FlowFixMe
|
|
396
|
+
e.skipSendToRemote = true;
|
|
397
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
398
|
+
|
|
376
399
|
setTimeout(() => {
|
|
377
400
|
if (isArray) {
|
|
378
401
|
payload = payload.map(message => {
|
|
@@ -384,7 +407,7 @@ class IssueReporter {
|
|
|
384
407
|
payload._retry = retry + 1;
|
|
385
408
|
}
|
|
386
409
|
|
|
387
|
-
this._sendDebugToGrafana(
|
|
410
|
+
this._sendDebugToGrafana(payload, retry + 1);
|
|
388
411
|
}, 5000 + retry * 1000);
|
|
389
412
|
});
|
|
390
413
|
}
|
package/lib/api/auth.js
CHANGED
|
@@ -135,6 +135,7 @@ class IssueReporter {
|
|
|
135
135
|
|
|
136
136
|
|
|
137
137
|
|
|
138
|
+
|
|
138
139
|
|
|
139
140
|
constructor() {
|
|
140
141
|
addLevelsTo(this);
|
|
@@ -146,12 +147,17 @@ class IssueReporter {
|
|
|
146
147
|
this.bufferTimeout = null;
|
|
147
148
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
148
149
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
150
|
+
this._callback = null;
|
|
149
151
|
}
|
|
150
152
|
|
|
151
153
|
init() {
|
|
152
154
|
this._catchConsole();
|
|
153
155
|
}
|
|
154
156
|
|
|
157
|
+
setCallback(cb ) {
|
|
158
|
+
this._callback = cb;
|
|
159
|
+
}
|
|
160
|
+
|
|
155
161
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
156
162
|
this.remoteClientConfiguration = configuration;
|
|
157
163
|
}
|
|
@@ -187,6 +193,7 @@ class IssueReporter {
|
|
|
187
193
|
|
|
188
194
|
// Handle category label
|
|
189
195
|
let category = null;
|
|
196
|
+
let skipSendToRemote = false;
|
|
190
197
|
let extra = {};
|
|
191
198
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
192
199
|
category = args[0].split('=')[1];
|
|
@@ -202,6 +209,7 @@ class IssueReporter {
|
|
|
202
209
|
errorMessage: lastArg.message,
|
|
203
210
|
errorStack: lastArg.stack,
|
|
204
211
|
errorType: lastArg.constructor.name,
|
|
212
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
205
213
|
};
|
|
206
214
|
} else {
|
|
207
215
|
extra = lastArg;
|
|
@@ -210,7 +218,12 @@ class IssueReporter {
|
|
|
210
218
|
args.splice(1, 1);
|
|
211
219
|
}
|
|
212
220
|
|
|
213
|
-
|
|
221
|
+
if (extra.skipSendToRemote) {
|
|
222
|
+
skipSendToRemote = true;
|
|
223
|
+
delete extra.skipSendToRemote;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
214
227
|
const message = args.join(', ');
|
|
215
228
|
let consoleMessage = message;
|
|
216
229
|
|
|
@@ -230,7 +243,13 @@ class IssueReporter {
|
|
|
230
243
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
231
244
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
232
245
|
|
|
233
|
-
this.
|
|
246
|
+
if (this._callback) {
|
|
247
|
+
this._callback(level, consoleMessage);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (!skipSendToRemote) {
|
|
251
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
252
|
+
}
|
|
234
253
|
}
|
|
235
254
|
|
|
236
255
|
logRequest(url , options , response , start ) {
|
|
@@ -375,7 +394,11 @@ class IssueReporter {
|
|
|
375
394
|
},
|
|
376
395
|
// $FlowFixMe
|
|
377
396
|
body,
|
|
378
|
-
}).catch(() => {
|
|
397
|
+
}).catch((e ) => {
|
|
398
|
+
// $FlowFixMe
|
|
399
|
+
e.skipSendToRemote = true;
|
|
400
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
401
|
+
|
|
379
402
|
setTimeout(() => {
|
|
380
403
|
if (isArray) {
|
|
381
404
|
payload = payload.map(message => {
|
|
@@ -387,7 +410,7 @@ class IssueReporter {
|
|
|
387
410
|
payload._retry = retry + 1;
|
|
388
411
|
}
|
|
389
412
|
|
|
390
|
-
this._sendDebugToGrafana(
|
|
413
|
+
this._sendDebugToGrafana(payload, retry + 1);
|
|
391
414
|
}, 5000 + retry * 1000);
|
|
392
415
|
});
|
|
393
416
|
}
|
|
@@ -1170,4 +1193,4 @@ var auth = (client , baseUrl ) => ({
|
|
|
1170
1193
|
});
|
|
1171
1194
|
|
|
1172
1195
|
exports.DETAULT_EXPIRATION = DETAULT_EXPIRATION;
|
|
1173
|
-
exports
|
|
1196
|
+
exports.default = auth;
|
package/lib/api/call-logd.js
CHANGED
|
@@ -72,6 +72,7 @@ class IssueReporter {
|
|
|
72
72
|
|
|
73
73
|
|
|
74
74
|
|
|
75
|
+
|
|
75
76
|
|
|
76
77
|
constructor() {
|
|
77
78
|
addLevelsTo(this);
|
|
@@ -83,12 +84,17 @@ class IssueReporter {
|
|
|
83
84
|
this.bufferTimeout = null;
|
|
84
85
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
85
86
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
87
|
+
this._callback = null;
|
|
86
88
|
}
|
|
87
89
|
|
|
88
90
|
init() {
|
|
89
91
|
this._catchConsole();
|
|
90
92
|
}
|
|
91
93
|
|
|
94
|
+
setCallback(cb ) {
|
|
95
|
+
this._callback = cb;
|
|
96
|
+
}
|
|
97
|
+
|
|
92
98
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
93
99
|
this.remoteClientConfiguration = configuration;
|
|
94
100
|
}
|
|
@@ -124,6 +130,7 @@ class IssueReporter {
|
|
|
124
130
|
|
|
125
131
|
// Handle category label
|
|
126
132
|
let category = null;
|
|
133
|
+
let skipSendToRemote = false;
|
|
127
134
|
let extra = {};
|
|
128
135
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
129
136
|
category = args[0].split('=')[1];
|
|
@@ -139,6 +146,7 @@ class IssueReporter {
|
|
|
139
146
|
errorMessage: lastArg.message,
|
|
140
147
|
errorStack: lastArg.stack,
|
|
141
148
|
errorType: lastArg.constructor.name,
|
|
149
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
142
150
|
};
|
|
143
151
|
} else {
|
|
144
152
|
extra = lastArg;
|
|
@@ -147,7 +155,12 @@ class IssueReporter {
|
|
|
147
155
|
args.splice(1, 1);
|
|
148
156
|
}
|
|
149
157
|
|
|
150
|
-
|
|
158
|
+
if (extra.skipSendToRemote) {
|
|
159
|
+
skipSendToRemote = true;
|
|
160
|
+
delete extra.skipSendToRemote;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
151
164
|
const message = args.join(', ');
|
|
152
165
|
let consoleMessage = message;
|
|
153
166
|
|
|
@@ -167,7 +180,13 @@ class IssueReporter {
|
|
|
167
180
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
168
181
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
169
182
|
|
|
170
|
-
this.
|
|
183
|
+
if (this._callback) {
|
|
184
|
+
this._callback(level, consoleMessage);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (!skipSendToRemote) {
|
|
188
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
189
|
+
}
|
|
171
190
|
}
|
|
172
191
|
|
|
173
192
|
logRequest(url , options , response , start ) {
|
|
@@ -312,7 +331,11 @@ class IssueReporter {
|
|
|
312
331
|
},
|
|
313
332
|
// $FlowFixMe
|
|
314
333
|
body,
|
|
315
|
-
}).catch(() => {
|
|
334
|
+
}).catch((e ) => {
|
|
335
|
+
// $FlowFixMe
|
|
336
|
+
e.skipSendToRemote = true;
|
|
337
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
338
|
+
|
|
316
339
|
setTimeout(() => {
|
|
317
340
|
if (isArray) {
|
|
318
341
|
payload = payload.map(message => {
|
|
@@ -324,7 +347,7 @@ class IssueReporter {
|
|
|
324
347
|
payload._retry = retry + 1;
|
|
325
348
|
}
|
|
326
349
|
|
|
327
|
-
this._sendDebugToGrafana(
|
|
350
|
+
this._sendDebugToGrafana(payload, retry + 1);
|
|
328
351
|
}, 5000 + retry * 1000);
|
|
329
352
|
});
|
|
330
353
|
}
|
|
@@ -426,7 +449,7 @@ class Recording {
|
|
|
426
449
|
|
|
427
450
|
|
|
428
451
|
|
|
429
|
-
static parseMany(recordings
|
|
452
|
+
static parseMany(recordings = []) {
|
|
430
453
|
return recordings.map(item => Recording.parse(item));
|
|
431
454
|
}
|
|
432
455
|
|
|
@@ -434,8 +457,8 @@ class Recording {
|
|
|
434
457
|
return new Recording({
|
|
435
458
|
deleted: plain.deleted,
|
|
436
459
|
fileName: plain.filename,
|
|
437
|
-
end: plain.end_time ? moment__default[
|
|
438
|
-
start: moment__default[
|
|
460
|
+
end: plain.end_time ? moment__default['default'](plain.end_time).toDate() : null,
|
|
461
|
+
start: moment__default['default'](plain.start_time).toDate(),
|
|
439
462
|
uuid: plain.uuid,
|
|
440
463
|
});
|
|
441
464
|
}
|
|
@@ -533,7 +556,7 @@ class CallLog {
|
|
|
533
556
|
|
|
534
557
|
static parse(plain ) {
|
|
535
558
|
return new CallLog({
|
|
536
|
-
answer: plain.answer ? moment__default[
|
|
559
|
+
answer: plain.answer ? moment__default['default'](plain.answer).toDate() : null,
|
|
537
560
|
answered: plain.answered,
|
|
538
561
|
callDirection: plain.call_direction,
|
|
539
562
|
destination: {
|
|
@@ -550,9 +573,9 @@ class CallLog {
|
|
|
550
573
|
},
|
|
551
574
|
id: plain.id,
|
|
552
575
|
duration: (plain.duration || 0) * 1000, // duration is in seconds
|
|
553
|
-
start: moment__default[
|
|
554
|
-
end: plain.end ? moment__default[
|
|
555
|
-
recordings: Recording.parseMany(plain.recordings),
|
|
576
|
+
start: moment__default['default'](plain.start).toDate(),
|
|
577
|
+
end: plain.end ? moment__default['default'](plain.end).toDate() : null,
|
|
578
|
+
recordings: Recording.parseMany(plain.recordings || []),
|
|
556
579
|
});
|
|
557
580
|
}
|
|
558
581
|
|
package/lib/api/calld.js
CHANGED
|
@@ -133,6 +133,7 @@ class IssueReporter {
|
|
|
133
133
|
|
|
134
134
|
|
|
135
135
|
|
|
136
|
+
|
|
136
137
|
|
|
137
138
|
constructor() {
|
|
138
139
|
addLevelsTo(this);
|
|
@@ -144,12 +145,17 @@ class IssueReporter {
|
|
|
144
145
|
this.bufferTimeout = null;
|
|
145
146
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
146
147
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
148
|
+
this._callback = null;
|
|
147
149
|
}
|
|
148
150
|
|
|
149
151
|
init() {
|
|
150
152
|
this._catchConsole();
|
|
151
153
|
}
|
|
152
154
|
|
|
155
|
+
setCallback(cb ) {
|
|
156
|
+
this._callback = cb;
|
|
157
|
+
}
|
|
158
|
+
|
|
153
159
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
154
160
|
this.remoteClientConfiguration = configuration;
|
|
155
161
|
}
|
|
@@ -185,6 +191,7 @@ class IssueReporter {
|
|
|
185
191
|
|
|
186
192
|
// Handle category label
|
|
187
193
|
let category = null;
|
|
194
|
+
let skipSendToRemote = false;
|
|
188
195
|
let extra = {};
|
|
189
196
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
190
197
|
category = args[0].split('=')[1];
|
|
@@ -200,6 +207,7 @@ class IssueReporter {
|
|
|
200
207
|
errorMessage: lastArg.message,
|
|
201
208
|
errorStack: lastArg.stack,
|
|
202
209
|
errorType: lastArg.constructor.name,
|
|
210
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
203
211
|
};
|
|
204
212
|
} else {
|
|
205
213
|
extra = lastArg;
|
|
@@ -208,7 +216,12 @@ class IssueReporter {
|
|
|
208
216
|
args.splice(1, 1);
|
|
209
217
|
}
|
|
210
218
|
|
|
211
|
-
|
|
219
|
+
if (extra.skipSendToRemote) {
|
|
220
|
+
skipSendToRemote = true;
|
|
221
|
+
delete extra.skipSendToRemote;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
212
225
|
const message = args.join(', ');
|
|
213
226
|
let consoleMessage = message;
|
|
214
227
|
|
|
@@ -228,7 +241,13 @@ class IssueReporter {
|
|
|
228
241
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
229
242
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
230
243
|
|
|
231
|
-
this.
|
|
244
|
+
if (this._callback) {
|
|
245
|
+
this._callback(level, consoleMessage);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (!skipSendToRemote) {
|
|
249
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
250
|
+
}
|
|
232
251
|
}
|
|
233
252
|
|
|
234
253
|
logRequest(url , options , response , start ) {
|
|
@@ -373,7 +392,11 @@ class IssueReporter {
|
|
|
373
392
|
},
|
|
374
393
|
// $FlowFixMe
|
|
375
394
|
body,
|
|
376
|
-
}).catch(() => {
|
|
395
|
+
}).catch((e ) => {
|
|
396
|
+
// $FlowFixMe
|
|
397
|
+
e.skipSendToRemote = true;
|
|
398
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
399
|
+
|
|
377
400
|
setTimeout(() => {
|
|
378
401
|
if (isArray) {
|
|
379
402
|
payload = payload.map(message => {
|
|
@@ -385,7 +408,7 @@ class IssueReporter {
|
|
|
385
408
|
payload._retry = retry + 1;
|
|
386
409
|
}
|
|
387
410
|
|
|
388
|
-
this._sendDebugToGrafana(
|
|
411
|
+
this._sendDebugToGrafana(payload, retry + 1);
|
|
389
412
|
}, 5000 + retry * 1000);
|
|
390
413
|
});
|
|
391
414
|
}
|
|
@@ -773,7 +796,7 @@ class ChatMessage {
|
|
|
773
796
|
static parse(plain ) {
|
|
774
797
|
return new ChatMessage({
|
|
775
798
|
uuid: plain.uuid,
|
|
776
|
-
date: moment__default[
|
|
799
|
+
date: moment__default['default'](plain.created_at).toDate(),
|
|
777
800
|
content: plain.content,
|
|
778
801
|
alias: plain.alias,
|
|
779
802
|
userUuid: plain.user_uuid,
|
|
@@ -865,7 +888,7 @@ class Voicemail {
|
|
|
865
888
|
static parse(plain ) {
|
|
866
889
|
return new Voicemail({
|
|
867
890
|
id: plain.id,
|
|
868
|
-
date: moment__default[
|
|
891
|
+
date: moment__default['default'](plain.timestamp * 1000).toDate(),
|
|
869
892
|
duration: plain.duration * 1000,
|
|
870
893
|
caller: {
|
|
871
894
|
name: plain.caller_id_name,
|
|
@@ -1002,7 +1025,7 @@ class Call {
|
|
|
1002
1025
|
onHold: plain.on_hold,
|
|
1003
1026
|
status: plain.status,
|
|
1004
1027
|
lineId: plain.line_id,
|
|
1005
|
-
startingTime: moment__default[
|
|
1028
|
+
startingTime: moment__default['default'](plain.creation_time).toDate(),
|
|
1006
1029
|
talkingToIds: Object.keys(plain.talking_to || {}),
|
|
1007
1030
|
recording: plain.record_state === RECORD_STATE_ACTIVE,
|
|
1008
1031
|
});
|
package/lib/api/chatd.js
CHANGED
|
@@ -132,6 +132,7 @@ class IssueReporter {
|
|
|
132
132
|
|
|
133
133
|
|
|
134
134
|
|
|
135
|
+
|
|
135
136
|
|
|
136
137
|
constructor() {
|
|
137
138
|
addLevelsTo(this);
|
|
@@ -143,12 +144,17 @@ class IssueReporter {
|
|
|
143
144
|
this.bufferTimeout = null;
|
|
144
145
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
145
146
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
147
|
+
this._callback = null;
|
|
146
148
|
}
|
|
147
149
|
|
|
148
150
|
init() {
|
|
149
151
|
this._catchConsole();
|
|
150
152
|
}
|
|
151
153
|
|
|
154
|
+
setCallback(cb ) {
|
|
155
|
+
this._callback = cb;
|
|
156
|
+
}
|
|
157
|
+
|
|
152
158
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
153
159
|
this.remoteClientConfiguration = configuration;
|
|
154
160
|
}
|
|
@@ -184,6 +190,7 @@ class IssueReporter {
|
|
|
184
190
|
|
|
185
191
|
// Handle category label
|
|
186
192
|
let category = null;
|
|
193
|
+
let skipSendToRemote = false;
|
|
187
194
|
let extra = {};
|
|
188
195
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
189
196
|
category = args[0].split('=')[1];
|
|
@@ -199,6 +206,7 @@ class IssueReporter {
|
|
|
199
206
|
errorMessage: lastArg.message,
|
|
200
207
|
errorStack: lastArg.stack,
|
|
201
208
|
errorType: lastArg.constructor.name,
|
|
209
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
202
210
|
};
|
|
203
211
|
} else {
|
|
204
212
|
extra = lastArg;
|
|
@@ -207,7 +215,12 @@ class IssueReporter {
|
|
|
207
215
|
args.splice(1, 1);
|
|
208
216
|
}
|
|
209
217
|
|
|
210
|
-
|
|
218
|
+
if (extra.skipSendToRemote) {
|
|
219
|
+
skipSendToRemote = true;
|
|
220
|
+
delete extra.skipSendToRemote;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
211
224
|
const message = args.join(', ');
|
|
212
225
|
let consoleMessage = message;
|
|
213
226
|
|
|
@@ -227,7 +240,13 @@ class IssueReporter {
|
|
|
227
240
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
228
241
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
229
242
|
|
|
230
|
-
this.
|
|
243
|
+
if (this._callback) {
|
|
244
|
+
this._callback(level, consoleMessage);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (!skipSendToRemote) {
|
|
248
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
249
|
+
}
|
|
231
250
|
}
|
|
232
251
|
|
|
233
252
|
logRequest(url , options , response , start ) {
|
|
@@ -372,7 +391,11 @@ class IssueReporter {
|
|
|
372
391
|
},
|
|
373
392
|
// $FlowFixMe
|
|
374
393
|
body,
|
|
375
|
-
}).catch(() => {
|
|
394
|
+
}).catch((e ) => {
|
|
395
|
+
// $FlowFixMe
|
|
396
|
+
e.skipSendToRemote = true;
|
|
397
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
398
|
+
|
|
376
399
|
setTimeout(() => {
|
|
377
400
|
if (isArray) {
|
|
378
401
|
payload = payload.map(message => {
|
|
@@ -384,7 +407,7 @@ class IssueReporter {
|
|
|
384
407
|
payload._retry = retry + 1;
|
|
385
408
|
}
|
|
386
409
|
|
|
387
|
-
this._sendDebugToGrafana(
|
|
410
|
+
this._sendDebugToGrafana(payload, retry + 1);
|
|
388
411
|
}, 5000 + retry * 1000);
|
|
389
412
|
});
|
|
390
413
|
}
|
|
@@ -1158,7 +1181,7 @@ class ChatMessage {
|
|
|
1158
1181
|
static parse(plain ) {
|
|
1159
1182
|
return new ChatMessage({
|
|
1160
1183
|
uuid: plain.uuid,
|
|
1161
|
-
date: moment__default[
|
|
1184
|
+
date: moment__default['default'](plain.created_at).toDate(),
|
|
1162
1185
|
content: plain.content,
|
|
1163
1186
|
alias: plain.alias,
|
|
1164
1187
|
userUuid: plain.user_uuid,
|