@wazo/sdk 0.37.20 → 0.37.24
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 +6 -6
- package/esm/__tests__/api-client.test.js +91 -21
- package/esm/__tests__/web-rtc-client.test.js +214 -165
- package/esm/api/agentd.js +25 -2
- package/esm/api/amid.js +26 -3
- package/esm/api/application.js +25 -2
- package/esm/api/auth.js +25 -2
- package/esm/api/call-logd.js +34 -4
- package/esm/api/calld.js +35 -2
- package/esm/api/chatd.js +32 -2
- package/esm/api/confd.js +56 -9
- package/esm/api/ctid-ng.js +38 -5
- package/esm/api/dird.js +29 -3
- package/esm/api/webhookd.js +26 -3
- package/esm/api-client.js +91 -21
- package/esm/checker/Checker.js +241 -190
- package/esm/checker/checks/aor.js +91 -21
- package/esm/checker/checks/api.js +91 -21
- package/esm/checker/checks/index.js +231 -180
- package/esm/checker/checks/wazo-websocket.js +42 -17
- package/esm/checker/checks/webrtc-transport.js +214 -165
- package/esm/checker/checks/webrtc.js +214 -165
- package/esm/domain/AdHocAPIConference.js +91 -21
- package/esm/domain/Call.js +3 -0
- package/esm/domain/CallLog.js +8 -1
- package/esm/domain/ChatMessage.js +4 -0
- package/esm/domain/ChatRoom.js +3 -0
- package/esm/domain/Contact.js +4 -1
- package/esm/domain/Features.js +91 -21
- package/esm/domain/Meeting.js +28 -5
- package/esm/domain/Phone/CTIPhone.js +109 -35
- package/esm/domain/Phone/WebRTCPhone.js +159 -102
- package/esm/domain/Recording.js +3 -0
- package/esm/domain/Voicemail.js +3 -0
- package/esm/domain/__tests__/Call.test.js +3 -0
- package/esm/domain/__tests__/CallLog.test.js +8 -1
- package/esm/domain/__tests__/Contact.test.js +4 -1
- package/esm/domain/__tests__/Meeting.test.js +144 -0
- package/esm/domain/__tests__/Voicemail.test.js +3 -0
- package/esm/index.js +509 -414
- package/esm/lib/WazoSessionDescriptionHandler.js +26 -41
- package/esm/service/CallApi.js +91 -21
- package/esm/service/IssueReporter.js +26 -3
- package/esm/service/__tests__/IssueReporter.test.js +26 -3
- package/esm/service/getApiClient.js +91 -21
- package/esm/simple/Auth.js +499 -404
- package/esm/simple/Configuration.js +499 -404
- package/esm/simple/Directory.js +91 -21
- package/esm/simple/Phone.js +499 -404
- package/esm/simple/Websocket.js +45 -19
- package/esm/simple/index.js +503 -408
- package/esm/simple/room/LocalParticipant.js +503 -408
- package/esm/simple/room/Participant.js +503 -408
- package/esm/simple/room/RemoteParticipant.js +503 -408
- package/esm/simple/room/Room.js +504 -409
- package/esm/simple/room/SipRoom.js +503 -408
- package/esm/simple/room/Stream.js +503 -408
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +503 -408
- package/esm/simple/utils.js +503 -408
- package/esm/types/WebSocketMessage.js +1 -1
- package/esm/utils/__tests__/api-requester.test.js +25 -2
- package/esm/utils/api-requester.js +25 -2
- package/esm/web-rtc-client.js +214 -165
- package/esm/websocket-client.js +43 -18
- package/lib/__tests__/api-client.test.js +91 -21
- package/lib/__tests__/web-rtc-client.test.js +214 -165
- package/lib/api/agentd.js +25 -2
- package/lib/api/amid.js +26 -3
- package/lib/api/application.js +25 -2
- package/lib/api/auth.js +25 -2
- package/lib/api/call-logd.js +34 -4
- package/lib/api/calld.js +35 -2
- package/lib/api/chatd.js +32 -2
- package/lib/api/confd.js +56 -9
- package/lib/api/ctid-ng.js +38 -5
- package/lib/api/dird.js +29 -3
- package/lib/api/webhookd.js +26 -3
- package/lib/api-client.js +91 -21
- package/lib/checker/Checker.js +241 -190
- package/lib/checker/checks/aor.js +91 -21
- package/lib/checker/checks/api.js +91 -21
- package/lib/checker/checks/index.js +231 -180
- package/lib/checker/checks/wazo-websocket.js +42 -17
- package/lib/checker/checks/webrtc-transport.js +214 -165
- package/lib/checker/checks/webrtc.js +214 -165
- package/lib/domain/AdHocAPIConference.js +91 -21
- package/lib/domain/Call.js +3 -0
- package/lib/domain/CallLog.js +8 -1
- package/lib/domain/ChatMessage.js +4 -0
- package/lib/domain/ChatRoom.js +3 -0
- package/lib/domain/Contact.js +4 -1
- package/lib/domain/Features.js +91 -21
- package/lib/domain/Meeting.js +32 -5
- package/lib/domain/Phone/CTIPhone.js +109 -35
- package/lib/domain/Phone/WebRTCPhone.js +159 -102
- package/lib/domain/Recording.js +3 -0
- package/lib/domain/Voicemail.js +3 -0
- package/lib/domain/__tests__/Call.test.js +3 -0
- package/lib/domain/__tests__/CallLog.test.js +8 -1
- package/lib/domain/__tests__/Contact.test.js +4 -1
- package/lib/domain/__tests__/Meeting.test.js +150 -0
- package/lib/domain/__tests__/Voicemail.test.js +3 -0
- package/lib/index.js +509 -414
- package/lib/lib/WazoSessionDescriptionHandler.js +26 -41
- package/lib/service/CallApi.js +91 -21
- package/lib/service/IssueReporter.js +26 -3
- package/lib/service/__tests__/IssueReporter.test.js +26 -3
- package/lib/service/getApiClient.js +91 -21
- package/lib/simple/Auth.js +499 -404
- package/lib/simple/Configuration.js +499 -404
- package/lib/simple/Directory.js +91 -21
- package/lib/simple/Phone.js +499 -404
- package/lib/simple/Websocket.js +45 -19
- package/lib/simple/index.js +503 -408
- package/lib/simple/room/LocalParticipant.js +503 -408
- package/lib/simple/room/Participant.js +503 -408
- package/lib/simple/room/RemoteParticipant.js +503 -408
- package/lib/simple/room/Room.js +504 -409
- package/lib/simple/room/SipRoom.js +503 -408
- package/lib/simple/room/Stream.js +503 -408
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +503 -408
- package/lib/simple/utils.js +503 -408
- package/lib/types/WebSocketMessage.js +2 -0
- package/lib/utils/__tests__/api-requester.test.js +25 -2
- package/lib/utils/api-requester.js +25 -2
- package/lib/web-rtc-client.js +214 -165
- package/lib/websocket-client.js +43 -17
- package/package.json +1 -1
- package/src/api/confd.js +5 -2
- package/src/domain/Call.js +3 -0
- package/src/domain/CallLog.js +4 -0
- package/src/domain/ChatMessage.js +4 -0
- package/src/domain/ChatRoom.js +3 -0
- package/src/domain/Contact.js +3 -0
- package/src/domain/Meeting.js +28 -5
- package/src/domain/Phone/CTIPhone.js +4 -0
- package/src/domain/Phone/Phone.js +2 -0
- package/src/domain/Phone/WebRTCPhone.js +49 -15
- package/src/domain/Recording.js +3 -0
- package/src/domain/Voicemail.js +3 -0
- package/src/domain/__tests__/Meeting.test.js +50 -0
- package/src/lib/WazoSessionDescriptionHandler.js +1 -35
- package/src/service/IssueReporter.js +25 -2
- package/src/simple/Phone.js +5 -0
- package/src/types/WebSocketMessage.js +5 -1
- package/src/web-rtc-client.js +41 -24
- package/src/websocket-client.js +2 -0
package/lib/api/confd.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,6 +215,11 @@ class IssueReporter {
|
|
|
207
215
|
args.splice(1, 1);
|
|
208
216
|
}
|
|
209
217
|
|
|
218
|
+
if (extra.skipSendToRemote) {
|
|
219
|
+
skipSendToRemote = true;
|
|
220
|
+
delete extra.skipSendToRemote;
|
|
221
|
+
}
|
|
222
|
+
|
|
210
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;
|
|
@@ -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 => {
|
|
@@ -1265,8 +1288,9 @@ class ExternalApp {
|
|
|
1265
1288
|
|
|
1266
1289
|
|
|
1267
1290
|
|
|
1268
|
-
|
|
1291
|
+
|
|
1269
1292
|
|
|
1293
|
+
|
|
1270
1294
|
|
|
1271
1295
|
|
|
1272
1296
|
class Meeting {
|
|
@@ -1277,9 +1301,10 @@ class Meeting {
|
|
|
1277
1301
|
|
|
1278
1302
|
|
|
1279
1303
|
|
|
1280
|
-
|
|
1304
|
+
|
|
1281
1305
|
|
|
1282
1306
|
|
|
1307
|
+
|
|
1283
1308
|
|
|
1284
1309
|
static parse(plain ) {
|
|
1285
1310
|
return new Meeting({
|
|
@@ -1289,24 +1314,43 @@ class Meeting {
|
|
|
1289
1314
|
ownerUuids: plain.owner_uuids,
|
|
1290
1315
|
port: plain.port,
|
|
1291
1316
|
uuid: plain.uuid,
|
|
1292
|
-
|
|
1317
|
+
extension: plain.exten,
|
|
1293
1318
|
persistent: plain.persistent,
|
|
1319
|
+
creationTime: moment__default['default'](plain.creation_time).toDate(),
|
|
1294
1320
|
});
|
|
1295
1321
|
}
|
|
1296
1322
|
|
|
1323
|
+
static parseMany(items ) {
|
|
1324
|
+
if (!items) {
|
|
1325
|
+
return [];
|
|
1326
|
+
}
|
|
1327
|
+
return items.map(plain => Meeting.parse(plain));
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1297
1330
|
static newFrom(meeting ) {
|
|
1298
1331
|
return newFrom(meeting, Meeting);
|
|
1299
1332
|
}
|
|
1300
1333
|
|
|
1301
|
-
constructor({
|
|
1334
|
+
constructor({
|
|
1335
|
+
uuid,
|
|
1336
|
+
name,
|
|
1337
|
+
guestSipAuthorization,
|
|
1338
|
+
ownerUuids,
|
|
1339
|
+
port,
|
|
1340
|
+
uri,
|
|
1341
|
+
extension,
|
|
1342
|
+
persistent,
|
|
1343
|
+
creationTime,
|
|
1344
|
+
} = {}) {
|
|
1302
1345
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
1303
1346
|
this.uri = uri;
|
|
1304
1347
|
this.name = name;
|
|
1305
1348
|
this.ownerUuids = ownerUuids;
|
|
1306
1349
|
this.port = port;
|
|
1307
1350
|
this.uuid = uuid;
|
|
1308
|
-
this.
|
|
1351
|
+
this.extension = extension;
|
|
1309
1352
|
this.persistent = persistent;
|
|
1353
|
+
this.creationTime = creationTime;
|
|
1310
1354
|
|
|
1311
1355
|
// Useful to compare instead of instanceof with minified code
|
|
1312
1356
|
this.type = 'Meeting';
|
|
@@ -1384,8 +1428,11 @@ var confd = (client , baseUrl ) => ({
|
|
|
1384
1428
|
}
|
|
1385
1429
|
},
|
|
1386
1430
|
|
|
1387
|
-
|
|
1388
|
-
client.
|
|
1431
|
+
getMyMeetings: () =>
|
|
1432
|
+
client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
|
|
1433
|
+
|
|
1434
|
+
createMyMeeting: (name , persistent ) =>
|
|
1435
|
+
client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
|
|
1389
1436
|
|
|
1390
1437
|
deleteMyMeeting: (meetingUuid ) =>
|
|
1391
1438
|
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
package/lib/api/ctid-ng.js
CHANGED
|
@@ -136,6 +136,7 @@ class IssueReporter {
|
|
|
136
136
|
|
|
137
137
|
|
|
138
138
|
|
|
139
|
+
|
|
139
140
|
|
|
140
141
|
constructor() {
|
|
141
142
|
addLevelsTo(this);
|
|
@@ -147,12 +148,17 @@ class IssueReporter {
|
|
|
147
148
|
this.bufferTimeout = null;
|
|
148
149
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
149
150
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
151
|
+
this._callback = null;
|
|
150
152
|
}
|
|
151
153
|
|
|
152
154
|
init() {
|
|
153
155
|
this._catchConsole();
|
|
154
156
|
}
|
|
155
157
|
|
|
158
|
+
setCallback(cb ) {
|
|
159
|
+
this._callback = cb;
|
|
160
|
+
}
|
|
161
|
+
|
|
156
162
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
157
163
|
this.remoteClientConfiguration = configuration;
|
|
158
164
|
}
|
|
@@ -188,6 +194,7 @@ class IssueReporter {
|
|
|
188
194
|
|
|
189
195
|
// Handle category label
|
|
190
196
|
let category = null;
|
|
197
|
+
let skipSendToRemote = false;
|
|
191
198
|
let extra = {};
|
|
192
199
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
193
200
|
category = args[0].split('=')[1];
|
|
@@ -203,6 +210,7 @@ class IssueReporter {
|
|
|
203
210
|
errorMessage: lastArg.message,
|
|
204
211
|
errorStack: lastArg.stack,
|
|
205
212
|
errorType: lastArg.constructor.name,
|
|
213
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
206
214
|
};
|
|
207
215
|
} else {
|
|
208
216
|
extra = lastArg;
|
|
@@ -211,6 +219,11 @@ class IssueReporter {
|
|
|
211
219
|
args.splice(1, 1);
|
|
212
220
|
}
|
|
213
221
|
|
|
222
|
+
if (extra.skipSendToRemote) {
|
|
223
|
+
skipSendToRemote = true;
|
|
224
|
+
delete extra.skipSendToRemote;
|
|
225
|
+
}
|
|
226
|
+
|
|
214
227
|
const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
215
228
|
const message = args.join(', ');
|
|
216
229
|
let consoleMessage = message;
|
|
@@ -231,7 +244,13 @@ class IssueReporter {
|
|
|
231
244
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
232
245
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
233
246
|
|
|
234
|
-
this.
|
|
247
|
+
if (this._callback) {
|
|
248
|
+
this._callback(level, consoleMessage);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (!skipSendToRemote) {
|
|
252
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
253
|
+
}
|
|
235
254
|
}
|
|
236
255
|
|
|
237
256
|
logRequest(url , options , response , start ) {
|
|
@@ -376,7 +395,11 @@ class IssueReporter {
|
|
|
376
395
|
},
|
|
377
396
|
// $FlowFixMe
|
|
378
397
|
body,
|
|
379
|
-
}).catch(() => {
|
|
398
|
+
}).catch((e ) => {
|
|
399
|
+
// $FlowFixMe
|
|
400
|
+
e.skipSendToRemote = true;
|
|
401
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
402
|
+
|
|
380
403
|
setTimeout(() => {
|
|
381
404
|
if (isArray) {
|
|
382
405
|
payload = payload.map(message => {
|
|
@@ -770,6 +793,10 @@ class ChatMessage {
|
|
|
770
793
|
|
|
771
794
|
|
|
772
795
|
static parseMany(plain ) {
|
|
796
|
+
if (!plain || !plain.items) {
|
|
797
|
+
return [];
|
|
798
|
+
}
|
|
799
|
+
|
|
773
800
|
return plain.items.map(item => ChatMessage.parse(item));
|
|
774
801
|
}
|
|
775
802
|
|
|
@@ -879,6 +906,9 @@ class Voicemail {
|
|
|
879
906
|
}
|
|
880
907
|
|
|
881
908
|
static parseMany(plain ) {
|
|
909
|
+
if (!plain) {
|
|
910
|
+
return [];
|
|
911
|
+
}
|
|
882
912
|
const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
|
|
883
913
|
const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
|
|
884
914
|
|
|
@@ -988,6 +1018,9 @@ class Call {
|
|
|
988
1018
|
|
|
989
1019
|
|
|
990
1020
|
static parseMany(plain ) {
|
|
1021
|
+
if (!plain) {
|
|
1022
|
+
return [];
|
|
1023
|
+
}
|
|
991
1024
|
return plain.map((plainCall ) => Call.parse(plainCall));
|
|
992
1025
|
}
|
|
993
1026
|
|
|
@@ -1132,11 +1165,11 @@ BwIDAQAB
|
|
|
1132
1165
|
|
|
1133
1166
|
//
|
|
1134
1167
|
|
|
1135
|
-
jsrsasign.KEYUTIL.getKey(swarmPublicKey);
|
|
1168
|
+
const swarmKey = jsrsasign.KEYUTIL.getKey(swarmPublicKey);
|
|
1136
1169
|
|
|
1137
1170
|
/* */
|
|
1138
1171
|
|
|
1139
|
-
IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
1172
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
1140
1173
|
|
|
1141
1174
|
/* eslint-disable dot-notation */
|
|
1142
1175
|
|
|
@@ -1158,7 +1191,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
1158
1191
|
|
|
1159
1192
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
1160
1193
|
|
|
1161
|
-
IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
1194
|
+
const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
1162
1195
|
|
|
1163
1196
|
/* */
|
|
1164
1197
|
|
package/lib/api/dird.js
CHANGED
|
@@ -134,6 +134,7 @@ class IssueReporter {
|
|
|
134
134
|
|
|
135
135
|
|
|
136
136
|
|
|
137
|
+
|
|
137
138
|
|
|
138
139
|
constructor() {
|
|
139
140
|
addLevelsTo(this);
|
|
@@ -145,12 +146,17 @@ class IssueReporter {
|
|
|
145
146
|
this.bufferTimeout = null;
|
|
146
147
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
147
148
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
149
|
+
this._callback = null;
|
|
148
150
|
}
|
|
149
151
|
|
|
150
152
|
init() {
|
|
151
153
|
this._catchConsole();
|
|
152
154
|
}
|
|
153
155
|
|
|
156
|
+
setCallback(cb ) {
|
|
157
|
+
this._callback = cb;
|
|
158
|
+
}
|
|
159
|
+
|
|
154
160
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
155
161
|
this.remoteClientConfiguration = configuration;
|
|
156
162
|
}
|
|
@@ -186,6 +192,7 @@ class IssueReporter {
|
|
|
186
192
|
|
|
187
193
|
// Handle category label
|
|
188
194
|
let category = null;
|
|
195
|
+
let skipSendToRemote = false;
|
|
189
196
|
let extra = {};
|
|
190
197
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
191
198
|
category = args[0].split('=')[1];
|
|
@@ -201,6 +208,7 @@ class IssueReporter {
|
|
|
201
208
|
errorMessage: lastArg.message,
|
|
202
209
|
errorStack: lastArg.stack,
|
|
203
210
|
errorType: lastArg.constructor.name,
|
|
211
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
204
212
|
};
|
|
205
213
|
} else {
|
|
206
214
|
extra = lastArg;
|
|
@@ -209,6 +217,11 @@ class IssueReporter {
|
|
|
209
217
|
args.splice(1, 1);
|
|
210
218
|
}
|
|
211
219
|
|
|
220
|
+
if (extra.skipSendToRemote) {
|
|
221
|
+
skipSendToRemote = true;
|
|
222
|
+
delete extra.skipSendToRemote;
|
|
223
|
+
}
|
|
224
|
+
|
|
212
225
|
const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
213
226
|
const message = args.join(', ');
|
|
214
227
|
let consoleMessage = message;
|
|
@@ -229,7 +242,13 @@ class IssueReporter {
|
|
|
229
242
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
230
243
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
231
244
|
|
|
232
|
-
this.
|
|
245
|
+
if (this._callback) {
|
|
246
|
+
this._callback(level, consoleMessage);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (!skipSendToRemote) {
|
|
250
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
251
|
+
}
|
|
233
252
|
}
|
|
234
253
|
|
|
235
254
|
logRequest(url , options , response , start ) {
|
|
@@ -374,7 +393,11 @@ class IssueReporter {
|
|
|
374
393
|
},
|
|
375
394
|
// $FlowFixMe
|
|
376
395
|
body,
|
|
377
|
-
}).catch(() => {
|
|
396
|
+
}).catch((e ) => {
|
|
397
|
+
// $FlowFixMe
|
|
398
|
+
e.skipSendToRemote = true;
|
|
399
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
400
|
+
|
|
378
401
|
setTimeout(() => {
|
|
379
402
|
if (isArray) {
|
|
380
403
|
payload = payload.map(message => {
|
|
@@ -717,7 +740,7 @@ const LINE_STATE = {
|
|
|
717
740
|
|
|
718
741
|
//
|
|
719
742
|
|
|
720
|
-
jsrsasign.KEYUTIL.getKey(swarmPublicKey);
|
|
743
|
+
const swarmKey = jsrsasign.KEYUTIL.getKey(swarmPublicKey);
|
|
721
744
|
|
|
722
745
|
//
|
|
723
746
|
|
|
@@ -998,6 +1021,9 @@ class Contact {
|
|
|
998
1021
|
}
|
|
999
1022
|
|
|
1000
1023
|
static parseMany(response ) {
|
|
1024
|
+
if (!response || !response.results) {
|
|
1025
|
+
return [];
|
|
1026
|
+
}
|
|
1001
1027
|
return response.results.map(r => Contact.parse(r, response.column_types));
|
|
1002
1028
|
}
|
|
1003
1029
|
|
package/lib/api/webhookd.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,6 +154,11 @@ class IssueReporter {
|
|
|
146
154
|
args.splice(1, 1);
|
|
147
155
|
}
|
|
148
156
|
|
|
157
|
+
if (extra.skipSendToRemote) {
|
|
158
|
+
skipSendToRemote = true;
|
|
159
|
+
delete extra.skipSendToRemote;
|
|
160
|
+
}
|
|
161
|
+
|
|
149
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;
|
|
@@ -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 => {
|
|
@@ -347,7 +370,7 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
347
370
|
|
|
348
371
|
/* */
|
|
349
372
|
|
|
350
|
-
IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
373
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
351
374
|
|
|
352
375
|
// Use a function here to be able to mock it in tests
|
|
353
376
|
const realFetch = () => {
|