@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/esm/api/confd.js
CHANGED
|
@@ -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.
|
|
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 => {
|
|
@@ -1259,8 +1282,9 @@ class ExternalApp {
|
|
|
1259
1282
|
|
|
1260
1283
|
|
|
1261
1284
|
|
|
1262
|
-
|
|
1285
|
+
|
|
1263
1286
|
|
|
1287
|
+
|
|
1264
1288
|
|
|
1265
1289
|
|
|
1266
1290
|
class Meeting {
|
|
@@ -1271,9 +1295,10 @@ class Meeting {
|
|
|
1271
1295
|
|
|
1272
1296
|
|
|
1273
1297
|
|
|
1274
|
-
|
|
1298
|
+
|
|
1275
1299
|
|
|
1276
1300
|
|
|
1301
|
+
|
|
1277
1302
|
|
|
1278
1303
|
static parse(plain ) {
|
|
1279
1304
|
return new Meeting({
|
|
@@ -1283,24 +1308,43 @@ class Meeting {
|
|
|
1283
1308
|
ownerUuids: plain.owner_uuids,
|
|
1284
1309
|
port: plain.port,
|
|
1285
1310
|
uuid: plain.uuid,
|
|
1286
|
-
|
|
1311
|
+
extension: plain.exten,
|
|
1287
1312
|
persistent: plain.persistent,
|
|
1313
|
+
creationTime: moment(plain.creation_time).toDate(),
|
|
1288
1314
|
});
|
|
1289
1315
|
}
|
|
1290
1316
|
|
|
1317
|
+
static parseMany(items ) {
|
|
1318
|
+
if (!items) {
|
|
1319
|
+
return [];
|
|
1320
|
+
}
|
|
1321
|
+
return items.map(plain => Meeting.parse(plain));
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1291
1324
|
static newFrom(meeting ) {
|
|
1292
1325
|
return newFrom(meeting, Meeting);
|
|
1293
1326
|
}
|
|
1294
1327
|
|
|
1295
|
-
constructor({
|
|
1328
|
+
constructor({
|
|
1329
|
+
uuid,
|
|
1330
|
+
name,
|
|
1331
|
+
guestSipAuthorization,
|
|
1332
|
+
ownerUuids,
|
|
1333
|
+
port,
|
|
1334
|
+
uri,
|
|
1335
|
+
extension,
|
|
1336
|
+
persistent,
|
|
1337
|
+
creationTime,
|
|
1338
|
+
} = {}) {
|
|
1296
1339
|
this.guestSipAuthorization = guestSipAuthorization;
|
|
1297
1340
|
this.uri = uri;
|
|
1298
1341
|
this.name = name;
|
|
1299
1342
|
this.ownerUuids = ownerUuids;
|
|
1300
1343
|
this.port = port;
|
|
1301
1344
|
this.uuid = uuid;
|
|
1302
|
-
this.
|
|
1345
|
+
this.extension = extension;
|
|
1303
1346
|
this.persistent = persistent;
|
|
1347
|
+
this.creationTime = creationTime;
|
|
1304
1348
|
|
|
1305
1349
|
// Useful to compare instead of instanceof with minified code
|
|
1306
1350
|
this.type = 'Meeting';
|
|
@@ -1378,8 +1422,11 @@ var confd = (client , baseUrl ) => ({
|
|
|
1378
1422
|
}
|
|
1379
1423
|
},
|
|
1380
1424
|
|
|
1381
|
-
|
|
1382
|
-
client.
|
|
1425
|
+
getMyMeetings: () =>
|
|
1426
|
+
client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
|
|
1427
|
+
|
|
1428
|
+
createMyMeeting: (name , persistent ) =>
|
|
1429
|
+
client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
|
|
1383
1430
|
|
|
1384
1431
|
deleteMyMeeting: (meetingUuid ) =>
|
|
1385
1432
|
client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
|
package/esm/api/ctid-ng.js
CHANGED
|
@@ -130,6 +130,7 @@ class IssueReporter {
|
|
|
130
130
|
|
|
131
131
|
|
|
132
132
|
|
|
133
|
+
|
|
133
134
|
|
|
134
135
|
constructor() {
|
|
135
136
|
addLevelsTo(this);
|
|
@@ -141,12 +142,17 @@ class IssueReporter {
|
|
|
141
142
|
this.bufferTimeout = null;
|
|
142
143
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
143
144
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
145
|
+
this._callback = null;
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
init() {
|
|
147
149
|
this._catchConsole();
|
|
148
150
|
}
|
|
149
151
|
|
|
152
|
+
setCallback(cb ) {
|
|
153
|
+
this._callback = cb;
|
|
154
|
+
}
|
|
155
|
+
|
|
150
156
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
151
157
|
this.remoteClientConfiguration = configuration;
|
|
152
158
|
}
|
|
@@ -182,6 +188,7 @@ class IssueReporter {
|
|
|
182
188
|
|
|
183
189
|
// Handle category label
|
|
184
190
|
let category = null;
|
|
191
|
+
let skipSendToRemote = false;
|
|
185
192
|
let extra = {};
|
|
186
193
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
187
194
|
category = args[0].split('=')[1];
|
|
@@ -197,6 +204,7 @@ class IssueReporter {
|
|
|
197
204
|
errorMessage: lastArg.message,
|
|
198
205
|
errorStack: lastArg.stack,
|
|
199
206
|
errorType: lastArg.constructor.name,
|
|
207
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
200
208
|
};
|
|
201
209
|
} else {
|
|
202
210
|
extra = lastArg;
|
|
@@ -205,6 +213,11 @@ class IssueReporter {
|
|
|
205
213
|
args.splice(1, 1);
|
|
206
214
|
}
|
|
207
215
|
|
|
216
|
+
if (extra.skipSendToRemote) {
|
|
217
|
+
skipSendToRemote = true;
|
|
218
|
+
delete extra.skipSendToRemote;
|
|
219
|
+
}
|
|
220
|
+
|
|
208
221
|
const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
209
222
|
const message = args.join(', ');
|
|
210
223
|
let consoleMessage = message;
|
|
@@ -225,7 +238,13 @@ class IssueReporter {
|
|
|
225
238
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
226
239
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
227
240
|
|
|
228
|
-
this.
|
|
241
|
+
if (this._callback) {
|
|
242
|
+
this._callback(level, consoleMessage);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (!skipSendToRemote) {
|
|
246
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
247
|
+
}
|
|
229
248
|
}
|
|
230
249
|
|
|
231
250
|
logRequest(url , options , response , start ) {
|
|
@@ -370,7 +389,11 @@ class IssueReporter {
|
|
|
370
389
|
},
|
|
371
390
|
// $FlowFixMe
|
|
372
391
|
body,
|
|
373
|
-
}).catch(() => {
|
|
392
|
+
}).catch((e ) => {
|
|
393
|
+
// $FlowFixMe
|
|
394
|
+
e.skipSendToRemote = true;
|
|
395
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
396
|
+
|
|
374
397
|
setTimeout(() => {
|
|
375
398
|
if (isArray) {
|
|
376
399
|
payload = payload.map(message => {
|
|
@@ -764,6 +787,10 @@ class ChatMessage {
|
|
|
764
787
|
|
|
765
788
|
|
|
766
789
|
static parseMany(plain ) {
|
|
790
|
+
if (!plain || !plain.items) {
|
|
791
|
+
return [];
|
|
792
|
+
}
|
|
793
|
+
|
|
767
794
|
return plain.items.map(item => ChatMessage.parse(item));
|
|
768
795
|
}
|
|
769
796
|
|
|
@@ -873,6 +900,9 @@ class Voicemail {
|
|
|
873
900
|
}
|
|
874
901
|
|
|
875
902
|
static parseMany(plain ) {
|
|
903
|
+
if (!plain) {
|
|
904
|
+
return [];
|
|
905
|
+
}
|
|
876
906
|
const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
|
|
877
907
|
const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
|
|
878
908
|
|
|
@@ -982,6 +1012,9 @@ class Call {
|
|
|
982
1012
|
|
|
983
1013
|
|
|
984
1014
|
static parseMany(plain ) {
|
|
1015
|
+
if (!plain) {
|
|
1016
|
+
return [];
|
|
1017
|
+
}
|
|
985
1018
|
return plain.map((plainCall ) => Call.parse(plainCall));
|
|
986
1019
|
}
|
|
987
1020
|
|
|
@@ -1126,11 +1159,11 @@ BwIDAQAB
|
|
|
1126
1159
|
|
|
1127
1160
|
//
|
|
1128
1161
|
|
|
1129
|
-
KEYUTIL.getKey(swarmPublicKey);
|
|
1162
|
+
const swarmKey = KEYUTIL.getKey(swarmPublicKey);
|
|
1130
1163
|
|
|
1131
1164
|
/* */
|
|
1132
1165
|
|
|
1133
|
-
IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
1166
|
+
const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
1134
1167
|
|
|
1135
1168
|
/* eslint-disable dot-notation */
|
|
1136
1169
|
|
|
@@ -1152,7 +1185,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
|
|
|
1152
1185
|
|
|
1153
1186
|
// const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
|
|
1154
1187
|
|
|
1155
|
-
IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
1188
|
+
const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
|
|
1156
1189
|
|
|
1157
1190
|
/* */
|
|
1158
1191
|
|
package/esm/api/dird.js
CHANGED
|
@@ -128,6 +128,7 @@ class IssueReporter {
|
|
|
128
128
|
|
|
129
129
|
|
|
130
130
|
|
|
131
|
+
|
|
131
132
|
|
|
132
133
|
constructor() {
|
|
133
134
|
addLevelsTo(this);
|
|
@@ -139,12 +140,17 @@ class IssueReporter {
|
|
|
139
140
|
this.bufferTimeout = null;
|
|
140
141
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
141
142
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
143
|
+
this._callback = null;
|
|
142
144
|
}
|
|
143
145
|
|
|
144
146
|
init() {
|
|
145
147
|
this._catchConsole();
|
|
146
148
|
}
|
|
147
149
|
|
|
150
|
+
setCallback(cb ) {
|
|
151
|
+
this._callback = cb;
|
|
152
|
+
}
|
|
153
|
+
|
|
148
154
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
149
155
|
this.remoteClientConfiguration = configuration;
|
|
150
156
|
}
|
|
@@ -180,6 +186,7 @@ class IssueReporter {
|
|
|
180
186
|
|
|
181
187
|
// Handle category label
|
|
182
188
|
let category = null;
|
|
189
|
+
let skipSendToRemote = false;
|
|
183
190
|
let extra = {};
|
|
184
191
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
185
192
|
category = args[0].split('=')[1];
|
|
@@ -195,6 +202,7 @@ class IssueReporter {
|
|
|
195
202
|
errorMessage: lastArg.message,
|
|
196
203
|
errorStack: lastArg.stack,
|
|
197
204
|
errorType: lastArg.constructor.name,
|
|
205
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
198
206
|
};
|
|
199
207
|
} else {
|
|
200
208
|
extra = lastArg;
|
|
@@ -203,6 +211,11 @@ class IssueReporter {
|
|
|
203
211
|
args.splice(1, 1);
|
|
204
212
|
}
|
|
205
213
|
|
|
214
|
+
if (extra.skipSendToRemote) {
|
|
215
|
+
skipSendToRemote = true;
|
|
216
|
+
delete extra.skipSendToRemote;
|
|
217
|
+
}
|
|
218
|
+
|
|
206
219
|
const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
207
220
|
const message = args.join(', ');
|
|
208
221
|
let consoleMessage = message;
|
|
@@ -223,7 +236,13 @@ class IssueReporter {
|
|
|
223
236
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
224
237
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
225
238
|
|
|
226
|
-
this.
|
|
239
|
+
if (this._callback) {
|
|
240
|
+
this._callback(level, consoleMessage);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (!skipSendToRemote) {
|
|
244
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
245
|
+
}
|
|
227
246
|
}
|
|
228
247
|
|
|
229
248
|
logRequest(url , options , response , start ) {
|
|
@@ -368,7 +387,11 @@ class IssueReporter {
|
|
|
368
387
|
},
|
|
369
388
|
// $FlowFixMe
|
|
370
389
|
body,
|
|
371
|
-
}).catch(() => {
|
|
390
|
+
}).catch((e ) => {
|
|
391
|
+
// $FlowFixMe
|
|
392
|
+
e.skipSendToRemote = true;
|
|
393
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
394
|
+
|
|
372
395
|
setTimeout(() => {
|
|
373
396
|
if (isArray) {
|
|
374
397
|
payload = payload.map(message => {
|
|
@@ -711,7 +734,7 @@ const LINE_STATE = {
|
|
|
711
734
|
|
|
712
735
|
//
|
|
713
736
|
|
|
714
|
-
KEYUTIL.getKey(swarmPublicKey);
|
|
737
|
+
const swarmKey = KEYUTIL.getKey(swarmPublicKey);
|
|
715
738
|
|
|
716
739
|
//
|
|
717
740
|
|
|
@@ -992,6 +1015,9 @@ class Contact {
|
|
|
992
1015
|
}
|
|
993
1016
|
|
|
994
1017
|
static parseMany(response ) {
|
|
1018
|
+
if (!response || !response.results) {
|
|
1019
|
+
return [];
|
|
1020
|
+
}
|
|
995
1021
|
return response.results.map(r => Contact.parse(r, response.column_types));
|
|
996
1022
|
}
|
|
997
1023
|
|
package/esm/api/webhookd.js
CHANGED
|
@@ -65,6 +65,7 @@ class IssueReporter {
|
|
|
65
65
|
|
|
66
66
|
|
|
67
67
|
|
|
68
|
+
|
|
68
69
|
|
|
69
70
|
constructor() {
|
|
70
71
|
addLevelsTo(this);
|
|
@@ -76,12 +77,17 @@ class IssueReporter {
|
|
|
76
77
|
this.bufferTimeout = null;
|
|
77
78
|
this._boundProcessBuffer = this._processBuffer.bind(this);
|
|
78
79
|
this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
|
|
80
|
+
this._callback = null;
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
init() {
|
|
82
84
|
this._catchConsole();
|
|
83
85
|
}
|
|
84
86
|
|
|
87
|
+
setCallback(cb ) {
|
|
88
|
+
this._callback = cb;
|
|
89
|
+
}
|
|
90
|
+
|
|
85
91
|
configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
|
|
86
92
|
this.remoteClientConfiguration = configuration;
|
|
87
93
|
}
|
|
@@ -117,6 +123,7 @@ class IssueReporter {
|
|
|
117
123
|
|
|
118
124
|
// Handle category label
|
|
119
125
|
let category = null;
|
|
126
|
+
let skipSendToRemote = false;
|
|
120
127
|
let extra = {};
|
|
121
128
|
if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
|
|
122
129
|
category = args[0].split('=')[1];
|
|
@@ -132,6 +139,7 @@ class IssueReporter {
|
|
|
132
139
|
errorMessage: lastArg.message,
|
|
133
140
|
errorStack: lastArg.stack,
|
|
134
141
|
errorType: lastArg.constructor.name,
|
|
142
|
+
skipSendToRemote: lastArg.skipSendToRemote,
|
|
135
143
|
};
|
|
136
144
|
} else {
|
|
137
145
|
extra = lastArg;
|
|
@@ -140,6 +148,11 @@ class IssueReporter {
|
|
|
140
148
|
args.splice(1, 1);
|
|
141
149
|
}
|
|
142
150
|
|
|
151
|
+
if (extra.skipSendToRemote) {
|
|
152
|
+
skipSendToRemote = true;
|
|
153
|
+
delete extra.skipSendToRemote;
|
|
154
|
+
}
|
|
155
|
+
|
|
143
156
|
const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
|
|
144
157
|
const message = args.join(', ');
|
|
145
158
|
let consoleMessage = message;
|
|
@@ -160,7 +173,13 @@ class IssueReporter {
|
|
|
160
173
|
const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
|
|
161
174
|
oldMethod.apply(oldMethod, [date, consoleMessage]);
|
|
162
175
|
|
|
163
|
-
this.
|
|
176
|
+
if (this._callback) {
|
|
177
|
+
this._callback(level, consoleMessage);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (!skipSendToRemote) {
|
|
181
|
+
this._sendToRemoteLogger(level, { date, message, category, ...extra });
|
|
182
|
+
}
|
|
164
183
|
}
|
|
165
184
|
|
|
166
185
|
logRequest(url , options , response , start ) {
|
|
@@ -305,7 +324,11 @@ class IssueReporter {
|
|
|
305
324
|
},
|
|
306
325
|
// $FlowFixMe
|
|
307
326
|
body,
|
|
308
|
-
}).catch(() => {
|
|
327
|
+
}).catch((e ) => {
|
|
328
|
+
// $FlowFixMe
|
|
329
|
+
e.skipSendToRemote = true;
|
|
330
|
+
this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
|
|
331
|
+
|
|
309
332
|
setTimeout(() => {
|
|
310
333
|
if (isArray) {
|
|
311
334
|
payload = payload.map(message => {
|
|
@@ -341,7 +364,7 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
341
364
|
|
|
342
365
|
/* */
|
|
343
366
|
|
|
344
|
-
IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
367
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
345
368
|
|
|
346
369
|
// Use a function here to be able to mock it in tests
|
|
347
370
|
const realFetch = () => {
|