@microsoft/omnichannel-chat-sdk 1.3.1-main.2674439 → 1.3.1-main.89ffb27
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/CHANGELOG.md +6 -0
- package/README.md +10 -2
- package/lib/OmnichannelChatSDK.d.ts +4 -2
- package/lib/OmnichannelChatSDK.js +233 -250
- package/lib/OmnichannelChatSDK.js.map +1 -1
- package/lib/core/ChatSDKErrors.d.ts +45 -1
- package/lib/core/ChatSDKErrors.js +44 -0
- package/lib/core/ChatSDKErrors.js.map +1 -1
- package/lib/core/ChatSDKExceptionDetails.d.ts +7 -0
- package/lib/core/GetConversationDetailsOptionalParams.d.ts +4 -0
- package/lib/core/GetConversationDetailsOptionalParams.js +3 -0
- package/lib/core/GetConversationDetailsOptionalParams.js.map +1 -0
- package/lib/core/GetLiveChatTranscriptOptionalParams.d.ts +4 -0
- package/lib/core/GetLiveChatTranscriptOptionalParams.js +3 -0
- package/lib/core/GetLiveChatTranscriptOptionalParams.js.map +1 -0
- package/lib/core/LiveChatContext.d.ts +8 -0
- package/lib/tsconfig.tsbuildinfo +74 -17
- package/lib/utils/chatAdapterCreators.js +16 -55
- package/lib/utils/chatAdapterCreators.js.map +1 -1
- package/lib/utils/exceptionThrowers.d.ts +111 -0
- package/lib/utils/exceptionThrowers.js +129 -0
- package/lib/utils/exceptionThrowers.js.map +1 -0
- package/package.json +1 -1
@@ -87,6 +87,7 @@ var createOmnichannelMessage_1 = require("./utils/createOmnichannelMessage");
|
|
87
87
|
var createTelemetry_1 = require("./utils/createTelemetry");
|
88
88
|
var createVoiceVideoCalling_1 = require("./api/createVoiceVideoCalling");
|
89
89
|
var MessageTags_1 = require("./core/messaging/MessageTags");
|
90
|
+
var exceptionThrowers_1 = require("./utils/exceptionThrowers");
|
90
91
|
var location_1 = require("./utils/location");
|
91
92
|
var utilities_1 = require("./utils/utilities");
|
92
93
|
var urlResolvers_1 = require("./utils/urlResolvers");
|
@@ -113,7 +114,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
113
114
|
this.isChatReconnect = false;
|
114
115
|
this.reconnectId = null;
|
115
116
|
this.refreshTokenTimer = null;
|
116
|
-
this.populateInitChatOptionalParam = function (requestOptionalParams, optionalParams) {
|
117
|
+
this.populateInitChatOptionalParam = function (requestOptionalParams, optionalParams, telemetryEvent) {
|
117
118
|
requestOptionalParams.initContext.locale = locale_1.getLocaleStringFromId(_this.localeId);
|
118
119
|
if (optionalParams.customContext) {
|
119
120
|
requestOptionalParams.initContext.customContextData = optionalParams.customContext; // eslint-disable-line @typescript-eslint/no-explicit-any
|
@@ -138,17 +139,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
138
139
|
}
|
139
140
|
if (optionalParams.sendDefaultInitContext) {
|
140
141
|
if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
|
141
|
-
var
|
142
|
-
|
143
|
-
message: "sendDefaultInitContext is only supported on browser"
|
144
|
-
};
|
145
|
-
console.error(exceptionDetails.message);
|
146
|
-
_this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAgentAvailability, {
|
142
|
+
var message = "sendDefaultInitContext is only supported on browser";
|
143
|
+
var telemetryData = {
|
147
144
|
RequestId: _this.requestId,
|
148
|
-
ChatId: _this.chatToken.chatId
|
149
|
-
|
150
|
-
|
151
|
-
throw new Error(exceptionDetails.response);
|
145
|
+
ChatId: _this.chatToken.chatId
|
146
|
+
};
|
147
|
+
exceptionThrowers_1.default.throwUnsupportedPlatform(_this.scenarioMarker, telemetryEvent, message, telemetryData);
|
152
148
|
}
|
153
149
|
requestOptionalParams.getContext = true;
|
154
150
|
}
|
@@ -231,7 +227,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
231
227
|
OmnichannelChatSDK.prototype.initialize = function (optionalParams) {
|
232
228
|
if (optionalParams === void 0) { optionalParams = {}; }
|
233
229
|
return __awaiter(this, void 0, void 0, function () {
|
234
|
-
var _a, getLiveChatConfigOptionalParams, _b, _c,
|
230
|
+
var _a, e_1, getLiveChatConfigOptionalParams, e_2, supportedLiveChatVersions, _b, _c, e_3;
|
235
231
|
return __generator(this, function (_d) {
|
236
232
|
switch (_d.label) {
|
237
233
|
case 0:
|
@@ -242,17 +238,37 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
242
238
|
}
|
243
239
|
_d.label = 1;
|
244
240
|
case 1:
|
245
|
-
_d.trys.push([1,
|
241
|
+
_d.trys.push([1, 3, , 4]);
|
246
242
|
this.OCSDKProvider = ocsdk_1.SDKProvider;
|
247
243
|
_a = this;
|
248
244
|
return [4 /*yield*/, ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, {}, this.ocSdkLogger)];
|
249
245
|
case 2:
|
250
246
|
_a.OCClient = _d.sent();
|
247
|
+
return [3 /*break*/, 4];
|
248
|
+
case 3:
|
249
|
+
e_1 = _d.sent();
|
250
|
+
exceptionThrowers_1.default.throwOmnichannelClientInitializationFailure(e_1, this.scenarioMarker, TelemetryEvent_1.default.InitializeChatSDK);
|
251
|
+
return [3 /*break*/, 4];
|
252
|
+
case 4:
|
253
|
+
_d.trys.push([4, 6, , 7]);
|
251
254
|
getLiveChatConfigOptionalParams = optionalParams.getLiveChatConfigOptionalParams;
|
252
255
|
return [4 /*yield*/, this.getChatConfig(getLiveChatConfigOptionalParams || {})];
|
253
|
-
case
|
256
|
+
case 5:
|
254
257
|
_d.sent();
|
255
|
-
|
258
|
+
return [3 /*break*/, 7];
|
259
|
+
case 6:
|
260
|
+
e_2 = _d.sent();
|
261
|
+
exceptionThrowers_1.default.throwChatConfigRetrievalFailure(e_2, this.scenarioMarker, TelemetryEvent_1.default.InitializeChatSDK);
|
262
|
+
return [3 /*break*/, 7];
|
263
|
+
case 7:
|
264
|
+
supportedLiveChatVersions = [LiveChatVersion_1.default.V1, LiveChatVersion_1.default.V2];
|
265
|
+
if (!supportedLiveChatVersions.includes(this.liveChatVersion)) {
|
266
|
+
exceptionThrowers_1.default.throwUnsupportedLiveChatVersionFailure(new Error(ChatSDKErrors_1.default.UnsupportedLiveChatVersion), this.scenarioMarker, TelemetryEvent_1.default.InitializeChatSDK);
|
267
|
+
}
|
268
|
+
_d.label = 8;
|
269
|
+
case 8:
|
270
|
+
_d.trys.push([8, 13, , 14]);
|
271
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 10];
|
256
272
|
this.ACSClient = new ACSClient_1.default(this.acsClientLogger);
|
257
273
|
_b = this;
|
258
274
|
return [4 /*yield*/, omnichannel_amsclient_1.default({
|
@@ -261,28 +277,25 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
261
277
|
debug: false,
|
262
278
|
logger: this.amsClientLogger
|
263
279
|
})];
|
264
|
-
case
|
280
|
+
case 9:
|
265
281
|
_b.AMSClient = _d.sent();
|
266
|
-
return [3 /*break*/,
|
267
|
-
case
|
268
|
-
if (!(this.liveChatVersion === LiveChatVersion_1.default.V1)) return [3 /*break*/,
|
282
|
+
return [3 /*break*/, 12];
|
283
|
+
case 10:
|
284
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V1)) return [3 /*break*/, 12];
|
269
285
|
_c = this;
|
270
286
|
return [4 /*yield*/, this.getIC3Client()];
|
271
|
-
case
|
287
|
+
case 11:
|
272
288
|
_c.IC3Client = _d.sent();
|
273
|
-
|
274
|
-
case
|
275
|
-
case 8:
|
289
|
+
_d.label = 12;
|
290
|
+
case 12:
|
276
291
|
this.isInitialized = true;
|
277
292
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeChatSDK);
|
278
|
-
return [3 /*break*/,
|
279
|
-
case
|
280
|
-
|
281
|
-
this.scenarioMarker
|
282
|
-
|
283
|
-
|
284
|
-
return [3 /*break*/, 10];
|
285
|
-
case 10: return [2 /*return*/, this.liveChatConfig];
|
293
|
+
return [3 /*break*/, 14];
|
294
|
+
case 13:
|
295
|
+
e_3 = _d.sent();
|
296
|
+
exceptionThrowers_1.default.throwMessagingClientCreationFailure(e_3, this.scenarioMarker, TelemetryEvent_1.default.InitializeChatSDK);
|
297
|
+
return [3 /*break*/, 14];
|
298
|
+
case 14: return [2 /*return*/, this.liveChatConfig];
|
286
299
|
}
|
287
300
|
});
|
288
301
|
});
|
@@ -375,116 +388,108 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
375
388
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
376
389
|
if (optionalParams === void 0) { optionalParams = {}; }
|
377
390
|
return __awaiter(this, void 0, void 0, function () {
|
378
|
-
var shouldReinitIC3Client, _w, reconnectableChatsParams, reconnectableChatsResponse,
|
391
|
+
var shouldReinitIC3Client, _w, reconnectableChatsParams, reconnectableChatsResponse, e_4, telemetryData, conversationDetails, telemetryData, telemetryData, e_5, telemetryData, sessionInitOptionalParams, location_2, error_3, telemetryData, chatAdapterConfig, error_4, telemetryData, _x, error_5, telemetryData, error_6, telemetryData, error_7, telemetryData, _y, error_8, telemetryData;
|
379
392
|
var _this = this;
|
380
|
-
return __generator(this, function (
|
381
|
-
switch (
|
393
|
+
return __generator(this, function (_z) {
|
394
|
+
switch (_z.label) {
|
382
395
|
case 0:
|
383
396
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.StartChat, {
|
384
397
|
RequestId: this.requestId
|
385
398
|
});
|
399
|
+
if (!this.isInitialized) {
|
400
|
+
exceptionThrowers_1.default.throwUninitializedChatSDK(this.scenarioMarker, TelemetryEvent_1.default.StartChat);
|
401
|
+
}
|
386
402
|
shouldReinitIC3Client = !platform_1.default.isNode() && !platform_1.default.isReactNative() && !this.IC3Client && this.liveChatVersion === LiveChatVersion_1.default.V1;
|
387
403
|
if (!shouldReinitIC3Client) return [3 /*break*/, 2];
|
388
404
|
_w = this;
|
389
405
|
return [4 /*yield*/, this.getIC3Client()];
|
390
406
|
case 1:
|
391
|
-
_w.IC3Client =
|
392
|
-
|
407
|
+
_w.IC3Client = _z.sent();
|
408
|
+
_z.label = 2;
|
393
409
|
case 2:
|
394
410
|
if (this.isChatReconnect && !((_a = this.chatSDKConfig.chatReconnect) === null || _a === void 0 ? void 0 : _a.disable) && !this.isPersistentChat && optionalParams.reconnectId) {
|
395
411
|
this.reconnectId = optionalParams.reconnectId;
|
396
412
|
}
|
397
413
|
if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/, 6];
|
398
|
-
|
414
|
+
_z.label = 3;
|
399
415
|
case 3:
|
400
|
-
|
416
|
+
_z.trys.push([3, 5, , 6]);
|
401
417
|
reconnectableChatsParams = {
|
402
418
|
authenticatedUserToken: this.authenticatedUserToken
|
403
419
|
};
|
404
420
|
return [4 /*yield*/, this.OCClient.getReconnectableChats(reconnectableChatsParams)];
|
405
421
|
case 4:
|
406
|
-
reconnectableChatsResponse =
|
422
|
+
reconnectableChatsResponse = _z.sent();
|
407
423
|
if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
|
408
424
|
this.reconnectId = reconnectableChatsResponse.reconnectid;
|
409
425
|
}
|
410
426
|
return [3 /*break*/, 6];
|
411
427
|
case 5:
|
412
|
-
|
413
|
-
|
414
|
-
|
428
|
+
e_4 = _z.sent();
|
429
|
+
telemetryData = {
|
430
|
+
RequestId: this.requestId,
|
431
|
+
ChatId: this.chatToken.chatId,
|
415
432
|
};
|
416
|
-
|
433
|
+
exceptionThrowers_1.default.throwPersistentChatConversationRetrievalFailure(e_4, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
|
434
|
+
return [3 /*break*/, 6];
|
417
435
|
case 6:
|
418
436
|
if (!(optionalParams.liveChatContext && Object.keys(optionalParams.liveChatContext).length > 0 && !this.reconnectId)) return [3 /*break*/, 8];
|
419
437
|
this.chatToken = optionalParams.liveChatContext.chatToken || {};
|
420
438
|
this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
|
421
439
|
return [4 /*yield*/, this.getConversationDetails()];
|
422
440
|
case 7:
|
423
|
-
conversationDetails =
|
441
|
+
conversationDetails = _z.sent();
|
424
442
|
if (Object.keys(conversationDetails).length === 0) {
|
425
|
-
|
426
|
-
response: "InvalidConversation"
|
427
|
-
};
|
428
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
|
443
|
+
telemetryData = {
|
429
444
|
RequestId: this.requestId,
|
430
445
|
ChatId: this.chatToken.chatId,
|
431
|
-
|
432
|
-
|
433
|
-
console.error("Conversation not found");
|
434
|
-
throw Error(exceptionDetails.response);
|
446
|
+
};
|
447
|
+
exceptionThrowers_1.default.throwInvalidConversation(this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
|
435
448
|
}
|
436
449
|
if (conversationDetails.state === LiveWorkItemState_1.default.WrapUp || conversationDetails.state === LiveWorkItemState_1.default.Closed) {
|
437
|
-
|
438
|
-
|
439
|
-
};
|
440
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
|
450
|
+
console.error("Unable to join conversation that's in '" + conversationDetails.state + "' state");
|
451
|
+
telemetryData = {
|
441
452
|
RequestId: this.requestId,
|
442
453
|
ChatId: this.chatToken.chatId,
|
443
|
-
|
444
|
-
|
445
|
-
console.error("Unable to join conversation that's in '" + conversationDetails.state + "' state");
|
446
|
-
throw Error(exceptionDetails.response);
|
454
|
+
};
|
455
|
+
exceptionThrowers_1.default.throwClosedConversation(this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
|
447
456
|
}
|
448
|
-
|
457
|
+
_z.label = 8;
|
449
458
|
case 8:
|
450
459
|
if (!this.authSettings) return [3 /*break*/, 14];
|
451
460
|
if (!!this.authenticatedUserToken) return [3 /*break*/, 10];
|
452
461
|
return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken)];
|
453
462
|
case 9:
|
454
|
-
|
455
|
-
|
463
|
+
_z.sent();
|
464
|
+
_z.label = 10;
|
456
465
|
case 10:
|
457
466
|
if (!(optionalParams.liveChatContext && Object.keys(optionalParams.liveChatContext).length > 0)) return [3 /*break*/, 14];
|
458
467
|
this.chatToken = optionalParams.liveChatContext.chatToken || {};
|
459
468
|
this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
|
460
|
-
|
469
|
+
_z.label = 11;
|
461
470
|
case 11:
|
462
|
-
|
471
|
+
_z.trys.push([11, 13, , 14]);
|
463
472
|
return [4 /*yield*/, this.OCClient.validateAuthChatRecord(this.requestId, {
|
464
473
|
authenticatedUserToken: this.authenticatedUserToken,
|
465
474
|
chatId: this.chatToken.chatId
|
466
475
|
})];
|
467
476
|
case 12:
|
468
|
-
|
477
|
+
_z.sent();
|
469
478
|
return [3 /*break*/, 14];
|
470
479
|
case 13:
|
471
|
-
|
472
|
-
|
473
|
-
response: "OCClientValidateAuthChatRecordFailed",
|
474
|
-
message: "InvalidAuthChatRecord"
|
475
|
-
};
|
476
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
|
480
|
+
e_5 = _z.sent();
|
481
|
+
telemetryData = {
|
477
482
|
RequestId: this.requestId,
|
478
483
|
ChatId: this.chatToken.chatId,
|
479
|
-
|
480
|
-
|
481
|
-
|
484
|
+
};
|
485
|
+
exceptionThrowers_1.default.throwAuthenticatedChatConversationRetrievalFailure(e_5, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
|
486
|
+
return [3 /*break*/, 14];
|
482
487
|
case 14:
|
483
488
|
if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 16];
|
484
489
|
return [4 /*yield*/, this.getChatToken(false)];
|
485
490
|
case 15:
|
486
|
-
|
487
|
-
|
491
|
+
_z.sent();
|
492
|
+
_z.label = 16;
|
488
493
|
case 16:
|
489
494
|
(_c = this.ic3ClientLogger) === null || _c === void 0 ? void 0 : _c.setChatId(this.chatToken.chatId || '');
|
490
495
|
(_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setChatId(this.chatToken.chatId || '');
|
@@ -495,7 +500,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
495
500
|
sessionInitOptionalParams = {
|
496
501
|
initContext: {}
|
497
502
|
};
|
498
|
-
sessionInitOptionalParams = this.populateInitChatOptionalParam(sessionInitOptionalParams, optionalParams);
|
503
|
+
sessionInitOptionalParams = this.populateInitChatOptionalParam(sessionInitOptionalParams, optionalParams, TelemetryEvent_1.default.StartChat);
|
499
504
|
sessionInitOptionalParams.initContext.isProactiveChat = !!optionalParams.isProactiveChat;
|
500
505
|
if (this.isPersistentChat && !((_j = this.chatSDKConfig.persistentChat) === null || _j === void 0 ? void 0 : _j.disable)) {
|
501
506
|
sessionInitOptionalParams.reconnectId = this.reconnectId;
|
@@ -506,36 +511,31 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
506
511
|
if (!(((_m = (_l = this.liveChatConfig) === null || _l === void 0 ? void 0 : _l.LiveWSAndLiveChatEngJoin) === null || _m === void 0 ? void 0 : _m.msdyn_requestvisitorlocation) === "true")) return [3 /*break*/, 18];
|
507
512
|
return [4 /*yield*/, location_1.getLocationInfo(this.scenarioMarker, this.chatToken.chatId, this.requestId)];
|
508
513
|
case 17:
|
509
|
-
location_2 =
|
514
|
+
location_2 = _z.sent();
|
510
515
|
sessionInitOptionalParams.initContext.latitude = location_2.latitude;
|
511
516
|
sessionInitOptionalParams.initContext.longitude = location_2.longitude;
|
512
|
-
|
517
|
+
_z.label = 18;
|
513
518
|
case 18:
|
514
519
|
if (!!optionalParams.liveChatContext) return [3 /*break*/, 22];
|
515
|
-
|
520
|
+
_z.label = 19;
|
516
521
|
case 19:
|
517
|
-
|
522
|
+
_z.trys.push([19, 21, , 22]);
|
518
523
|
return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
|
519
524
|
case 20:
|
520
|
-
|
525
|
+
_z.sent();
|
521
526
|
return [3 /*break*/, 22];
|
522
527
|
case 21:
|
523
|
-
error_3 =
|
524
|
-
|
525
|
-
|
528
|
+
error_3 = _z.sent();
|
529
|
+
telemetryData = {
|
530
|
+
RequestId: this.requestId,
|
531
|
+
ChatId: this.chatToken.chatId,
|
526
532
|
};
|
527
533
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
528
534
|
if (((_o = error_3) === null || _o === void 0 ? void 0 : _o.isAxiosError) && ((_q = (_p = error_3.response) === null || _p === void 0 ? void 0 : _p.headers) === null || _q === void 0 ? void 0 : _q.errorcode.toString()) === OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour.toString()) {
|
529
|
-
|
530
|
-
exceptionDetails.message = 'Widget used outside of operating hours';
|
531
|
-
console.error(exceptionDetails.message);
|
535
|
+
exceptionThrowers_1.default.throwWidgetUseOutsideOperatingHour(error_3, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
|
532
536
|
}
|
533
|
-
this.scenarioMarker
|
534
|
-
|
535
|
-
ChatId: this.chatToken.chatId,
|
536
|
-
ExceptionDetails: JSON.stringify(exceptionDetails)
|
537
|
-
});
|
538
|
-
throw new Error(exceptionDetails.response);
|
537
|
+
exceptionThrowers_1.default.throwConversationInitializationFailure(error_3, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
|
538
|
+
return [3 /*break*/, 22];
|
539
539
|
case 22:
|
540
540
|
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 33];
|
541
541
|
chatAdapterConfig = {
|
@@ -545,120 +545,101 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
545
545
|
environmentUrl: this.chatToken.acsEndpoint,
|
546
546
|
pollingInterval: 30000
|
547
547
|
};
|
548
|
-
|
548
|
+
_z.label = 23;
|
549
549
|
case 23:
|
550
|
-
|
550
|
+
_z.trys.push([23, 25, , 26]);
|
551
551
|
return [4 /*yield*/, ((_r = this.ACSClient) === null || _r === void 0 ? void 0 : _r.initialize({
|
552
552
|
token: chatAdapterConfig.token,
|
553
553
|
environmentUrl: chatAdapterConfig.environmentUrl
|
554
554
|
}))];
|
555
555
|
case 24:
|
556
|
-
|
556
|
+
_z.sent();
|
557
557
|
return [3 /*break*/, 26];
|
558
558
|
case 25:
|
559
|
-
error_4 =
|
560
|
-
|
561
|
-
response: "ACSClientInitializeFailed"
|
562
|
-
};
|
563
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
|
559
|
+
error_4 = _z.sent();
|
560
|
+
telemetryData = {
|
564
561
|
RequestId: this.requestId,
|
565
562
|
ChatId: this.chatToken.chatId,
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
return [2 /*return*/, error_4];
|
563
|
+
};
|
564
|
+
exceptionThrowers_1.default.throwMessagingClientInitializationFailure(error_4, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
|
565
|
+
return [3 /*break*/, 26];
|
570
566
|
case 26:
|
571
|
-
|
572
|
-
|
567
|
+
_z.trys.push([26, 28, , 29]);
|
568
|
+
_x = this;
|
573
569
|
return [4 /*yield*/, ((_s = this.ACSClient) === null || _s === void 0 ? void 0 : _s.joinConversation({
|
574
570
|
id: chatAdapterConfig.id,
|
575
571
|
threadId: chatAdapterConfig.threadId,
|
576
572
|
pollingInterval: chatAdapterConfig.pollingInterval
|
577
573
|
}))];
|
578
574
|
case 27:
|
579
|
-
|
575
|
+
_x.conversation = (_z.sent());
|
580
576
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
|
581
577
|
RequestId: this.requestId,
|
582
578
|
ChatId: this.chatToken.chatId
|
583
579
|
});
|
584
580
|
return [3 /*break*/, 29];
|
585
581
|
case 28:
|
586
|
-
error_5 =
|
587
|
-
|
588
|
-
response: "ACSClientJoinConversationFailed"
|
589
|
-
};
|
590
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
|
582
|
+
error_5 = _z.sent();
|
583
|
+
telemetryData = {
|
591
584
|
RequestId: this.requestId,
|
592
585
|
ChatId: this.chatToken.chatId,
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
throw Error(exceptionDetails.response);
|
586
|
+
};
|
587
|
+
exceptionThrowers_1.default.throwMessagingClientConversationJoinFailure(error_5, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
|
588
|
+
return [3 /*break*/, 29];
|
597
589
|
case 29:
|
598
|
-
|
590
|
+
_z.trys.push([29, 31, , 32]);
|
599
591
|
return [4 /*yield*/, ((_t = this.AMSClient) === null || _t === void 0 ? void 0 : _t.initialize({
|
600
592
|
chatToken: this.chatToken
|
601
593
|
}))];
|
602
594
|
case 30:
|
603
|
-
|
595
|
+
_z.sent();
|
604
596
|
return [3 /*break*/, 32];
|
605
597
|
case 31:
|
606
|
-
error_6 =
|
607
|
-
|
608
|
-
response: "AMSClientInitializeFailed"
|
609
|
-
};
|
610
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
|
598
|
+
error_6 = _z.sent();
|
599
|
+
telemetryData = {
|
611
600
|
RequestId: this.requestId,
|
612
601
|
ChatId: this.chatToken.chatId,
|
613
|
-
|
614
|
-
|
615
|
-
|
602
|
+
};
|
603
|
+
exceptionThrowers_1.default.throwMessagingClientInitializationFailure(error_6, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
|
604
|
+
return [3 /*break*/, 32];
|
616
605
|
case 32: return [3 /*break*/, 39];
|
617
606
|
case 33:
|
618
|
-
|
607
|
+
_z.trys.push([33, 35, , 36]);
|
619
608
|
return [4 /*yield*/, this.IC3Client.initialize({
|
620
609
|
token: this.chatToken.token,
|
621
610
|
regionGtms: this.chatToken.regionGTMS,
|
622
611
|
visitor: true
|
623
612
|
})];
|
624
613
|
case 34:
|
625
|
-
|
614
|
+
_z.sent();
|
626
615
|
return [3 /*break*/, 36];
|
627
616
|
case 35:
|
628
|
-
error_7 =
|
629
|
-
|
630
|
-
response: "IC3ClientInitializeFailed"
|
631
|
-
};
|
632
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
|
617
|
+
error_7 = _z.sent();
|
618
|
+
telemetryData = {
|
633
619
|
RequestId: this.requestId,
|
634
620
|
ChatId: this.chatToken.chatId,
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
return [2 /*return*/, error_7];
|
621
|
+
};
|
622
|
+
exceptionThrowers_1.default.throwMessagingClientInitializationFailure(error_7, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
|
623
|
+
return [3 /*break*/, 36];
|
639
624
|
case 36:
|
640
|
-
|
641
|
-
|
625
|
+
_z.trys.push([36, 38, , 39]);
|
626
|
+
_y = this;
|
642
627
|
return [4 /*yield*/, this.IC3Client.joinConversation(this.chatToken.chatId)];
|
643
628
|
case 37:
|
644
|
-
|
629
|
+
_y.conversation = _z.sent();
|
645
630
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
|
646
631
|
RequestId: this.requestId,
|
647
632
|
ChatId: this.chatToken.chatId
|
648
633
|
});
|
649
634
|
return [3 /*break*/, 39];
|
650
635
|
case 38:
|
651
|
-
error_8 =
|
652
|
-
|
653
|
-
response: "IC3ClientJoinConversationFailed"
|
654
|
-
};
|
655
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
|
636
|
+
error_8 = _z.sent();
|
637
|
+
telemetryData = {
|
656
638
|
RequestId: this.requestId,
|
657
639
|
ChatId: this.chatToken.chatId,
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
return [2 /*return*/, error_8];
|
640
|
+
};
|
641
|
+
exceptionThrowers_1.default.throwMessagingClientConversationJoinFailure(error_8, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
|
642
|
+
return [3 /*break*/, 39];
|
662
643
|
case 39:
|
663
644
|
if (this.isPersistentChat && !((_u = this.chatSDKConfig.persistentChat) === null || _u === void 0 ? void 0 : _u.disable)) {
|
664
645
|
this.refreshTokenTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
@@ -681,7 +662,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
681
662
|
OmnichannelChatSDK.prototype.endChat = function () {
|
682
663
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
683
664
|
return __awaiter(this, void 0, void 0, function () {
|
684
|
-
var sessionCloseOptionalParams, isReconnectChat, isChatReconnect, error_9,
|
665
|
+
var sessionCloseOptionalParams, isReconnectChat, isChatReconnect, error_9, telemetryData;
|
685
666
|
return __generator(this, function (_r) {
|
686
667
|
switch (_r.label) {
|
687
668
|
case 0:
|
@@ -738,16 +719,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
738
719
|
return [3 /*break*/, 4];
|
739
720
|
case 3:
|
740
721
|
error_9 = _r.sent();
|
741
|
-
|
742
|
-
response: "OCClientSessionCloseFailed"
|
743
|
-
};
|
744
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.EndChat, {
|
722
|
+
telemetryData = {
|
745
723
|
RequestId: this.requestId,
|
746
|
-
ChatId: this.chatToken.chatId
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
return [2 /*return*/, error_9];
|
724
|
+
ChatId: this.chatToken.chatId
|
725
|
+
};
|
726
|
+
exceptionThrowers_1.default.throwConversationClosureFailure(error_9, this.scenarioMarker, TelemetryEvent_1.default.EndChat, telemetryData);
|
727
|
+
return [3 /*break*/, 4];
|
751
728
|
case 4:
|
752
729
|
if (this.refreshTokenTimer !== null) {
|
753
730
|
clearInterval(this.refreshTokenTimer);
|
@@ -778,6 +755,9 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
778
755
|
if (Object.keys(chatSession.chatToken).length === 0) {
|
779
756
|
return [2 /*return*/, {}];
|
780
757
|
}
|
758
|
+
if (this.reconnectId) {
|
759
|
+
chatSession.reconnectId = this.reconnectId;
|
760
|
+
}
|
781
761
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetCurrentLiveChatContext, {
|
782
762
|
RequestId: requestId,
|
783
763
|
ChatId: chatToken.chatId
|
@@ -787,33 +767,46 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
787
767
|
});
|
788
768
|
});
|
789
769
|
};
|
790
|
-
OmnichannelChatSDK.prototype.getConversationDetails = function () {
|
791
|
-
var _a, _b, _c
|
770
|
+
OmnichannelChatSDK.prototype.getConversationDetails = function (optionalParams) {
|
771
|
+
var _a, _b, _c;
|
772
|
+
if (optionalParams === void 0) { optionalParams = {}; }
|
792
773
|
return __awaiter(this, void 0, void 0, function () {
|
793
|
-
var getLWIDetailsOptionalParams, lwiDetails, state, conversationId, agentAcceptedOn, canRenderPostChat, participantType, liveWorkItemDetails, error_10;
|
794
|
-
return __generator(this, function (
|
795
|
-
switch (
|
774
|
+
var requestId, chatToken, chatId, reconnectId, getLWIDetailsOptionalParams, lwiDetails, state, conversationId, agentAcceptedOn, canRenderPostChat, participantType, liveWorkItemDetails, error_10, exceptionDetails;
|
775
|
+
return __generator(this, function (_d) {
|
776
|
+
switch (_d.label) {
|
796
777
|
case 0:
|
778
|
+
requestId = this.requestId;
|
779
|
+
chatToken = this.chatToken;
|
780
|
+
chatId = chatToken.chatId;
|
781
|
+
reconnectId = this.reconnectId;
|
782
|
+
if (optionalParams.liveChatContext) {
|
783
|
+
requestId = optionalParams.liveChatContext.requestId;
|
784
|
+
chatToken = optionalParams.liveChatContext.chatToken;
|
785
|
+
chatId = chatToken.chatId;
|
786
|
+
}
|
787
|
+
if ((_a = optionalParams.liveChatContext) === null || _a === void 0 ? void 0 : _a.reconnectId) {
|
788
|
+
reconnectId = optionalParams.liveChatContext.reconnectId;
|
789
|
+
}
|
797
790
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetConversationDetails, {
|
798
|
-
RequestId:
|
799
|
-
ChatId:
|
791
|
+
RequestId: requestId,
|
792
|
+
ChatId: chatId || '',
|
800
793
|
});
|
801
794
|
getLWIDetailsOptionalParams = {};
|
802
|
-
if (this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable) &&
|
803
|
-
getLWIDetailsOptionalParams.reconnectId =
|
795
|
+
if (this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable) && reconnectId) {
|
796
|
+
getLWIDetailsOptionalParams.reconnectId = reconnectId;
|
804
797
|
}
|
805
|
-
if (this.isChatReconnect && !((_c = this.chatSDKConfig.chatReconnect) === null || _c === void 0 ? void 0 : _c.disable) && !this.isPersistentChat &&
|
806
|
-
getLWIDetailsOptionalParams.reconnectId =
|
798
|
+
if (this.isChatReconnect && !((_c = this.chatSDKConfig.chatReconnect) === null || _c === void 0 ? void 0 : _c.disable) && !this.isPersistentChat && reconnectId) {
|
799
|
+
getLWIDetailsOptionalParams.reconnectId = reconnectId;
|
807
800
|
}
|
808
801
|
if (this.authenticatedUserToken) {
|
809
802
|
getLWIDetailsOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
810
803
|
}
|
811
|
-
|
804
|
+
_d.label = 1;
|
812
805
|
case 1:
|
813
|
-
|
814
|
-
return [4 /*yield*/, this.OCClient.getLWIDetails(
|
806
|
+
_d.trys.push([1, 3, , 4]);
|
807
|
+
return [4 /*yield*/, this.OCClient.getLWIDetails(requestId, getLWIDetailsOptionalParams)];
|
815
808
|
case 2:
|
816
|
-
lwiDetails =
|
809
|
+
lwiDetails = _d.sent();
|
817
810
|
state = lwiDetails.State, conversationId = lwiDetails.ConversationId, agentAcceptedOn = lwiDetails.AgentAcceptedOn, canRenderPostChat = lwiDetails.CanRenderPostChat, participantType = lwiDetails.ParticipantType;
|
818
811
|
liveWorkItemDetails = {
|
819
812
|
state: state,
|
@@ -829,17 +822,21 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
829
822
|
liveWorkItemDetails.participantType = participantType;
|
830
823
|
}
|
831
824
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetConversationDetails, {
|
832
|
-
RequestId:
|
833
|
-
ChatId:
|
825
|
+
RequestId: requestId,
|
826
|
+
ChatId: chatId || '',
|
834
827
|
});
|
835
828
|
return [2 /*return*/, liveWorkItemDetails];
|
836
829
|
case 3:
|
837
|
-
error_10 =
|
830
|
+
error_10 = _d.sent();
|
831
|
+
exceptionDetails = {
|
832
|
+
response: ChatSDKErrors_1.default.ConversationDetailsRetrievalFailure,
|
833
|
+
errorObject: "" + error_10
|
834
|
+
};
|
838
835
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetConversationDetails, {
|
839
|
-
RequestId:
|
840
|
-
ChatId:
|
836
|
+
RequestId: requestId,
|
837
|
+
ChatId: chatId || '',
|
838
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
841
839
|
});
|
842
|
-
console.error("OmnichannelChatSDK/getConversationDetails/error " + error_10);
|
843
840
|
return [3 /*break*/, 4];
|
844
841
|
case 4: return [2 /*return*/, {}];
|
845
842
|
}
|
@@ -879,20 +876,20 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
879
876
|
});
|
880
877
|
};
|
881
878
|
OmnichannelChatSDK.prototype.getChatToken = function (cached) {
|
882
|
-
var _a, _b;
|
879
|
+
var _a, _b, _c;
|
883
880
|
if (cached === void 0) { cached = true; }
|
884
881
|
return __awaiter(this, void 0, void 0, function () {
|
885
|
-
var getChatTokenOptionalParams, chatToken, chatId, token, regionGtms, expiresIn, visitorId, voiceVideoCallToken, acsEndpoint, attachmentConfiguration, error_11,
|
886
|
-
return __generator(this, function (
|
887
|
-
switch (
|
882
|
+
var getChatTokenOptionalParams, chatToken, chatId, token, regionGtms, expiresIn, visitorId, voiceVideoCallToken, acsEndpoint, attachmentConfiguration, error_11, telemetryData;
|
883
|
+
return __generator(this, function (_d) {
|
884
|
+
switch (_d.label) {
|
888
885
|
case 0:
|
889
886
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetChatToken, {
|
890
887
|
RequestId: this.requestId
|
891
888
|
});
|
892
889
|
if (!!cached) return [3 /*break*/, 5];
|
893
|
-
|
890
|
+
_d.label = 1;
|
894
891
|
case 1:
|
895
|
-
|
892
|
+
_d.trys.push([1, 3, , 4]);
|
896
893
|
getChatTokenOptionalParams = {};
|
897
894
|
if (this.authenticatedUserToken) {
|
898
895
|
getChatTokenOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
@@ -905,7 +902,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
905
902
|
}
|
906
903
|
return [4 /*yield*/, this.OCClient.getChatToken(this.requestId, getChatTokenOptionalParams)];
|
907
904
|
case 2:
|
908
|
-
chatToken =
|
905
|
+
chatToken = _d.sent();
|
909
906
|
chatId = chatToken.ChatId, token = chatToken.Token, regionGtms = chatToken.RegionGtms, expiresIn = chatToken.ExpiresIn, visitorId = chatToken.VisitorId, voiceVideoCallToken = chatToken.VoiceVideoCallToken, acsEndpoint = chatToken.ACSEndpoint, attachmentConfiguration = chatToken.AttachmentConfiguration;
|
910
907
|
this.chatToken = {
|
911
908
|
chatId: chatId,
|
@@ -926,16 +923,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
926
923
|
});
|
927
924
|
return [3 /*break*/, 4];
|
928
925
|
case 3:
|
929
|
-
error_11 =
|
930
|
-
|
931
|
-
response: "OCClientGetChatTokenFailed"
|
932
|
-
};
|
933
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetChatToken, {
|
926
|
+
error_11 = _d.sent();
|
927
|
+
telemetryData = {
|
934
928
|
RequestId: this.requestId,
|
935
|
-
ChatId: this.chatToken.chatId,
|
936
|
-
|
937
|
-
|
938
|
-
console.error("OmnichannelChatSDK/getChatToken/error " + error_11);
|
929
|
+
ChatId: (_c = this.chatToken) === null || _c === void 0 ? void 0 : _c.chatId,
|
930
|
+
};
|
931
|
+
exceptionThrowers_1.default.throwChatTokenRetrievalFailure(error_11, this.scenarioMarker, TelemetryEvent_1.default.GetChatToken, telemetryData);
|
939
932
|
return [3 /*break*/, 4];
|
940
933
|
case 4: return [3 /*break*/, 6];
|
941
934
|
case 5:
|
@@ -943,7 +936,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
943
936
|
RequestId: this.requestId,
|
944
937
|
ChatId: this.chatToken.chatId
|
945
938
|
});
|
946
|
-
|
939
|
+
_d.label = 6;
|
947
940
|
case 6: return [2 /*return*/, this.chatToken];
|
948
941
|
}
|
949
942
|
});
|
@@ -1610,31 +1603,41 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1610
1603
|
});
|
1611
1604
|
});
|
1612
1605
|
};
|
1613
|
-
OmnichannelChatSDK.prototype.getLiveChatTranscript = function () {
|
1606
|
+
OmnichannelChatSDK.prototype.getLiveChatTranscript = function (optionalParams) {
|
1607
|
+
if (optionalParams === void 0) { optionalParams = {}; }
|
1614
1608
|
return __awaiter(this, void 0, void 0, function () {
|
1615
|
-
var getChatTranscriptOptionalParams, transcriptResponse;
|
1609
|
+
var getChatTranscriptOptionalParams, requestId, chatToken, chatId, transcriptResponse, telemetryData;
|
1616
1610
|
return __generator(this, function (_a) {
|
1617
1611
|
getChatTranscriptOptionalParams = {};
|
1612
|
+
requestId = this.requestId;
|
1613
|
+
chatToken = this.chatToken;
|
1614
|
+
chatId = chatToken.chatId;
|
1615
|
+
if (optionalParams.liveChatContext) {
|
1616
|
+
requestId = optionalParams.liveChatContext.requestId;
|
1617
|
+
chatToken = optionalParams.liveChatContext.chatToken;
|
1618
|
+
chatId = chatToken.chatId;
|
1619
|
+
}
|
1618
1620
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetLiveChatTranscript, {
|
1619
|
-
RequestId:
|
1620
|
-
ChatId:
|
1621
|
+
RequestId: requestId,
|
1622
|
+
ChatId: chatId
|
1621
1623
|
});
|
1622
1624
|
try {
|
1623
1625
|
if (this.authenticatedUserToken) {
|
1624
1626
|
getChatTranscriptOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
1625
1627
|
}
|
1626
|
-
transcriptResponse = this.OCClient.getChatTranscripts(
|
1628
|
+
transcriptResponse = this.OCClient.getChatTranscripts(requestId, chatToken.chatId, chatToken.token, getChatTranscriptOptionalParams);
|
1627
1629
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetLiveChatTranscript, {
|
1628
|
-
RequestId:
|
1629
|
-
ChatId:
|
1630
|
+
RequestId: requestId,
|
1631
|
+
ChatId: chatId
|
1630
1632
|
});
|
1631
1633
|
return [2 /*return*/, transcriptResponse];
|
1632
1634
|
}
|
1633
1635
|
catch (error) {
|
1634
|
-
|
1635
|
-
RequestId:
|
1636
|
-
ChatId:
|
1637
|
-
}
|
1636
|
+
telemetryData = {
|
1637
|
+
RequestId: requestId,
|
1638
|
+
ChatId: chatId
|
1639
|
+
};
|
1640
|
+
exceptionThrowers_1.default.throwLiveChatTranscriptRetrievalFailure(error, this.scenarioMarker, TelemetryEvent_1.default.GetLiveChatTranscript, telemetryData);
|
1638
1641
|
}
|
1639
1642
|
return [2 /*return*/];
|
1640
1643
|
});
|
@@ -1671,31 +1674,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1671
1674
|
OmnichannelChatSDK.prototype.getVoiceVideoCalling = function (params) {
|
1672
1675
|
if (params === void 0) { params = {}; }
|
1673
1676
|
return __awaiter(this, void 0, void 0, function () {
|
1674
|
-
var
|
1677
|
+
var message, message, chatConfig, liveWSAndLiveChatEngJoin, msdyn_widgetsnippet, widgetSnippetSourceRegex, result;
|
1675
1678
|
var _this = this;
|
1676
1679
|
return __generator(this, function (_a) {
|
1677
1680
|
switch (_a.label) {
|
1678
1681
|
case 0:
|
1679
1682
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetVoiceVideoCalling);
|
1680
1683
|
if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
|
1681
|
-
|
1682
|
-
|
1683
|
-
message: "VoiceVideoCalling is only supported on browser"
|
1684
|
-
};
|
1685
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetVoiceVideoCalling, {
|
1686
|
-
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1687
|
-
});
|
1688
|
-
throw new Error(exceptionDetails.response);
|
1684
|
+
message = "VoiceVideoCalling is only supported on browser";
|
1685
|
+
exceptionThrowers_1.default.throwUnsupportedPlatform(this.scenarioMarker, TelemetryEvent_1.default.GetVoiceVideoCalling, message);
|
1689
1686
|
}
|
1690
1687
|
if (this.callingOption.toString() === CallingOptionsOptionSetNumber_1.default.NoCalling.toString()) {
|
1691
|
-
|
1692
|
-
|
1693
|
-
message: "Voice and video call is not enabled"
|
1694
|
-
};
|
1695
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetVoiceVideoCalling, {
|
1696
|
-
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1697
|
-
});
|
1698
|
-
throw new Error(exceptionDetails.response);
|
1688
|
+
message = "Voice and video call is not enabled";
|
1689
|
+
exceptionThrowers_1.default.throwFeatureDisabled(this.scenarioMarker, TelemetryEvent_1.default.GetVoiceVideoCalling, message);
|
1699
1690
|
}
|
1700
1691
|
return [4 /*yield*/, this.getChatConfig()];
|
1701
1692
|
case 1:
|
@@ -1874,7 +1865,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1874
1865
|
OmnichannelChatSDK.prototype.getAgentAvailability = function (optionalParams) {
|
1875
1866
|
if (optionalParams === void 0) { optionalParams = {}; }
|
1876
1867
|
return __awaiter(this, void 0, void 0, function () {
|
1877
|
-
var reportError, getAgentAvailabilityOptionalParams, response,
|
1868
|
+
var reportError, getAgentAvailabilityOptionalParams, response, e_6;
|
1878
1869
|
var _this = this;
|
1879
1870
|
return __generator(this, function (_a) {
|
1880
1871
|
switch (_a.label) {
|
@@ -1907,7 +1898,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1907
1898
|
getAgentAvailabilityOptionalParams = {
|
1908
1899
|
initContext: {}
|
1909
1900
|
};
|
1910
|
-
getAgentAvailabilityOptionalParams = this.populateInitChatOptionalParam(getAgentAvailabilityOptionalParams, optionalParams);
|
1901
|
+
getAgentAvailabilityOptionalParams = this.populateInitChatOptionalParam(getAgentAvailabilityOptionalParams, optionalParams, TelemetryEvent_1.default.GetAgentAvailability);
|
1911
1902
|
_a.label = 1;
|
1912
1903
|
case 1:
|
1913
1904
|
_a.trys.push([1, 3, , 4]);
|
@@ -1916,9 +1907,9 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1916
1907
|
response = _a.sent();
|
1917
1908
|
return [2 /*return*/, response];
|
1918
1909
|
case 3:
|
1919
|
-
|
1910
|
+
e_6 = _a.sent();
|
1920
1911
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
1921
|
-
reportError("GetAgentAvailabilityFailed",
|
1912
|
+
reportError("GetAgentAvailabilityFailed", e_6.message);
|
1922
1913
|
return [3 /*break*/, 4];
|
1923
1914
|
case 4: return [2 /*return*/];
|
1924
1915
|
}
|
@@ -2021,22 +2012,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2021
2012
|
OmnichannelChatSDK.prototype.getChatConfig = function (optionalParams) {
|
2022
2013
|
if (optionalParams === void 0) { optionalParams = {}; }
|
2023
2014
|
return __awaiter(this, void 0, void 0, function () {
|
2024
|
-
var sendCacheHeaders, bypassCache, liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, chatWidgetLanguage, msdyn_localeid, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled
|
2015
|
+
var sendCacheHeaders, bypassCache, liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, chatWidgetLanguage, msdyn_localeid, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled;
|
2025
2016
|
return __generator(this, function (_a) {
|
2026
2017
|
switch (_a.label) {
|
2027
2018
|
case 0:
|
2028
2019
|
sendCacheHeaders = optionalParams.sendCacheHeaders;
|
2029
|
-
_a.label = 1;
|
2030
|
-
case 1:
|
2031
|
-
_a.trys.push([1, 5, , 6]);
|
2032
2020
|
bypassCache = sendCacheHeaders === true;
|
2033
2021
|
return [4 /*yield*/, this.OCClient.getChatConfig(this.requestId, bypassCache)];
|
2034
|
-
case
|
2022
|
+
case 1:
|
2035
2023
|
liveChatConfig = _a.sent();
|
2036
2024
|
dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion, chatWidgetLanguage = liveChatConfig.ChatWidgetLanguage;
|
2037
2025
|
msdyn_localeid = chatWidgetLanguage.msdyn_localeid;
|
2038
2026
|
this.localeId = msdyn_localeid || locale_1.defaultLocaleId;
|
2039
|
-
this.liveChatVersion = liveChatVersion || LiveChatVersion_1.default.
|
2027
|
+
this.liveChatVersion = liveChatVersion || LiveChatVersion_1.default.V2;
|
2040
2028
|
/* istanbul ignore next */
|
2041
2029
|
this.debug && console.log("[OmnichannelChatSDK][getChatConfig][liveChatVersion] " + this.liveChatVersion);
|
2042
2030
|
setting = dataMaskingConfig.setting;
|
@@ -2058,12 +2046,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2058
2046
|
if (isPreChatEnabled && preChatSurvey && preChatSurvey.trim().length > 0) {
|
2059
2047
|
this.preChatSurvey = preChatSurvey;
|
2060
2048
|
}
|
2061
|
-
if (!this.authSettings) return [3 /*break*/,
|
2049
|
+
if (!this.authSettings) return [3 /*break*/, 3];
|
2062
2050
|
return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken)];
|
2063
|
-
case
|
2051
|
+
case 2:
|
2064
2052
|
_a.sent();
|
2065
|
-
_a.label =
|
2066
|
-
case
|
2053
|
+
_a.label = 3;
|
2054
|
+
case 3:
|
2067
2055
|
if (this.preChatSurvey) {
|
2068
2056
|
/* istanbul ignore next */
|
2069
2057
|
this.debug && console.log('Prechat Survey!');
|
@@ -2071,11 +2059,6 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2071
2059
|
this.callingOption = msdyn_callingoptions;
|
2072
2060
|
this.liveChatConfig = liveChatConfig;
|
2073
2061
|
return [2 /*return*/, this.liveChatConfig];
|
2074
|
-
case 5:
|
2075
|
-
error_18 = _a.sent();
|
2076
|
-
console.error("OmnichannelChatSDK/getChatConfig/error " + error_18);
|
2077
|
-
return [2 /*return*/, error_18];
|
2078
|
-
case 6: return [2 /*return*/];
|
2079
2062
|
}
|
2080
2063
|
});
|
2081
2064
|
});
|
@@ -2088,7 +2071,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2088
2071
|
};
|
2089
2072
|
OmnichannelChatSDK.prototype.updateChatToken = function (newToken, newRegionGTMS) {
|
2090
2073
|
return __awaiter(this, void 0, void 0, function () {
|
2091
|
-
var sessionInfo,
|
2074
|
+
var sessionInfo, error_18, exceptionDetails;
|
2092
2075
|
return __generator(this, function (_a) {
|
2093
2076
|
switch (_a.label) {
|
2094
2077
|
case 0:
|
@@ -2116,7 +2099,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2116
2099
|
});
|
2117
2100
|
return [3 /*break*/, 5];
|
2118
2101
|
case 4:
|
2119
|
-
|
2102
|
+
error_18 = _a.sent();
|
2120
2103
|
exceptionDetails = {
|
2121
2104
|
response: "UpdateChatTokenFailed"
|
2122
2105
|
};
|
@@ -2125,7 +2108,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2125
2108
|
ChatId: this.chatToken.chatId,
|
2126
2109
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2127
2110
|
});
|
2128
|
-
console.error("OmnichannelChatSDK/updateChatToken/error " +
|
2111
|
+
console.error("OmnichannelChatSDK/updateChatToken/error " + error_18);
|
2129
2112
|
return [3 /*break*/, 5];
|
2130
2113
|
case 5: return [2 /*return*/];
|
2131
2114
|
}
|