@microsoft/omnichannel-chat-widget 1.5.1-main.132e1c6 → 1.5.1-main.b37ad3d
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/cjs/common/Constants.js +10 -8
- package/lib/cjs/common/telemetry/TelemetryConstants.js +0 -2
- package/lib/cjs/common/utils.js +2 -1
- package/lib/cjs/components/livechatwidget/common/chatDisconnectHelper.js +31 -16
- package/lib/cjs/components/livechatwidget/common/endChat.js +16 -4
- package/lib/cjs/components/livechatwidget/common/startChat.js +19 -80
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +198 -0
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.spec.js +282 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +2 -10
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +0 -8
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.spec.js +1 -1
- package/lib/esm/common/Constants.js +7 -6
- package/lib/esm/common/telemetry/TelemetryConstants.js +0 -2
- package/lib/esm/common/utils.js +3 -2
- package/lib/esm/components/livechatwidget/common/chatDisconnectHelper.js +31 -16
- package/lib/esm/components/livechatwidget/common/endChat.js +14 -3
- package/lib/esm/components/livechatwidget/common/startChat.js +20 -81
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +191 -0
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.spec.js +280 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +3 -11
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +0 -8
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.spec.js +1 -1
- package/lib/types/common/Constants.d.ts +8 -4
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +0 -1
- package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -3
- package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +5 -0
- package/lib/types/components/livechatwidget/common/startChatErrorHandler.spec.d.ts +1 -0
- package/package.json +3 -3
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.WebChatMiddlewareConstants = exports.TranscriptConstants = exports.StorageType = exports.Regex = exports.ParticipantType = exports.NotificationPaneConstants = exports.MimeTypes = exports.LocaleConstants = exports.LiveWorkItemState = exports.HtmlIdNames = exports.HtmlElementSelectors = exports.HtmlClassNames = exports.HtmlAttributeNames = exports.EnvironmentVersion = exports.ElementType = exports.E2VVOptions = exports.ConversationMode = exports.ConversationEndEntity = exports.Constants = exports.ConfirmationState = exports.
|
|
6
|
+
exports.WidgetLoadTelemetryMessage = exports.WidgetLoadCustomErrorString = exports.WebChatMiddlewareConstants = exports.TranscriptConstants = exports.StorageType = exports.Regex = exports.ParticipantType = exports.NotificationPaneConstants = exports.MimeTypes = exports.LocaleConstants = exports.LiveWorkItemState = exports.HtmlIdNames = exports.HtmlElementSelectors = exports.HtmlClassNames = exports.HtmlAttributeNames = exports.EnvironmentVersion = exports.ElementType = exports.E2VVOptions = exports.ConversationMode = exports.ConversationEndEntity = exports.Constants = exports.ConfirmationState = exports.AriaTelemetryConstants = exports.AMSConstants = void 0;
|
|
7
7
|
var _class;
|
|
8
8
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
9
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
@@ -191,12 +191,6 @@ exports.ElementType = ElementType;
|
|
|
191
191
|
(function (ElementType) {
|
|
192
192
|
ElementType["CallingContainerSDK"] = "CallingContainerSDK";
|
|
193
193
|
})(ElementType || (exports.ElementType = ElementType = {}));
|
|
194
|
-
let ChatSDKError;
|
|
195
|
-
exports.ChatSDKError = ChatSDKError;
|
|
196
|
-
(function (ChatSDKError) {
|
|
197
|
-
ChatSDKError["WidgetUseOutsideOperatingHour"] = "WidgetUseOutsideOperatingHour";
|
|
198
|
-
ChatSDKError["AuthContactIdNotFoundFailure"] = "AuthContactIdNotFoundFailure";
|
|
199
|
-
})(ChatSDKError || (exports.ChatSDKError = ChatSDKError = {}));
|
|
200
194
|
let EnvironmentVersion;
|
|
201
195
|
exports.EnvironmentVersion = EnvironmentVersion;
|
|
202
196
|
(function (EnvironmentVersion) {
|
|
@@ -294,4 +288,12 @@ _defineProperty(AriaTelemetryConstants, "MOONCAKE_ENDPOINT", "");
|
|
|
294
288
|
_defineProperty(AriaTelemetryConstants, "Public", "Public");
|
|
295
289
|
_defineProperty(AriaTelemetryConstants, "EU", "Europe");
|
|
296
290
|
// EUR: crm4; FRA: crm12; GER: crm16; CHE: crm17; NOR: crm19
|
|
297
|
-
_defineProperty(AriaTelemetryConstants, "lcwEUDomainNames", ["crm4.omnichannelengagementhub.com", "crm12.omnichannelengagementhub.com", "crm16.omnichannelengagementhub.com", "crm17.omnichannelengagementhub.com", "crm19.omnichannelengagementhub.com"]);
|
|
291
|
+
_defineProperty(AriaTelemetryConstants, "lcwEUDomainNames", ["crm4.omnichannelengagementhub.com", "crm12.omnichannelengagementhub.com", "crm16.omnichannelengagementhub.com", "crm17.omnichannelengagementhub.com", "crm19.omnichannelengagementhub.com"]);
|
|
292
|
+
class WidgetLoadTelemetryMessage {}
|
|
293
|
+
exports.WidgetLoadTelemetryMessage = WidgetLoadTelemetryMessage;
|
|
294
|
+
_defineProperty(WidgetLoadTelemetryMessage, "OOOHMessage", "Widget is OOOH");
|
|
295
|
+
_defineProperty(WidgetLoadTelemetryMessage, "PersistedStateRetrievedMessage", "Persisted state retrieved");
|
|
296
|
+
class WidgetLoadCustomErrorString {}
|
|
297
|
+
exports.WidgetLoadCustomErrorString = WidgetLoadCustomErrorString;
|
|
298
|
+
_defineProperty(WidgetLoadCustomErrorString, "AuthenticationFailedErrorString", "Authentication was not successful");
|
|
299
|
+
_defineProperty(WidgetLoadCustomErrorString, "NetworkErrorString", "Network Error");
|
|
@@ -133,7 +133,6 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
133
133
|
TelemetryEvent["ErrorUIPaneLoaded"] = "ErrorUIPaneLoaded";
|
|
134
134
|
TelemetryEvent["DownloadTranscriptFailed"] = "DownloadTranscriptFailed";
|
|
135
135
|
TelemetryEvent["StartChatFailed"] = "StartChatFailed";
|
|
136
|
-
TelemetryEvent["IC3ThreadUpdateEventReceived"] = "IC3ThreadUpdateEventReceived";
|
|
137
136
|
TelemetryEvent["ConfirmationCancelButtonClicked"] = "ConfirmationCancelButtonClicked";
|
|
138
137
|
TelemetryEvent["ConfirmationConfirmButtonClicked"] = "ConfirmationConfirmButtonClicked";
|
|
139
138
|
TelemetryEvent["LoadingPaneLoaded"] = "LoadingPaneLoaded";
|
|
@@ -250,7 +249,6 @@ class TelemetryConstants {
|
|
|
250
249
|
case TelemetryEvent.EmailTranscriptSent:
|
|
251
250
|
case TelemetryEvent.EmailTranscriptFailed:
|
|
252
251
|
case TelemetryEvent.DownloadTranscriptFailed:
|
|
253
|
-
case TelemetryEvent.IC3ThreadUpdateEventReceived:
|
|
254
252
|
case TelemetryEvent.ConfirmationCancelButtonClicked:
|
|
255
253
|
case TelemetryEvent.ConfirmationConfirmButtonClicked:
|
|
256
254
|
case TelemetryEvent.PreChatSurveyStartChatMethodFailed:
|
package/lib/cjs/common/utils.js
CHANGED
|
@@ -11,6 +11,7 @@ var _DataStoreManager = require("./contextDataStore/DataStoreManager");
|
|
|
11
11
|
var _KeyCodes = require("./KeyCodes");
|
|
12
12
|
var _md5Typescript = require("md5-typescript");
|
|
13
13
|
var _TelemetryHelper = require("./telemetry/TelemetryHelper");
|
|
14
|
+
var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
|
|
14
15
|
var _this = void 0;
|
|
15
16
|
const getElementBySelector = selector => {
|
|
16
17
|
let element;
|
|
@@ -406,7 +407,7 @@ const getConversationDetailsCall = async chatSDK => {
|
|
|
406
407
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
407
408
|
exports.getConversationDetailsCall = getConversationDetailsCall;
|
|
408
409
|
const checkContactIdError = e => {
|
|
409
|
-
if ((e === null || e === void 0 ? void 0 : e.message) ===
|
|
410
|
+
if ((e === null || e === void 0 ? void 0 : e.message) === _omnichannelChatSdk.ChatSDKErrorName.AuthContactIdNotFoundFailure) {
|
|
410
411
|
const contactIdNotFoundErrorEvent = {
|
|
411
412
|
eventName: _TelemetryConstants.BroadcastEvent.ContactIdNotFound,
|
|
412
413
|
payload: {
|
|
@@ -11,23 +11,38 @@ var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants"
|
|
|
11
11
|
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
12
12
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
13
|
const handleChatDisconnect = (props, state, setWebChatStyles) => {
|
|
14
|
-
var _state$appStates;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
var _state$appStates, _state$domainStates, _state$domainStates$m, _props$webChatContain, _props$webChatContain2;
|
|
15
|
+
const chatDisconnectState = state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.chatDisconnectEventReceived;
|
|
16
|
+
const chatDisconnectMessage = (state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$m = _state$domainStates.middlewareLocalizedTexts) === null || _state$domainStates$m === void 0 ? void 0 : _state$domainStates$m.MIDDLEWARE_BANNER_CHAT_DISCONNECT) ?? _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_CHAT_DISCONNECT;
|
|
17
|
+
const hideSendBoxOnConversationEnd = props === null || props === void 0 ? void 0 : (_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : (_props$webChatContain2 = _props$webChatContain.renderingMiddlewareProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.hideSendboxOnConversationEnd;
|
|
18
|
+
switch (chatDisconnectState) {
|
|
19
|
+
case true:
|
|
20
|
+
if (hideSendBoxOnConversationEnd !== false) {
|
|
21
|
+
setWebChatStyles(styles => {
|
|
22
|
+
return {
|
|
23
|
+
...styles,
|
|
24
|
+
hideSendBox: true
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
_NotificationHandler.NotificationHandler.notifyWarning(_NotificationScenarios.NotificationScenarios.ChatDisconnect, chatDisconnectMessage);
|
|
29
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
30
|
+
Event: _TelemetryConstants.TelemetryEvent.ChatDisconnectThreadEventReceived,
|
|
31
|
+
Description: "Chat disconnected due to timeout, left or removed."
|
|
24
32
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
break;
|
|
34
|
+
case false:
|
|
35
|
+
if (hideSendBoxOnConversationEnd !== false) {
|
|
36
|
+
setWebChatStyles(styles => {
|
|
37
|
+
return {
|
|
38
|
+
...styles,
|
|
39
|
+
hideSendBox: false
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
break;
|
|
44
|
+
default:
|
|
45
|
+
break;
|
|
31
46
|
}
|
|
32
47
|
};
|
|
33
48
|
exports.handleChatDisconnect = handleChatDisconnect;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.prepareEndChat = exports.endVoiceVideoCallIfOngoing = exports.endChatStateCleanUp = exports.endChat = exports.closeChatStateCleanUp = exports.callingStateCleanUp = void 0;
|
|
6
|
+
exports.prepareEndChat = exports.endVoiceVideoCallIfOngoing = exports.endChatStateCleanUp = exports.endChat = exports.closeChatStateCleanUp = exports.chatSDKStateCleanUp = exports.callingStateCleanUp = void 0;
|
|
7
7
|
var _Constants = require("../../../common/Constants");
|
|
8
8
|
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
9
9
|
var _authHelper = require("./authHelper");
|
|
@@ -16,6 +16,7 @@ var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
|
16
16
|
var _WebChatStoreLoader = require("../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader");
|
|
17
17
|
var _defaultWebChatContainerStatefulProps = require("../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps");
|
|
18
18
|
var _TelemetryManager = require("../../../common/telemetry/TelemetryManager");
|
|
19
|
+
var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
|
|
19
20
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
21
|
const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter) => {
|
|
21
22
|
try {
|
|
@@ -152,7 +153,7 @@ const endChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatSt
|
|
|
152
153
|
}
|
|
153
154
|
};
|
|
154
155
|
exports.endChat = endChat;
|
|
155
|
-
const callingStateCleanUp =
|
|
156
|
+
const callingStateCleanUp = dispatch => {
|
|
156
157
|
dispatch({
|
|
157
158
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SHOW_CALLING_CONTAINER,
|
|
158
159
|
payload: false
|
|
@@ -175,7 +176,7 @@ const callingStateCleanUp = async dispatch => {
|
|
|
175
176
|
});
|
|
176
177
|
};
|
|
177
178
|
exports.callingStateCleanUp = callingStateCleanUp;
|
|
178
|
-
const endChatStateCleanUp =
|
|
179
|
+
const endChatStateCleanUp = dispatch => {
|
|
179
180
|
// Need to clear these states immediately when chat ended from OC.
|
|
180
181
|
dispatch({
|
|
181
182
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
@@ -191,7 +192,7 @@ const endChatStateCleanUp = async dispatch => {
|
|
|
191
192
|
});
|
|
192
193
|
};
|
|
193
194
|
exports.endChatStateCleanUp = endChatStateCleanUp;
|
|
194
|
-
const closeChatStateCleanUp =
|
|
195
|
+
const closeChatStateCleanUp = dispatch => {
|
|
195
196
|
dispatch({
|
|
196
197
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
197
198
|
payload: undefined
|
|
@@ -229,6 +230,17 @@ const closeChatStateCleanUp = async dispatch => {
|
|
|
229
230
|
|
|
230
231
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
231
232
|
exports.closeChatStateCleanUp = closeChatStateCleanUp;
|
|
233
|
+
const chatSDKStateCleanUp = chatSDK => {
|
|
234
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
235
|
+
chatSDK.requestId = (0, _omnichannelChatSdk.uuidv4)();
|
|
236
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
237
|
+
chatSDK.chatToken = {};
|
|
238
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
239
|
+
chatSDK.reconnectId = null;
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
243
|
+
exports.chatSDKStateCleanUp = chatSDKStateCleanUp;
|
|
232
244
|
const endVoiceVideoCallIfOngoing = async (chatSDK, dispatch) => {
|
|
233
245
|
let callId = "";
|
|
234
246
|
try {
|
|
@@ -12,8 +12,6 @@ var _ActivityStreamHandler = require("./ActivityStreamHandler");
|
|
|
12
12
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
13
13
|
var _ConversationState = require("../../../contexts/common/ConversationState");
|
|
14
14
|
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
15
|
-
var _NotificationHandler = require("../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler");
|
|
16
|
-
var _NotificationScenarios = require("../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios");
|
|
17
15
|
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
18
16
|
var _TelemetryManager = require("../../../common/telemetry/TelemetryManager");
|
|
19
17
|
var _createAdapter = require("./createAdapter");
|
|
@@ -21,6 +19,8 @@ var _newMessageEventHandler = require("../../../plugins/newMessageEventHandler")
|
|
|
21
19
|
var _reconnectChatHelper = require("./reconnectChatHelper");
|
|
22
20
|
var _setPostChatContextAndLoadSurvey = require("./setPostChatContextAndLoadSurvey");
|
|
23
21
|
var _updateSessionDataForTelemetry = require("./updateSessionDataForTelemetry");
|
|
22
|
+
var _startChatErrorHandler = require("./startChatErrorHandler");
|
|
23
|
+
var _endChat = require("./endChat");
|
|
24
24
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
25
|
let optionalParams = {};
|
|
26
26
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -114,13 +114,21 @@ const setPreChatAndInitiateChat = async (chatSDK, dispatch, setAdapter, isProact
|
|
|
114
114
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
115
115
|
exports.setPreChatAndInitiateChat = setPreChatAndInitiateChat;
|
|
116
116
|
const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params, persistedState) => {
|
|
117
|
-
var _props$controlProps2;
|
|
118
117
|
let isStartChatSuccessful = false;
|
|
119
118
|
const chatConfig = props === null || props === void 0 ? void 0 : props.chatConfig;
|
|
120
119
|
const getAuthToken = props === null || props === void 0 ? void 0 : props.getAuthToken;
|
|
121
|
-
|
|
120
|
+
if ((state === null || state === void 0 ? void 0 : state.appStates.conversationState) === _ConversationState.ConversationState.Closed) {
|
|
121
|
+
// Preventive reset to avoid starting chat with previous requestId which could potentially cause problems
|
|
122
|
+
(0, _endChat.chatSDKStateCleanUp)(chatSDK);
|
|
123
|
+
}
|
|
122
124
|
try {
|
|
123
|
-
var _newAdapter$activity
|
|
125
|
+
var _state$appStates, _newAdapter$activity$;
|
|
126
|
+
// Clear disconnect state on start chat
|
|
127
|
+
(state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.chatDisconnectEventReceived) && dispatch({
|
|
128
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_DISCONNECT_EVENT_RECEIVED,
|
|
129
|
+
payload: false
|
|
130
|
+
});
|
|
131
|
+
|
|
124
132
|
//Start widget load timer
|
|
125
133
|
_TelemetryManager.TelemetryTimers.WidgetLoadTimer = (0, _utils.createTimer)();
|
|
126
134
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -132,8 +140,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
132
140
|
// set auth token to chat sdk before start chat
|
|
133
141
|
const authSuccess = await (0, _authHelper.handleAuthentication)(chatSDK, chatConfig, getAuthToken);
|
|
134
142
|
if (!authSuccess) {
|
|
135
|
-
|
|
136
|
-
throw new Error("Authentication was not successful");
|
|
143
|
+
throw new Error(_Constants.WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
|
|
137
144
|
}
|
|
138
145
|
}
|
|
139
146
|
|
|
@@ -196,16 +203,11 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
196
203
|
});
|
|
197
204
|
}
|
|
198
205
|
if (persistedState) {
|
|
199
|
-
var _TelemetryTimers$Widg;
|
|
200
206
|
dispatch({
|
|
201
207
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_STATE,
|
|
202
208
|
payload: persistedState
|
|
203
209
|
});
|
|
204
|
-
|
|
205
|
-
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadComplete,
|
|
206
|
-
Description: "Widget load complete. Persisted state retrieved",
|
|
207
|
-
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg === void 0 ? void 0 : _TelemetryTimers$Widg.milliSecondsElapsed
|
|
208
|
-
});
|
|
210
|
+
(0, _startChatErrorHandler.logWidgetLoadComplete)(_Constants.WidgetLoadTelemetryMessage.PersistedStateRetrievedMessage);
|
|
209
211
|
await (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch, true);
|
|
210
212
|
return;
|
|
211
213
|
}
|
|
@@ -216,11 +218,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
216
218
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
217
219
|
payload: liveChatContext
|
|
218
220
|
});
|
|
219
|
-
|
|
220
|
-
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadComplete,
|
|
221
|
-
Description: "Widget load complete",
|
|
222
|
-
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg2 = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg2 === void 0 ? void 0 : _TelemetryTimers$Widg2.milliSecondsElapsed
|
|
223
|
-
});
|
|
221
|
+
(0, _startChatErrorHandler.logWidgetLoadComplete)();
|
|
224
222
|
|
|
225
223
|
// Set post chat context in state
|
|
226
224
|
// Commenting this for now as post chat context is fetched during end chat
|
|
@@ -229,55 +227,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
229
227
|
// Updating chat session detail for telemetry
|
|
230
228
|
await (0, _updateSessionDataForTelemetry.updateSessionDataForTelemetry)(chatSDK, dispatch);
|
|
231
229
|
} catch (ex) {
|
|
232
|
-
|
|
233
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
234
|
-
if (ex.message === _Constants.ChatSDKError.WidgetUseOutsideOperatingHour) {
|
|
235
|
-
var _TelemetryTimers$Widg3;
|
|
236
|
-
dispatch({
|
|
237
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_OUTSIDE_OPERATING_HOURS,
|
|
238
|
-
payload: true
|
|
239
|
-
});
|
|
240
|
-
dispatch({
|
|
241
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
242
|
-
payload: _ConversationState.ConversationState.OutOfOffice
|
|
243
|
-
});
|
|
244
|
-
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
245
|
-
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadComplete,
|
|
246
|
-
Description: "Widget load complete. Widget is OOOH.",
|
|
247
|
-
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg3 = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg3 === void 0 ? void 0 : _TelemetryTimers$Widg3.milliSecondsElapsed
|
|
248
|
-
});
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
252
|
-
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
253
|
-
ExceptionDetails: {
|
|
254
|
-
Exception: `Widget load Failed: ${ex}`
|
|
255
|
-
},
|
|
256
|
-
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg4 = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg4 === void 0 ? void 0 : _TelemetryTimers$Widg4.milliSecondsElapsed
|
|
257
|
-
});
|
|
258
|
-
_NotificationHandler.NotificationHandler.notifyError(_NotificationScenarios.NotificationScenarios.Connection, "Start Chat Failed: " + ex);
|
|
259
|
-
dispatch({
|
|
260
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_START_CHAT_FAILING,
|
|
261
|
-
payload: true
|
|
262
|
-
});
|
|
263
|
-
if (!hideErrorUIPane) {
|
|
264
|
-
// Set app state to failing start chat if hideErrorUI is not turned on
|
|
265
|
-
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
266
|
-
Event: _TelemetryConstants.TelemetryEvent.ErrorUIPaneLoaded,
|
|
267
|
-
Description: "Error UI Pane Loaded"
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
// Show the loading pane in other cases for failure, this will help for both hideStartChatButton case
|
|
271
|
-
dispatch({
|
|
272
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
273
|
-
payload: _ConversationState.ConversationState.Loading
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
// If sessionInit was successful but LCW startchat failed due to some reason e.g adapter didn't load
|
|
277
|
-
// we need to directly endChat to avoid leaving ghost chats in OC, not disturbing any other UI state
|
|
278
|
-
if (isStartChatSuccessful === true) {
|
|
279
|
-
await forceEndChat(chatSDK);
|
|
280
|
-
}
|
|
230
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, chatSDK, props, ex, isStartChatSuccessful);
|
|
281
231
|
} finally {
|
|
282
232
|
optionalParams = {};
|
|
283
233
|
widgetInstanceId = "";
|
|
@@ -286,21 +236,10 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
286
236
|
|
|
287
237
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
288
238
|
exports.initStartChat = initStartChat;
|
|
289
|
-
const forceEndChat = async chatSDK => {
|
|
290
|
-
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
291
|
-
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
292
|
-
ExceptionDetails: {
|
|
293
|
-
Exception: "SessionInit was successful, but widget load failed."
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat();
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
300
239
|
const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
301
|
-
var _state$
|
|
240
|
+
var _state$appStates2, _persistedState$domai6, _persistedState$appSt;
|
|
302
241
|
// By pass this function in case of popout chat
|
|
303
|
-
if ((state === null || state === void 0 ? void 0 : (_state$
|
|
242
|
+
if ((state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.hideStartChatButton) === true) {
|
|
304
243
|
return false;
|
|
305
244
|
}
|
|
306
245
|
const persistedState = (0, _utils.getStateFromCache)((0, _utils.getWidgetCacheIdfromProps)(props));
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.logWidgetLoadComplete = exports.handleStartChatError = void 0;
|
|
7
|
+
var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
|
|
8
|
+
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
9
|
+
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
10
|
+
var _TelemetryManager = require("../../../common/telemetry/TelemetryManager");
|
|
11
|
+
var _ConversationState = require("../../../contexts/common/ConversationState");
|
|
12
|
+
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
13
|
+
var _endChat = require("./endChat");
|
|
14
|
+
var _DataStoreManager = require("../../../common/contextDataStore/DataStoreManager");
|
|
15
|
+
var _utils = require("../../../common/utils");
|
|
16
|
+
var _Constants = require("../../../common/Constants");
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
const handleStartChatError = (dispatch, chatSDK, props, ex, isStartChatSuccessful) => {
|
|
19
|
+
var _props$controlProps;
|
|
20
|
+
if (!ex) {
|
|
21
|
+
logWidgetLoadFailed();
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Handle internal or misc errors
|
|
26
|
+
if (ex.message === _Constants.WidgetLoadCustomErrorString.AuthenticationFailedErrorString || ex.message === _Constants.WidgetLoadCustomErrorString.NetworkErrorString) {
|
|
27
|
+
logWidgetLoadCompleteWithError(ex);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Handle ChatSDK errors
|
|
31
|
+
if (ex instanceof _omnichannelChatSdk.ChatSDKError) {
|
|
32
|
+
switch (ex.message) {
|
|
33
|
+
case _omnichannelChatSdk.ChatSDKErrorName.WidgetUseOutsideOperatingHour:
|
|
34
|
+
handleWidgetUseOutsideOperatingHour(dispatch);
|
|
35
|
+
return;
|
|
36
|
+
case _omnichannelChatSdk.ChatSDKErrorName.PersistentChatConversationRetrievalFailure:
|
|
37
|
+
handlePersistentChatConversationRetrievalFailure(ex);
|
|
38
|
+
break;
|
|
39
|
+
case _omnichannelChatSdk.ChatSDKErrorName.ConversationInitializationFailure:
|
|
40
|
+
handleConversationInitializationFailure(ex);
|
|
41
|
+
break;
|
|
42
|
+
case _omnichannelChatSdk.ChatSDKErrorName.ChatTokenRetrievalFailure:
|
|
43
|
+
handleChatTokenRetrievalFailure(ex);
|
|
44
|
+
break;
|
|
45
|
+
case _omnichannelChatSdk.ChatSDKErrorName.UninitializedChatSDK:
|
|
46
|
+
handleUninitializedChatSDK(ex);
|
|
47
|
+
break;
|
|
48
|
+
case _omnichannelChatSdk.ChatSDKErrorName.InvalidConversation:
|
|
49
|
+
case _omnichannelChatSdk.ChatSDKErrorName.ClosedConversation:
|
|
50
|
+
handleInvalidOrClosedConversation(dispatch, chatSDK, props, ex);
|
|
51
|
+
return;
|
|
52
|
+
default:
|
|
53
|
+
logWidgetLoadFailed(ex);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Show the error UI pane
|
|
58
|
+
dispatch({
|
|
59
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_START_CHAT_FAILING,
|
|
60
|
+
payload: true
|
|
61
|
+
});
|
|
62
|
+
if (!(props !== null && props !== void 0 && (_props$controlProps = props.controlProps) !== null && _props$controlProps !== void 0 && _props$controlProps.hideErrorUIPane)) {
|
|
63
|
+
// Set app state to failing start chat if hideErrorUI is not turned on
|
|
64
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
65
|
+
Event: _TelemetryConstants.TelemetryEvent.ErrorUIPaneLoaded,
|
|
66
|
+
Description: "Error UI Pane Loaded"
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
// Show the loading pane in other cases for failure, this will help for both hideStartChatButton case
|
|
70
|
+
dispatch({
|
|
71
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
72
|
+
payload: _ConversationState.ConversationState.Loading
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// If sessionInit was successful but LCW startchat failed due to some reason e.g adapter didn't load
|
|
76
|
+
// we need to directly endChat to avoid leaving ghost chats in OC, not disturbing any other UI state
|
|
77
|
+
if (isStartChatSuccessful === true) {
|
|
78
|
+
forceEndChat(chatSDK);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
exports.handleStartChatError = handleStartChatError;
|
|
82
|
+
const logWidgetLoadFailed = ex => {
|
|
83
|
+
var _TelemetryTimers$Widg;
|
|
84
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
85
|
+
const exDetails = {
|
|
86
|
+
Exception: `Widget load complete with error: ${ex}`
|
|
87
|
+
};
|
|
88
|
+
if (ex !== null && ex !== void 0 && ex.httpResponseStatusCode) {
|
|
89
|
+
exDetails.HttpResponseStatusCode = ex.httpResponseStatusCode;
|
|
90
|
+
}
|
|
91
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
92
|
+
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
93
|
+
ExceptionDetails: exDetails,
|
|
94
|
+
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg === void 0 ? void 0 : _TelemetryTimers$Widg.milliSecondsElapsed
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
const logWidgetLoadComplete = additionalMessage => {
|
|
98
|
+
var _TelemetryTimers$Widg2;
|
|
99
|
+
let descriptionString = "Widget load complete";
|
|
100
|
+
if (additionalMessage) {
|
|
101
|
+
descriptionString += `. ${additionalMessage}`;
|
|
102
|
+
}
|
|
103
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
104
|
+
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadComplete,
|
|
105
|
+
Description: descriptionString,
|
|
106
|
+
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg2 = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg2 === void 0 ? void 0 : _TelemetryTimers$Widg2.milliSecondsElapsed
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
exports.logWidgetLoadComplete = logWidgetLoadComplete;
|
|
110
|
+
const logWidgetLoadCompleteWithError = ex => {
|
|
111
|
+
var _TelemetryTimers$Widg3;
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
113
|
+
const exDetails = {
|
|
114
|
+
Exception: `Widget load complete with error: ${ex}`
|
|
115
|
+
};
|
|
116
|
+
if (ex !== null && ex !== void 0 && ex.httpResponseStatusCode) {
|
|
117
|
+
exDetails.HttpResponseStatusCode = ex.httpResponseStatusCode;
|
|
118
|
+
}
|
|
119
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.WARN, {
|
|
120
|
+
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadComplete,
|
|
121
|
+
Description: "Widget load complete with error",
|
|
122
|
+
ExceptionDetails: exDetails,
|
|
123
|
+
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg3 = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg3 === void 0 ? void 0 : _TelemetryTimers$Widg3.milliSecondsElapsed
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
128
|
+
const forceEndChat = chatSDK => {
|
|
129
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
130
|
+
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
131
|
+
ExceptionDetails: {
|
|
132
|
+
Exception: "SessionInit was successful, but widget load failed."
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat();
|
|
136
|
+
};
|
|
137
|
+
const handleWidgetUseOutsideOperatingHour = dispatch => {
|
|
138
|
+
dispatch({
|
|
139
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_OUTSIDE_OPERATING_HOURS,
|
|
140
|
+
payload: true
|
|
141
|
+
});
|
|
142
|
+
dispatch({
|
|
143
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
144
|
+
payload: _ConversationState.ConversationState.OutOfOffice
|
|
145
|
+
});
|
|
146
|
+
logWidgetLoadComplete(_Constants.WidgetLoadTelemetryMessage.OOOHMessage);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
150
|
+
const handlePersistentChatConversationRetrievalFailure = ex => {
|
|
151
|
+
if (ex.httpResponseStatusCode === 400) {
|
|
152
|
+
logWidgetLoadFailed(ex);
|
|
153
|
+
} else {
|
|
154
|
+
logWidgetLoadCompleteWithError(ex);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
159
|
+
const handleConversationInitializationFailure = ex => {
|
|
160
|
+
if (ex.httpResponseStatusCode === 400) {
|
|
161
|
+
logWidgetLoadFailed(ex);
|
|
162
|
+
} else {
|
|
163
|
+
logWidgetLoadCompleteWithError(ex);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
168
|
+
const handleChatTokenRetrievalFailure = ex => {
|
|
169
|
+
if (ex.httpResponseStatusCode === 400) {
|
|
170
|
+
logWidgetLoadFailed(ex);
|
|
171
|
+
} else {
|
|
172
|
+
logWidgetLoadCompleteWithError(ex);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
177
|
+
const handleUninitializedChatSDK = ex => {
|
|
178
|
+
logWidgetLoadCompleteWithError(ex);
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
182
|
+
const handleInvalidOrClosedConversation = (dispatch, chatSDK, props, ex) => {
|
|
183
|
+
var _DataStoreManager$cli;
|
|
184
|
+
logWidgetLoadCompleteWithError(ex);
|
|
185
|
+
|
|
186
|
+
// Reset all internal states
|
|
187
|
+
(0, _endChat.callingStateCleanUp)(dispatch);
|
|
188
|
+
(0, _endChat.endChatStateCleanUp)(dispatch);
|
|
189
|
+
(0, _endChat.closeChatStateCleanUp)(dispatch);
|
|
190
|
+
(0, _endChat.chatSDKStateCleanUp)(chatSDK);
|
|
191
|
+
(_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData((0, _utils.getWidgetCacheIdfromProps)(props));
|
|
192
|
+
|
|
193
|
+
// Starts new chat
|
|
194
|
+
dispatch({
|
|
195
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
196
|
+
payload: _ConversationState.ConversationState.Closed
|
|
197
|
+
});
|
|
198
|
+
};
|