@microsoft/omnichannel-chat-sdk 1.11.6-main.b982edb → 1.11.7-main.6fd4ccf
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.
@@ -118,6 +118,9 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
118
118
|
this.ACSClient = null;
|
119
119
|
this.AMSClient = null;
|
120
120
|
this.sessionId = null;
|
121
|
+
// Operation queue for serializing chat operations
|
122
|
+
this.chatOperationInProgress = false;
|
123
|
+
this.pendingOperations = [];
|
121
124
|
this.unqServicesOrgUrl = null;
|
122
125
|
this.coreServicesOrgUrl = null;
|
123
126
|
this.dynamicsLocationCode = null;
|
@@ -254,6 +257,59 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
254
257
|
}
|
255
258
|
loggerUtils_1.default.setRequestId(this.requestId, this.ocSdkLogger, this.acsClientLogger, this.acsAdapterLogger, this.callingSdkLogger, this.amsClientLogger, this.ic3ClientLogger);
|
256
259
|
}
|
260
|
+
/**
|
261
|
+
* Executes an operation with mutual exclusion to prevent race conditions
|
262
|
+
* between startChat and endChat operations
|
263
|
+
*/
|
264
|
+
OmnichannelChatSDK.prototype.executeWithLock = function (operation) {
|
265
|
+
return __awaiter(this, void 0, void 0, function () {
|
266
|
+
var _this = this;
|
267
|
+
return __generator(this, function (_a) {
|
268
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
269
|
+
var wrappedOperation = function () { return __awaiter(_this, void 0, void 0, function () {
|
270
|
+
var result, error_1;
|
271
|
+
return __generator(this, function (_a) {
|
272
|
+
switch (_a.label) {
|
273
|
+
case 0:
|
274
|
+
_a.trys.push([0, 2, 3, 4]);
|
275
|
+
return [4 /*yield*/, operation()];
|
276
|
+
case 1:
|
277
|
+
result = _a.sent();
|
278
|
+
resolve(result);
|
279
|
+
return [3 /*break*/, 4];
|
280
|
+
case 2:
|
281
|
+
error_1 = _a.sent();
|
282
|
+
reject(error_1);
|
283
|
+
return [3 /*break*/, 4];
|
284
|
+
case 3:
|
285
|
+
this.chatOperationInProgress = false;
|
286
|
+
this.processNextOperation();
|
287
|
+
return [7 /*endfinally*/];
|
288
|
+
case 4: return [2 /*return*/];
|
289
|
+
}
|
290
|
+
});
|
291
|
+
}); };
|
292
|
+
if (_this.chatOperationInProgress) {
|
293
|
+
_this.pendingOperations.push(wrappedOperation);
|
294
|
+
}
|
295
|
+
else {
|
296
|
+
_this.chatOperationInProgress = true;
|
297
|
+
wrappedOperation();
|
298
|
+
}
|
299
|
+
})];
|
300
|
+
});
|
301
|
+
});
|
302
|
+
};
|
303
|
+
/**
|
304
|
+
* Processes the next pending operation in the queue
|
305
|
+
*/
|
306
|
+
OmnichannelChatSDK.prototype.processNextOperation = function () {
|
307
|
+
if (this.pendingOperations.length > 0) {
|
308
|
+
this.chatOperationInProgress = true;
|
309
|
+
var nextOperation = this.pendingOperations.shift();
|
310
|
+
nextOperation();
|
311
|
+
}
|
312
|
+
};
|
257
313
|
/**
|
258
314
|
*
|
259
315
|
* @param flag Flag to enable/disable debug log telemetry, will be applied to all components
|
@@ -441,7 +497,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
441
497
|
};
|
442
498
|
OmnichannelChatSDK.prototype.parallelInitialization = function () {
|
443
499
|
return __awaiter(this, arguments, void 0, function (optionalParams) {
|
444
|
-
var
|
500
|
+
var error_2, telemetryData;
|
445
501
|
if (optionalParams === void 0) { optionalParams = {}; }
|
446
502
|
return __generator(this, function (_a) {
|
447
503
|
switch (_a.label) {
|
@@ -462,13 +518,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
462
518
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeChatSDKParallel);
|
463
519
|
return [3 /*break*/, 3];
|
464
520
|
case 2:
|
465
|
-
|
521
|
+
error_2 = _a.sent();
|
466
522
|
telemetryData = {
|
467
523
|
RequestId: this.requestId,
|
468
|
-
ExceptionDetails: (
|
524
|
+
ExceptionDetails: (error_2 instanceof ChatSDKError_1.ChatSDKError) ? JSON.stringify(error_2.exceptionDetails) : "".concat(error_2)
|
469
525
|
};
|
470
526
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.InitializeChatSDKParallel, telemetryData);
|
471
|
-
throw
|
527
|
+
throw error_2;
|
472
528
|
case 3: return [2 /*return*/, this.liveChatConfig];
|
473
529
|
}
|
474
530
|
});
|
@@ -628,7 +684,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
628
684
|
};
|
629
685
|
OmnichannelChatSDK.prototype.getChatReconnectContextWithAuthToken = function () {
|
630
686
|
return __awaiter(this, void 0, void 0, function () {
|
631
|
-
var context, reconnectableChatsParams, reconnectableChatsResponse,
|
687
|
+
var context, reconnectableChatsParams, reconnectableChatsResponse, error_3, exceptionDetails, telemetryData;
|
632
688
|
return __generator(this, function (_a) {
|
633
689
|
switch (_a.label) {
|
634
690
|
case 0:
|
@@ -659,7 +715,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
659
715
|
});
|
660
716
|
return [3 /*break*/, 4];
|
661
717
|
case 3:
|
662
|
-
|
718
|
+
error_3 = _a.sent();
|
663
719
|
exceptionDetails = {
|
664
720
|
response: "OCClientGetReconnectableChatsFailed"
|
665
721
|
};
|
@@ -668,11 +724,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
668
724
|
ChatId: this.chatToken.chatId,
|
669
725
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
670
726
|
};
|
671
|
-
if ((0, utilities_1.isClientIdNotFoundErrorMessage)(
|
672
|
-
exceptionThrowers_1.default.throwAuthContactIdNotFoundFailure(
|
727
|
+
if ((0, utilities_1.isClientIdNotFoundErrorMessage)(error_3)) {
|
728
|
+
exceptionThrowers_1.default.throwAuthContactIdNotFoundFailure(error_3, this.scenarioMarker, TelemetryEvent_1.default.GetChatReconnectContextWithAuthToken, telemetryData);
|
673
729
|
}
|
674
730
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetChatReconnectContextWithAuthToken, telemetryData);
|
675
|
-
console.error("OmnichannelChatSDK/GetChatReconnectContextWithAuthToken/error ".concat(
|
731
|
+
console.error("OmnichannelChatSDK/GetChatReconnectContextWithAuthToken/error ".concat(error_3));
|
676
732
|
return [3 /*break*/, 4];
|
677
733
|
case 4: return [2 /*return*/, context];
|
678
734
|
}
|
@@ -681,7 +737,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
681
737
|
};
|
682
738
|
OmnichannelChatSDK.prototype.getChatReconnectContextWithReconnectId = function () {
|
683
739
|
return __awaiter(this, arguments, void 0, function (optionalParams) {
|
684
|
-
var context, reconnectAvailabilityResponse,
|
740
|
+
var context, reconnectAvailabilityResponse, error_4, exceptionDetails;
|
685
741
|
if (optionalParams === void 0) { optionalParams = {}; }
|
686
742
|
return __generator(this, function (_a) {
|
687
743
|
switch (_a.label) {
|
@@ -716,7 +772,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
716
772
|
});
|
717
773
|
return [3 /*break*/, 4];
|
718
774
|
case 3:
|
719
|
-
|
775
|
+
error_4 = _a.sent();
|
720
776
|
exceptionDetails = {
|
721
777
|
response: "OCClientGetReconnectAvailabilityFailed"
|
722
778
|
};
|
@@ -725,7 +781,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
725
781
|
ChatId: this.chatToken.chatId,
|
726
782
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
727
783
|
});
|
728
|
-
console.error("OmnichannelChatSDK/GetChatReconnectContextWithReconnectId/error ".concat(
|
784
|
+
console.error("OmnichannelChatSDK/GetChatReconnectContextWithReconnectId/error ".concat(error_4));
|
729
785
|
return [3 /*break*/, 4];
|
730
786
|
case 4:
|
731
787
|
//here the context contains recconnectionId if valid, or redirectionURL if not valid
|
@@ -780,7 +836,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
780
836
|
};
|
781
837
|
OmnichannelChatSDK.prototype.startChat = function () {
|
782
838
|
return __awaiter(this, arguments, void 0, function (optionalParams) {
|
783
|
-
var
|
839
|
+
var _this = this;
|
840
|
+
if (optionalParams === void 0) { optionalParams = {}; }
|
841
|
+
return __generator(this, function (_a) {
|
842
|
+
return [2 /*return*/, this.executeWithLock(function () { return _this.internalStartChat(optionalParams); })];
|
843
|
+
});
|
844
|
+
});
|
845
|
+
};
|
846
|
+
OmnichannelChatSDK.prototype.internalStartChat = function () {
|
847
|
+
return __awaiter(this, arguments, void 0, function (optionalParams) {
|
848
|
+
var shouldReinitIC3Client, _a, reconnectableChatsParams, reconnectableChatsResponse, e_6, telemetryData, conversationDetails, telemetryData, telemetryData, e_7, telemetryData, sessionInitOptionalParams, location_2, sessionInitPromise, createConversationPromise, messagingClientPromise, attachmentClientPromise, error_5;
|
784
849
|
var _this = this;
|
785
850
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
786
851
|
if (optionalParams === void 0) { optionalParams = {}; }
|
@@ -919,7 +984,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
919
984
|
_o.label = 18;
|
920
985
|
case 18:
|
921
986
|
sessionInitPromise = function () { return __awaiter(_this, void 0, void 0, function () {
|
922
|
-
var
|
987
|
+
var error_6, telemetryData;
|
923
988
|
var _a, _b, _c;
|
924
989
|
return __generator(this, function (_d) {
|
925
990
|
switch (_d.label) {
|
@@ -933,23 +998,23 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
933
998
|
_d.sent();
|
934
999
|
return [3 /*break*/, 4];
|
935
1000
|
case 3:
|
936
|
-
|
1001
|
+
error_6 = _d.sent();
|
937
1002
|
telemetryData = {
|
938
1003
|
RequestId: this.requestId,
|
939
1004
|
ChatId: this.chatToken.chatId,
|
940
1005
|
};
|
941
1006
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
942
|
-
if ((
|
943
|
-
exceptionThrowers_1.default.throwWidgetUseOutsideOperatingHour(
|
1007
|
+
if ((error_6 === null || error_6 === void 0 ? void 0 : error_6.isAxiosError) && ((_c = (_b = (_a = error_6.response) === null || _a === void 0 ? void 0 : _a.headers) === null || _b === void 0 ? void 0 : _b.errorcode) === null || _c === void 0 ? void 0 : _c.toString()) === OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour.toString()) {
|
1008
|
+
exceptionThrowers_1.default.throwWidgetUseOutsideOperatingHour(error_6, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
|
944
1009
|
}
|
945
|
-
exceptionThrowers_1.default.throwConversationInitializationFailure(
|
1010
|
+
exceptionThrowers_1.default.throwConversationInitializationFailure(error_6, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
|
946
1011
|
return [3 /*break*/, 4];
|
947
1012
|
case 4: return [2 /*return*/];
|
948
1013
|
}
|
949
1014
|
});
|
950
1015
|
}); };
|
951
1016
|
createConversationPromise = function () { return __awaiter(_this, void 0, void 0, function () {
|
952
|
-
var chatToken,
|
1017
|
+
var chatToken, error_7, telemetryData;
|
953
1018
|
var _a, _b, _c;
|
954
1019
|
return __generator(this, function (_d) {
|
955
1020
|
switch (_d.label) {
|
@@ -967,23 +1032,23 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
967
1032
|
}
|
968
1033
|
return [3 /*break*/, 4];
|
969
1034
|
case 3:
|
970
|
-
|
1035
|
+
error_7 = _d.sent();
|
971
1036
|
telemetryData = {
|
972
1037
|
RequestId: this.requestId,
|
973
1038
|
ChatId: this.chatToken.chatId,
|
974
1039
|
};
|
975
1040
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
976
|
-
if ((
|
977
|
-
exceptionThrowers_1.default.throwWidgetUseOutsideOperatingHour(
|
1041
|
+
if ((error_7 === null || error_7 === void 0 ? void 0 : error_7.isAxiosError) && ((_c = (_b = (_a = error_7.response) === null || _a === void 0 ? void 0 : _a.headers) === null || _b === void 0 ? void 0 : _b.errorcode) === null || _c === void 0 ? void 0 : _c.toString()) === OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour.toString()) {
|
1042
|
+
exceptionThrowers_1.default.throwWidgetUseOutsideOperatingHour(error_7, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
|
978
1043
|
}
|
979
|
-
exceptionThrowers_1.default.throwConversationInitializationFailure(
|
1044
|
+
exceptionThrowers_1.default.throwConversationInitializationFailure(error_7, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
|
980
1045
|
return [3 /*break*/, 4];
|
981
1046
|
case 4: return [2 /*return*/];
|
982
1047
|
}
|
983
1048
|
});
|
984
1049
|
}); };
|
985
1050
|
messagingClientPromise = function () { return __awaiter(_this, void 0, void 0, function () {
|
986
|
-
var chatAdapterConfig,
|
1051
|
+
var chatAdapterConfig, error_8, telemetryData, _a, error_9, telemetryData, error_10, telemetryData, _b, error_11, telemetryData;
|
987
1052
|
var _c, _d;
|
988
1053
|
return __generator(this, function (_e) {
|
989
1054
|
switch (_e.label) {
|
@@ -1007,12 +1072,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1007
1072
|
_e.sent();
|
1008
1073
|
return [3 /*break*/, 4];
|
1009
1074
|
case 3:
|
1010
|
-
|
1075
|
+
error_8 = _e.sent();
|
1011
1076
|
telemetryData = {
|
1012
1077
|
RequestId: this.requestId,
|
1013
1078
|
ChatId: this.chatToken.chatId,
|
1014
1079
|
};
|
1015
|
-
exceptionThrowers_1.default.throwMessagingClientInitializationFailure(
|
1080
|
+
exceptionThrowers_1.default.throwMessagingClientInitializationFailure(error_8, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
|
1016
1081
|
return [3 /*break*/, 4];
|
1017
1082
|
case 4:
|
1018
1083
|
_e.trys.push([4, 6, , 7]);
|
@@ -1030,12 +1095,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1030
1095
|
});
|
1031
1096
|
return [3 /*break*/, 7];
|
1032
1097
|
case 6:
|
1033
|
-
|
1098
|
+
error_9 = _e.sent();
|
1034
1099
|
telemetryData = {
|
1035
1100
|
RequestId: this.requestId,
|
1036
1101
|
ChatId: this.chatToken.chatId,
|
1037
1102
|
};
|
1038
|
-
exceptionThrowers_1.default.throwMessagingClientConversationJoinFailure(
|
1103
|
+
exceptionThrowers_1.default.throwMessagingClientConversationJoinFailure(error_9, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
|
1039
1104
|
return [3 /*break*/, 7];
|
1040
1105
|
case 7: return [3 /*break*/, 14];
|
1041
1106
|
case 8:
|
@@ -1049,12 +1114,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1049
1114
|
_e.sent();
|
1050
1115
|
return [3 /*break*/, 11];
|
1051
1116
|
case 10:
|
1052
|
-
|
1117
|
+
error_10 = _e.sent();
|
1053
1118
|
telemetryData = {
|
1054
1119
|
RequestId: this.requestId,
|
1055
1120
|
ChatId: this.chatToken.chatId,
|
1056
1121
|
};
|
1057
|
-
exceptionThrowers_1.default.throwMessagingClientInitializationFailure(
|
1122
|
+
exceptionThrowers_1.default.throwMessagingClientInitializationFailure(error_10, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
|
1058
1123
|
return [3 /*break*/, 11];
|
1059
1124
|
case 11:
|
1060
1125
|
_e.trys.push([11, 13, , 14]);
|
@@ -1068,19 +1133,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1068
1133
|
});
|
1069
1134
|
return [3 /*break*/, 14];
|
1070
1135
|
case 13:
|
1071
|
-
|
1136
|
+
error_11 = _e.sent();
|
1072
1137
|
telemetryData = {
|
1073
1138
|
RequestId: this.requestId,
|
1074
1139
|
ChatId: this.chatToken.chatId,
|
1075
1140
|
};
|
1076
|
-
exceptionThrowers_1.default.throwMessagingClientConversationJoinFailure(
|
1141
|
+
exceptionThrowers_1.default.throwMessagingClientConversationJoinFailure(error_11, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
|
1077
1142
|
return [3 /*break*/, 14];
|
1078
1143
|
case 14: return [2 /*return*/];
|
1079
1144
|
}
|
1080
1145
|
});
|
1081
1146
|
}); };
|
1082
1147
|
attachmentClientPromise = function () { return __awaiter(_this, void 0, void 0, function () {
|
1083
|
-
var amsClient,
|
1148
|
+
var amsClient, error_12, telemetryData;
|
1084
1149
|
return __generator(this, function (_a) {
|
1085
1150
|
switch (_a.label) {
|
1086
1151
|
case 0:
|
@@ -1100,7 +1165,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1100
1165
|
_a.label = 3;
|
1101
1166
|
case 3: return [3 /*break*/, 5];
|
1102
1167
|
case 4:
|
1103
|
-
|
1168
|
+
error_12 = _a.sent();
|
1104
1169
|
telemetryData = {
|
1105
1170
|
RequestId: this.requestId,
|
1106
1171
|
ChatId: this.chatToken.chatId,
|
@@ -1127,15 +1192,15 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1127
1192
|
_o.sent();
|
1128
1193
|
return [3 /*break*/, 26];
|
1129
1194
|
case 24:
|
1130
|
-
|
1195
|
+
error_5 = _o.sent();
|
1131
1196
|
// If conversation joining fails after conversation was created, clean up the conversation
|
1132
1197
|
// Only cleanup conversations that were freshly created (not existing ones being reconnected to)
|
1133
|
-
return [4 /*yield*/, this.handleConversationJoinFailure(
|
1198
|
+
return [4 /*yield*/, this.handleConversationJoinFailure(error_5, optionalParams)];
|
1134
1199
|
case 25:
|
1135
1200
|
// If conversation joining fails after conversation was created, clean up the conversation
|
1136
1201
|
// Only cleanup conversations that were freshly created (not existing ones being reconnected to)
|
1137
1202
|
_o.sent();
|
1138
|
-
throw
|
1203
|
+
throw error_5; // Re-throw the original error
|
1139
1204
|
case 26:
|
1140
1205
|
if (this.isPersistentChat && !((_l = this.chatSDKConfig.persistentChat) === null || _l === void 0 ? void 0 : _l.disable)) {
|
1141
1206
|
this.refreshTokenTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
@@ -1157,7 +1222,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1157
1222
|
};
|
1158
1223
|
OmnichannelChatSDK.prototype.closeChat = function (endChatOptionalParams) {
|
1159
1224
|
return __awaiter(this, void 0, void 0, function () {
|
1160
|
-
var cleanupMetadata, sessionCloseOptionalParams, isReconnectChat, isChatReconnect,
|
1225
|
+
var cleanupMetadata, sessionCloseOptionalParams, isReconnectChat, isChatReconnect, error_13;
|
1161
1226
|
var _a, _b;
|
1162
1227
|
return __generator(this, function (_c) {
|
1163
1228
|
switch (_c.label) {
|
@@ -1192,8 +1257,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1192
1257
|
_c.sent();
|
1193
1258
|
return [3 /*break*/, 4];
|
1194
1259
|
case 3:
|
1195
|
-
|
1196
|
-
exceptionThrowers_1.default.throwConversationClosureFailure(
|
1260
|
+
error_13 = _c.sent();
|
1261
|
+
exceptionThrowers_1.default.throwConversationClosureFailure(error_13, this.scenarioMarker, TelemetryEvent_1.default.CloseChatSession, __assign(__assign({}, cleanupMetadata), { isSessionEnded: String(!(endChatOptionalParams === null || endChatOptionalParams === void 0 ? void 0 : endChatOptionalParams.isSessionEnded)) }));
|
1197
1262
|
return [3 /*break*/, 4];
|
1198
1263
|
case 4:
|
1199
1264
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.CloseChatSession, cleanupMetadata);
|
@@ -1205,7 +1270,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1205
1270
|
};
|
1206
1271
|
OmnichannelChatSDK.prototype.endChat = function () {
|
1207
1272
|
return __awaiter(this, arguments, void 0, function (endChatOptionalParams) {
|
1208
|
-
var
|
1273
|
+
var _this = this;
|
1274
|
+
if (endChatOptionalParams === void 0) { endChatOptionalParams = {}; }
|
1275
|
+
return __generator(this, function (_a) {
|
1276
|
+
return [2 /*return*/, this.executeWithLock(function () { return _this.internalEndChat(endChatOptionalParams); })];
|
1277
|
+
});
|
1278
|
+
});
|
1279
|
+
};
|
1280
|
+
OmnichannelChatSDK.prototype.internalEndChat = function () {
|
1281
|
+
return __awaiter(this, arguments, void 0, function (endChatOptionalParams) {
|
1282
|
+
var cleanupMetadata, error_14, telemetryData;
|
1209
1283
|
var _a;
|
1210
1284
|
if (endChatOptionalParams === void 0) { endChatOptionalParams = {}; }
|
1211
1285
|
return __generator(this, function (_b) {
|
@@ -1255,15 +1329,15 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1255
1329
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EndChat, cleanupMetadata);
|
1256
1330
|
return [3 /*break*/, 7];
|
1257
1331
|
case 6:
|
1258
|
-
|
1332
|
+
error_14 = _b.sent();
|
1259
1333
|
telemetryData = {
|
1260
1334
|
RequestId: this.requestId,
|
1261
1335
|
ChatId: this.chatToken.chatId
|
1262
1336
|
};
|
1263
|
-
if (
|
1264
|
-
exceptionThrowers_1.default.throwConversationClosureFailure(new Error(JSON.stringify(
|
1337
|
+
if (error_14 instanceof ChatSDKError_1.ChatSDKError) {
|
1338
|
+
exceptionThrowers_1.default.throwConversationClosureFailure(new Error(JSON.stringify(error_14.exceptionDetails)), this.scenarioMarker, TelemetryEvent_1.default.EndChat, telemetryData);
|
1265
1339
|
}
|
1266
|
-
exceptionThrowers_1.default.throwConversationClosureFailure(
|
1340
|
+
exceptionThrowers_1.default.throwConversationClosureFailure(error_14, this.scenarioMarker, TelemetryEvent_1.default.EndChat, telemetryData);
|
1267
1341
|
return [3 /*break*/, 7];
|
1268
1342
|
case 7: return [2 /*return*/];
|
1269
1343
|
}
|
@@ -1310,7 +1384,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1310
1384
|
};
|
1311
1385
|
OmnichannelChatSDK.prototype.getConversationDetails = function () {
|
1312
1386
|
return __awaiter(this, arguments, void 0, function (optionalParams) {
|
1313
|
-
var requestId, chatToken, chatId, reconnectId, sessionId, getLWIDetailsOptionalParams, lwiDetails, state, conversationId, agentAcceptedOn, canRenderPostChat, participantType, liveWorkItemDetails,
|
1387
|
+
var requestId, chatToken, chatId, reconnectId, sessionId, getLWIDetailsOptionalParams, lwiDetails, state, conversationId, agentAcceptedOn, canRenderPostChat, participantType, liveWorkItemDetails, error_15, telemetryData;
|
1314
1388
|
var _a, _b, _c, _d;
|
1315
1389
|
if (optionalParams === void 0) { optionalParams = {}; }
|
1316
1390
|
return __generator(this, function (_e) {
|
@@ -1383,15 +1457,15 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1383
1457
|
});
|
1384
1458
|
return [2 /*return*/, liveWorkItemDetails];
|
1385
1459
|
case 3:
|
1386
|
-
|
1460
|
+
error_15 = _e.sent();
|
1387
1461
|
telemetryData = {
|
1388
1462
|
RequestId: requestId,
|
1389
1463
|
ChatId: chatId
|
1390
1464
|
};
|
1391
|
-
if ((0, utilities_1.isClientIdNotFoundErrorMessage)(
|
1392
|
-
exceptionThrowers_1.default.throwAuthContactIdNotFoundFailure(
|
1465
|
+
if ((0, utilities_1.isClientIdNotFoundErrorMessage)(error_15)) {
|
1466
|
+
exceptionThrowers_1.default.throwAuthContactIdNotFoundFailure(error_15, this.scenarioMarker, TelemetryEvent_1.default.GetConversationDetails, telemetryData);
|
1393
1467
|
}
|
1394
|
-
exceptionSuppressors_1.default.suppressConversationDetailsRetrievalFailure(
|
1468
|
+
exceptionSuppressors_1.default.suppressConversationDetailsRetrievalFailure(error_15, this.scenarioMarker, TelemetryEvent_1.default.GetConversationDetails, telemetryData);
|
1395
1469
|
return [3 /*break*/, 4];
|
1396
1470
|
case 4: return [2 /*return*/, {}];
|
1397
1471
|
}
|
@@ -1432,7 +1506,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1432
1506
|
};
|
1433
1507
|
OmnichannelChatSDK.prototype.getChatToken = function () {
|
1434
1508
|
return __awaiter(this, arguments, void 0, function (cached, optionalParams) {
|
1435
|
-
var getChatTokenOptionalParams, chatToken,
|
1509
|
+
var getChatTokenOptionalParams, chatToken, error_16, telemetryData;
|
1436
1510
|
var _a, _b, _c;
|
1437
1511
|
if (cached === void 0) { cached = true; }
|
1438
1512
|
return __generator(this, function (_d) {
|
@@ -1474,16 +1548,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1474
1548
|
});
|
1475
1549
|
return [3 /*break*/, 4];
|
1476
1550
|
case 3:
|
1477
|
-
|
1551
|
+
error_16 = _d.sent();
|
1478
1552
|
telemetryData = {
|
1479
1553
|
RequestId: this.requestId,
|
1480
1554
|
ChatId: (_c = this.chatToken) === null || _c === void 0 ? void 0 : _c.chatId,
|
1481
1555
|
};
|
1482
|
-
if ((0, utilities_1.isClientIdNotFoundErrorMessage)(
|
1483
|
-
exceptionThrowers_1.default.throwAuthContactIdNotFoundFailure(
|
1556
|
+
if ((0, utilities_1.isClientIdNotFoundErrorMessage)(error_16)) {
|
1557
|
+
exceptionThrowers_1.default.throwAuthContactIdNotFoundFailure(error_16, this.scenarioMarker, TelemetryEvent_1.default.GetChatToken, telemetryData);
|
1484
1558
|
}
|
1485
1559
|
else {
|
1486
|
-
exceptionThrowers_1.default.throwChatTokenRetrievalFailure(
|
1560
|
+
exceptionThrowers_1.default.throwChatTokenRetrievalFailure(error_16, this.scenarioMarker, TelemetryEvent_1.default.GetChatToken, telemetryData);
|
1487
1561
|
}
|
1488
1562
|
return [3 /*break*/, 4];
|
1489
1563
|
case 4: return [3 /*break*/, 6];
|
@@ -1627,7 +1701,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1627
1701
|
};
|
1628
1702
|
OmnichannelChatSDK.prototype.sendMessage = function (message) {
|
1629
1703
|
return __awaiter(this, void 0, void 0, function () {
|
1630
|
-
var sendMessageRequest, chatMessage,
|
1704
|
+
var sendMessageRequest, chatMessage, error_17, exceptionDetails, messageToSend, error_18, exceptionDetails;
|
1631
1705
|
var _a;
|
1632
1706
|
return __generator(this, function (_b) {
|
1633
1707
|
switch (_b.label) {
|
@@ -1663,10 +1737,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1663
1737
|
});
|
1664
1738
|
return [2 /*return*/, chatMessage];
|
1665
1739
|
case 3:
|
1666
|
-
|
1740
|
+
error_17 = _b.sent();
|
1667
1741
|
exceptionDetails = {
|
1668
1742
|
response: ChatSDKError_1.ChatSDKErrorName.ChatSDKSendMessageFailed,
|
1669
|
-
errorObject: "".concat(
|
1743
|
+
errorObject: "".concat(error_17)
|
1670
1744
|
};
|
1671
1745
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendMessages, {
|
1672
1746
|
RequestId: this.requestId,
|
@@ -1675,7 +1749,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1675
1749
|
});
|
1676
1750
|
throw new ChatSDKError_1.ChatSDKError(ChatSDKError_1.ChatSDKErrorName.ChatSDKSendMessageFailed, undefined, {
|
1677
1751
|
response: ChatSDKError_1.ChatSDKErrorName.ChatSDKSendMessageFailed,
|
1678
|
-
errorObject: "".concat(
|
1752
|
+
errorObject: "".concat(error_17)
|
1679
1753
|
});
|
1680
1754
|
case 4: return [3 /*break*/, 9];
|
1681
1755
|
case 5:
|
@@ -1711,10 +1785,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1711
1785
|
});
|
1712
1786
|
return [3 /*break*/, 9];
|
1713
1787
|
case 8:
|
1714
|
-
|
1788
|
+
error_18 = _b.sent();
|
1715
1789
|
exceptionDetails = {
|
1716
1790
|
response: ChatSDKError_1.ChatSDKErrorName.ChatSDKSendMessageFailed,
|
1717
|
-
errorObject: "".concat(
|
1791
|
+
errorObject: "".concat(error_18)
|
1718
1792
|
};
|
1719
1793
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendMessages, {
|
1720
1794
|
RequestId: this.requestId,
|
@@ -1801,7 +1875,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1801
1875
|
};
|
1802
1876
|
OmnichannelChatSDK.prototype.sendTypingEvent = function () {
|
1803
1877
|
return __awaiter(this, void 0, void 0, function () {
|
1804
|
-
var
|
1878
|
+
var error_19;
|
1805
1879
|
return __generator(this, function (_a) {
|
1806
1880
|
switch (_a.label) {
|
1807
1881
|
case 0:
|
@@ -1830,7 +1904,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1830
1904
|
});
|
1831
1905
|
return [3 /*break*/, 5];
|
1832
1906
|
case 4:
|
1833
|
-
|
1907
|
+
error_19 = _a.sent();
|
1834
1908
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendTypingEvent, {
|
1835
1909
|
RequestId: this.requestId,
|
1836
1910
|
ChatId: this.chatToken.chatId
|
@@ -1967,7 +2041,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1967
2041
|
};
|
1968
2042
|
OmnichannelChatSDK.prototype.uploadFileAttachment = function (fileInfo) {
|
1969
2043
|
return __awaiter(this, void 0, void 0, function () {
|
1970
|
-
var amsClient, createObjectResponse, documentId, uploadDocumentResponse, fileIdsProperty, fileMetaProperty, sendMessageRequest, messageToSend,
|
2044
|
+
var amsClient, createObjectResponse, documentId, uploadDocumentResponse, fileIdsProperty, fileMetaProperty, sendMessageRequest, messageToSend, error_20, fileMetadata, messageToSend, error_21;
|
1971
2045
|
var _a, _b;
|
1972
2046
|
return __generator(this, function (_c) {
|
1973
2047
|
switch (_c.label) {
|
@@ -2036,7 +2110,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2036
2110
|
});
|
2037
2111
|
return [2 /*return*/, messageToSend];
|
2038
2112
|
case 6:
|
2039
|
-
|
2113
|
+
error_20 = _c.sent();
|
2040
2114
|
console.error("OmnichannelChatSDK/uploadFileAttachment/sendMessage/error");
|
2041
2115
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.UploadFileAttachment, {
|
2042
2116
|
RequestId: this.requestId,
|
@@ -2082,8 +2156,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2082
2156
|
});
|
2083
2157
|
return [2 /*return*/, messageToSend];
|
2084
2158
|
case 15:
|
2085
|
-
|
2086
|
-
console.error("OmnichannelChatSDK/uploadFileAttachment/error: ".concat(
|
2159
|
+
error_21 = _c.sent();
|
2160
|
+
console.error("OmnichannelChatSDK/uploadFileAttachment/error: ".concat(error_21));
|
2087
2161
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.UploadFileAttachment, {
|
2088
2162
|
RequestId: this.requestId,
|
2089
2163
|
ChatId: this.chatToken.chatId
|
@@ -2096,7 +2170,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2096
2170
|
};
|
2097
2171
|
OmnichannelChatSDK.prototype.downloadFileAttachment = function (fileMetadata) {
|
2098
2172
|
return __awaiter(this, void 0, void 0, function () {
|
2099
|
-
var amsClient, response, view_location, viewResponse, _a, downloadedFile,
|
2173
|
+
var amsClient, response, view_location, viewResponse, _a, downloadedFile, error_22;
|
2100
2174
|
return __generator(this, function (_b) {
|
2101
2175
|
switch (_b.label) {
|
2102
2176
|
case 0:
|
@@ -2156,8 +2230,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2156
2230
|
});
|
2157
2231
|
return [2 /*return*/, downloadedFile];
|
2158
2232
|
case 9:
|
2159
|
-
|
2160
|
-
console.error("OmnichannelChatSDK/downloadFileAttachment/error: ".concat(
|
2233
|
+
error_22 = _b.sent();
|
2234
|
+
console.error("OmnichannelChatSDK/downloadFileAttachment/error: ".concat(error_22));
|
2161
2235
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
|
2162
2236
|
RequestId: this.requestId,
|
2163
2237
|
ChatId: this.chatToken.chatId
|
@@ -2170,7 +2244,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2170
2244
|
};
|
2171
2245
|
OmnichannelChatSDK.prototype.emailLiveChatTranscript = function (body_1) {
|
2172
2246
|
return __awaiter(this, arguments, void 0, function (body, optionalParams) {
|
2173
|
-
var emailTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, emailRequestBody,
|
2247
|
+
var emailTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, emailRequestBody, error_23;
|
2174
2248
|
var _a;
|
2175
2249
|
if (optionalParams === void 0) { optionalParams = {}; }
|
2176
2250
|
return __generator(this, function (_b) {
|
@@ -2221,8 +2295,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2221
2295
|
});
|
2222
2296
|
return [3 /*break*/, 4];
|
2223
2297
|
case 3:
|
2224
|
-
|
2225
|
-
console.error("OmnichannelChatSDK/emailLiveChatTranscript/error: ".concat(
|
2298
|
+
error_23 = _b.sent();
|
2299
|
+
console.error("OmnichannelChatSDK/emailLiveChatTranscript/error: ".concat(error_23));
|
2226
2300
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.EmailLiveChatTranscript, {
|
2227
2301
|
RequestId: requestId,
|
2228
2302
|
ChatId: chatId
|
@@ -2235,7 +2309,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2235
2309
|
};
|
2236
2310
|
OmnichannelChatSDK.prototype.getLiveChatTranscript = function () {
|
2237
2311
|
return __awaiter(this, arguments, void 0, function (optionalParams) {
|
2238
|
-
var getChatTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, transcriptResponse,
|
2312
|
+
var getChatTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, transcriptResponse, error_24, telemetryData;
|
2239
2313
|
var _a, _b;
|
2240
2314
|
if (optionalParams === void 0) { optionalParams = {}; }
|
2241
2315
|
return __generator(this, function (_c) {
|
@@ -2292,12 +2366,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2292
2366
|
});
|
2293
2367
|
return [2 /*return*/, transcriptResponse];
|
2294
2368
|
case 3:
|
2295
|
-
|
2369
|
+
error_24 = _c.sent();
|
2296
2370
|
telemetryData = {
|
2297
2371
|
RequestId: requestId,
|
2298
2372
|
ChatId: chatId
|
2299
2373
|
};
|
2300
|
-
exceptionThrowers_1.default.throwLiveChatTranscriptRetrievalFailure(
|
2374
|
+
exceptionThrowers_1.default.throwLiveChatTranscriptRetrievalFailure(error_24, this.scenarioMarker, TelemetryEvent_1.default.GetLiveChatTranscript, telemetryData);
|
2301
2375
|
return [3 /*break*/, 4];
|
2302
2376
|
case 4: return [2 /*return*/];
|
2303
2377
|
}
|
@@ -2412,7 +2486,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2412
2486
|
};
|
2413
2487
|
OmnichannelChatSDK.prototype.getPostChatSurveyContext = function () {
|
2414
2488
|
return __awaiter(this, void 0, void 0, function () {
|
2415
|
-
var conversationId, chatConfig, liveWSAndLiveChatEngJoin, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, msfp_botsourcesurveyidentifier, postConversationSurveyOwnerId, postConversationBotSurveyOwnerId, msdyn_surveyprovider, surveyProvider, liveWorkItemDetails, participantJoined, participantType, agentSurveyInviteLinkRequest, botSurveyInviteLinkRequest, optionalParams, agentSurveyInviteLinkResponse, botSurveyInviteLinkResponse,
|
2489
|
+
var conversationId, chatConfig, liveWSAndLiveChatEngJoin, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, msfp_botsourcesurveyidentifier, postConversationSurveyOwnerId, postConversationBotSurveyOwnerId, msdyn_surveyprovider, surveyProvider, liveWorkItemDetails, participantJoined, participantType, agentSurveyInviteLinkRequest, botSurveyInviteLinkRequest, optionalParams, _a, agentSurveyInviteLinkResponse, botSurveyInviteLinkResponse, agentSurveyInviteLink, agentFormsProLocale, botSurveyInviteLink, botFormsProLocale, postChatContext, ex_1;
|
2416
2490
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
2417
2491
|
return __generator(this, function (_o) {
|
2418
2492
|
switch (_o.label) {
|
@@ -2426,7 +2500,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2426
2500
|
}
|
2427
2501
|
_o.label = 1;
|
2428
2502
|
case 1:
|
2429
|
-
_o.trys.push([1,
|
2503
|
+
_o.trys.push([1, 6, , 7]);
|
2430
2504
|
chatConfig = this.liveChatConfig;
|
2431
2505
|
liveWSAndLiveChatEngJoin = chatConfig.LiveWSAndLiveChatEngJoin;
|
2432
2506
|
msdyn_postconversationsurveyenable = liveWSAndLiveChatEngJoin.msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_sourcesurveyidentifier, msfp_botsourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_botsourcesurveyidentifier, postConversationSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationSurveyOwnerId, postConversationBotSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationBotSurveyOwnerId, msdyn_surveyprovider = liveWSAndLiveChatEngJoin.msdyn_surveyprovider;
|
@@ -2439,7 +2513,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2439
2513
|
});
|
2440
2514
|
return [2 /*return*/, Promise.reject("GetPostChatSurveyContext : msfp_sourcesurveyidentifier is mandatory for survey provider ".concat(SurveyProvider_1.SurveyProvider.CustomerVoice, "."))];
|
2441
2515
|
}
|
2442
|
-
if (!((0, parsers_1.parseLowerCaseString)(msdyn_postconversationsurveyenable) === "true")) return [3 /*break*/,
|
2516
|
+
if (!((0, parsers_1.parseLowerCaseString)(msdyn_postconversationsurveyenable) === "true")) return [3 /*break*/, 4];
|
2443
2517
|
return [4 /*yield*/, this.getConversationDetails()];
|
2444
2518
|
case 2:
|
2445
2519
|
liveWorkItemDetails = _o.sent();
|
@@ -2482,17 +2556,14 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2482
2556
|
if (this.authenticatedUserToken) {
|
2483
2557
|
optionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
2484
2558
|
}
|
2485
|
-
return [4 /*yield*/,
|
2559
|
+
return [4 /*yield*/, Promise.all([
|
2560
|
+
this.OCClient.getSurveyInviteLink(postConversationSurveyOwnerId, agentSurveyInviteLinkRequest, optionalParams),
|
2561
|
+
(postConversationBotSurveyOwnerId && msfp_botsourcesurveyidentifier)
|
2562
|
+
? this.OCClient.getSurveyInviteLink(postConversationBotSurveyOwnerId, botSurveyInviteLinkRequest, optionalParams)
|
2563
|
+
: Promise.resolve(null)
|
2564
|
+
])];
|
2486
2565
|
case 3:
|
2487
|
-
|
2488
|
-
_a = postConversationBotSurveyOwnerId && msfp_botsourcesurveyidentifier;
|
2489
|
-
if (!_a) return [3 /*break*/, 5];
|
2490
|
-
return [4 /*yield*/, this.OCClient.getSurveyInviteLink(postConversationBotSurveyOwnerId, botSurveyInviteLinkRequest, optionalParams)];
|
2491
|
-
case 4:
|
2492
|
-
_a = (_o.sent());
|
2493
|
-
_o.label = 5;
|
2494
|
-
case 5:
|
2495
|
-
botSurveyInviteLinkResponse = _a;
|
2566
|
+
_a = _o.sent(), agentSurveyInviteLinkResponse = _a[0], botSurveyInviteLinkResponse = _a[1];
|
2496
2567
|
agentSurveyInviteLink = void 0, agentFormsProLocale = void 0, botSurveyInviteLink = void 0, botFormsProLocale = void 0;
|
2497
2568
|
if (agentSurveyInviteLinkResponse != null) {
|
2498
2569
|
if (agentSurveyInviteLinkResponse.inviteList != null && agentSurveyInviteLinkResponse.inviteList.length == 1) {
|
@@ -2541,16 +2612,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2541
2612
|
});
|
2542
2613
|
return [2 /*return*/, Promise.reject("surveyInviteLinkResponse is null.")];
|
2543
2614
|
}
|
2544
|
-
return [3 /*break*/,
|
2545
|
-
case
|
2615
|
+
return [3 /*break*/, 5];
|
2616
|
+
case 4:
|
2546
2617
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
|
2547
2618
|
RequestId: this.requestId,
|
2548
2619
|
ChatId: (_l = this.chatToken) === null || _l === void 0 ? void 0 : _l.chatId,
|
2549
2620
|
ExceptionDetails: "Post Chat Survey is disabled. Please check the Omnichannel Administration Portal."
|
2550
2621
|
});
|
2551
2622
|
return [2 /*return*/, Promise.reject("Post Chat is disabled from admin side, or chat doesnt have a survey as part of their configuration.")];
|
2552
|
-
case
|
2553
|
-
case
|
2623
|
+
case 5: return [3 /*break*/, 7];
|
2624
|
+
case 6:
|
2554
2625
|
ex_1 = _o.sent();
|
2555
2626
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
|
2556
2627
|
ConversationId: conversationId !== null && conversationId !== void 0 ? conversationId : "",
|
@@ -2559,7 +2630,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2559
2630
|
ExceptionDetails: JSON.stringify(ex_1)
|
2560
2631
|
});
|
2561
2632
|
return [2 /*return*/, Promise.reject("Retrieving post chat context failed " + JSON.stringify(ex_1))];
|
2562
|
-
case
|
2633
|
+
case 7: return [2 /*return*/];
|
2563
2634
|
}
|
2564
2635
|
});
|
2565
2636
|
});
|
@@ -2836,7 +2907,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2836
2907
|
};
|
2837
2908
|
OmnichannelChatSDK.prototype.getChatConfig = function () {
|
2838
2909
|
return __awaiter(this, arguments, void 0, function (optionalParams) {
|
2839
|
-
var sendCacheHeaders, bypassCache, liveChatConfig,
|
2910
|
+
var sendCacheHeaders, bypassCache, liveChatConfig, error_25, _a;
|
2840
2911
|
var _b, _c;
|
2841
2912
|
if (optionalParams === void 0) { optionalParams = {}; }
|
2842
2913
|
return __generator(this, function (_d) {
|
@@ -2857,8 +2928,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2857
2928
|
this.debug && console.log("[OmnichannelChatSDK][getChatConfig][liveChatVersion] ".concat(this.liveChatVersion));
|
2858
2929
|
return [2 /*return*/, this.liveChatConfig];
|
2859
2930
|
case 3:
|
2860
|
-
|
2861
|
-
if (!(0, internalUtils_1.isCoreServicesOrgUrlDNSError)(
|
2931
|
+
error_25 = _d.sent();
|
2932
|
+
if (!(0, internalUtils_1.isCoreServicesOrgUrlDNSError)(error_25, this.coreServicesOrgUrl, this.dynamicsLocationCode)) return [3 /*break*/, 6];
|
2862
2933
|
this.omnichannelConfig.orgUrl = this.unqServicesOrgUrl;
|
2863
2934
|
_a = this;
|
2864
2935
|
return [4 /*yield*/, ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, (0, createOcSDKConfiguration_1.default)(false), this.ocSdkLogger)];
|
@@ -2870,10 +2941,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2870
2941
|
return [3 /*break*/, 7];
|
2871
2942
|
case 6:
|
2872
2943
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2873
|
-
if (((_c = (_b =
|
2944
|
+
if (((_c = (_b = error_25.response) === null || _b === void 0 ? void 0 : _b.headers) === null || _c === void 0 ? void 0 : _c.errorcode) && parseInt(error_25.response.headers.errorcode) === OmnichannelErrorCodes_1.default.WidgetNotFound) {
|
2874
2945
|
console.warn("No widget with the given app id is present in the system.");
|
2875
2946
|
}
|
2876
|
-
throw
|
2947
|
+
throw error_25; // Bubble up error by default to throw ChatConfigRetrievalFailure
|
2877
2948
|
case 7: return [3 /*break*/, 8];
|
2878
2949
|
case 8: return [2 /*return*/, this.liveChatConfig];
|
2879
2950
|
}
|
@@ -2908,7 +2979,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2908
2979
|
};
|
2909
2980
|
OmnichannelChatSDK.prototype.updateChatToken = function (newToken, newRegionGTMS) {
|
2910
2981
|
return __awaiter(this, void 0, void 0, function () {
|
2911
|
-
var sessionInfo,
|
2982
|
+
var sessionInfo, error_26, exceptionDetails;
|
2912
2983
|
return __generator(this, function (_a) {
|
2913
2984
|
switch (_a.label) {
|
2914
2985
|
case 0:
|
@@ -2936,7 +3007,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2936
3007
|
});
|
2937
3008
|
return [3 /*break*/, 5];
|
2938
3009
|
case 4:
|
2939
|
-
|
3010
|
+
error_26 = _a.sent();
|
2940
3011
|
exceptionDetails = {
|
2941
3012
|
response: "UpdateChatTokenFailed"
|
2942
3013
|
};
|
@@ -2953,7 +3024,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2953
3024
|
};
|
2954
3025
|
OmnichannelChatSDK.prototype.setAuthTokenProvider = function (provider_1) {
|
2955
3026
|
return __awaiter(this, arguments, void 0, function (provider, optionalParams) {
|
2956
|
-
var token, exceptionDetails,
|
3027
|
+
var token, exceptionDetails, error_27, exceptionDetails, exceptionDetails;
|
2957
3028
|
if (optionalParams === void 0) { optionalParams = {}; }
|
2958
3029
|
return __generator(this, function (_a) {
|
2959
3030
|
switch (_a.label) {
|
@@ -2985,12 +3056,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2985
3056
|
}
|
2986
3057
|
return [3 /*break*/, 4];
|
2987
3058
|
case 3:
|
2988
|
-
|
3059
|
+
error_27 = _a.sent();
|
2989
3060
|
exceptionDetails = {
|
2990
3061
|
response: ChatSDKError_1.ChatSDKErrorName.GetAuthTokenFailed
|
2991
3062
|
};
|
2992
|
-
if (
|
2993
|
-
exceptionDetails.response =
|
3063
|
+
if (error_27.message == ChatSDKError_1.ChatSDKErrorName.UndefinedAuthToken) {
|
3064
|
+
exceptionDetails.response = error_27.message;
|
2994
3065
|
}
|
2995
3066
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2996
3067
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
@@ -3064,7 +3135,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
3064
3135
|
* and ensure a retry in startChat won't be affected with
|
3065
3136
|
* data from a failed session
|
3066
3137
|
*/
|
3067
|
-
return [4 /*yield*/, this.
|
3138
|
+
return [4 /*yield*/, this.internalEndChat()];
|
3068
3139
|
case 2:
|
3069
3140
|
/**
|
3070
3141
|
* Calling cleanup to take care of any session cleanup,
|