@microsoft/omnichannel-chat-sdk 1.10.2-main.377272c → 1.10.2-main.936acc1
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/lib/OmnichannelChatSDK.d.ts +3 -1
- package/lib/OmnichannelChatSDK.js +110 -70
- package/lib/OmnichannelChatSDK.js.map +1 -1
- package/lib/core/EndChatOptionalParams.d.ts +3 -0
- package/lib/core/EndChatOptionalParams.js +3 -0
- package/lib/core/EndChatOptionalParams.js.map +1 -0
- package/lib/core/OmnichannelErrorCodes.d.ts +2 -1
- package/lib/core/OmnichannelErrorCodes.js +1 -0
- package/lib/core/OmnichannelErrorCodes.js.map +1 -1
- package/lib/telemetry/TelemetryEvent.d.ts +1 -0
- package/lib/telemetry/TelemetryEvent.js +1 -0
- package/lib/telemetry/TelemetryEvent.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
@@ -8,6 +8,7 @@ import ChatSDKConfig from "./core/ChatSDKConfig";
|
|
8
8
|
import ChatSDKMessage from "./core/messaging/ChatSDKMessage";
|
9
9
|
import ChatTranscriptBody from "./core/ChatTranscriptBody";
|
10
10
|
import EmailLiveChatTranscriptOptionaParams from "./core/EmailLiveChatTranscriptOptionalParams";
|
11
|
+
import EndChatOptionalParams from "./core/EndChatOptionalParams";
|
11
12
|
import FileMetadata from "@microsoft/omnichannel-amsclient/lib/FileMetadata";
|
12
13
|
import FramedClient from "@microsoft/omnichannel-amsclient/lib/FramedClient";
|
13
14
|
import FramedlessClient from "@microsoft/omnichannel-amsclient/lib/FramedlessClient";
|
@@ -89,7 +90,8 @@ declare class OmnichannelChatSDK {
|
|
89
90
|
private getChatReconnectContextWithReconnectId;
|
90
91
|
getChatReconnectContext(optionalParams?: ChatReconnectOptionalParams): Promise<ChatReconnectContext>;
|
91
92
|
startChat(optionalParams?: StartChatOptionalParams): Promise<void>;
|
92
|
-
|
93
|
+
private closeChat;
|
94
|
+
endChat(endChatOptionalParams?: EndChatOptionalParams): Promise<void>;
|
93
95
|
getCurrentLiveChatContext(): Promise<LiveChatContext | {}>;
|
94
96
|
getConversationDetails(optionalParams?: GetConversationDetailsOptionalParams): Promise<LiveWorkItemDetails>;
|
95
97
|
/**
|
@@ -975,17 +975,24 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
975
975
|
});
|
976
976
|
});
|
977
977
|
};
|
978
|
-
OmnichannelChatSDK.prototype.
|
978
|
+
OmnichannelChatSDK.prototype.closeChat = function (endChatOptionalParams) {
|
979
979
|
return __awaiter(this, void 0, void 0, function () {
|
980
|
-
var sessionCloseOptionalParams, isReconnectChat, isChatReconnect, error_10
|
981
|
-
var _a, _b
|
982
|
-
return __generator(this, function (
|
983
|
-
switch (
|
980
|
+
var cleanupMetadata, sessionCloseOptionalParams, isReconnectChat, isChatReconnect, error_10;
|
981
|
+
var _a, _b;
|
982
|
+
return __generator(this, function (_c) {
|
983
|
+
switch (_c.label) {
|
984
984
|
case 0:
|
985
|
-
|
985
|
+
cleanupMetadata = {
|
986
986
|
RequestId: this.requestId,
|
987
|
-
ChatId: this.chatToken.chatId
|
988
|
-
|
987
|
+
ChatId: this.chatToken.chatId,
|
988
|
+
isSessionEnded: !(endChatOptionalParams === null || endChatOptionalParams === void 0 ? void 0 : endChatOptionalParams.isSessionEnded)
|
989
|
+
};
|
990
|
+
// in case a session was ended by agent or disconnected, there is no need to close the session
|
991
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.CloseChatSession, cleanupMetadata);
|
992
|
+
if (!!(endChatOptionalParams === null || endChatOptionalParams === void 0 ? void 0 : endChatOptionalParams.isSessionEnded)) return [3 /*break*/, 5];
|
993
|
+
_c.label = 1;
|
994
|
+
case 1:
|
995
|
+
_c.trys.push([1, 3, , 4]);
|
989
996
|
sessionCloseOptionalParams = {};
|
990
997
|
if (this.isPersistentChat && !((_a = this.chatSDKConfig.persistentChat) === null || _a === void 0 ? void 0 : _a.disable)) {
|
991
998
|
isReconnectChat = this.reconnectId !== null ? true : false;
|
@@ -1000,17 +1007,44 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1000
1007
|
if (this.authenticatedUserToken) {
|
1001
1008
|
sessionCloseOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
1002
1009
|
}
|
1003
|
-
_d.label = 1;
|
1004
|
-
case 1:
|
1005
|
-
_d.trys.push([1, 3, , 4]);
|
1006
1010
|
return [4 /*yield*/, this.OCClient.sessionClose(this.requestId, sessionCloseOptionalParams)];
|
1007
1011
|
case 2:
|
1008
|
-
|
1009
|
-
|
1012
|
+
_c.sent();
|
1013
|
+
return [3 /*break*/, 4];
|
1014
|
+
case 3:
|
1015
|
+
error_10 = _c.sent();
|
1016
|
+
exceptionThrowers_1.default.throwConversationClosureFailure(error_10, this.scenarioMarker, TelemetryEvent_1.default.CloseChatSession, __assign(__assign({}, cleanupMetadata), { isSessionEnded: String(!(endChatOptionalParams === null || endChatOptionalParams === void 0 ? void 0 : endChatOptionalParams.isSessionEnded)) }));
|
1017
|
+
return [3 /*break*/, 4];
|
1018
|
+
case 4:
|
1019
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.CloseChatSession, cleanupMetadata);
|
1020
|
+
_c.label = 5;
|
1021
|
+
case 5: return [2 /*return*/];
|
1022
|
+
}
|
1023
|
+
});
|
1024
|
+
});
|
1025
|
+
};
|
1026
|
+
OmnichannelChatSDK.prototype.endChat = function () {
|
1027
|
+
return __awaiter(this, arguments, void 0, function (endChatOptionalParams) {
|
1028
|
+
var cleanupMetadata, error_11, telemetryData;
|
1029
|
+
var _a;
|
1030
|
+
if (endChatOptionalParams === void 0) { endChatOptionalParams = {}; }
|
1031
|
+
return __generator(this, function (_b) {
|
1032
|
+
switch (_b.label) {
|
1033
|
+
case 0:
|
1034
|
+
cleanupMetadata = {
|
1010
1035
|
RequestId: this.requestId,
|
1011
1036
|
ChatId: this.chatToken.chatId
|
1012
|
-
}
|
1013
|
-
|
1037
|
+
};
|
1038
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.EndChat, cleanupMetadata);
|
1039
|
+
_b.label = 1;
|
1040
|
+
case 1:
|
1041
|
+
_b.trys.push([1, 3, , 4]);
|
1042
|
+
// calling close chat, internally will handle the session close
|
1043
|
+
return [4 /*yield*/, this.closeChat(endChatOptionalParams)];
|
1044
|
+
case 2:
|
1045
|
+
// calling close chat, internally will handle the session close
|
1046
|
+
_b.sent();
|
1047
|
+
(_a = this.conversation) === null || _a === void 0 ? void 0 : _a.disconnect();
|
1014
1048
|
this.conversation = null;
|
1015
1049
|
this.requestId = (0, ocsdk_1.uuidv4)();
|
1016
1050
|
this.chatToken = {};
|
@@ -1026,21 +1060,21 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1026
1060
|
}
|
1027
1061
|
loggerUtils_1.default.setRequestId(this.requestId, this.ocSdkLogger, this.acsClientLogger, this.acsAdapterLogger, this.callingSdkLogger, this.amsClientLogger, this.ic3ClientLogger);
|
1028
1062
|
loggerUtils_1.default.setChatId('', this.ocSdkLogger, this.acsClientLogger, this.acsAdapterLogger, this.callingSdkLogger, this.amsClientLogger, this.ic3ClientLogger);
|
1063
|
+
if (this.refreshTokenTimer !== null) {
|
1064
|
+
clearInterval(this.refreshTokenTimer);
|
1065
|
+
this.refreshTokenTimer = null;
|
1066
|
+
}
|
1067
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EndChat, cleanupMetadata);
|
1029
1068
|
return [3 /*break*/, 4];
|
1030
1069
|
case 3:
|
1031
|
-
|
1070
|
+
error_11 = _b.sent();
|
1032
1071
|
telemetryData = {
|
1033
1072
|
RequestId: this.requestId,
|
1034
1073
|
ChatId: this.chatToken.chatId
|
1035
1074
|
};
|
1036
|
-
exceptionThrowers_1.default.throwConversationClosureFailure(
|
1075
|
+
exceptionThrowers_1.default.throwConversationClosureFailure(error_11, this.scenarioMarker, TelemetryEvent_1.default.EndChat, telemetryData);
|
1037
1076
|
return [3 /*break*/, 4];
|
1038
|
-
case 4:
|
1039
|
-
if (this.refreshTokenTimer !== null) {
|
1040
|
-
clearInterval(this.refreshTokenTimer);
|
1041
|
-
this.refreshTokenTimer = null;
|
1042
|
-
}
|
1043
|
-
return [2 /*return*/];
|
1077
|
+
case 4: return [2 /*return*/];
|
1044
1078
|
}
|
1045
1079
|
});
|
1046
1080
|
});
|
@@ -1082,7 +1116,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1082
1116
|
};
|
1083
1117
|
OmnichannelChatSDK.prototype.getConversationDetails = function () {
|
1084
1118
|
return __awaiter(this, arguments, void 0, function (optionalParams) {
|
1085
|
-
var requestId, chatToken, chatId, reconnectId, sessionId, getLWIDetailsOptionalParams, lwiDetails, state, conversationId, agentAcceptedOn, canRenderPostChat, participantType, liveWorkItemDetails,
|
1119
|
+
var requestId, chatToken, chatId, reconnectId, sessionId, getLWIDetailsOptionalParams, lwiDetails, state, conversationId, agentAcceptedOn, canRenderPostChat, participantType, liveWorkItemDetails, error_12, telemetryData;
|
1086
1120
|
var _a, _b, _c, _d;
|
1087
1121
|
if (optionalParams === void 0) { optionalParams = {}; }
|
1088
1122
|
return __generator(this, function (_e) {
|
@@ -1148,15 +1182,15 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1148
1182
|
});
|
1149
1183
|
return [2 /*return*/, liveWorkItemDetails];
|
1150
1184
|
case 3:
|
1151
|
-
|
1185
|
+
error_12 = _e.sent();
|
1152
1186
|
telemetryData = {
|
1153
1187
|
RequestId: requestId,
|
1154
1188
|
ChatId: chatId || ''
|
1155
1189
|
};
|
1156
|
-
if ((0, utilities_1.isClientIdNotFoundErrorMessage)(
|
1157
|
-
exceptionThrowers_1.default.throwAuthContactIdNotFoundFailure(
|
1190
|
+
if ((0, utilities_1.isClientIdNotFoundErrorMessage)(error_12)) {
|
1191
|
+
exceptionThrowers_1.default.throwAuthContactIdNotFoundFailure(error_12, this.scenarioMarker, TelemetryEvent_1.default.GetConversationDetails, telemetryData);
|
1158
1192
|
}
|
1159
|
-
exceptionSuppressors_1.default.suppressConversationDetailsRetrievalFailure(
|
1193
|
+
exceptionSuppressors_1.default.suppressConversationDetailsRetrievalFailure(error_12, this.scenarioMarker, TelemetryEvent_1.default.GetConversationDetails, telemetryData);
|
1160
1194
|
return [3 /*break*/, 4];
|
1161
1195
|
case 4: return [2 /*return*/, {}];
|
1162
1196
|
}
|
@@ -1197,7 +1231,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1197
1231
|
};
|
1198
1232
|
OmnichannelChatSDK.prototype.getChatToken = function () {
|
1199
1233
|
return __awaiter(this, arguments, void 0, function (cached, optionalParams) {
|
1200
|
-
var getChatTokenOptionalParams, chatToken, chatId, token, regionGtms, expiresIn, visitorId, voiceVideoCallToken, acsEndpoint, attachmentConfiguration,
|
1234
|
+
var getChatTokenOptionalParams, chatToken, chatId, token, regionGtms, expiresIn, visitorId, voiceVideoCallToken, acsEndpoint, attachmentConfiguration, error_13, telemetryData;
|
1201
1235
|
var _a, _b, _c;
|
1202
1236
|
if (cached === void 0) { cached = true; }
|
1203
1237
|
return __generator(this, function (_d) {
|
@@ -1249,16 +1283,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1249
1283
|
});
|
1250
1284
|
return [3 /*break*/, 4];
|
1251
1285
|
case 3:
|
1252
|
-
|
1286
|
+
error_13 = _d.sent();
|
1253
1287
|
telemetryData = {
|
1254
1288
|
RequestId: this.requestId,
|
1255
1289
|
ChatId: (_c = this.chatToken) === null || _c === void 0 ? void 0 : _c.chatId,
|
1256
1290
|
};
|
1257
|
-
if ((0, utilities_1.isClientIdNotFoundErrorMessage)(
|
1258
|
-
exceptionThrowers_1.default.throwAuthContactIdNotFoundFailure(
|
1291
|
+
if ((0, utilities_1.isClientIdNotFoundErrorMessage)(error_13)) {
|
1292
|
+
exceptionThrowers_1.default.throwAuthContactIdNotFoundFailure(error_13, this.scenarioMarker, TelemetryEvent_1.default.GetChatToken, telemetryData);
|
1259
1293
|
}
|
1260
1294
|
else {
|
1261
|
-
exceptionThrowers_1.default.throwChatTokenRetrievalFailure(
|
1295
|
+
exceptionThrowers_1.default.throwChatTokenRetrievalFailure(error_13, this.scenarioMarker, TelemetryEvent_1.default.GetChatToken, telemetryData);
|
1262
1296
|
}
|
1263
1297
|
return [3 /*break*/, 4];
|
1264
1298
|
case 4: return [3 /*break*/, 6];
|
@@ -1336,7 +1370,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1336
1370
|
};
|
1337
1371
|
OmnichannelChatSDK.prototype.sendMessage = function (message) {
|
1338
1372
|
return __awaiter(this, void 0, void 0, function () {
|
1339
|
-
var _a, disable, maskingCharacter, content, _i, _b, maskingRule, regex, match, replaceStr, sendMessageRequest,
|
1373
|
+
var _a, disable, maskingCharacter, content, _i, _b, maskingRule, regex, match, replaceStr, sendMessageRequest, error_14, messageToSend, _c;
|
1340
1374
|
var _d;
|
1341
1375
|
return __generator(this, function (_e) {
|
1342
1376
|
switch (_e.label) {
|
@@ -1382,7 +1416,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1382
1416
|
});
|
1383
1417
|
return [3 /*break*/, 4];
|
1384
1418
|
case 3:
|
1385
|
-
|
1419
|
+
error_14 = _e.sent();
|
1386
1420
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendMessages, {
|
1387
1421
|
RequestId: this.requestId,
|
1388
1422
|
ChatId: this.chatToken.chatId
|
@@ -1550,7 +1584,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1550
1584
|
};
|
1551
1585
|
OmnichannelChatSDK.prototype.sendTypingEvent = function () {
|
1552
1586
|
return __awaiter(this, void 0, void 0, function () {
|
1553
|
-
var
|
1587
|
+
var error_15, typingPayload, members, botMembers, error_16;
|
1554
1588
|
return __generator(this, function (_a) {
|
1555
1589
|
switch (_a.label) {
|
1556
1590
|
case 0:
|
@@ -1576,7 +1610,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1576
1610
|
});
|
1577
1611
|
return [3 /*break*/, 5];
|
1578
1612
|
case 4:
|
1579
|
-
|
1613
|
+
error_15 = _a.sent();
|
1580
1614
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendTypingEvent, {
|
1581
1615
|
RequestId: this.requestId,
|
1582
1616
|
ChatId: this.chatToken.chatId
|
@@ -1604,7 +1638,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1604
1638
|
});
|
1605
1639
|
return [3 /*break*/, 12];
|
1606
1640
|
case 11:
|
1607
|
-
|
1641
|
+
error_16 = _a.sent();
|
1608
1642
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendTypingEvent, {
|
1609
1643
|
RequestId: this.requestId,
|
1610
1644
|
ChatId: this.chatToken.chatId
|
@@ -1723,7 +1757,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1723
1757
|
};
|
1724
1758
|
OmnichannelChatSDK.prototype.uploadFileAttachment = function (fileInfo) {
|
1725
1759
|
return __awaiter(this, void 0, void 0, function () {
|
1726
|
-
var amsClient, createObjectResponse, documentId, uploadDocumentResponse, fileIdsProperty, fileMetaProperty, sendMessageRequest, messageToSend,
|
1760
|
+
var amsClient, createObjectResponse, documentId, uploadDocumentResponse, fileIdsProperty, fileMetaProperty, sendMessageRequest, messageToSend, error_17, fileMetadata, messageToSend, error_18;
|
1727
1761
|
var _a, _b;
|
1728
1762
|
return __generator(this, function (_c) {
|
1729
1763
|
switch (_c.label) {
|
@@ -1782,7 +1816,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1782
1816
|
});
|
1783
1817
|
return [2 /*return*/, messageToSend];
|
1784
1818
|
case 6:
|
1785
|
-
|
1819
|
+
error_17 = _c.sent();
|
1786
1820
|
console.error("OmnichannelChatSDK/uploadFileAttachment/sendMessage/error");
|
1787
1821
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.UploadFileAttachment, {
|
1788
1822
|
RequestId: this.requestId,
|
@@ -1828,8 +1862,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1828
1862
|
});
|
1829
1863
|
return [2 /*return*/, messageToSend];
|
1830
1864
|
case 15:
|
1831
|
-
|
1832
|
-
console.error("OmnichannelChatSDK/uploadFileAttachment/error: ".concat(
|
1865
|
+
error_18 = _c.sent();
|
1866
|
+
console.error("OmnichannelChatSDK/uploadFileAttachment/error: ".concat(error_18));
|
1833
1867
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.UploadFileAttachment, {
|
1834
1868
|
RequestId: this.requestId,
|
1835
1869
|
ChatId: this.chatToken.chatId
|
@@ -1842,7 +1876,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1842
1876
|
};
|
1843
1877
|
OmnichannelChatSDK.prototype.downloadFileAttachment = function (fileMetadata) {
|
1844
1878
|
return __awaiter(this, void 0, void 0, function () {
|
1845
|
-
var amsClient, response, view_location, viewResponse, _a, downloadedFile,
|
1879
|
+
var amsClient, response, view_location, viewResponse, _a, downloadedFile, error_19;
|
1846
1880
|
return __generator(this, function (_b) {
|
1847
1881
|
switch (_b.label) {
|
1848
1882
|
case 0: return [4 /*yield*/, this.getAMSClient()];
|
@@ -1887,8 +1921,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1887
1921
|
});
|
1888
1922
|
return [2 /*return*/, downloadedFile];
|
1889
1923
|
case 9:
|
1890
|
-
|
1891
|
-
console.error("OmnichannelChatSDK/downloadFileAttachment/error: ".concat(
|
1924
|
+
error_19 = _b.sent();
|
1925
|
+
console.error("OmnichannelChatSDK/downloadFileAttachment/error: ".concat(error_19));
|
1892
1926
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
|
1893
1927
|
RequestId: this.requestId,
|
1894
1928
|
ChatId: this.chatToken.chatId
|
@@ -1901,7 +1935,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1901
1935
|
};
|
1902
1936
|
OmnichannelChatSDK.prototype.emailLiveChatTranscript = function (body_1) {
|
1903
1937
|
return __awaiter(this, arguments, void 0, function (body, optionalParams) {
|
1904
|
-
var emailTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, emailRequestBody, emailResponse,
|
1938
|
+
var emailTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, emailRequestBody, emailResponse, error_20;
|
1905
1939
|
var _a;
|
1906
1940
|
if (optionalParams === void 0) { optionalParams = {}; }
|
1907
1941
|
return __generator(this, function (_b) {
|
@@ -1949,8 +1983,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1949
1983
|
});
|
1950
1984
|
return [2 /*return*/, emailResponse];
|
1951
1985
|
case 3:
|
1952
|
-
|
1953
|
-
console.error("OmnichannelChatSDK/emailLiveChatTranscript/error: ".concat(
|
1986
|
+
error_20 = _b.sent();
|
1987
|
+
console.error("OmnichannelChatSDK/emailLiveChatTranscript/error: ".concat(error_20));
|
1954
1988
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.EmailLiveChatTranscript, {
|
1955
1989
|
RequestId: requestId,
|
1956
1990
|
ChatId: chatId
|
@@ -1963,7 +1997,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1963
1997
|
};
|
1964
1998
|
OmnichannelChatSDK.prototype.getLiveChatTranscript = function () {
|
1965
1999
|
return __awaiter(this, arguments, void 0, function (optionalParams) {
|
1966
|
-
var getChatTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, transcriptResponse,
|
2000
|
+
var getChatTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, transcriptResponse, error_21, telemetryData;
|
1967
2001
|
var _a;
|
1968
2002
|
if (optionalParams === void 0) { optionalParams = {}; }
|
1969
2003
|
return __generator(this, function (_b) {
|
@@ -2005,12 +2039,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2005
2039
|
});
|
2006
2040
|
return [2 /*return*/, transcriptResponse];
|
2007
2041
|
case 3:
|
2008
|
-
|
2042
|
+
error_21 = _b.sent();
|
2009
2043
|
telemetryData = {
|
2010
2044
|
RequestId: requestId,
|
2011
2045
|
ChatId: chatId
|
2012
2046
|
};
|
2013
|
-
exceptionThrowers_1.default.throwLiveChatTranscriptRetrievalFailure(
|
2047
|
+
exceptionThrowers_1.default.throwLiveChatTranscriptRetrievalFailure(error_21, this.scenarioMarker, TelemetryEvent_1.default.GetLiveChatTranscript, telemetryData);
|
2014
2048
|
return [3 /*break*/, 4];
|
2015
2049
|
case 4: return [2 /*return*/];
|
2016
2050
|
}
|
@@ -2403,33 +2437,39 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2403
2437
|
};
|
2404
2438
|
OmnichannelChatSDK.prototype.getChatConfig = function () {
|
2405
2439
|
return __awaiter(this, arguments, void 0, function (optionalParams) {
|
2406
|
-
var sendCacheHeaders, bypassCache, liveChatConfig,
|
2440
|
+
var sendCacheHeaders, bypassCache, liveChatConfig, error_22, _a, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, chatWidgetLanguage, msdyn_localeid, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled;
|
2441
|
+
var _b, _c;
|
2407
2442
|
if (optionalParams === void 0) { optionalParams = {}; }
|
2408
|
-
return __generator(this, function (
|
2409
|
-
switch (
|
2443
|
+
return __generator(this, function (_d) {
|
2444
|
+
switch (_d.label) {
|
2410
2445
|
case 0:
|
2411
2446
|
sendCacheHeaders = optionalParams.sendCacheHeaders;
|
2412
2447
|
bypassCache = sendCacheHeaders === true;
|
2413
|
-
|
2448
|
+
_d.label = 1;
|
2414
2449
|
case 1:
|
2415
|
-
|
2450
|
+
_d.trys.push([1, 3, , 8]);
|
2416
2451
|
return [4 /*yield*/, this.OCClient.getChatConfig(this.requestId, bypassCache)];
|
2417
2452
|
case 2:
|
2418
|
-
liveChatConfig =
|
2453
|
+
liveChatConfig = _d.sent();
|
2419
2454
|
return [3 /*break*/, 8];
|
2420
2455
|
case 3:
|
2421
|
-
|
2422
|
-
if (!(0, internalUtils_1.isCoreServicesOrgUrlDNSError)(
|
2456
|
+
error_22 = _d.sent();
|
2457
|
+
if (!(0, internalUtils_1.isCoreServicesOrgUrlDNSError)(error_22, this.coreServicesOrgUrl, this.dynamicsLocationCode)) return [3 /*break*/, 6];
|
2423
2458
|
this.omnichannelConfig.orgUrl = this.unqServicesOrgUrl;
|
2424
2459
|
_a = this;
|
2425
2460
|
return [4 /*yield*/, ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, (0, createOcSDKConfiguration_1.default)(false), this.ocSdkLogger)];
|
2426
2461
|
case 4:
|
2427
|
-
_a.OCClient =
|
2462
|
+
_a.OCClient = _d.sent();
|
2428
2463
|
return [4 /*yield*/, this.OCClient.getChatConfig(this.requestId, bypassCache)];
|
2429
2464
|
case 5:
|
2430
|
-
liveChatConfig =
|
2465
|
+
liveChatConfig = _d.sent(); // Bubble up error by default to throw ChatConfigRetrievalFailure
|
2431
2466
|
return [3 /*break*/, 7];
|
2432
|
-
case 6:
|
2467
|
+
case 6:
|
2468
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2469
|
+
if (((_c = (_b = error_22.response) === null || _b === void 0 ? void 0 : _b.headers) === null || _c === void 0 ? void 0 : _c.errorcode) && parseInt(error_22.response.headers.errorcode) === OmnichannelErrorCodes_1.default.WidgetNotFound) {
|
2470
|
+
console.warn("No widget with the given app id is present in the system.");
|
2471
|
+
}
|
2472
|
+
throw error_22; // Bubble up error by default to throw ChatConfigRetrievalFailure
|
2433
2473
|
case 7: return [3 /*break*/, 8];
|
2434
2474
|
case 8:
|
2435
2475
|
dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion, chatWidgetLanguage = liveChatConfig.ChatWidgetLanguage;
|
@@ -2460,8 +2500,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2460
2500
|
if (!(this.authSettings && this.chatSDKConfig.getAuthToken)) return [3 /*break*/, 10];
|
2461
2501
|
return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken, { throwError: false })];
|
2462
2502
|
case 9:
|
2463
|
-
|
2464
|
-
|
2503
|
+
_d.sent(); // throwError set to 'false` for backward compatibility
|
2504
|
+
_d.label = 10;
|
2465
2505
|
case 10:
|
2466
2506
|
if (this.preChatSurvey) {
|
2467
2507
|
/* istanbul ignore next */
|
@@ -2482,7 +2522,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2482
2522
|
};
|
2483
2523
|
OmnichannelChatSDK.prototype.updateChatToken = function (newToken, newRegionGTMS) {
|
2484
2524
|
return __awaiter(this, void 0, void 0, function () {
|
2485
|
-
var sessionInfo,
|
2525
|
+
var sessionInfo, error_23, exceptionDetails;
|
2486
2526
|
return __generator(this, function (_a) {
|
2487
2527
|
switch (_a.label) {
|
2488
2528
|
case 0:
|
@@ -2510,7 +2550,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2510
2550
|
});
|
2511
2551
|
return [3 /*break*/, 5];
|
2512
2552
|
case 4:
|
2513
|
-
|
2553
|
+
error_23 = _a.sent();
|
2514
2554
|
exceptionDetails = {
|
2515
2555
|
response: "UpdateChatTokenFailed"
|
2516
2556
|
};
|
@@ -2527,7 +2567,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2527
2567
|
};
|
2528
2568
|
OmnichannelChatSDK.prototype.setAuthTokenProvider = function (provider_1) {
|
2529
2569
|
return __awaiter(this, arguments, void 0, function (provider, optionalParams) {
|
2530
|
-
var token, exceptionDetails,
|
2570
|
+
var token, exceptionDetails, error_24, exceptionDetails, exceptionDetails;
|
2531
2571
|
if (optionalParams === void 0) { optionalParams = {}; }
|
2532
2572
|
return __generator(this, function (_a) {
|
2533
2573
|
switch (_a.label) {
|
@@ -2559,12 +2599,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2559
2599
|
}
|
2560
2600
|
return [3 /*break*/, 4];
|
2561
2601
|
case 3:
|
2562
|
-
|
2602
|
+
error_24 = _a.sent();
|
2563
2603
|
exceptionDetails = {
|
2564
2604
|
response: ChatSDKError_1.ChatSDKErrorName.GetAuthTokenFailed
|
2565
2605
|
};
|
2566
|
-
if (
|
2567
|
-
exceptionDetails.response =
|
2606
|
+
if (error_24.message == ChatSDKError_1.ChatSDKErrorName.UndefinedAuthToken) {
|
2607
|
+
exceptionDetails.response = error_24.message;
|
2568
2608
|
}
|
2569
2609
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2570
2610
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|