@microsoft/omnichannel-chat-sdk 1.10.20-main.018fa96 → 1.10.20-main.4409212
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/README.md +2 -4
- package/lib/OmnichannelChatSDK.d.ts +0 -16
- package/lib/OmnichannelChatSDK.js +23 -79
- package/lib/OmnichannelChatSDK.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/createOmnichannelMessage.js +0 -3
- package/lib/utils/createOmnichannelMessage.js.map +1 -1
- package/lib/utils/exceptionThrowers.js +1 -13
- package/lib/utils/exceptionThrowers.js.map +1 -1
- package/lib/utils/loggerUtils.d.ts +0 -2
- package/lib/utils/loggerUtils.js +1 -10
- package/lib/utils/loggerUtils.js.map +1 -1
- package/package.json +2 -2
- package/lib/core/DebugOptionalParams.d.ts +0 -6
- package/lib/core/DebugOptionalParams.js +0 -3
- package/lib/core/DebugOptionalParams.js.map +0 -1
package/README.md
CHANGED
@@ -54,7 +54,7 @@ Please make sure you have a chat widget configured before using this package or
|
|
54
54
|
- [Persistent Chat](#persistent-chat)
|
55
55
|
- [Chat Reconnect with Authenticated User](#chat-reconnect-with-authenticated-user)
|
56
56
|
- [Chat Reconnect with Unauthenticated User](#chat-reconnect-with-unauthenticated-user)
|
57
|
-
- [Best Practices for Chat Session Management: Handling Disconnections and Network
|
57
|
+
- [Best Practices for Chat Session Management: Handling Disconnections and Network Instability](#best-practices-for-chat-session-management:-handling-disconnections-and-network-instability)
|
58
58
|
- [Operating Hours](#operating-hours)
|
59
59
|
- [Single Sign-on for Bots](/docs/scenarios/SINGLE_SIGN_ON_FOR_BOTS.md)
|
60
60
|
- [Sample Apps](https://github.com/microsoft/omnichannel-chat-sdk-samples)
|
@@ -625,9 +625,7 @@ const agentAvailability = await chatSDK.getAgentAvailability();
|
|
625
625
|
|
626
626
|
> See <https://docs.microsoft.com/en-us/dynamics365/customer-service/configure-post-conversation-survey?tabs=customerserviceadmincenter> on how to set up post-conversation surveys
|
627
627
|
|
628
|
-
|
629
|
-
|
630
|
-
> ❗ `chatSDK.getPostChatSurveyContext()` needs to be called before `chatSDK.endChat()` is called.
|
628
|
+
> ❗ `chatSDK.getPostChatSurveyContext()` needs to be called before `chatSDK.endChat()` is called
|
631
629
|
|
632
630
|
```ts
|
633
631
|
// 1. Start chat
|
@@ -9,7 +9,6 @@ import ChatReconnectOptionalParams from "./core/ChatReconnectOptionalParams";
|
|
9
9
|
import ChatSDKConfig from "./core/ChatSDKConfig";
|
10
10
|
import ChatSDKMessage from "./core/messaging/ChatSDKMessage";
|
11
11
|
import ChatTranscriptBody from "./core/ChatTranscriptBody";
|
12
|
-
import DebugOptionalParams from "./core/DebugOptionalParams";
|
13
12
|
import EmailLiveChatTranscriptOptionaParams from "./core/EmailLiveChatTranscriptOptionalParams";
|
14
13
|
import EndChatOptionalParams from "./core/EndChatOptionalParams";
|
15
14
|
import FetchChatTokenResponse from "@microsoft/ocsdk/lib/Model/FetchChatTokenResponse";
|
@@ -76,23 +75,8 @@ declare class OmnichannelChatSDK {
|
|
76
75
|
private maskingCharacter;
|
77
76
|
private botCSPId;
|
78
77
|
private isAMSClientAllowed;
|
79
|
-
private debugSDK;
|
80
|
-
private debugAMS;
|
81
|
-
private debugACS;
|
82
|
-
private detailedDebugEnabled;
|
83
78
|
constructor(omnichannelConfig: OmnichannelConfig, chatSDKConfig?: ChatSDKConfig);
|
84
|
-
/**
|
85
|
-
* @param flag Flag to enable/disable debug log telemetry, will be applied to all components
|
86
|
-
* @description Set the debug flag to enable/disable debug log telemetry
|
87
|
-
*/
|
88
79
|
setDebug(flag: boolean): void;
|
89
|
-
/**
|
90
|
-
* @description Allow to target specific components to enable/disable debug log telemetry, reducing the noise in the logs.
|
91
|
-
* @param flagSDK Flag to enable disable SDK debug log telemetry
|
92
|
-
* @param flagAcs Flag to enable/disable debugg log telemetry for Acs components (ACSClient and ACSAdapter)
|
93
|
-
* @param flagAttachment Flag to enable/disable debug log telemetry for Attachment components)
|
94
|
-
*/
|
95
|
-
setDebugDetailed(optionalParams: DebugOptionalParams): void;
|
96
80
|
private retryLoadAMSClient;
|
97
81
|
private getAMSClient;
|
98
82
|
private loadInitComponents;
|
@@ -59,7 +59,6 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
59
59
|
Object.defineProperty(exports, "__esModule", { value: true });
|
60
60
|
var loggers_1 = require("./utils/loggers");
|
61
61
|
var ACSClient_1 = require("./core/messaging/ACSClient");
|
62
|
-
var ChatSDKError_1 = require("./core/ChatSDKError");
|
63
62
|
var MessagePrinterFactory_1 = require("./utils/printers/MessagePrinterFactory");
|
64
63
|
var ocsdk_1 = require("@microsoft/ocsdk");
|
65
64
|
var chatAdapterCreators_1 = require("./utils/chatAdapterCreators");
|
@@ -75,6 +74,7 @@ var AMSClientLoadStates_1 = require("./utils/AMSClientLoadStates");
|
|
75
74
|
var AMSFileManager_1 = require("./external/ACSAdapter/AMSFileManager");
|
76
75
|
var CallingOptionsOptionSetNumber_1 = require("./core/CallingOptionsOptionSetNumber");
|
77
76
|
var ChatAdapterProtocols_1 = require("./core/messaging/ChatAdapterProtocols");
|
77
|
+
var ChatSDKError_1 = require("./core/ChatSDKError");
|
78
78
|
var ConversationMode_1 = require("./core/ConversationMode");
|
79
79
|
var DeliveryMode_1 = require("@microsoft/omnichannel-ic3core/lib/model/DeliveryMode");
|
80
80
|
var FileSharingProtocolType_1 = require("@microsoft/omnichannel-ic3core/lib/model/FileSharingProtocolType");
|
@@ -140,10 +140,6 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
140
140
|
this.maskingCharacter = "#";
|
141
141
|
this.botCSPId = null;
|
142
142
|
this.isAMSClientAllowed = false;
|
143
|
-
this.debugSDK = false;
|
144
|
-
this.debugAMS = false;
|
145
|
-
this.debugACS = false;
|
146
|
-
this.detailedDebugEnabled = false;
|
147
143
|
this.populateInitChatOptionalParam = function (requestOptionalParams, optionalParams, telemetryEvent) {
|
148
144
|
requestOptionalParams.initContext.locale = (0, locale_1.getLocaleStringFromId)(_this.localeId);
|
149
145
|
if (optionalParams === null || optionalParams === void 0 ? void 0 : optionalParams.customContext) {
|
@@ -201,10 +197,6 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
201
197
|
return requestOptionalParams;
|
202
198
|
};
|
203
199
|
this.debug = false;
|
204
|
-
this.debugSDK = false;
|
205
|
-
this.debugAMS = false;
|
206
|
-
this.debugACS = false;
|
207
|
-
this.detailedDebugEnabled = false;
|
208
200
|
this.runtimeId = (0, utilities_1.getRuntimeId)((_b = (_a = chatSDKConfig === null || chatSDKConfig === void 0 ? void 0 : chatSDKConfig.telemetry) === null || _a === void 0 ? void 0 : _a.runtimeId) !== null && _b !== void 0 ? _b : null);
|
209
201
|
this.omnichannelConfig = omnichannelConfig;
|
210
202
|
this.chatSDKConfig = __assign(__assign({}, SDKConfigValidators_1.defaultChatSDKConfig), chatSDKConfig // overrides
|
@@ -251,14 +243,9 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
251
243
|
}
|
252
244
|
loggerUtils_1.default.setRequestId(this.requestId, this.ocSdkLogger, this.acsClientLogger, this.acsAdapterLogger, this.callingSdkLogger, this.amsClientLogger, this.ic3ClientLogger);
|
253
245
|
}
|
254
|
-
/**
|
255
|
-
* @param flag Flag to enable/disable debug log telemetry, will be applied to all components
|
256
|
-
* @description Set the debug flag to enable/disable debug log telemetry
|
257
|
-
*/
|
258
246
|
/* istanbul ignore next */
|
259
247
|
OmnichannelChatSDK.prototype.setDebug = function (flag) {
|
260
248
|
var _a;
|
261
|
-
this.detailedDebugEnabled = false;
|
262
249
|
this.debug = flag;
|
263
250
|
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setDebug(flag);
|
264
251
|
this.scenarioMarker.setDebug(flag);
|
@@ -267,26 +254,6 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
267
254
|
}
|
268
255
|
loggerUtils_1.default.setDebug(flag, this.ocSdkLogger, this.acsClientLogger, this.acsAdapterLogger, this.callingSdkLogger, this.amsClientLogger, this.ic3ClientLogger);
|
269
256
|
};
|
270
|
-
/**
|
271
|
-
* @description Allow to target specific components to enable/disable debug log telemetry, reducing the noise in the logs.
|
272
|
-
* @param flagSDK Flag to enable disable SDK debug log telemetry
|
273
|
-
* @param flagAcs Flag to enable/disable debugg log telemetry for Acs components (ACSClient and ACSAdapter)
|
274
|
-
* @param flagAttachment Flag to enable/disable debug log telemetry for Attachment components)
|
275
|
-
*/
|
276
|
-
/* istanbul ignore next */
|
277
|
-
OmnichannelChatSDK.prototype.setDebugDetailed = function (optionalParams) {
|
278
|
-
var _a;
|
279
|
-
this.detailedDebugEnabled = true;
|
280
|
-
this.debug = (optionalParams === null || optionalParams === void 0 ? void 0 : optionalParams.flagSDK) === true;
|
281
|
-
this.debugACS = (optionalParams === null || optionalParams === void 0 ? void 0 : optionalParams.flagACS) === true;
|
282
|
-
this.debugAMS = (optionalParams === null || optionalParams === void 0 ? void 0 : optionalParams.flagAttachment) === true;
|
283
|
-
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setDebug(this.debug);
|
284
|
-
this.scenarioMarker.setDebug(this.debug);
|
285
|
-
if (this.AMSClient) {
|
286
|
-
this.AMSClient.setDebug(this.debugAMS);
|
287
|
-
}
|
288
|
-
loggerUtils_1.default.setDebugDetailed(this.debug, this.debugACS, this.debugAMS, this.ocSdkLogger, this.acsClientLogger, this.acsAdapterLogger, this.callingSdkLogger, this.amsClientLogger);
|
289
|
-
};
|
290
257
|
OmnichannelChatSDK.prototype.retryLoadAMSClient = function () {
|
291
258
|
return __awaiter(this, void 0, void 0, function () {
|
292
259
|
var RETRY_DELAY_MS, MAX_RETRY_COUNT, retryCount;
|
@@ -409,7 +376,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
409
376
|
return [4 /*yield*/, (0, omnichannel_amsclient_1.default)({
|
410
377
|
framedMode: (0, platform_1.isBrowser)(),
|
411
378
|
multiClient: true,
|
412
|
-
debug:
|
379
|
+
debug: this.debug,
|
413
380
|
logger: this.amsClientLogger
|
414
381
|
})];
|
415
382
|
case 2:
|
@@ -520,7 +487,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
520
487
|
return [4 /*yield*/, (0, omnichannel_amsclient_1.default)({
|
521
488
|
framedMode: (0, platform_1.isBrowser)(),
|
522
489
|
multiClient: true,
|
523
|
-
debug:
|
490
|
+
debug: this.debug,
|
524
491
|
logger: this.amsClientLogger
|
525
492
|
})];
|
526
493
|
case 9:
|
@@ -682,7 +649,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
682
649
|
_a.label = 1;
|
683
650
|
case 1:
|
684
651
|
_a.trys.push([1, 3, , 4]);
|
685
|
-
return [4 /*yield*/, this.OCClient.getReconnectAvailability(optionalParams.reconnectId
|
652
|
+
return [4 /*yield*/, this.OCClient.getReconnectAvailability(optionalParams.reconnectId)];
|
686
653
|
case 2:
|
687
654
|
reconnectAvailabilityResponse = _a.sent();
|
688
655
|
// isReconnectAvailable , indicates if the chat is still valid, or the token has expired
|
@@ -732,9 +699,6 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
732
699
|
if (!this.isInitialized) {
|
733
700
|
exceptionThrowers_1.default.throwUninitializedChatSDK(this.scenarioMarker, TelemetryEvent_1.default.GetChatReconnectContext);
|
734
701
|
}
|
735
|
-
if (!this.requestId) {
|
736
|
-
this.requestId = (0, ocsdk_1.uuidv4)();
|
737
|
-
}
|
738
702
|
context = {
|
739
703
|
reconnectId: null,
|
740
704
|
redirectURL: null
|
@@ -777,9 +741,6 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
777
741
|
if (!this.isInitialized) {
|
778
742
|
exceptionThrowers_1.default.throwUninitializedChatSDK(this.scenarioMarker, TelemetryEvent_1.default.StartChat);
|
779
743
|
}
|
780
|
-
if (!this.requestId) {
|
781
|
-
this.requestId = (0, ocsdk_1.uuidv4)();
|
782
|
-
}
|
783
744
|
shouldReinitIC3Client = !platform_1.default.isNode() && !platform_1.default.isReactNative() && !this.IC3Client && this.liveChatVersion === LiveChatVersion_1.default.V1;
|
784
745
|
if (!shouldReinitIC3Client) return [3 /*break*/, 2];
|
785
746
|
_a = this;
|
@@ -1095,18 +1056,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1095
1056
|
}
|
1096
1057
|
});
|
1097
1058
|
}); };
|
1098
|
-
if (!!((_k = this.chatSDKConfig.useCreateConversation) === null || _k === void 0 ? void 0 : _k.disable)) return [3 /*break*/,
|
1059
|
+
if (!!((_k = this.chatSDKConfig.useCreateConversation) === null || _k === void 0 ? void 0 : _k.disable)) return [3 /*break*/, 21];
|
1099
1060
|
return [4 /*yield*/, createConversationPromise()];
|
1100
1061
|
case 19:
|
1101
1062
|
_o.sent();
|
1102
|
-
return [
|
1103
|
-
case 20:
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
case 22:
|
1108
|
-
case 23:
|
1063
|
+
return [4 /*yield*/, Promise.all([messagingClientPromise(), attachmentClientPromise()])];
|
1064
|
+
case 20:
|
1065
|
+
_o.sent();
|
1066
|
+
return [3 /*break*/, 23];
|
1067
|
+
case 21: return [4 /*yield*/, Promise.all([sessionInitPromise(), messagingClientPromise(), attachmentClientPromise()])];
|
1068
|
+
case 22:
|
1109
1069
|
_o.sent();
|
1070
|
+
_o.label = 23;
|
1071
|
+
case 23:
|
1110
1072
|
if (this.isPersistentChat && !((_l = this.chatSDKConfig.persistentChat) === null || _l === void 0 ? void 0 : _l.disable)) {
|
1111
1073
|
this.refreshTokenTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
1112
1074
|
return __generator(this, function (_a) {
|
@@ -1191,15 +1153,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1191
1153
|
}
|
1192
1154
|
_b.label = 1;
|
1193
1155
|
case 1:
|
1194
|
-
_b.trys.push([1,
|
1195
|
-
|
1196
|
-
case 2:
|
1197
|
-
_b.trys.push([2, , 4, 5]);
|
1156
|
+
_b.trys.push([1, 3, , 4]);
|
1157
|
+
// calling close chat, internally will handle the session close
|
1198
1158
|
return [4 /*yield*/, this.closeChat(endChatOptionalParams)];
|
1199
|
-
case
|
1159
|
+
case 2:
|
1160
|
+
// calling close chat, internally will handle the session close
|
1200
1161
|
_b.sent();
|
1201
|
-
return [3 /*break*/, 5];
|
1202
|
-
case 4:
|
1203
1162
|
(_a = this.conversation) === null || _a === void 0 ? void 0 : _a.disconnect();
|
1204
1163
|
this.conversation = null;
|
1205
1164
|
this.requestId = (0, ocsdk_1.uuidv4)();
|
@@ -1220,22 +1179,17 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1220
1179
|
clearInterval(this.refreshTokenTimer);
|
1221
1180
|
this.refreshTokenTimer = null;
|
1222
1181
|
}
|
1223
|
-
return [7 /*endfinally*/];
|
1224
|
-
case 5:
|
1225
1182
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EndChat, cleanupMetadata);
|
1226
|
-
return [3 /*break*/,
|
1227
|
-
case
|
1183
|
+
return [3 /*break*/, 4];
|
1184
|
+
case 3:
|
1228
1185
|
error_12 = _b.sent();
|
1229
1186
|
telemetryData = {
|
1230
1187
|
RequestId: this.requestId,
|
1231
1188
|
ChatId: this.chatToken.chatId
|
1232
1189
|
};
|
1233
|
-
if (error_12 instanceof ChatSDKError_1.ChatSDKError) {
|
1234
|
-
exceptionThrowers_1.default.throwConversationClosureFailure(new Error(JSON.stringify(error_12.exceptionDetails)), this.scenarioMarker, TelemetryEvent_1.default.EndChat, telemetryData);
|
1235
|
-
}
|
1236
1190
|
exceptionThrowers_1.default.throwConversationClosureFailure(error_12, this.scenarioMarker, TelemetryEvent_1.default.EndChat, telemetryData);
|
1237
|
-
return [3 /*break*/,
|
1238
|
-
case
|
1191
|
+
return [3 /*break*/, 4];
|
1192
|
+
case 4: return [2 /*return*/];
|
1239
1193
|
}
|
1240
1194
|
});
|
1241
1195
|
});
|
@@ -1291,10 +1245,6 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1291
1245
|
chatId = chatToken.chatId;
|
1292
1246
|
reconnectId = this.reconnectId;
|
1293
1247
|
sessionId = this.sessionId;
|
1294
|
-
if (!this.requestId) {
|
1295
|
-
this.requestId = (0, ocsdk_1.uuidv4)();
|
1296
|
-
requestId = this.requestId;
|
1297
|
-
}
|
1298
1248
|
if (optionalParams.liveChatContext) {
|
1299
1249
|
requestId = optionalParams.liveChatContext.requestId;
|
1300
1250
|
chatToken = optionalParams.liveChatContext.chatToken;
|
@@ -1745,7 +1695,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1745
1695
|
var id = event.id;
|
1746
1696
|
var omnichannelMessage = (0, createOmnichannelMessage_1.default)(event, {
|
1747
1697
|
liveChatVersion: _this.liveChatVersion,
|
1748
|
-
debug:
|
1698
|
+
debug: _this.debug
|
1749
1699
|
});
|
1750
1700
|
if (!postedMessages_1.has(id)) {
|
1751
1701
|
onNewMessageCallback(omnichannelMessage);
|
@@ -2259,12 +2209,6 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2259
2209
|
sessionId = optionalParams.liveChatContext.sessionId;
|
2260
2210
|
this.OCClient.sessionId = sessionId;
|
2261
2211
|
}
|
2262
|
-
if (!chatId) {
|
2263
|
-
throw new ChatSDKError_1.ChatSDKError(ChatSDKError_1.ChatSDKErrorName.LiveChatTranscriptRetrievalFailure, undefined, {
|
2264
|
-
response: ChatSDKError_1.ChatSDKErrorName.LiveChatTranscriptRetrievalFailure,
|
2265
|
-
errorObject: "ChatId is not defined"
|
2266
|
-
});
|
2267
|
-
}
|
2268
2212
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetLiveChatTranscript, {
|
2269
2213
|
RequestId: requestId,
|
2270
2214
|
ChatId: chatId
|
@@ -2539,7 +2483,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2539
2483
|
ChatId: (_g = this.chatToken) === null || _g === void 0 ? void 0 : _g.chatId,
|
2540
2484
|
ExceptionDetails: "Post Chat Survey is disabled. Please check the Omnichannel Administration Portal."
|
2541
2485
|
});
|
2542
|
-
return [2 /*return*/, Promise.reject("Post Chat is disabled from admin side
|
2486
|
+
return [2 /*return*/, Promise.reject("Post Chat is disabled from admin side.")];
|
2543
2487
|
case 7: return [3 /*break*/, 9];
|
2544
2488
|
case 8:
|
2545
2489
|
ex_1 = _j.sent();
|