@microsoft/omnichannel-chat-widget 1.5.1-main.c3533cf → 1.5.1-main.ee4453c
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 +15 -8
- package/lib/cjs/common/telemetry/TelemetryConstants.js +1 -2
- package/lib/cjs/common/utils.js +2 -1
- package/lib/cjs/components/livechatwidget/common/endChat.js +16 -4
- package/lib/cjs/components/livechatwidget/common/startChat.js +8 -82
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +205 -0
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.spec.js +282 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +12 -13
- package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +1 -1
- package/lib/cjs/components/startchaterrorpanestateful/StartChatErrorPaneStateful.js +68 -0
- package/lib/cjs/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneGeneralStyleProps.js +17 -0
- package/lib/cjs/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneIconImageProps.js +17 -0
- package/lib/cjs/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneIconStyleProps.js +15 -0
- package/lib/cjs/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneSubtitleStyleProps.js +17 -0
- package/lib/cjs/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneTitleStyleProps.js +17 -0
- package/lib/cjs/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneControlProps.js +1 -0
- package/lib/cjs/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneProps.js +1 -0
- package/lib/cjs/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneStyleProps.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +2 -11
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.spec.js +1 -1
- package/lib/cjs/contexts/common/ConversationState.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +1 -0
- package/lib/cjs/controller/componentController.js +5 -1
- package/lib/esm/common/Constants.js +11 -6
- package/lib/esm/common/telemetry/TelemetryConstants.js +1 -2
- package/lib/esm/common/utils.js +3 -2
- package/lib/esm/components/livechatwidget/common/endChat.js +14 -3
- package/lib/esm/components/livechatwidget/common/startChat.js +9 -83
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +198 -0
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.spec.js +280 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +14 -15
- package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +1 -1
- package/lib/esm/components/startchaterrorpanestateful/StartChatErrorPaneStateful.js +57 -0
- package/lib/esm/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneGeneralStyleProps.js +10 -0
- package/lib/esm/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneIconImageProps.js +10 -0
- package/lib/esm/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneIconStyleProps.js +8 -0
- package/lib/esm/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneSubtitleStyleProps.js +10 -0
- package/lib/esm/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneTitleStyleProps.js +10 -0
- package/lib/esm/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneControlProps.js +1 -0
- package/lib/esm/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneProps.js +1 -0
- package/lib/esm/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneStyleProps.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +2 -11
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.spec.js +1 -1
- package/lib/esm/contexts/common/ConversationState.js +1 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +1 -0
- package/lib/esm/controller/componentController.js +3 -0
- package/lib/types/common/Constants.d.ts +13 -4
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +1 -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/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetComponentOverrides.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +1 -1
- package/lib/types/components/startchaterrorpanestateful/StartChatErrorPaneStateful.d.ts +3 -0
- package/lib/types/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneGeneralStyleProps.d.ts +2 -0
- package/lib/types/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneIconImageProps.d.ts +2 -0
- package/lib/types/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneIconStyleProps.d.ts +2 -0
- package/lib/types/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneSubtitleStyleProps.d.ts +2 -0
- package/lib/types/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneTitleStyleProps.d.ts +2 -0
- package/lib/types/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneClassNames.d.ts +5 -0
- package/lib/types/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneComponentOverrides.d.ts +6 -0
- package/lib/types/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneControlProps.d.ts +10 -0
- package/lib/types/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneProps.d.ts +8 -0
- package/lib/types/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneStyleProps.d.ts +10 -0
- package/lib/types/contexts/common/ConversationState.d.ts +2 -1
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
- package/lib/types/controller/componentController.d.ts +1 -0
- package/package.json +3 -3
- package/lib/types/components/loadingpanestateful/interfaces/IStartChatErrorPaneControlProps.d.ts +0 -4
- package/lib/types/components/loadingpanestateful/interfaces/IStartChatErrorPaneProps.d.ts +0 -4
- /package/lib/cjs/components/{loadingpanestateful/interfaces/IStartChatErrorPaneControlProps.js → startchaterrorpanestateful/interfaces/IStartChatErrorPaneClassNames.js} +0 -0
- /package/lib/cjs/components/{loadingpanestateful/interfaces/IStartChatErrorPaneProps.js → startchaterrorpanestateful/interfaces/IStartChatErrorPaneComponentOverrides.js} +0 -0
- /package/lib/esm/components/{loadingpanestateful/interfaces/IStartChatErrorPaneControlProps.js → startchaterrorpanestateful/interfaces/IStartChatErrorPaneClassNames.js} +0 -0
- /package/lib/esm/components/{loadingpanestateful/interfaces/IStartChatErrorPaneProps.js → startchaterrorpanestateful/interfaces/IStartChatErrorPaneComponentOverrides.js} +0 -0
|
@@ -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.StartChatErrorPaneConstants = 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) {
|
|
@@ -280,6 +274,11 @@ _defineProperty(NotificationPaneConstants, "IconText", "Notification Icon");
|
|
|
280
274
|
_defineProperty(NotificationPaneConstants, "ChatDisconnectTitleText", "Chat disconnected");
|
|
281
275
|
_defineProperty(NotificationPaneConstants, "ChatDisconnectSubtitleText", "For additional assistance, please close the chat and try again.");
|
|
282
276
|
_defineProperty(NotificationPaneConstants, "ChromeCloseIconName", "ChromeClose");
|
|
277
|
+
class StartChatErrorPaneConstants {}
|
|
278
|
+
exports.StartChatErrorPaneConstants = StartChatErrorPaneConstants;
|
|
279
|
+
_defineProperty(StartChatErrorPaneConstants, "DefaultStartChatErrorPaneId", "oc-lcw-start-chat-error-pane");
|
|
280
|
+
_defineProperty(StartChatErrorPaneConstants, "DefaultStartChatErrorTitleText", "We are unable to load chat at this time.");
|
|
281
|
+
_defineProperty(StartChatErrorPaneConstants, "DefaultStartChatErrorSubtitleText", "Please try again later.");
|
|
283
282
|
class AriaTelemetryConstants {}
|
|
284
283
|
exports.AriaTelemetryConstants = AriaTelemetryConstants;
|
|
285
284
|
// Aria Endpoint for different environment types.
|
|
@@ -294,4 +293,12 @@ _defineProperty(AriaTelemetryConstants, "MOONCAKE_ENDPOINT", "");
|
|
|
294
293
|
_defineProperty(AriaTelemetryConstants, "Public", "Public");
|
|
295
294
|
_defineProperty(AriaTelemetryConstants, "EU", "Europe");
|
|
296
295
|
// 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"]);
|
|
296
|
+
_defineProperty(AriaTelemetryConstants, "lcwEUDomainNames", ["crm4.omnichannelengagementhub.com", "crm12.omnichannelengagementhub.com", "crm16.omnichannelengagementhub.com", "crm17.omnichannelengagementhub.com", "crm19.omnichannelengagementhub.com"]);
|
|
297
|
+
class WidgetLoadTelemetryMessage {}
|
|
298
|
+
exports.WidgetLoadTelemetryMessage = WidgetLoadTelemetryMessage;
|
|
299
|
+
_defineProperty(WidgetLoadTelemetryMessage, "OOOHMessage", "Widget is OOOH");
|
|
300
|
+
_defineProperty(WidgetLoadTelemetryMessage, "PersistedStateRetrievedMessage", "Persisted state retrieved");
|
|
301
|
+
class WidgetLoadCustomErrorString {}
|
|
302
|
+
exports.WidgetLoadCustomErrorString = WidgetLoadCustomErrorString;
|
|
303
|
+
_defineProperty(WidgetLoadCustomErrorString, "AuthenticationFailedErrorString", "Authentication was not successful");
|
|
304
|
+
_defineProperty(WidgetLoadCustomErrorString, "NetworkErrorString", "Network Error");
|
|
@@ -133,10 +133,10 @@ 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";
|
|
139
|
+
TelemetryEvent["StartChatErrorPaneLoaded"] = "StartChatErrorPaneLoaded";
|
|
140
140
|
TelemetryEvent["EmailTranscriptLoaded"] = "EmailTranscriptLoaded";
|
|
141
141
|
TelemetryEvent["OutOfOfficePaneLoaded"] = "OutOfOfficePaneLoaded";
|
|
142
142
|
TelemetryEvent["ConfirmationPaneLoaded"] = "ConfirmationPaneLoaded";
|
|
@@ -250,7 +250,6 @@ class TelemetryConstants {
|
|
|
250
250
|
case TelemetryEvent.EmailTranscriptSent:
|
|
251
251
|
case TelemetryEvent.EmailTranscriptFailed:
|
|
252
252
|
case TelemetryEvent.DownloadTranscriptFailed:
|
|
253
|
-
case TelemetryEvent.IC3ThreadUpdateEventReceived:
|
|
254
253
|
case TelemetryEvent.ConfirmationCancelButtonClicked:
|
|
255
254
|
case TelemetryEvent.ConfirmationConfirmButtonClicked:
|
|
256
255
|
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: {
|
|
@@ -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,7 +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");
|
|
24
|
-
var
|
|
22
|
+
var _startChatErrorHandler = require("./startChatErrorHandler");
|
|
23
|
+
var _endChat = require("./endChat");
|
|
25
24
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
25
|
let optionalParams = {};
|
|
27
26
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -115,19 +114,15 @@ const setPreChatAndInitiateChat = async (chatSDK, dispatch, setAdapter, isProact
|
|
|
115
114
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
116
115
|
exports.setPreChatAndInitiateChat = setPreChatAndInitiateChat;
|
|
117
116
|
const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params, persistedState) => {
|
|
118
|
-
var _props$controlProps2;
|
|
119
117
|
let isStartChatSuccessful = false;
|
|
120
118
|
const chatConfig = props === null || props === void 0 ? void 0 : props.chatConfig;
|
|
121
119
|
const getAuthToken = props === null || props === void 0 ? void 0 : props.getAuthToken;
|
|
122
|
-
const hideErrorUIPane = props === null || props === void 0 ? void 0 : (_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.hideErrorUIPane;
|
|
123
120
|
if ((state === null || state === void 0 ? void 0 : state.appStates.conversationState) === _ConversationState.ConversationState.Closed) {
|
|
124
121
|
// Preventive reset to avoid starting chat with previous requestId which could potentially cause problems
|
|
125
|
-
|
|
126
|
-
chatSDK.chatToken = {};
|
|
127
|
-
chatSDK.reconnectId = null;
|
|
122
|
+
(0, _endChat.chatSDKStateCleanUp)(chatSDK);
|
|
128
123
|
}
|
|
129
124
|
try {
|
|
130
|
-
var _state$appStates, _newAdapter$activity
|
|
125
|
+
var _state$appStates, _newAdapter$activity$;
|
|
131
126
|
// Clear disconnect state on start chat
|
|
132
127
|
(state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.chatDisconnectEventReceived) && dispatch({
|
|
133
128
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_DISCONNECT_EVENT_RECEIVED,
|
|
@@ -145,8 +140,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
145
140
|
// set auth token to chat sdk before start chat
|
|
146
141
|
const authSuccess = await (0, _authHelper.handleAuthentication)(chatSDK, chatConfig, getAuthToken);
|
|
147
142
|
if (!authSuccess) {
|
|
148
|
-
|
|
149
|
-
throw new Error("Authentication was not successful");
|
|
143
|
+
throw new Error(_Constants.WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
|
|
150
144
|
}
|
|
151
145
|
}
|
|
152
146
|
|
|
@@ -209,16 +203,11 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
209
203
|
});
|
|
210
204
|
}
|
|
211
205
|
if (persistedState) {
|
|
212
|
-
var _TelemetryTimers$Widg;
|
|
213
206
|
dispatch({
|
|
214
207
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_STATE,
|
|
215
208
|
payload: persistedState
|
|
216
209
|
});
|
|
217
|
-
|
|
218
|
-
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadComplete,
|
|
219
|
-
Description: "Widget load complete. Persisted state retrieved",
|
|
220
|
-
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
|
|
221
|
-
});
|
|
210
|
+
(0, _startChatErrorHandler.logWidgetLoadComplete)(_Constants.WidgetLoadTelemetryMessage.PersistedStateRetrievedMessage);
|
|
222
211
|
await (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch, true);
|
|
223
212
|
return;
|
|
224
213
|
}
|
|
@@ -229,11 +218,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
229
218
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
230
219
|
payload: liveChatContext
|
|
231
220
|
});
|
|
232
|
-
|
|
233
|
-
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadComplete,
|
|
234
|
-
Description: "Widget load complete",
|
|
235
|
-
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
|
|
236
|
-
});
|
|
221
|
+
(0, _startChatErrorHandler.logWidgetLoadComplete)();
|
|
237
222
|
|
|
238
223
|
// Set post chat context in state
|
|
239
224
|
// Commenting this for now as post chat context is fetched during end chat
|
|
@@ -242,55 +227,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
242
227
|
// Updating chat session detail for telemetry
|
|
243
228
|
await (0, _updateSessionDataForTelemetry.updateSessionDataForTelemetry)(chatSDK, dispatch);
|
|
244
229
|
} catch (ex) {
|
|
245
|
-
|
|
246
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
247
|
-
if (ex.message === _Constants.ChatSDKError.WidgetUseOutsideOperatingHour) {
|
|
248
|
-
var _TelemetryTimers$Widg3;
|
|
249
|
-
dispatch({
|
|
250
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_OUTSIDE_OPERATING_HOURS,
|
|
251
|
-
payload: true
|
|
252
|
-
});
|
|
253
|
-
dispatch({
|
|
254
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
255
|
-
payload: _ConversationState.ConversationState.OutOfOffice
|
|
256
|
-
});
|
|
257
|
-
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
258
|
-
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadComplete,
|
|
259
|
-
Description: "Widget load complete. Widget is OOOH.",
|
|
260
|
-
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
|
|
261
|
-
});
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
265
|
-
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
266
|
-
ExceptionDetails: {
|
|
267
|
-
Exception: `Widget load Failed: ${ex}`
|
|
268
|
-
},
|
|
269
|
-
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
|
|
270
|
-
});
|
|
271
|
-
_NotificationHandler.NotificationHandler.notifyError(_NotificationScenarios.NotificationScenarios.Connection, "Start Chat Failed: " + ex);
|
|
272
|
-
dispatch({
|
|
273
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_START_CHAT_FAILING,
|
|
274
|
-
payload: true
|
|
275
|
-
});
|
|
276
|
-
if (!hideErrorUIPane) {
|
|
277
|
-
// Set app state to failing start chat if hideErrorUI is not turned on
|
|
278
|
-
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
279
|
-
Event: _TelemetryConstants.TelemetryEvent.ErrorUIPaneLoaded,
|
|
280
|
-
Description: "Error UI Pane Loaded"
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
// Show the loading pane in other cases for failure, this will help for both hideStartChatButton case
|
|
284
|
-
dispatch({
|
|
285
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
286
|
-
payload: _ConversationState.ConversationState.Loading
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
// If sessionInit was successful but LCW startchat failed due to some reason e.g adapter didn't load
|
|
290
|
-
// we need to directly endChat to avoid leaving ghost chats in OC, not disturbing any other UI state
|
|
291
|
-
if (isStartChatSuccessful === true) {
|
|
292
|
-
await forceEndChat(chatSDK);
|
|
293
|
-
}
|
|
230
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, chatSDK, props, ex, isStartChatSuccessful);
|
|
294
231
|
} finally {
|
|
295
232
|
optionalParams = {};
|
|
296
233
|
widgetInstanceId = "";
|
|
@@ -299,17 +236,6 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
299
236
|
|
|
300
237
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
301
238
|
exports.initStartChat = initStartChat;
|
|
302
|
-
const forceEndChat = async chatSDK => {
|
|
303
|
-
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
304
|
-
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
305
|
-
ExceptionDetails: {
|
|
306
|
-
Exception: "SessionInit was successful, but widget load failed."
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat();
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
313
239
|
const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
314
240
|
var _state$appStates2, _persistedState$domai6, _persistedState$appSt;
|
|
315
241
|
// By pass this function in case of popout chat
|
|
@@ -0,0 +1,205 @@
|
|
|
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
|
+
// New flow of leveraging ConversationState.Error
|
|
64
|
+
// Set app state to failing start chat if hideErrorUI is not turned on
|
|
65
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
66
|
+
Event: _TelemetryConstants.TelemetryEvent.ErrorUIPaneLoaded,
|
|
67
|
+
Description: "Error UI Pane Loaded"
|
|
68
|
+
});
|
|
69
|
+
dispatch({
|
|
70
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
71
|
+
payload: _ConversationState.ConversationState.Error
|
|
72
|
+
});
|
|
73
|
+
} else {
|
|
74
|
+
// Old flow of leveraging ConversationState.Loading
|
|
75
|
+
// Show the loading pane in other cases for failure, this will help for both hideStartChatButton case
|
|
76
|
+
dispatch({
|
|
77
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
78
|
+
payload: _ConversationState.ConversationState.Loading
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// If sessionInit was successful but LCW startchat failed due to some reason e.g adapter didn't load
|
|
83
|
+
// we need to directly endChat to avoid leaving ghost chats in OC, not disturbing any other UI state
|
|
84
|
+
if (isStartChatSuccessful === true) {
|
|
85
|
+
forceEndChat(chatSDK);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
exports.handleStartChatError = handleStartChatError;
|
|
89
|
+
const logWidgetLoadFailed = ex => {
|
|
90
|
+
var _TelemetryTimers$Widg;
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
|
+
const exDetails = {
|
|
93
|
+
Exception: `Widget load complete with error: ${ex}`
|
|
94
|
+
};
|
|
95
|
+
if (ex !== null && ex !== void 0 && ex.httpResponseStatusCode) {
|
|
96
|
+
exDetails.HttpResponseStatusCode = ex.httpResponseStatusCode;
|
|
97
|
+
}
|
|
98
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
99
|
+
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
100
|
+
ExceptionDetails: exDetails,
|
|
101
|
+
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
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
const logWidgetLoadComplete = additionalMessage => {
|
|
105
|
+
var _TelemetryTimers$Widg2;
|
|
106
|
+
let descriptionString = "Widget load complete";
|
|
107
|
+
if (additionalMessage) {
|
|
108
|
+
descriptionString += `. ${additionalMessage}`;
|
|
109
|
+
}
|
|
110
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
111
|
+
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadComplete,
|
|
112
|
+
Description: descriptionString,
|
|
113
|
+
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
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
exports.logWidgetLoadComplete = logWidgetLoadComplete;
|
|
117
|
+
const logWidgetLoadCompleteWithError = ex => {
|
|
118
|
+
var _TelemetryTimers$Widg3;
|
|
119
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
120
|
+
const exDetails = {
|
|
121
|
+
Exception: `Widget load complete with error: ${ex}`
|
|
122
|
+
};
|
|
123
|
+
if (ex !== null && ex !== void 0 && ex.httpResponseStatusCode) {
|
|
124
|
+
exDetails.HttpResponseStatusCode = ex.httpResponseStatusCode;
|
|
125
|
+
}
|
|
126
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.WARN, {
|
|
127
|
+
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadComplete,
|
|
128
|
+
Description: "Widget load complete with error",
|
|
129
|
+
ExceptionDetails: exDetails,
|
|
130
|
+
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
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
135
|
+
const forceEndChat = chatSDK => {
|
|
136
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
137
|
+
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
138
|
+
ExceptionDetails: {
|
|
139
|
+
Exception: "SessionInit was successful, but widget load failed."
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat();
|
|
143
|
+
};
|
|
144
|
+
const handleWidgetUseOutsideOperatingHour = dispatch => {
|
|
145
|
+
dispatch({
|
|
146
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_OUTSIDE_OPERATING_HOURS,
|
|
147
|
+
payload: true
|
|
148
|
+
});
|
|
149
|
+
dispatch({
|
|
150
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
151
|
+
payload: _ConversationState.ConversationState.OutOfOffice
|
|
152
|
+
});
|
|
153
|
+
logWidgetLoadComplete(_Constants.WidgetLoadTelemetryMessage.OOOHMessage);
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
157
|
+
const handlePersistentChatConversationRetrievalFailure = ex => {
|
|
158
|
+
if (ex.httpResponseStatusCode === 400) {
|
|
159
|
+
logWidgetLoadFailed(ex);
|
|
160
|
+
} else {
|
|
161
|
+
logWidgetLoadCompleteWithError(ex);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
166
|
+
const handleConversationInitializationFailure = ex => {
|
|
167
|
+
if (ex.httpResponseStatusCode === 400) {
|
|
168
|
+
logWidgetLoadFailed(ex);
|
|
169
|
+
} else {
|
|
170
|
+
logWidgetLoadCompleteWithError(ex);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
175
|
+
const handleChatTokenRetrievalFailure = ex => {
|
|
176
|
+
if (ex.httpResponseStatusCode === 400) {
|
|
177
|
+
logWidgetLoadFailed(ex);
|
|
178
|
+
} else {
|
|
179
|
+
logWidgetLoadCompleteWithError(ex);
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
184
|
+
const handleUninitializedChatSDK = ex => {
|
|
185
|
+
logWidgetLoadCompleteWithError(ex);
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
189
|
+
const handleInvalidOrClosedConversation = (dispatch, chatSDK, props, ex) => {
|
|
190
|
+
var _DataStoreManager$cli;
|
|
191
|
+
logWidgetLoadCompleteWithError(ex);
|
|
192
|
+
|
|
193
|
+
// Reset all internal states
|
|
194
|
+
(0, _endChat.callingStateCleanUp)(dispatch);
|
|
195
|
+
(0, _endChat.endChatStateCleanUp)(dispatch);
|
|
196
|
+
(0, _endChat.closeChatStateCleanUp)(dispatch);
|
|
197
|
+
(0, _endChat.chatSDKStateCleanUp)(chatSDK);
|
|
198
|
+
(_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData((0, _utils.getWidgetCacheIdfromProps)(props));
|
|
199
|
+
|
|
200
|
+
// Starts new chat
|
|
201
|
+
dispatch({
|
|
202
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
203
|
+
payload: _ConversationState.ConversationState.Closed
|
|
204
|
+
});
|
|
205
|
+
};
|