@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/agentd.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 => {
|
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,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 = () => {
|
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,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 => {
|
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,6 +218,11 @@ class IssueReporter {
|
|
|
210
218
|
args.splice(1, 1);
|
|
211
219
|
}
|
|
212
220
|
|
|
221
|
+
if (extra.skipSendToRemote) {
|
|
222
|
+
skipSendToRemote = true;
|
|
223
|
+
delete extra.skipSendToRemote;
|
|
224
|
+
}
|
|
225
|
+
|
|
213
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;
|
|
@@ -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 => {
|
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,6 +155,11 @@ class IssueReporter {
|
|
|
147
155
|
args.splice(1, 1);
|
|
148
156
|
}
|
|
149
157
|
|
|
158
|
+
if (extra.skipSendToRemote) {
|
|
159
|
+
skipSendToRemote = true;
|
|
160
|
+
delete extra.skipSendToRemote;
|
|
161
|
+
}
|
|
162
|
+
|
|
150
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;
|
|
@@ -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 => {
|
|
@@ -348,7 +371,7 @@ var IssueReporter$1 = new IssueReporter();
|
|
|
348
371
|
|
|
349
372
|
/* */
|
|
350
373
|
|
|
351
|
-
IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
374
|
+
const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
352
375
|
|
|
353
376
|
// Use a function here to be able to mock it in tests
|
|
354
377
|
const realFetch = () => {
|
|
@@ -399,7 +422,7 @@ BwIDAQAB
|
|
|
399
422
|
|
|
400
423
|
//
|
|
401
424
|
|
|
402
|
-
jsrsasign.KEYUTIL.getKey(swarmPublicKey);
|
|
425
|
+
const swarmKey = jsrsasign.KEYUTIL.getKey(swarmPublicKey);
|
|
403
426
|
|
|
404
427
|
//
|
|
405
428
|
|
|
@@ -427,6 +450,9 @@ class Recording {
|
|
|
427
450
|
|
|
428
451
|
|
|
429
452
|
static parseMany(recordings = []) {
|
|
453
|
+
if (!recordings) {
|
|
454
|
+
return [];
|
|
455
|
+
}
|
|
430
456
|
return recordings.map(item => Recording.parse(item));
|
|
431
457
|
}
|
|
432
458
|
|
|
@@ -528,6 +554,10 @@ class CallLog {
|
|
|
528
554
|
}
|
|
529
555
|
|
|
530
556
|
static parseMany(plain ) {
|
|
557
|
+
if (!plain || !plain.items) {
|
|
558
|
+
return [];
|
|
559
|
+
}
|
|
560
|
+
|
|
531
561
|
return plain.items.map(item => CallLog.parse(item));
|
|
532
562
|
}
|
|
533
563
|
|
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,6 +216,11 @@ class IssueReporter {
|
|
|
208
216
|
args.splice(1, 1);
|
|
209
217
|
}
|
|
210
218
|
|
|
219
|
+
if (extra.skipSendToRemote) {
|
|
220
|
+
skipSendToRemote = true;
|
|
221
|
+
delete extra.skipSendToRemote;
|
|
222
|
+
}
|
|
223
|
+
|
|
211
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;
|
|
@@ -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 => {
|
|
@@ -767,6 +790,10 @@ class ChatMessage {
|
|
|
767
790
|
|
|
768
791
|
|
|
769
792
|
static parseMany(plain ) {
|
|
793
|
+
if (!plain || !plain.items) {
|
|
794
|
+
return [];
|
|
795
|
+
}
|
|
796
|
+
|
|
770
797
|
return plain.items.map(item => ChatMessage.parse(item));
|
|
771
798
|
}
|
|
772
799
|
|
|
@@ -876,6 +903,9 @@ class Voicemail {
|
|
|
876
903
|
}
|
|
877
904
|
|
|
878
905
|
static parseMany(plain ) {
|
|
906
|
+
if (!plain) {
|
|
907
|
+
return [];
|
|
908
|
+
}
|
|
879
909
|
const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
|
|
880
910
|
const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
|
|
881
911
|
|
|
@@ -985,6 +1015,9 @@ class Call {
|
|
|
985
1015
|
|
|
986
1016
|
|
|
987
1017
|
static parseMany(plain ) {
|
|
1018
|
+
if (!plain) {
|
|
1019
|
+
return [];
|
|
1020
|
+
}
|
|
988
1021
|
return plain.map((plainCall ) => Call.parse(plainCall));
|
|
989
1022
|
}
|
|
990
1023
|
|
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,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 => {
|
|
@@ -1086,6 +1109,9 @@ class ChatRoom {
|
|
|
1086
1109
|
|
|
1087
1110
|
|
|
1088
1111
|
static parseMany(plain ) {
|
|
1112
|
+
if (!plain || !plain.items) {
|
|
1113
|
+
return [];
|
|
1114
|
+
}
|
|
1089
1115
|
return plain.items.map(item => ChatRoom.parse(item));
|
|
1090
1116
|
}
|
|
1091
1117
|
|
|
@@ -1152,6 +1178,10 @@ class ChatMessage {
|
|
|
1152
1178
|
|
|
1153
1179
|
|
|
1154
1180
|
static parseMany(plain ) {
|
|
1181
|
+
if (!plain || !plain.items) {
|
|
1182
|
+
return [];
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1155
1185
|
return plain.items.map(item => ChatMessage.parse(item));
|
|
1156
1186
|
}
|
|
1157
1187
|
|