podchat-browser 12.7.2-snapshot.8 → 12.7.2
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/_buildInfo.js +20 -0
- package/dist/node/buildConfig.json +1 -0
- package/dist/node/call.module.js +621 -414
- package/dist/node/chat.js +27 -46
- package/dist/node/events.module.js +2 -4
- package/dist/node/messaging.module.js +3 -2
- package/dist/podchat-browser-bundle.js +2054 -1410
- package/examples/index.html +18 -2
- package/package.json +10 -11
- package/src/buildConfig.json +1 -0
- package/src/call.module.js +239 -123
- package/src/chat.js +92 -124
- package/src/events.module.js +1 -3
- package/src/messaging.module.js +3 -2
- package/dist/node/lib/logger.js +0 -35
- package/src/lib/logger.js +0 -34
package/src/chat.js
CHANGED
|
@@ -6,7 +6,7 @@ import Dexie from "dexie"
|
|
|
6
6
|
import ChatCall from "./call.module"
|
|
7
7
|
import ChatEvents, { initEventHandler, chatEvents } from "./events.module"
|
|
8
8
|
import ChatMessaging from "./messaging.module"
|
|
9
|
-
|
|
9
|
+
import buildConfig from "./buildConfig.json"
|
|
10
10
|
|
|
11
11
|
import {
|
|
12
12
|
chatMessageVOTypes,
|
|
@@ -21,7 +21,6 @@ import {
|
|
|
21
21
|
} from "./lib/constants";
|
|
22
22
|
|
|
23
23
|
import deviceManager from "./lib/call/deviceManager.js";
|
|
24
|
-
import messagingModule from "./messaging.module";
|
|
25
24
|
|
|
26
25
|
function Chat(params) {
|
|
27
26
|
/*******************************************************
|
|
@@ -32,8 +31,9 @@ function Chat(params) {
|
|
|
32
31
|
var asyncClient,
|
|
33
32
|
peerId,
|
|
34
33
|
oldPeerId,
|
|
35
|
-
token = params.token,
|
|
34
|
+
token = params.token || "111",
|
|
36
35
|
generalTypeCode = params.typeCode || 'default',
|
|
36
|
+
typeCodeOwnerId = params.typeCodeOwnerId || null,
|
|
37
37
|
mapApiKey = params.mapApiKey || '8b77db18704aa646ee5aaea13e7370f4f88b9e8c',
|
|
38
38
|
deviceId,
|
|
39
39
|
productEnv = (typeof navigator != 'undefined') ? navigator.product : 'undefined',
|
|
@@ -176,14 +176,8 @@ function Chat(params) {
|
|
|
176
176
|
chatSendQueue = [],
|
|
177
177
|
chatWaitQueue = [],
|
|
178
178
|
chatUploadQueue = [],
|
|
179
|
-
fullResponseObject = params.fullResponseObject || false
|
|
180
|
-
|
|
181
|
-
// enable: ( params.externalLogging && params.externalLogging.enable !== undefined ? params.externalLogging.enable : true),
|
|
182
|
-
// url: (params.externalLogging && params.externalLogging.url !== undefined ? params.externalLogging.url : null),
|
|
183
|
-
// username: (params.externalLogging && params.externalLogging.username !== undefined ? params.externalLogging.username : null),
|
|
184
|
-
// password: (params.externalLogging && params.externalLogging.password !== undefined ? params.externalLogging.password : null)
|
|
185
|
-
// };
|
|
186
|
-
isAsyncReconnecting = false;
|
|
179
|
+
fullResponseObject = params.fullResponseObject || false,
|
|
180
|
+
webrtcConfig = (params.webrtcConfig ? params.webrtcConfig : null);
|
|
187
181
|
|
|
188
182
|
if(!consoleLogging) {
|
|
189
183
|
/**
|
|
@@ -196,10 +190,6 @@ function Chat(params) {
|
|
|
196
190
|
};
|
|
197
191
|
}
|
|
198
192
|
|
|
199
|
-
// if(externalLogging.enabled) {
|
|
200
|
-
// initExternalLogger(externalLogging);
|
|
201
|
-
// }
|
|
202
|
-
|
|
203
193
|
initEventHandler(Object.assign(params, {
|
|
204
194
|
consoleLogging,
|
|
205
195
|
}));
|
|
@@ -214,6 +204,7 @@ function Chat(params) {
|
|
|
214
204
|
//Utility: Utility,
|
|
215
205
|
consoleLogging: consoleLogging,
|
|
216
206
|
generalTypeCode: generalTypeCode,
|
|
207
|
+
typeCodeOwnerId,
|
|
217
208
|
chatPingMessageInterval: chatPingMessageInterval,
|
|
218
209
|
asyncRequestTimeout: asyncRequestTimeout,
|
|
219
210
|
serverName: serverName,
|
|
@@ -286,13 +277,13 @@ function Chat(params) {
|
|
|
286
277
|
messageTtl: messageTtl,
|
|
287
278
|
reconnectOnClose: reconnectOnClose,
|
|
288
279
|
asyncLogging: asyncLogging,
|
|
289
|
-
logLevel: (consoleLogging ? 3 : 1)
|
|
280
|
+
logLevel: (consoleLogging ? 3 : 1),
|
|
281
|
+
webrtcConfig: webrtcConfig
|
|
290
282
|
});
|
|
291
283
|
callModule.asyncInitialized(asyncClient);
|
|
292
284
|
chatMessaging.asyncInitialized(asyncClient);
|
|
293
285
|
|
|
294
286
|
asyncClient.on('asyncReady', function () {
|
|
295
|
-
chatMessaging.startChatPing();
|
|
296
287
|
if (actualTimingLog) {
|
|
297
288
|
Utility.chatStepLogger('Async Connection ', new Date().getTime() - asyncGetReadyTime);
|
|
298
289
|
}
|
|
@@ -300,94 +291,7 @@ function Chat(params) {
|
|
|
300
291
|
peerId = asyncClient.getPeerId();
|
|
301
292
|
|
|
302
293
|
if (!chatMessaging.userInfo) {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
getUserInfo(function (userInfoResult) {
|
|
306
|
-
if (actualTimingLog) {
|
|
307
|
-
Utility.chatStepLogger('Get User Info ', new Date().getTime() - getUserInfoTime);
|
|
308
|
-
}
|
|
309
|
-
if (!userInfoResult.hasError) {
|
|
310
|
-
chatMessaging.userInfo = userInfoResult.result.user;
|
|
311
|
-
|
|
312
|
-
getAllThreads({
|
|
313
|
-
summary: true,
|
|
314
|
-
cache: false
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* Check if user has KeyId stored in their cache or not?
|
|
319
|
-
*/
|
|
320
|
-
if (canUseCache) {
|
|
321
|
-
if (db) {
|
|
322
|
-
db.users
|
|
323
|
-
.where('id')
|
|
324
|
-
.equals(parseInt(chatMessaging.userInfo.id))
|
|
325
|
-
.toArray()
|
|
326
|
-
.then(function (users) {
|
|
327
|
-
if (users.length > 0 && typeof users[0].keyId != 'undefined') {
|
|
328
|
-
var user = users[0];
|
|
329
|
-
|
|
330
|
-
getEncryptionKey({
|
|
331
|
-
keyId: user.keyId
|
|
332
|
-
}, function (result) {
|
|
333
|
-
if (!result.hasError) {
|
|
334
|
-
cacheSecret = result.secretKey;
|
|
335
|
-
|
|
336
|
-
chatMessaging.chatState = true;
|
|
337
|
-
chatEvents.fireEvent('chatReady');
|
|
338
|
-
chatSendQueueHandler();
|
|
339
|
-
} else {
|
|
340
|
-
if (result.message !== '') {
|
|
341
|
-
try {
|
|
342
|
-
var response = JSON.parse(result.message);
|
|
343
|
-
if (response.error === 'invalid_param') {
|
|
344
|
-
generateEncryptionKey({
|
|
345
|
-
keyAlgorithm: 'AES',
|
|
346
|
-
keySize: 256
|
|
347
|
-
}, function () {
|
|
348
|
-
chatMessaging.chatState = true;
|
|
349
|
-
chatEvents.fireEvent('chatReady');
|
|
350
|
-
chatSendQueueHandler();
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
} catch (e) {
|
|
354
|
-
consoleLogging && console.log(e);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
} else {
|
|
360
|
-
generateEncryptionKey({
|
|
361
|
-
keyAlgorithm: 'AES',
|
|
362
|
-
keySize: 256
|
|
363
|
-
}, function () {
|
|
364
|
-
chatMessaging.chatState = true;
|
|
365
|
-
chatEvents.fireEvent('chatReady');
|
|
366
|
-
chatSendQueueHandler();
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
})
|
|
370
|
-
.catch(function (error) {
|
|
371
|
-
chatEvents.fireEvent('error', {
|
|
372
|
-
code: error.errorCode,
|
|
373
|
-
message: error.errorMessage,
|
|
374
|
-
error: error
|
|
375
|
-
});
|
|
376
|
-
});
|
|
377
|
-
} else {
|
|
378
|
-
chatEvents.fireEvent('error', {
|
|
379
|
-
code: 6601,
|
|
380
|
-
message: CHAT_ERRORS[6601],
|
|
381
|
-
error: null
|
|
382
|
-
});
|
|
383
|
-
}
|
|
384
|
-
} else {
|
|
385
|
-
chatMessaging.chatState = true;
|
|
386
|
-
chatEvents.fireEvent('chatReady');
|
|
387
|
-
chatSendQueueHandler();
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
});
|
|
294
|
+
getUserAndUpdateSDKState();
|
|
391
295
|
} else if (chatMessaging.userInfo.id > 0) {
|
|
392
296
|
chatMessaging.chatState = true;
|
|
393
297
|
chatEvents.fireEvent('chatReady');
|
|
@@ -417,24 +321,25 @@ function Chat(params) {
|
|
|
417
321
|
chatEvents.fireEvent('chatState', state);
|
|
418
322
|
chatFullStateObject = state;
|
|
419
323
|
|
|
420
|
-
// if(![0,2].includes(state.socketState)) {
|
|
421
|
-
// isAsyncReconnecting = false;
|
|
422
|
-
// } else if([0,2].includes(state.socketState)) {
|
|
423
|
-
// isAsyncReconnecting = true;
|
|
424
|
-
// }
|
|
425
|
-
|
|
426
324
|
switch (state.socketState) {
|
|
427
325
|
case 1: // CONNECTED
|
|
428
326
|
if (state.deviceRegister && state.serverRegister) {
|
|
429
|
-
chatMessaging.chatState = true;
|
|
430
|
-
chatMessaging.ping();
|
|
327
|
+
// chatMessaging.chatState = true;
|
|
328
|
+
// chatMessaging.ping();
|
|
329
|
+
chatMessaging.startChatPing();
|
|
431
330
|
}
|
|
432
331
|
break;
|
|
433
332
|
case 0: // CONNECTING
|
|
333
|
+
chatMessaging.chatState = false;
|
|
334
|
+
chatMessaging.stopChatPing();
|
|
335
|
+
break;
|
|
434
336
|
case 2: // CLOSING
|
|
337
|
+
chatMessaging.chatState = false;
|
|
338
|
+
chatMessaging.stopChatPing();
|
|
339
|
+
break;
|
|
435
340
|
case 3: // CLOSED
|
|
436
341
|
chatMessaging.chatState = false;
|
|
437
|
-
|
|
342
|
+
chatMessaging.stopChatPing();
|
|
438
343
|
// TODO: Check if this is OK or not?!
|
|
439
344
|
//chatMessaging.sendPingTimeout && clearTimeout(chatMessaging.sendPingTimeout);
|
|
440
345
|
break;
|
|
@@ -479,7 +384,26 @@ function Chat(params) {
|
|
|
479
384
|
});
|
|
480
385
|
});
|
|
481
386
|
},
|
|
387
|
+
getUserAndUpdateSDKState = function () {
|
|
388
|
+
var getUserInfoTime = new Date().getTime();
|
|
389
|
+
getUserInfo(function (userInfoResult) {
|
|
390
|
+
if (actualTimingLog) {
|
|
391
|
+
Utility.chatStepLogger('Get User Info ', new Date().getTime() - getUserInfoTime);
|
|
392
|
+
}
|
|
393
|
+
if (!userInfoResult.hasError) {
|
|
394
|
+
chatMessaging.userInfo = userInfoResult.result.user;
|
|
482
395
|
|
|
396
|
+
// getAllThreads({
|
|
397
|
+
// summary: true,
|
|
398
|
+
// cache: false
|
|
399
|
+
// });
|
|
400
|
+
|
|
401
|
+
chatMessaging.chatState = true;
|
|
402
|
+
chatEvents.fireEvent('chatReady');
|
|
403
|
+
chatSendQueueHandler();
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
},
|
|
483
407
|
/**
|
|
484
408
|
* Get Device Id With Token
|
|
485
409
|
*
|
|
@@ -4279,6 +4203,9 @@ function Chat(params) {
|
|
|
4279
4203
|
if (pushMessageVO.participant) {
|
|
4280
4204
|
message.ownerId = pushMessageVO.participant.id;
|
|
4281
4205
|
}
|
|
4206
|
+
else if (pushMessageVO.participantVO) {
|
|
4207
|
+
message.ownerId = pushMessageVO.participantVO.id;
|
|
4208
|
+
}
|
|
4282
4209
|
|
|
4283
4210
|
if (pushMessageVO.conversation) {
|
|
4284
4211
|
message.conversation = formatDataToMakeConversation(pushMessageVO.conversation);
|
|
@@ -4518,6 +4445,13 @@ function Chat(params) {
|
|
|
4518
4445
|
}
|
|
4519
4446
|
|
|
4520
4447
|
var functionLevelCache = (typeof params.cache == 'boolean') ? params.cache : true;
|
|
4448
|
+
|
|
4449
|
+
if (typeof params.isGroup === 'boolean') {
|
|
4450
|
+
content.isGroup = params.isGroup;
|
|
4451
|
+
}
|
|
4452
|
+
if (typeof params.type === 'number') {
|
|
4453
|
+
content.type = params.type;
|
|
4454
|
+
}
|
|
4521
4455
|
}
|
|
4522
4456
|
|
|
4523
4457
|
content.count = count;
|
|
@@ -5049,6 +4983,10 @@ function Chat(params) {
|
|
|
5049
4983
|
sendMessageParams.content.metadataCriteria = whereClause.metadataCriteria = params.metadataCriteria;
|
|
5050
4984
|
}
|
|
5051
4985
|
|
|
4986
|
+
if (typeof params.onlyNewMessages === "boolean") {
|
|
4987
|
+
sendMessageParams.content.newMessages = params.onlyNewMessages;
|
|
4988
|
+
}
|
|
4989
|
+
|
|
5052
4990
|
/**
|
|
5053
4991
|
* Get Thread Messages from cache
|
|
5054
4992
|
*
|
|
@@ -6327,7 +6265,12 @@ function Chat(params) {
|
|
|
6327
6265
|
if (typeof params.name === 'string') {
|
|
6328
6266
|
sendMessageParams.content.name = whereClause.name = params.name;
|
|
6329
6267
|
}
|
|
6330
|
-
|
|
6268
|
+
if (typeof params.username === 'string') {
|
|
6269
|
+
sendMessageParams.content.username = whereClause.username = params.username;
|
|
6270
|
+
}
|
|
6271
|
+
if (typeof params.cellphoneNumber === 'string') {
|
|
6272
|
+
sendMessageParams.content.cellphoneNumber = whereClause.cellphoneNumber = params.cellphoneNumber;
|
|
6273
|
+
}
|
|
6331
6274
|
if (typeof params.admin === 'boolean') {
|
|
6332
6275
|
sendMessageParams.content.admin = params.admin;
|
|
6333
6276
|
}
|
|
@@ -9983,6 +9926,9 @@ function Chat(params) {
|
|
|
9983
9926
|
if (typeof params.username === 'string') {
|
|
9984
9927
|
content.username = params.username;
|
|
9985
9928
|
}
|
|
9929
|
+
if (typeof params.coreUserId !== "undefined") {
|
|
9930
|
+
content.coreUserId = params.coreUserId;
|
|
9931
|
+
}
|
|
9986
9932
|
|
|
9987
9933
|
var functionLevelCache = (typeof params.cache == 'boolean') ? params.cache : true;
|
|
9988
9934
|
}
|
|
@@ -11889,6 +11835,8 @@ function Chat(params) {
|
|
|
11889
11835
|
data.typeCode = generalTypeCode;
|
|
11890
11836
|
}
|
|
11891
11837
|
|
|
11838
|
+
data.ownerId = typeCodeOwnerId ? typeCodeOwnerId : (params.ownerId ? params.ownerId : undefined);
|
|
11839
|
+
|
|
11892
11840
|
if (typeof params.cellphoneNumber === 'string') {
|
|
11893
11841
|
data.cellphoneNumber = params.cellphoneNumber;
|
|
11894
11842
|
} else {
|
|
@@ -12450,6 +12398,9 @@ function Chat(params) {
|
|
|
12450
12398
|
}
|
|
12451
12399
|
}
|
|
12452
12400
|
|
|
12401
|
+
data.ownerId = typeCodeOwnerId ? typeCodeOwnerId : (params.ownerId ? params.ownerId : undefined);
|
|
12402
|
+
|
|
12403
|
+
|
|
12453
12404
|
var requestParams = {
|
|
12454
12405
|
url: SERVICE_ADDRESSES.PLATFORM_ADDRESS + SERVICES_PATH.REMOVE_CONTACTS,
|
|
12455
12406
|
method: 'POST',
|
|
@@ -14146,15 +14097,8 @@ function Chat(params) {
|
|
|
14146
14097
|
return chatFullStateObject;
|
|
14147
14098
|
};
|
|
14148
14099
|
|
|
14149
|
-
publicized.reconnect = function (
|
|
14150
|
-
|
|
14151
|
-
asyncClient.reconnectSocket();
|
|
14152
|
-
// isAsyncReconnecting = true;
|
|
14153
|
-
// callback && callback({hasError: false, message: "Reconnecting..."});
|
|
14154
|
-
// } else {
|
|
14155
|
-
// callback && callback({hasError: true, message: "Socket state is not suitable for reconnecting."});
|
|
14156
|
-
// consoleLogging && console.log("[SDK] Socket state is not suitable for reconnecting.")
|
|
14157
|
-
// }
|
|
14100
|
+
publicized.reconnect = function () {
|
|
14101
|
+
asyncClient.reconnectSocket();
|
|
14158
14102
|
};
|
|
14159
14103
|
|
|
14160
14104
|
publicized.setToken = function (newToken) {
|
|
@@ -14163,6 +14107,9 @@ function Chat(params) {
|
|
|
14163
14107
|
callModule.updateToken(token);
|
|
14164
14108
|
chatMessaging.updateToken(token);
|
|
14165
14109
|
chatEvents.updateToken(token);
|
|
14110
|
+
if(!chatMessaging.userInfo || !chatMessaging.userInfo.id) {
|
|
14111
|
+
getUserAndUpdateSDKState();
|
|
14112
|
+
}
|
|
14166
14113
|
}
|
|
14167
14114
|
};
|
|
14168
14115
|
|
|
@@ -14287,6 +14234,27 @@ function Chat(params) {
|
|
|
14287
14234
|
});
|
|
14288
14235
|
};
|
|
14289
14236
|
|
|
14237
|
+
publicized.version = function () {
|
|
14238
|
+
console.log("%c[SDK] Version: podchat-browser@" + buildConfig.version, "color:green; font-size:13px")
|
|
14239
|
+
console.log("%c[SDK] Build date:" + buildConfig.date, "color:green;font-size:13px")
|
|
14240
|
+
console.log("%c[SDK] Additional info: " + buildConfig.VersionInfo, "color:green;font-size:13px")
|
|
14241
|
+
return buildConfig;
|
|
14242
|
+
};
|
|
14243
|
+
|
|
14244
|
+
publicized.changeProtocol = function (proto = "websocket") {
|
|
14245
|
+
if(["webrtc", "websocket"].includes(proto)) {
|
|
14246
|
+
if (proto != protocol) {
|
|
14247
|
+
protocol = proto.toLowerCase();
|
|
14248
|
+
asyncClient.logout();
|
|
14249
|
+
initAsync();
|
|
14250
|
+
} else {
|
|
14251
|
+
console.warn(`SDK is currently using the ${proto} protocol. Nothing to do.`)
|
|
14252
|
+
}
|
|
14253
|
+
} else {
|
|
14254
|
+
console.error(`Protocol ${proto} is not supported in SDK. Valid protocols: "webrtc", "websocket"`)
|
|
14255
|
+
}
|
|
14256
|
+
}
|
|
14257
|
+
|
|
14290
14258
|
init();
|
|
14291
14259
|
|
|
14292
14260
|
return publicized;
|
package/src/events.module.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import Utility from "./utility/utility"
|
|
2
|
-
import {externalLogger} from "./lib/logger";
|
|
3
2
|
// import Sentry from "./lib/sentry.js"
|
|
4
3
|
|
|
5
4
|
let chatEvents = null;
|
|
@@ -66,8 +65,7 @@ function ChatEvents(params) {
|
|
|
66
65
|
try {
|
|
67
66
|
throw new PodChatErrorException(param);
|
|
68
67
|
} catch (err) {
|
|
69
|
-
|
|
70
|
-
// console.error(err);
|
|
68
|
+
console.error(err);
|
|
71
69
|
}
|
|
72
70
|
}
|
|
73
71
|
|
package/src/messaging.module.js
CHANGED
|
@@ -77,7 +77,7 @@ import {errorList, raiseError} from "./lib/errorHandler";
|
|
|
77
77
|
* @return {object} Instant Function Return
|
|
78
78
|
*/
|
|
79
79
|
this.sendMessage = function (params, callbacks, recursiveCallback) {
|
|
80
|
-
if(!currentModuleInstance.chatState) {
|
|
80
|
+
if(!currentModuleInstance.chatState && chatMessageVOTypes.USER_INFO != params.chatMessageVOType) {
|
|
81
81
|
let clbck;
|
|
82
82
|
if(!callbacks) {
|
|
83
83
|
clbck = null;
|
|
@@ -236,7 +236,8 @@ import {errorList, raiseError} from "./lib/errorHandler";
|
|
|
236
236
|
ttl: (params.messageTtl > 0)
|
|
237
237
|
? params.messageTtl
|
|
238
238
|
: messageTtl
|
|
239
|
-
}
|
|
239
|
+
},
|
|
240
|
+
uniqueId: messageVO.uniqueId
|
|
240
241
|
};
|
|
241
242
|
|
|
242
243
|
asyncClient.send(data, function (res) {
|
package/dist/node/lib/logger.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.externalLogger = externalLogger;
|
|
7
|
-
exports.init = init;
|
|
8
|
-
var config = {
|
|
9
|
-
url: 'http://10.56.34.61:8080/twitter/tweet/1',
|
|
10
|
-
username: 'chat',
|
|
11
|
-
password: 'chat123'
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
function externalLogger(message) {
|
|
15
|
-
var msg;
|
|
16
|
-
if (typeof message !== "string") msg = JSON.stringify(message);
|
|
17
|
-
fetch(config.url, {
|
|
18
|
-
method: 'POST',
|
|
19
|
-
headers: {
|
|
20
|
-
'Authorization': 'Basic ' + btoa("".concat(config.username, ":").concat(config.password)),
|
|
21
|
-
'Content-Type': 'application/x-www-form-urlencoded'
|
|
22
|
-
},
|
|
23
|
-
body: new URLSearchParams({
|
|
24
|
-
'js-browser': msg
|
|
25
|
-
})
|
|
26
|
-
})["catch"](function (error) {
|
|
27
|
-
console.error("[SDK][ExternalLogger] Error while putting log, details: ", error);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function init(externalLogging) {
|
|
32
|
-
if (externalLogging.url) config.url = externalLogging.url;
|
|
33
|
-
if (externalLogging.username) config.username = externalLogging.username;
|
|
34
|
-
if (externalLogging.password) config.password = externalLogging.password;
|
|
35
|
-
}
|
package/src/lib/logger.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
let config = {
|
|
2
|
-
url: 'http://10.56.34.61:8080/twitter/tweet/1',
|
|
3
|
-
username: 'chat',
|
|
4
|
-
password: 'chat123'
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
function externalLogger(message) {
|
|
8
|
-
let msg;
|
|
9
|
-
if(typeof message !== "string")
|
|
10
|
-
msg = JSON.stringify(message);
|
|
11
|
-
fetch(config.url, {
|
|
12
|
-
method: 'POST',
|
|
13
|
-
headers: {
|
|
14
|
-
'Authorization': 'Basic ' + btoa(`${config.username}:${config.password}`),
|
|
15
|
-
'Content-Type': 'application/x-www-form-urlencoded'
|
|
16
|
-
},
|
|
17
|
-
body: new URLSearchParams({
|
|
18
|
-
'js-browser': msg
|
|
19
|
-
})
|
|
20
|
-
}).catch(error => {
|
|
21
|
-
console.error("[SDK][ExternalLogger] Error while putting log, details: ", error);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function init(externalLogging) {
|
|
26
|
-
if(externalLogging.url)
|
|
27
|
-
config.url = externalLogging.url;
|
|
28
|
-
if(externalLogging.username)
|
|
29
|
-
config.username = externalLogging.username;
|
|
30
|
-
if(externalLogging.password)
|
|
31
|
-
config.password = externalLogging.password;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export {init, externalLogger};
|